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

Side by Side Diff: src/effects/SkArithmeticMode_gpu.cpp

Issue 900883002: Revert of Move DstCopy on gpu into the GrXferProcessor. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 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 | « src/effects/SkArithmeticMode_gpu.h ('k') | src/gpu/GrBatchTarget.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 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 #include "SkArithmeticMode_gpu.h" 8 #include "SkArithmeticMode_gpu.h"
9 9
10 #if SK_SUPPORT_GPU 10 #if SK_SUPPORT_GPU
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 /////////////////////////////////////////////////////////////////////////////// 159 ///////////////////////////////////////////////////////////////////////////////
160 160
161 class GLArithmeticXP : public GrGLXferProcessor { 161 class GLArithmeticXP : public GrGLXferProcessor {
162 public: 162 public:
163 GLArithmeticXP(const GrProcessor&) 163 GLArithmeticXP(const GrProcessor&)
164 : fEnforcePMColor(true) { 164 : fEnforcePMColor(true) {
165 } 165 }
166 166
167 ~GLArithmeticXP() SK_OVERRIDE {} 167 ~GLArithmeticXP() SK_OVERRIDE {}
168 168
169 void emitCode(const EmitArgs& args) SK_OVERRIDE {
170 GrGLFPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
171
172 const char* dstColor = fsBuilder->dstColor();
173
174 fKUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility,
175 kVec4f_GrSLType, kDefault_GrSLPrecision,
176 "k");
177 const char* kUni = args.fPB->getUniformCStr(fKUni);
178
179 add_arithmetic_code(fsBuilder, args.fInputColor, dstColor, args.fOutputP rimary, kUni,
180 fEnforcePMColor);
181
182 fsBuilder->codeAppendf("%s = %s * %s + (vec4(1.0) - %s) * %s;",
183 args.fOutputPrimary, args.fOutputPrimary, args.fI nputCoverage,
184 args.fInputCoverage, dstColor);
185 }
186
187 void setData(const GrGLProgramDataManager& pdman,
188 const GrXferProcessor& processor) SK_OVERRIDE {
189 const GrArithmeticXP& arith = processor.cast<GrArithmeticXP>();
190 pdman.set4f(fKUni, arith.k1(), arith.k2(), arith.k3(), arith.k4());
191 fEnforcePMColor = arith.enforcePMColor();
192 };
193
169 static void GenKey(const GrProcessor& processor, const GrGLCaps& caps, 194 static void GenKey(const GrProcessor& processor, const GrGLCaps& caps,
170 GrProcessorKeyBuilder* b) { 195 GrProcessorKeyBuilder* b) {
171 const GrArithmeticXP& arith = processor.cast<GrArithmeticXP>(); 196 const GrArithmeticXP& arith = processor.cast<GrArithmeticXP>();
172 uint32_t key = arith.enforcePMColor() ? 1 : 0; 197 uint32_t key = arith.enforcePMColor() ? 1 : 0;
173 b->add32(key); 198 b->add32(key);
174 } 199 }
175 200
176 private: 201 private:
177 void onEmitCode(const EmitArgs& args) SK_OVERRIDE {
178 GrGLFPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
179
180 const char* dstColor = fsBuilder->dstColor();
181
182 fKUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility,
183 kVec4f_GrSLType, kDefault_GrSLPrecision,
184 "k");
185 const char* kUni = args.fPB->getUniformCStr(fKUni);
186
187 add_arithmetic_code(fsBuilder, args.fInputColor, dstColor, args.fOutputP rimary, kUni,
188 fEnforcePMColor);
189
190 fsBuilder->codeAppendf("%s = %s * %s + (vec4(1.0) - %s) * %s;",
191 args.fOutputPrimary, args.fOutputPrimary, args.fI nputCoverage,
192 args.fInputCoverage, dstColor);
193 }
194
195 void onSetData(const GrGLProgramDataManager& pdman,
196 const GrXferProcessor& processor) SK_OVERRIDE {
197 const GrArithmeticXP& arith = processor.cast<GrArithmeticXP>();
198 pdman.set4f(fKUni, arith.k1(), arith.k2(), arith.k3(), arith.k4());
199 fEnforcePMColor = arith.enforcePMColor();
200 };
201
202 GrGLProgramDataManager::UniformHandle fKUni; 202 GrGLProgramDataManager::UniformHandle fKUni;
203 bool fEnforcePMColor; 203 bool fEnforcePMColor;
204 204
205 typedef GrGLXferProcessor INHERITED; 205 typedef GrGLXferProcessor INHERITED;
206 }; 206 };
207 207
208 /////////////////////////////////////////////////////////////////////////////// 208 ///////////////////////////////////////////////////////////////////////////////
209 209
210 GrArithmeticXP::GrArithmeticXP(float k1, float k2, float k3, float k4, bool enfo rcePMColor, 210 GrArithmeticXP::GrArithmeticXP(float k1, float k2, float k3, float k4, bool enfo rcePMColor)
211 const GrDeviceCoordTexture* dstCopy, bool willRea dDstColor) 211 : fK1(k1)
212 : INHERITED(dstCopy, willReadDstColor)
213 , fK1(k1)
214 , fK2(k2) 212 , fK2(k2)
215 , fK3(k3) 213 , fK3(k3)
216 , fK4(k4) 214 , fK4(k4)
217 , fEnforcePMColor(enforcePMColor) { 215 , fEnforcePMColor(enforcePMColor) {
218 this->initClassID<GrPorterDuffXferProcessor>(); 216 this->initClassID<GrPorterDuffXferProcessor>();
217 this->setWillReadDstColor();
219 } 218 }
220 219
221 void GrArithmeticXP::onGetGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBui lder* b) const { 220 void GrArithmeticXP::getGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuild er* b) const {
222 GLArithmeticXP::GenKey(*this, caps, b); 221 GLArithmeticXP::GenKey(*this, caps, b);
223 } 222 }
224 223
225 GrGLXferProcessor* GrArithmeticXP::createGLInstance() const { 224 GrGLXferProcessor* GrArithmeticXP::createGLInstance() const {
226 return SkNEW_ARGS(GLArithmeticXP, (*this)); 225 return SkNEW_ARGS(GLArithmeticXP, (*this));
227 } 226 }
228 227
229 GrXferProcessor::OptFlags GrArithmeticXP::getOptimizations(const GrProcOptInfo& colorPOI, 228 GrXferProcessor::OptFlags GrArithmeticXP::getOptimizations(const GrProcOptInfo& colorPOI,
230 const GrProcOptInfo& coveragePOI, 229 const GrProcOptInfo& coveragePOI,
231 bool doesStencilWrite , 230 bool doesStencilWrite ,
(...skipping 30 matching lines...) Expand all
262 float k1 = random->nextF(); 261 float k1 = random->nextF();
263 float k2 = random->nextF(); 262 float k2 = random->nextF();
264 float k3 = random->nextF(); 263 float k3 = random->nextF();
265 float k4 = random->nextF(); 264 float k4 = random->nextF();
266 bool enforcePMColor = random->nextBool(); 265 bool enforcePMColor = random->nextBool();
267 266
268 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor); 267 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor);
269 } 268 }
270 269
271 #endif 270 #endif
OLDNEW
« no previous file with comments | « src/effects/SkArithmeticMode_gpu.h ('k') | src/gpu/GrBatchTarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698