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

Unified Diff: gm/gradients_2pt_conical.cpp

Issue 245963010: Move SkShader::fLocalMatrix into SkShader constructor. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nit 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/gradients.cpp ('k') | gm/hairmodes.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/gradients_2pt_conical.cpp
diff --git a/gm/gradients_2pt_conical.cpp b/gm/gradients_2pt_conical.cpp
index 93bddb2f7b5fe47f5f3d7019d30a83b82d02e8c9..7f0467e53e54b067fa4357007d8574c7774dfa9e 100644
--- a/gm/gradients_2pt_conical.cpp
+++ b/gm/gradients_2pt_conical.cpp
@@ -38,7 +38,8 @@ static const GradData gGradData[] = {
};
static SkShader* Make2ConicalOutside(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+ 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 @@ static SkShader* Make2ConicalOutside(const SkPoint pts[2], const GradData& data,
return SkGradientShader::CreateTwoPointConical(center0, radius0,
center1, radius1,
data.fColors, data.fPos,
- data.fCount, tm, mapper);
+ data.fCount, tm, mapper,
+ 0, &localMatrix);
}
static SkShader* Make2ConicalOutsideFlip(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+ 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,89 +63,97 @@ static SkShader* Make2ConicalOutsideFlip(const SkPoint pts[2], const GradData& d
return SkGradientShader::CreateTwoPointConical(center1, radius1,
center0, radius0,
data.fColors, data.fPos,
- data.fCount, tm, mapper);
+ data.fCount, tm, mapper,
+ 0, &localMatrix);
}
static SkShader* Make2ConicalInside(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+ 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));
center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
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, mapper);
+ 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, mapper,
+ 0, &localMatrix);
}
static SkShader* Make2ConicalInsideFlip(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+ 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));
center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
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, mapper);
+ 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, mapper,
+ 0, &localMatrix);
}
static SkShader* Make2ConicalInsideCenter(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+ 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));
center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
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, mapper);
+ 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, mapper,
+ 0, &localMatrix);
}
static SkShader* Make2ConicalZeroRad(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+ 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));
center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
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, mapper);
+ return SkGradientShader::CreateTwoPointConical(center1, 0.f,
+ center0, (pts[1].fX - pts[0].fX) / 2,
+ data.fColors, data.fPos, data.fCount, tm, mapper,
+ 0, &localMatrix);
}
static SkShader* Make2ConicalZeroRadFlip(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+ 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));
center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
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, mapper);
+ return SkGradientShader::CreateTwoPointConical(center1, (pts[1].fX - pts[0].fX) / 2,
+ center0, 0.f,
+ data.fColors, data.fPos, data.fCount, tm, mapper,
+ 0, &localMatrix);
}
static SkShader* Make2ConicalZeroRadCenter(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+ 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));
center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
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, mapper);
+ return SkGradientShader::CreateTwoPointConical(center0, 0.f,
+ center0, (pts[1].fX - pts[0].fX) / 2,
+ data.fColors, data.fPos, data.fCount, tm, mapper,
+ 0, &localMatrix);
}
static SkShader* Make2ConicalZeroRadOutside(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+ 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 @@ static SkShader* Make2ConicalZeroRadOutside(const SkPoint pts[2], const GradData
return SkGradientShader::CreateTwoPointConical(center0, radius0,
center1, radius1,
data.fColors, data.fPos,
- data.fCount, tm, mapper);
+ data.fCount, tm, mapper,
+ 0, &localMatrix);
}
static SkShader* Make2ConicalZeroRadFlipOutside(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+ 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 @@ static SkShader* Make2ConicalZeroRadFlipOutside(const SkPoint pts[2], const Grad
return SkGradientShader::CreateTwoPointConical(center1, radius1,
center0, radius0,
data.fColors, data.fPos,
- data.fCount, tm, mapper);
+ data.fCount, tm, mapper,
+ 0, &localMatrix);
}
static SkShader* Make2ConicalEdgeX(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+ 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 @@ static SkShader* Make2ConicalEdgeX(const SkPoint pts[2], const GradData& data,
return SkGradientShader::CreateTwoPointConical(center0, radius0,
center1, radius1,
data.fColors, data.fPos,
- data.fCount, tm, mapper);
+ data.fCount, tm, mapper,
+ 0, &localMatrix);
}
static SkShader* Make2ConicalEdgeY(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+ 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 @@ static SkShader* Make2ConicalEdgeY(const SkPoint pts[2], const GradData& data,
return SkGradientShader::CreateTwoPointConical(center0, radius0,
center1, radius1,
data.fColors, data.fPos,
- data.fCount, tm, mapper);
+ data.fCount, tm, mapper,
+ 0, &localMatrix);
}
static SkShader* Make2ConicalZeroRadEdgeX(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+ 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 @@ static SkShader* Make2ConicalZeroRadEdgeX(const SkPoint pts[2], const GradData&
return SkGradientShader::CreateTwoPointConical(center0, radius0,
center1, radius1,
data.fColors, data.fPos,
- data.fCount, tm, mapper);
+ data.fCount, tm, mapper,
+ 0, &localMatrix);
}
static SkShader* Make2ConicalZeroRadEdgeY(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+ 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 @@ static SkShader* Make2ConicalZeroRadEdgeY(const SkPoint pts[2], const GradData&
return SkGradientShader::CreateTwoPointConical(center0, radius0,
center1, radius1,
data.fColors, data.fPos,
- data.fCount, tm, mapper);
+ data.fCount, tm, mapper,
+ 0, &localMatrix);
}
static SkShader* Make2ConicalTouchX(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+ 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 @@ static SkShader* Make2ConicalTouchX(const SkPoint pts[2], const GradData& data,
return SkGradientShader::CreateTwoPointConical(center0, radius0,
center1, radius1,
data.fColors, data.fPos,
- data.fCount, tm, mapper);
+ data.fCount, tm, mapper,
+ 0, &localMatrix);
}
static SkShader* Make2ConicalTouchY(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+ 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,24 +272,27 @@ static SkShader* Make2ConicalTouchY(const SkPoint pts[2], const GradData& data,
return SkGradientShader::CreateTwoPointConical(center0, radius0,
center1, radius1,
data.fColors, data.fPos,
- data.fCount, tm, mapper);
+ data.fCount, tm, mapper,
+ 0, &localMatrix);
}
static SkShader* Make2ConicalInsideSmallRad(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+ 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));
center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
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, mapper);
+ return SkGradientShader::CreateTwoPointConical(center0, 0.0000000000000000001f,
+ center0, (pts[1].fX - pts[0].fX) / 2,
+ data.fColors, data.fPos, data.fCount, tm, mapper,
+ 0, &localMatrix);
}
typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper);
+ SkShader::TileMode tm, SkUnitMapper* mapper,
+ const SkMatrix& localMatrix);
static const GradMaker gGradMakersOutside[] = {
Make2ConicalOutside, Make2ConicalOutsideFlip,
@@ -336,15 +364,14 @@ protected:
for (size_t i = 0; i < SK_ARRAY_COUNT(gGradData); i++) {
canvas->save();
for (int j = 0; j < count; j++) {
- SkShader* shader = gradMaker[j](pts, gGradData[i], tm, NULL);
+ SkMatrix scale = SkMatrix::I();
if (i == 3) { // if the clamp case
- SkMatrix scale;
scale.setScale(0.5f, 0.5f);
scale.postTranslate(25.f, 25.f);
- shader->setLocalMatrix(scale);
}
+ SkShader* shader = gradMaker[j](pts, gGradData[i], tm, NULL, scale);
paint.setShader(shader);
canvas->drawRect(r, paint);
shader->unref();
« no previous file with comments | « gm/gradients.cpp ('k') | gm/hairmodes.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698