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

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

Issue 766653008: Revert of Make all blending up to GrOptDrawState be handled by the xp/xp factory. (Closed) Base URL: https://skia.googlesource.com/skia.git@xferFactorySolo
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/core/SkXfermode.h ('k') | include/gpu/GrXferProcessor.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #ifndef GrPaint_DEFINED 10 #ifndef GrPaint_DEFINED
11 #define GrPaint_DEFINED 11 #define GrPaint_DEFINED
12 12
13 #include "GrColor.h" 13 #include "GrColor.h"
14 #include "GrFragmentStage.h" 14 #include "GrFragmentStage.h"
15 #include "GrXferProcessor.h" 15 #include "GrXferProcessor.h"
16 #include "effects/GrPorterDuffXferProcessor.h"
17 16
18 #include "SkXfermode.h" 17 #include "SkXfermode.h"
19 18
20 /** 19 /**
21 * The paint describes how color and coverage are computed at each pixel by GrCo ntext draw 20 * The paint describes how color and coverage are computed at each pixel by GrCo ntext draw
22 * functions and the how color is blended with the destination pixel. 21 * functions and the how color is blended with the destination pixel.
23 * 22 *
24 * The paint allows installation of custom color and coverage stages. New types of stages are 23 * The paint allows installation of custom color and coverage stages. New types of stages are
25 * created by subclassing GrProcessor. 24 * created by subclassing GrProcessor.
26 * 25 *
(...skipping 18 matching lines...) Expand all
45 */ 44 */
46 class GrPaint { 45 class GrPaint {
47 public: 46 public:
48 GrPaint() { this->reset(); } 47 GrPaint() { this->reset(); }
49 48
50 GrPaint(const GrPaint& paint) { *this = paint; } 49 GrPaint(const GrPaint& paint) { *this = paint; }
51 50
52 ~GrPaint() {} 51 ~GrPaint() {}
53 52
54 /** 53 /**
54 * Sets the blending coefficients to use to blend the final primitive color with the
55 * destination color. Defaults to kOne for src and kZero for dst (i.e. src m ode).
56 */
57 void setBlendFunc(GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff) {
58 fSrcBlendCoeff = srcCoeff;
59 fDstBlendCoeff = dstCoeff;
60 }
61 GrBlendCoeff getSrcBlendCoeff() const { return fSrcBlendCoeff; }
62 GrBlendCoeff getDstBlendCoeff() const { return fDstBlendCoeff; }
63
64 /**
55 * The initial color of the drawn primitive. Defaults to solid white. 65 * The initial color of the drawn primitive. Defaults to solid white.
56 */ 66 */
57 void setColor(GrColor color) { fColor = color; } 67 void setColor(GrColor color) { fColor = color; }
58 GrColor getColor() const { return fColor; } 68 GrColor getColor() const { return fColor; }
59 69
60 /** 70 /**
61 * Should primitives be anti-aliased or not. Defaults to false. 71 * Should primitives be anti-aliased or not. Defaults to false.
62 */ 72 */
63 void setAntiAlias(bool aa) { fAntiAlias = aa; } 73 void setAntiAlias(bool aa) { fAntiAlias = aa; }
64 bool isAntiAlias() const { return fAntiAlias; } 74 bool isAntiAlias() const { return fAntiAlias; }
65 75
66 /** 76 /**
67 * Should dithering be applied. Defaults to false. 77 * Should dithering be applied. Defaults to false.
68 */ 78 */
69 void setDither(bool dither) { fDither = dither; } 79 void setDither(bool dither) { fDither = dither; }
70 bool isDither() const { return fDither; } 80 bool isDither() const { return fDither; }
71 81
72 const GrXPFactory* setXPFactory(const GrXPFactory* xpFactory) { 82 const GrXPFactory* setXPFactory(const GrXPFactory* xpFactory) {
73 fXPFactory.reset(SkRef(xpFactory)); 83 fXPFactory.reset(SkRef(xpFactory));
74 return xpFactory; 84 return xpFactory;
75 } 85 }
76 86
77 void setPorterDuffXPFactory(SkXfermode::Mode mode) {
78 fXPFactory.reset(GrPorterDuffXPFactory::Create(mode));
79 }
80
81 void setPorterDuffXPFactory(GrBlendCoeff src, GrBlendCoeff dst) {
82 fXPFactory.reset(GrPorterDuffXPFactory::Create(src, dst));
83 }
84
85 /** 87 /**
86 * Appends an additional color processor to the color computation. 88 * Appends an additional color processor to the color computation.
87 */ 89 */
88 const GrFragmentProcessor* addColorProcessor(const GrFragmentProcessor* fp) { 90 const GrFragmentProcessor* addColorProcessor(const GrFragmentProcessor* fp) {
89 SkASSERT(fp); 91 SkASSERT(fp);
90 SkNEW_APPEND_TO_TARRAY(&fColorStages, GrFragmentStage, (fp)); 92 SkNEW_APPEND_TO_TARRAY(&fColorStages, GrFragmentStage, (fp));
91 return fp; 93 return fp;
92 } 94 }
93 95
94 /** 96 /**
(...skipping 17 matching lines...) Expand all
112 int numColorStages() const { return fColorStages.count(); } 114 int numColorStages() const { return fColorStages.count(); }
113 int numCoverageStages() const { return fCoverageStages.count(); } 115 int numCoverageStages() const { return fCoverageStages.count(); }
114 int numTotalStages() const { return this->numColorStages() + this->numCovera geStages(); } 116 int numTotalStages() const { return this->numColorStages() + this->numCovera geStages(); }
115 117
116 const GrXPFactory* getXPFactory() const { return fXPFactory.get(); } 118 const GrXPFactory* getXPFactory() const { return fXPFactory.get(); }
117 119
118 const GrFragmentStage& getColorStage(int s) const { return fColorStages[s]; } 120 const GrFragmentStage& getColorStage(int s) const { return fColorStages[s]; }
119 const GrFragmentStage& getCoverageStage(int s) const { return fCoverageStage s[s]; } 121 const GrFragmentStage& getCoverageStage(int s) const { return fCoverageStage s[s]; }
120 122
121 GrPaint& operator=(const GrPaint& paint) { 123 GrPaint& operator=(const GrPaint& paint) {
124 fSrcBlendCoeff = paint.fSrcBlendCoeff;
125 fDstBlendCoeff = paint.fDstBlendCoeff;
122 fAntiAlias = paint.fAntiAlias; 126 fAntiAlias = paint.fAntiAlias;
123 fDither = paint.fDither; 127 fDither = paint.fDither;
124 128
125 fColor = paint.fColor; 129 fColor = paint.fColor;
126 130
127 fColorStages = paint.fColorStages; 131 fColorStages = paint.fColorStages;
128 fCoverageStages = paint.fCoverageStages; 132 fCoverageStages = paint.fCoverageStages;
129 133
130 fXPFactory.reset(SkRef(paint.getXPFactory())); 134 fXPFactory.reset(SkRef(paint.getXPFactory()));
131 135
132 return *this; 136 return *this;
133 } 137 }
134 138
135 /** 139 /**
136 * Resets the paint to the defaults. 140 * Resets the paint to the defaults.
137 */ 141 */
138 void reset() { 142 void reset() {
143 this->resetBlend();
139 this->resetOptions(); 144 this->resetOptions();
140 this->resetColor(); 145 this->resetColor();
141 this->resetStages(); 146 this->resetStages();
142 } 147 }
143 148
144 /** 149 /**
145 * Determines whether the drawing with this paint is opaque with respect to both color blending 150 * Determines whether the drawing with this paint is opaque with respect to both color blending
146 * and fractional coverage. It does not consider whether AA has been enabled on the paint or 151 * and fractional coverage. It does not consider whether AA has been enabled on the paint or
147 * not. Depending upon whether multisampling or coverage-based AA is in use, AA may make the 152 * not. Depending upon whether multisampling or coverage-based AA is in use, AA may make the
148 * result only apply to the interior of primitives. 153 * result only apply to the interior of primitives.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 return true; 204 return true;
200 } 205 }
201 206
202 friend class GrContext; // To access above two functions 207 friend class GrContext; // To access above two functions
203 friend class GrStencilAndCoverTextContext; // To access above two functions 208 friend class GrStencilAndCoverTextContext; // To access above two functions
204 209
205 SkAutoTUnref<const GrXPFactory> fXPFactory; 210 SkAutoTUnref<const GrXPFactory> fXPFactory;
206 SkSTArray<4, GrFragmentStage> fColorStages; 211 SkSTArray<4, GrFragmentStage> fColorStages;
207 SkSTArray<2, GrFragmentStage> fCoverageStages; 212 SkSTArray<2, GrFragmentStage> fCoverageStages;
208 213
214 GrBlendCoeff fSrcBlendCoeff;
215 GrBlendCoeff fDstBlendCoeff;
209 bool fAntiAlias; 216 bool fAntiAlias;
210 bool fDither; 217 bool fDither;
211 218
212 GrColor fColor; 219 GrColor fColor;
213 220
221 void resetBlend() {
222 fSrcBlendCoeff = kOne_GrBlendCoeff;
223 fDstBlendCoeff = kZero_GrBlendCoeff;
224 }
225
214 void resetOptions() { 226 void resetOptions() {
215 fAntiAlias = false; 227 fAntiAlias = false;
216 fDither = false; 228 fDither = false;
217 } 229 }
218 230
219 void resetColor() { 231 void resetColor() {
220 fColor = GrColorPackRGBA(0xff, 0xff, 0xff, 0xff); 232 fColor = GrColorPackRGBA(0xff, 0xff, 0xff, 0xff);
221 } 233 }
222 234
223 void resetStages(); 235 void resetStages();
224 }; 236 };
225 237
226 #endif 238 #endif
OLDNEW
« no previous file with comments | « include/core/SkXfermode.h ('k') | include/gpu/GrXferProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698