| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrPorterDuffXferProcessor_DEFINED | 8 #ifndef GrPorterDuffXferProcessor_DEFINED |
| 9 #define GrPorterDuffXferProcessor_DEFINED | 9 #define GrPorterDuffXferProcessor_DEFINED |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 GrGLXferProcessor* createGLInstance() const SK_OVERRIDE; | 31 GrGLXferProcessor* createGLInstance() const SK_OVERRIDE; |
| 32 | 32 |
| 33 virtual bool hasSecondaryOutput() const SK_OVERRIDE; | 33 virtual bool hasSecondaryOutput() const SK_OVERRIDE; |
| 34 | 34 |
| 35 /////////////////////////////////////////////////////////////////////////// | 35 /////////////////////////////////////////////////////////////////////////// |
| 36 /// @name Stage Output Types | 36 /// @name Stage Output Types |
| 37 //// | 37 //// |
| 38 | 38 |
| 39 enum PrimaryOutputType { | 39 enum PrimaryOutputType { |
| 40 kNone_PrimaryOutputType, |
| 41 kColor_PrimaryOutputType, |
| 42 kCoverage_PrimaryOutputType, |
| 40 // Modulate color and coverage, write result as the color output. | 43 // Modulate color and coverage, write result as the color output. |
| 41 kModulate_PrimaryOutputType, | 44 kModulate_PrimaryOutputType, |
| 42 // Combines the coverage, dst, and color as coverage * color + (1 - cove
rage) * dst. This | 45 // Combines the coverage, dst, and color as coverage * color + (1 - cove
rage) * dst. This |
| 43 // can only be set if fDstReadKey is non-zero. | 46 // can only be set if fDstReadKey is non-zero. |
| 44 kCombineWithDst_PrimaryOutputType, | 47 kCombineWithDst_PrimaryOutputType, |
| 45 }; | 48 }; |
| 46 | 49 |
| 47 enum SecondaryOutputType { | 50 enum SecondaryOutputType { |
| 48 // There is no secondary output | 51 // There is no secondary output |
| 49 kNone_SecondaryOutputType, | 52 kNone_SecondaryOutputType, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 61 }; | 64 }; |
| 62 | 65 |
| 63 PrimaryOutputType primaryOutputType() const { return fPrimaryOutputType; } | 66 PrimaryOutputType primaryOutputType() const { return fPrimaryOutputType; } |
| 64 SecondaryOutputType secondaryOutputType() const { return fSecondaryOutputTyp
e; } | 67 SecondaryOutputType secondaryOutputType() const { return fSecondaryOutputTyp
e; } |
| 65 | 68 |
| 66 GrXferProcessor::OptFlags getOptimizations(const GrProcOptInfo& colorPOI, | 69 GrXferProcessor::OptFlags getOptimizations(const GrProcOptInfo& colorPOI, |
| 67 const GrProcOptInfo& coveragePOI, | 70 const GrProcOptInfo& coveragePOI, |
| 68 bool isCoverageDrawing, | 71 bool isCoverageDrawing, |
| 69 bool colorWriteDisabled, | 72 bool colorWriteDisabled, |
| 70 bool doesStencilWrite, | 73 bool doesStencilWrite, |
| 71 GrColor* color, | 74 GrColor* overrideColor, |
| 72 uint8_t* coverage, | |
| 73 const GrDrawTargetCaps& caps) SK_
OVERRIDE; | 75 const GrDrawTargetCaps& caps) SK_
OVERRIDE; |
| 74 | 76 |
| 75 void getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const SK_OVERRIDE { | 77 void getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const SK_OVERRIDE { |
| 76 blendInfo->fSrcBlend = fSrcBlend; | 78 blendInfo->fSrcBlend = fSrcBlend; |
| 77 blendInfo->fDstBlend = fDstBlend; | 79 blendInfo->fDstBlend = fDstBlend; |
| 78 blendInfo->fBlendConstant = fBlendConstant; | 80 blendInfo->fBlendConstant = fBlendConstant; |
| 79 } | 81 } |
| 80 | 82 |
| 81 private: | 83 private: |
| 82 GrPorterDuffXferProcessor(GrBlendCoeff srcBlend, GrBlendCoeff dstBlend, GrCo
lor constant); | 84 GrPorterDuffXferProcessor(GrBlendCoeff srcBlend, GrBlendCoeff dstBlend, GrCo
lor constant); |
| 83 | 85 |
| 84 bool onIsEqual(const GrXferProcessor& xpBase) const SK_OVERRIDE { | 86 bool onIsEqual(const GrXferProcessor& xpBase) const SK_OVERRIDE { |
| 85 const GrPorterDuffXferProcessor& xp = xpBase.cast<GrPorterDuffXferProces
sor>(); | 87 const GrPorterDuffXferProcessor& xp = xpBase.cast<GrPorterDuffXferProces
sor>(); |
| 86 if (fSrcBlend != xp.fSrcBlend || | 88 if (fSrcBlend != xp.fSrcBlend || |
| 87 fDstBlend != xp.fDstBlend || | 89 fDstBlend != xp.fDstBlend || |
| 88 fBlendConstant != xp.fBlendConstant || | 90 fBlendConstant != xp.fBlendConstant || |
| 89 fPrimaryOutputType != xp.fPrimaryOutputType || | 91 fPrimaryOutputType != xp.fPrimaryOutputType || |
| 90 fSecondaryOutputType != xp.fSecondaryOutputType) { | 92 fSecondaryOutputType != xp.fSecondaryOutputType) { |
| 91 return false; | 93 return false; |
| 92 } | 94 } |
| 93 return true; | 95 return true; |
| 94 } | 96 } |
| 95 | 97 |
| 96 void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE; | 98 void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE; |
| 97 | 99 |
| 98 GrXferProcessor::OptFlags internalGetOptimizations(const GrProcOptInfo& colo
rPOI, | 100 GrXferProcessor::OptFlags internalGetOptimizations(const GrProcOptInfo& colo
rPOI, |
| 99 const GrProcOptInfo& cove
ragePOI, | 101 const GrProcOptInfo& cove
ragePOI, |
| 100 bool isCoverageDrawing, | 102 bool isCoverageDrawing, |
| 101 bool colorWriteDisabled, | 103 bool colorWriteDisabled, |
| 102 bool doesStencilWrite, | 104 bool doesStencilWrite); |
| 103 GrColor* color, | |
| 104 uint8_t* coverage); | |
| 105 | 105 |
| 106 void calcOutputTypes(GrXferProcessor::OptFlags blendOpts, const GrDrawTarget
Caps& caps, | 106 void calcOutputTypes(GrXferProcessor::OptFlags blendOpts, const GrDrawTarget
Caps& caps, |
| 107 bool hasSolidCoverage, bool readDst); | 107 bool hasSolidCoverage, bool readDst); |
| 108 | 108 |
| 109 GrBlendCoeff fSrcBlend; | 109 GrBlendCoeff fSrcBlend; |
| 110 GrBlendCoeff fDstBlend; | 110 GrBlendCoeff fDstBlend; |
| 111 GrColor fBlendConstant; | 111 GrColor fBlendConstant; |
| 112 PrimaryOutputType fPrimaryOutputType; | 112 PrimaryOutputType fPrimaryOutputType; |
| 113 SecondaryOutputType fSecondaryOutputType; | 113 SecondaryOutputType fSecondaryOutputType; |
| 114 | 114 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 157 |
| 158 GR_DECLARE_XP_FACTORY_TEST; | 158 GR_DECLARE_XP_FACTORY_TEST; |
| 159 | 159 |
| 160 GrBlendCoeff fSrcCoeff; | 160 GrBlendCoeff fSrcCoeff; |
| 161 GrBlendCoeff fDstCoeff; | 161 GrBlendCoeff fDstCoeff; |
| 162 | 162 |
| 163 typedef GrXPFactory INHERITED; | 163 typedef GrXPFactory INHERITED; |
| 164 }; | 164 }; |
| 165 | 165 |
| 166 #endif | 166 #endif |
| OLD | NEW |