Chromium Code Reviews| Index: src/gpu/GrDrawState.h |
| diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h |
| index 39163ff5eed75f787b70f498d3dc0b76f8c6ecb9..f50cc16dfc25179179326b64af259cfd7521fcfb 100644 |
| --- a/src/gpu/GrDrawState.h |
| +++ b/src/gpu/GrDrawState.h |
| @@ -17,7 +17,9 @@ |
| #include "GrProcOptInfo.h" |
| #include "GrRenderTarget.h" |
| #include "GrStencil.h" |
| +#include "GrXferProcessor.h" |
| #include "SkMatrix.h" |
| +#include "effects/GrPorterDuffXferProcessor.h" |
| #include "effects/GrSimpleTextureEffect.h" |
| class GrDrawTargetCaps; |
| @@ -214,6 +216,23 @@ public: |
| */ |
| bool willEffectReadDstColor() const; |
| + /** |
| + * The xfer processor factory. |
| + */ |
| + const GrXPFactory* setXPFactory(const GrXPFactory* xpFactory) { |
| + fXPFactory.reset(SkRef(xpFactory)); |
| + return xpFactory; |
| + } |
| + |
| + void setPorterDuffXPFactory(SkXfermode::Mode mode) { |
| + fXPFactory.reset(GrPorterDuffXPFactory::Create(mode)); |
| + } |
| + |
| + void setPorterDuffXPFactory(GrBlendCoeff src, GrBlendCoeff dst) { |
| + fXPFactory.reset(GrPorterDuffXPFactory::Create(src, dst)); |
| + } |
| + |
| + |
|
bsalomon
2014/12/08 15:38:51
extra \n
egdaniel
2014/12/08 16:24:01
Done.
|
| const GrFragmentProcessor* addColorProcessor(const GrFragmentProcessor* effect) { |
| SkASSERT(effect); |
| SkNEW_APPEND_TO_TARRAY(&fColorStages, GrFragmentStage, (effect)); |
| @@ -332,15 +351,6 @@ public: |
| /// @name Blending |
| //// |
| - GrBlendCoeff getSrcBlendCoeff() const { return fSrcBlend; } |
| - GrBlendCoeff getDstBlendCoeff() const { return fDstBlend; } |
| - |
| - /** |
| - * Retrieves the last value set by setBlendConstant() |
| - * @return the blending constant value |
| - */ |
| - GrColor getBlendConstant() const { return fBlendConstant; } |
| - |
| /** |
| * Determines whether multiplying the computed per-pixel color by the pixel's fractional |
| * coverage before the blend will give the correct final destination color. In general it |
| @@ -348,44 +358,6 @@ public: |
| */ |
| bool canTweakAlphaForCoverage() const; |
| - /** |
| - * Sets the blending function coefficients. |
| - * |
| - * The blend function will be: |
| - * D' = sat(S*srcCoef + D*dstCoef) |
| - * |
| - * where D is the existing destination color, S is the incoming source |
| - * color, and D' is the new destination color that will be written. sat() |
| - * is the saturation function. |
| - * |
| - * @param srcCoef coefficient applied to the src color. |
| - * @param dstCoef coefficient applied to the dst color. |
| - */ |
| - void setBlendFunc(GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff) { |
| - fSrcBlend = srcCoeff; |
| - fDstBlend = dstCoeff; |
| - #ifdef SK_DEBUG |
| - if (GrBlendCoeffRefsDst(dstCoeff)) { |
| - SkDebugf("Unexpected dst blend coeff. Won't work correctly with coverage stages.\n"); |
| - } |
| - if (GrBlendCoeffRefsSrc(srcCoeff)) { |
| - SkDebugf("Unexpected src blend coeff. Won't work correctly with coverage stages.\n"); |
| - } |
| - #endif |
| - } |
| - |
| - /** |
| - * Sets the blending function constant referenced by the following blending |
| - * coefficients: |
| - * kConstC_GrBlendCoeff |
| - * kIConstC_GrBlendCoeff |
| - * kConstA_GrBlendCoeff |
| - * kIConstA_GrBlendCoeff |
| - * |
| - * @param constant the constant to set |
| - */ |
| - void setBlendConstant(GrColor constant) { fBlendConstant = constant; } |
| - |
| /// @} |
| /////////////////////////////////////////////////////////////////////////// |
| @@ -637,47 +609,6 @@ public: |
| private: |
| bool isEqual(const GrDrawState& that) const; |
| - /** |
| - * Optimizations for blending / coverage to that can be applied based on the current state. |
| - */ |
| - enum BlendOpt { |
| - /** |
| - * No optimization |
| - */ |
| - kNone_BlendOpt, |
| - /** |
| - * Don't draw at all |
| - */ |
| - kSkipDraw_BlendOpt, |
| - /** |
| - * The coverage value does not have to be computed separately from alpha, the the output |
| - * color can be the modulation of the two. |
| - */ |
| - kCoverageAsAlpha_BlendOpt, |
| - /** |
| - * Instead of emitting a src color, emit coverage in the alpha channel and r,g,b are |
| - * "don't cares". |
| - */ |
| - kEmitCoverage_BlendOpt, |
| - /** |
| - * Emit transparent black instead of the src color, no need to compute coverage. |
| - */ |
| - kEmitTransBlack_BlendOpt |
| - }; |
| - |
| - /** |
| - * Determines what optimizations can be applied based on the blend. The coefficients may have |
| - * to be tweaked in order for the optimization to work. srcCoeff and dstCoeff are optional |
| - * params that receive the tweaked coefficients. Normally the function looks at the current |
| - * state to see if coverage is enabled. By setting forceCoverage the caller can speculatively |
| - * determine the blend optimizations that would be used if there was partial pixel coverage. |
| - * |
| - * This is used internally and when constructing a GrOptDrawState. |
| - */ |
| - BlendOpt getBlendOpt(bool forceCoverage = false, |
| - GrBlendCoeff* srcCoeff = NULL, |
| - GrBlendCoeff* dstCoeff = NULL) const; |
| - |
| const GrProcOptInfo& colorProcInfo() const { |
| this->calcColorInvariantOutput(); |
| return fColorProcInfo; |
| @@ -716,13 +647,10 @@ private: |
| SkAutoTUnref<GrRenderTarget> fRenderTarget; |
| GrColor fColor; |
| SkMatrix fViewMatrix; |
| - GrColor fBlendConstant; |
| uint32_t fFlagBits; |
| GrStencilSettings fStencilSettings; |
| uint8_t fCoverage; |
| DrawFace fDrawFace; |
| - GrBlendCoeff fSrcBlend; |
| - GrBlendCoeff fDstBlend; |
| SkAutoTUnref<const GrGeometryProcessor> fGeometryProcessor; |
| SkAutoTUnref<const GrXPFactory> fXPFactory; |
| FragmentStageArray fColorStages; |