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

Unified Diff: src/effects/SkMorphologyImageFilter.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/SkLightingImageFilter.cpp ('k') | src/effects/SkXfermodeImageFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkMorphologyImageFilter.cpp
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index 9e87fe04a41a4c00dbc41898277e0b7d7460e69f..2a0f078c053fd6ed0cc13577668090b7415a6c1c 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -478,26 +478,18 @@ static sk_sp<SkSpecialImage> apply_morphology(GrContext* context,
SkASSERT(srcTexture);
// setup new clip
- GrClip clip(SkRect::MakeWH(SkIntToScalar(srcTexture->width()),
- SkIntToScalar(srcTexture->height())));
-
- SkIRect dstRect = SkIRect::MakeWH(rect.width(), rect.height());
- GrSurfaceDesc desc;
- desc.fFlags = kRenderTarget_GrSurfaceFlag;
- desc.fWidth = rect.width();
- desc.fHeight = rect.height();
- desc.fConfig = kSkia8888_GrPixelConfig;
+ const GrClip clip(SkRect::MakeWH(SkIntToScalar(srcTexture->width()),
+ SkIntToScalar(srcTexture->height())));
+
+ const SkIRect dstRect = SkIRect::MakeWH(rect.width(), rect.height());
SkIRect srcRect = rect;
SkASSERT(radius.width() > 0 || radius.height() > 0);
if (radius.fWidth > 0) {
- GrTexture* scratch = context->textureProvider()->createApproxTexture(desc);
- if (!scratch) {
- return nullptr;
- }
- sk_sp<GrDrawContext> dstDrawContext(
- context->drawContext(sk_ref_sp(scratch->asRenderTarget())));
+ sk_sp<GrDrawContext> dstDrawContext(context->newDrawContext(GrContext::kLoose_BackingFit,
+ rect.width(), rect.height(),
+ kSkia8888_GrPixelConfig));
if (!dstDrawContext) {
return nullptr;
}
@@ -507,21 +499,18 @@ static sk_sp<SkSpecialImage> apply_morphology(GrContext* context,
Gr1DKernelEffect::kX_Direction);
SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom,
dstRect.width(), radius.fHeight);
- GrColor clearColor = GrMorphologyEffect::kErode_MorphologyType == morphType ?
- SK_ColorWHITE :
- SK_ColorTRANSPARENT;
+ GrColor clearColor = GrMorphologyEffect::kErode_MorphologyType == morphType
+ ? SK_ColorWHITE
+ : SK_ColorTRANSPARENT;
dstDrawContext->clear(&clearRect, clearColor, false);
- srcTexture.reset(scratch);
+ srcTexture = dstDrawContext->asTexture();
srcRect = dstRect;
}
if (radius.fHeight > 0) {
- GrTexture* scratch = context->textureProvider()->createApproxTexture(desc);
- if (!scratch) {
- return nullptr;
- }
- sk_sp<GrDrawContext> dstDrawContext(
- context->drawContext(sk_ref_sp(scratch->asRenderTarget())));
+ sk_sp<GrDrawContext> dstDrawContext(context->newDrawContext(GrContext::kLoose_BackingFit,
+ rect.width(), rect.height(),
+ kSkia8888_GrPixelConfig));
if (!dstDrawContext) {
return nullptr;
}
@@ -530,7 +519,7 @@ static sk_sp<SkSpecialImage> apply_morphology(GrContext* context,
srcRect, dstRect, radius.fHeight, morphType,
Gr1DKernelEffect::kY_Direction);
- srcTexture.reset(scratch);
+ srcTexture = dstDrawContext->asTexture();
}
return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(rect.width(), rect.height()),
« no previous file with comments | « src/effects/SkLightingImageFilter.cpp ('k') | src/effects/SkXfermodeImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698