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

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

Issue 224083002: Add base effect for gpu 2pt conical gradients (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Patch merging Created 6 years, 8 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 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkTwoPointConicalGradient.h" 8 #include "SkTwoPointConicalGradient.h"
9 9
10 #include "SkTwoPointConicalGradient_gpu.h" 10 #include "SkTwoPointConicalGradient_gpu.h"
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 buffer.writePoint(fCenter2); 328 buffer.writePoint(fCenter2);
329 buffer.writeScalar(fRadius1); 329 buffer.writeScalar(fRadius1);
330 buffer.writeScalar(fRadius2); 330 buffer.writeScalar(fRadius2);
331 } 331 }
332 332
333 #if SK_SUPPORT_GPU 333 #if SK_SUPPORT_GPU
334 334
335 GrEffectRef* SkTwoPointConicalGradient::asNewEffect(GrContext* context, const Sk Paint&) const { 335 GrEffectRef* SkTwoPointConicalGradient::asNewEffect(GrContext* context, const Sk Paint&) const {
336 SkASSERT(NULL != context); 336 SkASSERT(NULL != context);
337 SkASSERT(fPtsToUnit.isIdentity()); 337 SkASSERT(fPtsToUnit.isIdentity());
338 // invert the localM, translate to center1, rotate so center2 is on x axis.
339 SkMatrix matrix;
340 if (!this->getLocalMatrix().invert(&matrix)) {
341 return NULL;
342 }
343 matrix.postTranslate(-fCenter1.fX, -fCenter1.fY);
344 338
345 SkPoint diff = fCenter2 - fCenter1; 339 return Gr2PtConicalGradientEffect::Create(context, *this, fTileMode);
346 SkScalar diffLen = diff.length();
347 if (0 != diffLen) {
348 SkScalar invDiffLen = SkScalarInvert(diffLen);
349 SkMatrix rot;
350 rot.setSinCos(-SkScalarMul(invDiffLen, diff.fY),
351 SkScalarMul(invDiffLen, diff.fX));
352 matrix.postConcat(rot);
353 }
354
355 return Gr2PtConicalGradientEffect::Create(context, *this, matrix, fTileMode) ;
356 } 340 }
357 341
358 #else 342 #else
359 343
360 GrEffectRef* SkTwoPointConicalGradient::asNewEffect(GrContext*, const SkPaint&) const { 344 GrEffectRef* SkTwoPointConicalGradient::asNewEffect(GrContext*, const SkPaint&) const {
361 SkDEBUGFAIL("Should not call in GPU-less build"); 345 SkDEBUGFAIL("Should not call in GPU-less build");
362 return NULL; 346 return NULL;
363 } 347 }
364 348
365 #endif 349 #endif
(...skipping 16 matching lines...) Expand all
382 str->appendScalar(fCenter2.fY); 366 str->appendScalar(fCenter2.fY);
383 str->append(") radius2: "); 367 str->append(") radius2: ");
384 str->appendScalar(fRadius2); 368 str->appendScalar(fRadius2);
385 str->append(" "); 369 str->append(" ");
386 370
387 this->INHERITED::toString(str); 371 this->INHERITED::toString(str);
388 372
389 str->append(")"); 373 str->append(")");
390 } 374 }
391 #endif 375 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkTwoPointConicalGradient.h ('k') | src/effects/gradients/SkTwoPointConicalGradient_gpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698