- Revision
- 150088
- Author
- benja...@webkit.org
- Date
- 2013-05-14 14:14:51 -0700 (Tue, 14 May 2013)
Log Message
Get rid of Gradient::getColor()
https://bugs.webkit.org/show_bug.cgi?id=116089
Patch by Benjamin Poulain <bpoul...@apple.com> on 2013-05-14
Reviewed by Andreas Kling.
This code is now useless, remove it.
* html/canvas/CanvasGradient.h:
(CanvasGradient):
* platform/graphics/Gradient.cpp:
(WebCore::Gradient::Gradient):
(WebCore::Gradient::hash):
* platform/graphics/Gradient.h:
(Gradient):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (150087 => 150088)
--- trunk/Source/WebCore/ChangeLog 2013-05-14 20:37:13 UTC (rev 150087)
+++ trunk/Source/WebCore/ChangeLog 2013-05-14 21:14:51 UTC (rev 150088)
@@ -1,3 +1,20 @@
+2013-05-14 Benjamin Poulain <bpoul...@apple.com>
+
+ Get rid of Gradient::getColor()
+ https://bugs.webkit.org/show_bug.cgi?id=116089
+
+ Reviewed by Andreas Kling.
+
+ This code is now useless, remove it.
+
+ * html/canvas/CanvasGradient.h:
+ (CanvasGradient):
+ * platform/graphics/Gradient.cpp:
+ (WebCore::Gradient::Gradient):
+ (WebCore::Gradient::hash):
+ * platform/graphics/Gradient.h:
+ (Gradient):
+
2013-05-14 David Hyatt <hy...@apple.com>
REGRESSION: united.com has overlapping elements and is broken by flex box changes.
Modified: trunk/Source/WebCore/html/canvas/CanvasGradient.h (150087 => 150088)
--- trunk/Source/WebCore/html/canvas/CanvasGradient.h 2013-05-14 20:37:13 UTC (rev 150087)
+++ trunk/Source/WebCore/html/canvas/CanvasGradient.h 2013-05-14 21:14:51 UTC (rev 150088)
@@ -51,8 +51,6 @@
void addColorStop(float value, const String& color, ExceptionCode&);
- void getColor(float value, float* r, float* g, float* b, float* a) const { m_gradient->getColor(value, r, g, b, a); }
-
#if ENABLE(DASHBOARD_SUPPORT)
void setDashboardCompatibilityMode() { m_dashbardCompatibilityMode = true; }
#endif
Modified: trunk/Source/WebCore/platform/graphics/Gradient.cpp (150087 => 150088)
--- trunk/Source/WebCore/platform/graphics/Gradient.cpp 2013-05-14 20:37:13 UTC (rev 150087)
+++ trunk/Source/WebCore/platform/graphics/Gradient.cpp 2013-05-14 21:14:51 UTC (rev 150088)
@@ -44,7 +44,6 @@
, m_r1(0)
, m_aspectRatio(1)
, m_stopsSorted(false)
- , m_lastStop(0)
, m_spreadMethod(SpreadMethodPad)
, m_cachedHash(0)
{
@@ -59,7 +58,6 @@
, m_r1(r1)
, m_aspectRatio(aspectRatio)
, m_stopsSorted(false)
- , m_lastStop(0)
, m_spreadMethod(SpreadMethodPad)
, m_cachedHash(0)
{
@@ -138,73 +136,6 @@
invalidateHash();
}
-void Gradient::getColor(float value, float* r, float* g, float* b, float* a) const
-{
- ASSERT(value >= 0);
- ASSERT(value <= 1);
-
- if (m_stops.isEmpty()) {
- *r = 0;
- *g = 0;
- *b = 0;
- *a = 0;
- return;
- }
- if (!m_stopsSorted) {
- if (m_stops.size())
- std::stable_sort(m_stops.begin(), m_stops.end(), compareStops);
- m_stopsSorted = true;
- }
- if (value <= 0 || value <= m_stops.first().stop) {
- *r = m_stops.first().red;
- *g = m_stops.first().green;
- *b = m_stops.first().blue;
- *a = m_stops.first().alpha;
- return;
- }
- if (value >= 1 || value >= m_stops.last().stop) {
- *r = m_stops.last().red;
- *g = m_stops.last().green;
- *b = m_stops.last().blue;
- *a = m_stops.last().alpha;
- return;
- }
-
- // Find stop before and stop after and interpolate.
- int stop = findStop(value);
- const ColorStop& lastStop = m_stops[stop];
- const ColorStop& nextStop = m_stops[stop + 1];
- float stopFraction = (value - lastStop.stop) / (nextStop.stop - lastStop.stop);
- *r = lastStop.red + (nextStop.red - lastStop.red) * stopFraction;
- *g = lastStop.green + (nextStop.green - lastStop.green) * stopFraction;
- *b = lastStop.blue + (nextStop.blue - lastStop.blue) * stopFraction;
- *a = lastStop.alpha + (nextStop.alpha - lastStop.alpha) * stopFraction;
-}
-
-int Gradient::findStop(float value) const
-{
- ASSERT(value >= 0);
- ASSERT(value <= 1);
- ASSERT(m_stopsSorted);
-
- int numStops = m_stops.size();
- ASSERT(numStops >= 2);
- ASSERT(m_lastStop < numStops - 1);
-
- int i = m_lastStop;
- if (value < m_stops[i].stop)
- i = 1;
- else
- i = m_lastStop + 1;
-
- for (; i < numStops - 1; ++i)
- if (value < m_stops[i].stop)
- break;
-
- m_lastStop = i - 1;
- return m_lastStop;
-}
-
bool Gradient::hasAlpha() const
{
for (size_t i = 0; i < m_stops.size(); i++) {
@@ -257,7 +188,6 @@
float r0;
float r1;
float aspectRatio;
- int lastStop;
GradientSpreadMethod spreadMethod;
bool radial;
} parameters;
@@ -275,7 +205,6 @@
parameters.r0 = m_r0;
parameters.r1 = m_r1;
parameters.aspectRatio = m_aspectRatio;
- parameters.lastStop = m_lastStop;
parameters.spreadMethod = m_spreadMethod;
parameters.radial = m_radial;
Modified: trunk/Source/WebCore/platform/graphics/Gradient.h (150087 => 150088)
--- trunk/Source/WebCore/platform/graphics/Gradient.h 2013-05-14 20:37:13 UTC (rev 150087)
+++ trunk/Source/WebCore/platform/graphics/Gradient.h 2013-05-14 21:14:51 UTC (rev 150088)
@@ -85,7 +85,6 @@
void addColorStop(const ColorStop&);
void addColorStop(float, const Color&);
- void getColor(float value, float* r, float* g, float* b, float* a) const;
bool hasAlpha() const;
bool isRadial() const { return m_radial; }
@@ -186,7 +185,6 @@
void platformInit() { m_gradient = 0; }
void platformDestroy();
- int findStop(float value) const;
void sortStopsIfNecessary();
// Keep any parameters relevant to rendering in sync with the structure in Gradient::hash().
@@ -198,7 +196,6 @@
float m_aspectRatio; // For elliptical gradient, width / height.
mutable Vector<ColorStop, 2> m_stops;
mutable bool m_stopsSorted;
- mutable int m_lastStop;
GradientSpreadMethod m_spreadMethod;
AffineTransform m_gradientSpaceTransformation;