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

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

Issue 789343002: Revert of Create xfer processor backend. (Closed) Base URL: https://skia.googlesource.com/skia.git@xferBlendSolo
Patch Set: Created 6 years 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
« no previous file with comments | « include/gpu/GrProcessorUnitTest.h ('k') | include/gpu/effects/GrPorterDuffXferProcessor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "GrFragmentProcessor.h"
13 #include "GrTypes.h" 13 #include "GrTypes.h"
14 #include "SkXfermode.h" 14 #include "SkXfermode.h"
15 15
16 class GrDrawTargetCaps;
17 class GrGLCaps;
18 class GrGLXferProcessor;
19 class GrProcOptInfo; 16 class GrProcOptInfo;
20 17
21 /** 18 /**
22 * GrXferProcessor is responsible for implementing the xfer mode that blends the src color and dst 19 * GrXferProcessor is responsible for implementing the xfer mode that blends the src color and dst
23 * color. It does this by emitting fragment shader code and controlling the fixe d-function blend 20 * color. It does this by emitting fragment shader code and controlling the fixe d-function blend
24 * state. The inputs to its shader code are the final computed src color and fra ctional pixel 21 * state. The inputs to its shader code are the final computed src color and fra ctional pixel
25 * coverage. The GrXferProcessor's shader code writes the fragment shader output color that goes 22 * coverage. The GrXferProcessor's shader code writes the fragment shader output color that goes
26 * into the fixed-function blend. When dual-source blending is available, it may also write a 23 * into the fixed-function blend. When dual-source blending is available, it may also write a
27 * seconday fragment shader output color. When allowed by the backend API, the G rXferProcessor may 24 * seconday fragment shader output color. When allowed by the backend API, the G rXferProcessor may
28 * read the destination color. The GrXferProcessor is responsible for setting th e blend coefficients 25 * read the destination color. The GrXferProcessor is responsible for setting th e blend coefficients
29 * and blend constant color. 26 * and blend constant color.
30 * 27 *
31 * A GrXferProcessor is never installed directly into our draw state, but instea d is created from a 28 * A GrXferProcessor is never installed directly into our draw state, but instea d is created from a
32 * GrXPFactory once we have finalized the state of our draw. 29 * GrXPFactory once we have finalized the state of our draw.
33 */ 30 */
34 class GrXferProcessor : public GrProcessor { 31 class GrXferProcessor : public GrFragmentProcessor {
35 public: 32 public:
36 /** 33 /**
37 * Sets a unique key on the GrProcessorKeyBuilder that is directly associate d with this xfer
38 * processor's GL backend implementation.
39 */
40 virtual void getGLProcessorKey(const GrGLCaps& caps,
41 GrProcessorKeyBuilder* b) const = 0;
42
43 /** Returns a new instance of the appropriate *GL* implementation class
44 for the given GrXferProcessor; caller is responsible for deleting
45 the object. */
46 virtual GrGLXferProcessor* createGLInstance() const = 0;
47
48 /**
49 * Optimizations for blending / coverage that an OptDrawState should apply t o itself. 34 * Optimizations for blending / coverage that an OptDrawState should apply t o itself.
50 */ 35 */
51 enum OptFlags { 36 enum OptFlags {
52 /** 37 /**
53 * No optimizations needed 38 * No optimizations needed
54 */ 39 */
55 kNone_Opt = 0, 40 kNone_Opt = 0,
56 /** 41 /**
57 * The draw can be skipped completely. 42 * The draw can be skipped completely.
58 */ 43 */
(...skipping 23 matching lines...) Expand all
82 * and color/coverage values for its draw. 67 * and color/coverage values for its draw.
83 */ 68 */
84 // TODO: remove need for isCoverageDrawing once coverageDrawing is its own X P. 69 // TODO: remove need for isCoverageDrawing once coverageDrawing is its own X P.
85 // TODO: remove need for colorWriteDisabled once colorWriteDisabled is its o wn XP. 70 // TODO: remove need for colorWriteDisabled once colorWriteDisabled is its o wn XP.
86 virtual OptFlags getOptimizations(const GrProcOptInfo& colorPOI, 71 virtual OptFlags getOptimizations(const GrProcOptInfo& colorPOI,
87 const GrProcOptInfo& coveragePOI, 72 const GrProcOptInfo& coveragePOI,
88 bool isCoverageDrawing, 73 bool isCoverageDrawing,
89 bool colorWriteDisabled, 74 bool colorWriteDisabled,
90 bool doesStencilWrite, 75 bool doesStencilWrite,
91 GrColor* color, 76 GrColor* color,
92 uint8_t* coverage, 77 uint8_t* coverage) = 0;
93 const GrDrawTargetCaps& caps) = 0;
94 78
95 struct BlendInfo { 79 struct BlendInfo {
96 GrBlendCoeff fSrcBlend; 80 GrBlendCoeff fSrcBlend;
97 GrBlendCoeff fDstBlend; 81 GrBlendCoeff fDstBlend;
98 GrColor fBlendConstant; 82 GrColor fBlendConstant;
99 }; 83 };
100 84
101 virtual void getBlendInfo(BlendInfo* blendInfo) const = 0; 85 virtual void getBlendInfo(BlendInfo* blendInfo) const = 0;
102 86
103 /** Will this prceossor read the destination pixel value? */ 87 /** Will this prceossor read the destination pixel value? */
104 bool willReadDstColor() const { return fWillReadDstColor; } 88 bool willReadDstColor() const { return fWillReadDstColor; }
105 89
106 /**
107 * Returns whether or not this xferProcossor will set a secondary output to be used with dual
108 * source blending.
109 */
110 virtual bool hasSecondaryOutput() const { return false; }
111
112 /** Returns true if this and other processor conservatively draw identically . It can only return
113 true when the two processor are of the same subclass (i.e. they return t he same object from
114 from getFactory()).
115
116 A return value of true from isEqual() should not be used to test whether the processor would
117 generate the same shader code. To test for identical code generation use getGLProcessorKey*/
118
119 bool isEqual(const GrXferProcessor& that) const {
120 if (this->classID() != that.classID()) {
121 return false;
122 }
123 return this->onIsEqual(that);
124 }
125
126
127 protected: 90 protected:
128 GrXferProcessor() : fWillReadDstColor(false) {} 91 GrXferProcessor() : fWillReadDstColor(false) {}
129 92
130 /** 93 /**
131 * If the prceossor subclass will read the destination pixel value then it m ust call this 94 * If the prceossor subclass will read the destination pixel value then it m ust call this
132 * function from its constructor. Otherwise, when its generated backend-spec ific prceossor class 95 * function from its constructor. Otherwise, when its generated backend-spec ific prceossor class
133 * attempts to generate code that reads the destination pixel it will fail. 96 * attempts to generate code that reads the destination pixel it will fail.
134 */ 97 */
135 void setWillReadDstColor() { fWillReadDstColor = true; } 98 void setWillReadDstColor() { fWillReadDstColor = true; }
136 99
137 private: 100 private:
138 virtual bool onIsEqual(const GrXferProcessor&) const = 0;
139 101
140 bool fWillReadDstColor; 102 bool fWillReadDstColor;
141 103
142 typedef GrFragmentProcessor INHERITED; 104 typedef GrFragmentProcessor INHERITED;
143 }; 105 };
144 106
145 GR_MAKE_BITFIELD_OPS(GrXferProcessor::OptFlags); 107 GR_MAKE_BITFIELD_OPS(GrXferProcessor::OptFlags);
146 108
147 /** 109 /**
148 * We install a GrXPFactory (XPF) early on in the pipeline before all the final draw information is 110 * We install a GrXPFactory (XPF) early on in the pipeline before all the final draw information is
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 enum { 205 enum {
244 kIllegalXPFClassID = 0, 206 kIllegalXPFClassID = 0,
245 }; 207 };
246 static int32_t gCurrXPFClassID; 208 static int32_t gCurrXPFClassID;
247 209
248 typedef GrProgramElement INHERITED; 210 typedef GrProgramElement INHERITED;
249 }; 211 };
250 212
251 #endif 213 #endif
252 214
OLDNEW
« no previous file with comments | « include/gpu/GrProcessorUnitTest.h ('k') | include/gpu/effects/GrPorterDuffXferProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698