Fix up names from RenderTargetContext to SurfaceDrawContext.
RenderTargetContext was renamed several months ago; this CL just fixes up a few related names which hadn't yet updated yet. Change-Id: I59a6ea92fc5d309a9b45a83e3aca6e49cb8d662e Reviewed-on: https://skia-review.googlesource.com/c/skia/+/415745 Auto-Submit: John Stiles <johnstiles@google.com> Commit-Queue: John Stiles <johnstiles@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
bbaf630c76
commit
0fbc6a3bcb
@ -15,23 +15,23 @@
|
||||
// Size of each clear
|
||||
static constexpr int kSize = 64;
|
||||
|
||||
DEF_SIMPLE_GPU_GM(clear_swizzle, ctx, rtCtx, canvas, 6*kSize, 2*kSize) {
|
||||
DEF_SIMPLE_GPU_GM(clear_swizzle, ctx, sdCtx, canvas, 6*kSize, 2*kSize) {
|
||||
if (ctx->abandoned()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto make_offscreen = [&](const SkISize dimensions) {
|
||||
GrSwizzle readSwizzle = GrSwizzle::Concat(rtCtx->readSwizzle(), GrSwizzle{"bgra"});
|
||||
GrSwizzle writeSwizzle = GrSwizzle::Concat(rtCtx->readSwizzle(), GrSwizzle{"bgra"});
|
||||
GrSwizzle readSwizzle = GrSwizzle::Concat(sdCtx->readSwizzle(), GrSwizzle{"bgra"});
|
||||
GrSwizzle writeSwizzle = GrSwizzle::Concat(sdCtx->readSwizzle(), GrSwizzle{"bgra"});
|
||||
return GrSurfaceFillContext::Make(ctx,
|
||||
kPremul_SkAlphaType,
|
||||
rtCtx->colorInfo().refColorSpace(),
|
||||
sdCtx->colorInfo().refColorSpace(),
|
||||
dimensions,
|
||||
SkBackingFit::kExact,
|
||||
rtCtx->asSurfaceProxy()->backendFormat(),
|
||||
sdCtx->asSurfaceProxy()->backendFormat(),
|
||||
/* sample count*/ 1,
|
||||
GrMipmapped::kNo,
|
||||
rtCtx->asSurfaceProxy()->isProtected(),
|
||||
sdCtx->asSurfaceProxy()->isProtected(),
|
||||
readSwizzle,
|
||||
writeSwizzle,
|
||||
kTopLeft_GrSurfaceOrigin,
|
||||
@ -50,7 +50,7 @@ DEF_SIMPLE_GPU_GM(clear_swizzle, ctx, rtCtx, canvas, 6*kSize, 2*kSize) {
|
||||
|
||||
// onscreen for reference
|
||||
for (const auto& c : clears) {
|
||||
rtCtx->clear(c.rect, c.color);
|
||||
sdCtx->clear(c.rect, c.color);
|
||||
}
|
||||
|
||||
// partial clear offscreen
|
||||
@ -58,7 +58,7 @@ DEF_SIMPLE_GPU_GM(clear_swizzle, ctx, rtCtx, canvas, 6*kSize, 2*kSize) {
|
||||
for (const auto& c : clears) {
|
||||
offscreen->clear(c.rect, c.color);
|
||||
}
|
||||
rtCtx->blitTexture(offscreen->readSurfaceView(),
|
||||
sdCtx->blitTexture(offscreen->readSurfaceView(),
|
||||
SkIRect::MakeSize({2*kSize, 2*kSize}),
|
||||
SkIPoint{2*kSize, 0});
|
||||
|
||||
@ -66,7 +66,7 @@ DEF_SIMPLE_GPU_GM(clear_swizzle, ctx, rtCtx, canvas, 6*kSize, 2*kSize) {
|
||||
for (const auto& c : clears) {
|
||||
offscreen = make_offscreen(c.rect.size());
|
||||
offscreen->clear(SkIRect::MakeSize(c.rect.size()), c.color);
|
||||
rtCtx->blitTexture(offscreen->readSurfaceView(),
|
||||
sdCtx->blitTexture(offscreen->readSurfaceView(),
|
||||
SkIRect::MakeSize(offscreen->dimensions()),
|
||||
c.rect.topLeft() + SkIPoint{4*kSize, 0});
|
||||
}
|
||||
|
@ -59,10 +59,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
DEF_SIMPLE_GPU_GM(simple_dsl_test, ctx, rtCtx, canvas, 100, 100) {
|
||||
DEF_SIMPLE_GPU_GM(simple_dsl_test, ctx, sdCtx, canvas, 100, 100) {
|
||||
auto fp = std::make_unique<SimpleDSLEffect>();
|
||||
GrPaint paint;
|
||||
paint.setColorFragmentProcessor(std::move(fp));
|
||||
rtCtx->drawRect(nullptr, std::move(paint), GrAA::kNo, SkMatrix::I(),
|
||||
sdCtx->drawRect(nullptr, std::move(paint), GrAA::kNo, SkMatrix::I(),
|
||||
SkRect::MakeIWH(100, 100));
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ static std::unique_ptr<GrFragmentProcessor> wrap(std::unique_ptr<GrFragmentProce
|
||||
SkUNREACHABLE;
|
||||
}
|
||||
|
||||
DEF_SIMPLE_GPU_GM(fp_sample_chaining, ctx, rtCtx, canvas, 232, 232) {
|
||||
DEF_SIMPLE_GPU_GM(fp_sample_chaining, ctx, sdCtx, canvas, 232, 232) {
|
||||
SkBitmap bmp = make_test_bitmap();
|
||||
|
||||
int x = 10, y = 10;
|
||||
@ -171,7 +171,7 @@ DEF_SIMPLE_GPU_GM(fp_sample_chaining, ctx, rtCtx, canvas, 232, 232) {
|
||||
}
|
||||
GrPaint paint;
|
||||
paint.setColorFragmentProcessor(std::move(fp));
|
||||
rtCtx->drawRect(nullptr, std::move(paint), GrAA::kNo, SkMatrix::Translate(x, y),
|
||||
sdCtx->drawRect(nullptr, std::move(paint), GrAA::kNo, SkMatrix::Translate(x, y),
|
||||
SkRect::MakeIWH(64, 64));
|
||||
nextCol();
|
||||
};
|
||||
|
@ -71,7 +71,7 @@ std::unique_ptr<GrGLSLFragmentProcessor> SampleCoordEffect::onMakeProgramImpl()
|
||||
return std::make_unique<GLSLSampleCoordEffect>();
|
||||
}
|
||||
|
||||
DEF_SIMPLE_GPU_GM_BG(fpcoordinateoverride, ctx, rtCtx, canvas, 512, 512,
|
||||
DEF_SIMPLE_GPU_GM_BG(fpcoordinateoverride, ctx, sdCtx, canvas, 512, 512,
|
||||
ToolUtils::color_to_565(0xFF66AA99)) {
|
||||
SkRect bounds = SkRect::MakeIWH(512, 512);
|
||||
|
||||
@ -88,5 +88,5 @@ DEF_SIMPLE_GPU_GM_BG(fpcoordinateoverride, ctx, rtCtx, canvas, 512, 512,
|
||||
GrPaint grPaint;
|
||||
grPaint.setCoverageFragmentProcessor(std::move(fp));
|
||||
|
||||
rtCtx->addDrawOp(GrFillRectOp::MakeNonAARect(ctx, std::move(grPaint), SkMatrix::I(), bounds));
|
||||
sdCtx->addDrawOp(GrFillRectOp::MakeNonAARect(ctx, std::move(grPaint), SkMatrix::I(), bounds));
|
||||
}
|
||||
|
20
gm/gm.h
20
gm/gm.h
@ -60,31 +60,31 @@ struct GrContextOptions;
|
||||
|
||||
// A Simple GpuGM makes direct GPU calls. Its onDraw hook that includes GPU objects as params, and
|
||||
// is only invoked on GPU configs. Non-GPU configs automatically draw a GPU-only message and abort.
|
||||
#define DEF_SIMPLE_GPU_GM(NAME, GR_CONTEXT, RENDER_TARGET_CONTEXT, CANVAS, W, H) \
|
||||
DEF_SIMPLE_GPU_GM_BG(NAME, GR_CONTEXT, RENDER_TARGET_CONTEXT, CANVAS, W, H, SK_ColorWHITE)
|
||||
#define DEF_SIMPLE_GPU_GM_BG(NAME, GR_CONTEXT, RENDER_TARGET_CONTEXT, CANVAS, W, H, BGCOLOR) \
|
||||
#define DEF_SIMPLE_GPU_GM(NAME, GR_CONTEXT, SURFACE_DRAW_CONTEXT, CANVAS, W, H) \
|
||||
DEF_SIMPLE_GPU_GM_BG(NAME, GR_CONTEXT, SURFACE_DRAW_CONTEXT, CANVAS, W, H, SK_ColorWHITE)
|
||||
#define DEF_SIMPLE_GPU_GM_BG(NAME, GR_CONTEXT, SURFACE_DRAW_CONTEXT, CANVAS, W, H, BGCOLOR) \
|
||||
static void SK_MACRO_CONCAT(NAME,_GM_inner)(GrRecordingContext*, GrSurfaceDrawContext*, \
|
||||
SkCanvas*); \
|
||||
DEF_SIMPLE_GPU_GM_BG_CAN_FAIL(NAME, GR_CONTEXT, RENDER_TARGET_CONTEXT, CANVAS,, W, H, \
|
||||
DEF_SIMPLE_GPU_GM_BG_CAN_FAIL(NAME, GR_CONTEXT, SURFACE_DRAW_CONTEXT, CANVAS,, W, H, \
|
||||
BGCOLOR) { \
|
||||
SK_MACRO_CONCAT(NAME,_GM_inner)(GR_CONTEXT, RENDER_TARGET_CONTEXT, CANVAS); \
|
||||
SK_MACRO_CONCAT(NAME,_GM_inner)(GR_CONTEXT, SURFACE_DRAW_CONTEXT, CANVAS); \
|
||||
return skiagm::DrawResult::kOk; \
|
||||
} \
|
||||
void SK_MACRO_CONCAT(NAME,_GM_inner)( \
|
||||
GrRecordingContext* GR_CONTEXT, GrSurfaceDrawContext* RENDER_TARGET_CONTEXT, \
|
||||
GrRecordingContext* GR_CONTEXT, GrSurfaceDrawContext* SURFACE_DRAW_CONTEXT, \
|
||||
SkCanvas* CANVAS)
|
||||
|
||||
#define DEF_SIMPLE_GPU_GM_CAN_FAIL(NAME, GR_CONTEXT, RENDER_TARGET_CONTEXT, CANVAS, ERR_MSG, W, H) \
|
||||
DEF_SIMPLE_GPU_GM_BG_CAN_FAIL(NAME, GR_CONTEXT, RENDER_TARGET_CONTEXT, CANVAS, \
|
||||
#define DEF_SIMPLE_GPU_GM_CAN_FAIL(NAME, GR_CONTEXT, SURFACE_DRAW_CONTEXT, CANVAS, ERR_MSG, W, H) \
|
||||
DEF_SIMPLE_GPU_GM_BG_CAN_FAIL(NAME, GR_CONTEXT, SURFACE_DRAW_CONTEXT, CANVAS, \
|
||||
ERR_MSG, W, H, SK_ColorWHITE)
|
||||
#define DEF_SIMPLE_GPU_GM_BG_CAN_FAIL(NAME, GR_CONTEXT, RENDER_TARGET_CONTEXT, CANVAS, ERR_MSG, W, \
|
||||
#define DEF_SIMPLE_GPU_GM_BG_CAN_FAIL(NAME, GR_CONTEXT, SURFACE_DRAW_CONTEXT, CANVAS, ERR_MSG, W, \
|
||||
H, BGCOLOR) \
|
||||
static skiagm::DrawResult SK_MACRO_CONCAT(NAME,_GM)( \
|
||||
GrRecordingContext*, GrSurfaceDrawContext*, SkCanvas*, SkString*); \
|
||||
DEF_GM(return new skiagm::SimpleGpuGM(BGCOLOR, SkString(#NAME), {W,H}, \
|
||||
SK_MACRO_CONCAT(NAME,_GM));) \
|
||||
skiagm::DrawResult SK_MACRO_CONCAT(NAME,_GM)( \
|
||||
GrRecordingContext* GR_CONTEXT, GrSurfaceDrawContext* RENDER_TARGET_CONTEXT, \
|
||||
GrRecordingContext* GR_CONTEXT, GrSurfaceDrawContext* SURFACE_DRAW_CONTEXT, \
|
||||
SkCanvas* CANVAS, SkString* ERR_MSG)
|
||||
|
||||
namespace skiagm {
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "tools/Resources.h"
|
||||
#include "tools/ToolUtils.h"
|
||||
|
||||
DEF_SIMPLE_GPU_GM(swizzle, ctx, rtCtx, canvas, 512, 512) {
|
||||
DEF_SIMPLE_GPU_GM(swizzle, ctx, sdCtx, canvas, 512, 512) {
|
||||
SkRect bounds = SkRect::MakeIWH(512, 512);
|
||||
|
||||
SkBitmap bmp;
|
||||
@ -35,5 +35,5 @@ DEF_SIMPLE_GPU_GM(swizzle, ctx, rtCtx, canvas, 512, 512) {
|
||||
GrPaint grPaint;
|
||||
grPaint.setColorFragmentProcessor(std::move(fp));
|
||||
|
||||
rtCtx->addDrawOp(GrFillRectOp::MakeNonAARect(ctx, std::move(grPaint), SkMatrix(), bounds));
|
||||
sdCtx->addDrawOp(GrFillRectOp::MakeNonAARect(ctx, std::move(grPaint), SkMatrix(), bounds));
|
||||
}
|
||||
|
@ -223,7 +223,6 @@ tests_sources = [
|
||||
"$_tests/RectTest.cpp",
|
||||
"$_tests/RefCntTest.cpp",
|
||||
"$_tests/RegionTest.cpp",
|
||||
"$_tests/RenderTargetContextTest.cpp",
|
||||
"$_tests/RepeatedClippedBlurTest.cpp",
|
||||
"$_tests/ResourceAllocatorTest.cpp",
|
||||
"$_tests/ResourceCacheTest.cpp",
|
||||
@ -294,6 +293,7 @@ tests_sources = [
|
||||
"$_tests/StrokerTest.cpp",
|
||||
"$_tests/SubsetPath.cpp",
|
||||
"$_tests/SubsetPath.h",
|
||||
"$_tests/SurfaceDrawContextTest.cpp",
|
||||
"$_tests/SurfaceSemaphoreTest.cpp",
|
||||
"$_tests/SurfaceTest.cpp",
|
||||
"$_tests/SwizzlerTest.cpp",
|
||||
|
@ -161,13 +161,13 @@ static std::unique_ptr<GrSurfaceDrawContext> convolve_gaussian(GrRecordingContex
|
||||
//
|
||||
// Create the sdc with default SkSurfaceProps. Gaussian blurs will soon use a
|
||||
// GrSurfaceFillContext, at which point the SkSurfaceProps won't exist anymore.
|
||||
auto dstRenderTargetContext = GrSurfaceDrawContext::Make(
|
||||
auto dstSurfaceDrawContext = GrSurfaceDrawContext::Make(
|
||||
context, srcColorType, std::move(finalCS), fit, dstBounds.size(), SkSurfaceProps(), 1,
|
||||
GrMipmapped::kNo, srcView.proxy()->isProtected(), srcView.origin());
|
||||
if (!dstRenderTargetContext) {
|
||||
if (!dstSurfaceDrawContext) {
|
||||
return nullptr;
|
||||
}
|
||||
// This represents the translation from 'dstRenderTargetContext' coords to 'srcView' coords.
|
||||
// This represents the translation from 'dstSurfaceDrawContext' coords to 'srcView' coords.
|
||||
auto rtcToSrcOffset = dstBounds.topLeft();
|
||||
|
||||
auto srcBackingBounds = SkIRect::MakeSize(srcView.proxy()->backingStoreDimensions());
|
||||
@ -181,9 +181,9 @@ static std::unique_ptr<GrSurfaceDrawContext> convolve_gaussian(GrRecordingContex
|
||||
!(mode == SkTileMode::kDecal && !context->priv().caps()->clampToBorderSupport());
|
||||
if (!canSplit || canHWTile) {
|
||||
auto dstRect = SkIRect::MakeSize(dstBounds.size());
|
||||
convolve_gaussian_1d(dstRenderTargetContext.get(), std::move(srcView), srcBounds,
|
||||
convolve_gaussian_1d(dstSurfaceDrawContext.get(), std::move(srcView), srcBounds,
|
||||
rtcToSrcOffset, dstRect, srcAlphaType, direction, radius, sigma, mode);
|
||||
return dstRenderTargetContext;
|
||||
return dstSurfaceDrawContext;
|
||||
}
|
||||
|
||||
// 'left' and 'right' are the sub rects of 'srcBounds' where 'mode' must be enforced.
|
||||
@ -235,13 +235,13 @@ static std::unique_ptr<GrSurfaceDrawContext> convolve_gaussian(GrRecordingContex
|
||||
auto convolve = [&](SkIRect rect) {
|
||||
// Transform rect into the render target's coord system.
|
||||
rect.offset(-rtcToSrcOffset);
|
||||
convolve_gaussian_1d(dstRenderTargetContext.get(), srcView, srcBounds, rtcToSrcOffset, rect,
|
||||
convolve_gaussian_1d(dstSurfaceDrawContext.get(), srcView, srcBounds, rtcToSrcOffset, rect,
|
||||
srcAlphaType, direction, radius, sigma, mode);
|
||||
};
|
||||
auto clear = [&](SkIRect rect) {
|
||||
// Transform rect into the render target's coord system.
|
||||
rect.offset(-rtcToSrcOffset);
|
||||
dstRenderTargetContext->clearAtLeast(rect, SK_PMColor4fTRANSPARENT);
|
||||
dstSurfaceDrawContext->clearAtLeast(rect, SK_PMColor4fTRANSPARENT);
|
||||
};
|
||||
|
||||
// Doing mid separately will cause two draws to occur (left and right batch together). At
|
||||
@ -288,12 +288,11 @@ static std::unique_ptr<GrSurfaceDrawContext> convolve_gaussian(GrRecordingContex
|
||||
convolve(right);
|
||||
convolve(mid);
|
||||
}
|
||||
return dstRenderTargetContext;
|
||||
return dstSurfaceDrawContext;
|
||||
}
|
||||
|
||||
// Expand the contents of 'srcRenderTargetContext' to fit in 'dstII'. At this point, we are
|
||||
// expanding an intermediate image, so there's no need to account for a proxy offset from the
|
||||
// original input.
|
||||
// Expand the contents of 'src' to fit in 'dstSize'. At this point, we are expanding an intermediate
|
||||
// image, so there's no need to account for a proxy offset from the original input.
|
||||
static std::unique_ptr<GrSurfaceDrawContext> reexpand(GrRecordingContext* context,
|
||||
std::unique_ptr<GrSurfaceContext> src,
|
||||
const SkRect& srcBounds,
|
||||
@ -312,10 +311,10 @@ static std::unique_ptr<GrSurfaceDrawContext> reexpand(GrRecordingContext* contex
|
||||
|
||||
// Create the sdc with default SkSurfaceProps. Gaussian blurs will soon use a
|
||||
// GrSurfaceFillContext, at which point the SkSurfaceProps won't exist anymore.
|
||||
auto dstRenderTargetContext = GrSurfaceDrawContext::Make(
|
||||
auto dstSurfaceDrawContext = GrSurfaceDrawContext::Make(
|
||||
context, srcColorType, std::move(colorSpace), fit, dstSize, SkSurfaceProps(), 1,
|
||||
GrMipmapped::kNo, srcView.proxy()->isProtected(), srcView.origin());
|
||||
if (!dstRenderTargetContext) {
|
||||
if (!dstSurfaceDrawContext) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -326,10 +325,10 @@ static std::unique_ptr<GrSurfaceDrawContext> reexpand(GrRecordingContext* contex
|
||||
paint.setColorFragmentProcessor(std::move(fp));
|
||||
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
|
||||
dstRenderTargetContext->fillRectToRect(nullptr, std::move(paint), GrAA::kNo, SkMatrix::I(),
|
||||
SkRect::Make(dstSize), srcBounds);
|
||||
dstSurfaceDrawContext->fillRectToRect(nullptr, std::move(paint), GrAA::kNo, SkMatrix::I(),
|
||||
SkRect::Make(dstSize), srcBounds);
|
||||
|
||||
return dstRenderTargetContext;
|
||||
return dstSurfaceDrawContext;
|
||||
}
|
||||
|
||||
static std::unique_ptr<GrSurfaceDrawContext> two_pass_gaussian(GrRecordingContext* context,
|
||||
@ -346,7 +345,7 @@ static std::unique_ptr<GrSurfaceDrawContext> two_pass_gaussian(GrRecordingContex
|
||||
SkTileMode mode,
|
||||
SkBackingFit fit) {
|
||||
SkASSERT(radiusX || radiusY);
|
||||
std::unique_ptr<GrSurfaceDrawContext> dstRenderTargetContext;
|
||||
std::unique_ptr<GrSurfaceDrawContext> dstSurfaceDrawContext;
|
||||
if (radiusX > 0) {
|
||||
SkBackingFit xFit = radiusY > 0 ? SkBackingFit::kApprox : fit;
|
||||
// Expand the dstBounds vertically to produce necessary content for the y-pass. Then we will
|
||||
@ -419,20 +418,20 @@ static std::unique_ptr<GrSurfaceDrawContext> two_pass_gaussian(GrRecordingContex
|
||||
}
|
||||
}
|
||||
}
|
||||
dstRenderTargetContext = convolve_gaussian(
|
||||
dstSurfaceDrawContext = convolve_gaussian(
|
||||
context, std::move(srcView), srcColorType, srcAlphaType, srcBounds, xPassDstBounds,
|
||||
Direction::kX, radiusX, sigmaX, mode, colorSpace, xFit);
|
||||
if (!dstRenderTargetContext) {
|
||||
if (!dstSurfaceDrawContext) {
|
||||
return nullptr;
|
||||
}
|
||||
srcView = dstRenderTargetContext->readSurfaceView();
|
||||
srcView = dstSurfaceDrawContext->readSurfaceView();
|
||||
SkIVector newDstBoundsOffset = dstBounds.topLeft() - xPassDstBounds.topLeft();
|
||||
dstBounds = SkIRect::MakeSize(dstBounds.size()).makeOffset(newDstBoundsOffset);
|
||||
srcBounds = SkIRect::MakeSize(xPassDstBounds.size());
|
||||
}
|
||||
|
||||
if (!radiusY) {
|
||||
return dstRenderTargetContext;
|
||||
return dstSurfaceDrawContext;
|
||||
}
|
||||
|
||||
return convolve_gaussian(context, std::move(srcView), srcColorType, srcAlphaType, srcBounds,
|
||||
|
@ -189,9 +189,9 @@ std::unique_ptr<GrSurfaceDrawContext> GrDynamicAtlas::instantiate(
|
||||
#endif
|
||||
fBackingTexture = std::move(backingTexture);
|
||||
}
|
||||
auto rtc = onFlushRP->makeRenderTargetContext(fTextureProxy, kTextureOrigin, fColorType,
|
||||
nullptr, SkSurfaceProps());
|
||||
if (!rtc) {
|
||||
auto sdc = onFlushRP->makeSurfaceDrawContext(fTextureProxy, kTextureOrigin, fColorType,
|
||||
nullptr, SkSurfaceProps());
|
||||
if (!sdc) {
|
||||
onFlushRP->printWarningMessage(SkStringPrintf(
|
||||
"WARNING: failed to allocate a %ix%i atlas. Some masks will not be drawn.\n",
|
||||
fWidth, fHeight).c_str());
|
||||
@ -199,6 +199,6 @@ std::unique_ptr<GrSurfaceDrawContext> GrDynamicAtlas::instantiate(
|
||||
}
|
||||
|
||||
SkIRect clearRect = SkIRect::MakeSize(fDrawBounds);
|
||||
rtc->clearAtLeast(clearRect, SK_PMColor4fTRANSPARENT);
|
||||
return rtc;
|
||||
sdc->clearAtLeast(clearRect, SK_PMColor4fTRANSPARENT);
|
||||
return sdc;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "src/gpu/GrSurfaceProxy.h"
|
||||
#include "src/gpu/GrTextureResolveRenderTask.h"
|
||||
|
||||
std::unique_ptr<GrSurfaceDrawContext> GrOnFlushResourceProvider::makeRenderTargetContext(
|
||||
std::unique_ptr<GrSurfaceDrawContext> GrOnFlushResourceProvider::makeSurfaceDrawContext(
|
||||
sk_sp<GrSurfaceProxy> proxy, GrSurfaceOrigin origin, GrColorType colorType,
|
||||
sk_sp<SkColorSpace> colorSpace, const SkSurfaceProps& props) {
|
||||
// Since this is at flush time and these won't be allocated for us by the GrResourceAllocator
|
||||
|
@ -62,10 +62,10 @@ public:
|
||||
|
||||
explicit GrOnFlushResourceProvider(GrDrawingManager* drawingMgr) : fDrawingMgr(drawingMgr) {}
|
||||
|
||||
std::unique_ptr<GrSurfaceDrawContext> makeRenderTargetContext(sk_sp<GrSurfaceProxy>,
|
||||
GrSurfaceOrigin, GrColorType,
|
||||
sk_sp<SkColorSpace>,
|
||||
const SkSurfaceProps&);
|
||||
std::unique_ptr<GrSurfaceDrawContext> makeSurfaceDrawContext(sk_sp<GrSurfaceProxy>,
|
||||
GrSurfaceOrigin, GrColorType,
|
||||
sk_sp<SkColorSpace>,
|
||||
const SkSurfaceProps&);
|
||||
|
||||
void addTextureResolveTask(sk_sp<GrTextureProxy>, GrSurfaceProxy::ResolveFlags);
|
||||
|
||||
|
@ -596,7 +596,7 @@ bool GrOpsTask::onExecute(GrOpFlushState* flushState) {
|
||||
stencil->markHasPerformedInitialClear();
|
||||
break;
|
||||
}
|
||||
// renderTargetContexts are required to leave the user stencil bits in a cleared state
|
||||
// SurfaceDrawContexts are required to leave the user stencil bits in a cleared state
|
||||
// once finished, meaning the stencil values will always remain cleared after the
|
||||
// initial clear. Just fall through to reloading the existing (cleared) stencil values
|
||||
// from memory.
|
||||
|
@ -130,7 +130,7 @@ private:
|
||||
//
|
||||
// When requesting kClear: Tilers will load the stencil buffer with a "clear" op; non-tilers
|
||||
// will clear the stencil on first load, and then preserve it on subsequent loads. (Preserving
|
||||
// works because renderTargetContexts are required to leave the user bits in a cleared state
|
||||
// works because SurfaceDrawContexts are required to leave the user bits in a cleared state
|
||||
// once finished.)
|
||||
//
|
||||
// NOTE: initialContent must not be kClear if caps.performStencilClearsAsDraws() is true.
|
||||
|
@ -18,7 +18,7 @@
|
||||
#ifdef SK_DEBUG
|
||||
void GrPathRenderer::StencilPathArgs::validate() const {
|
||||
SkASSERT(fContext);
|
||||
SkASSERT(fRenderTargetContext);
|
||||
SkASSERT(fSurfaceDrawContext);
|
||||
SkASSERT(fClipConservativeBounds);
|
||||
SkASSERT(fViewMatrix);
|
||||
SkASSERT(fShape);
|
||||
@ -46,12 +46,12 @@ bool GrPathRenderer::drawPath(const DrawPathArgs& args) {
|
||||
args.validate();
|
||||
CanDrawPathArgs canArgs;
|
||||
canArgs.fCaps = args.fContext->priv().caps();
|
||||
canArgs.fProxy = args.fRenderTargetContext->asRenderTargetProxy();
|
||||
canArgs.fProxy = args.fSurfaceDrawContext->asRenderTargetProxy();
|
||||
canArgs.fClipConservativeBounds = args.fClipConservativeBounds;
|
||||
canArgs.fViewMatrix = args.fViewMatrix;
|
||||
canArgs.fShape = args.fShape;
|
||||
canArgs.fPaint = &args.fPaint;
|
||||
canArgs.fSurfaceProps = &args.fRenderTargetContext->surfaceProps();
|
||||
canArgs.fSurfaceProps = &args.fSurfaceDrawContext->surfaceProps();
|
||||
canArgs.fAAType = args.fAAType;
|
||||
canArgs.validate();
|
||||
|
||||
@ -110,7 +110,7 @@ void GrPathRenderer::onStencilPath(const StencilPathArgs& args) {
|
||||
DrawPathArgs drawArgs{args.fContext,
|
||||
std::move(paint),
|
||||
&kIncrementStencil,
|
||||
args.fRenderTargetContext,
|
||||
args.fSurfaceDrawContext,
|
||||
nullptr, // clip
|
||||
args.fClipConservativeBounds,
|
||||
args.fViewMatrix,
|
||||
|
@ -116,7 +116,7 @@ public:
|
||||
GrRecordingContext* fContext;
|
||||
GrPaint&& fPaint;
|
||||
const GrUserStencilSettings* fUserStencilSettings;
|
||||
GrSurfaceDrawContext* fRenderTargetContext;
|
||||
GrSurfaceDrawContext* fSurfaceDrawContext;
|
||||
const GrClip* fClip;
|
||||
const SkIRect* fClipConservativeBounds;
|
||||
const SkMatrix* fViewMatrix;
|
||||
@ -127,7 +127,7 @@ public:
|
||||
void validate() const {
|
||||
SkASSERT(fContext);
|
||||
SkASSERT(fUserStencilSettings);
|
||||
SkASSERT(fRenderTargetContext);
|
||||
SkASSERT(fSurfaceDrawContext);
|
||||
SkASSERT(fClipConservativeBounds);
|
||||
SkASSERT(fViewMatrix);
|
||||
SkASSERT(fShape);
|
||||
@ -147,7 +147,7 @@ public:
|
||||
SkDEBUGCODE(StencilPathArgs() { memset(this, 0, sizeof(*this)); }) // For validation.
|
||||
|
||||
GrRecordingContext* fContext;
|
||||
GrSurfaceDrawContext* fRenderTargetContext;
|
||||
GrSurfaceDrawContext* fSurfaceDrawContext;
|
||||
const GrHardClip* fClip;
|
||||
const SkIRect* fClipConservativeBounds;
|
||||
const SkMatrix* fViewMatrix;
|
||||
|
@ -223,7 +223,7 @@ private:
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// return true on success; false on failure
|
||||
bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(args.fRenderTargetContext->auditTrail(),
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(args.fSurfaceDrawContext->auditTrail(),
|
||||
"GrSoftwarePathRenderer::onDrawPath");
|
||||
if (!fProxyProvider) {
|
||||
return false;
|
||||
@ -242,13 +242,13 @@ bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
bool useCache = fAllowCaching && !inverseFilled && args.fViewMatrix->preservesAxisAlignment() &&
|
||||
args.fShape->hasUnstyledKey() && (GrAAType::kCoverage == args.fAAType);
|
||||
|
||||
if (!GetShapeAndClipBounds(args.fRenderTargetContext,
|
||||
if (!GetShapeAndClipBounds(args.fSurfaceDrawContext,
|
||||
args.fClip, *args.fShape,
|
||||
*args.fViewMatrix, &unclippedDevShapeBounds,
|
||||
&clippedDevShapeBounds,
|
||||
&devClipBounds)) {
|
||||
if (inverseFilled) {
|
||||
DrawAroundInvPath(args.fRenderTargetContext, std::move(args.fPaint),
|
||||
DrawAroundInvPath(args.fSurfaceDrawContext, std::move(args.fPaint),
|
||||
*args.fUserStencilSettings, args.fClip, *args.fViewMatrix,
|
||||
devClipBounds, unclippedDevShapeBounds);
|
||||
}
|
||||
@ -263,7 +263,7 @@ bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
int64_t unclippedArea = sk_64_mul(unclippedWidth, unclippedHeight);
|
||||
int64_t clippedArea = sk_64_mul(clippedDevShapeBounds.width(),
|
||||
clippedDevShapeBounds.height());
|
||||
int maxTextureSize = args.fRenderTargetContext->caps()->maxTextureSize();
|
||||
int maxTextureSize = args.fSurfaceDrawContext->caps()->maxTextureSize();
|
||||
if (unclippedArea > 2 * clippedArea || unclippedWidth > maxTextureSize ||
|
||||
unclippedHeight > maxTextureSize) {
|
||||
useCache = false;
|
||||
@ -317,7 +317,7 @@ bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
if (useCache) {
|
||||
auto proxy = fProxyProvider->findOrCreateProxyByUniqueKey(maskKey);
|
||||
if (proxy) {
|
||||
GrSwizzle swizzle = args.fRenderTargetContext->caps()->getReadSwizzle(
|
||||
GrSwizzle swizzle = args.fSurfaceDrawContext->caps()->getReadSwizzle(
|
||||
proxy->backendFormat(), GrColorType::kAlpha_8);
|
||||
view = {std::move(proxy), kTopLeft_GrSurfaceOrigin, swizzle};
|
||||
args.fContext->priv().stats()->incNumPathMasksCacheHits();
|
||||
@ -383,11 +383,11 @@ bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
}
|
||||
SkASSERT(view);
|
||||
if (inverseFilled) {
|
||||
DrawAroundInvPath(args.fRenderTargetContext, GrPaint::Clone(args.fPaint),
|
||||
DrawAroundInvPath(args.fSurfaceDrawContext, GrPaint::Clone(args.fPaint),
|
||||
*args.fUserStencilSettings, args.fClip, *args.fViewMatrix, devClipBounds,
|
||||
unclippedDevShapeBounds);
|
||||
}
|
||||
DrawToTargetWithShapeMask(std::move(view), args.fRenderTargetContext, std::move(args.fPaint),
|
||||
DrawToTargetWithShapeMask(std::move(view), args.fSurfaceDrawContext, std::move(args.fPaint),
|
||||
*args.fUserStencilSettings, args.fClip, *args.fViewMatrix,
|
||||
SkIPoint{boundsForMask->fLeft, boundsForMask->fTop}, *boundsForMask);
|
||||
|
||||
|
@ -305,12 +305,12 @@ static void draw_path(GrRecordingContext* context,
|
||||
}
|
||||
|
||||
static void stencil_path(GrRecordingContext* context,
|
||||
GrSurfaceDrawContext* rtc,
|
||||
GrSurfaceDrawContext* sdc,
|
||||
GrPathRenderer* pr, const GrFixedClip& clip, const SkMatrix& matrix,
|
||||
const GrStyledShape& shape, GrAA aa) {
|
||||
GrPathRenderer::StencilPathArgs args;
|
||||
args.fContext = context;
|
||||
args.fRenderTargetContext = rtc;
|
||||
args.fSurfaceDrawContext = sdc;
|
||||
args.fClip = &clip;
|
||||
args.fClipConservativeBounds = &clip.scissorRect();
|
||||
args.fViewMatrix = &matrix;
|
||||
@ -320,9 +320,9 @@ static void stencil_path(GrRecordingContext* context,
|
||||
pr->stencilPath(args);
|
||||
}
|
||||
|
||||
static GrAA supported_aa(GrSurfaceDrawContext* rtc, GrAA aa) {
|
||||
if (rtc->numSamples() > 1) {
|
||||
if (rtc->caps()->multisampleDisableSupport()) {
|
||||
static GrAA supported_aa(GrSurfaceDrawContext* sdc, GrAA aa) {
|
||||
if (sdc->numSamples() > 1) {
|
||||
if (sdc->caps()->multisampleDisableSupport()) {
|
||||
return aa;
|
||||
} else {
|
||||
return GrAA::kYes;
|
||||
@ -336,7 +336,7 @@ static GrAA supported_aa(GrSurfaceDrawContext* rtc, GrAA aa) {
|
||||
|
||||
bool GrStencilMaskHelper::init(const SkIRect& bounds, uint32_t genID,
|
||||
const GrWindowRectangles& windowRects, int numFPs) {
|
||||
if (!fRTC->mustRenderClip(genID, bounds, numFPs)) {
|
||||
if (!fSDC->mustRenderClip(genID, bounds, numFPs)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -362,20 +362,20 @@ void GrStencilMaskHelper::drawRect(const SkRect& rect,
|
||||
bool drawDirectToClip;
|
||||
auto passes = get_stencil_passes(op, GrPathRenderer::kNoRestriction_StencilSupport, false,
|
||||
&drawDirectToClip);
|
||||
aa = supported_aa(fRTC, aa);
|
||||
aa = supported_aa(fSDC, aa);
|
||||
|
||||
if (!drawDirectToClip) {
|
||||
// Draw to client stencil bits first
|
||||
draw_stencil_rect(fRTC, fClip.fixedClip(), &gDrawToStencil, matrix, rect, aa);
|
||||
draw_stencil_rect(fSDC, fClip.fixedClip(), &gDrawToStencil, matrix, rect, aa);
|
||||
}
|
||||
|
||||
// Now modify the clip bit (either by rendering directly), or by covering the bounding box
|
||||
// of the clip
|
||||
for (GrUserStencilSettings const* const* pass = passes; *pass; ++pass) {
|
||||
if (drawDirectToClip) {
|
||||
draw_stencil_rect(fRTC, fClip, *pass, matrix, rect, aa);
|
||||
draw_stencil_rect(fSDC, fClip, *pass, matrix, rect, aa);
|
||||
} else {
|
||||
draw_stencil_rect(fRTC, fClip, *pass, SkMatrix::I(),
|
||||
draw_stencil_rect(fSDC, fClip, *pass, SkMatrix::I(),
|
||||
SkRect::Make(fClip.fixedClip().scissorRect()), aa);
|
||||
}
|
||||
}
|
||||
@ -392,7 +392,7 @@ bool GrStencilMaskHelper::drawPath(const SkPath& path,
|
||||
// drawPath follows a similar approach to drawRect(), where we either draw directly to the clip
|
||||
// bit or first draw to client bits and then apply a cover pass. The complicating factor is that
|
||||
// we rely on path rendering and how the chosen path renderer uses the stencil buffer.
|
||||
aa = supported_aa(fRTC, aa);
|
||||
aa = supported_aa(fSDC, aa);
|
||||
|
||||
GrAAType pathAAType = aa == GrAA::kYes ? GrAAType::kMSAA : GrAAType::kNone;
|
||||
|
||||
@ -412,12 +412,12 @@ bool GrStencilMaskHelper::drawPath(const SkPath& path,
|
||||
|
||||
GrPathRenderer::CanDrawPathArgs canDrawArgs;
|
||||
canDrawArgs.fCaps = fContext->priv().caps();
|
||||
canDrawArgs.fProxy = fRTC->asRenderTargetProxy();
|
||||
canDrawArgs.fProxy = fSDC->asRenderTargetProxy();
|
||||
canDrawArgs.fClipConservativeBounds = &fClip.fixedClip().scissorRect();
|
||||
canDrawArgs.fViewMatrix = &matrix;
|
||||
canDrawArgs.fShape = &shape;
|
||||
canDrawArgs.fPaint = nullptr;
|
||||
canDrawArgs.fSurfaceProps = &fRTC->surfaceProps();
|
||||
canDrawArgs.fSurfaceProps = &fSDC->surfaceProps();
|
||||
canDrawArgs.fAAType = pathAAType;
|
||||
canDrawArgs.fHasUserStencilSettings = false;
|
||||
|
||||
@ -433,10 +433,10 @@ bool GrStencilMaskHelper::drawPath(const SkPath& path,
|
||||
// Write to client bits if necessary
|
||||
if (!drawDirectToClip) {
|
||||
if (stencilSupport == GrPathRenderer::kNoRestriction_StencilSupport) {
|
||||
draw_path(fContext, fRTC, pr, fClip.fixedClip(), fClip.fixedClip().scissorRect(),
|
||||
draw_path(fContext, fSDC, pr, fClip.fixedClip(), fClip.fixedClip().scissorRect(),
|
||||
&gDrawToStencil, matrix, shape, aa);
|
||||
} else {
|
||||
stencil_path(fContext, fRTC, pr, fClip.fixedClip(), matrix, shape, aa);
|
||||
stencil_path(fContext, fSDC, pr, fClip.fixedClip(), matrix, shape, aa);
|
||||
}
|
||||
}
|
||||
|
||||
@ -444,10 +444,10 @@ bool GrStencilMaskHelper::drawPath(const SkPath& path,
|
||||
// of the clip
|
||||
for (GrUserStencilSettings const* const* pass = passes; *pass; ++pass) {
|
||||
if (drawDirectToClip) {
|
||||
draw_path(fContext, fRTC, pr, fClip, fClip.fixedClip().scissorRect(),
|
||||
draw_path(fContext, fSDC, pr, fClip, fClip.fixedClip().scissorRect(),
|
||||
*pass, matrix, shape, aa);
|
||||
} else {
|
||||
draw_stencil_rect(fRTC, fClip, *pass, SkMatrix::I(),
|
||||
draw_stencil_rect(fSDC, fClip, *pass, SkMatrix::I(),
|
||||
SkRect::Make(fClip.fixedClip().scissorRect()), aa);
|
||||
}
|
||||
}
|
||||
@ -473,14 +473,14 @@ void GrStencilMaskHelper::clear(bool insideStencil) {
|
||||
if (fClip.fixedClip().hasWindowRectangles()) {
|
||||
// Use a draw to benefit from window rectangles when resetting the stencil buffer; for
|
||||
// large buffers with MSAA this can be significant.
|
||||
draw_stencil_rect(fRTC, fClip.fixedClip(),
|
||||
draw_stencil_rect(fSDC, fClip.fixedClip(),
|
||||
GrStencilSettings::SetClipBitSettings(insideStencil), SkMatrix::I(),
|
||||
SkRect::Make(fClip.fixedClip().scissorRect()), GrAA::kNo);
|
||||
} else {
|
||||
fRTC->clearStencilClip(fClip.fixedClip().scissorRect(), insideStencil);
|
||||
fSDC->clearStencilClip(fClip.fixedClip().scissorRect(), insideStencil);
|
||||
}
|
||||
}
|
||||
|
||||
void GrStencilMaskHelper::finish() {
|
||||
fRTC->setLastClip(fClip.stencilStackID(), fClip.fixedClip().scissorRect(), fNumFPs);
|
||||
fSDC->setLastClip(fClip.stencilStackID(), fClip.fixedClip().scissorRect(), fNumFPs);
|
||||
}
|
||||
|
@ -37,10 +37,10 @@ public:
|
||||
// Configure the helper to update the stencil mask within the given rectangle, respecting the
|
||||
// set window rectangles. It will use the provided context and render target to draw into, both
|
||||
// of which must outlive the helper.
|
||||
GrStencilMaskHelper(GrRecordingContext* context, GrSurfaceDrawContext* rtc)
|
||||
GrStencilMaskHelper(GrRecordingContext* context, GrSurfaceDrawContext* sdc)
|
||||
: fContext(context)
|
||||
, fRTC(rtc)
|
||||
, fClip(rtc->dimensions()) {}
|
||||
, fSDC(sdc)
|
||||
, fClip(sdc->dimensions()) {}
|
||||
|
||||
// Returns true if the stencil mask must be redrawn
|
||||
bool init(const SkIRect& maskBounds, uint32_t genID,
|
||||
@ -63,7 +63,7 @@ public:
|
||||
|
||||
private:
|
||||
GrRecordingContext* fContext;
|
||||
GrSurfaceDrawContext* fRTC;
|
||||
GrSurfaceDrawContext* fSDC;
|
||||
GrStencilClip fClip;
|
||||
int fNumFPs;
|
||||
|
||||
|
@ -166,7 +166,7 @@ public:
|
||||
return fReadView.asRenderTargetProxyRef();
|
||||
}
|
||||
|
||||
virtual GrSurfaceDrawContext* asRenderTargetContext() { return nullptr; }
|
||||
virtual GrSurfaceDrawContext* asSurfaceDrawContext() { return nullptr; }
|
||||
virtual GrSurfaceFillContext* asFillContext() { return nullptr; }
|
||||
|
||||
/**
|
||||
|
@ -248,7 +248,7 @@ std::unique_ptr<GrSurfaceDrawContext> GrSurfaceDrawContext::MakeFromBackendTextu
|
||||
}
|
||||
|
||||
// In MDB mode the reffing of the 'getLastOpsTask' call's result allows in-progress
|
||||
// GrOpsTask to be picked up and added to by renderTargetContexts lower in the call
|
||||
// GrOpsTask to be picked up and added to by SurfaceDrawContexts lower in the call
|
||||
// stack. When this occurs with a closed GrOpsTask, a new one will be allocated
|
||||
// when the surfaceDrawContext attempts to use it (via getOpsTask).
|
||||
GrSurfaceDrawContext::GrSurfaceDrawContext(GrRecordingContext* context,
|
||||
@ -895,7 +895,7 @@ bool GrSurfaceDrawContext::stencilPath(const GrHardClip* clip,
|
||||
|
||||
GrPathRenderer::StencilPathArgs args;
|
||||
args.fContext = fContext;
|
||||
args.fRenderTargetContext = this;
|
||||
args.fSurfaceDrawContext = this;
|
||||
args.fClip = clip;
|
||||
args.fClipConservativeBounds = &clipBounds;
|
||||
args.fViewMatrix = &viewMatrix;
|
||||
|
@ -595,7 +595,7 @@ public:
|
||||
SkGlyphRunListPainter* glyphRunPainter() { return &fGlyphPainter; }
|
||||
|
||||
/*
|
||||
* This unique ID will not change for a given RenderTargetContext. However, it is _NOT_
|
||||
* This unique ID will not change for a given SurfaceDrawContext. However, it is _NOT_
|
||||
* guaranteed to match the uniqueID of the underlying GrRenderTarget - beware!
|
||||
*/
|
||||
GrSurfaceProxy::UniqueID uniqueID() const { return this->asSurfaceProxy()->uniqueID(); }
|
||||
@ -639,7 +639,7 @@ public:
|
||||
// instantiated.
|
||||
GrRenderTarget* accessRenderTarget() { return this->asSurfaceProxy()->peekRenderTarget(); }
|
||||
|
||||
GrSurfaceDrawContext* asRenderTargetContext() override { return this; }
|
||||
GrSurfaceDrawContext* asSurfaceDrawContext() override { return this; }
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
void testingOnly_SetPreserveOpsOnFullClear() { fPreserveOpsOnFullClear_TestingOnly = true; }
|
||||
|
@ -920,9 +920,9 @@ private:
|
||||
} // anonymous namespace
|
||||
|
||||
bool GrAAConvexPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(args.fRenderTargetContext->auditTrail(),
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(args.fSurfaceDrawContext->auditTrail(),
|
||||
"GrAAConvexPathRenderer::onDrawPath");
|
||||
SkASSERT(args.fRenderTargetContext->numSamples() <= 1);
|
||||
SkASSERT(args.fSurfaceDrawContext->numSamples() <= 1);
|
||||
SkASSERT(!args.fShape->isEmpty());
|
||||
|
||||
SkPath path;
|
||||
@ -931,7 +931,7 @@ bool GrAAConvexPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
GrOp::Owner op = AAConvexPathOp::Make(args.fContext, std::move(args.fPaint),
|
||||
*args.fViewMatrix,
|
||||
path, args.fUserStencilSettings);
|
||||
args.fRenderTargetContext->addDrawOp(args.fClip, std::move(op));
|
||||
args.fSurfaceDrawContext->addDrawOp(args.fClip, std::move(op));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1309,9 +1309,9 @@ void AAHairlineOp::onExecute(GrOpFlushState* flushState, const SkRect& chainBoun
|
||||
}
|
||||
|
||||
bool GrAAHairLinePathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(args.fRenderTargetContext->auditTrail(),
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(args.fSurfaceDrawContext->auditTrail(),
|
||||
"GrAAHairlinePathRenderer::onDrawPath");
|
||||
SkASSERT(args.fRenderTargetContext->numSamples() <= 1);
|
||||
SkASSERT(args.fSurfaceDrawContext->numSamples() <= 1);
|
||||
|
||||
SkPath path;
|
||||
args.fShape->asPath(&path);
|
||||
@ -1319,7 +1319,7 @@ bool GrAAHairLinePathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
AAHairlineOp::Make(args.fContext, std::move(args.fPaint), *args.fViewMatrix, path,
|
||||
args.fShape->style(), *args.fClipConservativeBounds,
|
||||
args.fUserStencilSettings);
|
||||
args.fRenderTargetContext->addDrawOp(args.fClip, std::move(op));
|
||||
args.fSurfaceDrawContext->addDrawOp(args.fClip, std::move(op));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -388,9 +388,9 @@ private:
|
||||
} // anonymous namespace
|
||||
|
||||
bool GrAALinearizingConvexPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(args.fRenderTargetContext->auditTrail(),
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(args.fSurfaceDrawContext->auditTrail(),
|
||||
"GrAALinearizingConvexPathRenderer::onDrawPath");
|
||||
SkASSERT(args.fRenderTargetContext->numSamples() <= 1);
|
||||
SkASSERT(args.fSurfaceDrawContext->numSamples() <= 1);
|
||||
SkASSERT(!args.fShape->isEmpty());
|
||||
SkASSERT(!args.fShape->style().pathEffect());
|
||||
|
||||
@ -405,7 +405,7 @@ bool GrAALinearizingConvexPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
GrOp::Owner op = AAFlatteningConvexPathOp::Make(
|
||||
args.fContext, std::move(args.fPaint), *args.fViewMatrix, path, strokeWidth,
|
||||
stroke.getStyle(), join, miterLimit, args.fUserStencilSettings);
|
||||
args.fRenderTargetContext->addDrawOp(args.fClip, std::move(op));
|
||||
args.fSurfaceDrawContext->addDrawOp(args.fClip, std::move(op));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ GrDashLinePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
|
||||
}
|
||||
|
||||
bool GrDashLinePathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(args.fRenderTargetContext->auditTrail(),
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(args.fSurfaceDrawContext->auditTrail(),
|
||||
"GrDashLinePathRenderer::onDrawPath");
|
||||
GrDashOp::AAMode aaMode;
|
||||
switch (args.fAAType) {
|
||||
@ -37,7 +37,7 @@ bool GrDashLinePathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
aaMode = GrDashOp::AAMode::kNone;
|
||||
break;
|
||||
case GrAAType::kMSAA:
|
||||
if (args.fRenderTargetContext->canUseDynamicMSAA()) {
|
||||
if (args.fSurfaceDrawContext->canUseDynamicMSAA()) {
|
||||
// In DMSAA we avoid using MSAA, in order to reduce the number of MSAA triggers.
|
||||
aaMode = GrDashOp::AAMode::kCoverage;
|
||||
} else {
|
||||
@ -59,6 +59,6 @@ bool GrDashLinePathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
if (!op) {
|
||||
return false;
|
||||
}
|
||||
args.fRenderTargetContext->addDrawOp(args.fClip, std::move(op));
|
||||
args.fSurfaceDrawContext->addDrawOp(args.fClip, std::move(op));
|
||||
return true;
|
||||
}
|
||||
|
@ -716,17 +716,17 @@ GrDefaultPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
|
||||
}
|
||||
|
||||
bool GrDefaultPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(args.fRenderTargetContext->auditTrail(),
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(args.fSurfaceDrawContext->auditTrail(),
|
||||
"GrDefaultPathRenderer::onDrawPath");
|
||||
GrAAType aaType = (GrAAType::kNone != args.fAAType) ? GrAAType::kMSAA : GrAAType::kNone;
|
||||
|
||||
return this->internalDrawPath(
|
||||
args.fRenderTargetContext, std::move(args.fPaint), aaType, *args.fUserStencilSettings,
|
||||
args.fSurfaceDrawContext, std::move(args.fPaint), aaType, *args.fUserStencilSettings,
|
||||
args.fClip, *args.fViewMatrix, *args.fShape, false);
|
||||
}
|
||||
|
||||
void GrDefaultPathRenderer::onStencilPath(const StencilPathArgs& args) {
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(args.fRenderTargetContext->auditTrail(),
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(args.fSurfaceDrawContext->auditTrail(),
|
||||
"GrDefaultPathRenderer::onStencilPath");
|
||||
SkASSERT(!args.fShape->inverseFilled());
|
||||
|
||||
@ -736,7 +736,7 @@ void GrDefaultPathRenderer::onStencilPath(const StencilPathArgs& args) {
|
||||
auto aaType = (GrAA::kYes == args.fDoStencilMSAA) ? GrAAType::kMSAA : GrAAType::kNone;
|
||||
|
||||
this->internalDrawPath(
|
||||
args.fRenderTargetContext, std::move(paint), aaType, GrUserStencilSettings::kUnused,
|
||||
args.fSurfaceDrawContext, std::move(paint), aaType, GrUserStencilSettings::kUnused,
|
||||
args.fClip, *args.fViewMatrix, *args.fShape, true);
|
||||
}
|
||||
|
||||
|
@ -694,7 +694,7 @@ private:
|
||||
};
|
||||
|
||||
bool GrSmallPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(args.fRenderTargetContext->auditTrail(),
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(args.fSurfaceDrawContext->auditTrail(),
|
||||
"GrSmallPathRenderer::onDrawPath");
|
||||
|
||||
// we've already bailed on inverse filled paths, so this is safe
|
||||
@ -704,7 +704,7 @@ bool GrSmallPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
GrOp::Owner op = SmallPathOp::Make(
|
||||
args.fContext, std::move(args.fPaint), *args.fShape, *args.fViewMatrix,
|
||||
args.fGammaCorrect, args.fUserStencilSettings);
|
||||
args.fRenderTargetContext->addDrawOp(args.fClip, std::move(op));
|
||||
args.fSurfaceDrawContext->addDrawOp(args.fClip, std::move(op));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1178,7 +1178,7 @@ GrOp::Owner GrTextureOp::Make(GrRecordingContext* context,
|
||||
// A helper class that assists in breaking up bulk API quad draws into manageable chunks.
|
||||
class GrTextureOp::BatchSizeLimiter {
|
||||
public:
|
||||
BatchSizeLimiter(GrSurfaceDrawContext* rtc,
|
||||
BatchSizeLimiter(GrSurfaceDrawContext* sdc,
|
||||
const GrClip* clip,
|
||||
GrRecordingContext* context,
|
||||
int numEntries,
|
||||
@ -1188,7 +1188,7 @@ public:
|
||||
SkCanvas::SrcRectConstraint constraint,
|
||||
const SkMatrix& viewMatrix,
|
||||
sk_sp<GrColorSpaceXform> textureColorSpaceXform)
|
||||
: fRTC(rtc)
|
||||
: fSDC(sdc)
|
||||
, fClip(clip)
|
||||
, fContext(context)
|
||||
, fFilter(filter)
|
||||
@ -1214,7 +1214,7 @@ public:
|
||||
fConstraint,
|
||||
fViewMatrix,
|
||||
fTextureColorSpaceXform);
|
||||
fRTC->addDrawOp(fClip, std::move(op));
|
||||
fSDC->addDrawOp(fClip, std::move(op));
|
||||
|
||||
fNumLeft -= clumpSize;
|
||||
fNumClumped += clumpSize;
|
||||
@ -1224,7 +1224,7 @@ public:
|
||||
int baseIndex() const { return fNumClumped; }
|
||||
|
||||
private:
|
||||
GrSurfaceDrawContext* fRTC;
|
||||
GrSurfaceDrawContext* fSDC;
|
||||
const GrClip* fClip;
|
||||
GrRecordingContext* fContext;
|
||||
GrSamplerState::Filter fFilter;
|
||||
|
@ -609,13 +609,13 @@ private:
|
||||
} // anonymous namespace
|
||||
|
||||
bool GrTriangulatingPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(args.fRenderTargetContext->auditTrail(),
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(args.fSurfaceDrawContext->auditTrail(),
|
||||
"GrTriangulatingPathRenderer::onDrawPath");
|
||||
|
||||
GrOp::Owner op = TriangulatingPathOp::Make(
|
||||
args.fContext, std::move(args.fPaint), *args.fShape, *args.fViewMatrix,
|
||||
*args.fClipConservativeBounds, args.fAAType, args.fUserStencilSettings);
|
||||
args.fRenderTargetContext->addDrawOp(args.fClip, std::move(op));
|
||||
args.fSurfaceDrawContext->addDrawOp(args.fClip, std::move(op));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ static GrOp::Owner make_op(GrRecordingContext* rContext, const GrSurfaceContext*
|
||||
}
|
||||
|
||||
bool GrTessellationPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
GrSurfaceDrawContext* surfaceDrawContext = args.fRenderTargetContext;
|
||||
GrSurfaceDrawContext* surfaceDrawContext = args.fSurfaceDrawContext;
|
||||
|
||||
SkRect devBounds;
|
||||
args.fViewMatrix->mapRect(&devBounds, args.fShape->bounds());
|
||||
@ -261,7 +261,7 @@ bool GrTessellationPathRenderer::tryAddPathToAtlas(
|
||||
}
|
||||
|
||||
void GrTessellationPathRenderer::onStencilPath(const StencilPathArgs& args) {
|
||||
GrSurfaceDrawContext* surfaceDrawContext = args.fRenderTargetContext;
|
||||
GrSurfaceDrawContext* surfaceDrawContext = args.fSurfaceDrawContext;
|
||||
GrAAType aaType = (GrAA::kYes == args.fDoStencilMSAA) ? GrAAType::kMSAA : GrAAType::kNone;
|
||||
SkRect devBounds;
|
||||
args.fViewMatrix->mapRect(&devBounds, args.fShape->bounds());
|
||||
|
@ -40,7 +40,7 @@ static void test_dsl_fp(skiatest::Reporter* r,
|
||||
return;
|
||||
}
|
||||
}
|
||||
std::unique_ptr<GrSurfaceDrawContext> rtCtx =
|
||||
std::unique_ptr<GrSurfaceDrawContext> sdCtx =
|
||||
GrSurfaceDrawContext::Make(ctx,
|
||||
GrColorType::kRGBA_8888,
|
||||
/*colorSpace=*/nullptr,
|
||||
@ -48,13 +48,13 @@ static void test_dsl_fp(skiatest::Reporter* r,
|
||||
/*dimensions=*/{1, 1},
|
||||
SkSurfaceProps{});
|
||||
|
||||
rtCtx->fillRectWithFP(SkIRect::MakeWH(1, 1),
|
||||
sdCtx->fillRectWithFP(SkIRect::MakeWH(1, 1),
|
||||
FPClass::Make(std::forward<Uniforms>(uniforms)...));
|
||||
|
||||
SkImageInfo dstInfo = SkImageInfo::Make(/*width=*/1, /*height=*/1, kRGBA_8888_SkColorType,
|
||||
kPremul_SkAlphaType, /*cs=*/nullptr);
|
||||
GrPixmap dstPM = GrPixmap::Allocate(dstInfo);
|
||||
REPORTER_ASSERT(r, rtCtx->readPixels(ctx, dstPM, /*srcPt=*/{0, 0}));
|
||||
REPORTER_ASSERT(r, sdCtx->readPixels(ctx, dstPM, /*srcPt=*/{0, 0}));
|
||||
|
||||
const GrColor* color = static_cast<const GrColor*>(dstPM.addr());
|
||||
REPORTER_ASSERT(r, *color == GrColorPackRGBA(0x00, 0xFF, 0x00, 0xFF),
|
||||
|
@ -60,13 +60,13 @@ public:
|
||||
CCPRPathDrawer(sk_sp<GrDirectContext> dContext, skiatest::Reporter* reporter)
|
||||
: fDContext(dContext)
|
||||
, fCCPR(fDContext->priv().drawingManager()->getCoverageCountingPathRenderer())
|
||||
, fRTC(GrSurfaceDrawContext::Make(
|
||||
, fSDC(GrSurfaceDrawContext::Make(
|
||||
fDContext.get(), GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact,
|
||||
{kCanvasSize, kCanvasSize}, SkSurfaceProps())) {
|
||||
if (!fCCPR) {
|
||||
ERRORF(reporter, "ccpr not enabled in GrDirectContext for ccpr tests");
|
||||
}
|
||||
if (!fRTC) {
|
||||
if (!fSDC) {
|
||||
ERRORF(reporter, "failed to create GrSurfaceDrawContext for ccpr tests");
|
||||
}
|
||||
}
|
||||
@ -74,11 +74,11 @@ public:
|
||||
GrDirectContext* dContext() const { return fDContext.get(); }
|
||||
GrCoverageCountingPathRenderer* ccpr() const { return fCCPR; }
|
||||
|
||||
bool valid() const { return fCCPR && fRTC; }
|
||||
void clear() const { fRTC->clear(SK_PMColor4fTRANSPARENT); }
|
||||
bool valid() const { return fCCPR && fSDC; }
|
||||
void clear() const { fSDC->clear(SK_PMColor4fTRANSPARENT); }
|
||||
void destroyGrContext() {
|
||||
SkASSERT(fDContext->unique());
|
||||
fRTC.reset();
|
||||
fSDC.reset();
|
||||
fCCPR = nullptr;
|
||||
fDContext.reset();
|
||||
}
|
||||
@ -90,7 +90,7 @@ public:
|
||||
paint.setColor4f({0, 1, 0, 1});
|
||||
|
||||
CCPRClip clip(fCCPR, clipPath);
|
||||
fRTC->drawRect(&clip, std::move(paint), GrAA::kYes, SkMatrix::I(),
|
||||
fSDC->drawRect(&clip, std::move(paint), GrAA::kYes, SkMatrix::I(),
|
||||
SkRect::MakeIWH(kCanvasSize, kCanvasSize));
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ public:
|
||||
private:
|
||||
sk_sp<GrDirectContext> fDContext;
|
||||
GrCoverageCountingPathRenderer* fCCPR;
|
||||
std::unique_ptr<GrSurfaceDrawContext> fRTC;
|
||||
std::unique_ptr<GrSurfaceDrawContext> fSDC;
|
||||
};
|
||||
|
||||
class CCPRTest {
|
||||
|
@ -388,7 +388,7 @@ public:
|
||||
// 9 refs from the 9 AtlasedRectOps
|
||||
// The backing GrSurface should have only 1 though bc there is only one proxy
|
||||
CheckSingleThreadedProxyRefs(fReporter, fAtlasView.proxy(), 10, 1);
|
||||
auto rtc = resourceProvider->makeRenderTargetContext(
|
||||
auto rtc = resourceProvider->makeSurfaceDrawContext(
|
||||
fAtlasView.refProxy(), fAtlasView.origin(), GrColorType::kRGBA_8888, nullptr,
|
||||
SkSurfaceProps());
|
||||
|
||||
|
@ -139,7 +139,7 @@ private:
|
||||
static const int kRenderTargetHeight = 1;
|
||||
static const int kRenderTargetWidth = 1;
|
||||
|
||||
static std::unique_ptr<GrSurfaceDrawContext> random_render_target_context(
|
||||
static std::unique_ptr<GrSurfaceDrawContext> random_surface_draw_context(
|
||||
GrRecordingContext* rContext,
|
||||
SkRandom* random,
|
||||
const GrCaps* caps) {
|
||||
@ -283,7 +283,7 @@ bool GrDrawingManager::ProgramUnitTest(GrDirectContext* direct, int maxStages, i
|
||||
static const int NUM_TESTS = 1024;
|
||||
for (int t = 0; t < NUM_TESTS; t++) {
|
||||
// setup random render target(can fail)
|
||||
auto surfaceDrawContext = random_render_target_context(direct, &random, caps);
|
||||
auto surfaceDrawContext = random_surface_draw_context(direct, &random, caps);
|
||||
if (!surfaceDrawContext) {
|
||||
SkDebugf("Could not allocate surfaceDrawContext");
|
||||
return false;
|
||||
|
@ -17,53 +17,53 @@
|
||||
|
||||
static const int kSize = 64;
|
||||
|
||||
static std::unique_ptr<GrSurfaceDrawContext> get_rtc(GrRecordingContext* rContext) {
|
||||
static std::unique_ptr<GrSurfaceDrawContext> get_sdc(GrRecordingContext* rContext) {
|
||||
return GrSurfaceDrawContext::Make(rContext, GrColorType::kRGBA_8888, nullptr,
|
||||
SkBackingFit::kExact, {kSize, kSize}, SkSurfaceProps());
|
||||
}
|
||||
|
||||
static void check_instantiation_status(skiatest::Reporter* reporter,
|
||||
GrSurfaceDrawContext* rtCtx,
|
||||
GrSurfaceDrawContext* sdCtx,
|
||||
bool wrappedExpectation) {
|
||||
REPORTER_ASSERT(reporter, rtCtx->asRenderTargetProxy()->isInstantiated() == wrappedExpectation);
|
||||
REPORTER_ASSERT(reporter, sdCtx->asRenderTargetProxy()->isInstantiated() == wrappedExpectation);
|
||||
|
||||
GrTextureProxy* tProxy = rtCtx->asTextureProxy();
|
||||
GrTextureProxy* tProxy = sdCtx->asTextureProxy();
|
||||
REPORTER_ASSERT(reporter, tProxy);
|
||||
|
||||
REPORTER_ASSERT(reporter, tProxy->isInstantiated() == wrappedExpectation);
|
||||
}
|
||||
|
||||
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(RenderTargetContextTest, reporter, ctxInfo) {
|
||||
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceDrawContextTest, reporter, ctxInfo) {
|
||||
auto dContext = ctxInfo.directContext();
|
||||
|
||||
// Calling instantiate on a GrSurfaceDrawContext's textureProxy also instantiates the
|
||||
// GrSurfaceDrawContext
|
||||
{
|
||||
auto rtCtx = get_rtc(dContext);
|
||||
auto sdCtx = get_sdc(dContext);
|
||||
|
||||
check_instantiation_status(reporter, rtCtx.get(), false);
|
||||
check_instantiation_status(reporter, sdCtx.get(), false);
|
||||
|
||||
GrTextureProxy* tProxy = rtCtx->asTextureProxy();
|
||||
GrTextureProxy* tProxy = sdCtx->asTextureProxy();
|
||||
REPORTER_ASSERT(reporter, tProxy);
|
||||
|
||||
REPORTER_ASSERT(reporter, tProxy->instantiate(dContext->priv().resourceProvider()));
|
||||
|
||||
check_instantiation_status(reporter, rtCtx.get(), true);
|
||||
check_instantiation_status(reporter, sdCtx.get(), true);
|
||||
}
|
||||
|
||||
// readPixels switches a deferred rtCtx to wrapped
|
||||
// readPixels switches a deferred sdCtx to wrapped
|
||||
{
|
||||
auto rtCtx = get_rtc(dContext);
|
||||
auto sdCtx = get_sdc(dContext);
|
||||
|
||||
check_instantiation_status(reporter, rtCtx.get(), false);
|
||||
check_instantiation_status(reporter, sdCtx.get(), false);
|
||||
|
||||
SkImageInfo dstInfo = SkImageInfo::MakeN32Premul(kSize, kSize);
|
||||
GrPixmap dstPM = GrPixmap::Allocate(dstInfo);
|
||||
|
||||
bool result = rtCtx->readPixels(dContext, dstPM, {0, 0});
|
||||
bool result = sdCtx->readPixels(dContext, dstPM, {0, 0});
|
||||
REPORTER_ASSERT(reporter, result);
|
||||
|
||||
check_instantiation_status(reporter, rtCtx.get(), true);
|
||||
check_instantiation_status(reporter, sdCtx.get(), true);
|
||||
}
|
||||
|
||||
// TODO: in a future world we should be able to add a test that the majority of
|
Loading…
Reference in New Issue
Block a user