Index: gm/gradients_2pt_conical.cpp |
diff --git a/gm/gradients_2pt_conical.cpp b/gm/gradients_2pt_conical.cpp |
index 27f0da186d1dd324e943e6f2552269aab809ff17..dece66ed8b2aa6ab2c29f40a15da229ff92694d8 100644 |
--- a/gm/gradients_2pt_conical.cpp |
+++ b/gm/gradients_2pt_conical.cpp |
@@ -1,10 +1,10 @@ |
+ |
/* |
* Copyright 2014 Google Inc. |
* |
* Use of this source code is governed by a BSD-style license that can be |
* found in the LICENSE file. |
*/ |
- |
#include "gm.h" |
#include "SkGradientShader.h" |
@@ -38,7 +38,8 @@ |
}; |
static SkShader* Make2ConicalOutside(const SkPoint pts[2], const GradData& data, |
- SkShader::TileMode tm, const SkMatrix& localMatrix) { |
+ SkShader::TileMode tm, SkUnitMapper* mapper, |
+ const SkMatrix& localMatrix) { |
SkPoint center0, center1; |
SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 10); |
SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3); |
@@ -47,11 +48,13 @@ |
return SkGradientShader::CreateTwoPointConical(center0, radius0, |
center1, radius1, |
data.fColors, data.fPos, |
- data.fCount, tm, 0, &localMatrix); |
+ data.fCount, tm, mapper, |
+ 0, &localMatrix); |
} |
static SkShader* Make2ConicalOutsideFlip(const SkPoint pts[2], const GradData& data, |
- SkShader::TileMode tm, const SkMatrix& localMatrix) { |
+ SkShader::TileMode tm, SkUnitMapper* mapper, |
+ const SkMatrix& localMatrix) { |
SkPoint center0, center1; |
SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 10); |
SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3); |
@@ -60,11 +63,13 @@ |
return SkGradientShader::CreateTwoPointConical(center1, radius1, |
center0, radius0, |
data.fColors, data.fPos, |
- data.fCount, tm, 0, &localMatrix); |
+ data.fCount, tm, mapper, |
+ 0, &localMatrix); |
} |
static SkShader* Make2ConicalInside(const SkPoint pts[2], const GradData& data, |
- SkShader::TileMode tm, const SkMatrix& localMatrix) { |
+ SkShader::TileMode tm, SkUnitMapper* mapper, |
+ const SkMatrix& localMatrix) { |
SkPoint center0, center1; |
center0.set(SkScalarAve(pts[0].fX, pts[1].fX), |
SkScalarAve(pts[0].fY, pts[1].fY)); |
@@ -72,12 +77,13 @@ |
SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); |
return SkGradientShader::CreateTwoPointConical(center1, (pts[1].fX - pts[0].fX) / 7, |
center0, (pts[1].fX - pts[0].fX) / 2, |
- data.fColors, data.fPos, data.fCount, tm, |
+ data.fColors, data.fPos, data.fCount, tm, mapper, |
0, &localMatrix); |
} |
static SkShader* Make2ConicalInsideFlip(const SkPoint pts[2], const GradData& data, |
- SkShader::TileMode tm, const SkMatrix& localMatrix) { |
+ SkShader::TileMode tm, SkUnitMapper* mapper, |
+ const SkMatrix& localMatrix) { |
SkPoint center0, center1; |
center0.set(SkScalarAve(pts[0].fX, pts[1].fX), |
SkScalarAve(pts[0].fY, pts[1].fY)); |
@@ -85,12 +91,13 @@ |
SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); |
return SkGradientShader::CreateTwoPointConical(center0, (pts[1].fX - pts[0].fX) / 2, |
center1, (pts[1].fX - pts[0].fX) / 7, |
- data.fColors, data.fPos, data.fCount, tm, |
+ data.fColors, data.fPos, data.fCount, tm, mapper, |
0, &localMatrix); |
} |
static SkShader* Make2ConicalInsideCenter(const SkPoint pts[2], const GradData& data, |
- SkShader::TileMode tm, const SkMatrix& localMatrix) { |
+ SkShader::TileMode tm, SkUnitMapper* mapper, |
+ const SkMatrix& localMatrix) { |
SkPoint center0, center1; |
center0.set(SkScalarAve(pts[0].fX, pts[1].fX), |
SkScalarAve(pts[0].fY, pts[1].fY)); |
@@ -98,12 +105,13 @@ |
SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); |
return SkGradientShader::CreateTwoPointConical(center0, (pts[1].fX - pts[0].fX) / 7, |
center0, (pts[1].fX - pts[0].fX) / 2, |
- data.fColors, data.fPos, data.fCount, tm, |
+ data.fColors, data.fPos, data.fCount, tm, mapper, |
0, &localMatrix); |
} |
static SkShader* Make2ConicalZeroRad(const SkPoint pts[2], const GradData& data, |
- SkShader::TileMode tm, const SkMatrix& localMatrix) { |
+ SkShader::TileMode tm, SkUnitMapper* mapper, |
+ const SkMatrix& localMatrix) { |
SkPoint center0, center1; |
center0.set(SkScalarAve(pts[0].fX, pts[1].fX), |
SkScalarAve(pts[0].fY, pts[1].fY)); |
@@ -111,12 +119,13 @@ |
SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); |
return SkGradientShader::CreateTwoPointConical(center1, 0.f, |
center0, (pts[1].fX - pts[0].fX) / 2, |
- data.fColors, data.fPos, data.fCount, tm, |
+ data.fColors, data.fPos, data.fCount, tm, mapper, |
0, &localMatrix); |
} |
static SkShader* Make2ConicalZeroRadFlip(const SkPoint pts[2], const GradData& data, |
- SkShader::TileMode tm, const SkMatrix& localMatrix) { |
+ SkShader::TileMode tm, SkUnitMapper* mapper, |
+ const SkMatrix& localMatrix) { |
SkPoint center0, center1; |
center0.set(SkScalarAve(pts[0].fX, pts[1].fX), |
SkScalarAve(pts[0].fY, pts[1].fY)); |
@@ -124,12 +133,13 @@ |
SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); |
return SkGradientShader::CreateTwoPointConical(center1, (pts[1].fX - pts[0].fX) / 2, |
center0, 0.f, |
- data.fColors, data.fPos, data.fCount, tm, |
+ data.fColors, data.fPos, data.fCount, tm, mapper, |
0, &localMatrix); |
} |
static SkShader* Make2ConicalZeroRadCenter(const SkPoint pts[2], const GradData& data, |
- SkShader::TileMode tm, const SkMatrix& localMatrix) { |
+ SkShader::TileMode tm, SkUnitMapper* mapper, |
+ const SkMatrix& localMatrix) { |
SkPoint center0, center1; |
center0.set(SkScalarAve(pts[0].fX, pts[1].fX), |
SkScalarAve(pts[0].fY, pts[1].fY)); |
@@ -137,12 +147,13 @@ |
SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); |
return SkGradientShader::CreateTwoPointConical(center0, 0.f, |
center0, (pts[1].fX - pts[0].fX) / 2, |
- data.fColors, data.fPos, data.fCount, tm, |
+ data.fColors, data.fPos, data.fCount, tm, mapper, |
0, &localMatrix); |
} |
static SkShader* Make2ConicalZeroRadOutside(const SkPoint pts[2], const GradData& data, |
- SkShader::TileMode tm, const SkMatrix& localMatrix) { |
+ SkShader::TileMode tm, SkUnitMapper* mapper, |
+ const SkMatrix& localMatrix) { |
SkPoint center0, center1; |
SkScalar radius0 = 0.f; |
SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3); |
@@ -151,11 +162,13 @@ |
return SkGradientShader::CreateTwoPointConical(center0, radius0, |
center1, radius1, |
data.fColors, data.fPos, |
- data.fCount, tm, 0, &localMatrix); |
+ data.fCount, tm, mapper, |
+ 0, &localMatrix); |
} |
static SkShader* Make2ConicalZeroRadFlipOutside(const SkPoint pts[2], const GradData& data, |
- SkShader::TileMode tm, const SkMatrix& localMatrix) { |
+ SkShader::TileMode tm, SkUnitMapper* mapper, |
+ const SkMatrix& localMatrix) { |
SkPoint center0, center1; |
SkScalar radius0 = 0.f; |
SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3); |
@@ -164,11 +177,13 @@ |
return SkGradientShader::CreateTwoPointConical(center1, radius1, |
center0, radius0, |
data.fColors, data.fPos, |
- data.fCount, tm, 0, &localMatrix); |
+ data.fCount, tm, mapper, |
+ 0, &localMatrix); |
} |
static SkShader* Make2ConicalEdgeX(const SkPoint pts[2], const GradData& data, |
- SkShader::TileMode tm, const SkMatrix& localMatrix) { |
+ SkShader::TileMode tm, SkUnitMapper* mapper, |
+ const SkMatrix& localMatrix) { |
SkPoint center0, center1; |
SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 7); |
SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3); |
@@ -178,11 +193,13 @@ |
return SkGradientShader::CreateTwoPointConical(center0, radius0, |
center1, radius1, |
data.fColors, data.fPos, |
- data.fCount, tm, 0, &localMatrix); |
+ data.fCount, tm, mapper, |
+ 0, &localMatrix); |
} |
static SkShader* Make2ConicalEdgeY(const SkPoint pts[2], const GradData& data, |
- SkShader::TileMode tm, const SkMatrix& localMatrix) { |
+ SkShader::TileMode tm, SkUnitMapper* mapper, |
+ const SkMatrix& localMatrix) { |
SkPoint center0, center1; |
SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 7); |
SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3); |
@@ -192,10 +209,12 @@ |
return SkGradientShader::CreateTwoPointConical(center0, radius0, |
center1, radius1, |
data.fColors, data.fPos, |
- data.fCount, tm, 0, &localMatrix); |
+ data.fCount, tm, mapper, |
+ 0, &localMatrix); |
} |
static SkShader* Make2ConicalZeroRadEdgeX(const SkPoint pts[2], const GradData& data, |
- SkShader::TileMode tm, const SkMatrix& localMatrix) { |
+ SkShader::TileMode tm, SkUnitMapper* mapper, |
+ const SkMatrix& localMatrix) { |
SkPoint center0, center1; |
SkScalar radius0 = 0.f; |
SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3); |
@@ -205,11 +224,13 @@ |
return SkGradientShader::CreateTwoPointConical(center0, radius0, |
center1, radius1, |
data.fColors, data.fPos, |
- data.fCount, tm, 0, &localMatrix); |
+ data.fCount, tm, mapper, |
+ 0, &localMatrix); |
} |
static SkShader* Make2ConicalZeroRadEdgeY(const SkPoint pts[2], const GradData& data, |
- SkShader::TileMode tm, const SkMatrix& localMatrix) { |
+ SkShader::TileMode tm, SkUnitMapper* mapper, |
+ const SkMatrix& localMatrix) { |
SkPoint center0, center1; |
SkScalar radius0 = 0.f; |
SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3); |
@@ -219,11 +240,13 @@ |
return SkGradientShader::CreateTwoPointConical(center0, radius0, |
center1, radius1, |
data.fColors, data.fPos, |
- data.fCount, tm, 0, &localMatrix); |
+ data.fCount, tm, mapper, |
+ 0, &localMatrix); |
} |
static SkShader* Make2ConicalTouchX(const SkPoint pts[2], const GradData& data, |
- SkShader::TileMode tm, const SkMatrix& localMatrix) { |
+ SkShader::TileMode tm, SkUnitMapper* mapper, |
+ const SkMatrix& localMatrix) { |
SkPoint center0, center1; |
SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 7); |
SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3); |
@@ -233,11 +256,13 @@ |
return SkGradientShader::CreateTwoPointConical(center0, radius0, |
center1, radius1, |
data.fColors, data.fPos, |
- data.fCount, tm, 0, &localMatrix); |
+ data.fCount, tm, mapper, |
+ 0, &localMatrix); |
} |
static SkShader* Make2ConicalTouchY(const SkPoint pts[2], const GradData& data, |
- SkShader::TileMode tm, const SkMatrix& localMatrix) { |
+ SkShader::TileMode tm, SkUnitMapper* mapper, |
+ const SkMatrix& localMatrix) { |
SkPoint center0, center1; |
SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 7); |
SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3); |
@@ -247,11 +272,13 @@ |
return SkGradientShader::CreateTwoPointConical(center0, radius0, |
center1, radius1, |
data.fColors, data.fPos, |
- data.fCount, tm, 0, &localMatrix); |
+ data.fCount, tm, mapper, |
+ 0, &localMatrix); |
} |
static SkShader* Make2ConicalInsideSmallRad(const SkPoint pts[2], const GradData& data, |
- SkShader::TileMode tm, const SkMatrix& localMatrix) { |
+ SkShader::TileMode tm, SkUnitMapper* mapper, |
+ const SkMatrix& localMatrix) { |
SkPoint center0, center1; |
center0.set(SkScalarAve(pts[0].fX, pts[1].fX), |
SkScalarAve(pts[0].fY, pts[1].fY)); |
@@ -259,12 +286,13 @@ |
SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); |
return SkGradientShader::CreateTwoPointConical(center0, 0.0000000000000000001f, |
center0, (pts[1].fX - pts[0].fX) / 2, |
- data.fColors, data.fPos, data.fCount, tm, |
+ data.fColors, data.fPos, data.fCount, tm, mapper, |
0, &localMatrix); |
} |
typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, |
- SkShader::TileMode tm, const SkMatrix& localMatrix); |
+ SkShader::TileMode tm, SkUnitMapper* mapper, |
+ const SkMatrix& localMatrix); |
static const GradMaker gGradMakersOutside[] = { |
Make2ConicalOutside, Make2ConicalOutsideFlip, |
@@ -350,7 +378,7 @@ |
scale.postTranslate(25.f, 25.f); |
} |
- SkShader* shader = gradMaker[j](pts, gGradData[i], tm, scale); |
+ SkShader* shader = gradMaker[j](pts, gGradData[i], tm, NULL, scale); |
paint.setShader(shader); |
canvas->drawRect(r, paint); |
shader->unref(); |