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

Side by Side Diff: src/effects/gradients/SkSweepGradient.cpp

Issue 1490283004: Create GLSLUniformHandler class for gpu backend (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: clean up public api of uniformhandler Created 5 years 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
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 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 #include "SkSweepGradient.h" 9 #include "SkSweepGradient.h"
10 10
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } 161 }
162 } 162 }
163 } 163 }
164 164
165 ///////////////////////////////////////////////////////////////////// 165 /////////////////////////////////////////////////////////////////////
166 166
167 #if SK_SUPPORT_GPU 167 #if SK_SUPPORT_GPU
168 168
169 #include "SkGr.h" 169 #include "SkGr.h"
170 #include "gl/GrGLContext.h" 170 #include "gl/GrGLContext.h"
171 #include "gl/builders/GrGLProgramBuilder.h" 171 #include "glsl/GrGLSLCaps.h"
172 #include "glsl/GrGLSLFragmentShaderBuilder.h"
172 173
173 class GrGLSweepGradient : public GrGLGradientEffect { 174 class GrGLSweepGradient : public GrGLGradientEffect {
174 public: 175 public:
175 176
176 GrGLSweepGradient(const GrProcessor&) {} 177 GrGLSweepGradient(const GrProcessor&) {}
177 virtual ~GrGLSweepGradient() { } 178 virtual ~GrGLSweepGradient() { }
178 179
179 virtual void emitCode(EmitArgs&) override; 180 virtual void emitCode(EmitArgs&) override;
180 181
181 static void GenKey(const GrProcessor& processor, const GrGLSLCaps&, GrProces sorKeyBuilder* b) { 182 static void GenKey(const GrProcessor& processor, const GrGLSLCaps&, GrProces sorKeyBuilder* b) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 GrTest::TestMatr ix(d->fRandom), 241 GrTest::TestMatr ix(d->fRandom),
241 NULL, kNone_SkFi lterQuality); 242 NULL, kNone_SkFi lterQuality);
242 GrAlwaysAssert(fp); 243 GrAlwaysAssert(fp);
243 return fp; 244 return fp;
244 } 245 }
245 246
246 ///////////////////////////////////////////////////////////////////// 247 /////////////////////////////////////////////////////////////////////
247 248
248 void GrGLSweepGradient::emitCode(EmitArgs& args) { 249 void GrGLSweepGradient::emitCode(EmitArgs& args) {
249 const GrSweepGradient& ge = args.fFp.cast<GrSweepGradient>(); 250 const GrSweepGradient& ge = args.fFp.cast<GrSweepGradient>();
250 this->emitUniforms(args.fBuilder, ge); 251 this->emitUniforms(args.fUniformHandler, ge);
251 SkString coords2D = args.fFragBuilder->ensureFSCoords2D(args.fCoords, 0); 252 SkString coords2D = args.fFragBuilder->ensureFSCoords2D(args.fCoords, 0);
252 SkString t; 253 SkString t;
253 // 0.1591549430918 is 1/(2*pi), used since atan returns values [-pi, pi] 254 // 0.1591549430918 is 1/(2*pi), used since atan returns values [-pi, pi]
254 // On Intel GPU there is an issue where it reads the second arguement to ata n "- %s.x" as an int 255 // On Intel GPU there is an issue where it reads the second arguement to ata n "- %s.x" as an int
255 // thus must us -1.0 * %s.x to work correctly 256 // thus must us -1.0 * %s.x to work correctly
256 if (args.fGLSLCaps->mustForceNegatedAtanParamToFloat()){ 257 if (args.fGLSLCaps->mustForceNegatedAtanParamToFloat()){
257 t.printf("atan(- %s.y, -1.0 * %s.x) * 0.1591549430918 + 0.5", 258 t.printf("atan(- %s.y, -1.0 * %s.x) * 0.1591549430918 + 0.5",
258 coords2D.c_str(), coords2D.c_str()); 259 coords2D.c_str(), coords2D.c_str());
259 } else { 260 } else {
260 t.printf("atan(- %s.y, - %s.x) * 0.1591549430918 + 0.5", 261 t.printf("atan(- %s.y, - %s.x) * 0.1591549430918 + 0.5",
261 coords2D.c_str(), coords2D.c_str()); 262 coords2D.c_str(), coords2D.c_str());
262 } 263 }
263 this->emitColor(args.fBuilder, 264 this->emitColor(args.fFragBuilder,
264 args.fFragBuilder, 265 args.fUniformHandler,
265 args.fGLSLCaps, 266 args.fGLSLCaps,
266 ge, t.c_str(), 267 ge, t.c_str(),
267 args.fOutputColor, 268 args.fOutputColor,
268 args.fInputColor, 269 args.fInputColor,
269 args.fSamplers); 270 args.fSamplers);
270 } 271 }
271 272
272 ///////////////////////////////////////////////////////////////////// 273 /////////////////////////////////////////////////////////////////////
273 274
274 const GrFragmentProcessor* SkSweepGradient::asFragmentProcessor( 275 const GrFragmentProcessor* SkSweepGradient::asFragmentProcessor(
(...skipping 30 matching lines...) Expand all
305 str->appendScalar(fCenter.fX); 306 str->appendScalar(fCenter.fX);
306 str->append(", "); 307 str->append(", ");
307 str->appendScalar(fCenter.fY); 308 str->appendScalar(fCenter.fY);
308 str->append(") "); 309 str->append(") ");
309 310
310 this->INHERITED::toString(str); 311 this->INHERITED::toString(str);
311 312
312 str->append(")"); 313 str->append(")");
313 } 314 }
314 #endif 315 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkRadialGradient.cpp ('k') | src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698