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
This commit is contained in:
parent
897a8e3887
commit
06ca8ec87c
@ -630,13 +630,14 @@ private:
|
||||
|
||||
class GrPerlinNoise2Effect : public GrFragmentProcessor {
|
||||
public:
|
||||
static GrFragmentProcessor* Create(SkPerlinNoiseShader2::Type type,
|
||||
int numOctaves, bool stitchTiles,
|
||||
SkPerlinNoiseShader2::PaintingData* paintingData,
|
||||
GrTexture* permutationsTexture, GrTexture* noiseTexture,
|
||||
const SkMatrix& matrix) {
|
||||
return new GrPerlinNoise2Effect(type, numOctaves, stitchTiles, paintingData,
|
||||
permutationsTexture, noiseTexture, matrix);
|
||||
static sk_sp<GrFragmentProcessor> Make(SkPerlinNoiseShader2::Type type,
|
||||
int numOctaves, bool stitchTiles,
|
||||
SkPerlinNoiseShader2::PaintingData* paintingData,
|
||||
GrTexture* permutationsTexture, GrTexture* noiseTexture,
|
||||
const SkMatrix& matrix) {
|
||||
return sk_sp<GrFragmentProcessor>(
|
||||
new GrPerlinNoise2Effect(type, numOctaves, stitchTiles, paintingData,
|
||||
permutationsTexture, noiseTexture, matrix));
|
||||
}
|
||||
|
||||
virtual ~GrPerlinNoise2Effect() { delete fPaintingData; }
|
||||
@ -709,7 +710,7 @@ private:
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrPerlinNoise2Effect);
|
||||
|
||||
const GrFragmentProcessor* GrPerlinNoise2Effect::TestCreate(GrProcessorTestData* d) {
|
||||
sk_sp<GrFragmentProcessor> GrPerlinNoise2Effect::TestCreate(GrProcessorTestData* d) {
|
||||
int numOctaves = d->fRandom->nextRangeU(2, 10);
|
||||
bool stitchTiles = d->fRandom->nextBool();
|
||||
SkScalar seed = SkIntToScalar(d->fRandom->nextU());
|
||||
@ -1050,12 +1051,14 @@ private:
|
||||
|
||||
class GrImprovedPerlinNoiseEffect : public GrFragmentProcessor {
|
||||
public:
|
||||
static GrFragmentProcessor* Create(int octaves, SkScalar z,
|
||||
SkPerlinNoiseShader2::PaintingData* paintingData,
|
||||
GrTexture* permutationsTexture, GrTexture* gradientTexture,
|
||||
const SkMatrix& matrix) {
|
||||
return new GrImprovedPerlinNoiseEffect(octaves, z, paintingData, permutationsTexture,
|
||||
gradientTexture, matrix);
|
||||
static sk_sp<GrFragmentProcessor> Make(int octaves, SkScalar z,
|
||||
SkPerlinNoiseShader2::PaintingData* paintingData,
|
||||
GrTexture* permutationsTexture,
|
||||
GrTexture* gradientTexture,
|
||||
const SkMatrix& matrix) {
|
||||
return sk_sp<GrFragmentProcessor>(
|
||||
new GrImprovedPerlinNoiseEffect(octaves, z, paintingData, permutationsTexture,
|
||||
gradientTexture, matrix));
|
||||
}
|
||||
|
||||
virtual ~GrImprovedPerlinNoiseEffect() { delete fPaintingData; }
|
||||
@ -1118,7 +1121,7 @@ private:
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrImprovedPerlinNoiseEffect);
|
||||
|
||||
const GrFragmentProcessor* GrImprovedPerlinNoiseEffect::TestCreate(GrProcessorTestData* d) {
|
||||
sk_sp<GrFragmentProcessor> GrImprovedPerlinNoiseEffect::TestCreate(GrProcessorTestData* d) {
|
||||
SkScalar baseFrequencyX = d->fRandom->nextRangeScalar(0.01f,
|
||||
0.99f);
|
||||
SkScalar baseFrequencyY = d->fRandom->nextRangeScalar(0.01f,
|
||||
@ -1298,7 +1301,7 @@ void GrGLImprovedPerlinNoise::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
const GrFragmentProcessor* SkPerlinNoiseShader2::asFragmentProcessor(
|
||||
sk_sp<GrFragmentProcessor> SkPerlinNoiseShader2::asFragmentProcessor(
|
||||
GrContext* context,
|
||||
const SkMatrix& viewM,
|
||||
const SkMatrix* externalLocalMatrix,
|
||||
@ -1333,20 +1336,20 @@ const GrFragmentProcessor* SkPerlinNoiseShader2::asFragmentProcessor(
|
||||
SkAutoTUnref<GrTexture> gradientTexture(
|
||||
GrRefCachedBitmapTexture(context, paintingData->getGradientBitmap(),
|
||||
textureParams, gammaTreatment));
|
||||
return GrImprovedPerlinNoiseEffect::Create(fNumOctaves, fSeed, paintingData,
|
||||
return GrImprovedPerlinNoiseEffect::Make(fNumOctaves, fSeed, paintingData,
|
||||
permutationsTexture, gradientTexture, m);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
SkAutoTUnref<GrTexture> permutationsTexture(
|
||||
@ -1357,14 +1360,14 @@ const GrFragmentProcessor* SkPerlinNoiseShader2::asFragmentProcessor(
|
||||
GrTextureParams::ClampNoFilter(), gammaTreatment));
|
||||
|
||||
if ((permutationsTexture) && (noiseTexture)) {
|
||||
SkAutoTUnref<GrFragmentProcessor> inner(
|
||||
GrPerlinNoise2Effect::Create(fType,
|
||||
fNumOctaves,
|
||||
fStitchTiles,
|
||||
paintingData,
|
||||
permutationsTexture, noiseTexture,
|
||||
m));
|
||||
return GrFragmentProcessor::MulOutputByInputAlpha(inner);
|
||||
sk_sp<GrFragmentProcessor> inner(
|
||||
GrPerlinNoise2Effect::Make(fType,
|
||||
fNumOctaves,
|
||||
fStitchTiles,
|
||||
paintingData,
|
||||
permutationsTexture, noiseTexture,
|
||||
m));
|
||||
return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
|
||||
}
|
||||
delete paintingData;
|
||||
return nullptr;
|
||||
|
@ -106,7 +106,7 @@ public:
|
||||
};
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
const GrFragmentProcessor* asFragmentProcessor(GrContext* context, const SkMatrix& viewM,
|
||||
sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext* context, const SkMatrix& viewM,
|
||||
const SkMatrix*, SkFilterQuality,
|
||||
SkSourceGammaTreatment) const override;
|
||||
#endif
|
||||
|
@ -34,10 +34,10 @@ public:
|
||||
|
||||
const char* name() const override { return "BezierCubicOrConicTestBatch"; }
|
||||
|
||||
BezierCubicOrConicTestBatch(const GrGeometryProcessor* gp, const SkRect& bounds,
|
||||
BezierCubicOrConicTestBatch(sk_sp<GrGeometryProcessor> gp, const SkRect& bounds,
|
||||
GrColor color, const SkScalar klmEqs[9], SkScalar sign)
|
||||
: INHERITED(ClassID(), bounds, color)
|
||||
, fGeometryProcessor(SkRef(gp)) {
|
||||
, fGeometryProcessor(std::move(gp)) {
|
||||
for (int i = 0; i < 9; i++) {
|
||||
fKlmEqs[i] = klmEqs[i];
|
||||
}
|
||||
@ -67,12 +67,12 @@ private:
|
||||
verts[v].fKLM[1] = eval_line(verts[v].fPosition, fKlmEqs + 3, fSign);
|
||||
verts[v].fKLM[2] = eval_line(verts[v].fPosition, fKlmEqs + 6, 1.f);
|
||||
}
|
||||
helper.recordDraw(target, fGeometryProcessor);
|
||||
helper.recordDraw(target, fGeometryProcessor.get());
|
||||
}
|
||||
|
||||
SkScalar fKlmEqs[9];
|
||||
SkScalar fSign;
|
||||
SkAutoTUnref<const GrGeometryProcessor> fGeometryProcessor;
|
||||
SkScalar fKlmEqs[9];
|
||||
SkScalar fSign;
|
||||
sk_sp<GrGeometryProcessor> fGeometryProcessor;
|
||||
|
||||
static const int kVertsPerCubic = 4;
|
||||
static const int kIndicesPerCubic = 6;
|
||||
@ -135,10 +135,9 @@ protected:
|
||||
{rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}
|
||||
};
|
||||
for(int edgeType = 0; edgeType < kGrProcessorEdgeTypeCnt; ++edgeType) {
|
||||
SkAutoTUnref<GrGeometryProcessor> gp;
|
||||
sk_sp<GrGeometryProcessor> gp;
|
||||
GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)edgeType;
|
||||
gp.reset(GrCubicEffect::Create(color, SkMatrix::I(), et,
|
||||
*context->caps()));
|
||||
gp = GrCubicEffect::Make(color, SkMatrix::I(), et, *context->caps());
|
||||
if (!gp) {
|
||||
continue;
|
||||
}
|
||||
@ -191,7 +190,7 @@ protected:
|
||||
|
||||
GrPipelineBuilder pipelineBuilder;
|
||||
pipelineBuilder.setXPFactory(
|
||||
GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
|
||||
GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
|
||||
|
||||
SkAutoTUnref<GrDrawBatch> batch(
|
||||
new BezierCubicOrConicTestBatch(gp, bounds, color, klmEqs, klmSigns[c]));
|
||||
@ -269,10 +268,10 @@ protected:
|
||||
};
|
||||
SkScalar weight = rand.nextRangeF(0.f, 2.f);
|
||||
for(int edgeType = 0; edgeType < kGrProcessorEdgeTypeCnt; ++edgeType) {
|
||||
SkAutoTUnref<GrGeometryProcessor> gp;
|
||||
sk_sp<GrGeometryProcessor> gp;
|
||||
GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)edgeType;
|
||||
gp.reset(GrConicEffect::Create(color, SkMatrix::I(), et,
|
||||
*context->caps(), SkMatrix::I(), false));
|
||||
gp = GrConicEffect::Make(color, SkMatrix::I(), et,
|
||||
*context->caps(), SkMatrix::I(), false);
|
||||
if (!gp) {
|
||||
continue;
|
||||
}
|
||||
@ -323,7 +322,7 @@ protected:
|
||||
|
||||
GrPipelineBuilder pipelineBuilder;
|
||||
pipelineBuilder.setXPFactory(
|
||||
GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
|
||||
GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
|
||||
|
||||
SkAutoTUnref<GrDrawBatch> batch(
|
||||
new BezierCubicOrConicTestBatch(gp, bounds, color, klmEqs, 1.f));
|
||||
@ -387,11 +386,11 @@ public:
|
||||
DEFINE_BATCH_CLASS_ID
|
||||
const char* name() const override { return "BezierQuadTestBatch"; }
|
||||
|
||||
BezierQuadTestBatch(const GrGeometryProcessor* gp, const SkRect& bounds, GrColor color,
|
||||
BezierQuadTestBatch(sk_sp<GrGeometryProcessor> gp, const SkRect& bounds, GrColor color,
|
||||
const GrPathUtils::QuadUVMatrix& devToUV)
|
||||
: INHERITED(ClassID(), bounds, color)
|
||||
, fDevToUV(devToUV)
|
||||
, fGeometryProcessor(SkRef(gp)) {
|
||||
, fGeometryProcessor(std::move(gp)) {
|
||||
}
|
||||
|
||||
private:
|
||||
@ -413,11 +412,11 @@ private:
|
||||
verts[0].fPosition.setRectFan(bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom,
|
||||
sizeof(Vertex));
|
||||
fDevToUV.apply<4, sizeof(Vertex), sizeof(SkPoint)>(verts);
|
||||
helper.recordDraw(target, fGeometryProcessor);
|
||||
helper.recordDraw(target, fGeometryProcessor.get());
|
||||
}
|
||||
|
||||
GrPathUtils::QuadUVMatrix fDevToUV;
|
||||
SkAutoTUnref<const GrGeometryProcessor> fGeometryProcessor;
|
||||
GrPathUtils::QuadUVMatrix fDevToUV;
|
||||
sk_sp<GrGeometryProcessor> fGeometryProcessor;
|
||||
|
||||
static const int kVertsPerCubic = 4;
|
||||
static const int kIndicesPerCubic = 6;
|
||||
@ -479,10 +478,10 @@ protected:
|
||||
{rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}
|
||||
};
|
||||
for(int edgeType = 0; edgeType < kGrProcessorEdgeTypeCnt; ++edgeType) {
|
||||
SkAutoTUnref<GrGeometryProcessor> gp;
|
||||
sk_sp<GrGeometryProcessor> gp;
|
||||
GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)edgeType;
|
||||
gp.reset(GrQuadEffect::Create(color, SkMatrix::I(), et,
|
||||
*context->caps(), SkMatrix::I(), false));
|
||||
gp = GrQuadEffect::Make(color, SkMatrix::I(), et,
|
||||
*context->caps(), SkMatrix::I(), false);
|
||||
if (!gp) {
|
||||
continue;
|
||||
}
|
||||
@ -530,7 +529,7 @@ protected:
|
||||
|
||||
GrPipelineBuilder pipelineBuilder;
|
||||
pipelineBuilder.setXPFactory(
|
||||
GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
|
||||
GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
|
||||
|
||||
GrPathUtils::QuadUVMatrix DevToUV(pts);
|
||||
|
||||
|
@ -75,15 +75,14 @@ protected:
|
||||
canvas->drawRect(testBounds, paint);
|
||||
|
||||
GrPipelineBuilder pipelineBuilder;
|
||||
pipelineBuilder.setXPFactory(
|
||||
GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
|
||||
pipelineBuilder.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
|
||||
|
||||
SkRRect rrect = fRRect;
|
||||
rrect.offset(SkIntToScalar(x + kGap), SkIntToScalar(y + kGap));
|
||||
SkAutoTUnref<GrFragmentProcessor> fp(GrRRectEffect::Create(edgeType, rrect));
|
||||
sk_sp<GrFragmentProcessor> fp(GrRRectEffect::Make(edgeType, rrect));
|
||||
SkASSERT(fp);
|
||||
if (fp) {
|
||||
pipelineBuilder.addCoverageFragmentProcessor(fp);
|
||||
pipelineBuilder.addCoverageFragmentProcessor(std::move(fp));
|
||||
|
||||
SkRect bounds = testBounds;
|
||||
bounds.offset(SkIntToScalar(x), SkIntToScalar(y));
|
||||
|
@ -105,10 +105,10 @@ protected:
|
||||
|
||||
GrConstColorProcessor::InputMode mode = (GrConstColorProcessor::InputMode) m;
|
||||
GrColor color = kColors[procColor];
|
||||
SkAutoTUnref<GrFragmentProcessor> fp(GrConstColorProcessor::Create(color, mode));
|
||||
sk_sp<GrFragmentProcessor> fp(GrConstColorProcessor::Make(color, mode));
|
||||
|
||||
GrPipelineBuilder pipelineBuilder(grPaint, drawContext->mustUseHWAA(grPaint));
|
||||
pipelineBuilder.addColorFragmentProcessor(fp);
|
||||
pipelineBuilder.addColorFragmentProcessor(std::move(fp));
|
||||
|
||||
SkAutoTUnref<GrDrawBatch> batch(
|
||||
GrRectBatchFactory::CreateNonAAFill(grPaint.getColor(), viewMatrix,
|
||||
|
@ -58,8 +58,8 @@ private:
|
||||
Color color(this->color());
|
||||
Coverage coverage(Coverage::kSolid_Type);
|
||||
LocalCoords localCoords(LocalCoords::kUnused_Type);
|
||||
SkAutoTUnref<const GrGeometryProcessor> gp(
|
||||
GrDefaultGeoProcFactory::Create(color, coverage, localCoords, SkMatrix::I()));
|
||||
sk_sp<GrGeometryProcessor> gp(
|
||||
GrDefaultGeoProcFactory::Make(color, coverage, localCoords, SkMatrix::I()));
|
||||
|
||||
size_t vertexStride = gp->getVertexStride();
|
||||
SkASSERT(vertexStride == sizeof(SkPoint));
|
||||
@ -71,7 +71,7 @@ private:
|
||||
|
||||
fRect.toQuad(verts);
|
||||
|
||||
helper.recordDraw(target, gp);
|
||||
helper.recordDraw(target, gp.get());
|
||||
}
|
||||
|
||||
SkRect fRect;
|
||||
@ -173,15 +173,14 @@ protected:
|
||||
path->transform(m, &p);
|
||||
|
||||
GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et;
|
||||
SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create(edgeType, p));
|
||||
sk_sp<GrFragmentProcessor> fp(GrConvexPolyEffect::Make(edgeType, p));
|
||||
if (!fp) {
|
||||
continue;
|
||||
}
|
||||
|
||||
GrPipelineBuilder pipelineBuilder;
|
||||
pipelineBuilder.setXPFactory(
|
||||
GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
|
||||
pipelineBuilder.addCoverageFragmentProcessor(fp);
|
||||
pipelineBuilder.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
|
||||
pipelineBuilder.addCoverageFragmentProcessor(std::move(fp));
|
||||
|
||||
SkAutoTUnref<GrDrawBatch> batch(new PolyBoundsBatch(p.getBounds(), 0xff000000));
|
||||
|
||||
@ -213,15 +212,14 @@ protected:
|
||||
SkRect rect = *iter.get();
|
||||
rect.offset(x, y);
|
||||
GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et;
|
||||
SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create(edgeType, rect));
|
||||
sk_sp<GrFragmentProcessor> fp(GrConvexPolyEffect::Make(edgeType, rect));
|
||||
if (!fp) {
|
||||
continue;
|
||||
}
|
||||
|
||||
GrPipelineBuilder pipelineBuilder;
|
||||
pipelineBuilder.setXPFactory(
|
||||
GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
|
||||
pipelineBuilder.addCoverageFragmentProcessor(fp);
|
||||
pipelineBuilder.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
|
||||
pipelineBuilder.addCoverageFragmentProcessor(std::move(fp));
|
||||
|
||||
SkAutoTUnref<GrDrawBatch> batch(new PolyBoundsBatch(rect, 0xff000000));
|
||||
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
buf.writeMatrix(fDeviceMatrix);
|
||||
}
|
||||
|
||||
const GrFragmentProcessor* asFragmentProcessor(GrContext*,
|
||||
sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
|
||||
const SkMatrix& viewM,
|
||||
const SkMatrix* localMatrix,
|
||||
SkFilterQuality,
|
||||
@ -99,13 +99,13 @@ private:
|
||||
GrCoordTransform fDeviceTransform;
|
||||
};
|
||||
|
||||
const GrFragmentProcessor* DCShader::asFragmentProcessor(GrContext*,
|
||||
sk_sp<GrFragmentProcessor> DCShader::asFragmentProcessor(GrContext*,
|
||||
const SkMatrix& viewM,
|
||||
const SkMatrix* localMatrix,
|
||||
SkFilterQuality,
|
||||
SkSourceGammaTreatment) const {
|
||||
SkAutoTUnref<const GrFragmentProcessor> inner(new DCFP(fDeviceMatrix));
|
||||
return GrFragmentProcessor::MulOutputByInputAlpha(inner);
|
||||
sk_sp<GrFragmentProcessor> inner(new DCFP(fDeviceMatrix));
|
||||
return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
|
||||
}
|
||||
|
||||
class DCShaderGM : public GM {
|
||||
|
@ -103,15 +103,14 @@ protected:
|
||||
#if SK_SUPPORT_GPU
|
||||
GrPipelineBuilder pipelineBuilder;
|
||||
pipelineBuilder.setXPFactory(
|
||||
GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
|
||||
GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
|
||||
|
||||
SkRRect rrect = fRRects[curRRect];
|
||||
rrect.offset(SkIntToScalar(x), SkIntToScalar(y));
|
||||
GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et;
|
||||
SkAutoTUnref<GrFragmentProcessor> fp(GrRRectEffect::Create(edgeType,
|
||||
rrect));
|
||||
sk_sp<GrFragmentProcessor> fp(GrRRectEffect::Make(edgeType, rrect));
|
||||
if (fp) {
|
||||
pipelineBuilder.addCoverageFragmentProcessor(fp);
|
||||
pipelineBuilder.addCoverageFragmentProcessor(std::move(fp));
|
||||
|
||||
SkRect bounds = rrect.getBounds();
|
||||
bounds.outset(2.f, 2.f);
|
||||
|
@ -114,18 +114,18 @@ protected:
|
||||
GrTextureDomain::Mode mode = (GrTextureDomain::Mode) m;
|
||||
GrPipelineBuilder pipelineBuilder;
|
||||
pipelineBuilder.setXPFactory(
|
||||
GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
|
||||
SkAutoTUnref<const GrFragmentProcessor> fp(
|
||||
GrTextureDomainEffect::Create(texture, textureMatrices[tm],
|
||||
GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
|
||||
sk_sp<GrFragmentProcessor> fp(
|
||||
GrTextureDomainEffect::Make(texture, textureMatrices[tm],
|
||||
GrTextureDomain::MakeTexelDomain(texture,
|
||||
texelDomains[d]),
|
||||
texelDomains[d]),
|
||||
mode, GrTextureParams::kNone_FilterMode));
|
||||
|
||||
if (!fp) {
|
||||
continue;
|
||||
}
|
||||
const SkMatrix viewMatrix = SkMatrix::MakeTrans(x, y);
|
||||
pipelineBuilder.addColorFragmentProcessor(fp);
|
||||
pipelineBuilder.addColorFragmentProcessor(std::move(fp));
|
||||
|
||||
SkAutoTUnref<GrDrawBatch> batch(
|
||||
GrRectBatchFactory::CreateNonAAFill(GrColor_WHITE, viewMatrix,
|
||||
|
@ -114,18 +114,17 @@ protected:
|
||||
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
GrPipelineBuilder pipelineBuilder;
|
||||
pipelineBuilder.setXPFactory(
|
||||
GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
|
||||
SkAutoTUnref<const GrFragmentProcessor> fp(
|
||||
GrYUVEffect::CreateYUVToRGB(texture[indices[i][0]],
|
||||
texture[indices[i][1]],
|
||||
texture[indices[i][2]],
|
||||
sizes,
|
||||
static_cast<SkYUVColorSpace>(space)));
|
||||
pipelineBuilder.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
|
||||
sk_sp<GrFragmentProcessor> fp(
|
||||
GrYUVEffect::MakeYUVToRGB(texture[indices[i][0]],
|
||||
texture[indices[i][1]],
|
||||
texture[indices[i][2]],
|
||||
sizes,
|
||||
static_cast<SkYUVColorSpace>(space)));
|
||||
if (fp) {
|
||||
SkMatrix viewMatrix;
|
||||
viewMatrix.setTranslate(x, y);
|
||||
pipelineBuilder.addColorFragmentProcessor(fp);
|
||||
pipelineBuilder.addColorFragmentProcessor(std::move(fp));
|
||||
SkAutoTUnref<GrDrawBatch> batch(
|
||||
GrRectBatchFactory::CreateNonAAFill(GrColor_WHITE, viewMatrix,
|
||||
renderRect, nullptr, nullptr));
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "SkColor.h"
|
||||
#include "SkFlattenable.h"
|
||||
#include "SkRefCnt.h"
|
||||
#include "SkXfermode.h"
|
||||
|
||||
class GrContext;
|
||||
@ -142,6 +143,7 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
/**
|
||||
* A subclass may implement this factory function to work with the GPU backend. It returns
|
||||
* a GrFragmentProcessor that implemets the color filter in GPU shader code.
|
||||
@ -151,9 +153,8 @@ public:
|
||||
*
|
||||
* A null return indicates that the color filter isn't implemented for the GPU backend.
|
||||
*/
|
||||
virtual const GrFragmentProcessor* asFragmentProcessor(GrContext*) const {
|
||||
return nullptr;
|
||||
}
|
||||
virtual sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*) const;
|
||||
#endif
|
||||
|
||||
bool affectsTransparentBlack() const {
|
||||
return this->filterColor(0) != 0;
|
||||
|
@ -264,8 +264,8 @@ template <typename T> class sk_sp {
|
||||
public:
|
||||
using element_type = T;
|
||||
|
||||
sk_sp() : fPtr(nullptr) {}
|
||||
sk_sp(std::nullptr_t) : fPtr(nullptr) {}
|
||||
constexpr sk_sp() : fPtr(nullptr) {}
|
||||
constexpr sk_sp(std::nullptr_t) : fPtr(nullptr) {}
|
||||
|
||||
/**
|
||||
* Shares the underlying object by calling ref(), so that both the argument and the newly
|
||||
|
@ -310,7 +310,7 @@ public:
|
||||
|
||||
virtual bool asACompose(ComposeRec*) const { return false; }
|
||||
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
/**
|
||||
* Returns a GrFragmentProcessor that implements the shader for the GPU backend. NULL is
|
||||
* returned if there is no GPU implementation.
|
||||
@ -324,11 +324,12 @@ public:
|
||||
* The returned GrFragmentProcessor should expect an unpremultiplied input color and
|
||||
* produce a premultiplied output.
|
||||
*/
|
||||
virtual const GrFragmentProcessor* asFragmentProcessor(GrContext*,
|
||||
virtual sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkMatrix* localMatrix,
|
||||
SkFilterQuality,
|
||||
SkSourceGammaTreatment) const;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* If the shader can represent its "average" luminance in a single color, return true and
|
||||
|
@ -220,14 +220,14 @@ public:
|
||||
It is legal for the function to return a null output. This indicates that
|
||||
the output of the blend is simply the src color.
|
||||
*/
|
||||
virtual const GrFragmentProcessor* getFragmentProcessorForImageFilter(
|
||||
const GrFragmentProcessor* dst) const;
|
||||
virtual sk_sp<GrFragmentProcessor> makeFragmentProcessorForImageFilter(
|
||||
sk_sp<GrFragmentProcessor> dst) const;
|
||||
|
||||
/** A subclass must implement this factory function to work with the GPU backend.
|
||||
The xfermode will return a factory for which the caller will get a ref. It is up
|
||||
to the caller to install it. XferProcessors cannot use a background texture.
|
||||
*/
|
||||
virtual GrXPFactory* asXPFactory() const;
|
||||
virtual sk_sp<GrXPFactory> asXPFactory() const;
|
||||
#endif
|
||||
|
||||
SK_TO_STRING_PUREVIRT()
|
||||
|
@ -30,7 +30,7 @@ public:
|
||||
uint32_t getFlags() const override;
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
const GrFragmentProcessor* asFragmentProcessor(GrContext*) const override;
|
||||
sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*) const override;
|
||||
#endif
|
||||
|
||||
SK_TO_STRING_OVERRIDE()
|
||||
|
@ -9,6 +9,7 @@
|
||||
#define SkLumaColorFilter_DEFINED
|
||||
|
||||
#include "SkColorFilter.h"
|
||||
#include "SkRefCnt.h"
|
||||
|
||||
/**
|
||||
* Luminance-to-alpha color filter, as defined in
|
||||
@ -32,7 +33,7 @@ public:
|
||||
void filterSpan(const SkPMColor src[], int count, SkPMColor[]) const override;
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
const GrFragmentProcessor* asFragmentProcessor(GrContext*) const override;
|
||||
sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*) const override;
|
||||
#endif
|
||||
|
||||
SK_TO_STRING_OVERRIDE()
|
||||
|
@ -102,7 +102,7 @@ public:
|
||||
};
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
const GrFragmentProcessor* asFragmentProcessor(GrContext* context, const SkMatrix& viewM,
|
||||
sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext* context, const SkMatrix& viewM,
|
||||
const SkMatrix*, SkFilterQuality,
|
||||
SkSourceGammaTreatment) const override;
|
||||
#endif
|
||||
|
@ -22,7 +22,7 @@ class GrPipelineBuilder;
|
||||
class GrAppliedClip : public SkNoncopyable {
|
||||
public:
|
||||
GrAppliedClip() : fHasStencilClip(false) {}
|
||||
const GrFragmentProcessor* clipCoverageFragmentProcessor() const {
|
||||
GrFragmentProcessor* getClipCoverageFragmentProcessor() const {
|
||||
return fClipCoverageFP.get();
|
||||
}
|
||||
const GrScissorState& scissorState() const { return fScissorState; }
|
||||
@ -40,22 +40,22 @@ public:
|
||||
fHasStencilClip = hasStencil;
|
||||
}
|
||||
|
||||
void makeFPBased(sk_sp<const GrFragmentProcessor> fp) {
|
||||
void makeFPBased(sk_sp<GrFragmentProcessor> fp) {
|
||||
fClipCoverageFP = fp;
|
||||
fScissorState.setDisabled();
|
||||
fHasStencilClip = false;
|
||||
}
|
||||
|
||||
void makeScissoredFPBased(sk_sp<const GrFragmentProcessor> fp, SkIRect& scissor) {
|
||||
void makeScissoredFPBased(sk_sp<GrFragmentProcessor> fp, SkIRect& scissor) {
|
||||
fClipCoverageFP = fp;
|
||||
fScissorState.set(scissor);
|
||||
fHasStencilClip = false;
|
||||
}
|
||||
|
||||
private:
|
||||
sk_sp<const GrFragmentProcessor> fClipCoverageFP;
|
||||
GrScissorState fScissorState;
|
||||
bool fHasStencilClip;
|
||||
sk_sp<GrFragmentProcessor> fClipCoverageFP;
|
||||
GrScissorState fScissorState;
|
||||
bool fHasStencilClip;
|
||||
|
||||
typedef SkNoncopyable INHERITED;
|
||||
};
|
||||
|
@ -457,9 +457,9 @@ private:
|
||||
* of effects that make a readToUPM->writeToPM->readToUPM cycle invariant. Otherwise, they
|
||||
* return NULL. They also can perform a swizzle as part of the draw.
|
||||
*/
|
||||
const GrFragmentProcessor* createPMToUPMEffect(GrTexture*, const GrSwizzle&,
|
||||
sk_sp<GrFragmentProcessor> createPMToUPMEffect(GrTexture*, const GrSwizzle&,
|
||||
const SkMatrix&) const;
|
||||
const GrFragmentProcessor* createUPMToPMEffect(GrTexture*, const GrSwizzle&,
|
||||
sk_sp<GrFragmentProcessor> createUPMToPMEffect(GrTexture*, const GrSwizzle&,
|
||||
const SkMatrix&) const;
|
||||
/** Called before either of the above two functions to determine the appropriate fragment
|
||||
processors for conversions. This must be called by readSurfacePixels before a mutex is
|
||||
|
@ -31,29 +31,31 @@ public:
|
||||
* does so by returning a parent FP that multiplies the passed in FPs output by the parent's
|
||||
* input alpha. The passed in FP will not receive an input color.
|
||||
*/
|
||||
static const GrFragmentProcessor* MulOutputByInputAlpha(const GrFragmentProcessor*);
|
||||
static sk_sp<GrFragmentProcessor> MulOutputByInputAlpha(sk_sp<GrFragmentProcessor>);
|
||||
|
||||
/**
|
||||
* Similar to the above but it modulates the output r,g,b of the child processor by the input
|
||||
* rgb and then multiplies all the components by the input alpha. This effectively modulates
|
||||
* the child processor's premul color by a unpremul'ed input and produces a premul output
|
||||
*/
|
||||
static const GrFragmentProcessor* MulOutputByInputUnpremulColor(const GrFragmentProcessor*);
|
||||
static sk_sp<GrFragmentProcessor> MulOutputByInputUnpremulColor(sk_sp<GrFragmentProcessor>);
|
||||
|
||||
/**
|
||||
* Returns a parent fragment processor that adopts the passed fragment processor as a child.
|
||||
* The parent will ignore its input color and instead feed the passed in color as input to the
|
||||
* child.
|
||||
*/
|
||||
static const GrFragmentProcessor* OverrideInput(const GrFragmentProcessor*, GrColor);
|
||||
static sk_sp<GrFragmentProcessor> OverrideInput(sk_sp<GrFragmentProcessor>, GrColor);
|
||||
|
||||
/**
|
||||
* Returns a fragment processor that runs the passed in array of fragment processors in a
|
||||
* series. The original input is passed to the first, the first's output is passed to the
|
||||
* second, etc. The output of the returned processor is the output of the last processor of the
|
||||
* series.
|
||||
*
|
||||
* The array elements with be moved.
|
||||
*/
|
||||
static const GrFragmentProcessor* RunInSeries(const GrFragmentProcessor*[], int cnt);
|
||||
static sk_sp<GrFragmentProcessor> RunInSeries(sk_sp<GrFragmentProcessor>*, int cnt);
|
||||
|
||||
GrFragmentProcessor()
|
||||
: INHERITED()
|
||||
@ -155,7 +157,7 @@ protected:
|
||||
* processors will allow the ProgramBuilder to automatically handle their transformed coords and
|
||||
* texture accesses and mangle their uniform and output color names.
|
||||
*/
|
||||
int registerChildProcessor(const GrFragmentProcessor* child);
|
||||
int registerChildProcessor(sk_sp<GrFragmentProcessor> child);
|
||||
|
||||
/**
|
||||
* Subclass implements this to support getConstantColorComponents(...).
|
||||
@ -187,7 +189,7 @@ private:
|
||||
|
||||
bool hasSameTransforms(const GrFragmentProcessor&) const;
|
||||
|
||||
bool fUsesLocalCoords;
|
||||
bool fUsesLocalCoords;
|
||||
|
||||
/**
|
||||
* fCoordTransforms stores the transforms of this proc, followed by all the transforms of this
|
||||
@ -212,11 +214,16 @@ private:
|
||||
*
|
||||
* The same goes for fTextureAccesses with textures.
|
||||
*/
|
||||
SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms;
|
||||
int fNumTexturesExclChildren;
|
||||
int fNumBuffersExclChildren;
|
||||
int fNumTransformsExclChildren;
|
||||
SkSTArray<1, const GrFragmentProcessor*, true> fChildProcessors;
|
||||
SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms;
|
||||
int fNumTexturesExclChildren;
|
||||
int fNumBuffersExclChildren;
|
||||
int fNumTransformsExclChildren;
|
||||
|
||||
/**
|
||||
* This is not SkSTArray<1, sk_sp<GrFragmentProcessor>> because this class holds strong
|
||||
* references until notifyRefCntIsZero and then it holds pending executions.
|
||||
*/
|
||||
SkSTArray<1, GrFragmentProcessor*, true> fChildProcessors;
|
||||
|
||||
typedef GrProcessor INHERITED;
|
||||
};
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "effects/GrPorterDuffXferProcessor.h"
|
||||
#include "GrFragmentProcessor.h"
|
||||
|
||||
#include "SkRefCnt.h"
|
||||
#include "SkRegion.h"
|
||||
#include "SkXfermode.h"
|
||||
|
||||
@ -42,7 +43,7 @@ public:
|
||||
|
||||
GrPaint(const GrPaint& paint) { *this = paint; }
|
||||
|
||||
~GrPaint() { this->resetFragmentProcessors(); }
|
||||
~GrPaint() { }
|
||||
|
||||
/**
|
||||
* The initial color of the drawn primitive. Defaults to solid white.
|
||||
@ -79,13 +80,12 @@ public:
|
||||
setAllowSRGBInputs(gammaCorrect);
|
||||
}
|
||||
|
||||
const GrXPFactory* setXPFactory(const GrXPFactory* xpFactory) {
|
||||
fXPFactory.reset(SkSafeRef(xpFactory));
|
||||
return xpFactory;
|
||||
void setXPFactory(sk_sp<GrXPFactory> xpFactory) {
|
||||
fXPFactory = std::move(xpFactory);
|
||||
}
|
||||
|
||||
void setPorterDuffXPFactory(SkXfermode::Mode mode) {
|
||||
fXPFactory.reset(GrPorterDuffXPFactory::Create(mode));
|
||||
fXPFactory = GrPorterDuffXPFactory::Make(mode);
|
||||
}
|
||||
|
||||
void setCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage = false);
|
||||
@ -93,19 +93,17 @@ public:
|
||||
/**
|
||||
* Appends an additional color processor to the color computation.
|
||||
*/
|
||||
const GrFragmentProcessor* addColorFragmentProcessor(const GrFragmentProcessor* fp) {
|
||||
void addColorFragmentProcessor(sk_sp<GrFragmentProcessor> fp) {
|
||||
SkASSERT(fp);
|
||||
fColorFragmentProcessors.push_back(SkRef(fp));
|
||||
return fp;
|
||||
fColorFragmentProcessors.push_back(std::move(fp));
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends an additional coverage processor to the coverage computation.
|
||||
*/
|
||||
const GrFragmentProcessor* addCoverageFragmentProcessor(const GrFragmentProcessor* fp) {
|
||||
void addCoverageFragmentProcessor(sk_sp<GrFragmentProcessor> fp) {
|
||||
SkASSERT(fp);
|
||||
fCoverageFragmentProcessors.push_back(SkRef(fp));
|
||||
return fp;
|
||||
fCoverageFragmentProcessors.push_back(std::move(fp));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -122,15 +120,15 @@ public:
|
||||
int numTotalFragmentProcessors() const { return this->numColorFragmentProcessors() +
|
||||
this->numCoverageFragmentProcessors(); }
|
||||
|
||||
const GrXPFactory* getXPFactory() const {
|
||||
return fXPFactory;
|
||||
GrXPFactory* getXPFactory() const {
|
||||
return fXPFactory.get();
|
||||
}
|
||||
|
||||
const GrFragmentProcessor* getColorFragmentProcessor(int i) const {
|
||||
return fColorFragmentProcessors[i];
|
||||
GrFragmentProcessor* getColorFragmentProcessor(int i) const {
|
||||
return fColorFragmentProcessors[i].get();
|
||||
}
|
||||
const GrFragmentProcessor* getCoverageFragmentProcessor(int i) const {
|
||||
return fCoverageFragmentProcessors[i];
|
||||
GrFragmentProcessor* getCoverageFragmentProcessor(int i) const {
|
||||
return fCoverageFragmentProcessors[i].get();
|
||||
}
|
||||
|
||||
GrPaint& operator=(const GrPaint& paint) {
|
||||
@ -139,17 +137,10 @@ public:
|
||||
fAllowSRGBInputs = paint.fAllowSRGBInputs;
|
||||
|
||||
fColor = paint.fColor;
|
||||
this->resetFragmentProcessors();
|
||||
fColorFragmentProcessors = paint.fColorFragmentProcessors;
|
||||
fCoverageFragmentProcessors = paint.fCoverageFragmentProcessors;
|
||||
for (int i = 0; i < fColorFragmentProcessors.count(); ++i) {
|
||||
fColorFragmentProcessors[i]->ref();
|
||||
}
|
||||
for (int i = 0; i < fCoverageFragmentProcessors.count(); ++i) {
|
||||
fCoverageFragmentProcessors[i]->ref();
|
||||
}
|
||||
|
||||
fXPFactory.reset(SkSafeRef(paint.getXPFactory()));
|
||||
fXPFactory = paint.fXPFactory;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@ -163,26 +154,15 @@ public:
|
||||
bool isConstantBlendedColor(GrColor* constantColor) const;
|
||||
|
||||
private:
|
||||
void resetFragmentProcessors() {
|
||||
for (int i = 0; i < fColorFragmentProcessors.count(); ++i) {
|
||||
fColorFragmentProcessors[i]->unref();
|
||||
}
|
||||
for (int i = 0; i < fCoverageFragmentProcessors.count(); ++i) {
|
||||
fCoverageFragmentProcessors[i]->unref();
|
||||
}
|
||||
fColorFragmentProcessors.reset();
|
||||
fCoverageFragmentProcessors.reset();
|
||||
}
|
||||
mutable sk_sp<GrXPFactory> fXPFactory;
|
||||
SkSTArray<4, sk_sp<GrFragmentProcessor>> fColorFragmentProcessors;
|
||||
SkSTArray<2, sk_sp<GrFragmentProcessor>> fCoverageFragmentProcessors;
|
||||
|
||||
mutable SkAutoTUnref<const GrXPFactory> fXPFactory;
|
||||
SkSTArray<4, const GrFragmentProcessor*, true> fColorFragmentProcessors;
|
||||
SkSTArray<2, const GrFragmentProcessor*, true> fCoverageFragmentProcessors;
|
||||
bool fAntiAlias;
|
||||
bool fDisableOutputConversionToSRGB;
|
||||
bool fAllowSRGBInputs;
|
||||
|
||||
bool fAntiAlias;
|
||||
bool fDisableOutputConversionToSRGB;
|
||||
bool fAllowSRGBInputs;
|
||||
|
||||
GrColor fColor;
|
||||
GrColor fColor;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -28,7 +28,7 @@ enum {
|
||||
|
||||
/** This allows parent FPs to implement a test create with known leaf children in order to avoid
|
||||
creating an unbounded FP tree which may overflow various shader limits. */
|
||||
const GrFragmentProcessor* CreateChildFP(GrProcessorTestData*);
|
||||
sk_sp<GrFragmentProcessor> MakeChildFP(GrProcessorTestData*);
|
||||
|
||||
}
|
||||
|
||||
@ -66,28 +66,28 @@ class GrTexture;
|
||||
|
||||
template <class Processor> class GrProcessorTestFactory : SkNoncopyable {
|
||||
public:
|
||||
typedef const Processor* (*CreateProc)(GrProcessorTestData*);
|
||||
typedef sk_sp<Processor> (*MakeProc)(GrProcessorTestData*);
|
||||
|
||||
GrProcessorTestFactory(CreateProc createProc) {
|
||||
fCreateProc = createProc;
|
||||
GrProcessorTestFactory(MakeProc makeProc) {
|
||||
fMakeProc = makeProc;
|
||||
GetFactories()->push_back(this);
|
||||
}
|
||||
|
||||
/** Pick a random factory function and create a processor. */
|
||||
static const Processor* Create(GrProcessorTestData* data) {
|
||||
static sk_sp<Processor> Make(GrProcessorTestData* data) {
|
||||
VerifyFactoryCount();
|
||||
SkASSERT(GetFactories()->count());
|
||||
uint32_t idx = data->fRandom->nextRangeU(0, GetFactories()->count() - 1);
|
||||
return CreateIdx(idx, data);
|
||||
return MakeIdx(idx, data);
|
||||
}
|
||||
|
||||
/** Number of registered factory functions */
|
||||
static int Count() { return GetFactories()->count(); }
|
||||
|
||||
/** Use factory function at Index idx to create a processor. */
|
||||
static const Processor* CreateIdx(int idx, GrProcessorTestData* data) {
|
||||
static sk_sp<Processor> MakeIdx(int idx, GrProcessorTestData* data) {
|
||||
GrProcessorTestFactory<Processor>* factory = (*GetFactories())[idx];
|
||||
return factory->fCreateProc(data);
|
||||
return factory->fMakeProc(data);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -96,7 +96,7 @@ public:
|
||||
static void VerifyFactoryCount();
|
||||
|
||||
private:
|
||||
CreateProc fCreateProc;
|
||||
MakeProc fMakeProc;
|
||||
|
||||
static SkTArray<GrProcessorTestFactory<Processor>*, true>* GetFactories();
|
||||
};
|
||||
@ -106,15 +106,15 @@ private:
|
||||
*/
|
||||
#define GR_DECLARE_GEOMETRY_PROCESSOR_TEST \
|
||||
static GrProcessorTestFactory<GrGeometryProcessor> gTestFactory SK_UNUSED; \
|
||||
static const GrGeometryProcessor* TestCreate(GrProcessorTestData*)
|
||||
static sk_sp<GrGeometryProcessor> TestCreate(GrProcessorTestData*)
|
||||
|
||||
#define GR_DECLARE_FRAGMENT_PROCESSOR_TEST \
|
||||
static GrProcessorTestFactory<GrFragmentProcessor> gTestFactory SK_UNUSED; \
|
||||
static const GrFragmentProcessor* TestCreate(GrProcessorTestData*)
|
||||
static sk_sp<GrFragmentProcessor> TestCreate(GrProcessorTestData*)
|
||||
|
||||
#define GR_DECLARE_XP_FACTORY_TEST \
|
||||
static GrProcessorTestFactory<GrXPFactory> gTestFactory SK_UNUSED; \
|
||||
static const GrXPFactory* TestCreate(GrProcessorTestData*)
|
||||
static sk_sp<GrXPFactory> TestCreate(GrProcessorTestData*)
|
||||
|
||||
/** GrProcessor subclasses should insert this macro in their implementation file. They must then
|
||||
* also implement this static function:
|
||||
@ -134,19 +134,19 @@ private:
|
||||
// The unit test relies on static initializers. Just declare the TestCreate function so that
|
||||
// its definitions will compile.
|
||||
#define GR_DECLARE_FRAGMENT_PROCESSOR_TEST \
|
||||
static const GrFragmentProcessor* TestCreate(GrProcessorTestData*)
|
||||
static sk_sp<GrFragmentProcessor> TestCreate(GrProcessorTestData*)
|
||||
#define GR_DEFINE_FRAGMENT_PROCESSOR_TEST(X)
|
||||
|
||||
// The unit test relies on static initializers. Just declare the TestCreate function so that
|
||||
// its definitions will compile.
|
||||
#define GR_DECLARE_XP_FACTORY_TEST \
|
||||
static const GrXPFactory* TestCreate(GrProcessorTestData*)
|
||||
static sk_sp<GrXPFactory> TestCreate(GrProcessorTestData*)
|
||||
#define GR_DEFINE_XP_FACTORY_TEST(X)
|
||||
|
||||
// The unit test relies on static initializers. Just declare the TestCreate function so that
|
||||
// its definitions will compile.
|
||||
#define GR_DECLARE_GEOMETRY_PROCESSOR_TEST \
|
||||
static const GrGeometryProcessor* TestCreate(GrProcessorTestData*)
|
||||
static sk_sp<GrGeometryProcessor> TestCreate(GrProcessorTestData*)
|
||||
#define GR_DEFINE_GEOMETRY_PROCESSOR_TEST(X)
|
||||
|
||||
#endif // !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "GrTypes.h"
|
||||
#include "SkRect.h"
|
||||
#include "SkRefCnt.h"
|
||||
|
||||
/**
|
||||
* Types of shader-language-specific boxed variables we can create. (Currently only GrGLShaderVars,
|
||||
@ -476,4 +477,9 @@ enum class GrBackendObjectOwnership : bool {
|
||||
kOwned = true
|
||||
};
|
||||
|
||||
template <typename T> T * const * sk_sp_address_as_pointer_address(sk_sp<T> const * sp) {
|
||||
static_assert(sizeof(T*) == sizeof(sk_sp<T>), "sk_sp not expected size.");
|
||||
return reinterpret_cast<T * const *>(sp);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -26,8 +26,8 @@ public:
|
||||
};
|
||||
static const int kInputModeCnt = kLastInputMode + 1;
|
||||
|
||||
static GrFragmentProcessor* Create(GrColor color, InputMode mode) {
|
||||
return new GrConstColorProcessor(color, mode);
|
||||
static sk_sp<GrFragmentProcessor> Make(GrColor color, InputMode mode) {
|
||||
return sk_sp<GrFragmentProcessor>(new GrConstColorProcessor(color, mode));
|
||||
}
|
||||
|
||||
const char* name() const override { return "Color"; }
|
||||
|
@ -21,7 +21,7 @@ class GrProcOptInfo;
|
||||
*/
|
||||
class GrCoverageSetOpXPFactory : public GrXPFactory {
|
||||
public:
|
||||
static GrXPFactory* Create(SkRegion::Op regionOp, bool invertCoverage = false);
|
||||
static sk_sp<GrXPFactory> Make(SkRegion::Op regionOp, bool invertCoverage = false);
|
||||
|
||||
void getInvariantBlendedColor(const GrProcOptInfo& colorPOI,
|
||||
GrXPFactory::InvariantBlendedColor*) const override;
|
||||
|
@ -18,7 +18,7 @@ class GrTexture;
|
||||
*/
|
||||
namespace GrCustomXfermode {
|
||||
bool IsSupportedMode(SkXfermode::Mode mode);
|
||||
GrXPFactory* CreateXPFactory(SkXfermode::Mode mode);
|
||||
sk_sp<GrXPFactory> MakeXPFactory(SkXfermode::Mode mode);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -16,7 +16,7 @@ class GrProcOptInfo;
|
||||
|
||||
class GrPorterDuffXPFactory : public GrXPFactory {
|
||||
public:
|
||||
static GrXPFactory* Create(SkXfermode::Mode mode);
|
||||
static sk_sp<GrXPFactory> Make(SkXfermode::Mode mode);
|
||||
|
||||
void getInvariantBlendedColor(const GrProcOptInfo& colorPOI,
|
||||
GrXPFactory::InvariantBlendedColor*) const override;
|
||||
|
@ -15,20 +15,20 @@ class GrFragmentProcessor;
|
||||
namespace GrXfermodeFragmentProcessor {
|
||||
/** The color input to the returned processor is treated as the src and the passed in processor
|
||||
is the dst. */
|
||||
const GrFragmentProcessor* CreateFromDstProcessor(const GrFragmentProcessor* dst,
|
||||
SkXfermode::Mode mode);
|
||||
sk_sp<GrFragmentProcessor> MakeFromDstProcessor(sk_sp<GrFragmentProcessor> dst,
|
||||
SkXfermode::Mode mode);
|
||||
|
||||
/** The color input to the returned processor is treated as the dst and the passed in processor
|
||||
is the src. */
|
||||
const GrFragmentProcessor* CreateFromSrcProcessor(const GrFragmentProcessor* src,
|
||||
SkXfermode::Mode mode);
|
||||
sk_sp<GrFragmentProcessor> MakeFromSrcProcessor(sk_sp<GrFragmentProcessor> src,
|
||||
SkXfermode::Mode mode);
|
||||
|
||||
/** Takes the input color, which is assumed to be unpremultiplied, passes it as an opaque color
|
||||
to both src and dst. The outputs of a src and dst are blended using mode and the original
|
||||
input's alpha is applied to the blended color to produce a premul output. */
|
||||
const GrFragmentProcessor* CreateFromTwoProcessors(const GrFragmentProcessor* src,
|
||||
const GrFragmentProcessor* dst,
|
||||
SkXfermode::Mode mode);
|
||||
sk_sp<GrFragmentProcessor> MakeFromTwoProcessors(sk_sp<GrFragmentProcessor> src,
|
||||
sk_sp<GrFragmentProcessor> dst,
|
||||
SkXfermode::Mode mode);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -120,6 +120,15 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures there is enough reserved space for n elements.
|
||||
*/
|
||||
void reserve(int n) {
|
||||
if (fCount < n) {
|
||||
this->checkRealloc(n - fCount);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets to a copy of a C array.
|
||||
*/
|
||||
|
@ -410,7 +410,7 @@ void SkBitmapProcShader::toString(SkString* str) const {
|
||||
#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 @@ const GrFragmentProcessor* SkBitmapProcShader::asFragmentProcessor(GrContext* co
|
||||
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
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
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
|
||||
|
@ -31,6 +31,12 @@ bool SkColorFilter::asComponentTable(SkBitmap*) const {
|
||||
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 @@ public:
|
||||
#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
|
||||
|
@ -97,27 +97,25 @@ void SkColorFilterShader::FilterShaderContext::shadeSpan4f(int x, int y, SkPM4f
|
||||
#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
|
||||
|
@ -16,7 +16,7 @@ public:
|
||||
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,
|
||||
|
@ -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 @@ SkColorMatrixFilterRowMajor255::makeComposed(sk_sp<SkColorFilter> innerFilter) c
|
||||
|
||||
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 @@ private:
|
||||
|
||||
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
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
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()
|
||||
|
@ -89,12 +89,12 @@ SkShader::GradientType SkColorShader::asAGradient(GradientInfo* info) const {
|
||||
|
||||
#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 @@ SkShader::GradientType SkColor4Shader::asAGradient(GradientInfo* info) const {
|
||||
|
||||
#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
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
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 @@ public:
|
||||
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
|
||||
|
@ -183,7 +183,7 @@ void SkComposeShader::ComposeShaderContext::shadeSpan(int x, int y, SkPMColor re
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
const GrFragmentProcessor* SkComposeShader::asFragmentProcessor(
|
||||
sk_sp<GrFragmentProcessor> SkComposeShader::asFragmentProcessor(
|
||||
GrContext* context,
|
||||
const SkMatrix& viewM,
|
||||
const SkMatrix* localMatrix,
|
||||
@ -197,8 +197,8 @@ const GrFragmentProcessor* SkComposeShader::asFragmentProcessor(
|
||||
|
||||
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 @@ const GrFragmentProcessor* SkComposeShader::asFragmentProcessor(
|
||||
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
|
||||
|
@ -35,11 +35,11 @@ public:
|
||||
{}
|
||||
|
||||
#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 {
|
||||
|
@ -277,7 +277,7 @@ sk_sp<SkSpecialImage> SkImageFilter::DrawWithFP(GrContext* context,
|
||||
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,
|
||||
|
@ -72,7 +72,7 @@ public:
|
||||
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 @@ static bool make_mat(const SkBitmap& bm,
|
||||
return true;
|
||||
}
|
||||
|
||||
const GrFragmentProcessor* SkLightingShaderImpl::asFragmentProcessor(
|
||||
sk_sp<GrFragmentProcessor> SkLightingShaderImpl::asFragmentProcessor(
|
||||
GrContext* context,
|
||||
const SkMatrix& viewM,
|
||||
const SkMatrix* localMatrix,
|
||||
@ -404,10 +404,10 @@ const GrFragmentProcessor* SkLightingShaderImpl::asFragmentProcessor(
|
||||
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
|
||||
|
@ -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);
|
||||
|
@ -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 @@ public:
|
||||
}
|
||||
|
||||
#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 {
|
||||
|
@ -91,16 +91,16 @@ sk_sp<SkFlattenable> SkModeColorFilter::CreateProc(SkReadBuffer& buffer) {
|
||||
#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;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
#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)
|
||||
|
||||
|
@ -318,7 +318,7 @@ void SkPictureShader::toString(SkString* str) const {
|
||||
#endif
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
const GrFragmentProcessor* SkPictureShader::asFragmentProcessor(
|
||||
sk_sp<GrFragmentProcessor> SkPictureShader::asFragmentProcessor(
|
||||
GrContext* context, const SkMatrix& viewM,
|
||||
const SkMatrix* localMatrix,
|
||||
SkFilterQuality fq,
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
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,
|
||||
|
@ -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 @@ SkShader::GradientType SkShader::asAGradient(GradientInfo* info) const {
|
||||
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;
|
||||
|
@ -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 @@ bool SkXfermode::asMode(Mode* mode) const {
|
||||
}
|
||||
|
||||
#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 @@ void SkProcCoeffXfermode::xferA8(SkAlpha* SK_RESTRICT dst,
|
||||
}
|
||||
|
||||
#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
|
||||
|
||||
|
@ -45,9 +45,9 @@ public:
|
||||
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()
|
||||
|
@ -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 @@ void GrGLAlphaThresholdFragmentProcessor::onSetData(const GrGLSLProgramDataManag
|
||||
|
||||
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 @@ const GrFragmentProcessor* GrAlphaThresholdFragmentProcessor::TestCreate(GrProce
|
||||
SkIRect bounds = SkIRect::MakeXYWH(x, y, width, height);
|
||||
return GrAlphaThresholdFragmentProcessor::Make(bmpTex, maskTex,
|
||||
innerThresh, outerThresh,
|
||||
bounds).release();
|
||||
bounds);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -289,11 +289,11 @@ GrTexture* GrCircleBlurFragmentProcessor::CreateCircleBlurProfileTexture(
|
||||
|
||||
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
|
||||
|
@ -34,8 +34,8 @@ public:
|
||||
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 @@ public:
|
||||
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; }
|
||||
|
@ -33,9 +33,9 @@ public:
|
||||
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 @@ sk_sp<SkXfermode> SkArithmeticMode::Make(SkScalar k1, SkScalar k2, SkScalar k3,
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#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
|
||||
|
@ -85,12 +85,12 @@ private:
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
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 @@ void GrArithmeticFP::onComputeInvariantOutput(GrInvariantOutput* inout) const {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
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 @@ void GrArithmeticXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorP
|
||||
|
||||
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
|
||||
|
@ -31,9 +31,10 @@ class GrGLArtithmeticFP;
|
||||
|
||||
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 @@ private:
|
||||
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 @@ private:
|
||||
|
||||
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,
|
||||
|
@ -607,8 +607,8 @@ public:
|
||||
|
||||
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 @@ public:
|
||||
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 @@ void GrRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
|
||||
|
||||
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 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrTextureProvider* texProvider,
|
||||
|
||||
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 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrTextureProvider* texProvider,
|
||||
return false;
|
||||
}
|
||||
|
||||
grp->addCoverageFragmentProcessor(fp);
|
||||
grp->addCoverageFragmentProcessor(std::move(fp));
|
||||
|
||||
SkMatrix inverse;
|
||||
if (!viewMatrix.invert(&inverse)) {
|
||||
@ -908,7 +908,7 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrTextureProvider* texProvider,
|
||||
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 @@ private:
|
||||
};
|
||||
|
||||
|
||||
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 @@ const GrFragmentProcessor* GrRRectBlurEffect::Create(GrTextureProvider* texProvi
|
||||
}
|
||||
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 @@ bool GrRRectBlurEffect::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
|
||||
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 @@ bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrTextureProvider* texProvid
|
||||
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 @@ bool SkBlurMaskFilterImpl::filterMaskGPU(GrTexture* src,
|
||||
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);
|
||||
|
@ -161,8 +161,9 @@ void SkColorCubeFilter::toString(SkString* str) const {
|
||||
|
||||
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 @@ void GrColorCubeEffect::GLSLProcessor::GenKey(const GrProcessor& proc,
|
||||
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 @@ const GrFragmentProcessor* SkColorCubeFilter::asFragmentProcessor(GrContext* con
|
||||
}
|
||||
}
|
||||
|
||||
return GrColorCubeEffect::Create(textureCube);
|
||||
return sk_sp<GrFragmentProcessor>(GrColorCubeEffect::Make(textureCube));
|
||||
}
|
||||
#endif
|
||||
|
@ -214,13 +214,14 @@ void SkDisplacementMapEffect::flatten(SkWriteBuffer& buffer) const {
|
||||
#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 @@ sk_sp<SkSpecialImage> SkDisplacementMapEffect::onFilterImage(SkSpecialImage* sou
|
||||
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 @@ void GrDisplacementMapEffect::onComputeInvariantOutput(GrInvariantOutput* inout)
|
||||
|
||||
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 @@ const GrFragmentProcessor* GrDisplacementMapEffect::TestCreate(GrProcessorTestDa
|
||||
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);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -76,9 +76,9 @@ static void convolve_gaussian_1d(GrDrawContext* drawContext,
|
||||
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 @@ static void convolve_gaussian_2d(GrDrawContext* drawContext,
|
||||
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 @@ sk_sp<GrDrawContext> GaussianBlur(GrContext* context,
|
||||
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 {
|
||||
|
@ -359,10 +359,10 @@ protected:
|
||||
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 @@ void SkLightingImageFilterInternal::drawRect(GrDrawContext* drawContext,
|
||||
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 @@ protected:
|
||||
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 @@ protected:
|
||||
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 @@ private:
|
||||
|
||||
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 @@ private:
|
||||
|
||||
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 @@ void SkDiffuseLightingImageFilter::toString(SkString* str) const {
|
||||
#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 @@ void SkSpecularLightingImageFilter::toString(SkString* str) const {
|
||||
#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 @@ GrGLSLFragmentProcessor* GrDiffuseLightingEffect::onCreateGLSLInstance() const {
|
||||
|
||||
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 @@ const GrFragmentProcessor* GrDiffuseLightingEffect::TestCreate(GrProcessorTestDa
|
||||
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 @@ GrGLSLFragmentProcessor* GrSpecularLightingEffect::onCreateGLSLInstance() const
|
||||
|
||||
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 @@ const GrFragmentProcessor* GrSpecularLightingEffect::TestCreate(GrProcessorTestD
|
||||
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);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -58,8 +58,8 @@ void SkLumaColorFilter::toString(SkString* str) const {
|
||||
#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 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
const GrFragmentProcessor* SkLumaColorFilter::asFragmentProcessor(GrContext*) const {
|
||||
|
||||
return LumaColorFilterEffect::Create();
|
||||
sk_sp<GrFragmentProcessor> SkLumaColorFilter::asFragmentProcessor(GrContext*) const {
|
||||
return LumaColorFilterEffect::Make();
|
||||
}
|
||||
#endif
|
||||
|
@ -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 @@ GrGLSLFragmentProcessor* GrMagnifierEffect::onCreateGLSLInstance() const {
|
||||
|
||||
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 @@ const GrFragmentProcessor* GrMagnifierEffect::TestCreate(GrProcessorTestData* d)
|
||||
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 @@ const GrFragmentProcessor* GrMagnifierEffect::TestCreate(GrProcessorTestData* d)
|
||||
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 @@ sk_sp<SkSpecialImage> SkMagnifierImageFilter::onFilterImage(SkSpecialImage* sour
|
||||
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(),
|
||||
|
@ -315,8 +315,7 @@ sk_sp<SkSpecialImage> SkMatrixConvolutionImageFilter::onFilterImage(SkSpecialIma
|
||||
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,
|
||||
|
@ -143,14 +143,14 @@ public:
|
||||
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 @@ void GrMorphologyEffect::onComputeInvariantOutput(GrInvariantOutput* inout) cons
|
||||
|
||||
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 @@ static void apply_morphology_rect(GrDrawContext* drawContext,
|
||||
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 @@ static void apply_morphology_rect_no_bounds(GrDrawContext* drawContext,
|
||||
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));
|
||||
|
@ -495,13 +495,14 @@ private:
|
||||
|
||||
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 @@ private:
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
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 @@ void GrGLPerlinNoise::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
const GrFragmentProcessor* SkPerlinNoiseShader::asFragmentProcessor(
|
||||
sk_sp<GrFragmentProcessor> SkPerlinNoiseShader::asFragmentProcessor(
|
||||
GrContext* context,
|
||||
const SkMatrix& viewM,
|
||||
const SkMatrix* externalLocalMatrix,
|
||||
@ -911,13 +912,13 @@ const GrFragmentProcessor* SkPerlinNoiseShader::asFragmentProcessor(
|
||||
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 @@ const GrFragmentProcessor* SkPerlinNoiseShader::asFragmentProcessor(
|
||||
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;
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
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 @@ sk_sp<SkColorFilter> SkTable_ColorFilter::makeComposed(sk_sp<SkColorFilter> inne
|
||||
|
||||
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 @@ void GLColorTableEffect::emitCode(EmitArgs& args) {
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
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 @@ const GrFragmentProcessor* ColorTableEffect::Create(GrContext* context, SkBitmap
|
||||
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 @@ void ColorTableEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
|
||||
|
||||
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 @@ const GrFragmentProcessor* ColorTableEffect::TestCreate(GrProcessorTestData* d)
|
||||
(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
|
||||
|
@ -180,22 +180,22 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilter::filterImageGPU(SkSpecialImage* sour
|
||||
|
||||
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 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilter::filterImageGPU(SkSpecialImage* sour
|
||||
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 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilter::filterImageGPU(SkSpecialImage* sour
|
||||
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);
|
||||
|
@ -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 @@ private:
|
||||
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 @@ private:
|
||||
|
||||
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 @@ const GrFragmentProcessor* GrLinearGradient::TestCreate(GrProcessorTestData* d)
|
||||
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 @@ void GrGLLinearGradient::emitCode(EmitArgs& args) {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
const GrFragmentProcessor* SkLinearGradient::asFragmentProcessor(
|
||||
sk_sp<GrFragmentProcessor> SkLinearGradient::asFragmentProcessor(
|
||||
GrContext* context,
|
||||
const SkMatrix& viewm,
|
||||
const SkMatrix* localMatrix,
|
||||
@ -463,9 +464,8 @@ const GrFragmentProcessor* SkLinearGradient::asFragmentProcessor(
|
||||
}
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
|
@ -57,7 +57,7 @@ public:
|
||||
|
||||
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,
|
||||
|
@ -264,11 +264,11 @@ private:
|
||||
|
||||
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 @@ private:
|
||||
|
||||
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 @@ const GrFragmentProcessor* GrRadialGradient::TestCreate(GrProcessorTestData* d)
|
||||
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 @@ void GrGLRadialGradient::emitCode(EmitArgs& args) {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
const GrFragmentProcessor* SkRadialGradient::asFragmentProcessor(
|
||||
sk_sp<GrFragmentProcessor> SkRadialGradient::asFragmentProcessor(
|
||||
GrContext* context,
|
||||
const SkMatrix& viewM,
|
||||
const SkMatrix* localMatrix,
|
||||
@ -358,9 +358,8 @@ const GrFragmentProcessor* SkRadialGradient::asFragmentProcessor(
|
||||
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
|
||||
|
@ -26,7 +26,7 @@ public:
|
||||
|
||||
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,
|
||||
|
@ -147,9 +147,9 @@ private:
|
||||
|
||||
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 @@ private:
|
||||
|
||||
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 @@ const GrFragmentProcessor* GrSweepGradient::TestCreate(GrProcessorTestData* d) {
|
||||
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 @@ void GrGLSweepGradient::emitCode(EmitArgs& args) {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
const GrFragmentProcessor* SkSweepGradient::asFragmentProcessor(
|
||||
sk_sp<GrFragmentProcessor> SkSweepGradient::asFragmentProcessor(
|
||||
GrContext* context,
|
||||
const SkMatrix& viewM,
|
||||
const SkMatrix* localMatrix,
|
||||
@ -247,9 +247,8 @@ const GrFragmentProcessor* SkSweepGradient::asFragmentProcessor(
|
||||
}
|
||||
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
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
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,
|
||||
|
@ -356,7 +356,7 @@ void SkTwoPointConicalGradient::flatten(SkWriteBuffer& buffer) const {
|
||||
|
||||
#include "SkGr.h"
|
||||
|
||||
const GrFragmentProcessor* SkTwoPointConicalGradient::asFragmentProcessor(
|
||||
sk_sp<GrFragmentProcessor> SkTwoPointConicalGradient::asFragmentProcessor(
|
||||
GrContext* context,
|
||||
const SkMatrix& viewM,
|
||||
const SkMatrix* localMatrix,
|
||||
@ -364,9 +364,9 @@ const GrFragmentProcessor* SkTwoPointConicalGradient::asFragmentProcessor(
|
||||
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
|
||||
|
@ -57,7 +57,7 @@ public:
|
||||
|
||||
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,
|
||||
|
@ -61,11 +61,11 @@ static void set_matrix_edge_conical(const SkTwoPointConicalGradient& shader,
|
||||
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 @@ GR_DEFINE_FRAGMENT_PROCESSOR_TEST(Edge2PtConicalEffect);
|
||||
/*
|
||||
* 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 @@ const GrFragmentProcessor* Edge2PtConicalEffect::TestCreate(GrProcessorTestData*
|
||||
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 @@ static ConicalType set_matrix_focal_conical(const SkTwoPointConicalGradient& sha
|
||||
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 @@ GR_DEFINE_FRAGMENT_PROCESSOR_TEST(FocalOutside2PtConicalEffect);
|
||||
/*
|
||||
* 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 @@ const GrFragmentProcessor* FocalOutside2PtConicalEffect::TestCreate(GrProcessorT
|
||||
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 GLFocalInside2PtConicalEffect;
|
||||
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 @@ GR_DEFINE_FRAGMENT_PROCESSOR_TEST(FocalInside2PtConicalEffect);
|
||||
/*
|
||||
* 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 @@ const GrFragmentProcessor* FocalInside2PtConicalEffect::TestCreate(GrProcessorTe
|
||||
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 @@ static ConicalType set_matrix_circle_conical(const SkTwoPointConicalGradient& sh
|
||||
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 @@ GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleInside2PtConicalEffect);
|
||||
/*
|
||||
* 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 @@ const GrFragmentProcessor* CircleInside2PtConicalEffect::TestCreate(GrProcessorT
|
||||
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 @@ void GLCircleInside2PtConicalEffect::GenKey(const GrProcessor& processor,
|
||||
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 @@ GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleOutside2PtConicalEffect);
|
||||
/*
|
||||
* 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 @@ const GrFragmentProcessor* CircleOutside2PtConicalEffect::TestCreate(GrProcessor
|
||||
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 @@ void GLCircleOutside2PtConicalEffect::GenKey(const GrProcessor& processor,
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
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 @@ GrFragmentProcessor* Gr2PtConicalGradientEffect::Create(GrContext* ctx,
|
||||
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 @@ GrFragmentProcessor* Gr2PtConicalGradientEffect::Create(GrContext* ctx,
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,8 +18,8 @@ namespace Gr2PtConicalGradientEffect {
|
||||
* 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
|
||||
|
@ -35,8 +35,8 @@ static bool draw_mask(GrDrawContext* drawContext,
|
||||
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)) {
|
||||
|
@ -32,8 +32,8 @@ static const int kMaxAnalyticElements = 4;
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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 @@ static sk_sp<const GrFragmentProcessor> create_fp_for_mask(GrTexture* result,
|
||||
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 @@ static bool get_analytic_clip_processor(const GrReducedClip::ElementList& elemen
|
||||
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 @@ static bool get_analytic_clip_processor(const GrReducedClip::ElementList& elemen
|
||||
// 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 @@ static bool get_analytic_clip_processor(const GrReducedClip::ElementList& elemen
|
||||
|
||||
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 @@ bool GrClipMaskManager::SetupClipping(GrContext* context,
|
||||
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 @@ bool GrClipMaskManager::SetupClipping(GrContext* context,
|
||||
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 @@ bool GrClipMaskManager::CreateStencilClipMask(GrContext* context,
|
||||
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 @@ bool GrClipMaskManager::CreateStencilClipMask(GrContext* context,
|
||||
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;
|
||||
|
@ -317,12 +317,11 @@ bool GrContext::writeSurfacePixels(GrSurface* surface,
|
||||
// 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 @@ bool GrContext::writeSurfacePixels(GrSurface* surface,
|
||||
}
|
||||
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 @@ bool GrContext::writeSurfacePixels(GrSurface* surface,
|
||||
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 @@ bool GrContext::readSurfacePixels(GrSurface* src,
|
||||
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 @@ bool GrContext::readSurfacePixels(GrSurface* src,
|
||||
}
|
||||
}
|
||||
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 @@ bool GrContext::applyGamma(GrRenderTarget* dst, GrTexture* src, SkScalar gamma){
|
||||
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 @@ void GrContext::testPMConversionsIfNecessary(uint32_t flags) {
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ const GrFragmentProcessor* GrContext::createPMToUPMEffect(GrTexture* texture,
|
||||
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 @@ const GrFragmentProcessor* GrContext::createUPMToPMEffect(GrTexture* texture,
|
||||
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;
|
||||
}
|
||||
|
@ -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 @@ enum GPFlag {
|
||||
|
||||
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 @@ private:
|
||||
|
||||
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 @@ const GrGeometryProcessor* DefaultGeoProc::TestCreate(GrProcessorTestData* d) {
|
||||
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 @@ const GrGeometryProcessor* GrDefaultGeoProcFactory::Create(const Color& color,
|
||||
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 @@ const GrGeometryProcessor* GrDefaultGeoProcFactory::CreateForDeviceSpace(
|
||||
}
|
||||
|
||||
LocalCoords inverted(LocalCoords::kUsePosition_Type, &invert);
|
||||
return Create(color, coverage, inverted, SkMatrix::I());
|
||||
return Make(color, coverage, inverted, SkMatrix::I());
|
||||
}
|
||||
|
@ -115,20 +115,20 @@ namespace GrDefaultGeoProcFactory {
|
||||
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); }
|
||||
};
|
||||
|
@ -420,7 +420,7 @@ void GrDrawContextPriv::stencilRect(const GrFixedClip& clip,
|
||||
|
||||
GrPaint paint;
|
||||
paint.setAntiAlias(doAA);
|
||||
SkSafeUnref(paint.setXPFactory(GrDisableColorXPFactory::Create()));
|
||||
paint.setXPFactory(GrDisableColorXPFactory::Make());
|
||||
|
||||
bool useHWAA;
|
||||
SkAutoTUnref<GrDrawBatch> batch(
|
||||
@ -671,18 +671,18 @@ bool GrDrawContext::drawFilledDRRect(const GrClip& clip,
|
||||
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) {
|
||||
|
@ -245,9 +245,9 @@ void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder,
|
||||
|
||||
// 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 @@ void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder,
|
||||
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 @@ void GrDrawTarget::stencilPath(const GrPipelineBuilder& pipelineBuilder,
|
||||
|
||||
// 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 @@ void GrDrawTarget::clear(const SkIRect* rect,
|
||||
|
||||
// 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(
|
||||
|
@ -89,7 +89,7 @@ void GrFragmentProcessor::addCoordTransform(const GrCoordTransform* transform) {
|
||||
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 @@ int GrFragmentProcessor::registerChildProcessor(const GrFragmentProcessor* child
|
||||
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 @@ bool GrFragmentProcessor::hasSameTransforms(const GrFragmentProcessor& that) con
|
||||
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 @@ const GrFragmentProcessor* GrFragmentProcessor::MulOutputByInputUnpremulColor(
|
||||
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 @@ const GrFragmentProcessor* GrFragmentProcessor::OverrideInput(const GrFragmentPr
|
||||
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 @@ const GrFragmentProcessor* GrFragmentProcessor::RunInSeries(const GrFragmentProc
|
||||
|
||||
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 @@ const GrFragmentProcessor* GrFragmentProcessor::RunInSeries(const GrFragmentProc
|
||||
}
|
||||
|
||||
// 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));
|
||||
}
|
||||
|
@ -184,8 +184,9 @@ private:
|
||||
|
||||
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 @@ private:
|
||||
|
||||
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 @@ private:
|
||||
|
||||
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))));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -19,36 +19,34 @@ GrPaint::GrPaint()
|
||||
, 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) {
|
||||
|
@ -27,11 +27,11 @@ GrPipelineBuilder::GrPipelineBuilder(const GrPaint& paint, bool useHWAA)
|
||||
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 @@ void GrPipelineBuilder::AutoRestoreFragmentProcessorState::set(
|
||||
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 @@ void GrPipelineBuilder::AutoRestoreFragmentProcessorState::set(
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ public:
|
||||
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 @@ public:
|
||||
|
||||
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 @@ public:
|
||||
* 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 @@ public:
|
||||
* 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 @@ private:
|
||||
// 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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -189,10 +189,10 @@ void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture,
|
||||
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));
|
||||
|
@ -93,9 +93,9 @@ static GrTexture* copy_on_gpu(GrTexture* inputTexture, const SkIRect* subset,
|
||||
// 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 @@ static DomainMode determine_domain_mode(
|
||||
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 @@ static const GrFragmentProcessor* create_fp_for_domain_and_filter(
|
||||
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 @@ GrTexture* GrTextureMaker::refTextureForParams(const GrTextureParams& params,
|
||||
return result;
|
||||
}
|
||||
|
||||
const GrFragmentProcessor* GrTextureMaker::createFragmentProcessor(
|
||||
sk_sp<GrFragmentProcessor> GrTextureMaker::createFragmentProcessor(
|
||||
const SkMatrix& textureMatrix,
|
||||
const SkRect& constraintRect,
|
||||
FilterConstraint filterConstraint,
|
||||
|
@ -59,7 +59,7 @@ public:
|
||||
* @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 @@ public:
|
||||
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 @@ public:
|
||||
the texture. */
|
||||
GrTexture* refTextureForParams(const GrTextureParams&, SkSourceGammaTreatment);
|
||||
|
||||
const GrFragmentProcessor* createFragmentProcessor(
|
||||
sk_sp<GrFragmentProcessor> createFragmentProcessor(
|
||||
const SkMatrix& textureMatrix,
|
||||
const SkRect& constraintRect,
|
||||
FilterConstraint filterConstraint,
|
||||
|
@ -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 @@ static bool convert_texture(GrTexture* src, GrDrawContext* dst, int dstW, int ds
|
||||
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 @@ bool GrTextureToYUVPlanes(GrTexture* texture, const SkISize sizes[3], void* cons
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -121,13 +121,12 @@ sk_sp<GrTexture> GrYUVProvider::refAsTexture(GrContext* ctx,
|
||||
}
|
||||
|
||||
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 @@ sk_sp<GrTexture> GrYUVProvider::refAsTexture(GrContext* ctx,
|
||||
if (ctx->caps()->srgbWriteControl()) {
|
||||
paint.setDisableOutputConversionToSRGB(true);
|
||||
} else {
|
||||
paint.addColorFragmentProcessor(GrGammaEffect::Create(2.2f))->unref();
|
||||
paint.addColorFragmentProcessor(GrGammaEffect::Make(2.2f));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1198,7 +1198,7 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
|
||||
|
||||
// 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 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
|
||||
}
|
||||
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 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
|
||||
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 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
|
||||
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 @@ void SkGpuDevice::drawProducerNine(const SkDraw& draw, GrTextureProducer* produc
|
||||
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;
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ void SkGpuDevice::drawTextureProducerImpl(GrTextureProducer* producer,
|
||||
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) {
|
||||
|
@ -506,7 +506,7 @@ static inline bool blend_requires_shader(const SkXfermode::Mode mode, bool primi
|
||||
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 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context,
|
||||
|
||||
// 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 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context,
|
||||
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 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context,
|
||||
|
||||
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 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context,
|
||||
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 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context,
|
||||
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 @@ bool SkPaintToGrPaint(GrContext* context, const SkPaint& skPaint, const SkMatrix
|
||||
/** 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 SkPaintToGrPaintNoShader(GrContext* context,
|
||||
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 SkPaintToGrPaintWithXfermode(GrContext* context,
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user