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

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: Last update from dead machine 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/SkMatrixConvolutionImageFilter.cpp ('k') | src/effects/SkPerlinNoiseShader.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 1d465edcb5246d9a144bcce9b57cfdfe326128a3..8cca694403d7f07295dd7f6f7f262164b8e8aead 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -14,6 +14,7 @@
#include "SkRect.h"
#include "SkWriteBuffer.h"
#if SK_SUPPORT_GPU
+#include "SkGR.h"
#include "GrContext.h"
#include "GrDrawContext.h"
#include "GrInvariantOutput.h"
@@ -211,14 +212,15 @@ public:
kDilate_MorphologyType,
};
- static GrFragmentProcessor* Create(GrTexture* tex, Direction dir, int radius,
- MorphologyType type) {
- return new GrMorphologyEffect(tex, dir, radius, type);
+ static GrFragmentProcessor* Create(GrTexture* tex,
+ Direction dir, int radius, MorphologyType type, GrRenderTarget* dst) {
+ return new GrMorphologyEffect(tex, dir, radius, type, dst);
}
- static GrFragmentProcessor* Create(GrTexture* tex, Direction dir, int radius,
- MorphologyType type, float bounds[2]) {
- return new GrMorphologyEffect(tex, dir, radius, type, bounds);
+ static GrFragmentProcessor* Create(GrTexture* tex,
+ Direction dir, int radius, MorphologyType type,
+ float bounds[2], GrRenderTarget* dst) {
+ return new GrMorphologyEffect(tex, dir, radius, type, bounds, dst);
}
virtual ~GrMorphologyEffect();
@@ -244,9 +246,9 @@ private:
void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
- GrMorphologyEffect(GrTexture*, Direction, int radius, MorphologyType);
+ GrMorphologyEffect(GrTexture*, Direction, int radius, MorphologyType, GrRenderTarget* dst);
GrMorphologyEffect(GrTexture*, Direction, int radius, MorphologyType,
- float bounds[2]);
+ float bounds[2], GrRenderTarget* dst);
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
@@ -402,8 +404,8 @@ void GrGLMorphologyEffect::onSetData(const GrGLSLProgramDataManager& pdman,
GrMorphologyEffect::GrMorphologyEffect(GrTexture* texture,
Direction direction,
int radius,
- MorphologyType type)
- : INHERITED(texture, direction, radius)
+ MorphologyType type, GrRenderTarget* dst)
+ : INHERITED(texture, direction, radius, dst)
, fType(type), fUseRange(false) {
this->initClassID<GrMorphologyEffect>();
}
@@ -412,8 +414,8 @@ GrMorphologyEffect::GrMorphologyEffect(GrTexture* texture,
Direction direction,
int radius,
MorphologyType type,
- float range[2])
- : INHERITED(texture, direction, radius)
+ float range[2], GrRenderTarget* dst)
+ : INHERITED(texture, direction, radius, dst)
, fType(type), fUseRange(true) {
this->initClassID<GrMorphologyEffect>();
fRange[0] = range[0];
@@ -457,7 +459,7 @@ const GrFragmentProcessor* GrMorphologyEffect::TestCreate(GrProcessorTestData* d
MorphologyType type = d->fRandom->nextBool() ? GrMorphologyEffect::kErode_MorphologyType :
GrMorphologyEffect::kDilate_MorphologyType;
- return GrMorphologyEffect::Create(d->fTextures[texIdx], dir, radius, type);
+ return GrMorphologyEffect::Create(d->fTextures[texIdx], dir, radius, type, NULL);
}
namespace {
@@ -477,9 +479,10 @@ void apply_morphology_rect(GrDrawContext* drawContext,
direction,
radius,
morphType,
- bounds))->unref();
+ bounds, drawContext->rt_remove_me()))->unref();
+
drawContext->fillRectToRect(clip, paint, SkMatrix::I(), SkRect::Make(dstRect),
- SkRect::Make(srcRect));
+ SkRect::Make(srcRect));
}
void apply_morphology_rect_no_bounds(GrDrawContext* drawContext,
@@ -494,7 +497,8 @@ void apply_morphology_rect_no_bounds(GrDrawContext* drawContext,
paint.addColorFragmentProcessor(GrMorphologyEffect::Create(texture,
direction,
radius,
- morphType))->unref();
+ morphType, drawContext->rt_remove_me()))->unref();
+
drawContext->fillRectToRect(clip, paint, SkMatrix::I(), SkRect::Make(dstRect),
SkRect::Make(srcRect));
}
@@ -579,6 +583,7 @@ bool apply_morphology(const SkBitmap& input,
if (nullptr == scratch) {
return false;
}
+
SkAutoTUnref<GrDrawContext> dstDrawContext(
context->drawContext(scratch->asRenderTarget()));
if (!dstDrawContext) {
@@ -593,6 +598,7 @@ bool apply_morphology(const SkBitmap& input,
GrColor clearColor = GrMorphologyEffect::kErode_MorphologyType == morphType ?
SK_ColorWHITE :
SK_ColorTRANSPARENT;
+
dstDrawContext->clear(&clearRect, clearColor, false);
srcTexture.reset(scratch);
@@ -603,6 +609,7 @@ bool apply_morphology(const SkBitmap& input,
if (nullptr == scratch) {
return false;
}
+
SkAutoTUnref<GrDrawContext> dstDrawContext(
context->drawContext(scratch->asRenderTarget()));
if (!dstDrawContext) {
« no previous file with comments | « src/effects/SkMatrixConvolutionImageFilter.cpp ('k') | src/effects/SkPerlinNoiseShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698