sk_sp for Ganesh.
Convert use of GrFragmentProcessor, GrGeometryProcessor, and
GrXPFactory to sk_sp. This clarifies ownership and should
reduce reference count churn by moving ownership.
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2041113004
Review-Url: https://codereview.chromium.org/2041113004
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp
index e140f0f..972d731 100644
--- a/src/core/SkBitmapProcShader.cpp
+++ b/src/core/SkBitmapProcShader.cpp
@@ -410,7 +410,7 @@
#include "SkGr.h"
#include "effects/GrSimpleTextureEffect.h"
-const GrFragmentProcessor* SkBitmapProcShader::asFragmentProcessor(GrContext* context,
+sk_sp<GrFragmentProcessor> SkBitmapProcShader::asFragmentProcessor(GrContext* context,
const SkMatrix& viewM, const SkMatrix* localMatrix,
SkFilterQuality filterQuality,
SkSourceGammaTreatment gammaTreatment) const {
@@ -453,17 +453,17 @@
return nullptr;
}
- SkAutoTUnref<const GrFragmentProcessor> inner;
+ sk_sp<GrFragmentProcessor> inner;
if (doBicubic) {
- inner.reset(GrBicubicEffect::Create(texture, matrix, tm));
+ inner = GrBicubicEffect::Make(texture, matrix, tm);
} else {
- inner.reset(GrSimpleTextureEffect::Create(texture, matrix, params));
+ inner = GrSimpleTextureEffect::Make(texture, matrix, params);
}
if (kAlpha_8_SkColorType == fRawBitmap.colorType()) {
- return GrFragmentProcessor::MulOutputByInputUnpremulColor(inner);
+ return GrFragmentProcessor::MulOutputByInputUnpremulColor(std::move(inner));
}
- return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+ return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
#endif
diff --git a/src/core/SkBitmapProcShader.h b/src/core/SkBitmapProcShader.h
index dbd82a7..1d37433 100644
--- a/src/core/SkBitmapProcShader.h
+++ b/src/core/SkBitmapProcShader.h
@@ -25,7 +25,7 @@
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader)
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& viewM,
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*, const SkMatrix& viewM,
const SkMatrix*, SkFilterQuality,
SkSourceGammaTreatment) const override;
#endif
diff --git a/src/core/SkColorFilter.cpp b/src/core/SkColorFilter.cpp
index e3d8957..9470766 100644
--- a/src/core/SkColorFilter.cpp
+++ b/src/core/SkColorFilter.cpp
@@ -31,6 +31,12 @@
return false;
}
+#if SK_SUPPORT_GPU
+sk_sp<GrFragmentProcessor> SkColorFilter::asFragmentProcessor(GrContext*) const {
+ return nullptr;
+}
+#endif
+
void SkColorFilter::filterSpan4f(const SkPM4f[], int count, SkPM4f span[]) const {
const int N = 128;
SkPMColor tmp[N];
@@ -99,13 +105,13 @@
#endif
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext* context) const override {
- SkAutoTUnref<const GrFragmentProcessor> innerFP(fInner->asFragmentProcessor(context));
- SkAutoTUnref<const GrFragmentProcessor> outerFP(fOuter->asFragmentProcessor(context));
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext* context) const override {
+ sk_sp<GrFragmentProcessor> innerFP(fInner->asFragmentProcessor(context));
+ sk_sp<GrFragmentProcessor> outerFP(fOuter->asFragmentProcessor(context));
if (!innerFP || !outerFP) {
return nullptr;
}
- const GrFragmentProcessor* series[] = { innerFP, outerFP };
+ sk_sp<GrFragmentProcessor> series[] = { std::move(innerFP), std::move(outerFP) };
return GrFragmentProcessor::RunInSeries(series, 2);
}
#endif
diff --git a/src/core/SkColorFilterShader.cpp b/src/core/SkColorFilterShader.cpp
index 4ab232a..6f9fc97 100644
--- a/src/core/SkColorFilterShader.cpp
+++ b/src/core/SkColorFilterShader.cpp
@@ -97,27 +97,25 @@
#if SK_SUPPORT_GPU
/////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* SkColorFilterShader::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkColorFilterShader::asFragmentProcessor(
GrContext* context,
const SkMatrix& viewM,
const SkMatrix* localMatrix,
SkFilterQuality fq,
SkSourceGammaTreatment gammaTreatment) const {
- SkAutoTUnref<const GrFragmentProcessor> fp1(fShader->asFragmentProcessor(context, viewM,
- localMatrix, fq,
- gammaTreatment));
- if (!fp1.get()) {
+ sk_sp<GrFragmentProcessor> fp1(fShader->asFragmentProcessor(context, viewM, localMatrix, fq,
+ gammaTreatment));
+ if (!fp1) {
return nullptr;
}
- SkAutoTUnref<const GrFragmentProcessor> fp2(fFilter->asFragmentProcessor(context));
- if (!fp2.get()) {
- return fp1.release();
+ sk_sp<GrFragmentProcessor> fp2(fFilter->asFragmentProcessor(context));
+ if (!fp2) {
+ return fp1;
}
- const GrFragmentProcessor* fpSeries[] = { fp1.get(), fp2.get() };
-
+ sk_sp<GrFragmentProcessor> fpSeries[] = { std::move(fp1), std::move(fp2) };
return GrFragmentProcessor::RunInSeries(fpSeries, 2);
}
#endif
diff --git a/src/core/SkColorFilterShader.h b/src/core/SkColorFilterShader.h
index 01a03f8..39a62ab 100644
--- a/src/core/SkColorFilterShader.h
+++ b/src/core/SkColorFilterShader.h
@@ -16,7 +16,7 @@
SkColorFilterShader(sk_sp<SkShader> shader, sk_sp<SkColorFilter> filter);
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*,
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
const SkMatrix& viewM,
const SkMatrix* localMatrix,
SkFilterQuality,
diff --git a/src/core/SkColorMatrixFilterRowMajor255.cpp b/src/core/SkColorMatrixFilterRowMajor255.cpp
index c158a79..cdfd1df 100644
--- a/src/core/SkColorMatrixFilterRowMajor255.cpp
+++ b/src/core/SkColorMatrixFilterRowMajor255.cpp
@@ -8,11 +8,12 @@
#include "SkColorMatrixFilterRowMajor255.h"
#include "SkColorPriv.h"
#include "SkNx.h"
-#include "SkReadBuffer.h"
-#include "SkWriteBuffer.h"
-#include "SkUnPreMultiply.h"
-#include "SkString.h"
#include "SkPM4fPriv.h"
+#include "SkReadBuffer.h"
+#include "SkRefCnt.h"
+#include "SkString.h"
+#include "SkUnPreMultiply.h"
+#include "SkWriteBuffer.h"
static void transpose(float dst[20], const float src[20]) {
const float* srcR = src + 0;
@@ -247,8 +248,8 @@
class ColorMatrixEffect : public GrFragmentProcessor {
public:
- static const GrFragmentProcessor* Create(const SkScalar matrix[20]) {
- return new ColorMatrixEffect(matrix);
+ static sk_sp<GrFragmentProcessor> Make(const SkScalar matrix[20]) {
+ return sk_sp<GrFragmentProcessor>(new ColorMatrixEffect(matrix));
}
const char* name() const override { return "Color Matrix"; }
@@ -387,16 +388,16 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ColorMatrixEffect);
-const GrFragmentProcessor* ColorMatrixEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> ColorMatrixEffect::TestCreate(GrProcessorTestData* d) {
SkScalar colorMatrix[20];
for (size_t i = 0; i < SK_ARRAY_COUNT(colorMatrix); ++i) {
colorMatrix[i] = d->fRandom->nextSScalar1();
}
- return ColorMatrixEffect::Create(colorMatrix);
+ return ColorMatrixEffect::Make(colorMatrix);
}
-const GrFragmentProcessor* SkColorMatrixFilterRowMajor255::asFragmentProcessor(GrContext*) const {
- return ColorMatrixEffect::Create(fMatrix);
+sk_sp<GrFragmentProcessor> SkColorMatrixFilterRowMajor255::asFragmentProcessor(GrContext*) const {
+ return ColorMatrixEffect::Make(fMatrix);
}
#endif
diff --git a/src/core/SkColorMatrixFilterRowMajor255.h b/src/core/SkColorMatrixFilterRowMajor255.h
index 0ad64fa..79709b3 100644
--- a/src/core/SkColorMatrixFilterRowMajor255.h
+++ b/src/core/SkColorMatrixFilterRowMajor255.h
@@ -25,7 +25,7 @@
sk_sp<SkColorFilter> makeComposed(sk_sp<SkColorFilter>) const override;
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*) const override;
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*) const override;
#endif
SK_TO_STRING_OVERRIDE()
diff --git a/src/core/SkColorShader.cpp b/src/core/SkColorShader.cpp
index 2c7ee8b..83fd239 100644
--- a/src/core/SkColorShader.cpp
+++ b/src/core/SkColorShader.cpp
@@ -89,12 +89,12 @@
#include "SkGr.h"
#include "effects/GrConstColorProcessor.h"
-const GrFragmentProcessor* SkColorShader::asFragmentProcessor(GrContext*, const SkMatrix&,
+sk_sp<GrFragmentProcessor> SkColorShader::asFragmentProcessor(GrContext*, const SkMatrix&,
const SkMatrix*,
SkFilterQuality,
SkSourceGammaTreatment) const {
GrColor color = SkColorToPremulGrColor(fColor);
- return GrConstColorProcessor::Create(color, GrConstColorProcessor::kModulateA_InputMode);
+ return GrConstColorProcessor::Make(color, GrConstColorProcessor::kModulateA_InputMode);
}
#endif
@@ -217,13 +217,13 @@
#include "SkGr.h"
#include "effects/GrConstColorProcessor.h"
-const GrFragmentProcessor* SkColor4Shader::asFragmentProcessor(GrContext*, const SkMatrix&,
+sk_sp<GrFragmentProcessor> SkColor4Shader::asFragmentProcessor(GrContext*, const SkMatrix&,
const SkMatrix*,
SkFilterQuality,
SkSourceGammaTreatment) const {
// TODO: how to communicate color4f to Gr
GrColor color = SkColorToPremulGrColor(fCachedByteColor);
- return GrConstColorProcessor::Create(color, GrConstColorProcessor::kModulateA_InputMode);
+ return GrConstColorProcessor::Make(color, GrConstColorProcessor::kModulateA_InputMode);
}
#endif
diff --git a/src/core/SkColorShader.h b/src/core/SkColorShader.h
index 8419742..9e0c542 100644
--- a/src/core/SkColorShader.h
+++ b/src/core/SkColorShader.h
@@ -49,7 +49,7 @@
GradientType asAGradient(GradientInfo* info) const override;
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& viewM,
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*, const SkMatrix& viewM,
const SkMatrix*, SkFilterQuality,
SkSourceGammaTreatment) const override;
#endif
@@ -104,7 +104,7 @@
GradientType asAGradient(GradientInfo* info) const override;
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& viewM,
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*, const SkMatrix& viewM,
const SkMatrix*, SkFilterQuality,
SkSourceGammaTreatment) const override;
#endif
diff --git a/src/core/SkComposeShader.cpp b/src/core/SkComposeShader.cpp
index 13569f1..e9f3f4c 100644
--- a/src/core/SkComposeShader.cpp
+++ b/src/core/SkComposeShader.cpp
@@ -183,7 +183,7 @@
/////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* SkComposeShader::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkComposeShader::asFragmentProcessor(
GrContext* context,
const SkMatrix& viewM,
const SkMatrix* localMatrix,
@@ -197,8 +197,8 @@
switch (mode) {
case SkXfermode::kClear_Mode:
- return GrConstColorProcessor::Create(GrColor_TRANSPARENT_BLACK,
- GrConstColorProcessor::kIgnore_InputMode);
+ return GrConstColorProcessor::Make(GrColor_TRANSPARENT_BLACK,
+ GrConstColorProcessor::kIgnore_InputMode);
break;
case SkXfermode::kSrc_Mode:
return fShaderB->asFragmentProcessor(context, viewM, localMatrix, fq, gammaTreatment);
@@ -207,17 +207,18 @@
return fShaderA->asFragmentProcessor(context, viewM, localMatrix, fq, gammaTreatment);
break;
default:
- SkAutoTUnref<const GrFragmentProcessor> fpA(fShaderA->asFragmentProcessor(context,
- viewM, localMatrix, fq, gammaTreatment));
- if (!fpA.get()) {
+ sk_sp<GrFragmentProcessor> fpA(fShaderA->asFragmentProcessor(context,
+ viewM, localMatrix, fq, gammaTreatment));
+ if (!fpA) {
return nullptr;
}
- SkAutoTUnref<const GrFragmentProcessor> fpB(fShaderB->asFragmentProcessor(context,
- viewM, localMatrix, fq, gammaTreatment));
- if (!fpB.get()) {
+ sk_sp<GrFragmentProcessor> fpB(fShaderB->asFragmentProcessor(context,
+ viewM, localMatrix, fq, gammaTreatment));
+ if (!fpB) {
return nullptr;
}
- return GrXfermodeFragmentProcessor::CreateFromTwoProcessors(fpB, fpA, mode);
+ return GrXfermodeFragmentProcessor::MakeFromTwoProcessors(std::move(fpB),
+ std::move(fpA), mode);
}
}
#endif
diff --git a/src/core/SkComposeShader.h b/src/core/SkComposeShader.h
index ed89b88..dcd43d3 100644
--- a/src/core/SkComposeShader.h
+++ b/src/core/SkComposeShader.h
@@ -35,11 +35,11 @@
{}
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*,
- const SkMatrix& viewM,
- const SkMatrix* localMatrix,
- SkFilterQuality,
- SkSourceGammaTreatment) const override;
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
+ const SkMatrix& viewM,
+ const SkMatrix* localMatrix,
+ SkFilterQuality,
+ SkSourceGammaTreatment) const override;
#endif
class ComposeShaderContext : public SkShader::Context {
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index c7a5701..9e21525 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -277,7 +277,7 @@
sk_sp<GrFragmentProcessor> fp,
const SkIRect& bounds) {
GrPaint paint;
- paint.addColorFragmentProcessor(fp.get());
+ paint.addColorFragmentProcessor(std::move(fp));
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kApprox,
diff --git a/src/core/SkLightingShader.cpp b/src/core/SkLightingShader.cpp
index 542d0f3..a2ce52f 100644
--- a/src/core/SkLightingShader.cpp
+++ b/src/core/SkLightingShader.cpp
@@ -72,7 +72,7 @@
bool isOpaque() const override;
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*,
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
const SkMatrix& viewM,
const SkMatrix* localMatrix,
SkFilterQuality,
@@ -350,7 +350,7 @@
return true;
}
-const GrFragmentProcessor* SkLightingShaderImpl::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkLightingShaderImpl::asFragmentProcessor(
GrContext* context,
const SkMatrix& viewM,
const SkMatrix* localMatrix,
@@ -404,10 +404,10 @@
return nullptr;
}
- SkAutoTUnref<const GrFragmentProcessor> inner (
+ sk_sp<GrFragmentProcessor> inner (
new LightingFP(diffuseTexture, normalTexture, diffM, normM, diffParams, normParams, fLights,
fInvNormRotation));
- return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+ return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
#endif
diff --git a/src/core/SkLocalMatrixShader.cpp b/src/core/SkLocalMatrixShader.cpp
index ea4db53..cb85019 100644
--- a/src/core/SkLocalMatrixShader.cpp
+++ b/src/core/SkLocalMatrixShader.cpp
@@ -7,6 +7,23 @@
#include "SkLocalMatrixShader.h"
+#if SK_SUPPORT_GPU
+#include "GrFragmentProcessor.h"
+#endif
+
+#if SK_SUPPORT_GPU
+sk_sp<GrFragmentProcessor> SkLocalMatrixShader::asFragmentProcessor(
+ GrContext* context, const SkMatrix& viewM,
+ const SkMatrix* localMatrix, SkFilterQuality fq,
+ SkSourceGammaTreatment gammaTreatment) const {
+ SkMatrix tmp = this->getLocalMatrix();
+ if (localMatrix) {
+ tmp.preConcat(*localMatrix);
+ }
+ return fProxyShader->asFragmentProcessor(context, viewM, &tmp, fq, gammaTreatment);
+}
+#endif
+
sk_sp<SkFlattenable> SkLocalMatrixShader::CreateProc(SkReadBuffer& buffer) {
SkMatrix lm;
buffer.readMatrix(&lm);
diff --git a/src/core/SkLocalMatrixShader.h b/src/core/SkLocalMatrixShader.h
index 3d590e4..ea78419 100644
--- a/src/core/SkLocalMatrixShader.h
+++ b/src/core/SkLocalMatrixShader.h
@@ -12,6 +12,8 @@
#include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
+class GrFragmentProcessor;
+
class SkLocalMatrixShader : public SkShader {
public:
SkLocalMatrixShader(SkShader* proxy, const SkMatrix& localMatrix)
@@ -24,16 +26,10 @@
}
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(
GrContext* context, const SkMatrix& viewM,
const SkMatrix* localMatrix, SkFilterQuality fq,
- SkSourceGammaTreatment gammaTreatment) const override {
- SkMatrix tmp = this->getLocalMatrix();
- if (localMatrix) {
- tmp.preConcat(*localMatrix);
- }
- return fProxyShader->asFragmentProcessor(context, viewM, &tmp, fq, gammaTreatment);
- }
+ SkSourceGammaTreatment gammaTreatment) const override;
#endif
SkShader* refAsALocalMatrixShader(SkMatrix* localMatrix) const override {
diff --git a/src/core/SkModeColorFilter.cpp b/src/core/SkModeColorFilter.cpp
index eacd261..ba3b50d 100644
--- a/src/core/SkModeColorFilter.cpp
+++ b/src/core/SkModeColorFilter.cpp
@@ -91,16 +91,16 @@
#include "effects/GrConstColorProcessor.h"
#include "SkGr.h"
-const GrFragmentProcessor* SkModeColorFilter::asFragmentProcessor(GrContext*) const {
+sk_sp<GrFragmentProcessor> SkModeColorFilter::asFragmentProcessor(GrContext*) const {
if (SkXfermode::kDst_Mode == fMode) {
return nullptr;
}
- SkAutoTUnref<const GrFragmentProcessor> constFP(
- GrConstColorProcessor::Create(SkColorToPremulGrColor(fColor),
- GrConstColorProcessor::kIgnore_InputMode));
- const GrFragmentProcessor* fp =
- GrXfermodeFragmentProcessor::CreateFromSrcProcessor(constFP, fMode);
+ sk_sp<GrFragmentProcessor> constFP(
+ GrConstColorProcessor::Make(SkColorToPremulGrColor(fColor),
+ GrConstColorProcessor::kIgnore_InputMode));
+ sk_sp<GrFragmentProcessor> fp(
+ GrXfermodeFragmentProcessor::MakeFromSrcProcessor(std::move(constFP), fMode));
if (!fp) {
return nullptr;
}
diff --git a/src/core/SkModeColorFilter.h b/src/core/SkModeColorFilter.h
index d73cab7..01d1eaa 100644
--- a/src/core/SkModeColorFilter.h
+++ b/src/core/SkModeColorFilter.h
@@ -36,7 +36,7 @@
#endif
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*) const override;
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*) const override;
#endif
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkModeColorFilter)
diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp
index a880db3..a6186e6 100644
--- a/src/core/SkPictureShader.cpp
+++ b/src/core/SkPictureShader.cpp
@@ -318,7 +318,7 @@
#endif
#if SK_SUPPORT_GPU
-const GrFragmentProcessor* SkPictureShader::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkPictureShader::asFragmentProcessor(
GrContext* context, const SkMatrix& viewM,
const SkMatrix* localMatrix,
SkFilterQuality fq,
diff --git a/src/core/SkPictureShader.h b/src/core/SkPictureShader.h
index 01a66ec..11bec1a 100644
--- a/src/core/SkPictureShader.h
+++ b/src/core/SkPictureShader.h
@@ -28,7 +28,7 @@
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureShader)
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*,
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
const SkMatrix& viewM,
const SkMatrix*,
SkFilterQuality,
diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp
index 2ec3b0b..1ab4ea7 100644
--- a/src/core/SkShader.cpp
+++ b/src/core/SkShader.cpp
@@ -18,6 +18,10 @@
#include "SkShader.h"
#include "SkWriteBuffer.h"
+#if SK_SUPPORT_GPU
+#include "GrFragmentProcessor.h"
+#endif
+
//#define SK_TRACK_SHADER_LIFETIME
#ifdef SK_TRACK_SHADER_LIFETIME
@@ -220,11 +224,13 @@
return kNone_GradientType;
}
-const GrFragmentProcessor* SkShader::asFragmentProcessor(GrContext*, const SkMatrix&,
+#if SK_SUPPORT_GPU
+sk_sp<GrFragmentProcessor> SkShader::asFragmentProcessor(GrContext*, const SkMatrix&,
const SkMatrix*, SkFilterQuality,
- SkSourceGammaTreatment) const {
+ SkSourceGammaTreatment) const {
return nullptr;
}
+#endif
SkShader* SkShader::refAsALocalMatrixShader(SkMatrix*) const {
return nullptr;
diff --git a/src/core/SkXfermode.cpp b/src/core/SkXfermode.cpp
index b6d2388..e91f53a 100644
--- a/src/core/SkXfermode.cpp
+++ b/src/core/SkXfermode.cpp
@@ -16,6 +16,13 @@
#include "SkWriteBuffer.h"
#include "SkPM4f.h"
+#if SK_SUPPORT_GPU
+#include "GrFragmentProcessor.h"
+#include "effects/GrCustomXfermode.h"
+#include "effects/GrPorterDuffXferProcessor.h"
+#include "effects/GrXfermodeFragmentProcessor.h"
+#endif
+
#define SkAlphaMulAlpha(a, b) SkMulDiv255Round(a, b)
static inline unsigned saturated_add(unsigned a, unsigned b) {
@@ -985,15 +992,15 @@
}
#if SK_SUPPORT_GPU
-const GrFragmentProcessor* SkXfermode::getFragmentProcessorForImageFilter(
- const GrFragmentProcessor*) const {
+sk_sp<GrFragmentProcessor> SkXfermode::makeFragmentProcessorForImageFilter(
+ sk_sp<GrFragmentProcessor>) const {
// This should never be called.
// TODO: make pure virtual in SkXfermode once Android update lands
SkASSERT(0);
return nullptr;
}
-GrXPFactory* SkXfermode::asXPFactory() const {
+sk_sp<GrXPFactory> SkXfermode::asXPFactory() const {
// This should never be called.
// TODO: make pure virtual in SkXfermode once Android update lands
SkASSERT(0);
@@ -1240,25 +1247,21 @@
}
#if SK_SUPPORT_GPU
-#include "effects/GrCustomXfermode.h"
-#include "effects/GrPorterDuffXferProcessor.h"
-#include "effects/GrXfermodeFragmentProcessor.h"
-
-const GrFragmentProcessor* SkProcCoeffXfermode::getFragmentProcessorForImageFilter(
- const GrFragmentProcessor* dst) const {
+sk_sp<GrFragmentProcessor> SkProcCoeffXfermode::makeFragmentProcessorForImageFilter(
+ sk_sp<GrFragmentProcessor> dst) const {
SkASSERT(dst);
- return GrXfermodeFragmentProcessor::CreateFromDstProcessor(dst, fMode);
+ return GrXfermodeFragmentProcessor::MakeFromDstProcessor(std::move(dst), fMode);
}
-GrXPFactory* SkProcCoeffXfermode::asXPFactory() const {
+sk_sp<GrXPFactory> SkProcCoeffXfermode::asXPFactory() const {
if (CANNOT_USE_COEFF != fSrcCoeff) {
- GrXPFactory* result = GrPorterDuffXPFactory::Create(fMode);
+ sk_sp<GrXPFactory> result(GrPorterDuffXPFactory::Make(fMode));
SkASSERT(result);
return result;
}
SkASSERT(GrCustomXfermode::IsSupportedMode(fMode));
- return GrCustomXfermode::CreateXPFactory(fMode);
+ return GrCustomXfermode::MakeXPFactory(fMode);
}
#endif
diff --git a/src/core/SkXfermode_proccoeff.h b/src/core/SkXfermode_proccoeff.h
index 3b45594..357de43 100644
--- a/src/core/SkXfermode_proccoeff.h
+++ b/src/core/SkXfermode_proccoeff.h
@@ -45,9 +45,9 @@
bool isOpaque(SkXfermode::SrcColorOpacity opacityType) const override;
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* getFragmentProcessorForImageFilter(
- const GrFragmentProcessor*) const override;
- GrXPFactory* asXPFactory() const override;
+ sk_sp<GrFragmentProcessor> makeFragmentProcessorForImageFilter(
+ sk_sp<GrFragmentProcessor>) const override;
+ sk_sp<GrXPFactory> asXPFactory() const override;
#endif
SK_TO_STRING_OVERRIDE()
diff --git a/src/effects/GrAlphaThresholdFragmentProcessor.cpp b/src/effects/GrAlphaThresholdFragmentProcessor.cpp
index 1437989..03a4515 100644
--- a/src/effects/GrAlphaThresholdFragmentProcessor.cpp
+++ b/src/effects/GrAlphaThresholdFragmentProcessor.cpp
@@ -11,6 +11,7 @@
#include "GrInvariantOutput.h"
#include "GrTextureAccess.h"
+#include "SkRefCnt.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
@@ -144,7 +145,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrAlphaThresholdFragmentProcessor);
-const GrFragmentProcessor* GrAlphaThresholdFragmentProcessor::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrAlphaThresholdFragmentProcessor::TestCreate(GrProcessorTestData* d) {
GrTexture* bmpTex = d->fTextures[GrProcessorUnitTest::kSkiaPMTextureIdx];
GrTexture* maskTex = d->fTextures[GrProcessorUnitTest::kAlphaTextureIdx];
float innerThresh = d->fRandom->nextUScalar1();
@@ -158,7 +159,7 @@
SkIRect bounds = SkIRect::MakeXYWH(x, y, width, height);
return GrAlphaThresholdFragmentProcessor::Make(bmpTex, maskTex,
innerThresh, outerThresh,
- bounds).release();
+ bounds);
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/effects/GrCircleBlurFragmentProcessor.cpp b/src/effects/GrCircleBlurFragmentProcessor.cpp
index bd8adee..e5c0299 100644
--- a/src/effects/GrCircleBlurFragmentProcessor.cpp
+++ b/src/effects/GrCircleBlurFragmentProcessor.cpp
@@ -289,11 +289,11 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrCircleBlurFragmentProcessor);
-const GrFragmentProcessor* GrCircleBlurFragmentProcessor::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrCircleBlurFragmentProcessor::TestCreate(GrProcessorTestData* d) {
SkScalar wh = d->fRandom->nextRangeScalar(100.f, 1000.f);
SkScalar sigma = d->fRandom->nextRangeF(1.f,10.f);
SkRect circle = SkRect::MakeWH(wh, wh);
- return GrCircleBlurFragmentProcessor::Create(d->fContext->textureProvider(), circle, sigma);
+ return GrCircleBlurFragmentProcessor::Make(d->fContext->textureProvider(), circle, sigma);
}
#endif
diff --git a/src/effects/GrCircleBlurFragmentProcessor.h b/src/effects/GrCircleBlurFragmentProcessor.h
index ca12db7..6dc599b 100644
--- a/src/effects/GrCircleBlurFragmentProcessor.h
+++ b/src/effects/GrCircleBlurFragmentProcessor.h
@@ -34,8 +34,8 @@
return str;
}
- static const GrFragmentProcessor* Create(GrTextureProvider*textureProvider,
- const SkRect& circle, float sigma) {
+ static sk_sp<GrFragmentProcessor> Make(GrTextureProvider*textureProvider,
+ const SkRect& circle, float sigma) {
float offset;
SkAutoTUnref<GrTexture> blurProfile(CreateCircleBlurProfileTexture(textureProvider,
@@ -45,7 +45,8 @@
if (!blurProfile) {
return nullptr;
}
- return new GrCircleBlurFragmentProcessor(circle, sigma, offset, blurProfile);
+ return sk_sp<GrFragmentProcessor>(
+ new GrCircleBlurFragmentProcessor(circle, sigma, offset, blurProfile));
}
const SkRect& circle() const { return fCircle; }
diff --git a/src/effects/SkArithmeticMode.cpp b/src/effects/SkArithmeticMode.cpp
index e926f1b..bf17bb8 100644
--- a/src/effects/SkArithmeticMode.cpp
+++ b/src/effects/SkArithmeticMode.cpp
@@ -33,9 +33,9 @@
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkArithmeticMode_scalar)
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* getFragmentProcessorForImageFilter(
- const GrFragmentProcessor* dst) const override;
- GrXPFactory* asXPFactory() const override;
+ sk_sp<GrFragmentProcessor> makeFragmentProcessorForImageFilter(
+ sk_sp<GrFragmentProcessor> dst) const override;
+ sk_sp<GrXPFactory> asXPFactory() const override;
#endif
private:
@@ -127,22 +127,22 @@
//////////////////////////////////////////////////////////////////////////////
#if SK_SUPPORT_GPU
-const GrFragmentProcessor* SkArithmeticMode_scalar::getFragmentProcessorForImageFilter(
- const GrFragmentProcessor* dst) const {
- return GrArithmeticFP::Create(SkScalarToFloat(fK[0]),
- SkScalarToFloat(fK[1]),
- SkScalarToFloat(fK[2]),
- SkScalarToFloat(fK[3]),
- fEnforcePMColor,
- dst);
+sk_sp<GrFragmentProcessor> SkArithmeticMode_scalar::makeFragmentProcessorForImageFilter(
+ sk_sp<GrFragmentProcessor> dst) const {
+ return GrArithmeticFP::Make(SkScalarToFloat(fK[0]),
+ SkScalarToFloat(fK[1]),
+ SkScalarToFloat(fK[2]),
+ SkScalarToFloat(fK[3]),
+ fEnforcePMColor,
+ std::move(dst));
}
-GrXPFactory* SkArithmeticMode_scalar::asXPFactory() const {
- return GrArithmeticXPFactory::Create(SkScalarToFloat(fK[0]),
- SkScalarToFloat(fK[1]),
- SkScalarToFloat(fK[2]),
- SkScalarToFloat(fK[3]),
- fEnforcePMColor);
+sk_sp<GrXPFactory> SkArithmeticMode_scalar::asXPFactory() const {
+ return GrArithmeticXPFactory::Make(SkScalarToFloat(fK[0]),
+ SkScalarToFloat(fK[1]),
+ SkScalarToFloat(fK[2]),
+ SkScalarToFloat(fK[3]),
+ fEnforcePMColor);
}
#endif
diff --git a/src/effects/SkArithmeticMode_gpu.cpp b/src/effects/SkArithmeticMode_gpu.cpp
index 7fb6d66..50c46ad 100644
--- a/src/effects/SkArithmeticMode_gpu.cpp
+++ b/src/effects/SkArithmeticMode_gpu.cpp
@@ -85,12 +85,12 @@
///////////////////////////////////////////////////////////////////////////////
GrArithmeticFP::GrArithmeticFP(float k1, float k2, float k3, float k4, bool enforcePMColor,
- const GrFragmentProcessor* dst)
+ sk_sp<GrFragmentProcessor> dst)
: fK1(k1), fK2(k2), fK3(k3), fK4(k4), fEnforcePMColor(enforcePMColor) {
this->initClassID<GrArithmeticFP>();
SkASSERT(dst);
- SkDEBUGCODE(int dstIndex = )this->registerChildProcessor(dst);
+ SkDEBUGCODE(int dstIndex = )this->registerChildProcessor(std::move(dst));
SkASSERT(0 == dstIndex);
}
@@ -118,15 +118,15 @@
///////////////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* GrArithmeticFP::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrArithmeticFP::TestCreate(GrProcessorTestData* d) {
float k1 = d->fRandom->nextF();
float k2 = d->fRandom->nextF();
float k3 = d->fRandom->nextF();
float k4 = d->fRandom->nextF();
bool enforcePMColor = d->fRandom->nextBool();
- SkAutoTUnref<const GrFragmentProcessor> dst(GrProcessorUnitTest::CreateChildFP(d));
- return new GrArithmeticFP(k1, k2, k3, k4, enforcePMColor, dst);
+ sk_sp<GrFragmentProcessor> dst(GrProcessorUnitTest::MakeChildFP(d));
+ return GrArithmeticFP::Make(k1, k2, k3, k4, enforcePMColor, std::move(dst));
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrArithmeticFP);
@@ -283,14 +283,14 @@
GR_DEFINE_XP_FACTORY_TEST(GrArithmeticXPFactory);
-const GrXPFactory* GrArithmeticXPFactory::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrXPFactory> GrArithmeticXPFactory::TestCreate(GrProcessorTestData* d) {
float k1 = d->fRandom->nextF();
float k2 = d->fRandom->nextF();
float k3 = d->fRandom->nextF();
float k4 = d->fRandom->nextF();
bool enforcePMColor = d->fRandom->nextBool();
- return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor);
+ return GrArithmeticXPFactory::Make(k1, k2, k3, k4, enforcePMColor);
}
#endif
diff --git a/src/effects/SkArithmeticMode_gpu.h b/src/effects/SkArithmeticMode_gpu.h
index b8a40cf..98cbaf9 100644
--- a/src/effects/SkArithmeticMode_gpu.h
+++ b/src/effects/SkArithmeticMode_gpu.h
@@ -31,9 +31,10 @@
class GrArithmeticFP : public GrFragmentProcessor {
public:
- static const GrFragmentProcessor* Create(float k1, float k2, float k3, float k4,
- bool enforcePMColor, const GrFragmentProcessor* dst) {
- return new GrArithmeticFP(k1, k2, k3, k4, enforcePMColor, dst);
+ static sk_sp<GrFragmentProcessor> Make(float k1, float k2, float k3, float k4,
+ bool enforcePMColor, sk_sp<GrFragmentProcessor> dst) {
+ return sk_sp<GrFragmentProcessor>(new GrArithmeticFP(k1, k2, k3, k4, enforcePMColor,
+ std::move(dst)));
}
~GrArithmeticFP() override {};
@@ -62,7 +63,7 @@
void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
GrArithmeticFP(float k1, float k2, float k3, float k4, bool enforcePMColor,
- const GrFragmentProcessor* dst);
+ sk_sp<GrFragmentProcessor> dst);
float fK1, fK2, fK3, fK4;
bool fEnforcePMColor;
@@ -77,8 +78,8 @@
class GrArithmeticXPFactory : public GrXPFactory {
public:
- static GrXPFactory* Create(float k1, float k2, float k3, float k4, bool enforcePMColor) {
- return new GrArithmeticXPFactory(k1, k2, k3, k4, enforcePMColor);
+ static sk_sp<GrXPFactory> Make(float k1, float k2, float k3, float k4, bool enforcePMColor) {
+ return sk_sp<GrXPFactory>(new GrArithmeticXPFactory(k1, k2, k3, k4, enforcePMColor));
}
void getInvariantBlendedColor(const GrProcOptInfo& colorPOI,
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index 969afc1..1d277f8 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -607,8 +607,8 @@
const char* name() const override { return "RectBlur"; }
- static GrFragmentProcessor* Create(GrTextureProvider *textureProvider,
- const SkRect& rect, float sigma) {
+ static sk_sp<GrFragmentProcessor> Make(GrTextureProvider *textureProvider,
+ const SkRect& rect, float sigma) {
int doubleProfileSize = SkScalarCeilToInt(12*sigma);
if (doubleProfileSize >= rect.width() || doubleProfileSize >= rect.height()) {
@@ -637,11 +637,11 @@
SkScalarAbs(rect.width()) > kMAX_BLUR_COORD ||
SkScalarAbs(rect.height()) > kMAX_BLUR_COORD) {
precision = kHigh_GrSLPrecision;
- }
- else {
+ } else {
precision = kDefault_GrSLPrecision;
}
- return new GrRectBlurEffect(rect, sigma, blurProfile, precision);
+ return sk_sp<GrFragmentProcessor>(
+ new GrRectBlurEffect(rect, sigma, blurProfile, precision));
}
const SkRect& getRect() const { return fRect; }
@@ -841,12 +841,12 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRectBlurEffect);
-const GrFragmentProcessor* GrRectBlurEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrRectBlurEffect::TestCreate(GrProcessorTestData* d) {
float sigma = d->fRandom->nextRangeF(3,8);
float width = d->fRandom->nextRangeF(200,300);
float height = d->fRandom->nextRangeF(200,300);
- return GrRectBlurEffect::Create(d->fContext->textureProvider(), SkRect::MakeWH(width, height),
- sigma);
+ return GrRectBlurEffect::Make(d->fContext->textureProvider(), SkRect::MakeWH(width, height),
+ sigma);
}
@@ -870,16 +870,16 @@
SkScalar xformedSigma = this->computeXformedSigma(viewMatrix);
- SkAutoTUnref<const GrFragmentProcessor> fp;
+ sk_sp<GrFragmentProcessor> fp;
SkRect rect;
if (path.isRect(&rect)) {
int pad = SkScalarCeilToInt(6*xformedSigma)/2;
rect.outset(SkIntToScalar(pad), SkIntToScalar(pad));
- fp.reset(GrRectBlurEffect::Create(texProvider, rect, xformedSigma));
+ fp = GrRectBlurEffect::Make(texProvider, rect, xformedSigma);
} else if (path.isOval(&rect) && SkScalarNearlyEqual(rect.width(), rect.height())) {
- fp.reset(GrCircleBlurFragmentProcessor::Create(texProvider, rect, xformedSigma));
+ fp = GrCircleBlurFragmentProcessor::Make(texProvider, rect, xformedSigma);
// expand the rect for the coverage geometry
int pad = SkScalarCeilToInt(6*xformedSigma)/2;
@@ -892,7 +892,7 @@
return false;
}
- grp->addCoverageFragmentProcessor(fp);
+ grp->addCoverageFragmentProcessor(std::move(fp));
SkMatrix inverse;
if (!viewMatrix.invert(&inverse)) {
@@ -908,7 +908,7 @@
class GrRRectBlurEffect : public GrFragmentProcessor {
public:
- static const GrFragmentProcessor* Create(GrTextureProvider*, float sigma, const SkRRect&);
+ static sk_sp<GrFragmentProcessor> Make(GrTextureProvider*, float sigma, const SkRRect&);
virtual ~GrRRectBlurEffect() {};
const char* name() const override { return "GrRRectBlur"; }
@@ -938,10 +938,10 @@
};
-const GrFragmentProcessor* GrRRectBlurEffect::Create(GrTextureProvider* texProvider, float sigma,
+sk_sp<GrFragmentProcessor> GrRRectBlurEffect::Make(GrTextureProvider* texProvider, float sigma,
const SkRRect& rrect) {
if (rrect.isCircle()) {
- return GrCircleBlurFragmentProcessor::Create(texProvider, rrect.rect(), sigma);
+ return GrCircleBlurFragmentProcessor::Make(texProvider, rrect.rect(), sigma);
}
if (!rrect.isSimpleCircular()) {
@@ -1014,7 +1014,7 @@
}
texProvider->assignUniqueKeyToTexture(key, blurNinePatchTexture);
}
- return new GrRRectBlurEffect(sigma, rrect, blurNinePatchTexture);
+ return sk_sp<GrFragmentProcessor>(new GrRRectBlurEffect(sigma, rrect, blurNinePatchTexture));
}
void GrRRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
@@ -1041,14 +1041,14 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRRectBlurEffect);
-const GrFragmentProcessor* GrRRectBlurEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrRRectBlurEffect::TestCreate(GrProcessorTestData* d) {
SkScalar w = d->fRandom->nextRangeScalar(100.f, 1000.f);
SkScalar h = d->fRandom->nextRangeScalar(100.f, 1000.f);
SkScalar r = d->fRandom->nextRangeF(1.f, 9.f);
SkScalar sigma = d->fRandom->nextRangeF(1.f,10.f);
SkRRect rrect;
rrect.setRectXY(SkRect::MakeWH(w, h), r, r);
- return GrRRectBlurEffect::Create(d->fContext->textureProvider(), sigma, rrect);
+ return GrRRectBlurEffect::Make(d->fContext->textureProvider(), sigma, rrect);
}
//////////////////////////////////////////////////////////////////////////////
@@ -1174,13 +1174,12 @@
SkRect proxyRect = rrect.rect();
proxyRect.outset(extra, extra);
- SkAutoTUnref<const GrFragmentProcessor> fp(GrRRectBlurEffect::Create(texProvider,
- xformedSigma, rrect));
+ sk_sp<GrFragmentProcessor> fp(GrRRectBlurEffect::Make(texProvider, xformedSigma, rrect));
if (!fp) {
return false;
}
- grp->addCoverageFragmentProcessor(fp);
+ grp->addCoverageFragmentProcessor(std::move(fp));
SkMatrix inverse;
if (!viewMatrix.invert(&inverse)) {
@@ -1262,7 +1261,7 @@
SkMatrix matrix;
matrix.setIDiv(src->width(), src->height());
// Blend pathTexture over blurTexture.
- paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(src, matrix))->unref();
+ paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(src, matrix));
if (kInner_SkBlurStyle == fBlurStyle) {
// inner: dst = dst * src
paint.setCoverageSetOpXPFactory(SkRegion::kIntersect_Op);
diff --git a/src/effects/SkColorCubeFilter.cpp b/src/effects/SkColorCubeFilter.cpp
index fdf571c..3eb70d32 100644
--- a/src/effects/SkColorCubeFilter.cpp
+++ b/src/effects/SkColorCubeFilter.cpp
@@ -161,8 +161,9 @@
class GrColorCubeEffect : public GrFragmentProcessor {
public:
- static const GrFragmentProcessor* Create(GrTexture* colorCube) {
- return (nullptr != colorCube) ? new GrColorCubeEffect(colorCube) : nullptr;
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* colorCube) {
+ return (nullptr != colorCube) ? sk_sp<GrFragmentProcessor>(new GrColorCubeEffect(colorCube))
+ : nullptr;
}
virtual ~GrColorCubeEffect();
@@ -297,7 +298,7 @@
const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
}
-const GrFragmentProcessor* SkColorCubeFilter::asFragmentProcessor(GrContext* context) const {
+sk_sp<GrFragmentProcessor> SkColorCubeFilter::asFragmentProcessor(GrContext* context) const {
static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
GrUniqueKey key;
GrUniqueKey::Builder builder(&key, kDomain, 2);
@@ -323,6 +324,6 @@
}
}
- return GrColorCubeEffect::Create(textureCube);
+ return sk_sp<GrFragmentProcessor>(GrColorCubeEffect::Make(textureCube));
}
#endif
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index 541dbbd..29ce3fe 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -214,13 +214,14 @@
#if SK_SUPPORT_GPU
class GrDisplacementMapEffect : public GrFragmentProcessor {
public:
- static GrFragmentProcessor* Create(
+ static sk_sp<GrFragmentProcessor> Make(
SkDisplacementMapEffect::ChannelSelectorType xChannelSelector,
SkDisplacementMapEffect::ChannelSelectorType yChannelSelector, SkVector scale,
GrTexture* displacement, const SkMatrix& offsetMatrix, GrTexture* color,
const SkISize& colorDimensions) {
- return new GrDisplacementMapEffect(xChannelSelector, yChannelSelector, scale, displacement,
- offsetMatrix, color, colorDimensions);
+ return sk_sp<GrFragmentProcessor>(
+ new GrDisplacementMapEffect(xChannelSelector, yChannelSelector, scale, displacement,
+ offsetMatrix, color, colorDimensions));
}
virtual ~GrDisplacementMapEffect();
@@ -323,14 +324,13 @@
SkIntToScalar(colorOffset.fY - displOffset.fY));
paint.addColorFragmentProcessor(
- GrDisplacementMapEffect::Create(fXChannelSelector,
- fYChannelSelector,
- scale,
- displTexture.get(),
- offsetMatrix,
- colorTexture.get(),
- SkISize::Make(color->width(),
- color->height())))->unref();
+ GrDisplacementMapEffect::Make(fXChannelSelector,
+ fYChannelSelector,
+ scale,
+ displTexture.get(),
+ offsetMatrix,
+ colorTexture.get(),
+ SkISize::Make(color->width(), color->height())));
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
SkMatrix matrix;
matrix.setTranslate(-SkIntToScalar(colorBounds.x()), -SkIntToScalar(colorBounds.y()));
@@ -504,7 +504,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDisplacementMapEffect);
-const GrFragmentProcessor* GrDisplacementMapEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrDisplacementMapEffect::TestCreate(GrProcessorTestData* d) {
int texIdxDispl = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
int texIdxColor = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
@@ -521,9 +521,9 @@
SkISize colorDimensions;
colorDimensions.fWidth = d->fRandom->nextRangeU(0, d->fTextures[texIdxColor]->width());
colorDimensions.fHeight = d->fRandom->nextRangeU(0, d->fTextures[texIdxColor]->height());
- return GrDisplacementMapEffect::Create(xChannelSelector, yChannelSelector, scale,
- d->fTextures[texIdxDispl], SkMatrix::I(),
- d->fTextures[texIdxColor], colorDimensions);
+ return GrDisplacementMapEffect::Make(xChannelSelector, yChannelSelector, scale,
+ d->fTextures[texIdxDispl], SkMatrix::I(),
+ d->fTextures[texIdxColor], colorDimensions);
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/effects/SkGpuBlurUtils.cpp b/src/effects/SkGpuBlurUtils.cpp
index b377b41..9bc1265 100644
--- a/src/effects/SkGpuBlurUtils.cpp
+++ b/src/effects/SkGpuBlurUtils.cpp
@@ -76,9 +76,9 @@
float bounds[2]) {
GrPaint paint;
paint.setGammaCorrect(drawContext->isGammaCorrect());
- SkAutoTUnref<GrFragmentProcessor> conv(GrConvolutionEffect::CreateGaussian(
+ sk_sp<GrFragmentProcessor> conv(GrConvolutionEffect::MakeGaussian(
texture, direction, radius, sigma, useBounds, bounds));
- paint.addColorFragmentProcessor(conv);
+ paint.addColorFragmentProcessor(std::move(conv));
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
SkMatrix localMatrix = SkMatrix::MakeTrans(-SkIntToScalar(srcOffset.x()),
-SkIntToScalar(srcOffset.y()));
@@ -104,11 +104,11 @@
paint.setGammaCorrect(drawContext->isGammaCorrect());
SkIRect bounds = srcBounds ? *srcBounds : SkIRect::EmptyIRect();
- SkAutoTUnref<GrFragmentProcessor> conv(GrMatrixConvolutionEffect::CreateGaussian(
+ sk_sp<GrFragmentProcessor> conv(GrMatrixConvolutionEffect::MakeGaussian(
texture, bounds, size, 1.0, 0.0, kernelOffset,
srcBounds ? GrTextureDomain::kDecal_Mode : GrTextureDomain::kIgnore_Mode,
true, sigmaX, sigmaY));
- paint.addColorFragmentProcessor(conv);
+ paint.addColorFragmentProcessor(std::move(conv));
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
drawContext->fillRectWithLocalMatrix(clip, paint, SkMatrix::I(),
SkRect::Make(dstRect), localMatrix);
@@ -273,13 +273,13 @@
matrix.mapRect(&domain, SkRect::Make(*srcBounds));
domain.inset((i < scaleFactorX) ? SK_ScalarHalf / srcTexture->width() : 0.0f,
(i < scaleFactorY) ? SK_ScalarHalf / srcTexture->height() : 0.0f);
- sk_sp<const GrFragmentProcessor> fp(GrTextureDomainEffect::Create(
+ sk_sp<GrFragmentProcessor> fp(GrTextureDomainEffect::Make(
srcTexture.get(),
matrix,
domain,
GrTextureDomain::kDecal_Mode,
GrTextureParams::kBilerp_FilterMode));
- paint.addColorFragmentProcessor(fp.get());
+ paint.addColorFragmentProcessor(std::move(fp));
srcRect.offset(-srcOffset);
srcOffset.set(0, 0);
} else {
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index 7f4dcfd..8bf4077 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -359,10 +359,10 @@
SkSpecialImage* input,
const SkIRect& bounds,
const SkMatrix& matrix) const;
- virtual GrFragmentProcessor* getFragmentProcessor(GrTexture*,
- const SkMatrix&,
- const SkIRect* srcBounds,
- BoundaryMode boundaryMode) const = 0;
+ virtual sk_sp<GrFragmentProcessor> makeFragmentProcessor(GrTexture*,
+ const SkMatrix&,
+ const SkIRect* srcBounds,
+ BoundaryMode boundaryMode) const = 0;
#endif
private:
#if SK_SUPPORT_GPU
@@ -390,8 +390,9 @@
SkRect srcRect = dstRect.makeOffset(SkIntToScalar(bounds.x()), SkIntToScalar(bounds.y()));
GrPaint paint;
// SRGBTODO: AllowSRGBInputs?
- GrFragmentProcessor* fp = this->getFragmentProcessor(src, matrix, srcBounds, boundaryMode);
- paint.addColorFragmentProcessor(fp)->unref();
+ sk_sp<GrFragmentProcessor> fp(this->makeFragmentProcessor(src, matrix, srcBounds,
+ boundaryMode));
+ paint.addColorFragmentProcessor(std::move(fp));
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
drawContext->fillRectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect);
}
@@ -480,8 +481,9 @@
SkIPoint* offset) const override;
#if SK_SUPPORT_GPU
- GrFragmentProcessor* getFragmentProcessor(GrTexture*, const SkMatrix&, const SkIRect* bounds,
- BoundaryMode) const override;
+ sk_sp<GrFragmentProcessor> makeFragmentProcessor(GrTexture*, const SkMatrix&,
+ const SkIRect* bounds,
+ BoundaryMode) const override;
#endif
private:
@@ -515,8 +517,9 @@
SkIPoint* offset) const override;
#if SK_SUPPORT_GPU
- GrFragmentProcessor* getFragmentProcessor(GrTexture*, const SkMatrix&, const SkIRect* bounds,
- BoundaryMode) const override;
+ sk_sp<GrFragmentProcessor> makeFragmentProcessor(GrTexture*, const SkMatrix&,
+ const SkIRect* bounds,
+ BoundaryMode) const override;
#endif
private:
@@ -560,15 +563,16 @@
class GrDiffuseLightingEffect : public GrLightingEffect {
public:
- static GrFragmentProcessor* Create(GrTexture* texture,
- const SkImageFilterLight* light,
- SkScalar surfaceScale,
- const SkMatrix& matrix,
- SkScalar kd,
- BoundaryMode boundaryMode,
- const SkIRect* srcBounds) {
- return new GrDiffuseLightingEffect(texture, light, surfaceScale, matrix, kd, boundaryMode,
- srcBounds);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* texture,
+ const SkImageFilterLight* light,
+ SkScalar surfaceScale,
+ const SkMatrix& matrix,
+ SkScalar kd,
+ BoundaryMode boundaryMode,
+ const SkIRect* srcBounds) {
+ return sk_sp<GrFragmentProcessor>(
+ new GrDiffuseLightingEffect(texture, light, surfaceScale, matrix, kd, boundaryMode,
+ srcBounds));
}
const char* name() const override { return "DiffuseLighting"; }
@@ -597,16 +601,17 @@
class GrSpecularLightingEffect : public GrLightingEffect {
public:
- static GrFragmentProcessor* Create(GrTexture* texture,
- const SkImageFilterLight* light,
- SkScalar surfaceScale,
- const SkMatrix& matrix,
- SkScalar ks,
- SkScalar shininess,
- BoundaryMode boundaryMode,
- const SkIRect* srcBounds) {
- return new GrSpecularLightingEffect(texture, light, surfaceScale, matrix, ks, shininess,
- boundaryMode, srcBounds);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* texture,
+ const SkImageFilterLight* light,
+ SkScalar surfaceScale,
+ const SkMatrix& matrix,
+ SkScalar ks,
+ SkScalar shininess,
+ BoundaryMode boundaryMode,
+ const SkIRect* srcBounds) {
+ return sk_sp<GrFragmentProcessor>(
+ new GrSpecularLightingEffect(texture, light, surfaceScale, matrix, ks, shininess,
+ boundaryMode, srcBounds));
}
const char* name() const override { return "SpecularLighting"; }
@@ -1330,14 +1335,14 @@
#endif
#if SK_SUPPORT_GPU
-GrFragmentProcessor* SkDiffuseLightingImageFilter::getFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkDiffuseLightingImageFilter::makeFragmentProcessor(
GrTexture* texture,
const SkMatrix& matrix,
const SkIRect* srcBounds,
BoundaryMode boundaryMode) const {
SkScalar scale = SkScalarMul(this->surfaceScale(), SkIntToScalar(255));
- return GrDiffuseLightingEffect::Create(texture, this->light(), scale, matrix, this->kd(),
- boundaryMode, srcBounds);
+ return GrDiffuseLightingEffect::Make(texture, this->light(), scale, matrix, this->kd(),
+ boundaryMode, srcBounds);
}
#endif
@@ -1495,14 +1500,14 @@
#endif
#if SK_SUPPORT_GPU
-GrFragmentProcessor* SkSpecularLightingImageFilter::getFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkSpecularLightingImageFilter::makeFragmentProcessor(
GrTexture* texture,
const SkMatrix& matrix,
const SkIRect* srcBounds,
BoundaryMode boundaryMode) const {
SkScalar scale = SkScalarMul(this->surfaceScale(), SkIntToScalar(255));
- return GrSpecularLightingEffect::Create(texture, this->light(), scale, matrix, this->ks(),
- this->shininess(), boundaryMode, srcBounds);
+ return GrSpecularLightingEffect::Make(texture, this->light(), scale, matrix, this->ks(),
+ this->shininess(), boundaryMode, srcBounds);
}
#endif
@@ -1746,7 +1751,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDiffuseLightingEffect);
-const GrFragmentProcessor* GrDiffuseLightingEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrDiffuseLightingEffect::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
GrTexture* tex = d->fTextures[texIdx];
@@ -1762,7 +1767,7 @@
d->fRandom->nextRangeU(0, tex->width()),
d->fRandom->nextRangeU(0, tex->height()));
BoundaryMode mode = static_cast<BoundaryMode>(d->fRandom->nextU() % kBoundaryModeCount);
- return GrDiffuseLightingEffect::Create(tex, light, surfaceScale, matrix, kd, mode, &srcBounds);
+ return GrDiffuseLightingEffect::Make(tex, light, surfaceScale, matrix, kd, mode, &srcBounds);
}
@@ -1963,7 +1968,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSpecularLightingEffect);
-const GrFragmentProcessor* GrSpecularLightingEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrSpecularLightingEffect::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
GrTexture* tex = d->fTextures[texIdx];
@@ -1980,9 +1985,9 @@
d->fRandom->nextRangeU(0, tex->height()),
d->fRandom->nextRangeU(0, tex->width()),
d->fRandom->nextRangeU(0, tex->height()));
- return GrSpecularLightingEffect::Create(d->fTextures[GrProcessorUnitTest::kAlphaTextureIdx],
- light, surfaceScale, matrix, ks, shininess, mode,
- &srcBounds);
+ return GrSpecularLightingEffect::Make(d->fTextures[GrProcessorUnitTest::kAlphaTextureIdx],
+ light, surfaceScale, matrix, ks, shininess, mode,
+ &srcBounds);
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/effects/SkLumaColorFilter.cpp b/src/effects/SkLumaColorFilter.cpp
index 28b2e1e..ec94eca 100644
--- a/src/effects/SkLumaColorFilter.cpp
+++ b/src/effects/SkLumaColorFilter.cpp
@@ -58,8 +58,8 @@
#if SK_SUPPORT_GPU
class LumaColorFilterEffect : public GrFragmentProcessor {
public:
- static const GrFragmentProcessor* Create() {
- return new LumaColorFilterEffect;
+ static sk_sp<GrFragmentProcessor> Make() {
+ return sk_sp<GrFragmentProcessor>(new LumaColorFilterEffect);
}
const char* name() const override { return "Luminance-to-Alpha"; }
@@ -111,8 +111,7 @@
}
};
-const GrFragmentProcessor* SkLumaColorFilter::asFragmentProcessor(GrContext*) const {
-
- return LumaColorFilterEffect::Create();
+sk_sp<GrFragmentProcessor> SkLumaColorFilter::asFragmentProcessor(GrContext*) const {
+ return LumaColorFilterEffect::Make();
}
#endif
diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp
index 517e31d..cc2d243 100644
--- a/src/effects/SkMagnifierImageFilter.cpp
+++ b/src/effects/SkMagnifierImageFilter.cpp
@@ -28,18 +28,18 @@
class GrMagnifierEffect : public GrSingleTextureEffect {
public:
- static GrFragmentProcessor* Create(GrTexture* texture,
- const SkRect& bounds,
- float xOffset,
- float yOffset,
- float xInvZoom,
- float yInvZoom,
- float xInvInset,
- float yInvInset) {
- return new GrMagnifierEffect(texture, bounds,
- xOffset, yOffset,
- xInvZoom, yInvZoom,
- xInvInset, yInvInset);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* texture,
+ const SkRect& bounds,
+ float xOffset,
+ float yOffset,
+ float xInvZoom,
+ float yInvZoom,
+ float xInvInset,
+ float yInvInset) {
+ return sk_sp<GrFragmentProcessor>(new GrMagnifierEffect(texture, bounds,
+ xOffset, yOffset,
+ xInvZoom, yInvZoom,
+ xInvInset, yInvInset));
}
~GrMagnifierEffect() override {};
@@ -192,7 +192,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMagnifierEffect);
-const GrFragmentProcessor* GrMagnifierEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrMagnifierEffect::TestCreate(GrProcessorTestData* d) {
GrTexture* texture = d->fTextures[0];
const int kMaxWidth = 200;
const int kMaxHeight = 200;
@@ -203,7 +203,7 @@
uint32_t y = d->fRandom->nextULessThan(kMaxHeight - height);
uint32_t inset = d->fRandom->nextULessThan(kMaxInset);
- GrFragmentProcessor* effect = GrMagnifierEffect::Create(
+ sk_sp<GrFragmentProcessor> effect(GrMagnifierEffect::Make(
texture,
SkRect::MakeWH(SkIntToScalar(kMaxWidth), SkIntToScalar(kMaxHeight)),
(float) width / texture->width(),
@@ -211,7 +211,7 @@
texture->width() / (float) x,
texture->height() / (float) y,
(float) inset / texture->width(),
- (float) inset / texture->height());
+ (float) inset / texture->height()));
SkASSERT(effect);
return effect;
}
@@ -324,7 +324,7 @@
SkIntToScalar(inputTexture->width()) / bounds.width(),
SkIntToScalar(inputTexture->height()) / bounds.height());
// SRGBTODO: Handle sRGB here
- sk_sp<GrFragmentProcessor> fp(GrMagnifierEffect::Create(
+ sk_sp<GrFragmentProcessor> fp(GrMagnifierEffect::Make(
inputTexture.get(),
effectBounds,
fSrcRect.x() / inputTexture->width(),
diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp
index f5d9a3f..67d155b 100644
--- a/src/effects/SkMatrixConvolutionImageFilter.cpp
+++ b/src/effects/SkMatrixConvolutionImageFilter.cpp
@@ -315,8 +315,7 @@
bounds.offset(-inputOffset);
// SRGBTODO: handle sRGB here
- sk_sp<GrFragmentProcessor> fp(GrMatrixConvolutionEffect::Create(
- inputTexture.get(),
+ sk_sp<GrFragmentProcessor> fp(GrMatrixConvolutionEffect::Make(inputTexture.get(),
bounds,
fKernelSize,
fKernel,
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index bbd236e..4ac6568 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -143,14 +143,14 @@
kDilate_MorphologyType,
};
- static GrFragmentProcessor* Create(GrTexture* tex, Direction dir, int radius,
- MorphologyType type) {
- return new GrMorphologyEffect(tex, dir, radius, type);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, Direction dir, int radius,
+ MorphologyType type) {
+ return sk_sp<GrFragmentProcessor>(new GrMorphologyEffect(tex, dir, radius, type));
}
- static GrFragmentProcessor* Create(GrTexture* tex, Direction dir, int radius,
- MorphologyType type, float bounds[2]) {
- return new GrMorphologyEffect(tex, dir, radius, type, bounds);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, Direction dir, int radius,
+ MorphologyType type, float bounds[2]) {
+ return sk_sp<GrFragmentProcessor>(new GrMorphologyEffect(tex, dir, radius, type, bounds));
}
virtual ~GrMorphologyEffect();
@@ -370,16 +370,16 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMorphologyEffect);
-const GrFragmentProcessor* GrMorphologyEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrMorphologyEffect::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
- GrProcessorUnitTest::kAlphaTextureIdx;
+ GrProcessorUnitTest::kAlphaTextureIdx;
Direction dir = d->fRandom->nextBool() ? kX_Direction : kY_Direction;
static const int kMaxRadius = 10;
int radius = d->fRandom->nextRangeU(1, kMaxRadius);
MorphologyType type = d->fRandom->nextBool() ? GrMorphologyEffect::kErode_MorphologyType :
GrMorphologyEffect::kDilate_MorphologyType;
- return GrMorphologyEffect::Create(d->fTextures[texIdx], dir, radius, type);
+ return GrMorphologyEffect::Make(d->fTextures[texIdx], dir, radius, type);
}
@@ -394,11 +394,11 @@
Gr1DKernelEffect::Direction direction) {
GrPaint paint;
// SRGBTODO: AllowSRGBInputs?
- paint.addColorFragmentProcessor(GrMorphologyEffect::Create(texture,
- direction,
- radius,
- morphType,
- bounds))->unref();
+ paint.addColorFragmentProcessor(GrMorphologyEffect::Make(texture,
+ direction,
+ radius,
+ morphType,
+ bounds));
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
drawContext->fillRectToRect(clip, paint, SkMatrix::I(), SkRect::Make(dstRect),
SkRect::Make(srcRect));
@@ -414,10 +414,8 @@
Gr1DKernelEffect::Direction direction) {
GrPaint paint;
// SRGBTODO: AllowSRGBInputs?
- paint.addColorFragmentProcessor(GrMorphologyEffect::Create(texture,
- direction,
- radius,
- morphType))->unref();
+ paint.addColorFragmentProcessor(GrMorphologyEffect::Make(texture, direction, radius,
+ morphType));
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
drawContext->fillRectToRect(clip, paint, SkMatrix::I(), SkRect::Make(dstRect),
SkRect::Make(srcRect));
diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp
index d2d4606..1400905 100644
--- a/src/effects/SkPerlinNoiseShader.cpp
+++ b/src/effects/SkPerlinNoiseShader.cpp
@@ -495,13 +495,14 @@
class GrPerlinNoiseEffect : public GrFragmentProcessor {
public:
- static GrFragmentProcessor* Create(SkPerlinNoiseShader::Type type,
- int numOctaves, bool stitchTiles,
- SkPerlinNoiseShader::PaintingData* paintingData,
- GrTexture* permutationsTexture, GrTexture* noiseTexture,
- const SkMatrix& matrix) {
- return new GrPerlinNoiseEffect(type, numOctaves, stitchTiles, paintingData,
- permutationsTexture, noiseTexture, matrix);
+ static sk_sp<GrFragmentProcessor> Make(SkPerlinNoiseShader::Type type,
+ int numOctaves, bool stitchTiles,
+ SkPerlinNoiseShader::PaintingData* paintingData,
+ GrTexture* permutationsTexture, GrTexture* noiseTexture,
+ const SkMatrix& matrix) {
+ return sk_sp<GrFragmentProcessor>(
+ new GrPerlinNoiseEffect(type, numOctaves, stitchTiles, paintingData,
+ permutationsTexture, noiseTexture, matrix));
}
virtual ~GrPerlinNoiseEffect() { delete fPaintingData; }
@@ -574,7 +575,7 @@
/////////////////////////////////////////////////////////////////////
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrPerlinNoiseEffect);
-const GrFragmentProcessor* GrPerlinNoiseEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrPerlinNoiseEffect::TestCreate(GrProcessorTestData* d) {
int numOctaves = d->fRandom->nextRangeU(2, 10);
bool stitchTiles = d->fRandom->nextBool();
SkScalar seed = SkIntToScalar(d->fRandom->nextU());
@@ -892,7 +893,7 @@
}
/////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* SkPerlinNoiseShader::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkPerlinNoiseShader::asFragmentProcessor(
GrContext* context,
const SkMatrix& viewM,
const SkMatrix* externalLocalMatrix,
@@ -911,13 +912,13 @@
if (0 == fNumOctaves) {
if (kFractalNoise_Type == fType) {
// Extract the incoming alpha and emit rgba = (a/4, a/4, a/4, a/2)
- SkAutoTUnref<const GrFragmentProcessor> inner(
- GrConstColorProcessor::Create(0x80404040,
- GrConstColorProcessor::kModulateRGBA_InputMode));
- return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+ sk_sp<GrFragmentProcessor> inner(
+ GrConstColorProcessor::Make(0x80404040,
+ GrConstColorProcessor::kModulateRGBA_InputMode));
+ return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
// Emit zero.
- return GrConstColorProcessor::Create(0x0, GrConstColorProcessor::kIgnore_InputMode);
+ return GrConstColorProcessor::Make(0x0, GrConstColorProcessor::kIgnore_InputMode);
}
// Either we don't stitch tiles, either we have a valid tile size
@@ -936,14 +937,14 @@
m.setTranslateX(-localMatrix.getTranslateX() + SK_Scalar1);
m.setTranslateY(-localMatrix.getTranslateY() + SK_Scalar1);
if ((permutationsTexture) && (noiseTexture)) {
- SkAutoTUnref<GrFragmentProcessor> inner(
- GrPerlinNoiseEffect::Create(fType,
- fNumOctaves,
- fStitchTiles,
- paintingData,
- permutationsTexture, noiseTexture,
- m));
- return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+ sk_sp<GrFragmentProcessor> inner(
+ GrPerlinNoiseEffect::Make(fType,
+ fNumOctaves,
+ fStitchTiles,
+ paintingData,
+ permutationsTexture, noiseTexture,
+ m));
+ return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
delete paintingData;
return nullptr;
diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp
index e87a053..20d11f1 100644
--- a/src/effects/SkTableColorFilter.cpp
+++ b/src/effects/SkTableColorFilter.cpp
@@ -49,7 +49,7 @@
sk_sp<SkColorFilter> makeComposed(sk_sp<SkColorFilter> inner) const override;
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*) const override;
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*) const override;
#endif
void filterSpan(const SkPMColor src[], int count, SkPMColor dst[]) const override;
@@ -343,7 +343,7 @@
class ColorTableEffect : public GrFragmentProcessor {
public:
- static const GrFragmentProcessor* Create(GrContext* context, SkBitmap bitmap, unsigned flags);
+ static sk_sp<GrFragmentProcessor> Make(GrContext* context, SkBitmap bitmap, unsigned flags);
virtual ~ColorTableEffect();
@@ -459,8 +459,8 @@
}
///////////////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* ColorTableEffect::Create(GrContext* context, SkBitmap bitmap,
- unsigned flags) {
+sk_sp<GrFragmentProcessor> ColorTableEffect::Make(GrContext* context, SkBitmap bitmap,
+ unsigned flags) {
GrTextureStripAtlas::Desc desc;
desc.fWidth = bitmap.width();
@@ -479,7 +479,7 @@
texture.reset(SkRef(atlas->getTexture()));
}
- return new ColorTableEffect(texture, atlas, row, flags);
+ return sk_sp<GrFragmentProcessor>(new ColorTableEffect(texture, atlas, row, flags));
}
ColorTableEffect::ColorTableEffect(GrTexture* texture, GrTextureStripAtlas* atlas, int row,
@@ -540,7 +540,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ColorTableEffect);
-const GrFragmentProcessor* ColorTableEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> ColorTableEffect::TestCreate(GrProcessorTestData* d) {
int flags = 0;
uint8_t luts[256][4];
do {
@@ -562,16 +562,16 @@
(flags & (1 << 3)) ? luts[3] : nullptr
));
- const GrFragmentProcessor* fp = filter->asFragmentProcessor(d->fContext);
+ sk_sp<GrFragmentProcessor> fp = filter->asFragmentProcessor(d->fContext);
SkASSERT(fp);
return fp;
}
-const GrFragmentProcessor* SkTable_ColorFilter::asFragmentProcessor(GrContext* context) const {
+sk_sp<GrFragmentProcessor> SkTable_ColorFilter::asFragmentProcessor(GrContext* context) const {
SkBitmap bitmap;
this->asComponentTable(&bitmap);
- return ColorTableEffect::Create(context, bitmap, fFlags);
+ return ColorTableEffect::Make(context, bitmap, fFlags);
}
#endif // SK_SUPPORT_GPU
diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp
index 1921e00..785b46f 100644
--- a/src/effects/SkXfermodeImageFilter.cpp
+++ b/src/effects/SkXfermodeImageFilter.cpp
@@ -180,22 +180,22 @@
GrPaint paint;
// SRGBTODO: AllowSRGBInputs?
- SkAutoTUnref<const GrFragmentProcessor> bgFP;
+ sk_sp<GrFragmentProcessor> bgFP;
if (backgroundTex) {
SkMatrix backgroundMatrix;
backgroundMatrix.setIDiv(backgroundTex->width(), backgroundTex->height());
backgroundMatrix.preTranslate(SkIntToScalar(-backgroundOffset.fX),
SkIntToScalar(-backgroundOffset.fY));
- bgFP.reset(GrTextureDomainEffect::Create(
+ bgFP = GrTextureDomainEffect::Make(
backgroundTex.get(), backgroundMatrix,
GrTextureDomain::MakeTexelDomain(backgroundTex.get(),
background->subset()),
GrTextureDomain::kDecal_Mode,
- GrTextureParams::kNone_FilterMode));
+ GrTextureParams::kNone_FilterMode);
} else {
- bgFP.reset(GrConstColorProcessor::Create(GrColor_TRANSPARENT_BLACK,
- GrConstColorProcessor::kIgnore_InputMode));
+ bgFP = GrConstColorProcessor::Make(GrColor_TRANSPARENT_BLACK,
+ GrConstColorProcessor::kIgnore_InputMode);
}
if (foregroundTex) {
@@ -204,16 +204,16 @@
foregroundMatrix.preTranslate(SkIntToScalar(-foregroundOffset.fX),
SkIntToScalar(-foregroundOffset.fY));
- SkAutoTUnref<const GrFragmentProcessor> foregroundFP;
+ sk_sp<GrFragmentProcessor> foregroundFP;
- foregroundFP.reset(GrTextureDomainEffect::Create(
+ foregroundFP = GrTextureDomainEffect::Make(
foregroundTex.get(), foregroundMatrix,
GrTextureDomain::MakeTexelDomain(foregroundTex.get(),
foreground->subset()),
GrTextureDomain::kDecal_Mode,
- GrTextureParams::kNone_FilterMode));
+ GrTextureParams::kNone_FilterMode);
- paint.addColorFragmentProcessor(foregroundFP.get());
+ paint.addColorFragmentProcessor(std::move(foregroundFP));
// A null fMode is interpreted to mean kSrcOver_Mode (to match raster).
SkAutoTUnref<SkXfermode> mode(SkSafeRef(fMode.get()));
@@ -228,14 +228,15 @@
mode.reset(new SkProcCoeffXfermode(rec, SkXfermode::kSrcOver_Mode));
}
- sk_sp<const GrFragmentProcessor> xferFP(mode->getFragmentProcessorForImageFilter(bgFP));
+ sk_sp<GrFragmentProcessor> xferFP(
+ mode->makeFragmentProcessorForImageFilter(std::move(bgFP)));
// A null 'xferFP' here means kSrc_Mode was used in which case we can just proceed
if (xferFP) {
- paint.addColorFragmentProcessor(xferFP.get());
+ paint.addColorFragmentProcessor(std::move(xferFP));
}
} else {
- paint.addColorFragmentProcessor(bgFP);
+ paint.addColorFragmentProcessor(std::move(bgFP));
}
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp
index cd55673..40340fe 100644
--- a/src/effects/gradients/SkLinearGradient.cpp
+++ b/src/effects/gradients/SkLinearGradient.cpp
@@ -7,6 +7,7 @@
#include "Sk4fLinearGradient.h"
#include "SkLinearGradient.h"
+#include "SkRefCnt.h"
// define to test the 4f gradient path
// #define FORCE_4F_CONTEXT
@@ -369,11 +370,11 @@
class GrLinearGradient : public GrGradientEffect {
public:
- static GrFragmentProcessor* Create(GrContext* ctx,
- const SkLinearGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm) {
- return new GrLinearGradient(ctx, shader, matrix, tm);
+ static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
+ const SkLinearGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm) {
+ return sk_sp<GrFragmentProcessor>(new GrLinearGradient(ctx, shader, matrix, tm));
}
virtual ~GrLinearGradient() { }
@@ -407,7 +408,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrLinearGradient);
-const GrFragmentProcessor* GrLinearGradient::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrLinearGradient::TestCreate(GrProcessorTestData* d) {
SkPoint points[] = {{d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()},
{d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}};
@@ -417,7 +418,7 @@
SkShader::TileMode tm;
int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
auto shader = SkGradientShader::MakeLinear(points, colors, stops, colorCount, tm);
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
+ sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext,
GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
SkSourceGammaTreatment::kRespect);
GrAlwaysAssert(fp);
@@ -442,7 +443,7 @@
/////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* SkLinearGradient::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkLinearGradient::asFragmentProcessor(
GrContext* context,
const SkMatrix& viewm,
const SkMatrix* localMatrix,
@@ -463,9 +464,8 @@
}
matrix.postConcat(fPtsToUnit);
- SkAutoTUnref<const GrFragmentProcessor> inner(
- GrLinearGradient::Create(context, *this, matrix, fTileMode));
- return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+ sk_sp<GrFragmentProcessor> inner(GrLinearGradient::Make(context, *this, matrix, fTileMode));
+ return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
diff --git a/src/effects/gradients/SkLinearGradient.h b/src/effects/gradients/SkLinearGradient.h
index 8edcb9d..5800e57 100644
--- a/src/effects/gradients/SkLinearGradient.h
+++ b/src/effects/gradients/SkLinearGradient.h
@@ -57,7 +57,7 @@
GradientType asAGradient(GradientInfo* info) const override;
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*,
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
const SkMatrix& viewM,
const SkMatrix*,
SkFilterQuality,
diff --git a/src/effects/gradients/SkRadialGradient.cpp b/src/effects/gradients/SkRadialGradient.cpp
index a0fee27..c7e6656 100644
--- a/src/effects/gradients/SkRadialGradient.cpp
+++ b/src/effects/gradients/SkRadialGradient.cpp
@@ -264,11 +264,11 @@
class GrRadialGradient : public GrGradientEffect {
public:
- static GrFragmentProcessor* Create(GrContext* ctx,
- const SkRadialGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm) {
- return new GrRadialGradient(ctx, shader, matrix, tm);
+ static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
+ const SkRadialGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm) {
+ return sk_sp<GrFragmentProcessor>(new GrRadialGradient(ctx, shader, matrix, tm));
}
virtual ~GrRadialGradient() { }
@@ -302,7 +302,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRadialGradient);
-const GrFragmentProcessor* GrRadialGradient::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrRadialGradient::TestCreate(GrProcessorTestData* d) {
SkPoint center = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkScalar radius = d->fRandom->nextUScalar1();
@@ -312,7 +312,7 @@
SkShader::TileMode tm;
int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
auto shader = SkGradientShader::MakeRadial(center, radius, colors, stops, colorCount, tm);
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
+ sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext,
GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
SkSourceGammaTreatment::kRespect);
GrAlwaysAssert(fp);
@@ -338,7 +338,7 @@
/////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* SkRadialGradient::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkRadialGradient::asFragmentProcessor(
GrContext* context,
const SkMatrix& viewM,
const SkMatrix* localMatrix,
@@ -358,9 +358,8 @@
matrix.postConcat(inv);
}
matrix.postConcat(fPtsToUnit);
- SkAutoTUnref<const GrFragmentProcessor> inner(
- GrRadialGradient::Create(context, *this, matrix, fTileMode));
- return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+ sk_sp<GrFragmentProcessor> inner(GrRadialGradient::Make(context, *this, matrix, fTileMode));
+ return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
#endif
diff --git a/src/effects/gradients/SkRadialGradient.h b/src/effects/gradients/SkRadialGradient.h
index 8eb1f76..dfa6823 100644
--- a/src/effects/gradients/SkRadialGradient.h
+++ b/src/effects/gradients/SkRadialGradient.h
@@ -26,7 +26,7 @@
GradientType asAGradient(GradientInfo* info) const override;
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*,
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
const SkMatrix& viewM,
const SkMatrix*,
SkFilterQuality,
diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp
index 08232bc..9e2b909 100644
--- a/src/effects/gradients/SkSweepGradient.cpp
+++ b/src/effects/gradients/SkSweepGradient.cpp
@@ -147,9 +147,9 @@
class GrSweepGradient : public GrGradientEffect {
public:
- static GrFragmentProcessor* Create(GrContext* ctx, const SkSweepGradient& shader,
- const SkMatrix& m) {
- return new GrSweepGradient(ctx, shader, m);
+ static sk_sp<GrFragmentProcessor> Make(GrContext* ctx, const SkSweepGradient& shader,
+ const SkMatrix& m) {
+ return sk_sp<GrFragmentProcessor>(new GrSweepGradient(ctx, shader, m));
}
virtual ~GrSweepGradient() { }
@@ -181,7 +181,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSweepGradient);
-const GrFragmentProcessor* GrSweepGradient::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrSweepGradient::TestCreate(GrProcessorTestData* d) {
SkPoint center = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkColor colors[kMaxRandomGradientColors];
@@ -191,7 +191,7 @@
int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tmIgnored);
sk_sp<SkShader> shader(SkGradientShader::MakeSweep(center.fX, center.fY, colors, stops,
colorCount));
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
+ sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext,
GrTest::TestMatrix(d->fRandom),
NULL, kNone_SkFilterQuality,
SkSourceGammaTreatment::kRespect);
@@ -227,7 +227,7 @@
/////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* SkSweepGradient::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkSweepGradient::asFragmentProcessor(
GrContext* context,
const SkMatrix& viewM,
const SkMatrix* localMatrix,
@@ -247,9 +247,8 @@
}
matrix.postConcat(fPtsToUnit);
- SkAutoTUnref<const GrFragmentProcessor> inner(
- GrSweepGradient::Create(context, *this, matrix));
- return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+ sk_sp<GrFragmentProcessor> inner(GrSweepGradient::Make(context, *this, matrix));
+ return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
#endif
diff --git a/src/effects/gradients/SkSweepGradient.h b/src/effects/gradients/SkSweepGradient.h
index d0807da..0812a58 100644
--- a/src/effects/gradients/SkSweepGradient.h
+++ b/src/effects/gradients/SkSweepGradient.h
@@ -27,7 +27,7 @@
GradientType asAGradient(GradientInfo* info) const override;
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*,
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
const SkMatrix& viewM,
const SkMatrix*,
SkFilterQuality,
diff --git a/src/effects/gradients/SkTwoPointConicalGradient.cpp b/src/effects/gradients/SkTwoPointConicalGradient.cpp
index a7cdc7e..afc77fe 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient.cpp
@@ -356,7 +356,7 @@
#include "SkGr.h"
-const GrFragmentProcessor* SkTwoPointConicalGradient::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkTwoPointConicalGradient::asFragmentProcessor(
GrContext* context,
const SkMatrix& viewM,
const SkMatrix* localMatrix,
@@ -364,9 +364,9 @@
SkSourceGammaTreatment) const {
SkASSERT(context);
SkASSERT(fPtsToUnit.isIdentity());
- SkAutoTUnref<const GrFragmentProcessor> inner(
- Gr2PtConicalGradientEffect::Create(context, *this, fTileMode, localMatrix));
- return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+ sk_sp<GrFragmentProcessor> inner(
+ Gr2PtConicalGradientEffect::Make(context, *this, fTileMode, localMatrix));
+ return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
#endif
diff --git a/src/effects/gradients/SkTwoPointConicalGradient.h b/src/effects/gradients/SkTwoPointConicalGradient.h
index b50a5e3..f2102c1 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient.h
+++ b/src/effects/gradients/SkTwoPointConicalGradient.h
@@ -57,7 +57,7 @@
SkShader::GradientType asAGradient(GradientInfo* info) const override;
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*,
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
const SkMatrix&,
const SkMatrix*,
SkFilterQuality,
diff --git a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
index e638982..91b0a93 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
@@ -61,11 +61,11 @@
class Edge2PtConicalEffect : public GrGradientEffect {
public:
- static GrFragmentProcessor* Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm) {
- return new Edge2PtConicalEffect(ctx, shader, matrix, tm);
+ static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm) {
+ return sk_sp<GrFragmentProcessor>(new Edge2PtConicalEffect(ctx, shader, matrix, tm));
}
virtual ~Edge2PtConicalEffect() {}
@@ -184,7 +184,7 @@
/*
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
-const GrFragmentProcessor* Edge2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> Edge2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkScalar radius1 = d->fRandom->nextUScalar1();
SkPoint center2;
@@ -208,7 +208,7 @@
int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center2, radius2,
colors, stops, colorCount, tm);
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
+ sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext,
GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
SkSourceGammaTreatment::kRespect);
GrAlwaysAssert(fp);
@@ -370,12 +370,13 @@
class FocalOutside2PtConicalEffect : public GrGradientEffect {
public:
- static GrFragmentProcessor* Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm,
- SkScalar focalX) {
- return new FocalOutside2PtConicalEffect(ctx, shader, matrix, tm, focalX);
+ static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm,
+ SkScalar focalX) {
+ return sk_sp<GrFragmentProcessor>(
+ new FocalOutside2PtConicalEffect(ctx, shader, matrix, tm, focalX));
}
virtual ~FocalOutside2PtConicalEffect() { }
@@ -463,7 +464,7 @@
/*
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
-const GrFragmentProcessor* FocalOutside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> FocalOutside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkScalar radius1 = 0.f;
SkPoint center2;
@@ -484,7 +485,7 @@
int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center2, radius2,
colors, stops, colorCount, tm);
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
+ sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext,
GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
SkSourceGammaTreatment::kRespect);
GrAlwaysAssert(fp);
@@ -580,12 +581,13 @@
class FocalInside2PtConicalEffect : public GrGradientEffect {
public:
- static GrFragmentProcessor* Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm,
- SkScalar focalX) {
- return new FocalInside2PtConicalEffect(ctx, shader, matrix, tm, focalX);
+ static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm,
+ SkScalar focalX) {
+ return sk_sp<GrFragmentProcessor>(
+ new FocalInside2PtConicalEffect(ctx, shader, matrix, tm, focalX));
}
virtual ~FocalInside2PtConicalEffect() {}
@@ -668,7 +670,7 @@
/*
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
-const GrFragmentProcessor* FocalInside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> FocalInside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkScalar radius1 = 0.f;
SkPoint center2;
@@ -691,7 +693,7 @@
int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center2, radius2,
colors, stops, colorCount, tm);
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
+ sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext,
GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
SkSourceGammaTreatment::kRespect);
GrAlwaysAssert(fp);
@@ -819,12 +821,13 @@
class CircleInside2PtConicalEffect : public GrGradientEffect {
public:
- static GrFragmentProcessor* Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm,
- const CircleConicalInfo& info) {
- return new CircleInside2PtConicalEffect(ctx, shader, matrix, tm, info);
+ static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm,
+ const CircleConicalInfo& info) {
+ return sk_sp<GrFragmentProcessor>(
+ new CircleInside2PtConicalEffect(ctx, shader, matrix, tm, info));
}
virtual ~CircleInside2PtConicalEffect() {}
@@ -916,7 +919,7 @@
/*
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
-const GrFragmentProcessor* CircleInside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> CircleInside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkScalar radius1 = d->fRandom->nextUScalar1() + 0.0001f; // make sure radius1 != 0
SkPoint center2;
@@ -938,7 +941,7 @@
int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center2, radius2,
colors, stops, colorCount, tm);
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
+ sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext,
GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
SkSourceGammaTreatment::kRespect);
GrAlwaysAssert(fp);
@@ -1035,12 +1038,13 @@
class CircleOutside2PtConicalEffect : public GrGradientEffect {
public:
- static GrFragmentProcessor* Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm,
- const CircleConicalInfo& info) {
- return new CircleOutside2PtConicalEffect(ctx, shader, matrix, tm, info);
+ static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm,
+ const CircleConicalInfo& info) {
+ return sk_sp<GrFragmentProcessor>(
+ new CircleOutside2PtConicalEffect(ctx, shader, matrix, tm, info));
}
virtual ~CircleOutside2PtConicalEffect() {}
@@ -1147,7 +1151,7 @@
/*
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
-const GrFragmentProcessor* CircleOutside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> CircleOutside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkScalar radius1 = d->fRandom->nextUScalar1() + 0.0001f; // make sure radius1 != 0
SkPoint center2;
@@ -1170,7 +1174,7 @@
int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center2, radius2,
colors, stops, colorCount, tm);
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(
+ sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(
d->fContext,GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
SkSourceGammaTreatment::kRespect);
GrAlwaysAssert(fp);
@@ -1291,10 +1295,10 @@
//////////////////////////////////////////////////////////////////////////////
-GrFragmentProcessor* Gr2PtConicalGradientEffect::Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- SkShader::TileMode tm,
- const SkMatrix* localMatrix) {
+sk_sp<GrFragmentProcessor> Gr2PtConicalGradientEffect::Make(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ SkShader::TileMode tm,
+ const SkMatrix* localMatrix) {
SkMatrix matrix;
if (!shader.getLocalMatrix().invert(&matrix)) {
return nullptr;
@@ -1311,12 +1315,12 @@
SkScalar focalX;
ConicalType type = set_matrix_focal_conical(shader, &matrix, &focalX);
if (type == kInside_ConicalType) {
- return FocalInside2PtConicalEffect::Create(ctx, shader, matrix, tm, focalX);
+ return FocalInside2PtConicalEffect::Make(ctx, shader, matrix, tm, focalX);
} else if(type == kEdge_ConicalType) {
set_matrix_edge_conical(shader, &matrix);
- return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm);
+ return Edge2PtConicalEffect::Make(ctx, shader, matrix, tm);
} else {
- return FocalOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, focalX);
+ return FocalOutside2PtConicalEffect::Make(ctx, shader, matrix, tm, focalX);
}
}
@@ -1324,12 +1328,12 @@
ConicalType type = set_matrix_circle_conical(shader, &matrix, &info);
if (type == kInside_ConicalType) {
- return CircleInside2PtConicalEffect::Create(ctx, shader, matrix, tm, info);
+ return CircleInside2PtConicalEffect::Make(ctx, shader, matrix, tm, info);
} else if (type == kEdge_ConicalType) {
set_matrix_edge_conical(shader, &matrix);
- return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm);
+ return Edge2PtConicalEffect::Make(ctx, shader, matrix, tm);
} else {
- return CircleOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, info);
+ return CircleOutside2PtConicalEffect::Make(ctx, shader, matrix, tm, info);
}
}
diff --git a/src/effects/gradients/SkTwoPointConicalGradient_gpu.h b/src/effects/gradients/SkTwoPointConicalGradient_gpu.h
index 601a166..9dd058d 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient_gpu.h
+++ b/src/effects/gradients/SkTwoPointConicalGradient_gpu.h
@@ -18,8 +18,8 @@
* Creates an effect that produces a two point conical gradient based on the
* shader passed in.
*/
- GrFragmentProcessor* Create(GrContext* ctx, const SkTwoPointConicalGradient& shader,
- SkShader::TileMode tm, const SkMatrix* localMatrix);
+ sk_sp<GrFragmentProcessor> Make(GrContext* ctx, const SkTwoPointConicalGradient& shader,
+ SkShader::TileMode tm, const SkMatrix* localMatrix);
};
#endif
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index 1e85b87..94c6ea0 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -35,8 +35,8 @@
matrix.setTranslate(-SkIntToScalar(maskRect.fLeft), -SkIntToScalar(maskRect.fTop));
matrix.postIDiv(mask->width(), mask->height());
- grp->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(mask, matrix,
- kDevice_GrCoordSet))->unref();
+ grp->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(mask, matrix,
+ kDevice_GrCoordSet));
SkMatrix inverse;
if (!viewMatrix.invert(&inverse)) {
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index fd741b9..9348181 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -32,8 +32,8 @@
////////////////////////////////////////////////////////////////////////////////
// set up the draw state to enable the aa clipping mask. Besides setting up the
// stage matrix this also alters the vertex layout
-static sk_sp<const GrFragmentProcessor> create_fp_for_mask(GrTexture* result,
- const SkIRect &devBound) {
+static sk_sp<GrFragmentProcessor> create_fp_for_mask(GrTexture* result,
+ const SkIRect &devBound) {
SkMatrix mat;
// We use device coords to compute the texture coordinates. We set our matrix to be a
// translation to the devBound, and then a scaling matrix to normalized coords.
@@ -42,7 +42,7 @@
SkIntToScalar(-devBound.fTop));
SkIRect domainTexels = SkIRect::MakeWH(devBound.width(), devBound.height());
- return sk_sp<const GrFragmentProcessor>(GrTextureDomainEffect::Create(
+ return sk_sp<GrFragmentProcessor>(GrTextureDomainEffect::Make(
result,
mat,
GrTextureDomain::MakeTexelDomain(result, domainTexels),
@@ -156,20 +156,15 @@
bool abortIfAA,
SkVector& clipToRTOffset,
const SkRect* drawBounds,
- sk_sp<const GrFragmentProcessor>* resultFP) {
+ sk_sp<GrFragmentProcessor>* resultFP) {
SkRect boundsInClipSpace;
if (drawBounds) {
boundsInClipSpace = *drawBounds;
boundsInClipSpace.offset(-clipToRTOffset.fX, -clipToRTOffset.fY);
}
SkASSERT(elements.count() <= kMaxAnalyticElements);
- const GrFragmentProcessor* fps[kMaxAnalyticElements];
- for (int i = 0; i < kMaxAnalyticElements; ++i) {
- fps[i] = nullptr;
- }
- int fpCnt = 0;
+ SkSTArray<kMaxAnalyticElements, sk_sp<GrFragmentProcessor>> fps;
GrReducedClip::ElementList::Iter iter(elements);
- bool failed = false;
while (iter.get()) {
SkRegion::Op op = iter.get()->getOp();
bool invert;
@@ -190,18 +185,13 @@
// element's primitive, so don't attempt to set skip.
break;
default:
- failed = true;
- break;
- }
- if (failed) {
- break;
+ return false;
}
if (!skip) {
GrPrimitiveEdgeType edgeType;
if (iter.get()->isAA()) {
if (abortIfAA) {
- failed = true;
- break;
+ return false;
}
edgeType =
invert ? kInverseFillAA_GrProcessorEdgeType : kFillAA_GrProcessorEdgeType;
@@ -212,41 +202,36 @@
switch (iter.get()->getType()) {
case SkClipStack::Element::kPath_Type:
- fps[fpCnt] = GrConvexPolyEffect::Create(edgeType, iter.get()->getPath(),
- &clipToRTOffset);
+ fps.emplace_back(GrConvexPolyEffect::Make(edgeType, iter.get()->getPath(),
+ &clipToRTOffset));
break;
case SkClipStack::Element::kRRect_Type: {
SkRRect rrect = iter.get()->getRRect();
rrect.offset(clipToRTOffset.fX, clipToRTOffset.fY);
- fps[fpCnt] = GrRRectEffect::Create(edgeType, rrect);
+ fps.emplace_back(GrRRectEffect::Make(edgeType, rrect));
break;
}
case SkClipStack::Element::kRect_Type: {
SkRect rect = iter.get()->getRect();
rect.offset(clipToRTOffset.fX, clipToRTOffset.fY);
- fps[fpCnt] = GrConvexPolyEffect::Create(edgeType, rect);
+ fps.emplace_back(GrConvexPolyEffect::Make(edgeType, rect));
break;
}
default:
break;
}
- if (!fps[fpCnt]) {
- failed = true;
- break;
+ if (!fps.back()) {
+ return false;
}
- fpCnt++;
}
iter.next();
}
*resultFP = nullptr;
- if (!failed && fpCnt) {
- resultFP->reset(GrFragmentProcessor::RunInSeries(fps, fpCnt));
+ if (fps.count()) {
+ *resultFP = GrFragmentProcessor::RunInSeries(fps.begin(), fps.count());
}
- for (int i = 0; i < fpCnt; ++i) {
- fps[i]->unref();
- }
- return !failed;
+ return true;
}
////////////////////////////////////////////////////////////////////////////////
@@ -320,7 +305,7 @@
disallowAnalyticAA = pipelineBuilder.isHWAntialias() ||
pipelineBuilder.hasUserStencilSettings();
}
- sk_sp<const GrFragmentProcessor> clipFP;
+ sk_sp<GrFragmentProcessor> clipFP;
if (elements.isEmpty() ||
(requiresAA &&
get_analytic_clip_processor(elements, disallowAnalyticAA, clipToRTOffset, devBounds,
@@ -328,10 +313,10 @@
SkIRect scissorSpaceIBounds(clipSpaceIBounds);
scissorSpaceIBounds.offset(-clip.origin());
if (!devBounds || !SkRect::Make(scissorSpaceIBounds).contains(*devBounds)) {
- out->makeScissoredFPBased(clipFP, scissorSpaceIBounds);
+ out->makeScissoredFPBased(std::move(clipFP), scissorSpaceIBounds);
return true;
}
- out->makeFPBased(clipFP);
+ out->makeFPBased(std::move(clipFP));
return true;
}
}
@@ -683,7 +668,7 @@
if (!clipPath.isEmpty()) {
if (canRenderDirectToStencil) {
GrPaint paint;
- SkSafeUnref(paint.setXPFactory(GrDisableColorXPFactory::Create()));
+ paint.setXPFactory(GrDisableColorXPFactory::Make());
paint.setAntiAlias(element->isAA());
GrPathRenderer::DrawPathArgs args;
@@ -724,7 +709,7 @@
viewMatrix, element->getRect(), element->isAA(), *pass);
} else {
GrPaint paint;
- SkSafeUnref(paint.setXPFactory(GrDisableColorXPFactory::Create()));
+ paint.setXPFactory(GrDisableColorXPFactory::Make());
paint.setAntiAlias(element->isAA());
GrPathRenderer::DrawPathArgs args;
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 51ab64d..a9c6089 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -317,12 +317,11 @@
// temp buffer for doing sw premul conversion, if needed.
SkAutoSTMalloc<128 * 128, uint32_t> tmpPixels(0);
if (tempTexture) {
- SkAutoTUnref<const GrFragmentProcessor> fp;
+ sk_sp<GrFragmentProcessor> fp;
SkMatrix textureMatrix;
textureMatrix.setIDiv(tempTexture->width(), tempTexture->height());
if (applyPremulToSrc) {
- fp.reset(this->createUPMToPMEffect(tempTexture, tempDrawInfo.fSwizzle,
- textureMatrix));
+ fp = this->createUPMToPMEffect(tempTexture, tempDrawInfo.fSwizzle, textureMatrix);
// If premultiplying was the only reason for the draw, fall back to a straight write.
if (!fp) {
if (GrGpu::kCallerPrefersDraw_DrawPreference == drawPreference) {
@@ -334,8 +333,9 @@
}
if (tempTexture) {
if (!fp) {
- fp.reset(GrConfigConversionEffect::Create(tempTexture, tempDrawInfo.fSwizzle,
- GrConfigConversionEffect::kNone_PMConversion, textureMatrix));
+ fp = GrConfigConversionEffect::Make(tempTexture, tempDrawInfo.fSwizzle,
+ GrConfigConversionEffect::kNone_PMConversion,
+ textureMatrix);
if (!fp) {
return false;
}
@@ -368,7 +368,7 @@
return false;
}
GrPaint paint;
- paint.addColorFragmentProcessor(fp);
+ paint.addColorFragmentProcessor(std::move(fp));
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
paint.setAllowSRGBInputs(true);
SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
@@ -461,10 +461,10 @@
SkMatrix textureMatrix;
textureMatrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top));
textureMatrix.postIDiv(src->width(), src->height());
- SkAutoTUnref<const GrFragmentProcessor> fp;
+ sk_sp<GrFragmentProcessor> fp;
if (unpremul) {
- fp.reset(this->createPMToUPMEffect(src->asTexture(), tempDrawInfo.fSwizzle,
- textureMatrix));
+ fp = this->createPMToUPMEffect(src->asTexture(), tempDrawInfo.fSwizzle,
+ textureMatrix);
if (fp) {
unpremul = false; // we no longer need to do this on CPU after the read back.
} else if (GrGpu::kCallerPrefersDraw_DrawPreference == drawPreference) {
@@ -474,12 +474,13 @@
}
}
if (!fp && temp) {
- fp.reset(GrConfigConversionEffect::Create(src->asTexture(), tempDrawInfo.fSwizzle,
- GrConfigConversionEffect::kNone_PMConversion, textureMatrix));
+ fp = GrConfigConversionEffect::Make(src->asTexture(), tempDrawInfo.fSwizzle,
+ GrConfigConversionEffect::kNone_PMConversion,
+ textureMatrix);
}
if (fp) {
GrPaint paint;
- paint.addColorFragmentProcessor(fp);
+ paint.addColorFragmentProcessor(std::move(fp));
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
paint.setAllowSRGBInputs(true);
SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
@@ -550,7 +551,7 @@
GrPaint paint;
paint.addColorTextureProcessor(src, GrCoordTransform::MakeDivByTextureWHMatrix(src));
if (!SkScalarNearlyEqual(gamma, 1.0f)) {
- paint.addColorFragmentProcessor(GrGammaEffect::Create(gamma))->unref();
+ paint.addColorFragmentProcessor(GrGammaEffect::Make(gamma));
}
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
paint.setGammaCorrect(true);
@@ -709,7 +710,7 @@
}
}
-const GrFragmentProcessor* GrContext::createPMToUPMEffect(GrTexture* texture,
+sk_sp<GrFragmentProcessor> GrContext::createPMToUPMEffect(GrTexture* texture,
const GrSwizzle& swizzle,
const SkMatrix& matrix) const {
ASSERT_SINGLE_OWNER
@@ -718,13 +719,13 @@
GrConfigConversionEffect::PMConversion pmToUPM =
static_cast<GrConfigConversionEffect::PMConversion>(fPMToUPMConversion);
if (GrConfigConversionEffect::kNone_PMConversion != pmToUPM) {
- return GrConfigConversionEffect::Create(texture, swizzle, pmToUPM, matrix);
+ return GrConfigConversionEffect::Make(texture, swizzle, pmToUPM, matrix);
} else {
return nullptr;
}
}
-const GrFragmentProcessor* GrContext::createUPMToPMEffect(GrTexture* texture,
+sk_sp<GrFragmentProcessor> GrContext::createUPMToPMEffect(GrTexture* texture,
const GrSwizzle& swizzle,
const SkMatrix& matrix) const {
ASSERT_SINGLE_OWNER
@@ -733,7 +734,7 @@
GrConfigConversionEffect::PMConversion upmToPM =
static_cast<GrConfigConversionEffect::PMConversion>(fUPMToPMConversion);
if (GrConfigConversionEffect::kNone_PMConversion != upmToPM) {
- return GrConfigConversionEffect::Create(texture, swizzle, upmToPM, matrix);
+ return GrConfigConversionEffect::Make(texture, swizzle, upmToPM, matrix);
} else {
return nullptr;
}
diff --git a/src/gpu/GrDefaultGeoProcFactory.cpp b/src/gpu/GrDefaultGeoProcFactory.cpp
index df13d5d..9efd9eb 100644
--- a/src/gpu/GrDefaultGeoProcFactory.cpp
+++ b/src/gpu/GrDefaultGeoProcFactory.cpp
@@ -8,6 +8,7 @@
#include "GrDefaultGeoProcFactory.h"
#include "GrInvariantOutput.h"
+#include "SkRefCnt.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLGeometryProcessor.h"
#include "glsl/GrGLSLVertexShaderBuilder.h"
@@ -30,15 +31,16 @@
class DefaultGeoProc : public GrGeometryProcessor {
public:
- static GrGeometryProcessor* Create(uint32_t gpTypeFlags,
- GrColor color,
- const SkMatrix& viewMatrix,
- const SkMatrix& localMatrix,
- bool localCoordsWillBeRead,
- bool coverageWillBeIgnored,
- uint8_t coverage) {
- return new DefaultGeoProc(gpTypeFlags, color, viewMatrix, localMatrix, coverage,
- localCoordsWillBeRead, coverageWillBeIgnored);
+ static sk_sp<GrGeometryProcessor> Make(uint32_t gpTypeFlags,
+ GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkMatrix& localMatrix,
+ bool localCoordsWillBeRead,
+ bool coverageWillBeIgnored,
+ uint8_t coverage) {
+ return sk_sp<GrGeometryProcessor>(new DefaultGeoProc(
+ gpTypeFlags, color, viewMatrix, localMatrix, coverage,
+ localCoordsWillBeRead, coverageWillBeIgnored));
}
const char* name() const override { return "DefaultGeometryProcessor"; }
@@ -271,7 +273,7 @@
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DefaultGeoProc);
-const GrGeometryProcessor* DefaultGeoProc::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrGeometryProcessor> DefaultGeoProc::TestCreate(GrProcessorTestData* d) {
uint32_t flags = 0;
if (d->fRandom->nextBool()) {
flags |= kColor_GPFlag;
@@ -286,19 +288,19 @@
flags |= kTransformedLocalCoord_GPFlag;
}
- return DefaultGeoProc::Create(flags,
- GrRandomColor(d->fRandom),
- GrTest::TestMatrix(d->fRandom),
- GrTest::TestMatrix(d->fRandom),
- d->fRandom->nextBool(),
- d->fRandom->nextBool(),
- GrRandomCoverage(d->fRandom));
+ return DefaultGeoProc::Make(flags,
+ GrRandomColor(d->fRandom),
+ GrTest::TestMatrix(d->fRandom),
+ GrTest::TestMatrix(d->fRandom),
+ d->fRandom->nextBool(),
+ d->fRandom->nextBool(),
+ GrRandomCoverage(d->fRandom));
}
-const GrGeometryProcessor* GrDefaultGeoProcFactory::Create(const Color& color,
- const Coverage& coverage,
- const LocalCoords& localCoords,
- const SkMatrix& viewMatrix) {
+sk_sp<GrGeometryProcessor> GrDefaultGeoProcFactory::Make(const Color& color,
+ const Coverage& coverage,
+ const LocalCoords& localCoords,
+ const SkMatrix& viewMatrix) {
uint32_t flags = 0;
flags |= color.fType == Color::kAttribute_Type ? kColor_GPFlag : 0;
flags |= coverage.fType == Coverage::kAttribute_Type ? kCoverage_GPFlag : 0;
@@ -311,16 +313,16 @@
bool localCoordsWillBeRead = localCoords.fType != LocalCoords::kUnused_Type;
GrColor inColor = color.fColor;
- return DefaultGeoProc::Create(flags,
- inColor,
- viewMatrix,
- localCoords.fMatrix ? *localCoords.fMatrix : SkMatrix::I(),
- localCoordsWillBeRead,
- coverageWillBeIgnored,
- inCoverage);
+ return DefaultGeoProc::Make(flags,
+ inColor,
+ viewMatrix,
+ localCoords.fMatrix ? *localCoords.fMatrix : SkMatrix::I(),
+ localCoordsWillBeRead,
+ coverageWillBeIgnored,
+ inCoverage);
}
-const GrGeometryProcessor* GrDefaultGeoProcFactory::CreateForDeviceSpace(
+sk_sp<GrGeometryProcessor> GrDefaultGeoProcFactory::MakeForDeviceSpace(
const Color& color,
const Coverage& coverage,
const LocalCoords& localCoords,
@@ -339,5 +341,5 @@
}
LocalCoords inverted(LocalCoords::kUsePosition_Type, &invert);
- return Create(color, coverage, inverted, SkMatrix::I());
+ return Make(color, coverage, inverted, SkMatrix::I());
}
diff --git a/src/gpu/GrDefaultGeoProcFactory.h b/src/gpu/GrDefaultGeoProcFactory.h
index 23bcb45..f7ddb06 100644
--- a/src/gpu/GrDefaultGeoProcFactory.h
+++ b/src/gpu/GrDefaultGeoProcFactory.h
@@ -115,20 +115,20 @@
const SkMatrix* fMatrix;
};
- const GrGeometryProcessor* Create(const Color&,
- const Coverage&,
- const LocalCoords&,
- const SkMatrix& viewMatrix);
+ sk_sp<GrGeometryProcessor> Make(const Color&,
+ const Coverage&,
+ const LocalCoords&,
+ const SkMatrix& viewMatrix);
/*
* Use this factory to create a GrGeometryProcessor that expects a device space vertex position
* attribute. The view matrix must still be provided to compute correctly transformed
* coordinates for GrFragmentProcessors. It may fail if the view matrix is not invertible.
*/
- const GrGeometryProcessor* CreateForDeviceSpace(const Color&,
- const Coverage&,
- const LocalCoords&,
- const SkMatrix& viewMatrix);
+ sk_sp<GrGeometryProcessor> MakeForDeviceSpace(const Color&,
+ const Coverage&,
+ const LocalCoords&,
+ const SkMatrix& viewMatrix);
inline size_t DefaultVertexStride() { return sizeof(PositionAttr); }
};
diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp
index 2f78d1e..64ce0ce 100644
--- a/src/gpu/GrDrawContext.cpp
+++ b/src/gpu/GrDrawContext.cpp
@@ -420,7 +420,7 @@
GrPaint paint;
paint.setAntiAlias(doAA);
- SkSafeUnref(paint.setXPFactory(GrDisableColorXPFactory::Create()));
+ paint.setXPFactory(GrDisableColorXPFactory::Make());
bool useHWAA;
SkAutoTUnref<GrDrawBatch> batch(
@@ -671,18 +671,18 @@
grPaint.setAntiAlias(false);
// TODO these need to be a geometry processors
- SkAutoTUnref<GrFragmentProcessor> innerEffect(GrRRectEffect::Create(innerEdgeType, *inner));
+ sk_sp<GrFragmentProcessor> innerEffect(GrRRectEffect::Make(innerEdgeType, *inner));
if (!innerEffect) {
return false;
}
- SkAutoTUnref<GrFragmentProcessor> outerEffect(GrRRectEffect::Create(outerEdgeType, *outer));
+ sk_sp<GrFragmentProcessor> outerEffect(GrRRectEffect::Make(outerEdgeType, *outer));
if (!outerEffect) {
return false;
}
- grPaint.addCoverageFragmentProcessor(innerEffect);
- grPaint.addCoverageFragmentProcessor(outerEffect);
+ grPaint.addCoverageFragmentProcessor(std::move(innerEffect));
+ grPaint.addCoverageFragmentProcessor(std::move(outerEffect));
SkRect bounds = outer->getBounds();
if (applyAA) {
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index ac0c766..7213a92 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -245,9 +245,9 @@
// TODO: this is the only remaining usage of the AutoRestoreFragmentProcessorState - remove it
GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps;
- if (appliedClip.clipCoverageFragmentProcessor()) {
+ if (appliedClip.getClipCoverageFragmentProcessor()) {
arfps.set(&pipelineBuilder);
- arfps.addCoverageFragmentProcessor(appliedClip.clipCoverageFragmentProcessor());
+ arfps.addCoverageFragmentProcessor(sk_ref_sp(appliedClip.getClipCoverageFragmentProcessor()));
}
GrPipeline::CreateArgs args;
@@ -288,11 +288,12 @@
finalScissor.set(ibounds);
args.fScissor = &finalScissor;
}
- args.fOpts.fColorPOI.completeCalculations(pipelineBuilder.fColorFragmentProcessors.begin(),
- pipelineBuilder.numColorFragmentProcessors());
+ args.fOpts.fColorPOI.completeCalculations(
+ sk_sp_address_as_pointer_address(pipelineBuilder.fColorFragmentProcessors.begin()),
+ pipelineBuilder.numColorFragmentProcessors());
args.fOpts.fCoveragePOI.completeCalculations(
- pipelineBuilder.fCoverageFragmentProcessors.begin(),
- pipelineBuilder.numCoverageFragmentProcessors());
+ sk_sp_address_as_pointer_address(pipelineBuilder.fCoverageFragmentProcessors.begin()),
+ pipelineBuilder.numCoverageFragmentProcessors());
if (!this->setupDstReadIfNecessary(pipelineBuilder, drawContext->accessRenderTarget(),
clip, args.fOpts,
&args.fDstTexture, batch->bounds())) {
@@ -330,7 +331,7 @@
// Coverage AA does not make sense when rendering to the stencil buffer. The caller should never
// attempt this in a situation that would require coverage AA.
- SkASSERT(!appliedClip.clipCoverageFragmentProcessor());
+ SkASSERT(!appliedClip.getClipCoverageFragmentProcessor());
GrStencilAttachment* stencilAttachment = fResourceProvider->attachStencilAttachment(
drawContext->accessRenderTarget());
@@ -379,8 +380,7 @@
// TODO: flip this into real draw!
GrPipelineBuilder pipelineBuilder;
- pipelineBuilder.setXPFactory(
- GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
+ pipelineBuilder.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
SkRect scalarRect = SkRect::Make(*rect);
SkAutoTUnref<GrDrawBatch> batch(
diff --git a/src/gpu/GrFragmentProcessor.cpp b/src/gpu/GrFragmentProcessor.cpp
index 9524c84..96a0f71 100644
--- a/src/gpu/GrFragmentProcessor.cpp
+++ b/src/gpu/GrFragmentProcessor.cpp
@@ -89,7 +89,7 @@
fNumTransformsExclChildren++;
}
-int GrFragmentProcessor::registerChildProcessor(const GrFragmentProcessor* child) {
+int GrFragmentProcessor::registerChildProcessor(sk_sp<GrFragmentProcessor> child) {
// Append the child's transforms to our transforms array and the child's textures array to our
// textures array
if (!child->fCoordTransforms.empty()) {
@@ -101,15 +101,15 @@
child->fTextureAccesses.begin());
}
- int index = fChildProcessors.count();
- fChildProcessors.push_back(SkRef(child));
-
this->combineRequiredFeatures(*child);
if (child->usesLocalCoords()) {
fUsesLocalCoords = true;
}
+ int index = fChildProcessors.count();
+ fChildProcessors.push_back(child.release());
+
return index;
}
@@ -134,20 +134,21 @@
return true;
}
-const GrFragmentProcessor* GrFragmentProcessor::MulOutputByInputAlpha(
- const GrFragmentProcessor* fp) {
+sk_sp<GrFragmentProcessor> GrFragmentProcessor::MulOutputByInputAlpha(
+ sk_sp<GrFragmentProcessor> fp) {
if (!fp) {
return nullptr;
}
- return GrXfermodeFragmentProcessor::CreateFromDstProcessor(fp, SkXfermode::kDstIn_Mode);
+ return GrXfermodeFragmentProcessor::MakeFromDstProcessor(std::move(fp),
+ SkXfermode::kDstIn_Mode);
}
-const GrFragmentProcessor* GrFragmentProcessor::MulOutputByInputUnpremulColor(
- const GrFragmentProcessor* fp) {
+sk_sp<GrFragmentProcessor> GrFragmentProcessor::MulOutputByInputUnpremulColor(
+ sk_sp<GrFragmentProcessor> fp) {
class PremulFragmentProcessor : public GrFragmentProcessor {
public:
- PremulFragmentProcessor(const GrFragmentProcessor* processor) {
+ PremulFragmentProcessor(sk_sp<GrFragmentProcessor> processor) {
this->initClassID<PremulFragmentProcessor>();
this->registerChildProcessor(processor);
}
@@ -209,19 +210,19 @@
if (!fp) {
return nullptr;
}
- return new PremulFragmentProcessor(fp);
+ return sk_sp<GrFragmentProcessor>(new PremulFragmentProcessor(std::move(fp)));
}
//////////////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* GrFragmentProcessor::OverrideInput(const GrFragmentProcessor* fp,
+sk_sp<GrFragmentProcessor> GrFragmentProcessor::OverrideInput(sk_sp<GrFragmentProcessor> fp,
GrColor color) {
class ReplaceInputFragmentProcessor : public GrFragmentProcessor {
public:
- ReplaceInputFragmentProcessor(const GrFragmentProcessor* child, GrColor color)
+ ReplaceInputFragmentProcessor(sk_sp<GrFragmentProcessor> child, GrColor color)
: fColor(color) {
this->initClassID<ReplaceInputFragmentProcessor>();
- this->registerChildProcessor(child);
+ this->registerChildProcessor(std::move(child));
}
const char* name() const override { return "Replace Color"; }
@@ -285,21 +286,21 @@
GrInvariantOutput childOut(0x0, kNone_GrColorComponentFlags, false);
fp->computeInvariantOutput(&childOut);
if (childOut.willUseInputColor()) {
- return new ReplaceInputFragmentProcessor(fp, color);
+ return sk_sp<GrFragmentProcessor>(new ReplaceInputFragmentProcessor(std::move(fp), color));
} else {
- return SkRef(fp);
+ return fp;
}
}
-const GrFragmentProcessor* GrFragmentProcessor::RunInSeries(const GrFragmentProcessor* series[],
+sk_sp<GrFragmentProcessor> GrFragmentProcessor::RunInSeries(sk_sp<GrFragmentProcessor>* series,
int cnt) {
class SeriesFragmentProcessor : public GrFragmentProcessor {
public:
- SeriesFragmentProcessor(const GrFragmentProcessor* children[], int cnt){
+ SeriesFragmentProcessor(sk_sp<GrFragmentProcessor>* children, int cnt){
SkASSERT(cnt > 1);
this->initClassID<SeriesFragmentProcessor>();
for (int i = 0; i < cnt; ++i) {
- this->registerChildProcessor(children[i]);
+ this->registerChildProcessor(std::move(children[i]));
}
}
@@ -330,13 +331,8 @@
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
GrProcOptInfo info;
- SkTDArray<const GrFragmentProcessor*> children;
- children.setCount(this->numChildProcessors());
- for (int i = 0; i < children.count(); ++i) {
- children[i] = &this->childProcessor(i);
- }
- info.calcWithInitialValues(children.begin(), children.count(), inout->color(),
- inout->validFlags(), false, false);
+ info.calcWithInitialValues(fChildProcessors.begin(), fChildProcessors.count(),
+ inout->color(), inout->validFlags(), false, false);
for (int i = 0; i < this->numChildProcessors(); ++i) {
this->childProcessor(i).computeInvariantOutput(inout);
}
@@ -348,36 +344,34 @@
}
// Run the through the series, do the invariant output processing, and look for eliminations.
- SkTDArray<const GrFragmentProcessor*> replacementSeries;
- SkAutoTUnref<const GrFragmentProcessor> colorFP;
GrProcOptInfo info;
-
- info.calcWithInitialValues(series, cnt, 0x0, kNone_GrColorComponentFlags, false, false);
+ info.calcWithInitialValues(sk_sp_address_as_pointer_address(series), cnt,
+ 0x0, kNone_GrColorComponentFlags, false, false);
if (kRGBA_GrColorComponentFlags == info.validFlags()) {
- return GrConstColorProcessor::Create(info.color(),
- GrConstColorProcessor::kIgnore_InputMode);
- } else {
- int firstIdx = info.firstEffectiveProcessorIndex();
- cnt -= firstIdx;
- if (firstIdx > 0 && info.inputColorIsUsed()) {
- colorFP.reset(GrConstColorProcessor::Create(info.inputColorToFirstEffectiveProccesor(),
- GrConstColorProcessor::kIgnore_InputMode));
- cnt += 1;
- replacementSeries.setCount(cnt);
- replacementSeries[0] = colorFP;
- for (int i = 0; i < cnt - 1; ++i) {
- replacementSeries[i + 1] = series[firstIdx + i];
- }
- series = replacementSeries.begin();
- } else {
- series += firstIdx;
- cnt -= firstIdx;
+ return GrConstColorProcessor::Make(info.color(), GrConstColorProcessor::kIgnore_InputMode);
+ }
+
+ SkTArray<sk_sp<GrFragmentProcessor>> replacementSeries;
+
+ int firstIdx = info.firstEffectiveProcessorIndex();
+ cnt -= firstIdx;
+ if (firstIdx > 0 && info.inputColorIsUsed()) {
+ sk_sp<GrFragmentProcessor> colorFP(GrConstColorProcessor::Make(
+ info.inputColorToFirstEffectiveProccesor(), GrConstColorProcessor::kIgnore_InputMode));
+ cnt += 1;
+ replacementSeries.reserve(cnt);
+ replacementSeries.emplace_back(std::move(colorFP));
+ for (int i = 0; i < cnt - 1; ++i) {
+ replacementSeries.emplace_back(std::move(series[firstIdx + i]));
}
+ series = replacementSeries.begin();
+ } else {
+ series += firstIdx;
+ cnt -= firstIdx;
}
if (1 == cnt) {
- return SkRef(series[0]);
- } else {
- return new SeriesFragmentProcessor(series, cnt);
+ return series[0];
}
+ return sk_sp<GrFragmentProcessor>(new SeriesFragmentProcessor(series, cnt));
}
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index 2accbf6..cef08f4 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -184,8 +184,9 @@
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(CircleGeometryProcessor);
-const GrGeometryProcessor* CircleGeometryProcessor::TestCreate(GrProcessorTestData* d) {
- return new CircleGeometryProcessor(d->fRandom->nextBool(), GrTest::TestMatrix(d->fRandom));
+sk_sp<GrGeometryProcessor> CircleGeometryProcessor::TestCreate(GrProcessorTestData* d) {
+ return sk_sp<GrGeometryProcessor>(
+ new CircleGeometryProcessor(d->fRandom->nextBool(), GrTest::TestMatrix(d->fRandom)));
}
///////////////////////////////////////////////////////////////////////////////
@@ -335,8 +336,9 @@
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(EllipseGeometryProcessor);
-const GrGeometryProcessor* EllipseGeometryProcessor::TestCreate(GrProcessorTestData* d) {
- return new EllipseGeometryProcessor(d->fRandom->nextBool(), GrTest::TestMatrix(d->fRandom));
+sk_sp<GrGeometryProcessor> EllipseGeometryProcessor::TestCreate(GrProcessorTestData* d) {
+ return sk_sp<GrGeometryProcessor>(
+ new EllipseGeometryProcessor(d->fRandom->nextBool(), GrTest::TestMatrix(d->fRandom)));
}
///////////////////////////////////////////////////////////////////////////////
@@ -514,9 +516,10 @@
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DIEllipseGeometryProcessor);
-const GrGeometryProcessor* DIEllipseGeometryProcessor::TestCreate(GrProcessorTestData* d) {
- return new DIEllipseGeometryProcessor(GrTest::TestMatrix(d->fRandom),
- (DIEllipseStyle)(d->fRandom->nextRangeU(0,2)));
+sk_sp<GrGeometryProcessor> DIEllipseGeometryProcessor::TestCreate(GrProcessorTestData* d) {
+ return sk_sp<GrGeometryProcessor>(
+ new DIEllipseGeometryProcessor(GrTest::TestMatrix(d->fRandom),
+ (DIEllipseStyle)(d->fRandom->nextRangeU(0,2))));
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/GrPaint.cpp b/src/gpu/GrPaint.cpp
index f41469e..fd78f9f 100644
--- a/src/gpu/GrPaint.cpp
+++ b/src/gpu/GrPaint.cpp
@@ -19,36 +19,34 @@
, fColor(GrColor_WHITE) {}
void GrPaint::setCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage) {
- fXPFactory.reset(GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage));
+ fXPFactory = GrCoverageSetOpXPFactory::Make(regionOp, invertCoverage);
}
void GrPaint::addColorTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
- this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(texture, matrix))->unref();
+ this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(texture, matrix));
}
void GrPaint::addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
- this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(texture, matrix))->unref();
+ this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(texture, matrix));
}
void GrPaint::addColorTextureProcessor(GrTexture* texture,
const SkMatrix& matrix,
const GrTextureParams& params) {
- this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(texture,
- matrix, params))->unref();
+ this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(texture, matrix, params));
}
void GrPaint::addCoverageTextureProcessor(GrTexture* texture,
const SkMatrix& matrix,
const GrTextureParams& params) {
- this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(texture,
- matrix, params))->unref();
+ this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(texture, matrix, params));
}
bool GrPaint::isConstantBlendedColor(GrColor* color) const {
GrProcOptInfo colorProcInfo;
- colorProcInfo.calcWithInitialValues(fColorFragmentProcessors.begin(),
- this->numColorFragmentProcessors(), fColor,
- kRGBA_GrColorComponentFlags, false);
+ colorProcInfo.calcWithInitialValues(
+ sk_sp_address_as_pointer_address(fColorFragmentProcessors.begin()),
+ this->numColorFragmentProcessors(), fColor, kRGBA_GrColorComponentFlags, false);
GrXPFactory::InvariantBlendedColor blendedColor;
if (fXPFactory) {
diff --git a/src/gpu/GrPipelineBuilder.cpp b/src/gpu/GrPipelineBuilder.cpp
index f7848ba..e142de2 100644
--- a/src/gpu/GrPipelineBuilder.cpp
+++ b/src/gpu/GrPipelineBuilder.cpp
@@ -27,11 +27,11 @@
SkDEBUGCODE(fBlockEffectRemovalCnt = 0;)
for (int i = 0; i < paint.numColorFragmentProcessors(); ++i) {
- fColorFragmentProcessors.push_back(SkRef(paint.getColorFragmentProcessor(i)));
+ fColorFragmentProcessors.emplace_back(SkRef(paint.getColorFragmentProcessor(i)));
}
for (int i = 0; i < paint.numCoverageFragmentProcessors(); ++i) {
- fCoverageFragmentProcessors.push_back(SkRef(paint.getCoverageFragmentProcessor(i)));
+ fCoverageFragmentProcessors.emplace_back(SkRef(paint.getCoverageFragmentProcessor(i)));
}
fXPFactory.reset(SkSafeRef(paint.getXPFactory()));
@@ -58,17 +58,12 @@
if (fPipelineBuilder) {
int m = fPipelineBuilder->numColorFragmentProcessors() - fColorEffectCnt;
SkASSERT(m >= 0);
- for (int i = 0; i < m; ++i) {
- fPipelineBuilder->fColorFragmentProcessors.fromBack(i)->unref();
- }
fPipelineBuilder->fColorFragmentProcessors.pop_back_n(m);
int n = fPipelineBuilder->numCoverageFragmentProcessors() - fCoverageEffectCnt;
SkASSERT(n >= 0);
- for (int i = 0; i < n; ++i) {
- fPipelineBuilder->fCoverageFragmentProcessors.fromBack(i)->unref();
- }
fPipelineBuilder->fCoverageFragmentProcessors.pop_back_n(n);
+
SkDEBUGCODE(--fPipelineBuilder->fBlockEffectRemovalCnt;)
}
fPipelineBuilder = const_cast<GrPipelineBuilder*>(pipelineBuilder);
@@ -83,10 +78,4 @@
GrPipelineBuilder::~GrPipelineBuilder() {
SkASSERT(0 == fBlockEffectRemovalCnt);
- for (int i = 0; i < fColorFragmentProcessors.count(); ++i) {
- fColorFragmentProcessors[i]->unref();
- }
- for (int i = 0; i < fCoverageFragmentProcessors.count(); ++i) {
- fCoverageFragmentProcessors[i]->unref();
- }
}
diff --git a/src/gpu/GrPipelineBuilder.h b/src/gpu/GrPipelineBuilder.h
index cccbc2c..a7556eb 100644
--- a/src/gpu/GrPipelineBuilder.h
+++ b/src/gpu/GrPipelineBuilder.h
@@ -16,6 +16,7 @@
#include "GrUserStencilSettings.h"
#include "GrXferProcessor.h"
#include "SkMatrix.h"
+#include "SkRefCnt.h"
#include "effects/GrCoverageSetOpXP.h"
#include "effects/GrDisableColorXP.h"
#include "effects/GrPorterDuffXferProcessor.h"
@@ -56,47 +57,43 @@
this->numCoverageFragmentProcessors(); }
const GrFragmentProcessor* getColorFragmentProcessor(int idx) const {
- return fColorFragmentProcessors[idx];
+ return fColorFragmentProcessors[idx].get();
}
const GrFragmentProcessor* getCoverageFragmentProcessor(int idx) const {
- return fCoverageFragmentProcessors[idx];
+ return fCoverageFragmentProcessors[idx].get();
}
- const GrFragmentProcessor* addColorFragmentProcessor(const GrFragmentProcessor* processor) {
+ void addColorFragmentProcessor(sk_sp<GrFragmentProcessor> processor) {
SkASSERT(processor);
- fColorFragmentProcessors.push_back(SkRef(processor));
- return processor;
+ fColorFragmentProcessors.push_back(std::move(processor));
}
- const GrFragmentProcessor* addCoverageFragmentProcessor(const GrFragmentProcessor* processor) {
+ void addCoverageFragmentProcessor(sk_sp<GrFragmentProcessor> processor) {
SkASSERT(processor);
- fCoverageFragmentProcessors.push_back(SkRef(processor));
- return processor;
+ fCoverageFragmentProcessors.push_back(std::move(processor));
}
/**
* Creates a GrSimpleTextureEffect that uses local coords as texture coordinates.
*/
void addColorTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
- this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(texture, matrix))->unref();
+ this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(texture, matrix));
}
void addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
- this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(texture, matrix))->unref();
+ this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(texture, matrix));
}
void addColorTextureProcessor(GrTexture* texture,
const SkMatrix& matrix,
const GrTextureParams& params) {
- this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(texture, matrix,
- params))->unref();
+ this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(texture, matrix, params));
}
void addCoverageTextureProcessor(GrTexture* texture,
const SkMatrix& matrix,
const GrTextureParams& params) {
- this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(texture, matrix,
- params))->unref();
+ this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(texture, matrix, params));
}
/**
@@ -125,10 +122,9 @@
bool isSet() const { return SkToBool(fPipelineBuilder); }
- const GrFragmentProcessor* addCoverageFragmentProcessor(
- const GrFragmentProcessor* processor) {
+ void addCoverageFragmentProcessor(sk_sp<GrFragmentProcessor> processor) {
SkASSERT(this->isSet());
- return fPipelineBuilder->addCoverageFragmentProcessor(processor);
+ return fPipelineBuilder->addCoverageFragmentProcessor(std::move(processor));
}
private:
@@ -148,9 +144,8 @@
* Installs a GrXPFactory. This object controls how src color, fractional pixel coverage,
* and the dst color are blended.
*/
- const GrXPFactory* setXPFactory(const GrXPFactory* xpFactory) {
- fXPFactory.reset(SkSafeRef(xpFactory));
- return xpFactory;
+ void setXPFactory(sk_sp<GrXPFactory> xpFactory) {
+ fXPFactory = std::move(xpFactory);
}
/**
@@ -158,11 +153,11 @@
* rendering to the stencil buffer.
*/
void setDisableColorXPFactory() {
- fXPFactory.reset(GrDisableColorXPFactory::Create());
+ fXPFactory = GrDisableColorXPFactory::Make();
}
const GrXPFactory* getXPFactory() const {
- return fXPFactory;
+ return fXPFactory.get();
}
/**
@@ -304,12 +299,12 @@
// This is used to assert that this condition holds.
SkDEBUGCODE(mutable int fBlockEffectRemovalCnt;)
- typedef SkSTArray<4, const GrFragmentProcessor*, true> FragmentProcessorArray;
+ typedef SkSTArray<4, sk_sp<GrFragmentProcessor>> FragmentProcessorArray;
uint32_t fFlags;
const GrUserStencilSettings* fUserStencilSettings;
DrawFace fDrawFace;
- mutable SkAutoTUnref<const GrXPFactory> fXPFactory;
+ mutable sk_sp<GrXPFactory> fXPFactory;
FragmentProcessorArray fColorFragmentProcessors;
FragmentProcessorArray fCoverageFragmentProcessors;
diff --git a/src/gpu/GrProcessorUnitTest.cpp b/src/gpu/GrProcessorUnitTest.cpp
index bdc602c..3f43389 100644
--- a/src/gpu/GrProcessorUnitTest.cpp
+++ b/src/gpu/GrProcessorUnitTest.cpp
@@ -8,14 +8,14 @@
#include "GrProcessorUnitTest.h"
#include "GrFragmentProcessor.h"
-const GrFragmentProcessor* GrProcessorUnitTest::CreateChildFP(GrProcessorTestData* data) {
+sk_sp<GrFragmentProcessor> GrProcessorUnitTest::MakeChildFP(GrProcessorTestData* data) {
#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
- SkAutoTUnref<const GrFragmentProcessor> fp;
+ sk_sp<GrFragmentProcessor> fp;
do {
- fp.reset(GrProcessorTestFactory<GrFragmentProcessor>::Create(data));
+ fp = GrProcessorTestFactory<GrFragmentProcessor>::Make(data);
SkASSERT(fp);
} while (fp->numChildProcessors() != 0);
- return SkRef(fp.get());
+ return fp;
#else
SkFAIL("Should not be called if !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS");
return nullptr;
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp
index 05e270f..0c42a2b 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -189,10 +189,10 @@
pipelineBuilder.setUserStencil(userStencilSettings);
pipelineBuilder.addCoverageFragmentProcessor(
- GrSimpleTextureEffect::Create(texture,
- maskMatrix,
- GrTextureParams::kNone_FilterMode,
- kDevice_GrCoordSet))->unref();
+ GrSimpleTextureEffect::Make(texture,
+ maskMatrix,
+ GrTextureParams::kNone_FilterMode,
+ kDevice_GrCoordSet));
SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(color, SkMatrix::I(),
dstRect, nullptr, &invert));
diff --git a/src/gpu/GrTextureParamsAdjuster.cpp b/src/gpu/GrTextureParamsAdjuster.cpp
index 076750e..a68c3d7 100644
--- a/src/gpu/GrTextureParamsAdjuster.cpp
+++ b/src/gpu/GrTextureParamsAdjuster.cpp
@@ -93,9 +93,9 @@
// better!
SkASSERT(copyParams.fFilter != GrTextureParams::kMipMap_FilterMode);
paint.addColorFragmentProcessor(
- GrTextureDomainEffect::Create(inputTexture, SkMatrix::I(), domain,
- GrTextureDomain::kClamp_Mode,
- copyParams.fFilter))->unref();
+ GrTextureDomainEffect::Make(inputTexture, SkMatrix::I(), domain,
+ GrTextureDomain::kClamp_Mode,
+ copyParams.fFilter));
} else {
GrTextureParams params(SkShader::kClamp_TileMode, copyParams.fFilter);
paint.addColorTextureProcessor(inputTexture, SkMatrix::I(), params);
@@ -342,7 +342,7 @@
return kDomain_DomainMode;
}
-static const GrFragmentProcessor* create_fp_for_domain_and_filter(
+static sk_sp<GrFragmentProcessor> create_fp_for_domain_and_filter(
GrTexture* texture,
const SkMatrix& textureMatrix,
DomainMode domainMode,
@@ -351,25 +351,25 @@
SkASSERT(kTightCopy_DomainMode != domainMode);
if (filterOrNullForBicubic) {
if (kDomain_DomainMode == domainMode) {
- return GrTextureDomainEffect::Create(texture, textureMatrix, domain,
- GrTextureDomain::kClamp_Mode,
- *filterOrNullForBicubic);
+ return GrTextureDomainEffect::Make(texture, textureMatrix, domain,
+ GrTextureDomain::kClamp_Mode,
+ *filterOrNullForBicubic);
} else {
GrTextureParams params(SkShader::kClamp_TileMode, *filterOrNullForBicubic);
- return GrSimpleTextureEffect::Create(texture, textureMatrix, params);
+ return GrSimpleTextureEffect::Make(texture, textureMatrix, params);
}
} else {
if (kDomain_DomainMode == domainMode) {
- return GrBicubicEffect::Create(texture, textureMatrix, domain);
+ return GrBicubicEffect::Make(texture, textureMatrix, domain);
} else {
static const SkShader::TileMode kClampClamp[] =
{ SkShader::kClamp_TileMode, SkShader::kClamp_TileMode };
- return GrBicubicEffect::Create(texture, textureMatrix, kClampClamp);
+ return GrBicubicEffect::Make(texture, textureMatrix, kClampClamp);
}
}
}
-const GrFragmentProcessor* GrTextureAdjuster::createFragmentProcessor(
+sk_sp<GrFragmentProcessor> GrTextureAdjuster::createFragmentProcessor(
const SkMatrix& origTextureMatrix,
const SkRect& origConstraintRect,
FilterConstraint filterConstraint,
@@ -467,7 +467,7 @@
return result;
}
-const GrFragmentProcessor* GrTextureMaker::createFragmentProcessor(
+sk_sp<GrFragmentProcessor> GrTextureMaker::createFragmentProcessor(
const SkMatrix& textureMatrix,
const SkRect& constraintRect,
FilterConstraint filterConstraint,
diff --git a/src/gpu/GrTextureParamsAdjuster.h b/src/gpu/GrTextureParamsAdjuster.h
index 5f0f271..08d71c4 100644
--- a/src/gpu/GrTextureParamsAdjuster.h
+++ b/src/gpu/GrTextureParamsAdjuster.h
@@ -59,7 +59,7 @@
* @param filterOrNullForBicubic If non-null indicates the filter mode. If null means
* use bicubic filtering.
**/
- virtual const GrFragmentProcessor* createFragmentProcessor(
+ virtual sk_sp<GrFragmentProcessor> createFragmentProcessor(
const SkMatrix& textureMatrix,
const SkRect& constraintRect,
FilterConstraint filterConstraint,
@@ -131,7 +131,7 @@
GrTexture* refTextureSafeForParams(const GrTextureParams&, SkSourceGammaTreatment,
SkIPoint* outOffset);
- const GrFragmentProcessor* createFragmentProcessor(
+ sk_sp<GrFragmentProcessor> createFragmentProcessor(
const SkMatrix& textureMatrix,
const SkRect& constraintRect,
FilterConstraint,
@@ -172,7 +172,7 @@
the texture. */
GrTexture* refTextureForParams(const GrTextureParams&, SkSourceGammaTreatment);
- const GrFragmentProcessor* createFragmentProcessor(
+ sk_sp<GrFragmentProcessor> createFragmentProcessor(
const SkMatrix& textureMatrix,
const SkRect& constraintRect,
FilterConstraint filterConstraint,
diff --git a/src/gpu/GrTextureToYUVPlanes.cpp b/src/gpu/GrTextureToYUVPlanes.cpp
index 4215602..58c4b9a 100644
--- a/src/gpu/GrTextureToYUVPlanes.cpp
+++ b/src/gpu/GrTextureToYUVPlanes.cpp
@@ -15,12 +15,12 @@
#include "GrTextureProvider.h"
namespace {
- using CreateFPProc = const GrFragmentProcessor* (*)(const GrFragmentProcessor*,
- SkYUVColorSpace colorSpace);
+ using MakeFPProc = sk_sp<GrFragmentProcessor> (*)(sk_sp<GrFragmentProcessor>,
+ SkYUVColorSpace colorSpace);
};
static bool convert_texture(GrTexture* src, GrDrawContext* dst, int dstW, int dstH,
- SkYUVColorSpace colorSpace, CreateFPProc proc) {
+ SkYUVColorSpace colorSpace, MakeFPProc proc) {
SkScalar xScale = SkIntToScalar(src->width()) / dstW / src->width();
SkScalar yScale = SkIntToScalar(src->height()) / dstH / src->height();
@@ -31,18 +31,18 @@
filter = GrTextureParams::kBilerp_FilterMode;
}
- SkAutoTUnref<const GrFragmentProcessor> fp(
- GrSimpleTextureEffect::Create(src, SkMatrix::MakeScale(xScale, yScale), filter));
+ sk_sp<GrFragmentProcessor> fp(
+ GrSimpleTextureEffect::Make(src, SkMatrix::MakeScale(xScale, yScale), filter));
if (!fp) {
return false;
}
- fp.reset(proc(fp, colorSpace));
+ fp = proc(std::move(fp), colorSpace);
if (!fp) {
return false;
}
GrPaint paint;
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
- paint.addColorFragmentProcessor(fp);
+ paint.addColorFragmentProcessor(std::move(fp));
dst->drawRect(GrNoClip(), paint, SkMatrix::I(), SkRect::MakeIWH(dstW, dstH));
return true;
}
@@ -107,32 +107,32 @@
if (yuvDrawContext) {
if (!convert_texture(texture, yuvDrawContext.get(),
sizes[0].fWidth, sizes[0].fHeight,
- colorSpace, GrYUVEffect::CreateRGBToYUV)) {
+ colorSpace, GrYUVEffect::MakeRGBToYUV)) {
return false;
}
} else {
SkASSERT(yDrawContext);
if (!convert_texture(texture, yDrawContext.get(),
sizes[0].fWidth, sizes[0].fHeight,
- colorSpace, GrYUVEffect::CreateRGBToY)) {
+ colorSpace, GrYUVEffect::MakeRGBToY)) {
return false;
}
if (uvDrawContext) {
if (!convert_texture(texture, uvDrawContext.get(),
sizes[1].fWidth, sizes[1].fHeight,
- colorSpace, GrYUVEffect::CreateRGBToUV)) {
+ colorSpace, GrYUVEffect::MakeRGBToUV)) {
return false;
}
} else {
SkASSERT(uDrawContext && vDrawContext);
if (!convert_texture(texture, uDrawContext.get(),
sizes[1].fWidth, sizes[1].fHeight,
- colorSpace, GrYUVEffect::CreateRGBToU)) {
+ colorSpace, GrYUVEffect::MakeRGBToU)) {
return false;
}
if (!convert_texture(texture, vDrawContext.get(),
sizes[2].fWidth, sizes[2].fHeight,
- colorSpace, GrYUVEffect::CreateRGBToV)) {
+ colorSpace, GrYUVEffect::MakeRGBToV)) {
return false;
}
}
diff --git a/src/gpu/GrYUVProvider.cpp b/src/gpu/GrYUVProvider.cpp
index a7281da..b30ff1f 100644
--- a/src/gpu/GrYUVProvider.cpp
+++ b/src/gpu/GrYUVProvider.cpp
@@ -121,13 +121,12 @@
}
GrPaint paint;
- SkAutoTUnref<const GrFragmentProcessor> yuvToRgbProcessor(
- GrYUVEffect::CreateYUVToRGB(yuvTextures[0],
- yuvTextures[1],
- yuvTextures[2],
- yuvInfo.fSizeInfo.fSizes,
- yuvInfo.fColorSpace));
- paint.addColorFragmentProcessor(yuvToRgbProcessor);
+ sk_sp<GrFragmentProcessor> yuvToRgbProcessor(GrYUVEffect::MakeYUVToRGB(yuvTextures[0],
+ yuvTextures[1],
+ yuvTextures[2],
+ yuvInfo.fSizeInfo.fSizes,
+ yuvInfo.fColorSpace));
+ paint.addColorFragmentProcessor(std::move(yuvToRgbProcessor));
// If we're decoding an sRGB image, the result of our linear math on the YUV planes is already
// in sRGB. (The encoding is just math on bytes, with no concept of color spaces.) So, we need
@@ -139,7 +138,7 @@
if (ctx->caps()->srgbWriteControl()) {
paint.setDisableOutputConversionToSRGB(true);
} else {
- paint.addColorFragmentProcessor(GrGammaEffect::Create(2.2f))->unref();
+ paint.addColorFragmentProcessor(GrGammaEffect::Make(2.2f));
}
}
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 81e955d..a894f98 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1198,7 +1198,7 @@
// Construct a GrPaint by setting the bitmap texture as the first effect and then configuring
// the rest from the SkPaint.
- SkAutoTUnref<const GrFragmentProcessor> fp;
+ sk_sp<GrFragmentProcessor> fp;
if (needsTextureDomain && (SkCanvas::kStrict_SrcRectConstraint == constraint)) {
// Use a constrained texture domain to avoid color bleeding
@@ -1219,24 +1219,21 @@
}
textureDomain.setLTRB(left, top, right, bottom);
if (bicubic) {
- fp.reset(GrBicubicEffect::Create(texture, texMatrix, textureDomain));
+ fp = GrBicubicEffect::Make(texture, texMatrix, textureDomain);
} else {
- fp.reset(GrTextureDomainEffect::Create(texture,
- texMatrix,
- textureDomain,
- GrTextureDomain::kClamp_Mode,
- params.filterMode()));
+ fp = GrTextureDomainEffect::Make(texture, texMatrix, textureDomain,
+ GrTextureDomain::kClamp_Mode, params.filterMode());
}
} else if (bicubic) {
SkASSERT(GrTextureParams::kNone_FilterMode == params.filterMode());
SkShader::TileMode tileModes[2] = { params.getTileModeX(), params.getTileModeY() };
- fp.reset(GrBicubicEffect::Create(texture, texMatrix, tileModes));
+ fp = GrBicubicEffect::Make(texture, texMatrix, tileModes);
} else {
- fp.reset(GrSimpleTextureEffect::Create(texture, texMatrix, params));
+ fp = GrSimpleTextureEffect::Make(texture, texMatrix, params);
}
GrPaint grPaint;
- if (!SkPaintToGrPaintWithTexture(this->context(), paint, viewMatrix, fp,
+ if (!SkPaintToGrPaintWithTexture(this->context(), paint, viewMatrix, std::move(fp),
kAlpha_8_SkColorType == bitmap.colorType(),
this->surfaceProps().isGammaCorrect(), &grPaint)) {
return;
@@ -1280,14 +1277,13 @@
SkASSERT(!paint.getImageFilter());
GrPaint grPaint;
- SkAutoTUnref<const GrFragmentProcessor> fp(
- GrSimpleTextureEffect::Create(texture, SkMatrix::I()));
+ sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(texture, SkMatrix::I()));
if (alphaOnly) {
- fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp));
+ fp = GrFragmentProcessor::MulOutputByInputUnpremulColor(std::move(fp));
} else {
- fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp));
+ fp = GrFragmentProcessor::MulOutputByInputAlpha(std::move(fp));
}
- if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp,
+ if (!SkPaintToGrPaintReplaceShader(this->context(), paint, std::move(fp),
this->surfaceProps().isGammaCorrect(), &grPaint)) {
return;
}
@@ -1415,16 +1411,15 @@
SkASSERT(!paint.getImageFilter());
GrPaint grPaint;
- SkAutoTUnref<const GrFragmentProcessor> fp(
- GrSimpleTextureEffect::Create(devTex.get(), SkMatrix::I()));
+ sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(devTex.get(), SkMatrix::I()));
if (GrPixelConfigIsAlphaOnly(devTex->config())) {
// Can this happen?
- fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp));
+ fp = GrFragmentProcessor::MulOutputByInputUnpremulColor(std::move(fp));
} else {
- fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp));
+ fp = GrFragmentProcessor::MulOutputByInputAlpha(std::move(fp));
}
- if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp,
+ if (!SkPaintToGrPaintReplaceShader(this->context(), paint, std::move(fp),
this->surfaceProps().isGammaCorrect(), &grPaint)) {
return;
}
@@ -1529,13 +1524,13 @@
bool gammaCorrect = this->surfaceProps().isGammaCorrect();
SkSourceGammaTreatment gammaTreatment = gammaCorrect
? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore;
- SkAutoTUnref<const GrFragmentProcessor> fp(
+ sk_sp<GrFragmentProcessor> fp(
producer->createFragmentProcessor(SkMatrix::I(),
SkRect::MakeIWH(producer->width(), producer->height()),
GrTextureProducer::kNo_FilterConstraint, true,
&kMode, gammaTreatment));
GrPaint grPaint;
- if (!SkPaintToGrPaintWithTexture(this->context(), paint, *draw.fMatrix, fp,
+ if (!SkPaintToGrPaintWithTexture(this->context(), paint, *draw.fMatrix, std::move(fp),
producer->isAlphaOnly(), gammaCorrect, &grPaint)) {
return;
}
diff --git a/src/gpu/SkGpuDevice_drawTexture.cpp b/src/gpu/SkGpuDevice_drawTexture.cpp
index 4ba3c8d..8dc4926 100644
--- a/src/gpu/SkGpuDevice_drawTexture.cpp
+++ b/src/gpu/SkGpuDevice_drawTexture.cpp
@@ -204,7 +204,7 @@
bool gammaCorrect = this->surfaceProps().isGammaCorrect();
SkSourceGammaTreatment gammaTreatment = gammaCorrect
? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore;
- SkAutoTUnref<const GrFragmentProcessor> fp(producer->createFragmentProcessor(
+ sk_sp<GrFragmentProcessor> fp(producer->createFragmentProcessor(
*textureMatrix, clippedSrcRect, constraintMode, coordsAllInsideSrcRect, filterMode,
gammaTreatment));
if (!fp) {
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index fb2916d..ca7d6b8 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -506,7 +506,7 @@
static inline bool skpaint_to_grpaint_impl(GrContext* context,
const SkPaint& skPaint,
const SkMatrix& viewM,
- const GrFragmentProcessor** shaderProcessor,
+ sk_sp<GrFragmentProcessor>* shaderProcessor,
SkXfermode::Mode* primColorMode,
bool primitiveIsSrc,
bool allowSRGBInputs,
@@ -516,17 +516,15 @@
// Setup the initial color considering the shader, the SkPaint color, and the presence or not
// of per-vertex colors.
- SkAutoTUnref<const GrFragmentProcessor> aufp;
- const GrFragmentProcessor* shaderFP = nullptr;
+ sk_sp<GrFragmentProcessor> shaderFP;
if (!primColorMode || blend_requires_shader(*primColorMode, primitiveIsSrc)) {
if (shaderProcessor) {
shaderFP = *shaderProcessor;
} else if (const SkShader* shader = skPaint.getShader()) {
SkSourceGammaTreatment gammaTreatment = allowSRGBInputs
? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore;
- aufp.reset(shader->asFragmentProcessor(context, viewM, nullptr,
- skPaint.getFilterQuality(), gammaTreatment));
- shaderFP = aufp;
+ shaderFP = shader->asFragmentProcessor(context, viewM, nullptr,
+ skPaint.getFilterQuality(), gammaTreatment);
if (!shaderFP) {
return false;
}
@@ -549,16 +547,13 @@
GrColor shaderInput = SkColorToOpaqueGrColor(skPaint.getColor());
shaderFP = GrFragmentProcessor::OverrideInput(shaderFP, shaderInput);
- aufp.reset(shaderFP);
-
if (primitiveIsSrc) {
- shaderFP = GrXfermodeFragmentProcessor::CreateFromDstProcessor(shaderFP,
- *primColorMode);
+ shaderFP = GrXfermodeFragmentProcessor::MakeFromDstProcessor(std::move(shaderFP),
+ *primColorMode);
} else {
- shaderFP = GrXfermodeFragmentProcessor::CreateFromSrcProcessor(shaderFP,
- *primColorMode);
+ shaderFP = GrXfermodeFragmentProcessor::MakeFromSrcProcessor(std::move(shaderFP),
+ *primColorMode);
}
- aufp.reset(shaderFP);
// The above may return null if compose results in a pass through of the prim color.
if (shaderFP) {
grPaint->addColorFragmentProcessor(shaderFP);
@@ -566,39 +561,38 @@
GrColor paintAlpha = SkColorAlphaToGrColor(skPaint.getColor());
if (GrColor_WHITE != paintAlpha) {
- grPaint->addColorFragmentProcessor(GrConstColorProcessor::Create(
- paintAlpha, GrConstColorProcessor::kModulateRGBA_InputMode))->unref();
+ grPaint->addColorFragmentProcessor(GrConstColorProcessor::Make(
+ paintAlpha, GrConstColorProcessor::kModulateRGBA_InputMode));
}
} else {
// The shader's FP sees the paint unpremul color
grPaint->setColor(SkColorToUnpremulGrColor(skPaint.getColor()));
- grPaint->addColorFragmentProcessor(shaderFP);
+ grPaint->addColorFragmentProcessor(std::move(shaderFP));
}
} else {
if (primColorMode) {
// There is a blend between the primitive color and the paint color. The blend considers
// the opaque paint color. The paint's alpha is applied to the post-blended color.
- SkAutoTUnref<const GrFragmentProcessor> processor(
- GrConstColorProcessor::Create(SkColorToOpaqueGrColor(skPaint.getColor()),
+ sk_sp<GrFragmentProcessor> processor(
+ GrConstColorProcessor::Make(SkColorToOpaqueGrColor(skPaint.getColor()),
GrConstColorProcessor::kIgnore_InputMode));
if (primitiveIsSrc) {
- processor.reset(GrXfermodeFragmentProcessor::CreateFromDstProcessor(processor,
- *primColorMode));
+ processor = GrXfermodeFragmentProcessor::MakeFromDstProcessor(std::move(processor),
+ *primColorMode);
} else {
- processor.reset(GrXfermodeFragmentProcessor::CreateFromSrcProcessor(processor,
- *primColorMode));
-
+ processor = GrXfermodeFragmentProcessor::MakeFromSrcProcessor(std::move(processor),
+ *primColorMode);
}
if (processor) {
- grPaint->addColorFragmentProcessor(processor);
+ grPaint->addColorFragmentProcessor(std::move(processor));
}
grPaint->setColor(SkColorToOpaqueGrColor(skPaint.getColor()));
GrColor paintAlpha = SkColorAlphaToGrColor(skPaint.getColor());
if (GrColor_WHITE != paintAlpha) {
- grPaint->addColorFragmentProcessor(GrConstColorProcessor::Create(
- paintAlpha, GrConstColorProcessor::kModulateRGBA_InputMode))->unref();
+ grPaint->addColorFragmentProcessor(GrConstColorProcessor::Make(
+ paintAlpha, GrConstColorProcessor::kModulateRGBA_InputMode));
}
} else {
// No shader, no primitive color.
@@ -612,10 +606,9 @@
if (applyColorFilterToPaintColor) {
grPaint->setColor(SkColorToPremulGrColor(colorFilter->filterColor(skPaint.getColor())));
} else {
- SkAutoTUnref<const GrFragmentProcessor> cfFP(
- colorFilter->asFragmentProcessor(context));
+ sk_sp<GrFragmentProcessor> cfFP(colorFilter->asFragmentProcessor(context));
if (cfFP) {
- grPaint->addColorFragmentProcessor(cfFP);
+ grPaint->addColorFragmentProcessor(std::move(cfFP));
} else {
return false;
}
@@ -627,14 +620,12 @@
SkASSERT(!grPaint->getXPFactory());
SkXfermode* xfermode = skPaint.getXfermode();
if (xfermode) {
- // SafeUnref in case a new xfermode is added that returns null.
- // In such cases we will fall back to kSrcOver_Mode.
- SkSafeUnref(grPaint->setXPFactory(xfermode->asXPFactory()));
+ grPaint->setXPFactory(xfermode->asXPFactory());
}
#ifndef SK_IGNORE_GPU_DITHER
if (skPaint.isDither() && grPaint->numColorFragmentProcessors() > 0) {
- grPaint->addColorFragmentProcessor(GrDitherEffect::Create())->unref();
+ grPaint->addColorFragmentProcessor(GrDitherEffect::Make());
}
#endif
return true;
@@ -649,7 +640,7 @@
/** Replaces the SkShader (if any) on skPaint with the passed in GrFragmentProcessor. */
bool SkPaintToGrPaintReplaceShader(GrContext* context,
const SkPaint& skPaint,
- const GrFragmentProcessor* shaderFP,
+ sk_sp<GrFragmentProcessor> shaderFP,
bool allowSRGBInputs,
GrPaint* grPaint) {
if (!shaderFP) {
@@ -665,8 +656,8 @@
bool allowSRGBInputs,
GrPaint* grPaint) {
// Use a ptr to a nullptr to to indicate that the SkShader is ignored and not replaced.
- static const GrFragmentProcessor* kNullShaderFP = nullptr;
- static const GrFragmentProcessor** kIgnoreShader = &kNullShaderFP;
+ static sk_sp<GrFragmentProcessor> kNullShaderFP(nullptr);
+ static sk_sp<GrFragmentProcessor>* kIgnoreShader = &kNullShaderFP;
return skpaint_to_grpaint_impl(context, skPaint, SkMatrix::I(), kIgnoreShader, nullptr, false,
allowSRGBInputs, grPaint);
}
@@ -687,33 +678,34 @@
bool SkPaintToGrPaintWithTexture(GrContext* context,
const SkPaint& paint,
const SkMatrix& viewM,
- const GrFragmentProcessor* fp,
+ sk_sp<GrFragmentProcessor> fp,
bool textureIsAlphaOnly,
bool allowSRGBInputs,
GrPaint* grPaint) {
- SkAutoTUnref<const GrFragmentProcessor> shaderFP;
+ sk_sp<GrFragmentProcessor> shaderFP;
if (textureIsAlphaOnly) {
if (const SkShader* shader = paint.getShader()) {
SkSourceGammaTreatment gammaTreatment = allowSRGBInputs
? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore;
- shaderFP.reset(shader->asFragmentProcessor(context,
- viewM,
- nullptr,
- paint.getFilterQuality(),
- gammaTreatment));
+ shaderFP = shader->asFragmentProcessor(context,
+ viewM,
+ nullptr,
+ paint.getFilterQuality(),
+ gammaTreatment);
if (!shaderFP) {
return false;
}
- const GrFragmentProcessor* fpSeries[] = { shaderFP.get(), fp };
- shaderFP.reset(GrFragmentProcessor::RunInSeries(fpSeries, 2));
+ sk_sp<GrFragmentProcessor> fpSeries[] = { std::move(shaderFP), std::move(fp) };
+ shaderFP = GrFragmentProcessor::RunInSeries(fpSeries, 2);
} else {
- shaderFP.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp));
+ shaderFP = GrFragmentProcessor::MulOutputByInputUnpremulColor(fp);
}
} else {
- shaderFP.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp));
+ shaderFP = GrFragmentProcessor::MulOutputByInputAlpha(fp);
}
- return SkPaintToGrPaintReplaceShader(context, paint, shaderFP.get(), allowSRGBInputs, grPaint);
+ return SkPaintToGrPaintReplaceShader(context, paint, std::move(shaderFP), allowSRGBInputs,
+ grPaint);
}
diff --git a/src/gpu/SkGrPriv.h b/src/gpu/SkGrPriv.h
index 290c056..266cfff 100644
--- a/src/gpu/SkGrPriv.h
+++ b/src/gpu/SkGrPriv.h
@@ -62,7 +62,7 @@
no primitive color. */
bool SkPaintToGrPaintReplaceShader(GrContext*,
const SkPaint& skPaint,
- const GrFragmentProcessor* shaderFP,
+ sk_sp<GrFragmentProcessor> shaderFP,
bool allowSRGBInputs,
GrPaint* grPaint);
@@ -93,7 +93,7 @@
bool SkPaintToGrPaintWithTexture(GrContext* context,
const SkPaint& paint,
const SkMatrix& viewM,
- const GrFragmentProcessor* fp,
+ sk_sp<GrFragmentProcessor> fp,
bool textureIsAlphaOnly,
bool allowSRGBInputs,
GrPaint* grPaint);
diff --git a/src/gpu/batches/GrAAConvexPathRenderer.cpp b/src/gpu/batches/GrAAConvexPathRenderer.cpp
index e875f1c..390162e 100644
--- a/src/gpu/batches/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/batches/GrAAConvexPathRenderer.cpp
@@ -526,9 +526,9 @@
class QuadEdgeEffect : public GrGeometryProcessor {
public:
- static GrGeometryProcessor* Create(GrColor color, const SkMatrix& localMatrix,
- bool usesLocalCoords) {
- return new QuadEdgeEffect(color, localMatrix, usesLocalCoords);
+ static sk_sp<GrGeometryProcessor> Make(GrColor color, const SkMatrix& localMatrix,
+ bool usesLocalCoords) {
+ return sk_sp<GrGeometryProcessor>(new QuadEdgeEffect(color, localMatrix, usesLocalCoords));
}
virtual ~QuadEdgeEffect() {}
@@ -669,12 +669,12 @@
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(QuadEdgeEffect);
-const GrGeometryProcessor* QuadEdgeEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrGeometryProcessor> QuadEdgeEffect::TestCreate(GrProcessorTestData* d) {
// Doesn't work without derivative instructions.
return d->fCaps->shaderCaps()->shaderDerivativeSupport() ?
- QuadEdgeEffect::Create(GrRandomColor(d->fRandom),
- GrTest::TestMatrix(d->fRandom),
- d->fRandom->nextBool()) : nullptr;
+ QuadEdgeEffect::Make(GrRandomColor(d->fRandom),
+ GrTest::TestMatrix(d->fRandom),
+ d->fRandom->nextBool()) : nullptr;
}
///////////////////////////////////////////////////////////////////////////////
@@ -718,7 +718,7 @@
}
}
-static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage,
+static sk_sp<GrGeometryProcessor> create_fill_gp(bool tweakAlphaForCoverage,
const SkMatrix& viewMatrix,
bool usesLocalCoords,
bool coverageIgnored) {
@@ -737,7 +737,7 @@
Coverage coverage(coverageType);
LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type :
LocalCoords::kUnused_Type);
- return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix);
+ return MakeForDeviceSpace(color, coverage, localCoords, viewMatrix);
}
class AAConvexPathBatch : public GrVertexBatch {
@@ -782,10 +782,10 @@
bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
// Setup GrGeometryProcessor
- SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_gp(canTweakAlphaForCoverage,
- this->viewMatrix(),
- this->usesLocalCoords(),
- this->coverageIgnored()));
+ sk_sp<GrGeometryProcessor> gp(create_fill_gp(canTweakAlphaForCoverage,
+ this->viewMatrix(),
+ this->usesLocalCoords(),
+ this->coverageIgnored()));
if (!gp) {
SkDebugf("Could not create GrGeometryProcessor\n");
return;
@@ -836,7 +836,7 @@
vertexBuffer, indexBuffer,
firstVertex, firstIndex,
tess.numPts(), tess.numIndices());
- target->draw(gp, mesh);
+ target->draw(gp.get(), mesh);
}
}
@@ -857,8 +857,8 @@
}
// Setup GrGeometryProcessor
- SkAutoTUnref<GrGeometryProcessor> quadProcessor(
- QuadEdgeEffect::Create(this->color(), invert, this->usesLocalCoords()));
+ sk_sp<GrGeometryProcessor> quadProcessor(
+ QuadEdgeEffect::Make(this->color(), invert, this->usesLocalCoords()));
// TODO generate all segments for all paths and use one vertex buffer
for (int i = 0; i < instanceCount; i++) {
@@ -924,7 +924,7 @@
const Draw& draw = draws[j];
mesh.initIndexed(kTriangles_GrPrimitiveType, vertexBuffer, indexBuffer,
firstVertex, firstIndex, draw.fVertexCnt, draw.fIndexCnt);
- target->draw(quadProcessor, mesh);
+ target->draw(quadProcessor.get(), mesh);
firstVertex += draw.fVertexCnt;
firstIndex += draw.fIndexCnt;
}
diff --git a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
index ed9902c..e6be590 100644
--- a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
+++ b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
@@ -172,9 +172,9 @@
}
struct FlushInfo {
- SkAutoTUnref<const GrBuffer> fVertexBuffer;
- SkAutoTUnref<const GrBuffer> fIndexBuffer;
- SkAutoTUnref<const GrGeometryProcessor> fGeometryProcessor;
+ SkAutoTUnref<const GrBuffer> fVertexBuffer;
+ SkAutoTUnref<const GrBuffer> fIndexBuffer;
+ sk_sp<GrGeometryProcessor> fGeometryProcessor;
int fVertexOffset;
int fInstancesToFlush;
};
@@ -200,13 +200,12 @@
// Setup GrGeometryProcessor
GrBatchAtlas* atlas = fAtlas;
- flushInfo.fGeometryProcessor.reset(
- GrDistanceFieldPathGeoProc::Create(this->color(),
- this->viewMatrix(),
- atlas->getTexture(),
- params,
- flags,
- this->usesLocalCoords()));
+ flushInfo.fGeometryProcessor = GrDistanceFieldPathGeoProc::Make(this->color(),
+ this->viewMatrix(),
+ atlas->getTexture(),
+ params,
+ flags,
+ this->usesLocalCoords());
// allocate vertices
size_t vertexStride = flushInfo.fGeometryProcessor->getVertexStride();
@@ -484,7 +483,7 @@
mesh.initInstanced(kTriangles_GrPrimitiveType, flushInfo->fVertexBuffer,
flushInfo->fIndexBuffer, flushInfo->fVertexOffset, kVerticesPerQuad,
kIndicesPerQuad, flushInfo->fInstancesToFlush, maxInstancesPerDraw);
- target->draw(flushInfo->fGeometryProcessor, mesh);
+ target->draw(flushInfo->fGeometryProcessor.get(), mesh);
flushInfo->fVertexOffset += kVerticesPerQuad * flushInfo->fInstancesToFlush;
flushInfo->fInstancesToFlush = 0;
}
diff --git a/src/gpu/batches/GrAAFillRectBatch.cpp b/src/gpu/batches/GrAAFillRectBatch.cpp
index 2c90b8b..94cef02 100644
--- a/src/gpu/batches/GrAAFillRectBatch.cpp
+++ b/src/gpu/batches/GrAAFillRectBatch.cpp
@@ -44,7 +44,7 @@
gAAFillRectIndexBufferKey);
}
-static const GrGeometryProcessor* create_fill_rect_gp(
+static sk_sp<GrGeometryProcessor> create_fill_rect_gp(
const SkMatrix& viewMatrix,
const GrXPOverridesForBatch& overrides,
GrDefaultGeoProcFactory::LocalCoords::Type localCoordsType) {
@@ -65,11 +65,11 @@
// We assume the caller has inverted the viewmatrix
if (LocalCoords::kHasExplicit_Type == localCoordsType) {
LocalCoords localCoords(localCoordsType);
- return GrDefaultGeoProcFactory::Create(color, coverage, localCoords, SkMatrix::I());
+ return GrDefaultGeoProcFactory::Make(color, coverage, localCoords, SkMatrix::I());
} else {
LocalCoords localCoords(overrides.readsLocalCoords() ? localCoordsType :
LocalCoords::kUnused_Type);
- return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix);
+ return MakeForDeviceSpace(color, coverage, localCoords, viewMatrix);
}
}
@@ -239,9 +239,9 @@
return !overrides.readsLocalCoords() || mine.fViewMatrix.cheapEqualTo(theirs.fViewMatrix);
}
- static const GrGeometryProcessor* CreateGP(const Geometry& geo,
+ static sk_sp<GrGeometryProcessor> MakeGP(const Geometry& geo,
const GrXPOverridesForBatch& overrides) {
- const GrGeometryProcessor* gp =
+ sk_sp<GrGeometryProcessor> gp =
create_fill_rect_gp(geo.fViewMatrix, overrides,
GrDefaultGeoProcFactory::LocalCoords::kUsePosition_Type);
@@ -286,9 +286,9 @@
return true;
}
- static const GrGeometryProcessor* CreateGP(const Geometry& geo,
+ static sk_sp<GrGeometryProcessor> MakeGP(const Geometry& geo,
const GrXPOverridesForBatch& overrides) {
- const GrGeometryProcessor* gp =
+ sk_sp<GrGeometryProcessor> gp =
create_fill_rect_gp(geo.fViewMatrix, overrides,
GrDefaultGeoProcFactory::LocalCoords::kHasExplicit_Type);
diff --git a/src/gpu/batches/GrAAHairLinePathRenderer.cpp b/src/gpu/batches/GrAAHairLinePathRenderer.cpp
index ac5ecc1..f44c454 100644
--- a/src/gpu/batches/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/batches/GrAAHairLinePathRenderer.cpp
@@ -831,7 +831,7 @@
// do lines first
if (lineCount) {
- SkAutoTUnref<const GrGeometryProcessor> lineGP;
+ sk_sp<GrGeometryProcessor> lineGP;
{
using namespace GrDefaultGeoProcFactory;
@@ -840,8 +840,8 @@
LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUsePosition_Type :
LocalCoords::kUnused_Type);
localCoords.fMatrix = geometryProcessorLocalM;
- lineGP.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoords,
- *geometryProcessorViewM));
+ lineGP = GrDefaultGeoProcFactory::Make(color, coverage, localCoords,
+ *geometryProcessorViewM);
}
SkAutoTUnref<const GrBuffer> linesIndexBuffer(
@@ -870,27 +870,27 @@
mesh.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, linesIndexBuffer,
firstVertex, kLineSegNumVertices, kIdxsPerLineSeg, lineCount,
kLineSegsNumInIdxBuffer);
- target->draw(lineGP, mesh);
+ target->draw(lineGP.get(), mesh);
}
if (quadCount || conicCount) {
- SkAutoTUnref<const GrGeometryProcessor> quadGP(
- GrQuadEffect::Create(this->color(),
- *geometryProcessorViewM,
- kHairlineAA_GrProcessorEdgeType,
- target->caps(),
- *geometryProcessorLocalM,
- this->usesLocalCoords(),
- this->coverage()));
+ sk_sp<GrGeometryProcessor> quadGP(
+ GrQuadEffect::Make(this->color(),
+ *geometryProcessorViewM,
+ kHairlineAA_GrProcessorEdgeType,
+ target->caps(),
+ *geometryProcessorLocalM,
+ this->usesLocalCoords(),
+ this->coverage()));
- SkAutoTUnref<const GrGeometryProcessor> conicGP(
- GrConicEffect::Create(this->color(),
- *geometryProcessorViewM,
- kHairlineAA_GrProcessorEdgeType,
- target->caps(),
- *geometryProcessorLocalM,
- this->usesLocalCoords(),
- this->coverage()));
+ sk_sp<GrGeometryProcessor> conicGP(
+ GrConicEffect::Make(this->color(),
+ *geometryProcessorViewM,
+ kHairlineAA_GrProcessorEdgeType,
+ target->caps(),
+ *geometryProcessorLocalM,
+ this->usesLocalCoords(),
+ this->coverage()));
const GrBuffer* vertexBuffer;
int firstVertex;
@@ -927,7 +927,7 @@
mesh.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, quadsIndexBuffer,
firstVertex, kQuadNumVertices, kIdxsPerQuad, quadCount,
kQuadsNumInIdxBuffer);
- target->draw(quadGP, mesh);
+ target->draw(quadGP.get(), mesh);
firstVertex += quadCount * kQuadNumVertices;
}
@@ -936,7 +936,7 @@
mesh.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, quadsIndexBuffer,
firstVertex, kQuadNumVertices, kIdxsPerQuad, conicCount,
kQuadsNumInIdxBuffer);
- target->draw(conicGP, mesh);
+ target->draw(conicGP.get(), mesh);
}
}
}
diff --git a/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp b/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp
index 227f86b..1847a67 100644
--- a/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp
+++ b/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp
@@ -96,7 +96,7 @@
}
}
-static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage,
+static sk_sp<GrGeometryProcessor> create_fill_gp(bool tweakAlphaForCoverage,
const SkMatrix& viewMatrix,
bool usesLocalCoords,
bool coverageIgnored) {
@@ -115,7 +115,7 @@
Coverage coverage(coverageType);
LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type :
LocalCoords::kUnused_Type);
- return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix);
+ return MakeForDeviceSpace(color, coverage, localCoords, viewMatrix);
}
class AAFlatteningConvexPathBatch : public GrVertexBatch {
@@ -195,10 +195,10 @@
bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
// Setup GrGeometryProcessor
- SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_gp(canTweakAlphaForCoverage,
- this->viewMatrix(),
- this->usesLocalCoords(),
- this->coverageIgnored()));
+ sk_sp<GrGeometryProcessor> gp(create_fill_gp(canTweakAlphaForCoverage,
+ this->viewMatrix(),
+ this->usesLocalCoords(),
+ this->coverageIgnored()));
if (!gp) {
SkDebugf("Couldn't create a GrGeometryProcessor\n");
return;
@@ -231,7 +231,8 @@
if (indexCount + currentIndices > UINT16_MAX) {
// if we added the current instance, we would overflow the indices we can store in a
// uint16_t. Draw what we've got so far and reset.
- this->draw(target, gp, vertexCount, vertexStride, vertices, indexCount, indices);
+ this->draw(target, gp.get(),
+ vertexCount, vertexStride, vertices, indexCount, indices);
vertexCount = 0;
indexCount = 0;
}
@@ -250,7 +251,7 @@
vertexCount += currentVertices;
indexCount += currentIndices;
}
- this->draw(target, gp, vertexCount, vertexStride, vertices, indexCount, indices);
+ this->draw(target, gp.get(), vertexCount, vertexStride, vertices, indexCount, indices);
sk_free(vertices);
sk_free(indices);
}
diff --git a/src/gpu/batches/GrAAStrokeRectBatch.cpp b/src/gpu/batches/GrAAStrokeRectBatch.cpp
index cc54408..98b764a 100644
--- a/src/gpu/batches/GrAAStrokeRectBatch.cpp
+++ b/src/gpu/batches/GrAAStrokeRectBatch.cpp
@@ -21,7 +21,7 @@
r.fRight - dx, r.fBottom - dy, stride);
}
-static const GrGeometryProcessor* create_stroke_rect_gp(bool tweakAlphaForCoverage,
+static sk_sp<GrGeometryProcessor> create_stroke_rect_gp(bool tweakAlphaForCoverage,
const SkMatrix& viewMatrix,
bool usesLocalCoords,
bool coverageIgnored) {
@@ -40,7 +40,7 @@
Coverage coverage(coverageType);
LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type :
LocalCoords::kUnused_Type);
- return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix);
+ return MakeForDeviceSpace(color, coverage, localCoords, viewMatrix);
}
class AAStrokeRectBatch : public GrVertexBatch {
@@ -183,10 +183,10 @@
void AAStrokeRectBatch::onPrepareDraws(Target* target) const {
bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
- SkAutoTUnref<const GrGeometryProcessor> gp(create_stroke_rect_gp(canTweakAlphaForCoverage,
- this->viewMatrix(),
- this->usesLocalCoords(),
- this->coverageIgnored()));
+ sk_sp<GrGeometryProcessor> gp(create_stroke_rect_gp(canTweakAlphaForCoverage,
+ this->viewMatrix(),
+ this->usesLocalCoords(),
+ this->coverageIgnored()));
if (!gp) {
SkDebugf("Couldn't create GrGeometryProcessor\n");
return;
@@ -229,7 +229,7 @@
args.fDegenerate,
canTweakAlphaForCoverage);
}
- helper.recordDraw(target, gp);
+ helper.recordDraw(target, gp.get());
}
const GrBuffer* AAStrokeRectBatch::GetIndexBuffer(GrResourceProvider* resourceProvider,
diff --git a/src/gpu/batches/GrAtlasTextBatch.cpp b/src/gpu/batches/GrAtlasTextBatch.cpp
index 32a64c3..3c4b4a5 100644
--- a/src/gpu/batches/GrAtlasTextBatch.cpp
+++ b/src/gpu/batches/GrAtlasTextBatch.cpp
@@ -100,17 +100,16 @@
FlushInfo flushInfo;
if (this->usesDistanceFields()) {
- flushInfo.fGeometryProcessor.reset(
- this->setupDfProcessor(this->viewMatrix(), fFilteredColor, this->color(), texture));
+ flushInfo.fGeometryProcessor =
+ this->setupDfProcessor(this->viewMatrix(), fFilteredColor, this->color(), texture);
} else {
GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kNone_FilterMode);
- flushInfo.fGeometryProcessor.reset(
- GrBitmapTextGeoProc::Create(this->color(),
- texture,
- params,
- maskFormat,
- localMatrix,
- this->usesLocalCoords()));
+ flushInfo.fGeometryProcessor = GrBitmapTextGeoProc::Make(this->color(),
+ texture,
+ params,
+ maskFormat,
+ localMatrix,
+ this->usesLocalCoords());
}
flushInfo.fGlyphsToFlush = 0;
@@ -178,7 +177,7 @@
flushInfo->fIndexBuffer, flushInfo->fVertexOffset,
kVerticesPerGlyph, kIndicesPerGlyph, flushInfo->fGlyphsToFlush,
maxGlyphsPerDraw);
- target->draw(flushInfo->fGeometryProcessor, mesh);
+ target->draw(flushInfo->fGeometryProcessor.get(), mesh);
flushInfo->fVertexOffset += kVerticesPerGlyph * flushInfo->fGlyphsToFlush;
flushInfo->fGlyphsToFlush = 0;
}
@@ -246,9 +245,10 @@
// TODO just use class params
// TODO trying to figure out why lcd is so whack
-GrGeometryProcessor* GrAtlasTextBatch::setupDfProcessor(const SkMatrix& viewMatrix,
- SkColor filteredColor,
- GrColor color, GrTexture* texture) const {
+sk_sp<GrGeometryProcessor> GrAtlasTextBatch::setupDfProcessor(const SkMatrix& viewMatrix,
+ SkColor filteredColor,
+ GrColor color,
+ GrTexture* texture) const {
GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kBilerp_FilterMode);
bool isLCD = this->isLCD();
// set up any flags
@@ -277,32 +277,32 @@
greenCorrection,
blueCorrection);
- return GrDistanceFieldLCDTextGeoProc::Create(color,
- viewMatrix,
- texture,
- params,
- widthAdjust,
- flags,
- this->usesLocalCoords());
+ return GrDistanceFieldLCDTextGeoProc::Make(color,
+ viewMatrix,
+ texture,
+ params,
+ widthAdjust,
+ flags,
+ this->usesLocalCoords());
} else {
#ifdef SK_GAMMA_APPLY_TO_A8
U8CPU lum = SkColorSpaceLuminance::computeLuminance(SK_GAMMA_EXPONENT, filteredColor);
float correction = fDistanceAdjustTable->getAdjustment(
lum >> kDistanceAdjustLumShift, fUseGammaCorrectDistanceTable);
- return GrDistanceFieldA8TextGeoProc::Create(color,
- viewMatrix,
- texture,
- params,
- correction,
- flags,
- this->usesLocalCoords());
+ return GrDistanceFieldA8TextGeoProc::Make(color,
+ viewMatrix,
+ texture,
+ params,
+ correction,
+ flags,
+ this->usesLocalCoords());
#else
- return GrDistanceFieldA8TextGeoProc::Create(color,
- viewMatrix,
- texture,
- params,
- flags,
- this->usesLocalCoords());
+ return GrDistanceFieldA8TextGeoProc::Make(color,
+ viewMatrix,
+ texture,
+ params,
+ flags,
+ this->usesLocalCoords());
#endif
}
diff --git a/src/gpu/batches/GrAtlasTextBatch.h b/src/gpu/batches/GrAtlasTextBatch.h
index 72e299d..89a2f4e 100644
--- a/src/gpu/batches/GrAtlasTextBatch.h
+++ b/src/gpu/batches/GrAtlasTextBatch.h
@@ -101,11 +101,11 @@
void initBatchTracker(const GrXPOverridesForBatch& overrides) override;
struct FlushInfo {
- SkAutoTUnref<const GrBuffer> fVertexBuffer;
- SkAutoTUnref<const GrBuffer> fIndexBuffer;
- SkAutoTUnref<const GrGeometryProcessor> fGeometryProcessor;
- int fGlyphsToFlush;
- int fVertexOffset;
+ SkAutoTUnref<const GrBuffer> fVertexBuffer;
+ SkAutoTUnref<const GrBuffer> fIndexBuffer;
+ sk_sp<GrGeometryProcessor> fGeometryProcessor;
+ int fGlyphsToFlush;
+ int fVertexOffset;
};
void onPrepareDraws(Target* target) const override;
@@ -153,8 +153,8 @@
// TODO just use class params
// TODO trying to figure out why lcd is so whack
- GrGeometryProcessor* setupDfProcessor(const SkMatrix& viewMatrix, SkColor filteredColor,
- GrColor color, GrTexture* texture) const;
+ sk_sp<GrGeometryProcessor> setupDfProcessor(const SkMatrix& viewMatrix, SkColor filteredColor,
+ GrColor color, GrTexture* texture) const;
struct BatchTracker {
GrColor fColor;
diff --git a/src/gpu/batches/GrDefaultPathRenderer.cpp b/src/gpu/batches/GrDefaultPathRenderer.cpp
index c643c49..7fd7913 100644
--- a/src/gpu/batches/GrDefaultPathRenderer.cpp
+++ b/src/gpu/batches/GrDefaultPathRenderer.cpp
@@ -128,7 +128,7 @@
}
void onPrepareDraws(Target* target) const override {
- SkAutoTUnref<const GrGeometryProcessor> gp;
+ sk_sp<GrGeometryProcessor> gp;
{
using namespace GrDefaultGeoProcFactory;
Color color(this->color());
@@ -138,8 +138,7 @@
}
LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUsePosition_Type :
LocalCoords::kUnused_Type);
- gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoords,
- this->viewMatrix()));
+ gp = GrDefaultGeoProcFactory::Make(color, coverage, localCoords, this->viewMatrix());
}
size_t vertexStride = gp->getVertexStride();
@@ -243,7 +242,7 @@
} else {
mesh.init(primitiveType, vertexBuffer, firstVertex, vertexOffset);
}
- target->draw(gp, mesh);
+ target->draw(gp.get(), mesh);
// put back reserves
target->putBackIndices((size_t)(maxIndices - indexOffset));
@@ -627,7 +626,7 @@
SkASSERT(SkPath::kInverseWinding_FillType != args.fPath->getFillType());
GrPaint paint;
- SkSafeUnref(paint.setXPFactory(GrDisableColorXPFactory::Create()));
+ paint.setXPFactory(GrDisableColorXPFactory::Make());
paint.setAntiAlias(args.fIsAA);
this->internalDrawPath(args.fDrawContext,
diff --git a/src/gpu/batches/GrDrawAtlasBatch.cpp b/src/gpu/batches/GrDrawAtlasBatch.cpp
index 58ce137..5b823a9 100644
--- a/src/gpu/batches/GrDrawAtlasBatch.cpp
+++ b/src/gpu/batches/GrDrawAtlasBatch.cpp
@@ -36,7 +36,7 @@
fCoverageIgnored = !overrides.readsCoverage();
}
-static const GrGeometryProcessor* set_vertex_attributes(bool hasColors,
+static sk_sp<GrGeometryProcessor> set_vertex_attributes(bool hasColors,
GrColor color,
const SkMatrix& viewMatrix,
bool coverageIgnored) {
@@ -48,15 +48,15 @@
Coverage coverage(coverageIgnored ? Coverage::kNone_Type : Coverage::kSolid_Type);
LocalCoords localCoords(LocalCoords::kHasExplicit_Type);
- return GrDefaultGeoProcFactory::Create(gpColor, coverage, localCoords, viewMatrix);
+ return GrDefaultGeoProcFactory::Make(gpColor, coverage, localCoords, viewMatrix);
}
void GrDrawAtlasBatch::onPrepareDraws(Target* target) const {
// Setup geometry processor
- SkAutoTUnref<const GrGeometryProcessor> gp(set_vertex_attributes(this->hasColors(),
- this->color(),
- this->viewMatrix(),
- this->coverageIgnored()));
+ sk_sp<GrGeometryProcessor> gp(set_vertex_attributes(this->hasColors(),
+ this->color(),
+ this->viewMatrix(),
+ this->coverageIgnored()));
int instanceCount = fGeoData.count();
size_t vertexStride = gp->getVertexStride();
@@ -79,7 +79,7 @@
memcpy(vertPtr, args.fVerts.begin(), allocSize);
vertPtr += allocSize;
}
- helper.recordDraw(target, gp);
+ helper.recordDraw(target, gp.get());
}
GrDrawAtlasBatch::GrDrawAtlasBatch(const Geometry& geometry, const SkMatrix& viewMatrix,
diff --git a/src/gpu/batches/GrDrawVerticesBatch.cpp b/src/gpu/batches/GrDrawVerticesBatch.cpp
index 12ea05a..dd1ed62 100644
--- a/src/gpu/batches/GrDrawVerticesBatch.cpp
+++ b/src/gpu/batches/GrDrawVerticesBatch.cpp
@@ -11,7 +11,7 @@
#include "GrInvariantOutput.h"
#include "GrDefaultGeoProcFactory.h"
-static const GrGeometryProcessor* set_vertex_attributes(bool hasLocalCoords,
+static sk_sp<GrGeometryProcessor> set_vertex_attributes(bool hasLocalCoords,
int* colorOffset,
int* texOffset,
const SkMatrix& viewMatrix,
@@ -27,8 +27,8 @@
if (hasLocalCoords) {
*texOffset = sizeof(SkPoint) + sizeof(GrColor);
}
- return GrDefaultGeoProcFactory::Create(Color(Color::kAttribute_Type),
- coverage, localCoords, viewMatrix);
+ return GrDefaultGeoProcFactory::Make(Color(Color::kAttribute_Type),
+ coverage, localCoords, viewMatrix);
}
GrDrawVerticesBatch::GrDrawVerticesBatch(const Geometry& geometry, GrPrimitiveType primitiveType,
@@ -94,9 +94,8 @@
void GrDrawVerticesBatch::onPrepareDraws(Target* target) const {
bool hasLocalCoords = !fGeoData[0].fLocalCoords.isEmpty();
int colorOffset = -1, texOffset = -1;
- SkAutoTUnref<const GrGeometryProcessor> gp(
- set_vertex_attributes(hasLocalCoords, &colorOffset, &texOffset, fViewMatrix,
- fCoverageIgnored));
+ sk_sp<GrGeometryProcessor> gp(set_vertex_attributes(hasLocalCoords, &colorOffset, &texOffset,
+ fViewMatrix, fCoverageIgnored));
size_t vertexStride = gp->getVertexStride();
SkASSERT(vertexStride == sizeof(SkPoint) + (hasLocalCoords ? sizeof(SkPoint) : 0)
@@ -162,7 +161,7 @@
} else {
mesh.init(this->primitiveType(), vertexBuffer, firstVertex, fVertexCount);
}
- target->draw(gp, mesh);
+ target->draw(gp.get(), mesh);
}
bool GrDrawVerticesBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) {
diff --git a/src/gpu/batches/GrMSAAPathRenderer.cpp b/src/gpu/batches/GrMSAAPathRenderer.cpp
index cd2713e..edc285e 100644
--- a/src/gpu/batches/GrMSAAPathRenderer.cpp
+++ b/src/gpu/batches/GrMSAAPathRenderer.cpp
@@ -84,7 +84,7 @@
*(lines.nextIndex++) = edgeV0Idx + 1;
}
-static inline void add_quad(MSAALineVertices& lines, MSAAQuadVertices& quads, const SkPoint pts[],
+static inline void add_quad(MSAALineVertices& lines, MSAAQuadVertices& quads, const SkPoint pts[],
SkColor color, bool indexed, uint16_t subpathLineIdxStart) {
SkASSERT(lines.nextVertex < lines.verticesEnd);
*lines.nextVertex = { pts[2], color };
@@ -144,16 +144,16 @@
vsBuilder->codeAppendf("%s = %s;", uv.vsOut(), qp.inUV()->fName);
// Setup position
- this->setupPosition(vsBuilder, uniformHandler, gpArgs, qp.inPosition()->fName,
+ this->setupPosition(vsBuilder, uniformHandler, gpArgs, qp.inPosition()->fName,
qp.viewMatrix(), &fViewMatrixUniform);
// emit transforms
- this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, gpArgs->fPositionVar,
- qp.inPosition()->fName, SkMatrix::I(), args.fTransformsIn,
+ this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, gpArgs->fPositionVar,
+ qp.inPosition()->fName, SkMatrix::I(), args.fTransformsIn,
args.fTransformsOut);
GrGLSLPPFragmentBuilder* fsBuilder = args.fFragBuilder;
- fsBuilder->codeAppendf("if (%s.x * %s.x >= %s.y) discard;", uv.fsIn(), uv.fsIn(),
+ fsBuilder->codeAppendf("if (%s.x * %s.x >= %s.y) discard;", uv.fsIn(), uv.fsIn(),
uv.fsIn());
fsBuilder->codeAppendf("%s = vec4(1.0);", args.fOutputCoverage);
}
@@ -204,9 +204,9 @@
MSAAQuadProcessor(const SkMatrix& viewMatrix)
: fViewMatrix(viewMatrix) {
this->initClassID<MSAAQuadProcessor>();
- fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType,
+ fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType,
kHigh_GrSLPrecision));
- fInUV = &this->addVertexAttrib(Attribute("inUV", kVec2f_GrVertexAttribType,
+ fInUV = &this->addVertexAttrib(Attribute("inUV", kVec2f_GrVertexAttribType,
kHigh_GrSLPrecision));
fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexAttribType));
this->setSampleShading(1.0f);
@@ -216,7 +216,7 @@
const Attribute* fInUV;
const Attribute* fInColor;
SkMatrix fViewMatrix;
-
+
GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
typedef GrGeometryProcessor INHERITED;
@@ -232,14 +232,14 @@
SkScalar fTolerance;
};
- static MSAAPathBatch* Create(const Geometry& geometry, const SkMatrix& viewMatrix,
+ static MSAAPathBatch* Create(const Geometry& geometry, const SkMatrix& viewMatrix,
const SkRect& devBounds) {
return new MSAAPathBatch(geometry, viewMatrix, devBounds);
}
const char* name() const override { return "MSAAPathBatch"; }
- void computePipelineOptimizations(GrInitInvariantOutput* color,
+ void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
// When this is called on a batch, there is only one geometry bundle
@@ -260,7 +260,7 @@
overrides.getOverrideColorIfSet(&fGeoData[0].fColor);
}
- void computeWorstCasePointCount(const SkPath& path, int* subpaths, SkScalar tol,
+ void computeWorstCasePointCount(const SkPath& path, int* subpaths, SkScalar tol,
int* outLinePointCount, int* outQuadPointCount) const {
int linePointCount = 0;
int quadPointCount = 0;
@@ -319,7 +319,7 @@
return;
}
- GrPrimitiveType primitiveType = fIsIndexed ? kTriangles_GrPrimitiveType
+ GrPrimitiveType primitiveType = fIsIndexed ? kTriangles_GrPrimitiveType
: kTriangleFan_GrPrimitiveType;
// allocate vertex / index buffers
@@ -327,9 +327,9 @@
int firstLineVertex;
MSAALineVertices lines;
size_t lineVertexStride = sizeof(MSAALineVertices::Vertex);
- lines.vertices = (MSAALineVertices::Vertex*) target->makeVertexSpace(lineVertexStride,
+ lines.vertices = (MSAALineVertices::Vertex*) target->makeVertexSpace(lineVertexStride,
fMaxLineVertices,
- &lineVertexBuffer,
+ &lineVertexBuffer,
&firstLineVertex);
if (!lines.vertices) {
SkDebugf("Could not allocate vertices\n");
@@ -348,7 +348,7 @@
const GrBuffer* lineIndexBuffer = nullptr;
int firstLineIndex;
if (fIsIndexed) {
- lines.indices = target->makeIndexSpace(fMaxLineIndices, &lineIndexBuffer,
+ lines.indices = target->makeIndexSpace(fMaxLineIndices, &lineIndexBuffer,
&firstLineIndex);
if (!lines.indices) {
SkDebugf("Could not allocate indices\n");
@@ -392,26 +392,26 @@
SkASSERT(quadVertexOffset <= fMaxQuadVertices && quadIndexOffset <= fMaxQuadIndices);
if (lineVertexOffset) {
- SkAutoTUnref<const GrGeometryProcessor> lineGP;
+ sk_sp<GrGeometryProcessor> lineGP;
{
using namespace GrDefaultGeoProcFactory;
- lineGP.reset(GrDefaultGeoProcFactory::Create(Color(Color::kAttribute_Type),
- Coverage(255),
- LocalCoords(LocalCoords::kUnused_Type),
- fViewMatrix));
+ lineGP = GrDefaultGeoProcFactory::Make(Color(Color::kAttribute_Type),
+ Coverage(255),
+ LocalCoords(LocalCoords::kUnused_Type),
+ fViewMatrix);
}
SkASSERT(lineVertexStride == lineGP->getVertexStride());
GrMesh lineMeshes;
if (fIsIndexed) {
- lineMeshes.initIndexed(primitiveType, lineVertexBuffer, lineIndexBuffer,
- firstLineVertex, firstLineIndex, lineVertexOffset,
+ lineMeshes.initIndexed(primitiveType, lineVertexBuffer, lineIndexBuffer,
+ firstLineVertex, firstLineIndex, lineVertexOffset,
lineIndexOffset);
} else {
- lineMeshes.init(primitiveType, lineVertexBuffer, firstLineVertex,
+ lineMeshes.init(primitiveType, lineVertexBuffer, firstLineVertex,
lineVertexOffset);
}
- target->draw(lineGP, lineMeshes);
+ target->draw(lineGP.get(), lineMeshes);
}
if (quadVertexOffset) {
@@ -420,7 +420,7 @@
const GrBuffer* quadVertexBuffer;
int firstQuadVertex;
- MSAAQuadVertices::Vertex* quadVertices = (MSAAQuadVertices::Vertex*)
+ MSAAQuadVertices::Vertex* quadVertices = (MSAAQuadVertices::Vertex*)
target->makeVertexSpace(quadVertexStride, quadVertexOffset, &quadVertexBuffer,
&firstQuadVertex);
memcpy(quadVertices, quads.vertices, quadVertexStride * quadVertexOffset);
@@ -428,15 +428,15 @@
if (fIsIndexed) {
const GrBuffer* quadIndexBuffer;
int firstQuadIndex;
- uint16_t* quadIndices = (uint16_t*) target->makeIndexSpace(quadIndexOffset,
- &quadIndexBuffer,
+ uint16_t* quadIndices = (uint16_t*) target->makeIndexSpace(quadIndexOffset,
+ &quadIndexBuffer,
&firstQuadIndex);
memcpy(quadIndices, quads.indices, sizeof(uint16_t) * quadIndexOffset);
- quadMeshes.initIndexed(kTriangles_GrPrimitiveType, quadVertexBuffer,
- quadIndexBuffer, firstQuadVertex, firstQuadIndex,
+ quadMeshes.initIndexed(kTriangles_GrPrimitiveType, quadVertexBuffer,
+ quadIndexBuffer, firstQuadVertex, firstQuadIndex,
quadVertexOffset, quadIndexOffset);
} else {
- quadMeshes.init(kTriangles_GrPrimitiveType, quadVertexBuffer, firstQuadVertex,
+ quadMeshes.init(kTriangles_GrPrimitiveType, quadVertexBuffer, firstQuadVertex,
quadVertexOffset);
}
target->draw(quadGP, quadMeshes);
@@ -451,7 +451,7 @@
fGeoData.push_back(geometry);
this->setBounds(devBounds);
int contourCount;
- this->computeWorstCasePointCount(geometry.fPath, &contourCount, kTolerance,
+ this->computeWorstCasePointCount(geometry.fPath, &contourCount, kTolerance,
&fMaxLineVertices, &fMaxQuadVertices);
fMaxLineIndices = fMaxLineVertices * 3;
fMaxQuadIndices = fMaxQuadVertices * 3;
@@ -469,7 +469,7 @@
return false;
}
- if ((fMaxLineIndices + that->fMaxLineIndices > SK_MaxU16) ||
+ if ((fMaxLineIndices + that->fMaxLineIndices > SK_MaxU16) ||
(fMaxQuadIndices + that->fMaxQuadIndices > SK_MaxU16)) {
return false;
}
@@ -524,17 +524,17 @@
case SkPath::kConic_Verb: {
SkScalar weight = iter.conicWeight();
SkAutoConicToQuads converter;
- const SkPoint* quadPts = converter.computeQuads(pts, weight,
+ const SkPoint* quadPts = converter.computeQuads(pts, weight,
kTolerance);
for (int i = 0; i < converter.countQuads(); ++i) {
- add_quad(lines, quads, quadPts + i * 2, color, isIndexed,
+ add_quad(lines, quads, quadPts + i * 2, color, isIndexed,
subpathIdxStart);
}
break;
}
case SkPath::kQuad_Verb: {
add_quad(lines, quads, pts, color, isIndexed, subpathIdxStart);
- break;
+ break;
}
case SkPath::kCubic_Verb: {
SkSTArray<15, SkPoint, true> quadPts;
@@ -682,7 +682,7 @@
geometry.fPath = path;
geometry.fTolerance = kTolerance;
- SkAutoTUnref<MSAAPathBatch> batch(MSAAPathBatch::Create(geometry, viewMatrix,
+ SkAutoTUnref<MSAAPathBatch> batch(MSAAPathBatch::Create(geometry, viewMatrix,
devBounds));
if (!batch->isValid()) {
return false;
@@ -749,7 +749,7 @@
SkASSERT(SkPath::kInverseWinding_FillType != args.fPath->getFillType());
GrPaint paint;
- SkSafeUnref(paint.setXPFactory(GrDisableColorXPFactory::Create()));
+ paint.setXPFactory(GrDisableColorXPFactory::Make());
paint.setAntiAlias(args.fIsAA);
this->internalDrawPath(args.fDrawContext,
diff --git a/src/gpu/batches/GrNinePatch.cpp b/src/gpu/batches/GrNinePatch.cpp
index 24e3dd6..5f53395 100644
--- a/src/gpu/batches/GrNinePatch.cpp
+++ b/src/gpu/batches/GrNinePatch.cpp
@@ -15,12 +15,12 @@
#include "SkNinePatchIter.h"
#include "SkRect.h"
-static const GrGeometryProcessor* create_gp(bool readsCoverage) {
+static sk_sp<GrGeometryProcessor> create_gp(bool readsCoverage) {
using namespace GrDefaultGeoProcFactory;
Color color(Color::kAttribute_Type);
Coverage coverage(readsCoverage ? Coverage::kSolid_Type : Coverage::kNone_Type);
LocalCoords localCoords(LocalCoords::kHasExplicit_Type);
- return GrDefaultGeoProcFactory::Create(color, coverage, localCoords, SkMatrix::I());
+ return GrDefaultGeoProcFactory::Make(color, coverage, localCoords, SkMatrix::I());
}
class GrNonAANinePatchBatch : public GrVertexBatch {
@@ -85,7 +85,7 @@
private:
void onPrepareDraws(Target* target) const override {
- SkAutoTUnref<const GrGeometryProcessor> gp(create_gp(fOverrides.readsCoverage()));
+ sk_sp<GrGeometryProcessor> gp(create_gp(fOverrides.readsCoverage()));
if (!gp) {
SkDebugf("Couldn't create GrGeometryProcessor\n");
return;
@@ -136,7 +136,7 @@
verts += kVertsPerRect * vertexStride;
}
}
- helper.recordDraw(target, gp);
+ helper.recordDraw(target, gp.get());
}
void initBatchTracker(const GrXPOverridesForBatch& overrides) override {
diff --git a/src/gpu/batches/GrNonAAFillRectBatch.cpp b/src/gpu/batches/GrNonAAFillRectBatch.cpp
index 5e9d176..3b4c5da 100644
--- a/src/gpu/batches/GrNonAAFillRectBatch.cpp
+++ b/src/gpu/batches/GrNonAAFillRectBatch.cpp
@@ -51,10 +51,10 @@
The vertex attrib order is always pos, color, [local coords].
*/
-static const GrGeometryProcessor* create_gp(const SkMatrix& viewMatrix,
- bool readsCoverage,
- bool hasExplicitLocalCoords,
- const SkMatrix* localMatrix) {
+static sk_sp<GrGeometryProcessor> make_gp(const SkMatrix& viewMatrix,
+ bool readsCoverage,
+ bool hasExplicitLocalCoords,
+ const SkMatrix* localMatrix) {
using namespace GrDefaultGeoProcFactory;
Color color(Color::kAttribute_Type);
Coverage coverage(readsCoverage ? Coverage::kSolid_Type : Coverage::kNone_Type);
@@ -67,14 +67,14 @@
LocalCoords localCoords(hasExplicitLocalCoords ? LocalCoords::kHasExplicit_Type :
LocalCoords::kUsePosition_Type,
localMatrix);
- return GrDefaultGeoProcFactory::Create(color, coverage, localCoords, viewMatrix);
+ return GrDefaultGeoProcFactory::Make(color, coverage, localCoords, viewMatrix);
} else if (hasExplicitLocalCoords) {
LocalCoords localCoords(LocalCoords::kHasExplicit_Type);
- return GrDefaultGeoProcFactory::Create(color, coverage, localCoords, SkMatrix::I());
+ return GrDefaultGeoProcFactory::Make(color, coverage, localCoords, SkMatrix::I());
} else {
LocalCoords localCoords(LocalCoords::kUsePosition_Type, localMatrix);
- return GrDefaultGeoProcFactory::CreateForDeviceSpace(color, coverage, localCoords,
- viewMatrix);
+ return GrDefaultGeoProcFactory::MakeForDeviceSpace(color, coverage, localCoords,
+ viewMatrix);
}
}
@@ -138,10 +138,10 @@
return true;
}
- static const GrGeometryProcessor* CreateGP(const Geometry& geo,
- const GrXPOverridesForBatch& overrides) {
- const GrGeometryProcessor* gp = create_gp(geo.fViewMatrix, overrides.readsCoverage(), true,
- nullptr);
+ static sk_sp<GrGeometryProcessor> MakeGP(const Geometry& geo,
+ const GrXPOverridesForBatch& overrides) {
+ sk_sp<GrGeometryProcessor> gp = make_gp(geo.fViewMatrix, overrides.readsCoverage(), true,
+ nullptr);
SkASSERT(gp->getVertexStride() ==
sizeof(GrDefaultGeoProcFactory::PositionColorLocalCoordAttr));
@@ -186,12 +186,12 @@
(!mine.fHasLocalMatrix || mine.fLocalMatrix.cheapEqualTo(theirs.fLocalMatrix));
}
- static const GrGeometryProcessor* CreateGP(const Geometry& geo,
- const GrXPOverridesForBatch& overrides) {
- const GrGeometryProcessor* gp = create_gp(geo.fViewMatrix, overrides.readsCoverage(),
- geo.fHasLocalRect,
- geo.fHasLocalMatrix ? &geo.fLocalMatrix :
- nullptr);
+ static sk_sp<GrGeometryProcessor> MakeGP(const Geometry& geo,
+ const GrXPOverridesForBatch& overrides) {
+ sk_sp<GrGeometryProcessor> gp = make_gp(geo.fViewMatrix, overrides.readsCoverage(),
+ geo.fHasLocalRect,
+ geo.fHasLocalMatrix ? &geo.fLocalMatrix
+ : nullptr);
SkASSERT(geo.fHasLocalRect ?
gp->getVertexStride() == sizeof(GrDefaultGeoProcFactory::PositionColorLocalCoordAttr) :
diff --git a/src/gpu/batches/GrNonAAStrokeRectBatch.cpp b/src/gpu/batches/GrNonAAStrokeRectBatch.cpp
index 36092ea..a38760c 100644
--- a/src/gpu/batches/GrNonAAStrokeRectBatch.cpp
+++ b/src/gpu/batches/GrNonAAStrokeRectBatch.cpp
@@ -105,7 +105,7 @@
}
void onPrepareDraws(Target* target) const override {
- SkAutoTUnref<const GrGeometryProcessor> gp;
+ sk_sp<GrGeometryProcessor> gp;
{
using namespace GrDefaultGeoProcFactory;
Color color(this->color());
@@ -113,8 +113,7 @@
Coverage::kNone_Type);
LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUsePosition_Type :
LocalCoords::kUnused_Type);
- gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoords,
- this->viewMatrix()));
+ gp = GrDefaultGeoProcFactory::Make(color, coverage, localCoords, this->viewMatrix());
}
size_t vertexStride = gp->getVertexStride();
@@ -157,7 +156,7 @@
GrMesh mesh;
mesh.init(primType, vertexBuffer, firstVertex, vertexCount);
- target->draw(gp, mesh);
+ target->draw(gp.get(), mesh);
}
void initBatchTracker(const GrXPOverridesForBatch& overrides) override {
diff --git a/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp b/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp
index 344748c..2a48018 100644
--- a/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp
+++ b/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp
@@ -72,7 +72,7 @@
SkASSERT(!args.fIsAA || args.fDrawContext->isStencilBufferMultisampled());
GrPaint paint;
- SkSafeUnref(paint.setXPFactory(GrDisableColorXPFactory::Create()));
+ paint.setXPFactory(GrDisableColorXPFactory::Make());
paint.setAntiAlias(args.fIsAA);
const GrPipelineBuilder pipelineBuilder(paint, args.fIsAA);
diff --git a/src/gpu/batches/GrTInstanceBatch.h b/src/gpu/batches/GrTInstanceBatch.h
index b85b3aa..c501fd9 100644
--- a/src/gpu/batches/GrTInstanceBatch.h
+++ b/src/gpu/batches/GrTInstanceBatch.h
@@ -89,8 +89,7 @@
GrTInstanceBatch() : INHERITED(ClassID()) {}
void onPrepareDraws(Target* target) const override {
- SkAutoTUnref<const GrGeometryProcessor> gp(Impl::CreateGP(this->seedGeometry(),
- fOverrides));
+ sk_sp<GrGeometryProcessor> gp(Impl::MakeGP(this->seedGeometry(), fOverrides));
if (!gp) {
SkDebugf("Couldn't create GrGeometryProcessor\n");
return;
@@ -115,7 +114,7 @@
i * Impl::kVertsPerInstance * vertexStride;
Impl::Tesselate(verts, vertexStride, fGeoData[i], fOverrides);
}
- helper.recordDraw(target, gp);
+ helper.recordDraw(target, gp.get());
}
const Geometry& seedGeometry() const { return fGeoData[0]; }
diff --git a/src/gpu/batches/GrTessellatingPathRenderer.cpp b/src/gpu/batches/GrTessellatingPathRenderer.cpp
index e9c6e1e..6bc8549 100644
--- a/src/gpu/batches/GrTessellatingPathRenderer.cpp
+++ b/src/gpu/batches/GrTessellatingPathRenderer.cpp
@@ -211,7 +211,7 @@
}
void onPrepareDraws(Target* target) const override {
- SkAutoTUnref<const GrGeometryProcessor> gp;
+ sk_sp<GrGeometryProcessor> gp;
{
using namespace GrDefaultGeoProcFactory;
@@ -226,8 +226,7 @@
coverageType = Coverage::kNone_Type;
}
Coverage coverage(coverageType);
- gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoords,
- fViewMatrix));
+ gp = GrDefaultGeoProcFactory::Make(color, coverage, localCoords, fViewMatrix);
}
this->draw(target, gp.get());
}
diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp
index 075ce16..9d3e8ee 100644
--- a/src/gpu/effects/GrBezierEffect.cpp
+++ b/src/gpu/effects/GrBezierEffect.cpp
@@ -272,15 +272,15 @@
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrConicEffect);
-const GrGeometryProcessor* GrConicEffect::TestCreate(GrProcessorTestData* d) {
- GrGeometryProcessor* gp;
+sk_sp<GrGeometryProcessor> GrConicEffect::TestCreate(GrProcessorTestData* d) {
+ sk_sp<GrGeometryProcessor> gp;
do {
GrPrimitiveEdgeType edgeType =
static_cast<GrPrimitiveEdgeType>(
d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt));
- gp = GrConicEffect::Create(GrRandomColor(d->fRandom), GrTest::TestMatrix(d->fRandom),
- edgeType, *d->fCaps,
- GrTest::TestMatrix(d->fRandom), d->fRandom->nextBool());
+ gp = GrConicEffect::Make(GrRandomColor(d->fRandom), GrTest::TestMatrix(d->fRandom),
+ edgeType, *d->fCaps,
+ GrTest::TestMatrix(d->fRandom), d->fRandom->nextBool());
} while (nullptr == gp);
return gp;
}
@@ -488,16 +488,16 @@
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrQuadEffect);
-const GrGeometryProcessor* GrQuadEffect::TestCreate(GrProcessorTestData* d) {
- GrGeometryProcessor* gp;
+sk_sp<GrGeometryProcessor> GrQuadEffect::TestCreate(GrProcessorTestData* d) {
+ sk_sp<GrGeometryProcessor> gp;
do {
GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(
d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt));
- gp = GrQuadEffect::Create(GrRandomColor(d->fRandom),
- GrTest::TestMatrix(d->fRandom),
- edgeType, *d->fCaps,
- GrTest::TestMatrix(d->fRandom),
- d->fRandom->nextBool());
+ gp = GrQuadEffect::Make(GrRandomColor(d->fRandom),
+ GrTest::TestMatrix(d->fRandom),
+ edgeType, *d->fCaps,
+ GrTest::TestMatrix(d->fRandom),
+ d->fRandom->nextBool());
} while (nullptr == gp);
return gp;
}
@@ -716,14 +716,14 @@
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrCubicEffect);
-const GrGeometryProcessor* GrCubicEffect::TestCreate(GrProcessorTestData* d) {
- GrGeometryProcessor* gp;
+sk_sp<GrGeometryProcessor> GrCubicEffect::TestCreate(GrProcessorTestData* d) {
+ sk_sp<GrGeometryProcessor> gp;
do {
GrPrimitiveEdgeType edgeType =
static_cast<GrPrimitiveEdgeType>(
d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt));
- gp = GrCubicEffect::Create(GrRandomColor(d->fRandom),
- GrTest::TestMatrix(d->fRandom), edgeType, *d->fCaps);
+ gp = GrCubicEffect::Make(GrRandomColor(d->fRandom),
+ GrTest::TestMatrix(d->fRandom), edgeType, *d->fCaps);
} while (nullptr == gp);
return gp;
}
diff --git a/src/gpu/effects/GrBezierEffect.h b/src/gpu/effects/GrBezierEffect.h
index ddb249b..50dca99 100644
--- a/src/gpu/effects/GrBezierEffect.h
+++ b/src/gpu/effects/GrBezierEffect.h
@@ -58,30 +58,33 @@
class GrConicEffect : public GrGeometryProcessor {
public:
- static GrGeometryProcessor* Create(GrColor color,
- const SkMatrix& viewMatrix,
- const GrPrimitiveEdgeType edgeType,
- const GrCaps& caps,
- const SkMatrix& localMatrix,
- bool usesLocalCoords,
- uint8_t coverage = 0xff) {
+ static sk_sp<GrGeometryProcessor> Make(GrColor color,
+ const SkMatrix& viewMatrix,
+ const GrPrimitiveEdgeType edgeType,
+ const GrCaps& caps,
+ const SkMatrix& localMatrix,
+ bool usesLocalCoords,
+ uint8_t coverage = 0xff) {
switch (edgeType) {
case kFillAA_GrProcessorEdgeType:
if (!caps.shaderCaps()->shaderDerivativeSupport()) {
return nullptr;
}
- return new GrConicEffect(color, viewMatrix, coverage, kFillAA_GrProcessorEdgeType,
- localMatrix, usesLocalCoords);
+ return sk_sp<GrGeometryProcessor>(
+ new GrConicEffect(color, viewMatrix, coverage, kFillAA_GrProcessorEdgeType,
+ localMatrix, usesLocalCoords));
case kHairlineAA_GrProcessorEdgeType:
if (!caps.shaderCaps()->shaderDerivativeSupport()) {
return nullptr;
}
- return new GrConicEffect(color, viewMatrix, coverage,
- kHairlineAA_GrProcessorEdgeType, localMatrix,
- usesLocalCoords);
+ return sk_sp<GrGeometryProcessor>(
+ new GrConicEffect(color, viewMatrix, coverage,
+ kHairlineAA_GrProcessorEdgeType, localMatrix,
+ usesLocalCoords));
case kFillBW_GrProcessorEdgeType:
- return new GrConicEffect(color, viewMatrix, coverage, kFillBW_GrProcessorEdgeType,
- localMatrix, usesLocalCoords);
+ return sk_sp<GrGeometryProcessor>(
+ new GrConicEffect(color, viewMatrix, coverage, kFillBW_GrProcessorEdgeType,
+ localMatrix, usesLocalCoords));
default:
return nullptr;
}
@@ -138,30 +141,33 @@
class GrQuadEffect : public GrGeometryProcessor {
public:
- static GrGeometryProcessor* Create(GrColor color,
- const SkMatrix& viewMatrix,
- const GrPrimitiveEdgeType edgeType,
- const GrCaps& caps,
- const SkMatrix& localMatrix,
- bool usesLocalCoords,
- uint8_t coverage = 0xff) {
+ static sk_sp<GrGeometryProcessor> Make(GrColor color,
+ const SkMatrix& viewMatrix,
+ const GrPrimitiveEdgeType edgeType,
+ const GrCaps& caps,
+ const SkMatrix& localMatrix,
+ bool usesLocalCoords,
+ uint8_t coverage = 0xff) {
switch (edgeType) {
case kFillAA_GrProcessorEdgeType:
if (!caps.shaderCaps()->shaderDerivativeSupport()) {
return nullptr;
}
- return new GrQuadEffect(color, viewMatrix, coverage, kFillAA_GrProcessorEdgeType,
- localMatrix, usesLocalCoords);
+ return sk_sp<GrGeometryProcessor>(
+ new GrQuadEffect(color, viewMatrix, coverage, kFillAA_GrProcessorEdgeType,
+ localMatrix, usesLocalCoords));
case kHairlineAA_GrProcessorEdgeType:
if (!caps.shaderCaps()->shaderDerivativeSupport()) {
return nullptr;
}
- return new GrQuadEffect(color, viewMatrix, coverage,
- kHairlineAA_GrProcessorEdgeType, localMatrix,
- usesLocalCoords);
+ return sk_sp<GrGeometryProcessor>(
+ new GrQuadEffect(color, viewMatrix, coverage,
+ kHairlineAA_GrProcessorEdgeType, localMatrix,
+ usesLocalCoords));
case kFillBW_GrProcessorEdgeType:
- return new GrQuadEffect(color, viewMatrix, coverage, kFillBW_GrProcessorEdgeType,
- localMatrix, usesLocalCoords);
+ return sk_sp<GrGeometryProcessor>(
+ new GrQuadEffect(color, viewMatrix, coverage, kFillBW_GrProcessorEdgeType,
+ localMatrix, usesLocalCoords));
default:
return nullptr;
}
@@ -220,23 +226,26 @@
class GrCubicEffect : public GrGeometryProcessor {
public:
- static GrGeometryProcessor* Create(GrColor color,
- const SkMatrix& viewMatrix,
- const GrPrimitiveEdgeType edgeType,
- const GrCaps& caps) {
+ static sk_sp<GrGeometryProcessor> Make(GrColor color,
+ const SkMatrix& viewMatrix,
+ const GrPrimitiveEdgeType edgeType,
+ const GrCaps& caps) {
switch (edgeType) {
case kFillAA_GrProcessorEdgeType:
if (!caps.shaderCaps()->shaderDerivativeSupport()) {
return nullptr;
}
- return new GrCubicEffect(color, viewMatrix, kFillAA_GrProcessorEdgeType);
+ return sk_sp<GrGeometryProcessor>(
+ new GrCubicEffect(color, viewMatrix, kFillAA_GrProcessorEdgeType));
case kHairlineAA_GrProcessorEdgeType:
if (!caps.shaderCaps()->shaderDerivativeSupport()) {
return nullptr;
}
- return new GrCubicEffect(color, viewMatrix, kHairlineAA_GrProcessorEdgeType);
+ return sk_sp<GrGeometryProcessor>(
+ new GrCubicEffect(color, viewMatrix, kHairlineAA_GrProcessorEdgeType));
case kFillBW_GrProcessorEdgeType:
- return new GrCubicEffect(color, viewMatrix, kFillBW_GrProcessorEdgeType);
+ return sk_sp<GrGeometryProcessor>(
+ new GrCubicEffect(color, viewMatrix, kFillBW_GrProcessorEdgeType));
default:
return nullptr;
}
diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp
index 0a06b62..5e6967c 100644
--- a/src/gpu/effects/GrBicubicEffect.cpp
+++ b/src/gpu/effects/GrBicubicEffect.cpp
@@ -179,14 +179,14 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrBicubicEffect);
-const GrFragmentProcessor* GrBicubicEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrBicubicEffect::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
SkScalar coefficients[16];
for (int i = 0; i < 16; i++) {
coefficients[i] = d->fRandom->nextSScalar1();
}
- return GrBicubicEffect::Create(d->fTextures[texIdx], coefficients);
+ return GrBicubicEffect::Make(d->fTextures[texIdx], coefficients);
}
//////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/effects/GrBicubicEffect.h b/src/gpu/effects/GrBicubicEffect.h
index 2087192..3c84f97 100644
--- a/src/gpu/effects/GrBicubicEffect.h
+++ b/src/gpu/effects/GrBicubicEffect.h
@@ -32,43 +32,46 @@
/**
* Create a simple filter effect with custom bicubic coefficients and optional domain.
*/
- static const GrFragmentProcessor* Create(GrTexture* tex, const SkScalar coefficients[16],
- const SkRect* domain = nullptr) {
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, const SkScalar coefficients[16],
+ const SkRect* domain = nullptr) {
if (nullptr == domain) {
static const SkShader::TileMode kTileModes[] = { SkShader::kClamp_TileMode,
SkShader::kClamp_TileMode };
- return Create(tex, coefficients, GrCoordTransform::MakeDivByTextureWHMatrix(tex),
- kTileModes);
+ return Make(tex, coefficients, GrCoordTransform::MakeDivByTextureWHMatrix(tex),
+ kTileModes);
} else {
- return new GrBicubicEffect(tex, coefficients,
- GrCoordTransform::MakeDivByTextureWHMatrix(tex), *domain);
+ return sk_sp<GrFragmentProcessor>(
+ new GrBicubicEffect(tex, coefficients,
+ GrCoordTransform::MakeDivByTextureWHMatrix(tex), *domain));
}
}
/**
* Create a Mitchell filter effect with specified texture matrix and x/y tile modes.
*/
- static const GrFragmentProcessor* Create(GrTexture* tex, const SkMatrix& matrix,
- const SkShader::TileMode tileModes[2]) {
- return Create(tex, gMitchellCoefficients, matrix, tileModes);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, const SkMatrix& matrix,
+ const SkShader::TileMode tileModes[2]) {
+ return Make(tex, gMitchellCoefficients, matrix, tileModes);
}
/**
* Create a filter effect with custom bicubic coefficients, the texture matrix, and the x/y
* tilemodes.
*/
- static const GrFragmentProcessor* Create(GrTexture* tex, const SkScalar coefficients[16],
- const SkMatrix& matrix,
- const SkShader::TileMode tileModes[2]) {
- return new GrBicubicEffect(tex, coefficients, matrix, tileModes);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, const SkScalar coefficients[16],
+ const SkMatrix& matrix,
+ const SkShader::TileMode tileModes[2]) {
+ return sk_sp<GrFragmentProcessor>(new GrBicubicEffect(tex, coefficients, matrix,
+ tileModes));
}
/**
* Create a Mitchell filter effect with a texture matrix and a domain.
*/
- static const GrFragmentProcessor* Create(GrTexture* tex, const SkMatrix& matrix,
- const SkRect& domain) {
- return new GrBicubicEffect(tex, gMitchellCoefficients, matrix, domain);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, const SkMatrix& matrix,
+ const SkRect& domain) {
+ return sk_sp<GrFragmentProcessor>(new GrBicubicEffect(tex, gMitchellCoefficients, matrix,
+ domain));
}
/**
diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp
index 246d7be..633a880 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.cpp
+++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp
@@ -164,7 +164,7 @@
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrBitmapTextGeoProc);
-const GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrGeometryProcessor> GrBitmapTextGeoProc::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
static const SkShader::TileMode kTileModes[] = {
@@ -177,7 +177,7 @@
kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
};
GrTextureParams params(tileModes, d->fRandom->nextBool() ? GrTextureParams::kBilerp_FilterMode :
- GrTextureParams::kNone_FilterMode);
+ GrTextureParams::kNone_FilterMode);
GrMaskFormat format = kARGB_GrMaskFormat; // init to avoid warning
switch (d->fRandom->nextULessThan(3)) {
@@ -192,7 +192,7 @@
break;
}
- return GrBitmapTextGeoProc::Create(GrRandomColor(d->fRandom), d->fTextures[texIdx], params,
- format, GrTest::TestMatrix(d->fRandom),
- d->fRandom->nextBool());
+ return GrBitmapTextGeoProc::Make(GrRandomColor(d->fRandom), d->fTextures[texIdx], params,
+ format, GrTest::TestMatrix(d->fRandom),
+ d->fRandom->nextBool());
}
diff --git a/src/gpu/effects/GrBitmapTextGeoProc.h b/src/gpu/effects/GrBitmapTextGeoProc.h
index 5501d93..226ae77 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.h
+++ b/src/gpu/effects/GrBitmapTextGeoProc.h
@@ -21,10 +21,11 @@
*/
class GrBitmapTextGeoProc : public GrGeometryProcessor {
public:
- static GrGeometryProcessor* Create(GrColor color, GrTexture* tex, const GrTextureParams& p,
+ static sk_sp<GrGeometryProcessor> Make(GrColor color, GrTexture* tex, const GrTextureParams& p,
GrMaskFormat format, const SkMatrix& localMatrix,
bool usesLocalCoords) {
- return new GrBitmapTextGeoProc(color, tex, p, format, localMatrix, usesLocalCoords);
+ return sk_sp<GrGeometryProcessor>(
+ new GrBitmapTextGeoProc(color, tex, p, format, localMatrix, usesLocalCoords));
}
virtual ~GrBitmapTextGeoProc() {}
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index 9791cb4..d2fde96 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -125,14 +125,15 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConfigConversionEffect);
-const GrFragmentProcessor* GrConfigConversionEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrConfigConversionEffect::TestCreate(GrProcessorTestData* d) {
PMConversion pmConv = static_cast<PMConversion>(d->fRandom->nextULessThan(kPMConversionCnt));
GrSwizzle swizzle;
do {
swizzle = GrSwizzle::CreateRandom(d->fRandom);
} while (pmConv == kNone_PMConversion && swizzle == GrSwizzle::RGBA());
- return new GrConfigConversionEffect(d->fTextures[GrProcessorUnitTest::kSkiaPMTextureIdx],
- swizzle, pmConv, GrTest::TestMatrix(d->fRandom));
+ return sk_sp<GrFragmentProcessor>(
+ new GrConfigConversionEffect(d->fTextures[GrProcessorUnitTest::kSkiaPMTextureIdx],
+ swizzle, pmConv, GrTest::TestMatrix(d->fRandom)));
}
///////////////////////////////////////////////////////////////////////////////
@@ -214,17 +215,16 @@
GrPaint paint1;
GrPaint paint2;
GrPaint paint3;
- SkAutoTUnref<GrFragmentProcessor> pmToUPM1(new GrConfigConversionEffect(
+ sk_sp<GrFragmentProcessor> pmToUPM1(new GrConfigConversionEffect(
dataTex, GrSwizzle::RGBA(), *pmToUPMRule, SkMatrix::I()));
- SkAutoTUnref<GrFragmentProcessor> upmToPM(new GrConfigConversionEffect(
+ sk_sp<GrFragmentProcessor> upmToPM(new GrConfigConversionEffect(
readTex, GrSwizzle::RGBA(), *upmToPMRule, SkMatrix::I()));
- SkAutoTUnref<GrFragmentProcessor> pmToUPM2(new GrConfigConversionEffect(
+ sk_sp<GrFragmentProcessor> pmToUPM2(new GrConfigConversionEffect(
tempTex, GrSwizzle::RGBA(), *pmToUPMRule, SkMatrix::I()));
- paint1.addColorFragmentProcessor(pmToUPM1);
+ paint1.addColorFragmentProcessor(std::move(pmToUPM1));
paint1.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
-
sk_sp<GrDrawContext> readDrawContext(
context->drawContext(sk_ref_sp(readTex->asRenderTarget())));
if (!readDrawContext) {
@@ -240,7 +240,7 @@
readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, firstRead);
- paint2.addColorFragmentProcessor(upmToPM);
+ paint2.addColorFragmentProcessor(std::move(upmToPM));
paint2.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
sk_sp<GrDrawContext> tempDrawContext(
@@ -255,7 +255,7 @@
kDstRect,
kSrcRect);
- paint3.addColorFragmentProcessor(pmToUPM2);
+ paint3.addColorFragmentProcessor(std::move(pmToUPM2));
paint3.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
readDrawContext = context->drawContext(sk_ref_sp(readTex->asRenderTarget()));
@@ -288,15 +288,15 @@
}
}
-const GrFragmentProcessor* GrConfigConversionEffect::Create(GrTexture* texture,
- const GrSwizzle& swizzle,
- PMConversion pmConversion,
- const SkMatrix& matrix) {
+sk_sp<GrFragmentProcessor> GrConfigConversionEffect::Make(GrTexture* texture,
+ const GrSwizzle& swizzle,
+ PMConversion pmConversion,
+ const SkMatrix& matrix) {
if (swizzle == GrSwizzle::RGBA() && kNone_PMConversion == pmConversion) {
// If we returned a GrConfigConversionEffect that was equivalent to a GrSimpleTextureEffect
// then we may pollute our texture cache with redundant shaders. So in the case that no
// conversions were requested we instead return a GrSimpleTextureEffect.
- return GrSimpleTextureEffect::Create(texture, matrix);
+ return GrSimpleTextureEffect::Make(texture, matrix);
} else {
if (kRGBA_8888_GrPixelConfig != texture->config() &&
kBGRA_8888_GrPixelConfig != texture->config() &&
@@ -304,6 +304,7 @@
// The PM conversions assume colors are 0..255
return nullptr;
}
- return new GrConfigConversionEffect(texture, swizzle, pmConversion, matrix);
+ return sk_sp<GrFragmentProcessor>(
+ new GrConfigConversionEffect(texture, swizzle, pmConversion, matrix));
}
}
diff --git a/src/gpu/effects/GrConfigConversionEffect.h b/src/gpu/effects/GrConfigConversionEffect.h
index 65c55e7..93b49aa 100644
--- a/src/gpu/effects/GrConfigConversionEffect.h
+++ b/src/gpu/effects/GrConfigConversionEffect.h
@@ -33,8 +33,8 @@
kPMConversionCnt
};
- static const GrFragmentProcessor* Create(GrTexture*, const GrSwizzle&, PMConversion,
- const SkMatrix&);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture*, const GrSwizzle&, PMConversion,
+ const SkMatrix&);
const char* name() const override { return "Config Conversion"; }
diff --git a/src/gpu/effects/GrConstColorProcessor.cpp b/src/gpu/effects/GrConstColorProcessor.cpp
index c51ab8e..0684c9c 100644
--- a/src/gpu/effects/GrConstColorProcessor.cpp
+++ b/src/gpu/effects/GrConstColorProcessor.cpp
@@ -112,7 +112,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConstColorProcessor);
-const GrFragmentProcessor* GrConstColorProcessor::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrConstColorProcessor::TestCreate(GrProcessorTestData* d) {
GrColor color SK_INIT_TO_AVOID_WARNING;
int colorPicker = d->fRandom->nextULessThan(3);
switch (colorPicker) {
@@ -133,5 +133,5 @@
break;
}
InputMode mode = static_cast<InputMode>(d->fRandom->nextULessThan(kInputModeCnt));
- return GrConstColorProcessor::Create(color, mode);
+ return GrConstColorProcessor::Make(color, mode);
}
diff --git a/src/gpu/effects/GrConvexPolyEffect.cpp b/src/gpu/effects/GrConvexPolyEffect.cpp
index caf86c2..5ce7867 100644
--- a/src/gpu/effects/GrConvexPolyEffect.cpp
+++ b/src/gpu/effects/GrConvexPolyEffect.cpp
@@ -19,8 +19,8 @@
public:
const SkRect& getRect() const { return fRect; }
- static GrFragmentProcessor* Create(GrPrimitiveEdgeType edgeType, const SkRect& rect) {
- return new AARectEffect(edgeType, rect);
+ static sk_sp<GrFragmentProcessor> Make(GrPrimitiveEdgeType edgeType, const SkRect& rect) {
+ return sk_sp<GrFragmentProcessor>(new AARectEffect(edgeType, rect));
}
GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
@@ -63,17 +63,17 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(AARectEffect);
-const GrFragmentProcessor* AARectEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> AARectEffect::TestCreate(GrProcessorTestData* d) {
SkRect rect = SkRect::MakeLTRB(d->fRandom->nextSScalar1(),
d->fRandom->nextSScalar1(),
d->fRandom->nextSScalar1(),
d->fRandom->nextSScalar1());
- GrFragmentProcessor* fp;
+ sk_sp<GrFragmentProcessor> fp;
do {
GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(
d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt));
- fp = AARectEffect::Create(edgeType, rect);
+ fp = AARectEffect::Make(edgeType, rect);
} while (nullptr == fp);
return fp;
}
@@ -237,8 +237,8 @@
//////////////////////////////////////////////////////////////////////////////
-GrFragmentProcessor* GrConvexPolyEffect::Create(GrPrimitiveEdgeType type, const SkPath& path,
- const SkVector* offset) {
+sk_sp<GrFragmentProcessor> GrConvexPolyEffect::Make(GrPrimitiveEdgeType type, const SkPath& path,
+ const SkVector* offset) {
if (kHairlineAA_GrProcessorEdgeType == type) {
return nullptr;
}
@@ -253,10 +253,10 @@
// skip the draw or omit the clip element.
if (!SkPathPriv::CheapComputeFirstDirection(path, &dir)) {
if (GrProcessorEdgeTypeIsInverseFill(type)) {
- return GrConstColorProcessor::Create(0xFFFFFFFF,
- GrConstColorProcessor::kModulateRGBA_InputMode);
+ return GrConstColorProcessor::Make(0xFFFFFFFF,
+ GrConstColorProcessor::kModulateRGBA_InputMode);
}
- return GrConstColorProcessor::Create(0, GrConstColorProcessor::kIgnore_InputMode);
+ return GrConstColorProcessor::Make(0, GrConstColorProcessor::kIgnore_InputMode);
}
SkVector t;
@@ -308,14 +308,15 @@
if (path.isInverseFillType()) {
type = GrInvertProcessorEdgeType(type);
}
- return Create(type, n, edges);
+ return Make(type, n, edges);
}
-GrFragmentProcessor* GrConvexPolyEffect::Create(GrPrimitiveEdgeType edgeType, const SkRect& rect) {
+sk_sp<GrFragmentProcessor> GrConvexPolyEffect::Make(GrPrimitiveEdgeType edgeType,
+ const SkRect& rect) {
if (kHairlineAA_GrProcessorEdgeType == edgeType){
return nullptr;
}
- return AARectEffect::Create(edgeType, rect);
+ return AARectEffect::Make(edgeType, rect);
}
GrConvexPolyEffect::~GrConvexPolyEffect() {}
@@ -359,18 +360,18 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConvexPolyEffect);
-const GrFragmentProcessor* GrConvexPolyEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrConvexPolyEffect::TestCreate(GrProcessorTestData* d) {
int count = d->fRandom->nextULessThan(kMaxEdges) + 1;
SkScalar edges[kMaxEdges * 3];
for (int i = 0; i < 3 * count; ++i) {
edges[i] = d->fRandom->nextSScalar1();
}
- GrFragmentProcessor* fp;
+ sk_sp<GrFragmentProcessor> fp;
do {
GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(
d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt));
- fp = GrConvexPolyEffect::Create(edgeType, count, edges);
+ fp = GrConvexPolyEffect::Make(edgeType, count, edges);
} while (nullptr == fp);
return fp;
}
diff --git a/src/gpu/effects/GrConvexPolyEffect.h b/src/gpu/effects/GrConvexPolyEffect.h
index 316f111..8fc76fe 100644
--- a/src/gpu/effects/GrConvexPolyEffect.h
+++ b/src/gpu/effects/GrConvexPolyEffect.h
@@ -38,12 +38,12 @@
* have to modify the effect/shaderbuilder interface to make it possible (e.g. give access
* to the view matrix or untransformed positions in the fragment shader).
*/
- static GrFragmentProcessor* Create(GrPrimitiveEdgeType edgeType, int n,
- const SkScalar edges[]) {
+ static sk_sp<GrFragmentProcessor> Make(GrPrimitiveEdgeType edgeType, int n,
+ const SkScalar edges[]) {
if (n <= 0 || n > kMaxEdges || kHairlineAA_GrProcessorEdgeType == edgeType) {
return nullptr;
}
- return new GrConvexPolyEffect(edgeType, n, edges);
+ return sk_sp<GrFragmentProcessor>(new GrConvexPolyEffect(edgeType, n, edges));
}
/**
@@ -51,13 +51,13 @@
* inverse filled, or has too many edges, this will return nullptr. If offset is non-nullptr, then
* the path is translated by the vector.
*/
- static GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkPath&,
- const SkVector* offset = nullptr);
+ static sk_sp<GrFragmentProcessor> Make(GrPrimitiveEdgeType, const SkPath&,
+ const SkVector* offset = nullptr);
/**
* Creates an effect that fills inside the rect with AA edges..
*/
- static GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkRect&);
+ static sk_sp<GrFragmentProcessor> Make(GrPrimitiveEdgeType, const SkRect&);
virtual ~GrConvexPolyEffect();
diff --git a/src/gpu/effects/GrConvolutionEffect.cpp b/src/gpu/effects/GrConvolutionEffect.cpp
index 9567e4c..2266c47 100644
--- a/src/gpu/effects/GrConvolutionEffect.cpp
+++ b/src/gpu/effects/GrConvolutionEffect.cpp
@@ -213,7 +213,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConvolutionEffect);
-const GrFragmentProcessor* GrConvolutionEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrConvolutionEffect::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
Direction dir = d->fRandom->nextBool() ? kX_Direction : kY_Direction;
@@ -228,10 +228,10 @@
}
bool useBounds = d->fRandom->nextBool();
- return GrConvolutionEffect::Create(d->fTextures[texIdx],
- dir,
- radius,
- kernel,
- useBounds,
- bounds);
+ return GrConvolutionEffect::Make(d->fTextures[texIdx],
+ dir,
+ radius,
+ kernel,
+ useBounds,
+ bounds);
}
diff --git a/src/gpu/effects/GrConvolutionEffect.h b/src/gpu/effects/GrConvolutionEffect.h
index af58021..c353542 100644
--- a/src/gpu/effects/GrConvolutionEffect.h
+++ b/src/gpu/effects/GrConvolutionEffect.h
@@ -21,23 +21,25 @@
public:
/// Convolve with an arbitrary user-specified kernel
- static GrFragmentProcessor* Create(GrTexture* tex,
- Direction dir,
- int halfWidth,
- const float* kernel,
- bool useBounds,
- float bounds[2]) {
- return new GrConvolutionEffect(tex, dir, halfWidth, kernel, useBounds, bounds);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* tex,
+ Direction dir,
+ int halfWidth,
+ const float* kernel,
+ bool useBounds,
+ float bounds[2]) {
+ return sk_sp<GrFragmentProcessor>(
+ new GrConvolutionEffect(tex, dir, halfWidth, kernel, useBounds, bounds));
}
/// Convolve with a Gaussian kernel
- static GrFragmentProcessor* CreateGaussian(GrTexture* tex,
- Direction dir,
- int halfWidth,
- float gaussianSigma,
- bool useBounds,
- float bounds[2]) {
- return new GrConvolutionEffect(tex, dir, halfWidth, gaussianSigma, useBounds, bounds);
+ static sk_sp<GrFragmentProcessor> MakeGaussian(GrTexture* tex,
+ Direction dir,
+ int halfWidth,
+ float gaussianSigma,
+ bool useBounds,
+ float bounds[2]) {
+ return sk_sp<GrFragmentProcessor>(
+ new GrConvolutionEffect(tex, dir, halfWidth, gaussianSigma, useBounds, bounds));
}
virtual ~GrConvolutionEffect();
diff --git a/src/gpu/effects/GrCoverageSetOpXP.cpp b/src/gpu/effects/GrCoverageSetOpXP.cpp
index c0ba62f..90657ea 100644
--- a/src/gpu/effects/GrCoverageSetOpXP.cpp
+++ b/src/gpu/effects/GrCoverageSetOpXP.cpp
@@ -243,65 +243,65 @@
this->initClassID<GrCoverageSetOpXPFactory>();
}
-GrXPFactory* GrCoverageSetOpXPFactory::Create(SkRegion::Op regionOp, bool invertCoverage) {
+sk_sp<GrXPFactory> GrCoverageSetOpXPFactory::Make(SkRegion::Op regionOp, bool invertCoverage) {
switch (regionOp) {
case SkRegion::kReplace_Op: {
if (invertCoverage) {
static GrCoverageSetOpXPFactory gReplaceCDXPFI(regionOp, invertCoverage);
- return SkRef(&gReplaceCDXPFI);
+ return sk_sp<GrXPFactory>(SkRef(&gReplaceCDXPFI));
} else {
static GrCoverageSetOpXPFactory gReplaceCDXPF(regionOp, invertCoverage);
- return SkRef(&gReplaceCDXPF);
+ return sk_sp<GrXPFactory>(SkRef(&gReplaceCDXPF));
}
break;
}
case SkRegion::kIntersect_Op: {
if (invertCoverage) {
static GrCoverageSetOpXPFactory gIntersectCDXPFI(regionOp, invertCoverage);
- return SkRef(&gIntersectCDXPFI);
+ return sk_sp<GrXPFactory>(SkRef(&gIntersectCDXPFI));
} else {
static GrCoverageSetOpXPFactory gIntersectCDXPF(regionOp, invertCoverage);
- return SkRef(&gIntersectCDXPF);
+ return sk_sp<GrXPFactory>(SkRef(&gIntersectCDXPF));
}
break;
}
case SkRegion::kUnion_Op: {
if (invertCoverage) {
static GrCoverageSetOpXPFactory gUnionCDXPFI(regionOp, invertCoverage);
- return SkRef(&gUnionCDXPFI);
+ return sk_sp<GrXPFactory>(SkRef(&gUnionCDXPFI));
} else {
static GrCoverageSetOpXPFactory gUnionCDXPF(regionOp, invertCoverage);
- return SkRef(&gUnionCDXPF);
+ return sk_sp<GrXPFactory>(SkRef(&gUnionCDXPF));
}
break;
}
case SkRegion::kXOR_Op: {
if (invertCoverage) {
static GrCoverageSetOpXPFactory gXORCDXPFI(regionOp, invertCoverage);
- return SkRef(&gXORCDXPFI);
+ return sk_sp<GrXPFactory>(SkRef(&gXORCDXPFI));
} else {
static GrCoverageSetOpXPFactory gXORCDXPF(regionOp, invertCoverage);
- return SkRef(&gXORCDXPF);
+ return sk_sp<GrXPFactory>(SkRef(&gXORCDXPF));
}
break;
}
case SkRegion::kDifference_Op: {
if (invertCoverage) {
static GrCoverageSetOpXPFactory gDifferenceCDXPFI(regionOp, invertCoverage);
- return SkRef(&gDifferenceCDXPFI);
+ return sk_sp<GrXPFactory>(SkRef(&gDifferenceCDXPFI));
} else {
static GrCoverageSetOpXPFactory gDifferenceCDXPF(regionOp, invertCoverage);
- return SkRef(&gDifferenceCDXPF);
+ return sk_sp<GrXPFactory>(SkRef(&gDifferenceCDXPF));
}
break;
}
case SkRegion::kReverseDifference_Op: {
if (invertCoverage) {
static GrCoverageSetOpXPFactory gRevDiffCDXPFI(regionOp, invertCoverage);
- return SkRef(&gRevDiffCDXPFI);
+ return sk_sp<GrXPFactory>(SkRef(&gRevDiffCDXPFI));
} else {
static GrCoverageSetOpXPFactory gRevDiffCDXPF(regionOp, invertCoverage);
- return SkRef(&gRevDiffCDXPF);
+ return sk_sp<GrXPFactory>(SkRef(&gRevDiffCDXPF));
}
break;
}
@@ -337,8 +337,8 @@
GR_DEFINE_XP_FACTORY_TEST(GrCoverageSetOpXPFactory);
-const GrXPFactory* GrCoverageSetOpXPFactory::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrXPFactory> GrCoverageSetOpXPFactory::TestCreate(GrProcessorTestData* d) {
SkRegion::Op regionOp = SkRegion::Op(d->fRandom->nextULessThan(SkRegion::kLastOp + 1));
bool invertCoverage = !d->fDrawContext->hasMixedSamples() && d->fRandom->nextBool();
- return GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage);
+ return GrCoverageSetOpXPFactory::Make(regionOp, invertCoverage);
}
diff --git a/src/gpu/effects/GrCustomXfermode.cpp b/src/gpu/effects/GrCustomXfermode.cpp
index 50fe5cb..1b94a6b 100644
--- a/src/gpu/effects/GrCustomXfermode.cpp
+++ b/src/gpu/effects/GrCustomXfermode.cpp
@@ -382,19 +382,19 @@
}
GR_DEFINE_XP_FACTORY_TEST(CustomXPFactory);
-const GrXPFactory* CustomXPFactory::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrXPFactory> CustomXPFactory::TestCreate(GrProcessorTestData* d) {
int mode = d->fRandom->nextRangeU(SkXfermode::kLastCoeffMode + 1,
SkXfermode::kLastSeparableMode);
- return new CustomXPFactory(static_cast<SkXfermode::Mode>(mode));
+ return sk_sp<GrXPFactory>(new CustomXPFactory(static_cast<SkXfermode::Mode>(mode)));
}
///////////////////////////////////////////////////////////////////////////////
-GrXPFactory* GrCustomXfermode::CreateXPFactory(SkXfermode::Mode mode) {
+sk_sp<GrXPFactory> GrCustomXfermode::MakeXPFactory(SkXfermode::Mode mode) {
if (!GrCustomXfermode::IsSupportedMode(mode)) {
return nullptr;
} else {
- return new CustomXPFactory(mode);
+ return sk_sp<GrXPFactory>(new CustomXPFactory(mode));
}
}
diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp
index 8a7cb5e..ae37540 100644
--- a/src/gpu/effects/GrDashingEffect.cpp
+++ b/src/gpu/effects/GrDashingEffect.cpp
@@ -232,11 +232,11 @@
* Bounding geometry is rendered and the effect computes coverage based on the fragment's
* position relative to the dashed line.
*/
-static GrGeometryProcessor* create_dash_gp(GrColor,
- AAMode aaMode,
- DashCap cap,
- const SkMatrix& localMatrix,
- bool usesLocalCoords);
+static sk_sp<GrGeometryProcessor> make_dash_gp(GrColor,
+ AAMode aaMode,
+ DashCap cap,
+ const SkMatrix& localMatrix,
+ bool usesLocalCoords);
class DashBatch : public GrVertexBatch {
public:
@@ -331,10 +331,10 @@
bool isRoundCap = SkPaint::kRound_Cap == cap;
DashCap capType = isRoundCap ? kRound_DashCap : kNonRound_DashCap;
- SkAutoTUnref<const GrGeometryProcessor> gp;
+ sk_sp<GrGeometryProcessor> gp;
if (this->fullDash()) {
- gp.reset(create_dash_gp(this->color(), this->aaMode(), capType, this->viewMatrix(),
- this->usesLocalCoords()));
+ gp = make_dash_gp(this->color(), this->aaMode(), capType, this->viewMatrix(),
+ this->usesLocalCoords());
} else {
// Set up the vertex data for the line and start/end dashes
using namespace GrDefaultGeoProcFactory;
@@ -343,7 +343,7 @@
Coverage::kSolid_Type);
LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUsePosition_Type :
LocalCoords::kUnused_Type);
- gp.reset(CreateForDeviceSpace(color, coverage, localCoords, this->viewMatrix()));
+ gp = MakeForDeviceSpace(color, coverage, localCoords, this->viewMatrix());
}
if (!gp) {
@@ -622,7 +622,7 @@
rectIndex++;
}
SkASSERT(0 == (curVIdx % 4) && (curVIdx / 4) == totalRectCount);
- helper.recordDraw(target, gp);
+ helper.recordDraw(target, gp.get());
}
bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override {
@@ -757,10 +757,10 @@
public:
typedef SkPathEffect::DashInfo DashInfo;
- static GrGeometryProcessor* Create(GrColor,
- AAMode aaMode,
- const SkMatrix& localMatrix,
- bool usesLocalCoords);
+ static sk_sp<GrGeometryProcessor> Make(GrColor,
+ AAMode aaMode,
+ const SkMatrix& localMatrix,
+ bool usesLocalCoords);
const char* name() const override { return "DashingCircleEffect"; }
@@ -919,11 +919,12 @@
//////////////////////////////////////////////////////////////////////////////
-GrGeometryProcessor* DashingCircleEffect::Create(GrColor color,
- AAMode aaMode,
- const SkMatrix& localMatrix,
- bool usesLocalCoords) {
- return new DashingCircleEffect(color, aaMode, localMatrix, usesLocalCoords);
+sk_sp<GrGeometryProcessor> DashingCircleEffect::Make(GrColor color,
+ AAMode aaMode,
+ const SkMatrix& localMatrix,
+ bool usesLocalCoords) {
+ return sk_sp<GrGeometryProcessor>(
+ new DashingCircleEffect(color, aaMode, localMatrix, usesLocalCoords));
}
void DashingCircleEffect::getGLSLProcessorKey(const GrGLSLCaps& caps,
@@ -952,11 +953,11 @@
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingCircleEffect);
-const GrGeometryProcessor* DashingCircleEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrGeometryProcessor> DashingCircleEffect::TestCreate(GrProcessorTestData* d) {
AAMode aaMode = static_cast<AAMode>(d->fRandom->nextULessThan(GrDashingEffect::kAAModeCnt));
- return DashingCircleEffect::Create(GrRandomColor(d->fRandom),
- aaMode, GrTest::TestMatrix(d->fRandom),
- d->fRandom->nextBool());
+ return DashingCircleEffect::Make(GrRandomColor(d->fRandom),
+ aaMode, GrTest::TestMatrix(d->fRandom),
+ d->fRandom->nextBool());
}
//////////////////////////////////////////////////////////////////////////////
@@ -976,10 +977,10 @@
public:
typedef SkPathEffect::DashInfo DashInfo;
- static GrGeometryProcessor* Create(GrColor,
- AAMode aaMode,
- const SkMatrix& localMatrix,
- bool usesLocalCoords);
+ static sk_sp<GrGeometryProcessor> Make(GrColor,
+ AAMode aaMode,
+ const SkMatrix& localMatrix,
+ bool usesLocalCoords);
const char* name() const override { return "DashingEffect"; }
@@ -1151,11 +1152,12 @@
//////////////////////////////////////////////////////////////////////////////
-GrGeometryProcessor* DashingLineEffect::Create(GrColor color,
- AAMode aaMode,
- const SkMatrix& localMatrix,
- bool usesLocalCoords) {
- return new DashingLineEffect(color, aaMode, localMatrix, usesLocalCoords);
+sk_sp<GrGeometryProcessor> DashingLineEffect::Make(GrColor color,
+ AAMode aaMode,
+ const SkMatrix& localMatrix,
+ bool usesLocalCoords) {
+ return sk_sp<GrGeometryProcessor>(
+ new DashingLineEffect(color, aaMode, localMatrix, usesLocalCoords));
}
void DashingLineEffect::getGLSLProcessorKey(const GrGLSLCaps& caps,
@@ -1183,20 +1185,20 @@
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingLineEffect);
-const GrGeometryProcessor* DashingLineEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrGeometryProcessor> DashingLineEffect::TestCreate(GrProcessorTestData* d) {
AAMode aaMode = static_cast<AAMode>(d->fRandom->nextULessThan(GrDashingEffect::kAAModeCnt));
- return DashingLineEffect::Create(GrRandomColor(d->fRandom),
- aaMode, GrTest::TestMatrix(d->fRandom),
- d->fRandom->nextBool());
+ return DashingLineEffect::Make(GrRandomColor(d->fRandom),
+ aaMode, GrTest::TestMatrix(d->fRandom),
+ d->fRandom->nextBool());
}
//////////////////////////////////////////////////////////////////////////////
-static GrGeometryProcessor* create_dash_gp(GrColor color,
- AAMode aaMode,
- DashCap cap,
- const SkMatrix& viewMatrix,
- bool usesLocalCoords) {
+static sk_sp<GrGeometryProcessor> make_dash_gp(GrColor color,
+ AAMode aaMode,
+ DashCap cap,
+ const SkMatrix& viewMatrix,
+ bool usesLocalCoords) {
SkMatrix invert;
if (usesLocalCoords && !viewMatrix.invert(&invert)) {
SkDebugf("Failed to invert\n");
@@ -1205,9 +1207,9 @@
switch (cap) {
case kRound_DashCap:
- return DashingCircleEffect::Create(color, aaMode, invert, usesLocalCoords);
+ return DashingCircleEffect::Make(color, aaMode, invert, usesLocalCoords);
case kNonRound_DashCap:
- return DashingLineEffect::Create(color, aaMode, invert, usesLocalCoords);
+ return DashingLineEffect::Make(color, aaMode, invert, usesLocalCoords);
}
return nullptr;
}
diff --git a/src/gpu/effects/GrDisableColorXP.cpp b/src/gpu/effects/GrDisableColorXP.cpp
index 7d776e7..1ff8ad6 100644
--- a/src/gpu/effects/GrDisableColorXP.cpp
+++ b/src/gpu/effects/GrDisableColorXP.cpp
@@ -104,6 +104,6 @@
GR_DEFINE_XP_FACTORY_TEST(GrDisableColorXPFactory);
-const GrXPFactory* GrDisableColorXPFactory::TestCreate(GrProcessorTestData*) {
- return GrDisableColorXPFactory::Create();
+sk_sp<GrXPFactory> GrDisableColorXPFactory::TestCreate(GrProcessorTestData*) {
+ return GrDisableColorXPFactory::Make();
}
diff --git a/src/gpu/effects/GrDisableColorXP.h b/src/gpu/effects/GrDisableColorXP.h
index 5584954..4aed6b6 100644
--- a/src/gpu/effects/GrDisableColorXP.h
+++ b/src/gpu/effects/GrDisableColorXP.h
@@ -10,12 +10,13 @@
#include "GrTypes.h"
#include "GrXferProcessor.h"
+#include "SkRefCnt.h"
class GrProcOptInfo;
class GrDisableColorXPFactory : public GrXPFactory {
public:
- static GrXPFactory* Create() { return new GrDisableColorXPFactory; }
+ static sk_sp<GrXPFactory> Make() { return sk_sp<GrXPFactory>(new GrDisableColorXPFactory); }
void getInvariantBlendedColor(const GrProcOptInfo& colorPOI,
GrXPFactory::InvariantBlendedColor* blendedColor) const override {
diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
index e87021e..f43a1e8 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
@@ -260,7 +260,7 @@
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldA8TextGeoProc);
-const GrGeometryProcessor* GrDistanceFieldA8TextGeoProc::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrGeometryProcessor> GrDistanceFieldA8TextGeoProc::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
static const SkShader::TileMode kTileModes[] = {
@@ -281,14 +281,14 @@
flags |= d->fRandom->nextBool() ? kScaleOnly_DistanceFieldEffectFlag : 0;
}
- return GrDistanceFieldA8TextGeoProc::Create(GrRandomColor(d->fRandom),
- GrTest::TestMatrix(d->fRandom),
- d->fTextures[texIdx], params,
+ return GrDistanceFieldA8TextGeoProc::Make(GrRandomColor(d->fRandom),
+ GrTest::TestMatrix(d->fRandom),
+ d->fTextures[texIdx], params,
#ifdef SK_GAMMA_APPLY_TO_A8
- d->fRandom->nextF(),
+ d->fRandom->nextF(),
#endif
- flags,
- d->fRandom->nextBool());
+ flags,
+ d->fRandom->nextBool());
}
///////////////////////////////////////////////////////////////////////////////
@@ -497,7 +497,7 @@
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldPathGeoProc);
-const GrGeometryProcessor* GrDistanceFieldPathGeoProc::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrGeometryProcessor> GrDistanceFieldPathGeoProc::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: GrProcessorUnitTest::kAlphaTextureIdx;
static const SkShader::TileMode kTileModes[] = {
@@ -518,12 +518,12 @@
flags |= d->fRandom->nextBool() ? kScaleOnly_DistanceFieldEffectFlag : 0;
}
- return GrDistanceFieldPathGeoProc::Create(GrRandomColor(d->fRandom),
- GrTest::TestMatrix(d->fRandom),
- d->fTextures[texIdx],
- params,
- flags,
- d->fRandom->nextBool());
+ return GrDistanceFieldPathGeoProc::Make(GrRandomColor(d->fRandom),
+ GrTest::TestMatrix(d->fRandom),
+ d->fTextures[texIdx],
+ params,
+ flags,
+ d->fRandom->nextBool());
}
///////////////////////////////////////////////////////////////////////////////
@@ -794,7 +794,7 @@
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldLCDTextGeoProc);
-const GrGeometryProcessor* GrDistanceFieldLCDTextGeoProc::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrGeometryProcessor> GrDistanceFieldLCDTextGeoProc::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
static const SkShader::TileMode kTileModes[] = {
@@ -815,10 +815,10 @@
flags |= d->fRandom->nextBool() ? kScaleOnly_DistanceFieldEffectFlag : 0;
}
flags |= d->fRandom->nextBool() ? kBGR_DistanceFieldEffectFlag : 0;
- return GrDistanceFieldLCDTextGeoProc::Create(GrRandomColor(d->fRandom),
- GrTest::TestMatrix(d->fRandom),
- d->fTextures[texIdx], params,
- wa,
- flags,
- d->fRandom->nextBool());
+ return GrDistanceFieldLCDTextGeoProc::Make(GrRandomColor(d->fRandom),
+ GrTest::TestMatrix(d->fRandom),
+ d->fTextures[texIdx], params,
+ wa,
+ flags,
+ d->fRandom->nextBool());
}
diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.h b/src/gpu/effects/GrDistanceFieldGeoProc.h
index 406c352..0f6d8c1 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.h
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.h
@@ -49,18 +49,20 @@
class GrDistanceFieldA8TextGeoProc : public GrGeometryProcessor {
public:
#ifdef SK_GAMMA_APPLY_TO_A8
- static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix,
- GrTexture* tex, const GrTextureParams& params,
- float lum, uint32_t flags, bool usesLocalCoords) {
- return new GrDistanceFieldA8TextGeoProc(color, viewMatrix, tex, params, lum, flags,
- usesLocalCoords);
+ static sk_sp<GrGeometryProcessor> Make(GrColor color, const SkMatrix& viewMatrix,
+ GrTexture* tex, const GrTextureParams& params,
+ float lum, uint32_t flags, bool usesLocalCoords) {
+ return sk_sp<GrGeometryProcessor>(
+ new GrDistanceFieldA8TextGeoProc(color, viewMatrix, tex, params, lum, flags,
+ usesLocalCoords));
}
#else
- static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix,
- GrTexture* tex, const GrTextureParams& params,
- uint32_t flags, bool usesLocalCoords) {
- return new GrDistanceFieldA8TextGeoProc(color, viewMatrix, tex, params, flags,
- usesLocalCoords);
+ static sk_sp<GrGeometryProcessor> Make(GrColor color, const SkMatrix& viewMatrix,
+ GrTexture* tex, const GrTextureParams& params,
+ uint32_t flags, bool usesLocalCoords) {
+ return sk_sp<GrGeometryProcessor>(
+ new GrDistanceFieldA8TextGeoProc(color, viewMatrix, tex, params, flags,
+ usesLocalCoords));
}
#endif
@@ -118,11 +120,11 @@
*/
class GrDistanceFieldPathGeoProc : public GrGeometryProcessor {
public:
- static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix, GrTexture* tex,
- const GrTextureParams& params,
- uint32_t flags, bool usesLocalCoords) {
- return new GrDistanceFieldPathGeoProc(color, viewMatrix, tex, params, flags,
- usesLocalCoords);
+ static sk_sp<GrGeometryProcessor> Make(GrColor color, const SkMatrix& viewMatrix,
+ GrTexture* tex, const GrTextureParams& params,
+ uint32_t flags, bool usesLocalCoords) {
+ return sk_sp<GrGeometryProcessor>(
+ new GrDistanceFieldPathGeoProc(color, viewMatrix, tex, params, flags, usesLocalCoords));
}
virtual ~GrDistanceFieldPathGeoProc() {}
@@ -184,12 +186,13 @@
}
};
- static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix,
- GrTexture* tex, const GrTextureParams& params,
- DistanceAdjust distanceAdjust, uint32_t flags,
- bool usesLocalCoords) {
- return new GrDistanceFieldLCDTextGeoProc(color, viewMatrix, tex, params, distanceAdjust,
- flags, usesLocalCoords);
+ static sk_sp<GrGeometryProcessor> Make(GrColor color, const SkMatrix& viewMatrix,
+ GrTexture* tex, const GrTextureParams& params,
+ DistanceAdjust distanceAdjust, uint32_t flags,
+ bool usesLocalCoords) {
+ return sk_sp<GrGeometryProcessor>(
+ new GrDistanceFieldLCDTextGeoProc(color, viewMatrix, tex, params, distanceAdjust,
+ flags, usesLocalCoords));
}
virtual ~GrDistanceFieldLCDTextGeoProc() {}
diff --git a/src/gpu/effects/GrDitherEffect.cpp b/src/gpu/effects/GrDitherEffect.cpp
index 39d4063..abce5ca 100644
--- a/src/gpu/effects/GrDitherEffect.cpp
+++ b/src/gpu/effects/GrDitherEffect.cpp
@@ -16,8 +16,8 @@
class DitherEffect : public GrFragmentProcessor {
public:
- static GrFragmentProcessor* Create() {
- return new DitherEffect;
+ static sk_sp<GrFragmentProcessor> Make() {
+ return sk_sp<GrFragmentProcessor>(new DitherEffect);
}
virtual ~DitherEffect() {};
@@ -52,8 +52,8 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(DitherEffect);
-const GrFragmentProcessor* DitherEffect::TestCreate(GrProcessorTestData*) {
- return DitherEffect::Create();
+sk_sp<GrFragmentProcessor> DitherEffect::TestCreate(GrProcessorTestData*) {
+ return DitherEffect::Make();
}
//////////////////////////////////////////////////////////////////////////////
@@ -95,4 +95,4 @@
return new GLDitherEffect;
}
-GrFragmentProcessor* GrDitherEffect::Create() { return DitherEffect::Create(); }
+sk_sp<GrFragmentProcessor> GrDitherEffect::Make() { return DitherEffect::Make(); }
diff --git a/src/gpu/effects/GrDitherEffect.h b/src/gpu/effects/GrDitherEffect.h
index 64c85f7..b92723d 100644
--- a/src/gpu/effects/GrDitherEffect.h
+++ b/src/gpu/effects/GrDitherEffect.h
@@ -10,6 +10,7 @@
#include "GrTypes.h"
#include "GrTypesPriv.h"
+#include "SkRefCnt.h"
class GrFragmentProcessor;
@@ -17,7 +18,7 @@
/**
* Creates an effect that dithers the resulting color to an RGBA8 framebuffer
*/
- GrFragmentProcessor* Create();
+ sk_sp<GrFragmentProcessor> Make();
};
#endif
diff --git a/src/gpu/effects/GrGammaEffect.cpp b/src/gpu/effects/GrGammaEffect.cpp
index 71d8c91..63ffc32 100644
--- a/src/gpu/effects/GrGammaEffect.cpp
+++ b/src/gpu/effects/GrGammaEffect.cpp
@@ -116,11 +116,11 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrGammaEffect);
-const GrFragmentProcessor* GrGammaEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrGammaEffect::TestCreate(GrProcessorTestData* d) {
// We want to be sure and test sRGB sometimes
Mode testMode = static_cast<Mode>(d->fRandom->nextRangeU(0, 2));
SkScalar gamma = d->fRandom->nextRangeScalar(0.5f, 2.0f);
- return new GrGammaEffect(testMode, gamma);
+ return sk_sp<GrFragmentProcessor>(new GrGammaEffect(testMode, gamma));
}
///////////////////////////////////////////////////////////////////////////////
@@ -134,15 +134,15 @@
return new GrGLGammaEffect();
}
-const GrFragmentProcessor* GrGammaEffect::Create(SkScalar gamma) {
+sk_sp<GrFragmentProcessor> GrGammaEffect::Make(SkScalar gamma) {
// TODO: Once our public-facing API for specifying gamma curves settles down, expose this,
// and allow clients to explicitly request sRGB, rather than inferring from the exponent.
// Note that AdobeRGB (for example) is speficied as x^2.2, not the Rec.709 curves.
if (SkScalarNearlyEqual(gamma, 2.2f)) {
- return new GrGammaEffect(Mode::kSRGBToLinear, 2.2f);
+ return sk_sp<GrFragmentProcessor>(new GrGammaEffect(Mode::kSRGBToLinear, 2.2f));
} else if (SkScalarNearlyEqual(gamma, 1.0f / 2.2f)) {
- return new GrGammaEffect(Mode::kLinearToSRGB, 1.0f / 2.2f);
+ return sk_sp<GrFragmentProcessor>(new GrGammaEffect(Mode::kLinearToSRGB, 1.0f / 2.2f));
} else {
- return new GrGammaEffect(Mode::kExponential, gamma);
+ return sk_sp<GrFragmentProcessor>(new GrGammaEffect(Mode::kExponential, gamma));
}
}
diff --git a/src/gpu/effects/GrGammaEffect.h b/src/gpu/effects/GrGammaEffect.h
index 2e53b09..3f84ac9 100644
--- a/src/gpu/effects/GrGammaEffect.h
+++ b/src/gpu/effects/GrGammaEffect.h
@@ -21,7 +21,7 @@
/**
* Creates an effect that applies a gamma curve.
*/
- static const GrFragmentProcessor* Create(SkScalar gamma);
+ static sk_sp<GrFragmentProcessor> Make(SkScalar gamma);
const char* name() const override { return "Gamma"; }
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
index 60f518b..5422755 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
@@ -191,17 +191,17 @@
}
// Static function to create a 2D convolution
-GrFragmentProcessor*
-GrMatrixConvolutionEffect::CreateGaussian(GrTexture* texture,
- const SkIRect& bounds,
- const SkISize& kernelSize,
- SkScalar gain,
- SkScalar bias,
- const SkIPoint& kernelOffset,
- GrTextureDomain::Mode tileMode,
- bool convolveAlpha,
- SkScalar sigmaX,
- SkScalar sigmaY) {
+sk_sp<GrFragmentProcessor>
+GrMatrixConvolutionEffect::MakeGaussian(GrTexture* texture,
+ const SkIRect& bounds,
+ const SkISize& kernelSize,
+ SkScalar gain,
+ SkScalar bias,
+ const SkIPoint& kernelOffset,
+ GrTextureDomain::Mode tileMode,
+ bool convolveAlpha,
+ SkScalar sigmaX,
+ SkScalar sigmaY) {
float kernel[MAX_KERNEL_SIZE];
int width = kernelSize.width();
int height = kernelSize.height();
@@ -228,13 +228,14 @@
for (int i = 0; i < width * height; ++i) {
kernel[i] *= scale;
}
- return new GrMatrixConvolutionEffect(texture, bounds, kernelSize, kernel, gain, bias,
- kernelOffset, tileMode, convolveAlpha);
+ return sk_sp<GrFragmentProcessor>(
+ new GrMatrixConvolutionEffect(texture, bounds, kernelSize, kernel, gain, bias,
+ kernelOffset, tileMode, convolveAlpha));
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMatrixConvolutionEffect);
-const GrFragmentProcessor* GrMatrixConvolutionEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrMatrixConvolutionEffect::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
int width = d->fRandom->nextRangeU(1, MAX_KERNEL_SIZE);
@@ -255,13 +256,13 @@
GrTextureDomain::Mode tileMode =
static_cast<GrTextureDomain::Mode>(d->fRandom->nextRangeU(0, 2));
bool convolveAlpha = d->fRandom->nextBool();
- return GrMatrixConvolutionEffect::Create(d->fTextures[texIdx],
- bounds,
- kernelSize,
- kernel.get(),
- gain,
- bias,
- kernelOffset,
- tileMode,
- convolveAlpha);
+ return GrMatrixConvolutionEffect::Make(d->fTextures[texIdx],
+ bounds,
+ kernelSize,
+ kernel.get(),
+ gain,
+ bias,
+ kernelOffset,
+ tileMode,
+ convolveAlpha);
}
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.h b/src/gpu/effects/GrMatrixConvolutionEffect.h
index 066da65..b8df437 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.h
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.h
@@ -18,29 +18,30 @@
class GrMatrixConvolutionEffect : public GrSingleTextureEffect {
public:
- static GrFragmentProcessor* Create(GrTexture* texture,
- const SkIRect& bounds,
- const SkISize& kernelSize,
- const SkScalar* kernel,
- SkScalar gain,
- SkScalar bias,
- const SkIPoint& kernelOffset,
- GrTextureDomain::Mode tileMode,
- bool convolveAlpha) {
- return new GrMatrixConvolutionEffect(texture, bounds, kernelSize, kernel, gain, bias,
- kernelOffset, tileMode, convolveAlpha);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* texture,
+ const SkIRect& bounds,
+ const SkISize& kernelSize,
+ const SkScalar* kernel,
+ SkScalar gain,
+ SkScalar bias,
+ const SkIPoint& kernelOffset,
+ GrTextureDomain::Mode tileMode,
+ bool convolveAlpha) {
+ return sk_sp<GrFragmentProcessor>(
+ new GrMatrixConvolutionEffect(texture, bounds, kernelSize, kernel, gain, bias,
+ kernelOffset, tileMode, convolveAlpha));
}
- static GrFragmentProcessor* CreateGaussian(GrTexture* texture,
- const SkIRect& bounds,
- const SkISize& kernelSize,
- SkScalar gain,
- SkScalar bias,
- const SkIPoint& kernelOffset,
- GrTextureDomain::Mode tileMode,
- bool convolveAlpha,
- SkScalar sigmaX,
- SkScalar sigmaY);
+ static sk_sp<GrFragmentProcessor> MakeGaussian(GrTexture* texture,
+ const SkIRect& bounds,
+ const SkISize& kernelSize,
+ SkScalar gain,
+ SkScalar bias,
+ const SkIPoint& kernelOffset,
+ GrTextureDomain::Mode tileMode,
+ bool convolveAlpha,
+ SkScalar sigmaX,
+ SkScalar sigmaY);
const SkIRect& bounds() const { return fBounds; }
const SkISize& kernelSize() const { return fKernelSize; }
diff --git a/src/gpu/effects/GrOvalEffect.cpp b/src/gpu/effects/GrOvalEffect.cpp
index 3e6287b..a288537 100644
--- a/src/gpu/effects/GrOvalEffect.cpp
+++ b/src/gpu/effects/GrOvalEffect.cpp
@@ -19,7 +19,8 @@
class CircleEffect : public GrFragmentProcessor {
public:
- static GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkPoint& center, SkScalar radius);
+ static sk_sp<GrFragmentProcessor> Make(GrPrimitiveEdgeType, const SkPoint& center,
+ SkScalar radius);
virtual ~CircleEffect() {};
@@ -50,10 +51,10 @@
typedef GrFragmentProcessor INHERITED;
};
-GrFragmentProcessor* CircleEffect::Create(GrPrimitiveEdgeType edgeType, const SkPoint& center,
- SkScalar radius) {
+sk_sp<GrFragmentProcessor> CircleEffect::Make(GrPrimitiveEdgeType edgeType, const SkPoint& center,
+ SkScalar radius) {
SkASSERT(radius >= 0);
- return new CircleEffect(edgeType, center, radius);
+ return sk_sp<GrFragmentProcessor>(new CircleEffect(edgeType, center, radius));
}
void CircleEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
@@ -77,7 +78,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleEffect);
-const GrFragmentProcessor* CircleEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> CircleEffect::TestCreate(GrProcessorTestData* d) {
SkPoint center;
center.fX = d->fRandom->nextRangeScalar(0.f, 1000.f);
center.fY = d->fRandom->nextRangeScalar(0.f, 1000.f);
@@ -86,7 +87,7 @@
do {
et = (GrPrimitiveEdgeType)d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt);
} while (kHairlineAA_GrProcessorEdgeType == et);
- return CircleEffect::Create(et, center, radius);
+ return CircleEffect::Make(et, center, radius);
}
//////////////////////////////////////////////////////////////////////////////
@@ -183,8 +184,8 @@
class EllipseEffect : public GrFragmentProcessor {
public:
- static GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkPoint& center, SkScalar rx,
- SkScalar ry);
+ static sk_sp<GrFragmentProcessor> Make(GrPrimitiveEdgeType, const SkPoint& center,
+ SkScalar rx, SkScalar ry);
virtual ~EllipseEffect() {};
@@ -215,12 +216,12 @@
typedef GrFragmentProcessor INHERITED;
};
-GrFragmentProcessor* EllipseEffect::Create(GrPrimitiveEdgeType edgeType,
- const SkPoint& center,
- SkScalar rx,
- SkScalar ry) {
+sk_sp<GrFragmentProcessor> EllipseEffect::Make(GrPrimitiveEdgeType edgeType,
+ const SkPoint& center,
+ SkScalar rx,
+ SkScalar ry) {
SkASSERT(rx >= 0 && ry >= 0);
- return new EllipseEffect(edgeType, center, rx, ry);
+ return sk_sp<GrFragmentProcessor>(new EllipseEffect(edgeType, center, rx, ry));
}
void EllipseEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
@@ -244,7 +245,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(EllipseEffect);
-const GrFragmentProcessor* EllipseEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> EllipseEffect::TestCreate(GrProcessorTestData* d) {
SkPoint center;
center.fX = d->fRandom->nextRangeScalar(0.f, 1000.f);
center.fY = d->fRandom->nextRangeScalar(0.f, 1000.f);
@@ -254,7 +255,7 @@
do {
et = (GrPrimitiveEdgeType)d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt);
} while (kHairlineAA_GrProcessorEdgeType == et);
- return EllipseEffect::Create(et, center, rx, ry);
+ return EllipseEffect::Make(et, center, rx, ry);
}
//////////////////////////////////////////////////////////////////////////////
@@ -391,7 +392,7 @@
//////////////////////////////////////////////////////////////////////////////
-GrFragmentProcessor* GrOvalEffect::Create(GrPrimitiveEdgeType edgeType, const SkRect& oval) {
+sk_sp<GrFragmentProcessor> GrOvalEffect::Make(GrPrimitiveEdgeType edgeType, const SkRect& oval) {
if (kHairlineAA_GrProcessorEdgeType == edgeType) {
return nullptr;
}
@@ -399,11 +400,11 @@
SkScalar h = oval.height();
if (SkScalarNearlyEqual(w, h)) {
w /= 2;
- return CircleEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, oval.fTop + w), w);
+ return CircleEffect::Make(edgeType, SkPoint::Make(oval.fLeft + w, oval.fTop + w), w);
} else {
w /= 2;
h /= 2;
- return EllipseEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, oval.fTop + h), w, h);
+ return EllipseEffect::Make(edgeType, SkPoint::Make(oval.fLeft + w, oval.fTop + h), w, h);
}
return nullptr;
diff --git a/src/gpu/effects/GrOvalEffect.h b/src/gpu/effects/GrOvalEffect.h
index 8f85365..3ff241a 100644
--- a/src/gpu/effects/GrOvalEffect.h
+++ b/src/gpu/effects/GrOvalEffect.h
@@ -10,6 +10,7 @@
#include "GrTypes.h"
#include "GrTypesPriv.h"
+#include "SkRefCnt.h"
class GrFragmentProcessor;
struct SkRect;
@@ -18,7 +19,7 @@
/**
* Creates an effect that performs clipping against an oval.
*/
- GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkRect&);
+ sk_sp<GrFragmentProcessor> Make(GrPrimitiveEdgeType, const SkRect&);
};
#endif
diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.cpp b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
index 8168de6..9aae026 100644
--- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp
+++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
@@ -704,7 +704,7 @@
this->initClassID<GrPorterDuffXPFactory>();
}
-GrXPFactory* GrPorterDuffXPFactory::Create(SkXfermode::Mode xfermode) {
+sk_sp<GrXPFactory> GrPorterDuffXPFactory::Make(SkXfermode::Mode xfermode) {
static GrPorterDuffXPFactory gClearPDXPF(SkXfermode::kClear_Mode);
static GrPorterDuffXPFactory gSrcPDXPF(SkXfermode::kSrc_Mode);
static GrPorterDuffXPFactory gDstPDXPF(SkXfermode::kDst_Mode);
@@ -731,7 +731,7 @@
if (xfermode < 0 || xfermode > SkXfermode::kLastCoeffMode) {
return nullptr;
}
- return SkRef(gFactories[xfermode]);
+ return sk_sp<GrXPFactory>(SkRef(gFactories[xfermode]));
}
GrXferProcessor*
@@ -826,9 +826,9 @@
GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory);
-const GrXPFactory* GrPorterDuffXPFactory::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrXPFactory> GrPorterDuffXPFactory::TestCreate(GrProcessorTestData* d) {
SkXfermode::Mode mode = SkXfermode::Mode(d->fRandom->nextULessThan(SkXfermode::kLastCoeffMode));
- return GrPorterDuffXPFactory::Create(mode);
+ return GrPorterDuffXPFactory::Make(mode);
}
void GrPorterDuffXPFactory::TestGetXPOutputTypes(const GrXferProcessor* xp,
diff --git a/src/gpu/effects/GrRRectEffect.cpp b/src/gpu/effects/GrRRectEffect.cpp
index d1d811d..14d03dd 100644
--- a/src/gpu/effects/GrRRectEffect.cpp
+++ b/src/gpu/effects/GrRRectEffect.cpp
@@ -45,8 +45,8 @@
// The flags are used to indicate which corners are circluar (unflagged corners are assumed to
// be square).
- static GrFragmentProcessor* Create(GrPrimitiveEdgeType, uint32_t circularCornerFlags,
- const SkRRect&);
+ static sk_sp<GrFragmentProcessor> Make(GrPrimitiveEdgeType, uint32_t circularCornerFlags,
+ const SkRRect&);
virtual ~CircularRRectEffect() {};
@@ -78,13 +78,14 @@
typedef GrFragmentProcessor INHERITED;
};
-GrFragmentProcessor* CircularRRectEffect::Create(GrPrimitiveEdgeType edgeType,
- uint32_t circularCornerFlags,
- const SkRRect& rrect) {
+sk_sp<GrFragmentProcessor> CircularRRectEffect::Make(GrPrimitiveEdgeType edgeType,
+ uint32_t circularCornerFlags,
+ const SkRRect& rrect) {
if (kFillAA_GrProcessorEdgeType != edgeType && kInverseFillAA_GrProcessorEdgeType != edgeType) {
return nullptr;
}
- return new CircularRRectEffect(edgeType, circularCornerFlags, rrect);
+ return sk_sp<GrFragmentProcessor>(
+ new CircularRRectEffect(edgeType, circularCornerFlags, rrect));
}
void CircularRRectEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
@@ -110,17 +111,17 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircularRRectEffect);
-const GrFragmentProcessor* CircularRRectEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> CircularRRectEffect::TestCreate(GrProcessorTestData* d) {
SkScalar w = d->fRandom->nextRangeScalar(20.f, 1000.f);
SkScalar h = d->fRandom->nextRangeScalar(20.f, 1000.f);
SkScalar r = d->fRandom->nextRangeF(kRadiusMin, 9.f);
SkRRect rrect;
rrect.setRectXY(SkRect::MakeWH(w, h), r, r);
- GrFragmentProcessor* fp;
+ sk_sp<GrFragmentProcessor> fp;
do {
GrPrimitiveEdgeType et =
(GrPrimitiveEdgeType)d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt);
- fp = GrRRectEffect::Create(et, rrect);
+ fp = GrRRectEffect::Make(et, rrect);
} while (nullptr == fp);
return fp;
}
@@ -387,7 +388,7 @@
class EllipticalRRectEffect : public GrFragmentProcessor {
public:
- static GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkRRect&);
+ static sk_sp<GrFragmentProcessor> Make(GrPrimitiveEdgeType, const SkRRect&);
virtual ~EllipticalRRectEffect() {};
@@ -416,12 +417,12 @@
typedef GrFragmentProcessor INHERITED;
};
-GrFragmentProcessor*
-EllipticalRRectEffect::Create(GrPrimitiveEdgeType edgeType, const SkRRect& rrect) {
+sk_sp<GrFragmentProcessor>
+EllipticalRRectEffect::Make(GrPrimitiveEdgeType edgeType, const SkRRect& rrect) {
if (kFillAA_GrProcessorEdgeType != edgeType && kInverseFillAA_GrProcessorEdgeType != edgeType) {
return nullptr;
}
- return new EllipticalRRectEffect(edgeType, rrect);
+ return sk_sp<GrFragmentProcessor>(new EllipticalRRectEffect(edgeType, rrect));
}
void EllipticalRRectEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
@@ -444,7 +445,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(EllipticalRRectEffect);
-const GrFragmentProcessor* EllipticalRRectEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> EllipticalRRectEffect::TestCreate(GrProcessorTestData* d) {
SkScalar w = d->fRandom->nextRangeScalar(20.f, 1000.f);
SkScalar h = d->fRandom->nextRangeScalar(20.f, 1000.f);
SkVector r[4];
@@ -471,11 +472,11 @@
rrect.setRectXY(SkRect::MakeWH(w, h), r[SkRRect::kUpperLeft_Corner].fX,
r[SkRRect::kUpperLeft_Corner].fY);
}
- GrFragmentProcessor* fp;
+ sk_sp<GrFragmentProcessor> fp;
do {
GrPrimitiveEdgeType et =
(GrPrimitiveEdgeType)d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt);
- fp = GrRRectEffect::Create(et, rrect);
+ fp = GrRRectEffect::Make(et, rrect);
} while (nullptr == fp);
return fp;
}
@@ -680,26 +681,26 @@
//////////////////////////////////////////////////////////////////////////////
-GrFragmentProcessor* GrRRectEffect::Create(GrPrimitiveEdgeType edgeType, const SkRRect& rrect) {
+sk_sp<GrFragmentProcessor> GrRRectEffect::Make(GrPrimitiveEdgeType edgeType, const SkRRect& rrect) {
if (rrect.isRect()) {
- return GrConvexPolyEffect::Create(edgeType, rrect.getBounds());
+ return GrConvexPolyEffect::Make(edgeType, rrect.getBounds());
}
if (rrect.isOval()) {
- return GrOvalEffect::Create(edgeType, rrect.getBounds());
+ return GrOvalEffect::Make(edgeType, rrect.getBounds());
}
if (rrect.isSimple()) {
if (rrect.getSimpleRadii().fX < kRadiusMin || rrect.getSimpleRadii().fY < kRadiusMin) {
// In this case the corners are extremely close to rectangular and we collapse the
// clip to a rectangular clip.
- return GrConvexPolyEffect::Create(edgeType, rrect.getBounds());
+ return GrConvexPolyEffect::Make(edgeType, rrect.getBounds());
}
if (rrect.getSimpleRadii().fX == rrect.getSimpleRadii().fY) {
- return CircularRRectEffect::Create(edgeType, CircularRRectEffect::kAll_CornerFlags,
+ return CircularRRectEffect::Make(edgeType, CircularRRectEffect::kAll_CornerFlags,
rrect);
} else {
- return EllipticalRRectEffect::Create(edgeType, rrect);
+ return EllipticalRRectEffect::Make(edgeType, rrect);
}
}
@@ -755,10 +756,10 @@
if (squashedRadii) {
rr.writable()->setRectRadii(rrect.getBounds(), radii);
}
- return CircularRRectEffect::Create(edgeType, cornerFlags, *rr);
+ return CircularRRectEffect::Make(edgeType, cornerFlags, *rr);
}
case CircularRRectEffect::kNone_CornerFlags:
- return GrConvexPolyEffect::Create(edgeType, rrect.getBounds());
+ return GrConvexPolyEffect::Make(edgeType, rrect.getBounds());
default: {
if (squashedRadii) {
// If we got here then we squashed some but not all the radii to zero. (If all
@@ -767,7 +768,7 @@
return nullptr;
}
if (rrect.isNinePatch()) {
- return EllipticalRRectEffect::Create(edgeType, rrect);
+ return EllipticalRRectEffect::Make(edgeType, rrect);
}
return nullptr;
}
diff --git a/src/gpu/effects/GrRRectEffect.h b/src/gpu/effects/GrRRectEffect.h
index 63e08a4..6ff2cc9 100644
--- a/src/gpu/effects/GrRRectEffect.h
+++ b/src/gpu/effects/GrRRectEffect.h
@@ -10,6 +10,7 @@
#include "GrTypes.h"
#include "GrTypesPriv.h"
+#include "SkRefCnt.h"
class GrFragmentProcessor;
class GrProcessor;
@@ -20,7 +21,7 @@
* Creates an effect that performs anti-aliased clipping against a SkRRect. It doesn't support
* all varieties of SkRRect so the caller must check for a nullptr return.
*/
- GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkRRect&);
+ sk_sp<GrFragmentProcessor> Make(GrPrimitiveEdgeType, const SkRRect&);
};
#endif
diff --git a/src/gpu/effects/GrSimpleTextureEffect.cpp b/src/gpu/effects/GrSimpleTextureEffect.cpp
index f4cbd06..7e7b828 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.cpp
+++ b/src/gpu/effects/GrSimpleTextureEffect.cpp
@@ -46,7 +46,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSimpleTextureEffect);
-const GrFragmentProcessor* GrSimpleTextureEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrSimpleTextureEffect::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
static const SkShader::TileMode kTileModes[] = {
@@ -68,5 +68,5 @@
GrCoordSet coordSet = kCoordSets[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kCoordSets))];
const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom);
- return GrSimpleTextureEffect::Create(d->fTextures[texIdx], matrix, coordSet);
+ return GrSimpleTextureEffect::Make(d->fTextures[texIdx], matrix, coordSet);
}
diff --git a/src/gpu/effects/GrSimpleTextureEffect.h b/src/gpu/effects/GrSimpleTextureEffect.h
index 18a8a78..08eb8c1 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.h
+++ b/src/gpu/effects/GrSimpleTextureEffect.h
@@ -21,25 +21,27 @@
class GrSimpleTextureEffect : public GrSingleTextureEffect {
public:
/* unfiltered, clamp mode */
- static const GrFragmentProcessor* Create(GrTexture* tex,
- const SkMatrix& matrix,
- GrCoordSet coordSet = kLocal_GrCoordSet) {
- return new GrSimpleTextureEffect(tex, matrix, GrTextureParams::kNone_FilterMode, coordSet);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* tex,
+ const SkMatrix& matrix,
+ GrCoordSet coordSet = kLocal_GrCoordSet) {
+ return sk_sp<GrFragmentProcessor>(
+ new GrSimpleTextureEffect(tex, matrix, GrTextureParams::kNone_FilterMode, coordSet));
}
/* clamp mode */
- static GrFragmentProcessor* Create(GrTexture* tex,
- const SkMatrix& matrix,
- GrTextureParams::FilterMode filterMode,
- GrCoordSet coordSet = kLocal_GrCoordSet) {
- return new GrSimpleTextureEffect(tex, matrix, filterMode, coordSet);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* tex,
+ const SkMatrix& matrix,
+ GrTextureParams::FilterMode filterMode,
+ GrCoordSet coordSet = kLocal_GrCoordSet) {
+ return sk_sp<GrFragmentProcessor>(
+ new GrSimpleTextureEffect(tex, matrix, filterMode, coordSet));
}
- static GrFragmentProcessor* Create(GrTexture* tex,
- const SkMatrix& matrix,
- const GrTextureParams& p,
- GrCoordSet coordSet = kLocal_GrCoordSet) {
- return new GrSimpleTextureEffect(tex, matrix, p, coordSet);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* tex,
+ const SkMatrix& matrix,
+ const GrTextureParams& p,
+ GrCoordSet coordSet = kLocal_GrCoordSet) {
+ return sk_sp<GrFragmentProcessor>(new GrSimpleTextureEffect(tex, matrix, p, coordSet));
}
virtual ~GrSimpleTextureEffect() {}
diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp
index cf6ebe5..3fbf000 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -218,18 +218,19 @@
///////////////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* GrTextureDomainEffect::Create(GrTexture* texture,
- const SkMatrix& matrix,
- const SkRect& domain,
- GrTextureDomain::Mode mode,
- GrTextureParams::FilterMode filterMode,
- GrCoordSet coordSet) {
+sk_sp<GrFragmentProcessor> GrTextureDomainEffect::Make(GrTexture* texture,
+ const SkMatrix& matrix,
+ const SkRect& domain,
+ GrTextureDomain::Mode mode,
+ GrTextureParams::FilterMode filterMode,
+ GrCoordSet coordSet) {
static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1};
if (GrTextureDomain::kIgnore_Mode == mode ||
(GrTextureDomain::kClamp_Mode == mode && domain.contains(kFullRect))) {
- return GrSimpleTextureEffect::Create(texture, matrix, filterMode);
+ return GrSimpleTextureEffect::Make(texture, matrix, filterMode);
} else {
- return new GrTextureDomainEffect(texture, matrix, domain, mode, filterMode, coordSet);
+ return sk_sp<GrFragmentProcessor>(
+ new GrTextureDomainEffect(texture, matrix, domain, mode, filterMode, coordSet));
}
}
@@ -278,7 +279,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrTextureDomainEffect);
-const GrFragmentProcessor* GrTextureDomainEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrTextureDomainEffect::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
SkRect domain;
@@ -291,7 +292,7 @@
const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom);
bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool() : false;
GrCoordSet coords = d->fRandom->nextBool() ? kLocal_GrCoordSet : kDevice_GrCoordSet;
- return GrTextureDomainEffect::Create(
+ return GrTextureDomainEffect::Make(
d->fTextures[texIdx],
matrix,
domain,
diff --git a/src/gpu/effects/GrTextureDomain.h b/src/gpu/effects/GrTextureDomain.h
index 387016e..a86ce95 100644
--- a/src/gpu/effects/GrTextureDomain.h
+++ b/src/gpu/effects/GrTextureDomain.h
@@ -166,12 +166,12 @@
class GrTextureDomainEffect : public GrSingleTextureEffect {
public:
- static const GrFragmentProcessor* Create(GrTexture*,
- const SkMatrix&,
- const SkRect& domain,
- GrTextureDomain::Mode,
- GrTextureParams::FilterMode filterMode,
- GrCoordSet = kLocal_GrCoordSet);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture*,
+ const SkMatrix&,
+ const SkRect& domain,
+ GrTextureDomain::Mode,
+ GrTextureParams::FilterMode filterMode,
+ GrCoordSet = kLocal_GrCoordSet);
virtual ~GrTextureDomainEffect();
diff --git a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
index a881999..051061f 100644
--- a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
+++ b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
@@ -17,12 +17,12 @@
class ComposeTwoFragmentProcessor : public GrFragmentProcessor {
public:
- ComposeTwoFragmentProcessor(const GrFragmentProcessor* src, const GrFragmentProcessor* dst,
- SkXfermode::Mode mode)
+ ComposeTwoFragmentProcessor(sk_sp<GrFragmentProcessor> src, sk_sp<GrFragmentProcessor> dst,
+ SkXfermode::Mode mode)
: fMode(mode) {
this->initClassID<ComposeTwoFragmentProcessor>();
- SkDEBUGCODE(int shaderAChildIndex = )this->registerChildProcessor(src);
- SkDEBUGCODE(int shaderBChildIndex = )this->registerChildProcessor(dst);
+ SkDEBUGCODE(int shaderAChildIndex = )this->registerChildProcessor(std::move(src));
+ SkDEBUGCODE(int shaderBChildIndex = )this->registerChildProcessor(std::move(dst));
SkASSERT(0 == shaderAChildIndex);
SkASSERT(1 == shaderBChildIndex);
}
@@ -69,14 +69,15 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ComposeTwoFragmentProcessor);
-const GrFragmentProcessor* ComposeTwoFragmentProcessor::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> ComposeTwoFragmentProcessor::TestCreate(GrProcessorTestData* d) {
// Create two random frag procs.
- SkAutoTUnref<const GrFragmentProcessor> fpA(GrProcessorUnitTest::CreateChildFP(d));
- SkAutoTUnref<const GrFragmentProcessor> fpB(GrProcessorUnitTest::CreateChildFP(d));
+ sk_sp<GrFragmentProcessor> fpA(GrProcessorUnitTest::MakeChildFP(d));
+ sk_sp<GrFragmentProcessor> fpB(GrProcessorUnitTest::MakeChildFP(d));
SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(
d->fRandom->nextRangeU(0, SkXfermode::kLastMode));
- return new ComposeTwoFragmentProcessor(fpA, fpB, mode);
+ return sk_sp<GrFragmentProcessor>(
+ new ComposeTwoFragmentProcessor(std::move(fpA), std::move(fpB), mode));
}
GrGLSLFragmentProcessor* ComposeTwoFragmentProcessor::onCreateGLSLInstance() const{
@@ -118,18 +119,19 @@
}
}
-const GrFragmentProcessor* GrXfermodeFragmentProcessor::CreateFromTwoProcessors(
- const GrFragmentProcessor* src, const GrFragmentProcessor* dst, SkXfermode::Mode mode) {
+sk_sp<GrFragmentProcessor> GrXfermodeFragmentProcessor::MakeFromTwoProcessors(
+ sk_sp<GrFragmentProcessor> src, sk_sp<GrFragmentProcessor> dst, SkXfermode::Mode mode) {
switch (mode) {
case SkXfermode::kClear_Mode:
- return GrConstColorProcessor::Create(GrColor_TRANSPARENT_BLACK,
- GrConstColorProcessor::kIgnore_InputMode);
+ return GrConstColorProcessor::Make(GrColor_TRANSPARENT_BLACK,
+ GrConstColorProcessor::kIgnore_InputMode);
case SkXfermode::kSrc_Mode:
- return SkRef(src);
+ return src;
case SkXfermode::kDst_Mode:
- return SkRef(dst);
+ return dst;
default:
- return new ComposeTwoFragmentProcessor(src, dst, mode);
+ return sk_sp<GrFragmentProcessor>(
+ new ComposeTwoFragmentProcessor(std::move(src), std::move(dst), mode));
}
}
@@ -142,11 +144,11 @@
kSrc_Child,
};
- ComposeOneFragmentProcessor(const GrFragmentProcessor* dst, SkXfermode::Mode mode, Child child)
+ ComposeOneFragmentProcessor(sk_sp<GrFragmentProcessor> dst, SkXfermode::Mode mode, Child child)
: fMode(mode)
, fChild(child) {
this->initClassID<ComposeOneFragmentProcessor>();
- SkDEBUGCODE(int dstIndex = )this->registerChildProcessor(dst);
+ SkDEBUGCODE(int dstIndex = )this->registerChildProcessor(std::move(dst));
SkASSERT(0 == dstIndex);
}
@@ -260,17 +262,17 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ComposeOneFragmentProcessor);
-const GrFragmentProcessor* ComposeOneFragmentProcessor::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> ComposeOneFragmentProcessor::TestCreate(GrProcessorTestData* d) {
// Create one random frag procs.
// For now, we'll prevent either children from being a shader with children to prevent the
// possibility of an arbitrarily large tree of procs.
- SkAutoTUnref<const GrFragmentProcessor> dst(GrProcessorUnitTest::CreateChildFP(d));
+ sk_sp<GrFragmentProcessor> dst(GrProcessorUnitTest::MakeChildFP(d));
SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(
d->fRandom->nextRangeU(0, SkXfermode::kLastMode));
ComposeOneFragmentProcessor::Child child = d->fRandom->nextBool() ?
ComposeOneFragmentProcessor::kDst_Child :
ComposeOneFragmentProcessor::kSrc_Child;
- return new ComposeOneFragmentProcessor(dst, mode, child);
+ return sk_sp<GrFragmentProcessor>(new ComposeOneFragmentProcessor(std::move(dst), mode, child));
}
GrGLSLFragmentProcessor* ComposeOneFragmentProcessor::onCreateGLSLInstance() const {
@@ -279,30 +281,32 @@
//////////////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* GrXfermodeFragmentProcessor::CreateFromDstProcessor(
- const GrFragmentProcessor* dst, SkXfermode::Mode mode) {
+sk_sp<GrFragmentProcessor> GrXfermodeFragmentProcessor::MakeFromDstProcessor(
+ sk_sp<GrFragmentProcessor> dst, SkXfermode::Mode mode) {
switch (mode) {
case SkXfermode::kClear_Mode:
- return GrConstColorProcessor::Create(GrColor_TRANSPARENT_BLACK,
+ return GrConstColorProcessor::Make(GrColor_TRANSPARENT_BLACK,
GrConstColorProcessor::kIgnore_InputMode);
case SkXfermode::kSrc_Mode:
return nullptr;
default:
- return new ComposeOneFragmentProcessor(dst, mode,
- ComposeOneFragmentProcessor::kDst_Child);
+ return sk_sp<GrFragmentProcessor>(
+ new ComposeOneFragmentProcessor(std::move(dst), mode,
+ ComposeOneFragmentProcessor::kDst_Child));
}
}
-const GrFragmentProcessor* GrXfermodeFragmentProcessor::CreateFromSrcProcessor(
- const GrFragmentProcessor* src, SkXfermode::Mode mode) {
+sk_sp<GrFragmentProcessor> GrXfermodeFragmentProcessor::MakeFromSrcProcessor(
+ sk_sp<GrFragmentProcessor> src, SkXfermode::Mode mode) {
switch (mode) {
case SkXfermode::kClear_Mode:
- return GrConstColorProcessor::Create(GrColor_TRANSPARENT_BLACK,
+ return GrConstColorProcessor::Make(GrColor_TRANSPARENT_BLACK,
GrConstColorProcessor::kIgnore_InputMode);
case SkXfermode::kDst_Mode:
return nullptr;
default:
- return new ComposeOneFragmentProcessor(src, mode,
- ComposeOneFragmentProcessor::kSrc_Child);
+ return sk_sp<GrFragmentProcessor>(
+ new ComposeOneFragmentProcessor(src, mode,
+ ComposeOneFragmentProcessor::kSrc_Child));
}
}
diff --git a/src/gpu/effects/GrYUVEffect.cpp b/src/gpu/effects/GrYUVEffect.cpp
index 97ef663..94dca84 100644
--- a/src/gpu/effects/GrYUVEffect.cpp
+++ b/src/gpu/effects/GrYUVEffect.cpp
@@ -62,9 +62,9 @@
class YUVtoRGBEffect : public GrFragmentProcessor {
public:
- static GrFragmentProcessor* Create(GrTexture* yTexture, GrTexture* uTexture,
- GrTexture* vTexture, const SkISize sizes[3],
- SkYUVColorSpace colorSpace) {
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* yTexture, GrTexture* uTexture,
+ GrTexture* vTexture, const SkISize sizes[3],
+ SkYUVColorSpace colorSpace) {
SkScalar w[3], h[3];
w[0] = SkIntToScalar(sizes[0].fWidth) / SkIntToScalar(yTexture->width());
h[0] = SkIntToScalar(sizes[0].fHeight) / SkIntToScalar(yTexture->height());
@@ -85,8 +85,8 @@
(sizes[2].fHeight != sizes[0].fHeight)) ?
GrTextureParams::kBilerp_FilterMode :
GrTextureParams::kNone_FilterMode;
- return new YUVtoRGBEffect(yTexture, uTexture, vTexture, yuvMatrix, uvFilterMode,
- colorSpace);
+ return sk_sp<GrFragmentProcessor>(
+ new YUVtoRGBEffect(yTexture, uTexture, vTexture, yuvMatrix, uvFilterMode, colorSpace));
}
const char* name() const override { return "YUV to RGB"; }
@@ -206,12 +206,12 @@
kV_OutputChannels
};
- RGBToYUVEffect(const GrFragmentProcessor* rgbFP, SkYUVColorSpace colorSpace,
+ RGBToYUVEffect(sk_sp<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace,
OutputChannels output)
: fColorSpace(colorSpace)
, fOutputChannels(output) {
this->initClassID<RGBToYUVEffect>();
- this->registerChildProcessor(rgbFP);
+ this->registerChildProcessor(std::move(rgbFP));
}
const char* name() const override { return "RGBToYUV"; }
@@ -350,39 +350,44 @@
//////////////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor*
-GrYUVEffect::CreateYUVToRGB(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture,
+sk_sp<GrFragmentProcessor>
+GrYUVEffect::MakeYUVToRGB(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture,
const SkISize sizes[3], SkYUVColorSpace colorSpace) {
SkASSERT(yTexture && uTexture && vTexture && sizes);
- return YUVtoRGBEffect::Create(yTexture, uTexture, vTexture, sizes, colorSpace);
+ return YUVtoRGBEffect::Make(yTexture, uTexture, vTexture, sizes, colorSpace);
}
-const GrFragmentProcessor*
-GrYUVEffect::CreateRGBToYUV(const GrFragmentProcessor* rgbFP, SkYUVColorSpace colorSpace) {
+sk_sp<GrFragmentProcessor>
+GrYUVEffect::MakeRGBToYUV(sk_sp<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace) {
SkASSERT(rgbFP);
- return new RGBToYUVEffect(rgbFP, colorSpace, RGBToYUVEffect::kYUV_OutputChannels);
+ return sk_sp<GrFragmentProcessor>(
+ new RGBToYUVEffect(std::move(rgbFP), colorSpace, RGBToYUVEffect::kYUV_OutputChannels));
}
-const GrFragmentProcessor*
-GrYUVEffect::CreateRGBToY(const GrFragmentProcessor* rgbFP, SkYUVColorSpace colorSpace) {
+sk_sp<GrFragmentProcessor>
+GrYUVEffect::MakeRGBToY(sk_sp<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace) {
SkASSERT(rgbFP);
- return new RGBToYUVEffect(rgbFP, colorSpace, RGBToYUVEffect::kY_OutputChannels);
+ return sk_sp<GrFragmentProcessor>(
+ new RGBToYUVEffect(std::move(rgbFP), colorSpace, RGBToYUVEffect::kY_OutputChannels));
}
-const GrFragmentProcessor*
-GrYUVEffect::CreateRGBToUV(const GrFragmentProcessor* rgbFP, SkYUVColorSpace colorSpace) {
+sk_sp<GrFragmentProcessor>
+GrYUVEffect::MakeRGBToUV(sk_sp<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace) {
SkASSERT(rgbFP);
- return new RGBToYUVEffect(rgbFP, colorSpace, RGBToYUVEffect::kUV_OutputChannels);
+ return sk_sp<GrFragmentProcessor>(
+ new RGBToYUVEffect(std::move(rgbFP), colorSpace, RGBToYUVEffect::kUV_OutputChannels));
}
-const GrFragmentProcessor*
-GrYUVEffect::CreateRGBToU(const GrFragmentProcessor* rgbFP, SkYUVColorSpace colorSpace) {
+sk_sp<GrFragmentProcessor>
+GrYUVEffect::MakeRGBToU(sk_sp<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace) {
SkASSERT(rgbFP);
- return new RGBToYUVEffect(rgbFP, colorSpace, RGBToYUVEffect::kU_OutputChannels);
+ return sk_sp<GrFragmentProcessor>(
+ new RGBToYUVEffect(std::move(rgbFP), colorSpace, RGBToYUVEffect::kU_OutputChannels));
}
-const GrFragmentProcessor*
-GrYUVEffect::CreateRGBToV(const GrFragmentProcessor* rgbFP, SkYUVColorSpace colorSpace) {
+sk_sp<GrFragmentProcessor>
+GrYUVEffect::MakeRGBToV(sk_sp<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace) {
SkASSERT(rgbFP);
- return new RGBToYUVEffect(rgbFP, colorSpace, RGBToYUVEffect::kV_OutputChannels);
+ return sk_sp<GrFragmentProcessor>(
+ new RGBToYUVEffect(std::move(rgbFP), colorSpace, RGBToYUVEffect::kV_OutputChannels));
}
diff --git a/src/gpu/effects/GrYUVEffect.h b/src/gpu/effects/GrYUVEffect.h
index 4f3848e..6d3b158 100644
--- a/src/gpu/effects/GrYUVEffect.h
+++ b/src/gpu/effects/GrYUVEffect.h
@@ -18,33 +18,33 @@
* Creates an effect that performs color conversion from YUV to RGB. The input textures are
* assumed to be kA8_GrPixelConfig.
*/
- const GrFragmentProcessor* CreateYUVToRGB(GrTexture* yTexture, GrTexture* uTexture,
- GrTexture* vTexture, const SkISize sizes[3],
- SkYUVColorSpace colorSpace);
+ sk_sp<GrFragmentProcessor> MakeYUVToRGB(GrTexture* yTexture, GrTexture* uTexture,
+ GrTexture* vTexture, const SkISize sizes[3],
+ SkYUVColorSpace colorSpace);
/**
* Creates a processor that performs color conversion from the passed in processor's RGB
* channels to Y, U ,and V channels. The output color is (y, u, v, a) where a is the passed in
* processor's alpha output.
*/
- const GrFragmentProcessor* CreateRGBToYUV(const GrFragmentProcessor*,
- SkYUVColorSpace colorSpace);
+ sk_sp<GrFragmentProcessor> MakeRGBToYUV(sk_sp<GrFragmentProcessor>,
+ SkYUVColorSpace colorSpace);
/**
* Creates a processor that performs color conversion from the passed in processor's RGB
* channels to U and V channels. The output color is (u, v, 0, a) where a is the passed in
* processor's alpha output.
*/
- const GrFragmentProcessor* CreateRGBToUV(const GrFragmentProcessor*,
- SkYUVColorSpace colorSpace);
+ sk_sp<GrFragmentProcessor> MakeRGBToUV(sk_sp<GrFragmentProcessor>,
+ SkYUVColorSpace colorSpace);
/**
* Creates a processor that performs color conversion from the passed in fragment processors's
* RGB channels to Y, U, or V (replicated across all four output color channels). The alpha
* output of the passed in fragment processor is ignored.
*/
- const GrFragmentProcessor* CreateRGBToY(const GrFragmentProcessor*, SkYUVColorSpace colorSpace);
- const GrFragmentProcessor* CreateRGBToU(const GrFragmentProcessor*, SkYUVColorSpace colorSpace);
- const GrFragmentProcessor* CreateRGBToV(const GrFragmentProcessor*, SkYUVColorSpace colorSpace);
+ sk_sp<GrFragmentProcessor> MakeRGBToY(sk_sp<GrFragmentProcessor>, SkYUVColorSpace colorSpace);
+ sk_sp<GrFragmentProcessor> MakeRGBToU(sk_sp<GrFragmentProcessor>, SkYUVColorSpace colorSpace);
+ sk_sp<GrFragmentProcessor> MakeRGBToV(sk_sp<GrFragmentProcessor>, SkYUVColorSpace colorSpace);
};
#endif
diff --git a/src/image/SkImageShader.cpp b/src/image/SkImageShader.cpp
index b2fab39..33edfde 100644
--- a/src/image/SkImageShader.cpp
+++ b/src/image/SkImageShader.cpp
@@ -83,7 +83,7 @@
#include "effects/GrBicubicEffect.h"
#include "effects/GrSimpleTextureEffect.h"
-const GrFragmentProcessor* SkImageShader::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkImageShader::asFragmentProcessor(
GrContext* context,
const SkMatrix& viewM,
const SkMatrix* localMatrix,
@@ -120,17 +120,17 @@
return nullptr;
}
- SkAutoTUnref<const GrFragmentProcessor> inner;
+ sk_sp<GrFragmentProcessor> inner;
if (doBicubic) {
- inner.reset(GrBicubicEffect::Create(texture, matrix, tm));
+ inner = GrBicubicEffect::Make(texture, matrix, tm);
} else {
- inner.reset(GrSimpleTextureEffect::Create(texture, matrix, params));
+ inner = GrSimpleTextureEffect::Make(texture, matrix, params);
}
if (GrPixelConfigIsAlphaOnly(texture->config())) {
- return SkRef(inner.get());
+ return inner;
}
- return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+ return sk_sp<GrFragmentProcessor>(GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner)));
}
#endif
diff --git a/src/image/SkImageShader.h b/src/image/SkImageShader.h
index 58b22dd..c0d9589 100644
--- a/src/image/SkImageShader.h
+++ b/src/image/SkImageShader.h
@@ -22,7 +22,7 @@
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkImageShader)
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& viewM,
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*, const SkMatrix& viewM,
const SkMatrix*, SkFilterQuality,
SkSourceGammaTreatment) const override;
#endif
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 0c4769f..cc92d4e 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -266,8 +266,8 @@
GrPaint paint;
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
- paint.addColorFragmentProcessor(GrYUVEffect::CreateYUVToRGB(yTex, uTex, vTex, yuvSizes,
- colorSpace))->unref();
+ paint.addColorFragmentProcessor(GrYUVEffect::MakeYUVToRGB(yTex, uTex, vTex, yuvSizes,
+ colorSpace));
const SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));