| 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 GrXferProcessor_DEFINED | 8 #ifndef GrXferProcessor_DEFINED |
| 9 #define GrXferProcessor_DEFINED | 9 #define GrXferProcessor_DEFINED |
| 10 | 10 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 79 |
| 80 /** | 80 /** |
| 81 * Determines which optimizations (as described by the ptFlags above) can be
performed by | 81 * Determines which optimizations (as described by the ptFlags above) can be
performed by |
| 82 * the draw with this xfer processor. If this function is called, the xfer p
rocessor may change | 82 * the draw with this xfer processor. If this function is called, the xfer p
rocessor may change |
| 83 * its state to reflected the given blend optimizations. If the XP needs to
see a specific input | 83 * its state to reflected the given blend optimizations. If the XP needs to
see a specific input |
| 84 * color to blend correctly, it will set the OverrideColor flag and the outp
ut parameter | 84 * color to blend correctly, it will set the OverrideColor flag and the outp
ut parameter |
| 85 * overrideColor will be the required value that should be passed into the X
P. | 85 * overrideColor will be the required value that should be passed into the X
P. |
| 86 * A caller who calls this function on a XP is required to honor the returne
d OptFlags | 86 * A caller who calls this function on a XP is required to honor the returne
d OptFlags |
| 87 * and color values for its draw. | 87 * and color values for its draw. |
| 88 */ | 88 */ |
| 89 // TODO: remove need for isCoverageDrawing once coverageDrawing is its own X
P. | |
| 90 // TODO: remove need for colorWriteDisabled once colorWriteDisabled is its o
wn XP. | 89 // TODO: remove need for colorWriteDisabled once colorWriteDisabled is its o
wn XP. |
| 91 virtual OptFlags getOptimizations(const GrProcOptInfo& colorPOI, | 90 virtual OptFlags getOptimizations(const GrProcOptInfo& colorPOI, |
| 92 const GrProcOptInfo& coveragePOI, | 91 const GrProcOptInfo& coveragePOI, |
| 93 bool isCoverageDrawing, | |
| 94 bool colorWriteDisabled, | 92 bool colorWriteDisabled, |
| 95 bool doesStencilWrite, | 93 bool doesStencilWrite, |
| 96 GrColor* overrideColor, | 94 GrColor* overrideColor, |
| 97 const GrDrawTargetCaps& caps) = 0; | 95 const GrDrawTargetCaps& caps) = 0; |
| 98 | 96 |
| 99 struct BlendInfo { | 97 struct BlendInfo { |
| 100 GrBlendCoeff fSrcBlend; | 98 GrBlendCoeff fSrcBlend; |
| 101 GrBlendCoeff fDstBlend; | 99 GrBlendCoeff fDstBlend; |
| 102 GrColor fBlendConstant; | 100 GrColor fBlendConstant; |
| 103 }; | 101 }; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 120 A return value of true from isEqual() should not be used to test whether
the processor would | 118 A return value of true from isEqual() should not be used to test whether
the processor would |
| 121 generate the same shader code. To test for identical code generation use
getGLProcessorKey*/ | 119 generate the same shader code. To test for identical code generation use
getGLProcessorKey*/ |
| 122 | 120 |
| 123 bool isEqual(const GrXferProcessor& that) const { | 121 bool isEqual(const GrXferProcessor& that) const { |
| 124 if (this->classID() != that.classID()) { | 122 if (this->classID() != that.classID()) { |
| 125 return false; | 123 return false; |
| 126 } | 124 } |
| 127 return this->onIsEqual(that); | 125 return this->onIsEqual(that); |
| 128 } | 126 } |
| 129 | 127 |
| 130 | |
| 131 protected: | 128 protected: |
| 132 GrXferProcessor() : fWillReadDstColor(false) {} | 129 GrXferProcessor() : fWillReadDstColor(false) {} |
| 133 | 130 |
| 134 /** | 131 /** |
| 135 * If the prceossor subclass will read the destination pixel value then it m
ust call this | 132 * If the prceossor subclass will read the destination pixel value then it m
ust call this |
| 136 * function from its constructor. Otherwise, when its generated backend-spec
ific prceossor class | 133 * function from its constructor. Otherwise, when its generated backend-spec
ific prceossor class |
| 137 * attempts to generate code that reads the destination pixel it will fail. | 134 * attempts to generate code that reads the destination pixel it will fail. |
| 138 */ | 135 */ |
| 139 void setWillReadDstColor() { fWillReadDstColor = true; } | 136 void setWillReadDstColor() { fWillReadDstColor = true; } |
| 140 | 137 |
| 141 /** | |
| 142 * Subclass implements this to support getConstantColorComponents(...). | |
| 143 */ | |
| 144 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const = 0; | |
| 145 | |
| 146 private: | 138 private: |
| 147 virtual bool onIsEqual(const GrXferProcessor&) const = 0; | 139 virtual bool onIsEqual(const GrXferProcessor&) const = 0; |
| 148 | 140 |
| 149 bool fWillReadDstColor; | 141 bool fWillReadDstColor; |
| 150 | 142 |
| 151 typedef GrFragmentProcessor INHERITED; | 143 typedef GrFragmentProcessor INHERITED; |
| 152 }; | 144 }; |
| 153 | 145 |
| 154 GR_MAKE_BITFIELD_OPS(GrXferProcessor::OptFlags); | 146 GR_MAKE_BITFIELD_OPS(GrXferProcessor::OptFlags); |
| 155 | 147 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 174 * correctly blend when using RGB coverage. The knownColor and knownColorFla
gs represent the | 166 * correctly blend when using RGB coverage. The knownColor and knownColorFla
gs represent the |
| 175 * final computed color from the color stages. | 167 * final computed color from the color stages. |
| 176 */ | 168 */ |
| 177 virtual bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlag
s) const = 0; | 169 virtual bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlag
s) const = 0; |
| 178 | 170 |
| 179 /** | 171 /** |
| 180 * Depending on color blend mode requested it may or may not be possible to
correctly blend with | 172 * Depending on color blend mode requested it may or may not be possible to
correctly blend with |
| 181 * fractional pixel coverage generated by the fragment shader. | 173 * fractional pixel coverage generated by the fragment shader. |
| 182 * | 174 * |
| 183 * This function considers the known color and coverage input into the xfer
processor and | 175 * This function considers the known color and coverage input into the xfer
processor and |
| 184 * certain state information (isCoverageDrawing and colorWriteDisabled) to d
etermine whether | 176 * certain state information (colorWriteDisabled) to determine whether |
| 185 * coverage can be handled correctly. | 177 * coverage can be handled correctly. |
| 186 */ | 178 */ |
| 187 // TODO: remove need for isCoverageDrawing once coverageDrawing is its own X
P. | |
| 188 // TODO: remove need for colorWriteDisabled once colorWriteDisabled is its o
wn XP. | 179 // TODO: remove need for colorWriteDisabled once colorWriteDisabled is its o
wn XP. |
| 189 virtual bool canApplyCoverage(const GrProcOptInfo& colorPOI, const GrProcOpt
Info& coveragePOI, | 180 virtual bool canApplyCoverage(const GrProcOptInfo& colorPOI, const GrProcOpt
Info& coveragePOI, |
| 190 bool isCoverageDrawing, bool colorWriteDisable
d) const = 0; | 181 bool colorWriteDisabled) const = 0; |
| 191 | 182 |
| 192 /** | 183 /** |
| 193 * This function returns true if the destination pixel values will be read f
or blending during | 184 * This function returns true if the destination pixel values will be read f
or blending during |
| 194 * draw. | 185 * draw. |
| 195 */ | 186 */ |
| 196 // TODO: remove need for isCoverageDrawing once coverageDrawing is its own X
P. | |
| 197 // TODO: remove need for colorWriteDisabled once only XP can read dst. | 187 // TODO: remove need for colorWriteDisabled once only XP can read dst. |
| 198 virtual bool willBlendWithDst(const GrProcOptInfo& colorPOI, const GrProcOpt
Info& coveragePOI, | 188 virtual bool willBlendWithDst(const GrProcOptInfo& colorPOI, const GrProcOpt
Info& coveragePOI, |
| 199 bool isCoverageDrawing, bool colorWriteDisable
d) const = 0; | 189 bool colorWriteDisabled) const = 0; |
| 200 | 190 |
| 201 /** | 191 /** |
| 202 * Determines whether multiplying the computed per-pixel color by the pixel'
s fractional | 192 * Determines whether multiplying the computed per-pixel color by the pixel'
s fractional |
| 203 * coverage before the blend will give the correct final destination color.
In general it | 193 * coverage before the blend will give the correct final destination color.
In general it |
| 204 * will not as coverage is applied after blending. | 194 * will not as coverage is applied after blending. |
| 205 */ | 195 */ |
| 206 // TODO: remove need for isCoverageDrawing once coverageDrawing is its own X
P. | 196 virtual bool canTweakAlphaForCoverage() const = 0; |
| 207 virtual bool canTweakAlphaForCoverage(bool isCoverageDrawing) const = 0; | |
| 208 | 197 |
| 209 virtual bool getOpaqueAndKnownColor(const GrProcOptInfo& colorPOI, | 198 virtual bool getOpaqueAndKnownColor(const GrProcOptInfo& colorPOI, |
| 210 const GrProcOptInfo& coveragePOI, GrColo
r* solidColor, | 199 const GrProcOptInfo& coveragePOI, GrColo
r* solidColor, |
| 211 uint32_t* solidColorKnownComponents) con
st = 0; | 200 uint32_t* solidColorKnownComponents) con
st = 0; |
| 212 | 201 |
| 213 bool isEqual(const GrXPFactory& that) const { | 202 bool isEqual(const GrXPFactory& that) const { |
| 214 if (this->classID() != that.classID()) { | 203 if (this->classID() != that.classID()) { |
| 215 return false; | 204 return false; |
| 216 } | 205 } |
| 217 return this->onIsEqual(that); | 206 return this->onIsEqual(that); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 enum { | 241 enum { |
| 253 kIllegalXPFClassID = 0, | 242 kIllegalXPFClassID = 0, |
| 254 }; | 243 }; |
| 255 static int32_t gCurrXPFClassID; | 244 static int32_t gCurrXPFClassID; |
| 256 | 245 |
| 257 typedef GrProgramElement INHERITED; | 246 typedef GrProgramElement INHERITED; |
| 258 }; | 247 }; |
| 259 | 248 |
| 260 #endif | 249 #endif |
| 261 | 250 |
| OLD | NEW |