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

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: rebase, remove constexpr 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 inline bool 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
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 void reset() { 182 void reset() {
183 fEquation = kAdd_GrBlendEquation;
145 fSrcBlend = kOne_GrBlendCoeff; 184 fSrcBlend = kOne_GrBlendCoeff;
146 fDstBlend = kZero_GrBlendCoeff; 185 fDstBlend = kZero_GrBlendCoeff;
147 fBlendConstant = 0; 186 fBlendConstant = 0;
148 fWriteColor = true; 187 fWriteColor = true;
149 } 188 }
150 189
190 GrBlendEquation fEquation;
151 GrBlendCoeff fSrcBlend; 191 GrBlendCoeff fSrcBlend;
152 GrBlendCoeff fDstBlend; 192 GrBlendCoeff fDstBlend;
153 GrColor fBlendConstant; 193 GrColor fBlendConstant;
154 bool fWriteColor; 194 bool fWriteColor;
155 }; 195 };
156 196
157 void getBlendInfo(BlendInfo* blendInfo) const { 197 void getBlendInfo(BlendInfo* blendInfo) const {
158 blendInfo->reset(); 198 blendInfo->reset();
159 this->onGetBlendInfo(blendInfo); 199 this->onGetBlendInfo(blendInfo);
160 } 200 }
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 enum { 381 enum {
342 kIllegalXPFClassID = 0, 382 kIllegalXPFClassID = 0,
343 }; 383 };
344 static int32_t gCurrXPFClassID; 384 static int32_t gCurrXPFClassID;
345 385
346 typedef GrProgramElement INHERITED; 386 typedef GrProgramElement INHERITED;
347 }; 387 };
348 388
349 #endif 389 #endif
350 390
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698