More work on Bug 3781: Animation via canvas could be faster
authoroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Dec 2008 12:32:12 +0000 (12:32 +0000)
committeroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Dec 2008 12:32:12 +0000 (12:32 +0000)
<https://bugs.webkit.org/show_bug.cgi?id=3781>

Reviewed by Cameron Zwarich

Make use of the fast path parsing of color strings that Color
uses.  This improves performance of '#rgb', '#rrggbb', etc and
named (eg. 'green') colors.

Improves frame rate of test by around 40%

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@39526 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/html/CanvasStyle.cpp

index 2a1ac72..a046ead 100644 (file)
@@ -1,3 +1,20 @@
+2008-12-31  Oliver Hunt  <oliver@apple.com>
+
+        Reviewed by Cameron Zwarich.
+
+        More work on Bug 3781: Animation via canvas could be faster
+        <https://bugs.webkit.org/show_bug.cgi?id=3781>
+
+        Make use of the fast path parsing of color strings that Color
+        uses.  This improves performance of '#rgb', '#rrggbb', etc and
+        named (eg. 'green') colors.
+
+        Improves frame rate of test by around 40%
+
+        * html/CanvasStyle.cpp:
+        (WebCore::CanvasStyle::applyStrokeColor):
+        (WebCore::CanvasStyle::applyFillColor):
+
 2008-12-30  Simon Fraser  <simon.fraser@apple.com>
 
         Reviewed by Darin Adler
index 54debf3..0f00f2c 100644 (file)
@@ -105,12 +105,22 @@ void CanvasStyle::applyStrokeColor(GraphicsContext* context)
         return;
     switch (m_type) {
         case ColorString: {
+            Color c = Color(m_color);
+            if (c.isValid()) {
+                context->setStrokeColor(c.rgb());
+                break;
+            }
             RGBA32 color = 0; // default is transparant black
             if (CSSParser::parseColor(color, m_color))
                 context->setStrokeColor(color);
             break;
         }
         case ColorStringWithAlpha: {
+            Color c = Color(m_color);
+            if (c.isValid()) {
+                context->setStrokeColor(colorWithOverrideAlpha(c.rgb(), m_alpha));
+                break;
+            }
             RGBA32 color = 0; // default is transparant black
             if (CSSParser::parseColor(color, m_color))
                 context->setStrokeColor(colorWithOverrideAlpha(color, m_alpha));
@@ -156,12 +166,22 @@ void CanvasStyle::applyFillColor(GraphicsContext* context)
         return;
     switch (m_type) {
         case ColorString: {
+            Color c = Color(m_color);
+            if (c.isValid()){
+                context->setFillColor(c.rgb());
+                break;
+            }
             RGBA32 rgba = 0; // default is transparant black
             if (CSSParser::parseColor(rgba, m_color))
                 context->setFillColor(rgba);
             break;
         }
         case ColorStringWithAlpha: {
+            Color c = Color(m_color);
+            if (c.isValid()){
+                context->setFillColor(colorWithOverrideAlpha(c.rgb(), m_alpha));
+                break;
+            }
             RGBA32 color = 0; // default is transparant black
             if (CSSParser::parseColor(color, m_color))
                 context->setFillColor(colorWithOverrideAlpha(color, m_alpha));