| 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 |
| 11 #include "GrColor.h" | 11 #include "GrColor.h" |
| 12 #include "GrProcessor.h" | 12 #include "GrProcessor.h" |
| 13 #include "GrTexture.h" | 13 #include "GrTexture.h" |
| 14 #include "GrTypes.h" | 14 #include "GrTypes.h" |
| 15 #include "SkXfermode.h" | 15 #include "SkXfermode.h" |
| 16 | 16 |
| 17 class GrDrawTargetCaps; | 17 class GrDrawTargetCaps; |
| 18 class GrGLCaps; | 18 class GrGLCaps; |
| 19 class GrGLXferProcessor; | 19 class GrGLXferProcessor; |
| 20 class GrProcOptInfo; | 20 class GrProcOptInfo; |
| 21 | 21 |
| 22 /** | 22 /** |
| 23 * Equations for alpha-blending. |
| 24 */ |
| 25 enum GrBlendEquation { |
| 26 kInvalid_GrBlendEquation = -1, |
| 27 |
| 28 // Basic blend equations. |
| 29 kAdd_GrBlendEquation, //<! Cs*S + Cd*D |
| 30 kSubtract_GrBlendEquation, //<! Cs*S - Cd*D |
| 31 kReverseSubtract_GrBlendEquation, //<! Cd*D - Cs*S |
| 32 |
| 33 kLastBasicGrBlendEquation = kReverseSubtract_GrBlendEquation, |
| 34 |
| 35 // Advanced blend equations. These are described in the SVG and PDF specs. |
| 36 kScreen_GrBlendEquation, |
| 37 kOverlay_GrBlendEquation, |
| 38 kDarken_GrBlendEquation, |
| 39 kLighten_GrBlendEquation, |
| 40 kColorDodge_GrBlendEquation, |
| 41 kColorBurn_GrBlendEquation, |
| 42 kHardLight_GrBlendEquation, |
| 43 kSoftLight_GrBlendEquation, |
| 44 kDifference_GrBlendEquation, |
| 45 kExclusion_GrBlendEquation, |
| 46 kMultiply_GrBlendEquation, |
| 47 kHSLHue_GrBlendEquation, |
| 48 kHSLSaturation_GrBlendEquation, |
| 49 kHSLColor_GrBlendEquation, |
| 50 kHSLLuminosity_GrBlendEquation, |
| 51 |
| 52 kTotalGrBlendEquationCount |
| 53 }; |
| 54 |
| 55 bool constexpr GrBlendEquationIsAdvanced(GrBlendEquation equation) { |
| 56 return equation > kLastBasicGrBlendEquation; |
| 57 } |
| 58 |
| 59 /** |
| 23 * Coeffecients for alpha-blending. | 60 * Coeffecients for alpha-blending. |
| 24 */ | 61 */ |
| 25 enum GrBlendCoeff { | 62 enum GrBlendCoeff { |
| 26 kInvalid_GrBlendCoeff = -1, | 63 kInvalid_GrBlendCoeff = -1, |
| 27 | 64 |
| 28 kZero_GrBlendCoeff, //<! 0 | 65 kZero_GrBlendCoeff, //<! 0 |
| 29 kOne_GrBlendCoeff, //<! 1 | 66 kOne_GrBlendCoeff, //<! 1 |
| 30 kSC_GrBlendCoeff, //<! src color | 67 kSC_GrBlendCoeff, //<! src color |
| 31 kISC_GrBlendCoeff, //<! one minus src color | 68 kISC_GrBlendCoeff, //<! one minus src color |
| 32 kDC_GrBlendCoeff, //<! dst color | 69 kDC_GrBlendCoeff, //<! dst color |
| (...skipping 13 matching lines...) Expand all Loading... |
| 46 | 83 |
| 47 kTotalGrBlendCoeffCount | 84 kTotalGrBlendCoeffCount |
| 48 }; | 85 }; |
| 49 | 86 |
| 50 /** | 87 /** |
| 51 * Barriers for blending. When a shader reads the dst directly, an Xfer barrier
is sometimes | 88 * Barriers for blending. When a shader reads the dst directly, an Xfer barrier
is sometimes |
| 52 * required after a pixel has been written, before it can be safely read again. | 89 * required after a pixel has been written, before it can be safely read again. |
| 53 */ | 90 */ |
| 54 enum GrXferBarrierType { | 91 enum GrXferBarrierType { |
| 55 kTexture_GrXferBarrierType, //<! Required when a shader reads and renders to
the same texture. | 92 kTexture_GrXferBarrierType, //<! Required when a shader reads and renders to
the same texture. |
| 93 kBlend_GrXferBarrierType, //<! Required by certain blend extensions. |
| 56 }; | 94 }; |
| 57 | 95 |
| 58 /** | 96 /** |
| 59 * GrXferProcessor is responsible for implementing the xfer mode that blends the
src color and dst | 97 * GrXferProcessor is responsible for implementing the xfer mode that blends the
src color and dst |
| 60 * color. It does this by emitting fragment shader code and controlling the fixe
d-function blend | 98 * color. It does this by emitting fragment shader code and controlling the fixe
d-function blend |
| 61 * state. The inputs to its shader code are the final computed src color and fra
ctional pixel | 99 * state. The inputs to its shader code are the final computed src color and fra
ctional pixel |
| 62 * coverage. The GrXferProcessor's shader code writes the fragment shader output
color that goes | 100 * coverage. The GrXferProcessor's shader code writes the fragment shader output
color that goes |
| 63 * into the fixed-function blend. When dual-source blending is available, it may
also write a | 101 * into the fixed-function blend. When dual-source blending is available, it may
also write a |
| 64 * seconday fragment shader output color. When allowed by the backend API, the G
rXferProcessor may | 102 * seconday fragment shader output color. When allowed by the backend API, the G
rXferProcessor may |
| 65 * read the destination color. The GrXferProcessor is responsible for setting th
e blend coefficients | 103 * read the destination color. The GrXferProcessor is responsible for setting th
e blend coefficients |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 172 |
| 135 /** | 173 /** |
| 136 * Returns whether this XP will require an Xfer barrier on the given rt. If
true, outBarrierType | 174 * Returns whether this XP will require an Xfer barrier on the given rt. If
true, outBarrierType |
| 137 * is updated to contain the type of barrier needed. | 175 * is updated to contain the type of barrier needed. |
| 138 */ | 176 */ |
| 139 virtual bool willNeedXferBarrier(const GrRenderTarget* rt, | 177 virtual bool willNeedXferBarrier(const GrRenderTarget* rt, |
| 140 const GrDrawTargetCaps& caps, | 178 const GrDrawTargetCaps& caps, |
| 141 GrXferBarrierType* outBarrierType) const; | 179 GrXferBarrierType* outBarrierType) const; |
| 142 | 180 |
| 143 struct BlendInfo { | 181 struct BlendInfo { |
| 144 GrBlendCoeff fSrcBlend; | 182 GrBlendEquation fEquation; |
| 145 GrBlendCoeff fDstBlend; | 183 GrBlendCoeff fSrcBlend; |
| 146 GrColor fBlendConstant; | 184 GrBlendCoeff fDstBlend; |
| 147 bool fWriteColor; | 185 GrColor fBlendConstant; |
| 186 bool fWriteColor; |
| 148 }; | 187 }; |
| 149 | 188 |
| 150 void getBlendInfo(BlendInfo* blendInfo) const { | 189 void getBlendInfo(BlendInfo* blendInfo) const { |
| 190 blendInfo->fEquation = kAdd_GrBlendEquation; |
| 151 blendInfo->fSrcBlend = kOne_GrBlendCoeff; | 191 blendInfo->fSrcBlend = kOne_GrBlendCoeff; |
| 152 blendInfo->fDstBlend = kZero_GrBlendCoeff; | 192 blendInfo->fDstBlend = kZero_GrBlendCoeff; |
| 153 blendInfo->fBlendConstant = 0; | 193 blendInfo->fBlendConstant = 0; |
| 154 blendInfo->fWriteColor = true; | 194 blendInfo->fWriteColor = true; |
| 155 this->onGetBlendInfo(blendInfo); | 195 this->onGetBlendInfo(blendInfo); |
| 156 } | 196 } |
| 157 | 197 |
| 158 bool willReadDstColor() const { return fWillReadDstColor; } | 198 bool willReadDstColor() const { return fWillReadDstColor; } |
| 159 | 199 |
| 160 /** | 200 /** |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 enum { | 377 enum { |
| 338 kIllegalXPFClassID = 0, | 378 kIllegalXPFClassID = 0, |
| 339 }; | 379 }; |
| 340 static int32_t gCurrXPFClassID; | 380 static int32_t gCurrXPFClassID; |
| 341 | 381 |
| 342 typedef GrProgramElement INHERITED; | 382 typedef GrProgramElement INHERITED; |
| 343 }; | 383 }; |
| 344 | 384 |
| 345 #endif | 385 #endif |
| 346 | 386 |
| OLD | NEW |