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

Unified Diff: src/effects/gradients/SkRadialGradient.cpp

Issue 793763003: Gradient shaders: make fPtsToUnit const, pre-cache getType(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/effects/gradients/SkLinearGradient.cpp ('k') | src/effects/gradients/SkSweepGradient.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/gradients/SkRadialGradient.cpp
diff --git a/src/effects/gradients/SkRadialGradient.cpp b/src/effects/gradients/SkRadialGradient.cpp
index e880df25cbbe59aa8d665467a26a995624b601b4..c10c555147fa4ee11dcf491c41d0ca722eddd191 100644
--- a/src/effects/gradients/SkRadialGradient.cpp
+++ b/src/effects/gradients/SkRadialGradient.cpp
@@ -12,6 +12,8 @@
#define kSQRT_TABLE_BITS 11
#define kSQRT_TABLE_SIZE (1 << kSQRT_TABLE_BITS)
+SK_COMPILE_ASSERT(sizeof(gSqrt8Table) == kSQRT_TABLE_SIZE, SqrtTableSizesMatch);
+
#if 0
#include <stdio.h>
@@ -55,12 +57,13 @@ inline SkFixed repeat_tileproc_nonstatic(SkFixed x) {
return repeat_tileproc(x);
}
-void rad_to_unit_matrix(const SkPoint& center, SkScalar radius,
- SkMatrix* matrix) {
+SkMatrix rad_to_unit_matrix(const SkPoint& center, SkScalar radius) {
SkScalar inv = SkScalarInvert(radius);
- matrix->setTranslate(-center.fX, -center.fY);
- matrix->postScale(inv, inv);
+ SkMatrix matrix;
+ matrix.setTranslate(-center.fX, -center.fY);
+ matrix.postScale(inv, inv);
+ return matrix;
}
typedef void (* RadialShade16Proc)(SkScalar sfx, SkScalar sdx,
@@ -146,14 +149,9 @@ void shadeSpan16_radial_repeat(SkScalar fx, SkScalar dx, SkScalar fy, SkScalar d
/////////////////////////////////////////////////////////////////////
SkRadialGradient::SkRadialGradient(const SkPoint& center, SkScalar radius, const Descriptor& desc)
- : SkGradientShaderBase(desc)
+ : SkGradientShaderBase(desc, rad_to_unit_matrix(center, radius))
, fCenter(center)
- , fRadius(radius)
-{
- // make sure our table is insync with our current #define for kSQRT_TABLE_SIZE
- SkASSERT(sizeof(gSqrt8Table) == kSQRT_TABLE_SIZE);
-
- rad_to_unit_matrix(center, radius, &fPtsToUnit);
+ , fRadius(radius) {
}
size_t SkRadialGradient::contextSize() const {
« no previous file with comments | « src/effects/gradients/SkLinearGradient.cpp ('k') | src/effects/gradients/SkSweepGradient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698