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

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

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

Powered by Google App Engine
This is Rietveld 408576698