Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Unified Diff: src/gpu/GrBlurUtils.cpp

Issue 1914883002: Refactor drawContext/RenderTarget creation (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix variable name Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/effects/SkXfermodeImageFilter.cpp ('k') | src/gpu/GrContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrBlurUtils.cpp
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index 6827c83421b532941d9a68ddfefca4f183be827d..f95bdfff02ffa45325e85db2a8ca4479170a688e 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -93,38 +93,34 @@ static bool sw_draw_with_mask_filter(GrDrawContext* drawContext,
}
// Create a mask of 'devPath' and place the result in 'mask'.
-static GrTexture* create_mask_GPU(GrContext* context,
- SkRect* maskRect,
- const SkPath& devPath,
- const GrStrokeInfo& strokeInfo,
- bool doAA,
- int sampleCnt) {
+static sk_sp<GrTexture> create_mask_GPU(GrContext* context,
+ SkRect* maskRect,
+ const SkPath& devPath,
+ const GrStrokeInfo& strokeInfo,
+ bool doAA,
+ int sampleCnt) {
// This mask will ultimately be drawn as a non-AA rect (see draw_mask).
// Non-AA rects have a bad habit of snapping arbitrarily. Integerize here
// so the mask draws in a reproducible manner.
*maskRect = SkRect::Make(maskRect->roundOut());
- GrSurfaceDesc desc;
- desc.fFlags = kRenderTarget_GrSurfaceFlag;
- desc.fWidth = SkScalarCeilToInt(maskRect->width());
- desc.fHeight = SkScalarCeilToInt(maskRect->height());
- desc.fSampleCnt = doAA ? sampleCnt : 0;
- // We actually only need A8, but it often isn't supported as a
- // render target so default to RGBA_8888
- desc.fConfig = kRGBA_8888_GrPixelConfig;
-
- if (context->caps()->isConfigRenderable(kAlpha_8_GrPixelConfig, desc.fSampleCnt > 0)) {
- desc.fConfig = kAlpha_8_GrPixelConfig;
+ if (!doAA) {
+ // Don't need MSAA if mask isn't AA
+ sampleCnt = 0;
}
- GrTexture* mask = context->textureProvider()->createApproxTexture(desc);
- if (nullptr == mask) {
- return nullptr;
+ // We actually only need A8, but it often isn't supported as a
+ // render target so default to RGBA_8888
+ GrPixelConfig config = kRGBA_8888_GrPixelConfig;
+ if (context->caps()->isConfigRenderable(kAlpha_8_GrPixelConfig, sampleCnt > 0)) {
+ config = kAlpha_8_GrPixelConfig;
}
- SkRect clipRect = SkRect::MakeWH(maskRect->width(), maskRect->height());
-
- sk_sp<GrDrawContext> drawContext(context->drawContext(sk_ref_sp(mask->asRenderTarget())));
+ sk_sp<GrDrawContext> drawContext(context->newDrawContext(GrContext::kLoose_BackingFit,
+ SkScalarCeilToInt(maskRect->width()),
+ SkScalarCeilToInt(maskRect->height()),
+ config,
+ sampleCnt));
if (!drawContext) {
return nullptr;
}
@@ -136,6 +132,7 @@ static GrTexture* create_mask_GPU(GrContext* context,
tempPaint.setCoverageSetOpXPFactory(SkRegion::kReplace_Op);
// setup new clip
+ const SkRect clipRect = SkRect::MakeWH(maskRect->width(), maskRect->height());
GrClip clip(clipRect);
// Draw the mask into maskTexture with the path's integerized top-left at
@@ -143,7 +140,7 @@ static GrTexture* create_mask_GPU(GrContext* context,
SkMatrix translate;
translate.setTranslate(-maskRect->fLeft, -maskRect->fTop);
drawContext->drawPath(clip, tempPaint, translate, devPath, strokeInfo);
- return mask;
+ return drawContext->asTexture();;
}
static void draw_path_with_mask_filter(GrContext* context,
@@ -219,16 +216,16 @@ static void draw_path_with_mask_filter(GrContext* context,
return;
}
- SkAutoTUnref<GrTexture> mask(create_mask_GPU(context,
- &maskRect,
- *devPathPtr,
- strokeInfo,
- paint->isAntiAlias(),
- drawContext->numColorSamples()));
+ sk_sp<GrTexture> mask(create_mask_GPU(context,
+ &maskRect,
+ *devPathPtr,
+ strokeInfo,
+ paint->isAntiAlias(),
+ drawContext->numColorSamples()));
if (mask) {
GrTexture* filtered;
- if (maskFilter->filterMaskGPU(mask, viewMatrix, maskRect, &filtered, true)) {
+ if (maskFilter->filterMaskGPU(mask.get(), viewMatrix, maskRect, &filtered, true)) {
// filterMaskGPU gives us ownership of a ref to the result
SkAutoTUnref<GrTexture> atu(filtered);
if (draw_mask(drawContext, clip, viewMatrix, maskRect, paint, filtered)) {
« no previous file with comments | « src/effects/SkXfermodeImageFilter.cpp ('k') | src/gpu/GrContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698