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

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

Issue 385713005: Allow GrGLEffects to produce variable length keys. (Closed) Base URL: https://skia.googlesource.com/skia.git@key
Patch Set: rebase Created 6 years, 5 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 179
180 class GrGLSweepGradient : public GrGLGradientEffect { 180 class GrGLSweepGradient : public GrGLGradientEffect {
181 public: 181 public:
182 182
183 GrGLSweepGradient(const GrBackendEffectFactory& factory, 183 GrGLSweepGradient(const GrBackendEffectFactory& factory,
184 const GrDrawEffect&) : INHERITED (factory) { } 184 const GrDrawEffect&) : INHERITED (factory) { }
185 virtual ~GrGLSweepGradient() { } 185 virtual ~GrGLSweepGradient() { }
186 186
187 virtual void emitCode(GrGLShaderBuilder*, 187 virtual void emitCode(GrGLShaderBuilder*,
188 const GrDrawEffect&, 188 const GrDrawEffect&,
189 EffectKey, 189 const GrEffectKey&,
190 const char* outputColor, 190 const char* outputColor,
191 const char* inputColor, 191 const char* inputColor,
192 const TransformedCoordsArray&, 192 const TransformedCoordsArray&,
193 const TextureSamplerArray&) SK_OVERRIDE; 193 const TextureSamplerArray&) SK_OVERRIDE;
194 194
195 static EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) { 195 static void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, GrEffect KeyBuilder* b) {
196 return GenBaseGradientKey(drawEffect); 196 b->add32(GenBaseGradientKey(drawEffect));
197 } 197 }
198 198
199 private: 199 private:
200 200
201 typedef GrGLGradientEffect INHERITED; 201 typedef GrGLGradientEffect INHERITED;
202 202
203 }; 203 };
204 204
205 ///////////////////////////////////////////////////////////////////// 205 /////////////////////////////////////////////////////////////////////
206 206
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 GrEffect* effect; 249 GrEffect* effect;
250 GrColor paintColor; 250 GrColor paintColor;
251 SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effec t)); 251 SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effec t));
252 return effect; 252 return effect;
253 } 253 }
254 254
255 ///////////////////////////////////////////////////////////////////// 255 /////////////////////////////////////////////////////////////////////
256 256
257 void GrGLSweepGradient::emitCode(GrGLShaderBuilder* builder, 257 void GrGLSweepGradient::emitCode(GrGLShaderBuilder* builder,
258 const GrDrawEffect&, 258 const GrDrawEffect&,
259 EffectKey key, 259 const GrEffectKey& key,
260 const char* outputColor, 260 const char* outputColor,
261 const char* inputColor, 261 const char* inputColor,
262 const TransformedCoordsArray& coords, 262 const TransformedCoordsArray& coords,
263 const TextureSamplerArray& samplers) { 263 const TextureSamplerArray& samplers) {
264 this->emitUniforms(builder, key); 264 uint32_t baseKey = key.get32(0);
265 this->emitUniforms(builder, baseKey);
265 SkString coords2D = builder->ensureFSCoords2D(coords, 0); 266 SkString coords2D = builder->ensureFSCoords2D(coords, 0);
266 const GrGLContextInfo ctxInfo = builder->ctxInfo(); 267 const GrGLContextInfo ctxInfo = builder->ctxInfo();
267 SkString t; 268 SkString t;
268 // 0.1591549430918 is 1/(2*pi), used since atan returns values [-pi, pi] 269 // 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 270 // 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 271 // thus must us -1.0 * %s.x to work correctly
271 if (kIntel_GrGLVendor != ctxInfo.vendor()){ 272 if (kIntel_GrGLVendor != ctxInfo.vendor()){
272 t.printf("atan(- %s.y, - %s.x) * 0.1591549430918 + 0.5", 273 t.printf("atan(- %s.y, - %s.x) * 0.1591549430918 + 0.5",
273 coords2D.c_str(), coords2D.c_str()); 274 coords2D.c_str(), coords2D.c_str());
274 } else { 275 } else {
275 t.printf("atan(- %s.y, -1.0 * %s.x) * 0.1591549430918 + 0.5", 276 t.printf("atan(- %s.y, -1.0 * %s.x) * 0.1591549430918 + 0.5",
276 coords2D.c_str(), coords2D.c_str()); 277 coords2D.c_str(), coords2D.c_str());
277 } 278 }
278 this->emitColor(builder, t.c_str(), key, 279 this->emitColor(builder, t.c_str(), baseKey, outputColor, inputColor, sample rs);
279 outputColor, inputColor, samplers);
280 } 280 }
281 281
282 ///////////////////////////////////////////////////////////////////// 282 /////////////////////////////////////////////////////////////////////
283 283
284 bool SkSweepGradient::asNewEffect(GrContext* context, const SkPaint& paint, 284 bool SkSweepGradient::asNewEffect(GrContext* context, const SkPaint& paint,
285 const SkMatrix* localMatrix, GrColor* paintCol or, 285 const SkMatrix* localMatrix, GrColor* paintCol or,
286 GrEffect** effect) const { 286 GrEffect** effect) const {
287 287
288 SkMatrix matrix; 288 SkMatrix matrix;
289 if (!this->getLocalMatrix().invert(&matrix)) { 289 if (!this->getLocalMatrix().invert(&matrix)) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 str->appendScalar(fCenter.fX); 323 str->appendScalar(fCenter.fX);
324 str->append(", "); 324 str->append(", ");
325 str->appendScalar(fCenter.fY); 325 str->appendScalar(fCenter.fY);
326 str->append(") "); 326 str->append(") ");
327 327
328 this->INHERITED::toString(str); 328 this->INHERITED::toString(str);
329 329
330 str->append(")"); 330 str->append(")");
331 } 331 }
332 #endif 332 #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