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

Unified Diff: src/pdf/SkPDFShader.cpp

Issue 1117423003: remove redundant/deprecated TwoPointRadial gradiet -- use TwoPointConical (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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 | « src/gpu/SkGpuDevice.cpp ('k') | tests/GradientTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFShader.cpp
diff --git a/src/pdf/SkPDFShader.cpp b/src/pdf/SkPDFShader.cpp
index cf4188123a8fd28d9a243fb1b2ee9998160ae212..c2f0bc4677120e600f6982c1ed83749d6d7a35a1 100644
--- a/src/pdf/SkPDFShader.cpp
+++ b/src/pdf/SkPDFShader.cpp
@@ -290,58 +290,6 @@ static SkString radialCode(const SkShader::GradientInfo& info,
return function;
}
-/* The math here is all based on the description in Two_Point_Radial_Gradient,
- with one simplification, the coordinate space has been scaled so that
- Dr = 1. This means we don't need to scale the entire equation by 1/Dr^2.
- */
-static SkString twoPointRadialCode(const SkShader::GradientInfo& info,
- const SkMatrix& perspectiveRemover) {
- SkScalar dx = info.fPoint[0].fX - info.fPoint[1].fX;
- SkScalar dy = info.fPoint[0].fY - info.fPoint[1].fY;
- SkScalar sr = info.fRadius[0];
- SkScalar a = SkScalarMul(dx, dx) + SkScalarMul(dy, dy) - SK_Scalar1;
- bool posRoot = info.fRadius[1] > info.fRadius[0];
-
- // We start with a stack of (x y), copy it and then consume one copy in
- // order to calculate b and the other to calculate c.
- SkString function("{");
-
- function.append(apply_perspective_to_coordinates(perspectiveRemover));
-
- function.append("2 copy ");
-
- // Calculate -b and b^2.
- function.appendScalar(dy);
- function.append(" mul exch ");
- function.appendScalar(dx);
- function.append(" mul add ");
- function.appendScalar(sr);
- function.append(" sub 2 mul neg dup dup mul\n");
-
- // Calculate c
- function.append("4 2 roll dup mul exch dup mul add ");
- function.appendScalar(SkScalarMul(sr, sr));
- function.append(" sub\n");
-
- // Calculate the determinate
- function.appendScalar(SkScalarMul(SkIntToScalar(4), a));
- function.append(" mul sub abs sqrt\n");
-
- // And then the final value of t.
- if (posRoot) {
- function.append("sub ");
- } else {
- function.append("add ");
- }
- function.appendScalar(SkScalarMul(SkIntToScalar(2), a));
- function.append(" div\n");
-
- tileModeCode(info.fTileMode, &function);
- gradientFunctionCode(info, &function);
- function.append("}");
- return function;
-}
-
/* Conical gradient shader, based on the Canvas spec for radial gradients
See: http://www.w3.org/TR/2dcontext/#dom-context-2d-createradialgradient
*/
@@ -782,17 +730,6 @@ SkPDFFunctionShader* SkPDFFunctionShader::Create(
transformPoints[1].fX += info->fRadius[0];
codeFunction = &radialCode;
break;
- case SkShader::kRadial2_GradientType: {
- // Bail out if the radii are the same.
- if (info->fRadius[0] == info->fRadius[1]) {
- return NULL;
- }
- transformPoints[1] = transformPoints[0];
- SkScalar dr = info->fRadius[1] - info->fRadius[0];
- transformPoints[1].fX += dr;
- codeFunction = &twoPointRadialCode;
- break;
- }
case SkShader::kConical_GradientType: {
transformPoints[1] = transformPoints[0];
transformPoints[1].fX += SK_Scalar1;
@@ -852,7 +789,7 @@ SkPDFFunctionShader* SkPDFFunctionShader::Create(
// state.fInfo
// in translating from x, y coordinates to the t parameter. So, we have
// to transform the points and radii according to the calculated matrix.
- if (state.fType == SkShader::kRadial2_GradientType) {
+ if (state.fType == SkShader::kConical_GradientType) {
SkShader::GradientInfo twoPointRadialInfo = *info;
SkMatrix inverseMapperMatrix;
if (!mapperMatrix.invert(&inverseMapperMatrix)) {
@@ -1143,7 +1080,6 @@ bool SkPDFShader::State::operator==(const SkPDFShader::State& b) const {
return false;
}
break;
- case SkShader::kRadial2_GradientType:
case SkShader::kConical_GradientType:
if (fInfo.fPoint[1] != b.fInfo.fPoint[1] ||
fInfo.fRadius[0] != b.fInfo.fRadius[0] ||
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | tests/GradientTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698