Index: src/effects/gradients/SkSweepGradient.cpp |
diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp |
index c6699e87e0fabe0877c46013da16a8339879e0e7..40b0f8288bfadf81865fe8909b994340f0edc65a 100644 |
--- a/src/effects/gradients/SkSweepGradient.cpp |
+++ b/src/effects/gradients/SkSweepGradient.cpp |
@@ -167,6 +167,7 @@ void SkSweepGradient::SweepGradientContext::shadeSpan16(int x, int y, uint16_t* |
#if SK_SUPPORT_GPU |
#include "SkGr.h" |
+#include "effects/GrExtractAlphaFragmentProcessor.h" |
#include "gl/builders/GrGLProgramBuilder.h" |
class GrGLSweepGradient : public GrGLGradientEffect { |
@@ -226,7 +227,7 @@ private: |
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSweepGradient); |
-GrFragmentProcessor* GrSweepGradient::TestCreate(GrProcessorTestData* d) { |
+const GrFragmentProcessor* GrSweepGradient::TestCreate(GrProcessorTestData* d) { |
SkPoint center = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; |
SkColor colors[kMaxRandomGradientColors]; |
@@ -236,12 +237,11 @@ GrFragmentProcessor* GrSweepGradient::TestCreate(GrProcessorTestData* d) { |
int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tmIgnored); |
SkAutoTUnref<SkShader> shader(SkGradientShader::CreateSweep(center.fX, center.fY, |
colors, stops, colorCount)); |
- SkPaint paint; |
- GrFragmentProcessor* fp; |
- GrColor paintColor; |
- SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, |
- GrTest::TestMatrix(d->fRandom), nullptr, |
- &paintColor, d->fProcDataManager, &fp)); |
+ const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext, |
+ GrTest::TestMatrix(d->fRandom), |
+ NULL, kNone_SkFilterQuality, |
+ d->fProcDataManager); |
+ GrAlwaysAssert(fp); |
return fp; |
} |
@@ -270,38 +270,29 @@ void GrGLSweepGradient::emitCode(EmitArgs& args) { |
///////////////////////////////////////////////////////////////////// |
-bool SkSweepGradient::asFragmentProcessor(GrContext* context, const SkPaint& paint, |
- const SkMatrix& viewM, |
- const SkMatrix* localMatrix, GrColor* paintColor, |
- GrProcessorDataManager* procDataManager, |
- GrFragmentProcessor** effect) const { |
+const GrFragmentProcessor* SkSweepGradient::asFragmentProcessor( |
+ GrContext* context, |
+ const SkMatrix& viewM, |
+ const SkMatrix* localMatrix, |
+ SkFilterQuality, |
+ GrProcessorDataManager* procDataManager) const { |
SkMatrix matrix; |
if (!this->getLocalMatrix().invert(&matrix)) { |
- return false; |
+ return nullptr; |
} |
if (localMatrix) { |
SkMatrix inv; |
if (!localMatrix->invert(&inv)) { |
- return false; |
+ return nullptr; |
} |
matrix.postConcat(inv); |
} |
matrix.postConcat(fPtsToUnit); |
- *effect = GrSweepGradient::Create(context, procDataManager, *this, matrix); |
- *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); |
- |
- return true; |
-} |
- |
-#else |
- |
-bool SkSweepGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix&, |
- const SkMatrix*, GrColor*, GrProcessorDataManager*, |
- GrFragmentProcessor**) const { |
- SkDEBUGFAIL("Should not call in GPU-less build"); |
- return false; |
+ SkAutoTUnref<const GrFragmentProcessor> inner( |
+ GrSweepGradient::Create(context, procDataManager, *this, matrix)); |
+ return GrExtractAlphaFragmentProcessor::Create(inner); |
} |
#endif |