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

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

Issue 866573002: XPFactory lazily initializie in drawstate / GrPaint (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: cleanup Created 5 years, 11 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
« no previous file with comments | « include/gpu/GrContext.h ('k') | src/effects/SkGpuBlurUtils.cpp » ('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
(...skipping 27 matching lines...) Expand all
38 * of the destination pixel, labeled Bs and Bd respectively. The final value of the destination 38 * of the destination pixel, labeled Bs and Bd respectively. The final value of the destination
39 * pixel is then D' = (1-C)*D + C*(Bd*D + Bs*S). 39 * pixel is then D' = (1-C)*D + C*(Bd*D + Bs*S).
40 * 40 *
41 * Note that the coverage is applied after the blend. This is why they are compu ted as distinct 41 * Note that the coverage is applied after the blend. This is why they are compu ted as distinct
42 * values. 42 * values.
43 * 43 *
44 * TODO: Encapsulate setXfermodeColorFilter in a GrProcessor and remove from GrP aint. 44 * TODO: Encapsulate setXfermodeColorFilter in a GrProcessor and remove from GrP aint.
45 */ 45 */
46 class GrPaint { 46 class GrPaint {
47 public: 47 public:
48 GrPaint() { this->reset(); } 48 GrPaint();
49 49
50 GrPaint(const GrPaint& paint) { *this = paint; } 50 GrPaint(const GrPaint& paint) { *this = paint; }
51 51
52 ~GrPaint() {} 52 ~GrPaint() {}
53 53
54 /** 54 /**
55 * The initial color of the drawn primitive. Defaults to solid white. 55 * The initial color of the drawn primitive. Defaults to solid white.
56 */ 56 */
57 void setColor(GrColor color) { fColor = color; } 57 void setColor(GrColor color) { fColor = color; }
58 GrColor getColor() const { return fColor; } 58 GrColor getColor() const { return fColor; }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 */ 106 */
107 void addColorTextureProcessor(GrTexture*, const SkMatrix&); 107 void addColorTextureProcessor(GrTexture*, const SkMatrix&);
108 void addCoverageTextureProcessor(GrTexture*, const SkMatrix&); 108 void addCoverageTextureProcessor(GrTexture*, const SkMatrix&);
109 void addColorTextureProcessor(GrTexture*, const SkMatrix&, const GrTexturePa rams&); 109 void addColorTextureProcessor(GrTexture*, const SkMatrix&, const GrTexturePa rams&);
110 void addCoverageTextureProcessor(GrTexture*, const SkMatrix&, const GrTextur eParams&); 110 void addCoverageTextureProcessor(GrTexture*, const SkMatrix&, const GrTextur eParams&);
111 111
112 int numColorStages() const { return fColorStages.count(); } 112 int numColorStages() const { return fColorStages.count(); }
113 int numCoverageStages() const { return fCoverageStages.count(); } 113 int numCoverageStages() const { return fCoverageStages.count(); }
114 int numTotalStages() const { return this->numColorStages() + this->numCovera geStages(); } 114 int numTotalStages() const { return this->numColorStages() + this->numCovera geStages(); }
115 115
116 const GrXPFactory* getXPFactory() const { return fXPFactory.get(); } 116 const GrXPFactory* getXPFactory() const {
117 if (!fXPFactory) {
118 fXPFactory.reset(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode ));
119 }
120 return fXPFactory.get();
121 }
117 122
118 const GrFragmentStage& getColorStage(int s) const { return fColorStages[s]; } 123 const GrFragmentStage& getColorStage(int s) const { return fColorStages[s]; }
119 const GrFragmentStage& getCoverageStage(int s) const { return fCoverageStage s[s]; } 124 const GrFragmentStage& getCoverageStage(int s) const { return fCoverageStage s[s]; }
120 125
121 GrPaint& operator=(const GrPaint& paint) { 126 GrPaint& operator=(const GrPaint& paint) {
122 fAntiAlias = paint.fAntiAlias; 127 fAntiAlias = paint.fAntiAlias;
123 fDither = paint.fDither; 128 fDither = paint.fDither;
124 129
125 fColor = paint.fColor; 130 fColor = paint.fColor;
126 131
127 fColorStages = paint.fColorStages; 132 fColorStages = paint.fColorStages;
128 fCoverageStages = paint.fCoverageStages; 133 fCoverageStages = paint.fCoverageStages;
129 134
130 fXPFactory.reset(SkRef(paint.getXPFactory())); 135 fXPFactory.reset(SkRef(paint.getXPFactory()));
131 136
132 return *this; 137 return *this;
133 } 138 }
134 139
135 /** 140 /**
136 * Resets the paint to the defaults.
137 */
138 void reset() {
139 this->resetOptions();
140 this->resetColor();
141 this->resetStages();
142 }
143
144 /**
145 * Returns true if isOpaque would return true and the paint represents a sol id constant color 141 * Returns true if isOpaque would return true and the paint represents a sol id constant color
146 * draw. If the result is true, constantColor will be updated to contain the constant color. 142 * draw. If the result is true, constantColor will be updated to contain the constant color.
147 */ 143 */
148 bool isOpaqueAndConstantColor(GrColor* constantColor) const; 144 bool isOpaqueAndConstantColor(GrColor* constantColor) const;
149 145
150 private: 146 private:
151 SkAutoTUnref<const GrXPFactory> fXPFactory; 147 mutable SkAutoTUnref<const GrXPFactory> fXPFactory;
152 SkSTArray<4, GrFragmentStage> fColorStages; 148 SkSTArray<4, GrFragmentStage> fColorStages;
153 SkSTArray<2, GrFragmentStage> fCoverageStages; 149 SkSTArray<2, GrFragmentStage> fCoverageStages;
154 150
155 bool fAntiAlias; 151 bool fAntiAlias;
156 bool fDither; 152 bool fDither;
157 153
158 GrColor fColor; 154 GrColor fColor;
159
160 void resetOptions() {
161 fAntiAlias = false;
162 fDither = false;
163 }
164
165 void resetColor() {
166 fColor = GrColorPackRGBA(0xff, 0xff, 0xff, 0xff);
167 }
168
169 void resetStages();
170 }; 155 };
171 156
172 #endif 157 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrContext.h ('k') | src/effects/SkGpuBlurUtils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698