Index: Source/platform/graphics/Gradient.cpp |
diff --git a/Source/platform/graphics/Gradient.cpp b/Source/platform/graphics/Gradient.cpp |
index ab3ac96cdaa7e9dd0126152b73766e29608b5c35..fd0cd09c4d33c1561f4b52e5aa30761fe09b0b68 100644 |
--- a/Source/platform/graphics/Gradient.cpp |
+++ b/Source/platform/graphics/Gradient.cpp |
@@ -70,12 +70,7 @@ Gradient::~Gradient() |
void Gradient::addColorStop(float value, const Color& color) |
{ |
- float r; |
- float g; |
- float b; |
- float a; |
- color.getRGBA(r, g, b, a); |
- m_stops.append(ColorStop(value, r, g, b, a)); |
+ m_stops.append(ColorStop(value, color)); |
m_stopsSorted = false; |
m_gradient.clear(); |
@@ -110,7 +105,7 @@ void Gradient::sortStopsIfNecessary() |
bool Gradient::hasAlpha() const |
{ |
for (size_t i = 0; i < m_stops.size(); i++) { |
- if (m_stops[i].alpha < 1) |
+ if (m_stops[i].color.hasAlpha()) |
return true; |
} |
@@ -147,16 +142,6 @@ void Gradient::setGradientSpaceTransform(const AffineTransform& gradientSpaceTra |
m_gradient->setLocalMatrix(affineTransformToSkMatrix(m_gradientSpaceTransformation)); |
} |
-static inline U8CPU F2B(float x) |
-{ |
- return static_cast<int>(x * 255); |
-} |
- |
-static SkColor makeSkColor(float a, float r, float g, float b) |
-{ |
- return SkColorSetARGB(F2B(a), F2B(r), F2B(g), F2B(b)); |
-} |
- |
// Determine the total number of stops needed, including pseudo-stops at the |
// ends as necessary. |
static size_t totalStopsNeeded(const Gradient::ColorStop* stopData, size_t count) |
@@ -185,7 +170,7 @@ static void fillStops(const Gradient::ColorStop* stopData, |
if (count < 1) { |
// A gradient with no stops must be transparent black. |
pos[0] = WebCoreFloatToSkScalar(0.0); |
- colors[0] = makeSkColor(0.0, 0.0, 0.0, 0.0); |
+ colors[0] = SK_ColorTRANSPARENT; |
start = 1; |
} else if (stop->stop > 0.0) { |
// Copy the first stop to 0.0. The first stop position may have a slight |
@@ -193,13 +178,13 @@ static void fillStops(const Gradient::ColorStop* stopData, |
// 0.0 comes through cleanly and people aren't likely to want a gradient |
// with a stop at (0 + epsilon). |
pos[0] = WebCoreFloatToSkScalar(0.0); |
- colors[0] = makeSkColor(stop->alpha, stop->red, stop->green, stop->blue); |
+ colors[0] = stop->color.rgb(); |
f(malita)
2014/03/17 18:50:17
We should use SkColorSetARGB() to avoid any packin
|
start = 1; |
} |
for (size_t i = start; i < start + count; i++) { |
pos[i] = WebCoreFloatToSkScalar(stop->stop); |
- colors[i] = makeSkColor(stop->alpha, stop->red, stop->green, stop->blue); |
+ colors[i] = stop->color.rgb(); |
f(malita)
2014/03/17 18:50:17
Ditto.
|
++stop; |
} |