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

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

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