Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: include/gpu/GrXferProcessor.h

Issue 1037123003: Implement support for KHR_blend_equation_advanced (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_zzz2_barriers
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 * A caller who calls this function on a XP is required to honor the returne d OptFlags 155 * A caller who calls this function on a XP is required to honor the returne d OptFlags
119 * and color values for its draw. 156 * and color values for its draw.
120 */ 157 */
121 virtual OptFlags getOptimizations(const GrProcOptInfo& colorPOI, 158 virtual OptFlags getOptimizations(const GrProcOptInfo& colorPOI,
122 const GrProcOptInfo& coveragePOI, 159 const GrProcOptInfo& coveragePOI,
123 bool doesStencilWrite, 160 bool doesStencilWrite,
124 GrColor* overrideColor, 161 GrColor* overrideColor,
125 const GrDrawTargetCaps& caps) = 0; 162 const GrDrawTargetCaps& caps) = 0;
126 163
127 struct BlendInfo { 164 struct BlendInfo {
128 GrBlendCoeff fSrcBlend; 165 GrBlendEquation fEquation;
129 GrBlendCoeff fDstBlend; 166 GrBlendCoeff fSrcBlend;
130 GrColor fBlendConstant; 167 GrBlendCoeff fDstBlend;
131 bool fWriteColor; 168 GrColor fBlendConstant;
169 bool fWriteColor;
132 }; 170 };
133 171
134 void getBlendInfo(BlendInfo* blendInfo) const { 172 void getBlendInfo(BlendInfo* blendInfo) const {
173 blendInfo->fEquation = kAdd_GrBlendEquation;
135 blendInfo->fSrcBlend = kOne_GrBlendCoeff; 174 blendInfo->fSrcBlend = kOne_GrBlendCoeff;
136 blendInfo->fDstBlend = kZero_GrBlendCoeff; 175 blendInfo->fDstBlend = kZero_GrBlendCoeff;
137 blendInfo->fBlendConstant = 0; 176 blendInfo->fBlendConstant = 0;
138 blendInfo->fWriteColor = true; 177 blendInfo->fWriteColor = true;
139 this->onGetBlendInfo(blendInfo); 178 this->onGetBlendInfo(blendInfo);
140 } 179 }
141 180
142 bool willReadDstColor() const { return fWillReadDstColor; } 181 bool willReadDstColor() const { return fWillReadDstColor; }
143 182
144 /** 183 /**
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 enum { 367 enum {
329 kIllegalXPFClassID = 0, 368 kIllegalXPFClassID = 0,
330 }; 369 };
331 static int32_t gCurrXPFClassID; 370 static int32_t gCurrXPFClassID;
332 371
333 typedef GrProgramElement INHERITED; 372 typedef GrProgramElement INHERITED;
334 }; 373 };
335 374
336 #endif 375 #endif
337 376
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698