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

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

Issue 1307223004: Remove GrStagedProcessor, remove the word Stage as it applies to FPs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix misresolve Created 5 years, 3 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/GrFragmentProcessor.h ('k') | include/gpu/GrStagedProcessor.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 "GrStagedProcessor.h"
15 #include "GrProcessorDataManager.h" 14 #include "GrProcessorDataManager.h"
16 #include "GrXferProcessor.h" 15 #include "GrXferProcessor.h"
17 #include "effects/GrPorterDuffXferProcessor.h" 16 #include "effects/GrPorterDuffXferProcessor.h"
18 #include "GrFragmentProcessor.h" 17 #include "GrFragmentProcessor.h"
19 18
20 #include "SkRegion.h" 19 #include "SkRegion.h"
21 #include "SkXfermode.h" 20 #include "SkXfermode.h"
22 21
23 /** 22 /**
24 * The paint describes how color and coverage are computed at each pixel by GrCo ntext draw 23 * The paint describes how color and coverage are computed at each pixel by GrCo ntext draw
(...skipping 12 matching lines...) Expand all
37 * 36 *
38 * setXPFactory is used to control blending between the output color and dest. I t also implements 37 * setXPFactory is used to control blending between the output color and dest. I t also implements
39 * the application of fractional coverage from the coverage pipeline. 38 * the application of fractional coverage from the coverage pipeline.
40 */ 39 */
41 class GrPaint { 40 class GrPaint {
42 public: 41 public:
43 GrPaint(); 42 GrPaint();
44 43
45 GrPaint(const GrPaint& paint) { *this = paint; } 44 GrPaint(const GrPaint& paint) { *this = paint; }
46 45
47 ~GrPaint() {} 46 ~GrPaint() { this->resetFragmentProcessors(); }
48 47
49 /** 48 /**
50 * The initial color of the drawn primitive. Defaults to solid white. 49 * The initial color of the drawn primitive. Defaults to solid white.
51 */ 50 */
52 void setColor(GrColor color) { fColor = color; } 51 void setColor(GrColor color) { fColor = color; }
53 GrColor getColor() const { return fColor; } 52 GrColor getColor() const { return fColor; }
54 53
55 /** 54 /**
56 * Should primitives be anti-aliased or not. Defaults to false. 55 * Should primitives be anti-aliased or not. Defaults to false.
57 */ 56 */
(...skipping 13 matching lines...) Expand all
71 70
72 void setPorterDuffXPFactory(SkXfermode::Mode mode) { 71 void setPorterDuffXPFactory(SkXfermode::Mode mode) {
73 fXPFactory.reset(GrPorterDuffXPFactory::Create(mode)); 72 fXPFactory.reset(GrPorterDuffXPFactory::Create(mode));
74 } 73 }
75 74
76 void setCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage = false); 75 void setCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage = false);
77 76
78 /** 77 /**
79 * Appends an additional color processor to the color computation. 78 * Appends an additional color processor to the color computation.
80 */ 79 */
81 const GrFragmentProcessor* addColorProcessor(const GrFragmentProcessor* fp) { 80 const GrFragmentProcessor* addColorFragmentProcessor(const GrFragmentProcess or* fp) {
82 SkASSERT(fp); 81 SkASSERT(fp);
83 SkNEW_APPEND_TO_TARRAY(&fColorStages, GrFragmentStage, (fp)); 82 fColorFragmentProcessors.push_back(SkRef(fp));
84 return fp; 83 return fp;
85 } 84 }
86 85
87 /** 86 /**
88 * Appends an additional coverage processor to the coverage computation. 87 * Appends an additional coverage processor to the coverage computation.
89 */ 88 */
90 const GrFragmentProcessor* addCoverageProcessor(const GrFragmentProcessor* f p) { 89 const GrFragmentProcessor* addCoverageFragmentProcessor(const GrFragmentProc essor* fp) {
91 SkASSERT(fp); 90 SkASSERT(fp);
92 SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrFragmentStage, (fp)); 91 fCoverageFragmentProcessors.push_back(SkRef(fp));
93 return fp; 92 return fp;
94 } 93 }
95 94
96 /** 95 /**
97 * Helpers for adding color or coverage effects that sample a texture. The m atrix is applied 96 * Helpers for adding color or coverage effects that sample a texture. The m atrix is applied
98 * to the src space position to compute texture coordinates. 97 * to the src space position to compute texture coordinates.
99 */ 98 */
100 void addColorTextureProcessor(GrTexture*, const SkMatrix&); 99 void addColorTextureProcessor(GrTexture*, const SkMatrix&);
101 void addCoverageTextureProcessor(GrTexture*, const SkMatrix&); 100 void addCoverageTextureProcessor(GrTexture*, const SkMatrix&);
102 void addColorTextureProcessor(GrTexture*, const SkMatrix&, const GrTexturePa rams&); 101 void addColorTextureProcessor(GrTexture*, const SkMatrix&, const GrTexturePa rams&);
103 void addCoverageTextureProcessor(GrTexture*, const SkMatrix&, const GrTextur eParams&); 102 void addCoverageTextureProcessor(GrTexture*, const SkMatrix&, const GrTextur eParams&);
104 103
105 int numColorStages() const { return fColorStages.count(); } 104 int numColorFragmentProcessors() const { return fColorFragmentProcessors.cou nt(); }
106 int numCoverageStages() const { return fCoverageStages.count(); } 105 int numCoverageFragmentProcessors() const { return fCoverageFragmentProcesso rs.count(); }
107 int numTotalStages() const { return this->numColorStages() + this->numCovera geStages(); } 106 int numTotalFragmentProcessors() const { return this->numColorFragmentProces sors() +
107 this->numCoverageFragmentProcessor s(); }
108 108
109 const GrXPFactory* getXPFactory() const { 109 const GrXPFactory* getXPFactory() const {
110 if (!fXPFactory) { 110 if (!fXPFactory) {
111 fXPFactory.reset(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode )); 111 fXPFactory.reset(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode ));
112 } 112 }
113 return fXPFactory.get(); 113 return fXPFactory.get();
114 } 114 }
115 115
116 const GrFragmentStage& getColorStage(int s) const { return fColorStages[s]; } 116 const GrFragmentProcessor* getColorFragmentProcessor(int i) const {
117 const GrFragmentStage& getCoverageStage(int s) const { return fCoverageStage s[s]; } 117 return fColorFragmentProcessors[i];
118 }
119 const GrFragmentProcessor* getCoverageFragmentProcessor(int i) const {
120 return fCoverageFragmentProcessors[i];
121 }
118 122
119 GrPaint& operator=(const GrPaint& paint) { 123 GrPaint& operator=(const GrPaint& paint) {
120 fAntiAlias = paint.fAntiAlias; 124 fAntiAlias = paint.fAntiAlias;
121 fDither = paint.fDither; 125 fDither = paint.fDither;
122 126
123 fColor = paint.fColor; 127 fColor = paint.fColor;
124 128 this->resetFragmentProcessors();
125 fColorStages = paint.fColorStages; 129 fColorFragmentProcessors = paint.fColorFragmentProcessors;
126 fCoverageStages = paint.fCoverageStages; 130 fCoverageFragmentProcessors = paint.fCoverageFragmentProcessors;
131 for (int i = 0; i < fColorFragmentProcessors.count(); ++i) {
132 fColorFragmentProcessors[i]->ref();
133 }
134 for (int i = 0; i < fCoverageFragmentProcessors.count(); ++i) {
135 fCoverageFragmentProcessors[i]->ref();
136 }
127 137
128 fXPFactory.reset(SkRef(paint.getXPFactory())); 138 fXPFactory.reset(SkRef(paint.getXPFactory()));
129 fProcDataManager.reset(new GrProcessorDataManager(*paint.processorDataMa nager())); 139 fProcDataManager.reset(new GrProcessorDataManager(*paint.processorDataMa nager()));
130 140
131 return *this; 141 return *this;
132 } 142 }
133 143
134 /** 144 /**
135 * Returns true if the paint's output color will be constant after blending. If the result is 145 * Returns true if the paint's output color will be constant after blending. If the result is
136 * true, constantColor will be updated to contain the constant color. Note t hat we can conflate 146 * true, constantColor will be updated to contain the constant color. Note t hat we can conflate
137 * coverage and color, so the actual values written to pixels with partial c overage may still 147 * coverage and color, so the actual values written to pixels with partial c overage may still
138 * not seem constant, even if this function returns true. 148 * not seem constant, even if this function returns true.
139 */ 149 */
140 bool isConstantBlendedColor(GrColor* constantColor) const; 150 bool isConstantBlendedColor(GrColor* constantColor) const;
141 151
142 GrProcessorDataManager* getProcessorDataManager() { return fProcDataManager. get(); } 152 GrProcessorDataManager* getProcessorDataManager() { return fProcDataManager. get(); }
143 153
144 const GrProcessorDataManager* processorDataManager() const { return fProcDat aManager.get(); } 154 const GrProcessorDataManager* processorDataManager() const { return fProcDat aManager.get(); }
145 155
146 private: 156 private:
147 mutable SkAutoTUnref<const GrXPFactory> fXPFactory; 157 void resetFragmentProcessors() {
148 SkSTArray<4, GrFragmentStage> fColorStages; 158 for (int i = 0; i < fColorFragmentProcessors.count(); ++i) {
149 SkSTArray<2, GrFragmentStage> fCoverageStages; 159 fColorFragmentProcessors[i]->unref();
160 }
161 for (int i = 0; i < fCoverageFragmentProcessors.count(); ++i) {
162 fCoverageFragmentProcessors[i]->unref();
163 }
164 fColorFragmentProcessors.reset();
165 fCoverageFragmentProcessors.reset();
166 }
150 167
151 bool fAntiAlias; 168 mutable SkAutoTUnref<const GrXPFactory> fXPFactory;
152 bool fDither; 169 SkSTArray<4, const GrFragmentProcessor*, true> fColorFragmentProcessors;
170 SkSTArray<2, const GrFragmentProcessor*, true> fCoverageFragmentProcessors;
153 171
154 GrColor fColor; 172 bool fAntiAlias;
155 SkAutoTUnref<GrProcessorDataManager> fProcDataManager; 173 bool fDither;
174
175 GrColor fColor;
176 SkAutoTUnref<GrProcessorDataManager> fProcDataManager;
156 }; 177 };
157 178
158 #endif 179 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrFragmentProcessor.h ('k') | include/gpu/GrStagedProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698