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

Unified Diff: src/effects/SkMorphologyImageFilter.cpp

Issue 1225923010: Refugee from Dead Machine 4: MDB Monster Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update Created 5 years, 5 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
Index: src/effects/SkMorphologyImageFilter.cpp
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index 5eccb0db233828351ee828617264f4fbba97b807..ca39083cfcffe2aa9dd2c421544a71de33a1d7f1 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -667,18 +667,21 @@ bool apply_morphology(const SkBitmap& input,
desc.fConfig = kSkia8888_GrPixelConfig;
SkIRect srcRect = rect;
- GrDrawContext* drawContext = context->drawContext();
- if (!drawContext) {
- return false;
- }
+ GrDrawContext* srcDrawContext = NULL;
if (radius.fWidth > 0) {
- GrTexture* texture = context->textureProvider()->refScratchTexture(
+ GrTexture* dst = context->textureProvider()->refScratchTexture(
desc, GrTextureProvider::kApprox_ScratchTexMatch);
- if (NULL == texture) {
+ if (NULL == dst) {
+ return false;
+ }
+ GrDrawContext* dstDrawContext = context->drawContext(dst->asRenderTarget());
+ if (!dstDrawContext) {
return false;
}
- apply_morphology_pass(drawContext, texture->asRenderTarget(), clip, srcTexture,
+ dstDrawContext->uses(srcTexture);
+
+ apply_morphology_pass(dstDrawContext, dst->asRenderTarget(), clip, srcTexture,
srcRect, dstRect, radius.fWidth, morphType,
Gr1DKernelEffect::kX_Direction);
SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom,
@@ -686,20 +689,34 @@ bool apply_morphology(const SkBitmap& input,
GrColor clearColor = GrMorphologyEffect::kErode_MorphologyType == morphType ?
SK_ColorWHITE :
SK_ColorTRANSPARENT;
- drawContext->clear(texture->asRenderTarget(), &clearRect, clearColor, false);
- srcTexture.reset(texture);
+ dstDrawContext->clear(dst->asRenderTarget(), &clearRect, clearColor, false);
+
+ srcDrawContext = dstDrawContext;
+ srcTexture.reset(dst);
srcRect = dstRect;
}
if (radius.fHeight > 0) {
- GrTexture* texture = context->textureProvider()->refScratchTexture(desc,
+ GrTexture* dst = context->textureProvider()->refScratchTexture(desc,
GrTextureProvider::kApprox_ScratchTexMatch);
- if (NULL == texture) {
+ if (NULL == dst) {
return false;
}
- apply_morphology_pass(drawContext, texture->asRenderTarget(), clip, srcTexture,
+ GrDrawContext* dstDrawContext = context->drawContext(dst->asRenderTarget());
+ if (!dstDrawContext) {
+ return false;
+ }
+ if (srcDrawContext) {
+ dstDrawContext->uses(srcDrawContext);
+ } else {
+ dstDrawContext->uses(srcTexture);
+ }
+
+ apply_morphology_pass(dstDrawContext, dst->asRenderTarget(), clip, srcTexture,
srcRect, dstRect, radius.fHeight, morphType,
Gr1DKernelEffect::kY_Direction);
- srcTexture.reset(texture);
+
+ srcDrawContext = dstDrawContext;
+ srcTexture.reset(dst);
}
SkImageFilter::WrapTexture(srcTexture, rect.width(), rect.height(), dst);
return true;
@@ -715,7 +732,8 @@ bool SkMorphologyImageFilter::filterImageGPUGeneric(bool dilate,
SkIPoint* offset) const {
SkBitmap input = src;
SkIPoint srcOffset = SkIPoint::Make(0, 0);
- if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctx, &input, &srcOffset)) {
+ if (this->getInput(0) &&
+ !this->getInput(0)->getInputResultGPU(proxy, src, ctx, &input, &srcOffset)) {
return false;
}
SkIRect bounds;
@@ -741,9 +759,9 @@ bool SkMorphologyImageFilter::filterImageGPUGeneric(bool dilate,
return true;
}
- GrMorphologyEffect::MorphologyType type = dilate ? GrMorphologyEffect::kDilate_MorphologyType : GrMorphologyEffect::kErode_MorphologyType;
- if (!apply_morphology(input, srcBounds, type,
- SkISize::Make(width, height), result)) {
+ GrMorphologyEffect::MorphologyType type = dilate ? GrMorphologyEffect::kDilate_MorphologyType
+ : GrMorphologyEffect::kErode_MorphologyType;
+ if (!apply_morphology(input, srcBounds, type, SkISize::Make(width, height), result)) {
return false;
}
offset->fX = bounds.left();

Powered by Google App Engine
This is Rietveld 408576698