| Index: third_party/WebKit/Source/platform/graphics/Gradient.cpp
|
| diff --git a/third_party/WebKit/Source/platform/graphics/Gradient.cpp b/third_party/WebKit/Source/platform/graphics/Gradient.cpp
|
| index 000587b8b9e099e8304a2aa85e5200857be7962e..f7cae2883b6607736256079363666ea68564548f 100644
|
| --- a/third_party/WebKit/Source/platform/graphics/Gradient.cpp
|
| +++ b/third_party/WebKit/Source/platform/graphics/Gradient.cpp
|
| @@ -46,7 +46,7 @@ Gradient::Gradient(const FloatPoint& p0, const FloatPoint& p1)
|
| , m_r0(0)
|
| , m_r1(0)
|
| , m_aspectRatio(1)
|
| - , m_radial(false)
|
| + , m_class(LinearClass)
|
| , m_stopsSorted(false)
|
| , m_drawInPMColorSpace(false)
|
| , m_spreadMethod(SpreadMethodPad)
|
| @@ -59,7 +59,19 @@ Gradient::Gradient(const FloatPoint& p0, float r0, const FloatPoint& p1, float r
|
| , m_r0(r0)
|
| , m_r1(r1)
|
| , m_aspectRatio(aspectRatio)
|
| - , m_radial(true)
|
| + , m_class(RadialClass)
|
| + , m_stopsSorted(false)
|
| + , m_drawInPMColorSpace(false)
|
| + , m_spreadMethod(SpreadMethodPad)
|
| +{
|
| +}
|
| +
|
| +Gradient::Gradient(const FloatPoint& p0, float startAngle)
|
| + : m_p0(p0)
|
| + , m_r0(startAngle) // FIXME
|
| + , m_r1(0)
|
| + , m_aspectRatio(1)
|
| + , m_class(ConicClass)
|
| , m_stopsSorted(false)
|
| , m_drawInPMColorSpace(false)
|
| , m_spreadMethod(SpreadMethodPad)
|
| @@ -77,6 +89,7 @@ static inline bool compareStops(const Gradient::ColorStop& a, const Gradient::Co
|
|
|
| void Gradient::addColorStop(const Gradient::ColorStop& stop)
|
| {
|
| + printf("*** addColorStop: %f/%x\n", stop.stop, stop.color.rgb());
|
| if (m_stops.isEmpty()) {
|
| m_stopsSorted = true;
|
| } else {
|
| @@ -217,7 +230,8 @@ sk_sp<SkShader> Gradient::createShader()
|
|
|
| sk_sp<SkShader> shader;
|
| uint32_t shouldDrawInPMColorSpace = m_drawInPMColorSpace ? SkGradientShader::kInterpolateColorsInPremul_Flag : 0;
|
| - if (m_radial) {
|
| + switch (m_class) {
|
| + case RadialClass: {
|
| if (aspectRatio() != 1) {
|
| // CSS3 elliptical gradients: apply the elliptical scaling at the
|
| // gradient center point.
|
| @@ -239,10 +253,16 @@ sk_sp<SkShader> Gradient::createShader()
|
| SkScalar radius1 = m_r1 >= 0.0f ? WebCoreFloatToSkScalar(m_r1) : 0;
|
| shader = SkGradientShader::MakeTwoPointConical(m_p0.data(), radius0, m_p1.data(), radius1, colors.data(), pos.data(), static_cast<int>(countUsed), tile, shouldDrawInPMColorSpace, &localMatrix);
|
| }
|
| - } else {
|
| + } break;
|
| + case LinearClass: {
|
| SkPoint pts[2] = { m_p0.data(), m_p1.data() };
|
| SkMatrix localMatrix = affineTransformToSkMatrix(m_gradientSpaceTransformation);
|
| shader = SkGradientShader::MakeLinear(pts, colors.data(), pos.data(), static_cast<int>(countUsed), tile, shouldDrawInPMColorSpace, &localMatrix);
|
| + } break;
|
| + case ConicClass: {
|
| + SkMatrix localMatrix = affineTransformToSkMatrix(m_gradientSpaceTransformation);
|
| + shader = SkGradientShader::MakeSweep(m_p0.x(), m_p0.y(), colors.data(), pos.data(), static_cast<int>(countUsed), shouldDrawInPMColorSpace, &localMatrix);
|
| + } break;
|
| }
|
|
|
| if (!shader) {
|
|
|