diff options
-rw-r--r-- | gyp/gpu.gypi | 2 | ||||
-rw-r--r-- | include/gpu/GrPaint.h | 5 | ||||
-rw-r--r-- | include/gpu/GrTypes.h | 26 | ||||
-rw-r--r-- | include/gpu/GrXferProcessor.h | 28 | ||||
-rw-r--r-- | include/gpu/effects/GrCoverageSetOpXP.h (renamed from src/gpu/effects/GrCoverageSetOpXP.h) | 16 | ||||
-rw-r--r-- | include/gpu/effects/GrPorterDuffXferProcessor.h | 8 | ||||
-rw-r--r-- | src/effects/SkBlurMaskFilter.cpp | 11 | ||||
-rw-r--r-- | src/gpu/GrBlend.h | 1 | ||||
-rw-r--r-- | src/gpu/GrGpu.h | 15 | ||||
-rw-r--r-- | src/gpu/GrPaint.cpp | 5 | ||||
-rw-r--r-- | src/gpu/GrPipelineBuilder.h | 8 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 13 | ||||
-rw-r--r-- | src/gpu/effects/GrCoverageSetOpXP.cpp | 5 | ||||
-rw-r--r-- | src/gpu/effects/GrPorterDuffXferProcessor.cpp | 19 |
14 files changed, 60 insertions, 102 deletions
diff --git a/gyp/gpu.gypi b/gyp/gpu.gypi index ad3d357a15..68264f040c 100644 --- a/gyp/gpu.gypi +++ b/gyp/gpu.gypi @@ -34,6 +34,7 @@ '<(skia_include_path)/gpu/GrUserConfig.h', '<(skia_include_path)/gpu/GrXferProcessor.h', + '<(skia_include_path)/gpu/effects/GrCoverageSetOpXP.h', '<(skia_include_path)/gpu/effects/GrCustomXfermode.h', '<(skia_include_path)/gpu/effects/GrPorterDuffXferProcessor.h', @@ -186,7 +187,6 @@ '<(skia_src_path)/gpu/effects/GrConfigConversionEffect.cpp', '<(skia_src_path)/gpu/effects/GrConfigConversionEffect.h', '<(skia_src_path)/gpu/effects/GrCoverageSetOpXP.cpp', - '<(skia_src_path)/gpu/effects/GrCoverageSetOpXP.h', '<(skia_src_path)/gpu/effects/GrCustomXfermode.cpp', '<(skia_src_path)/gpu/effects/GrCustomXfermodePriv.h', '<(skia_src_path)/gpu/effects/GrBezierEffect.cpp', diff --git a/include/gpu/GrPaint.h b/include/gpu/GrPaint.h index 64b51d2c65..bf29693115 100644 --- a/include/gpu/GrPaint.h +++ b/include/gpu/GrPaint.h @@ -15,6 +15,7 @@ #include "GrXferProcessor.h" #include "effects/GrPorterDuffXferProcessor.h" +#include "SkRegion.h" #include "SkXfermode.h" /** @@ -70,9 +71,7 @@ public: fXPFactory.reset(GrPorterDuffXPFactory::Create(mode)); } - void setPorterDuffXPFactory(GrBlendCoeff src, GrBlendCoeff dst) { - fXPFactory.reset(GrPorterDuffXPFactory::Create(src, dst)); - } + void setCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage = false); /** * Appends an additional color processor to the color computation. diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h index 7532984ebe..7fbe432875 100644 --- a/include/gpu/GrTypes.h +++ b/include/gpu/GrTypes.h @@ -156,32 +156,6 @@ static inline bool GrIsPrimTypeTris(GrPrimitiveType type) { } /** - * Coeffecients for alpha-blending. - */ -enum GrBlendCoeff { - kInvalid_GrBlendCoeff = -1, - - kZero_GrBlendCoeff, //<! 0 - kOne_GrBlendCoeff, //<! 1 - kSC_GrBlendCoeff, //<! src color - kISC_GrBlendCoeff, //<! one minus src color - kDC_GrBlendCoeff, //<! dst color - kIDC_GrBlendCoeff, //<! one minus dst color - kSA_GrBlendCoeff, //<! src alpha - kISA_GrBlendCoeff, //<! one minus src alpha - kDA_GrBlendCoeff, //<! dst alpha - kIDA_GrBlendCoeff, //<! one minus dst alpha - kConstC_GrBlendCoeff, //<! constant color - kIConstC_GrBlendCoeff, //<! one minus constant color - kConstA_GrBlendCoeff, //<! constant color alpha - kIConstA_GrBlendCoeff, //<! one minus constant color alpha - - kFirstPublicGrBlendCoeff = kZero_GrBlendCoeff, - kLastPublicGrBlendCoeff = kIConstA_GrBlendCoeff, -}; -static const int kPublicGrBlendCoeffCount = kLastPublicGrBlendCoeff + 1; - -/** * Formats for masks, used by the font cache. * Important that these are 0-based. */ diff --git a/include/gpu/GrXferProcessor.h b/include/gpu/GrXferProcessor.h index 312e769224..b9adb66a1c 100644 --- a/include/gpu/GrXferProcessor.h +++ b/include/gpu/GrXferProcessor.h @@ -20,6 +20,34 @@ class GrGLXferProcessor; class GrProcOptInfo; /** + * Coeffecients for alpha-blending. + */ +enum GrBlendCoeff { + kInvalid_GrBlendCoeff = -1, + + kZero_GrBlendCoeff, //<! 0 + kOne_GrBlendCoeff, //<! 1 + kSC_GrBlendCoeff, //<! src color + kISC_GrBlendCoeff, //<! one minus src color + kDC_GrBlendCoeff, //<! dst color + kIDC_GrBlendCoeff, //<! one minus dst color + kSA_GrBlendCoeff, //<! src alpha + kISA_GrBlendCoeff, //<! one minus src alpha + kDA_GrBlendCoeff, //<! dst alpha + kIDA_GrBlendCoeff, //<! one minus dst alpha + kConstC_GrBlendCoeff, //<! constant color + kIConstC_GrBlendCoeff, //<! one minus constant color + kConstA_GrBlendCoeff, //<! constant color alpha + kIConstA_GrBlendCoeff, //<! one minus constant color alpha + kS2C_GrBlendCoeff, + kIS2C_GrBlendCoeff, + kS2A_GrBlendCoeff, + kIS2A_GrBlendCoeff, + + kTotalGrBlendCoeffCount +}; + +/** * GrXferProcessor is responsible for implementing the xfer mode that blends the src color and dst * color. It does this by emitting fragment shader code and controlling the fixed-function blend * state. The inputs to its shader code are the final computed src color and fractional pixel diff --git a/src/gpu/effects/GrCoverageSetOpXP.h b/include/gpu/effects/GrCoverageSetOpXP.h index 01dce95211..e781999a1d 100644 --- a/src/gpu/effects/GrCoverageSetOpXP.h +++ b/include/gpu/effects/GrCoverageSetOpXP.h @@ -14,16 +14,22 @@ class GrProcOptInfo; +/** + * This xfer processor directly blends the the src coverage with the dst using a set operator. It is + * useful for rendering coverage masks using CSG. It can optionally invert the src coverage before + * applying the set operator. + */ class GrCoverageSetOpXPFactory : public GrXPFactory { public: static GrXPFactory* Create(SkRegion::Op regionOp, bool invertCoverage = false); - bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const SK_OVERRIDE { + bool supportsRGBCoverage(GrColor /*knownColor*/, + uint32_t /*knownColorFlags*/) const SK_OVERRIDE { return true; } - bool canApplyCoverage(const GrProcOptInfo& colorPOI, - const GrProcOptInfo& coveragePOI) const SK_OVERRIDE { + bool canApplyCoverage(const GrProcOptInfo& /*colorPOI*/, + const GrProcOptInfo& /*coveragePOI*/) const SK_OVERRIDE { return true; } @@ -39,8 +45,8 @@ private: const GrProcOptInfo& coveragePOI, const GrDeviceCoordTexture* dstCopy) const SK_OVERRIDE; - bool willReadDstColor(const GrProcOptInfo& colorPOI, - const GrProcOptInfo& coveragePOI) const SK_OVERRIDE { + bool willReadDstColor(const GrProcOptInfo& /*colorPOI*/, + const GrProcOptInfo& /*coveragePOI*/) const SK_OVERRIDE { return false; } diff --git a/include/gpu/effects/GrPorterDuffXferProcessor.h b/include/gpu/effects/GrPorterDuffXferProcessor.h index 1bd199370e..0d3b01ff4d 100644 --- a/include/gpu/effects/GrPorterDuffXferProcessor.h +++ b/include/gpu/effects/GrPorterDuffXferProcessor.h @@ -18,14 +18,6 @@ class GrPorterDuffXPFactory : public GrXPFactory { public: static GrXPFactory* Create(SkXfermode::Mode mode); - static GrXPFactory* Create(SkXfermode::Coeff src, SkXfermode::Coeff dst) { - return SkNEW_ARGS(GrPorterDuffXPFactory, ((GrBlendCoeff)(src), (GrBlendCoeff)(dst))); - } - - static GrXPFactory* Create(GrBlendCoeff src, GrBlendCoeff dst) { - return SkNEW_ARGS(GrPorterDuffXPFactory, (src, dst)); - } - bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const SK_OVERRIDE; bool canApplyCoverage(const GrProcOptInfo& colorPOI, diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp index b521546a80..bfc5a5c420 100644 --- a/src/effects/SkBlurMaskFilter.cpp +++ b/src/effects/SkBlurMaskFilter.cpp @@ -24,7 +24,6 @@ #include "GrInvariantOutput.h" #include "SkGrPixelRef.h" #include "SkDraw.h" -#include "effects/GrPorterDuffXferProcessor.h" #include "effects/GrSimpleTextureEffect.h" #include "gl/GrGLProcessor.h" #include "gl/builders/GrGLProgramBuilder.h" @@ -1217,18 +1216,18 @@ bool SkBlurMaskFilterImpl::filterMaskGPU(GrTexture* src, matrix.setIDiv(src->width(), src->height()); // Blend pathTexture over blurTexture. GrContext::AutoRenderTarget art(context, (*result)->asRenderTarget()); - paint.addColorProcessor(GrSimpleTextureEffect::Create(src, matrix))->unref(); + paint.addCoverageProcessor(GrSimpleTextureEffect::Create(src, matrix))->unref(); if (kInner_SkBlurStyle == fBlurStyle) { // inner: dst = dst * src - paint.setPorterDuffXPFactory(kDC_GrBlendCoeff, kZero_GrBlendCoeff); + paint.setCoverageSetOpXPFactory(SkRegion::kIntersect_Op); } else if (kSolid_SkBlurStyle == fBlurStyle) { // solid: dst = src + dst - src * dst - // = (1 - dst) * src + 1 * dst - paint.setPorterDuffXPFactory(kIDC_GrBlendCoeff, kOne_GrBlendCoeff); + // = src + (1 - src) * dst + paint.setCoverageSetOpXPFactory(SkRegion::kUnion_Op); } else if (kOuter_SkBlurStyle == fBlurStyle) { // outer: dst = dst * (1 - src) // = 0 * src + (1 - src) * dst - paint.setPorterDuffXPFactory(kZero_GrBlendCoeff, kISC_GrBlendCoeff); + paint.setCoverageSetOpXPFactory(SkRegion::kDifference_Op); } context->drawRect(paint, SkMatrix::I(), clipRect); } diff --git a/src/gpu/GrBlend.h b/src/gpu/GrBlend.h index e70d945777..e5b8993377 100644 --- a/src/gpu/GrBlend.h +++ b/src/gpu/GrBlend.h @@ -8,6 +8,7 @@ #include "GrTypes.h" #include "GrColor.h" +#include "GrXferProcessor.h" #ifndef GrBlend_DEFINED #define GrBlend_DEFINED diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h index 8a3c32b7ab..2d5eaba8e8 100644 --- a/src/gpu/GrGpu.h +++ b/src/gpu/GrGpu.h @@ -27,21 +27,6 @@ class GrVertexBufferAllocPool; class GrGpu : public SkRefCnt { public: /** - * Additional blend coefficients for dual source blending, not exposed - * through GrPaint/GrContext. - */ - enum ExtendedBlendCoeffs { - // source 2 refers to second output color when - // using dual source blending. - kS2C_GrBlendCoeff = kPublicGrBlendCoeffCount, - kIS2C_GrBlendCoeff, - kS2A_GrBlendCoeff, - kIS2A_GrBlendCoeff, - - kTotalGrBlendCoeffCount - }; - - /** * Create an instance of GrGpu that matches the specified backend. If the requested backend is * not supported (at compile-time or run-time) this returns NULL. The context will not be * fully constructed and should not be used by GrGpu until after this function returns. diff --git a/src/gpu/GrPaint.cpp b/src/gpu/GrPaint.cpp index d35b41feb3..c9cebad9d8 100644 --- a/src/gpu/GrPaint.cpp +++ b/src/gpu/GrPaint.cpp @@ -9,6 +9,7 @@ #include "GrPaint.h" #include "GrProcOptInfo.h" +#include "effects/GrCoverageSetOpXP.h" #include "effects/GrPorterDuffXferProcessor.h" #include "effects/GrSimpleTextureEffect.h" @@ -18,6 +19,10 @@ GrPaint::GrPaint() , fColor(GrColor_WHITE) { } +void GrPaint::setCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage) { + fXPFactory.reset(GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage)); +} + void GrPaint::addColorTextureProcessor(GrTexture* texture, const SkMatrix& matrix) { this->addColorProcessor(GrSimpleTextureEffect::Create(texture, matrix))->unref(); } diff --git a/src/gpu/GrPipelineBuilder.h b/src/gpu/GrPipelineBuilder.h index 72f8e28c57..ad509e14f8 100644 --- a/src/gpu/GrPipelineBuilder.h +++ b/src/gpu/GrPipelineBuilder.h @@ -114,14 +114,6 @@ public: return xpFactory; } - void setPorterDuffXPFactory(SkXfermode::Mode mode) { - fXPFactory.reset(GrPorterDuffXPFactory::Create(mode)); - } - - void setPorterDuffXPFactory(GrBlendCoeff src, GrBlendCoeff dst) { - fXPFactory.reset(GrPorterDuffXPFactory::Create(src, dst)); - } - void setCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage = false) { fXPFactory.reset(GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage)); } diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 8912851d8f..b6cc69d858 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -9,7 +9,6 @@ #include "effects/GrBicubicEffect.h" #include "effects/GrDashingEffect.h" -#include "effects/GrPorterDuffXferProcessor.h" #include "effects/GrTextureDomain.h" #include "effects/GrSimpleTextureEffect.h" @@ -677,16 +676,8 @@ GrTexture* create_mask_GPU(GrContext* context, context->clear(NULL, 0x0, true, mask->asRenderTarget()); GrPaint tempPaint; - if (doAA) { - tempPaint.setAntiAlias(true); - // AA uses the "coverage" stages on GrDrawTarget. Coverage with a dst - // blend coeff of zero requires dual source blending support in order - // to properly blend partially covered pixels. This means the AA - // code path may not be taken. So we use a dst blend coeff of ISA. We - // could special case AA draws to a dst surface with known alpha=0 to - // use a zero dst coeff when dual source blending isn't available. - tempPaint.setPorterDuffXPFactory(kOne_GrBlendCoeff, kISC_GrBlendCoeff); - } + tempPaint.setAntiAlias(doAA); + tempPaint.setCoverageSetOpXPFactory(SkRegion::kReplace_Op); // Draw the mask into maskTexture with the path's top-left at the origin using tempPaint. SkMatrix translate; diff --git a/src/gpu/effects/GrCoverageSetOpXP.cpp b/src/gpu/effects/GrCoverageSetOpXP.cpp index f0ec1f9b00..2b262116f0 100644 --- a/src/gpu/effects/GrCoverageSetOpXP.cpp +++ b/src/gpu/effects/GrCoverageSetOpXP.cpp @@ -15,11 +15,6 @@ #include "gl/builders/GrGLFragmentShaderBuilder.h" #include "gl/builders/GrGLProgramBuilder.h" -/** - * This xfer processor directly blends the the src coverage with the dst using a set operator. It is - * useful for rendering coverage masks using CSG. It can optionally invert the src coverage before - * applying the set operator. - * */ class CoverageSetOpXP : public GrXferProcessor { public: static GrXferProcessor* Create(SkRegion::Op regionOp, bool invertCoverage) { diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.cpp b/src/gpu/effects/GrPorterDuffXferProcessor.cpp index 428b76a38a..a08776a20f 100644 --- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp +++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp @@ -266,15 +266,15 @@ void PorterDuffXferProcessor::calcOutputTypes(GrXferProcessor::OptFlags optFlags if (kZero_GrBlendCoeff == fDstBlend) { // write the coverage value to second color fSecondaryOutputType = kCoverage_SecondaryOutputType; - fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; + fDstBlend = kIS2C_GrBlendCoeff; } else if (kSA_GrBlendCoeff == fDstBlend) { // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered. fSecondaryOutputType = kCoverageISA_SecondaryOutputType; - fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; + fDstBlend = kIS2C_GrBlendCoeff; } else if (kSC_GrBlendCoeff == fDstBlend) { // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered. fSecondaryOutputType = kCoverageISC_SecondaryOutputType; - fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; + fDstBlend = kIS2C_GrBlendCoeff; } } } @@ -617,16 +617,7 @@ GrXPFactory* GrPorterDuffXPFactory::TestCreate(SkRandom* random, GrContext*, const GrDrawTargetCaps&, GrTexture*[]) { - GrBlendCoeff src; - do { - src = GrBlendCoeff(random->nextRangeU(kFirstPublicGrBlendCoeff, kLastPublicGrBlendCoeff)); - } while (GrBlendCoeffRefsSrc(src)); - - GrBlendCoeff dst; - do { - dst = GrBlendCoeff(random->nextRangeU(kFirstPublicGrBlendCoeff, kLastPublicGrBlendCoeff)); - } while (GrBlendCoeffRefsDst(dst)); - - return GrPorterDuffXPFactory::Create(src, dst); + SkXfermode::Mode mode = SkXfermode::Mode(random->nextULessThan(SkXfermode::kLastCoeffMode)); + return GrPorterDuffXPFactory::Create(mode); } |