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

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

Issue 808703006: remove view matrix from context (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: one more fix Created 6 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 SkColor colors[kMaxRandomGradientColors]; 253 SkColor colors[kMaxRandomGradientColors];
254 SkScalar stopsArray[kMaxRandomGradientColors]; 254 SkScalar stopsArray[kMaxRandomGradientColors];
255 SkScalar* stops = stopsArray; 255 SkScalar* stops = stopsArray;
256 SkShader::TileMode tmIgnored; 256 SkShader::TileMode tmIgnored;
257 int colorCount = RandomGradientParams(random, colors, &stops, &tmIgnored); 257 int colorCount = RandomGradientParams(random, colors, &stops, &tmIgnored);
258 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateSweep(center.fX, cente r.fY, 258 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateSweep(center.fX, cente r.fY,
259 colors, stops, c olorCount)); 259 colors, stops, c olorCount));
260 SkPaint paint; 260 SkPaint paint;
261 GrFragmentProcessor* fp; 261 GrFragmentProcessor* fp;
262 GrColor paintColor; 262 GrColor paintColor;
263 SkAssertResult(shader->asFragmentProcessor(context, paint, NULL, &paintColor , &fp)); 263 SkAssertResult(shader->asFragmentProcessor(context, paint,
264 GrProcessorUnitTest::TestMatrix(r andom), NULL,
265 &paintColor, &fp));
264 return fp; 266 return fp;
265 } 267 }
266 268
267 ///////////////////////////////////////////////////////////////////// 269 /////////////////////////////////////////////////////////////////////
268 270
269 void GrGLSweepGradient::emitCode(GrGLFPBuilder* builder, 271 void GrGLSweepGradient::emitCode(GrGLFPBuilder* builder,
270 const GrFragmentProcessor& fp, 272 const GrFragmentProcessor& fp,
271 const char* outputColor, 273 const char* outputColor,
272 const char* inputColor, 274 const char* inputColor,
273 const TransformedCoordsArray& coords, 275 const TransformedCoordsArray& coords,
(...skipping 12 matching lines...) Expand all
286 } else { 288 } else {
287 t.printf("atan(- %s.y, -1.0 * %s.x) * 0.1591549430918 + 0.5", 289 t.printf("atan(- %s.y, -1.0 * %s.x) * 0.1591549430918 + 0.5",
288 coords2D.c_str(), coords2D.c_str()); 290 coords2D.c_str(), coords2D.c_str());
289 } 291 }
290 this->emitColor(builder, ge, t.c_str(), outputColor, inputColor, samplers); 292 this->emitColor(builder, ge, t.c_str(), outputColor, inputColor, samplers);
291 } 293 }
292 294
293 ///////////////////////////////////////////////////////////////////// 295 /////////////////////////////////////////////////////////////////////
294 296
295 bool SkSweepGradient::asFragmentProcessor(GrContext* context, const SkPaint& pai nt, 297 bool SkSweepGradient::asFragmentProcessor(GrContext* context, const SkPaint& pai nt,
298 const SkMatrix& viewM,
296 const SkMatrix* localMatrix, GrColor* paintColor, 299 const SkMatrix* localMatrix, GrColor* paintColor,
297 GrFragmentProcessor** effect) const { 300 GrFragmentProcessor** effect) const {
298 301
299 SkMatrix matrix; 302 SkMatrix matrix;
300 if (!this->getLocalMatrix().invert(&matrix)) { 303 if (!this->getLocalMatrix().invert(&matrix)) {
301 return false; 304 return false;
302 } 305 }
303 if (localMatrix) { 306 if (localMatrix) {
304 SkMatrix inv; 307 SkMatrix inv;
305 if (!localMatrix->invert(&inv)) { 308 if (!localMatrix->invert(&inv)) {
306 return false; 309 return false;
307 } 310 }
308 matrix.postConcat(inv); 311 matrix.postConcat(inv);
309 } 312 }
310 matrix.postConcat(fPtsToUnit); 313 matrix.postConcat(fPtsToUnit);
311 314
312 *effect = GrSweepGradient::Create(context, *this, matrix); 315 *effect = GrSweepGradient::Create(context, *this, matrix);
313 *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); 316 *paintColor = SkColor2GrColorJustAlpha(paint.getColor());
314 317
315 return true; 318 return true;
316 } 319 }
317 320
318 #else 321 #else
319 322
320 bool SkSweepGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa trix*, GrColor*, 323 bool SkSweepGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa trix&,
324 const SkMatrix*, GrColor*,
321 GrFragmentProcessor**) const { 325 GrFragmentProcessor**) const {
322 SkDEBUGFAIL("Should not call in GPU-less build"); 326 SkDEBUGFAIL("Should not call in GPU-less build");
323 return false; 327 return false;
324 } 328 }
325 329
326 #endif 330 #endif
327 331
328 #ifndef SK_IGNORE_TO_STRING 332 #ifndef SK_IGNORE_TO_STRING
329 void SkSweepGradient::toString(SkString* str) const { 333 void SkSweepGradient::toString(SkString* str) const {
330 str->append("SkSweepGradient: ("); 334 str->append("SkSweepGradient: (");
331 335
332 str->append("center: ("); 336 str->append("center: (");
333 str->appendScalar(fCenter.fX); 337 str->appendScalar(fCenter.fX);
334 str->append(", "); 338 str->append(", ");
335 str->appendScalar(fCenter.fY); 339 str->appendScalar(fCenter.fY);
336 str->append(") "); 340 str->append(") ");
337 341
338 this->INHERITED::toString(str); 342 this->INHERITED::toString(str);
339 343
340 str->append(")"); 344 str->append(")");
341 } 345 }
342 #endif 346 #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