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

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

Issue 491673002: Initial refactor of shaderbuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase Created 6 years, 4 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
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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 toggle = next_dither_toggle16(toggle); 166 toggle = next_dither_toggle16(toggle);
167 } 167 }
168 } 168 }
169 } 169 }
170 170
171 ///////////////////////////////////////////////////////////////////// 171 /////////////////////////////////////////////////////////////////////
172 172
173 #if SK_SUPPORT_GPU 173 #if SK_SUPPORT_GPU
174 174
175 #include "GrTBackendEffectFactory.h" 175 #include "GrTBackendEffectFactory.h"
176 #include "gl/GrGLShaderBuilder.h" 176 #include "gl/builders/GrGLProgramBuilder.h"
177 #include "SkGr.h" 177 #include "SkGr.h"
178 178
179 class GrGLSweepGradient : public GrGLGradientEffect { 179 class GrGLSweepGradient : public GrGLGradientEffect {
180 public: 180 public:
181 181
182 GrGLSweepGradient(const GrBackendEffectFactory& factory, 182 GrGLSweepGradient(const GrBackendEffectFactory& factory,
183 const GrDrawEffect&) : INHERITED (factory) { } 183 const GrDrawEffect&) : INHERITED (factory) { }
184 virtual ~GrGLSweepGradient() { } 184 virtual ~GrGLSweepGradient() { }
185 185
186 virtual void emitCode(GrGLShaderBuilder*, 186 virtual void emitCode(GrGLProgramBuilder*,
187 const GrDrawEffect&, 187 const GrDrawEffect&,
188 const GrEffectKey&, 188 const GrEffectKey&,
189 const char* outputColor, 189 const char* outputColor,
190 const char* inputColor, 190 const char* inputColor,
191 const TransformedCoordsArray&, 191 const TransformedCoordsArray&,
192 const TextureSamplerArray&) SK_OVERRIDE; 192 const TextureSamplerArray&) SK_OVERRIDE;
193 193
194 static void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, GrEffect KeyBuilder* b) { 194 static void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, GrEffect KeyBuilder* b) {
195 b->add32(GenBaseGradientKey(drawEffect)); 195 b->add32(GenBaseGradientKey(drawEffect));
196 } 196 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 colors, stops, c olorCount)); 246 colors, stops, c olorCount));
247 SkPaint paint; 247 SkPaint paint;
248 GrEffect* effect; 248 GrEffect* effect;
249 GrColor paintColor; 249 GrColor paintColor;
250 SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effec t)); 250 SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effec t));
251 return effect; 251 return effect;
252 } 252 }
253 253
254 ///////////////////////////////////////////////////////////////////// 254 /////////////////////////////////////////////////////////////////////
255 255
256 void GrGLSweepGradient::emitCode(GrGLShaderBuilder* builder, 256 void GrGLSweepGradient::emitCode(GrGLProgramBuilder* builder,
257 const GrDrawEffect&, 257 const GrDrawEffect&,
258 const GrEffectKey& key, 258 const GrEffectKey& key,
259 const char* outputColor, 259 const char* outputColor,
260 const char* inputColor, 260 const char* inputColor,
261 const TransformedCoordsArray& coords, 261 const TransformedCoordsArray& coords,
262 const TextureSamplerArray& samplers) { 262 const TextureSamplerArray& samplers) {
263 uint32_t baseKey = key.get32(0); 263 uint32_t baseKey = key.get32(0);
264 this->emitUniforms(builder, baseKey); 264 this->emitUniforms(builder, baseKey);
265 SkString coords2D = builder->ensureFSCoords2D(coords, 0); 265 SkString coords2D = builder->getFragmentShaderBuilder()->ensureFSCoords2D(co ords, 0);
266 const GrGLContextInfo ctxInfo = builder->ctxInfo(); 266 const GrGLContextInfo ctxInfo = builder->ctxInfo();
267 SkString t; 267 SkString t;
268 // 0.1591549430918 is 1/(2*pi), used since atan returns values [-pi, pi] 268 // 0.1591549430918 is 1/(2*pi), used since atan returns values [-pi, pi]
269 // On Intel GPU there is an issue where it reads the second arguement to ata n "- %s.x" as an int 269 // On Intel GPU there is an issue where it reads the second arguement to ata n "- %s.x" as an int
270 // thus must us -1.0 * %s.x to work correctly 270 // thus must us -1.0 * %s.x to work correctly
271 if (kIntel_GrGLVendor != ctxInfo.vendor()){ 271 if (kIntel_GrGLVendor != ctxInfo.vendor()){
272 t.printf("atan(- %s.y, - %s.x) * 0.1591549430918 + 0.5", 272 t.printf("atan(- %s.y, - %s.x) * 0.1591549430918 + 0.5",
273 coords2D.c_str(), coords2D.c_str()); 273 coords2D.c_str(), coords2D.c_str());
274 } else { 274 } else {
275 t.printf("atan(- %s.y, -1.0 * %s.x) * 0.1591549430918 + 0.5", 275 t.printf("atan(- %s.y, -1.0 * %s.x) * 0.1591549430918 + 0.5",
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 str->appendScalar(fCenter.fX); 322 str->appendScalar(fCenter.fX);
323 str->append(", "); 323 str->append(", ");
324 str->appendScalar(fCenter.fY); 324 str->appendScalar(fCenter.fY);
325 str->append(") "); 325 str->append(") ");
326 326
327 this->INHERITED::toString(str); 327 this->INHERITED::toString(str);
328 328
329 str->append(")"); 329 str->append(")");
330 } 330 }
331 #endif 331 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698