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

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

Issue 278963002: add localmatrix parameter to shader's asNewEffect (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 SkPoint center = {random->nextUScalar1(), random->nextUScalar1()}; 240 SkPoint center = {random->nextUScalar1(), random->nextUScalar1()};
241 241
242 SkColor colors[kMaxRandomGradientColors]; 242 SkColor colors[kMaxRandomGradientColors];
243 SkScalar stopsArray[kMaxRandomGradientColors]; 243 SkScalar stopsArray[kMaxRandomGradientColors];
244 SkScalar* stops = stopsArray; 244 SkScalar* stops = stopsArray;
245 SkShader::TileMode tmIgnored; 245 SkShader::TileMode tmIgnored;
246 int colorCount = RandomGradientParams(random, colors, &stops, &tmIgnored); 246 int colorCount = RandomGradientParams(random, colors, &stops, &tmIgnored);
247 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateSweep(center.fX, cente r.fY, 247 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateSweep(center.fX, cente r.fY,
248 colors, stops, c olorCount)); 248 colors, stops, c olorCount));
249 SkPaint paint; 249 SkPaint paint;
250 return shader->asNewEffect(context, paint); 250 return shader->asNewEffect(context, paint, NULL);
251 } 251 }
252 252
253 ///////////////////////////////////////////////////////////////////// 253 /////////////////////////////////////////////////////////////////////
254 254
255 void GrGLSweepGradient::emitCode(GrGLShaderBuilder* builder, 255 void GrGLSweepGradient::emitCode(GrGLShaderBuilder* builder,
256 const GrDrawEffect&, 256 const GrDrawEffect&,
257 EffectKey key, 257 EffectKey key,
258 const char* outputColor, 258 const char* outputColor,
259 const char* inputColor, 259 const char* inputColor,
260 const TransformedCoordsArray& coords, 260 const TransformedCoordsArray& coords,
(...skipping 11 matching lines...) Expand all
272 } else { 272 } else {
273 t.printf("atan(- %s.y, -1.0 * %s.x) * 0.1591549430918 + 0.5", 273 t.printf("atan(- %s.y, -1.0 * %s.x) * 0.1591549430918 + 0.5",
274 coords2D.c_str(), coords2D.c_str()); 274 coords2D.c_str(), coords2D.c_str());
275 } 275 }
276 this->emitColor(builder, t.c_str(), key, 276 this->emitColor(builder, t.c_str(), key,
277 outputColor, inputColor, samplers); 277 outputColor, inputColor, samplers);
278 } 278 }
279 279
280 ///////////////////////////////////////////////////////////////////// 280 /////////////////////////////////////////////////////////////////////
281 281
282 GrEffectRef* SkSweepGradient::asNewEffect(GrContext* context, const SkPaint&) co nst { 282 GrEffectRef* SkSweepGradient::asNewEffect(GrContext* context, const SkPaint&,
283 const SkMatrix* localMatrix) const {
283 SkMatrix matrix; 284 SkMatrix matrix;
284 if (!this->getLocalMatrix().invert(&matrix)) { 285 if (!this->getLocalMatrix().invert(&matrix)) {
285 return NULL; 286 return NULL;
286 } 287 }
288 if (localMatrix) {
289 SkMatrix inv;
290 if (!localMatrix->invert(&inv)) {
291 return NULL;
292 }
293 matrix.postConcat(inv);
294 }
287 matrix.postConcat(fPtsToUnit); 295 matrix.postConcat(fPtsToUnit);
288 return GrSweepGradient::Create(context, *this, matrix); 296 return GrSweepGradient::Create(context, *this, matrix);
289 } 297 }
290 298
291 #else 299 #else
292 300
293 GrEffectRef* SkSweepGradient::asNewEffect(GrContext*, const SkPaint&) const { 301 GrEffectRef* SkSweepGradient::asNewEffect(GrContext*, const SkPaint&) const {
294 SkDEBUGFAIL("Should not call in GPU-less build"); 302 SkDEBUGFAIL("Should not call in GPU-less build");
295 return NULL; 303 return NULL;
296 } 304 }
297 305
298 #endif 306 #endif
299 307
300 #ifndef SK_IGNORE_TO_STRING 308 #ifndef SK_IGNORE_TO_STRING
301 void SkSweepGradient::toString(SkString* str) const { 309 void SkSweepGradient::toString(SkString* str) const {
302 str->append("SkSweepGradient: ("); 310 str->append("SkSweepGradient: (");
303 311
304 str->append("center: ("); 312 str->append("center: (");
305 str->appendScalar(fCenter.fX); 313 str->appendScalar(fCenter.fX);
306 str->append(", "); 314 str->append(", ");
307 str->appendScalar(fCenter.fY); 315 str->appendScalar(fCenter.fY);
308 str->append(") "); 316 str->append(") ");
309 317
310 this->INHERITED::toString(str); 318 this->INHERITED::toString(str);
311 319
312 str->append(")"); 320 str->append(")");
313 } 321 }
314 #endif 322 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkSweepGradient.h ('k') | src/effects/gradients/SkTwoPointConicalGradient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698