| Index: src/gpu/effects/GrConfigConversionEffect.cpp
|
| diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
|
| index 160773d81ecdd05844fc1bf137ed59f978d61721..f9a5262f9eea014f1884ca4a9c0bc3f026a8533e 100644
|
| --- a/src/gpu/effects/GrConfigConversionEffect.cpp
|
| +++ b/src/gpu/effects/GrConfigConversionEffect.cpp
|
| @@ -100,8 +100,8 @@ private:
|
| GrConfigConversionEffect::GrConfigConversionEffect(GrTexture* texture,
|
| bool swapRedAndBlue,
|
| PMConversion pmConversion,
|
| - const SkMatrix& matrix)
|
| - : INHERITED(texture, matrix)
|
| + const SkMatrix& matrix, GrRenderTarget* dst)
|
| + : INHERITED(texture, matrix, kLocal_GrCoordSet, dst)
|
| , fSwapRedAndBlue(swapRedAndBlue)
|
| , fPMConversion(pmConversion) {
|
| this->initClassID<GrConfigConversionEffect>();
|
| @@ -137,7 +137,7 @@ const GrFragmentProcessor* GrConfigConversionEffect::TestCreate(GrProcessorTestD
|
| swapRB = d->fRandom->nextBool();
|
| }
|
| return new GrConfigConversionEffect(d->fTextures[GrProcessorUnitTest::kSkiaPMTextureIdx],
|
| - swapRB, pmConv, GrTest::TestMatrix(d->fRandom));
|
| + swapRB, pmConv, GrTest::TestMatrix(d->fRandom), NULL);
|
| }
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
| @@ -152,6 +152,7 @@ GrGLFragmentProcessor* GrConfigConversionEffect::onCreateGLInstance() const {
|
| }
|
|
|
|
|
| +#include "GrDrawTarget.h"
|
|
|
| void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context,
|
| PMConversion* pmToUPMRule,
|
| @@ -189,12 +190,15 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
|
| if (!tempTex.get()) {
|
| return;
|
| }
|
| +
|
| desc.fFlags = kNone_GrSurfaceFlags;
|
| SkAutoTUnref<GrTexture> dataTex(context->textureProvider()->createTexture(desc, true, data, 0));
|
| if (!dataTex.get()) {
|
| return;
|
| }
|
|
|
| + dataTex->setException(true);
|
| +
|
| static const PMConversion kConversionRules[][2] = {
|
| {kDivByAlpha_RoundDown_PMConversion, kMulByAlpha_RoundUp_PMConversion},
|
| {kDivByAlpha_RoundUp_PMConversion, kMulByAlpha_RoundDown_PMConversion},
|
| @@ -202,6 +206,9 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
|
|
|
| bool failed = true;
|
|
|
| + SkAutoTUnref<GrDrawContext> readDrawContext;
|
| + SkAutoTUnref<GrDrawContext> tempDrawContext;
|
| +
|
| for (size_t i = 0; i < SK_ARRAY_COUNT(kConversionRules) && failed; ++i) {
|
| *pmToUPMRule = kConversionRules[i][0];
|
| *upmToPMRule = kConversionRules[i][1];
|
| @@ -216,20 +223,17 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
|
| GrPaint paint2;
|
| GrPaint paint3;
|
| SkAutoTUnref<GrFragmentProcessor> pmToUPM1(new GrConfigConversionEffect(
|
| - dataTex, false, *pmToUPMRule, SkMatrix::I()));
|
| + dataTex, false, *pmToUPMRule, SkMatrix::I(), readTex->asRenderTarget()));
|
| SkAutoTUnref<GrFragmentProcessor> upmToPM(new GrConfigConversionEffect(
|
| - readTex, false, *upmToPMRule, SkMatrix::I()));
|
| + readTex, false, *upmToPMRule, SkMatrix::I(), tempTex->asRenderTarget()));
|
| SkAutoTUnref<GrFragmentProcessor> pmToUPM2(new GrConfigConversionEffect(
|
| - tempTex, false, *pmToUPMRule, SkMatrix::I()));
|
| + tempTex, false, *pmToUPMRule, SkMatrix::I(), readTex->asRenderTarget()));
|
|
|
| paint1.addColorFragmentProcessor(pmToUPM1);
|
|
|
| -
|
| - SkAutoTUnref<GrDrawContext> readDrawContext(
|
| - context->drawContext(readTex->asRenderTarget()));
|
| + readDrawContext.reset(context->drawContext(readTex->asRenderTarget()));
|
| if (!readDrawContext) {
|
| - failed = true;
|
| - break;
|
| + return;
|
| }
|
|
|
| readDrawContext->fillRectToRect(GrClip::WideOpen(),
|
| @@ -242,12 +246,11 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
|
|
|
| paint2.addColorFragmentProcessor(upmToPM);
|
|
|
| - SkAutoTUnref<GrDrawContext> tempDrawContext(
|
| - context->drawContext(tempTex->asRenderTarget()));
|
| + tempDrawContext.reset(context->drawContext(tempTex->asRenderTarget()));
|
| if (!tempDrawContext) {
|
| - failed = true;
|
| - break;
|
| + return;
|
| }
|
| +
|
| tempDrawContext->fillRectToRect(GrClip::WideOpen(),
|
| paint2,
|
| SkMatrix::I(),
|
| @@ -256,10 +259,11 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
|
|
|
| paint3.addColorFragmentProcessor(pmToUPM2);
|
|
|
| + SkASSERT(readDrawContext);
|
| +
|
| readDrawContext.reset(context->drawContext(readTex->asRenderTarget()));
|
| if (!readDrawContext) {
|
| - failed = true;
|
| - break;
|
| + return;
|
| }
|
|
|
| readDrawContext->fillRectToRect(GrClip::WideOpen(),
|
| @@ -289,12 +293,12 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
|
| const GrFragmentProcessor* GrConfigConversionEffect::Create(GrTexture* texture,
|
| bool swapRedAndBlue,
|
| PMConversion pmConversion,
|
| - const SkMatrix& matrix) {
|
| + const SkMatrix& matrix, GrRenderTarget* dst) {
|
| if (!swapRedAndBlue && kNone_PMConversion == pmConversion) {
|
| // If we returned a GrConfigConversionEffect that was equivalent to a GrSimpleTextureEffect
|
| // then we may pollute our texture cache with redundant shaders. So in the case that no
|
| // conversions were requested we instead return a GrSimpleTextureEffect.
|
| - return GrSimpleTextureEffect::Create(texture, matrix);
|
| + return GrSimpleTextureEffect::Create(texture, matrix, kLocal_GrCoordSet, dst);
|
| } else {
|
| if (kRGBA_8888_GrPixelConfig != texture->config() &&
|
| kBGRA_8888_GrPixelConfig != texture->config() &&
|
| @@ -302,6 +306,6 @@ const GrFragmentProcessor* GrConfigConversionEffect::Create(GrTexture* texture,
|
| // The PM conversions assume colors are 0..255
|
| return nullptr;
|
| }
|
| - return new GrConfigConversionEffect(texture, swapRedAndBlue, pmConversion, matrix);
|
| + return new GrConfigConversionEffect(texture, swapRedAndBlue, pmConversion, matrix, dst);
|
| }
|
| }
|
|
|