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

Unified Diff: src/gpu/GrBlurUtils.cpp

Issue 1929833004: Revert of Refactor drawContext/RenderTarget creation (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 f95bdfff02ffa45325e85db2a8ca4479170a688e..6827c83421b532941d9a68ddfefca4f183be827d 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -93,34 +93,38 @@
}
// Create a mask of 'devPath' and place the result in 'mask'.
-static sk_sp<GrTexture> create_mask_GPU(GrContext* context,
- SkRect* maskRect,
- const SkPath& devPath,
- const GrStrokeInfo& strokeInfo,
- bool doAA,
- int sampleCnt) {
+static 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());
- if (!doAA) {
- // Don't need MSAA if mask isn't AA
- sampleCnt = 0;
- }
-
+ 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
- GrPixelConfig config = kRGBA_8888_GrPixelConfig;
- if (context->caps()->isConfigRenderable(kAlpha_8_GrPixelConfig, sampleCnt > 0)) {
- config = kAlpha_8_GrPixelConfig;
- }
-
- sk_sp<GrDrawContext> drawContext(context->newDrawContext(GrContext::kLoose_BackingFit,
- SkScalarCeilToInt(maskRect->width()),
- SkScalarCeilToInt(maskRect->height()),
- config,
- sampleCnt));
+ desc.fConfig = kRGBA_8888_GrPixelConfig;
+
+ if (context->caps()->isConfigRenderable(kAlpha_8_GrPixelConfig, desc.fSampleCnt > 0)) {
+ desc.fConfig = kAlpha_8_GrPixelConfig;
+ }
+
+ GrTexture* mask = context->textureProvider()->createApproxTexture(desc);
+ if (nullptr == mask) {
+ return nullptr;
+ }
+
+ SkRect clipRect = SkRect::MakeWH(maskRect->width(), maskRect->height());
+
+ sk_sp<GrDrawContext> drawContext(context->drawContext(sk_ref_sp(mask->asRenderTarget())));
if (!drawContext) {
return nullptr;
}
@@ -132,7 +136,6 @@
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
@@ -140,7 +143,7 @@
SkMatrix translate;
translate.setTranslate(-maskRect->fLeft, -maskRect->fTop);
drawContext->drawPath(clip, tempPaint, translate, devPath, strokeInfo);
- return drawContext->asTexture();;
+ return mask;
}
static void draw_path_with_mask_filter(GrContext* context,
@@ -216,16 +219,16 @@
return;
}
- sk_sp<GrTexture> mask(create_mask_GPU(context,
- &maskRect,
- *devPathPtr,
- strokeInfo,
- paint->isAntiAlias(),
- drawContext->numColorSamples()));
+ SkAutoTUnref<GrTexture> mask(create_mask_GPU(context,
+ &maskRect,
+ *devPathPtr,
+ strokeInfo,
+ paint->isAntiAlias(),
+ drawContext->numColorSamples()));
if (mask) {
GrTexture* filtered;
- if (maskFilter->filterMaskGPU(mask.get(), viewMatrix, maskRect, &filtered, true)) {
+ if (maskFilter->filterMaskGPU(mask, 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