Title: [120905] trunk/Source/WebCore
Revision
120905
Author
[email protected]
Date
2012-06-20 23:08:47 -0700 (Wed, 20 Jun 2012)

Log Message

[cairo] improve putByteArray speed by avoiding max/min checks at Color construction.
https://bugs.webkit.org/show_bug.cgi?id=89138

Patch by Arnaud Renevier <[email protected]> on 2012-06-20
Reviewed by Adam Barth.

Color constructor accepts integer arguments and checks if they are
between 0 and 255. In some cases, we already known those numbers to be
within those boundaries. For example when using unsigned chars. So
this patch introduces Color::createUnChecked which return a Color
object without checking for boundaries.

No new tests: no behaviour change

* platform/graphics/Color.cpp:
(WebCore::colorFromPremultipliedARGB):
* platform/graphics/Color.h:
(WebCore::Color::createUnCheked):
(Color):
* platform/graphics/cairo/ImageBufferCairo.cpp:
(WebCore::ImageBuffer::putByteArray):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (120904 => 120905)


--- trunk/Source/WebCore/ChangeLog	2012-06-21 05:39:56 UTC (rev 120904)
+++ trunk/Source/WebCore/ChangeLog	2012-06-21 06:08:47 UTC (rev 120905)
@@ -1,3 +1,26 @@
+2012-06-20  Arnaud Renevier  <[email protected]>
+
+        [cairo] improve putByteArray speed by avoiding max/min checks at Color construction.
+        https://bugs.webkit.org/show_bug.cgi?id=89138
+
+        Reviewed by Adam Barth.
+
+        Color constructor accepts integer arguments and checks if they are
+        between 0 and 255. In some cases, we already known those numbers to be
+        within those boundaries. For example when using unsigned chars. So
+        this patch introduces Color::createUnChecked which return a Color
+        object without checking for boundaries.
+
+        No new tests: no behaviour change
+
+        * platform/graphics/Color.cpp:
+        (WebCore::colorFromPremultipliedARGB):
+        * platform/graphics/Color.h:
+        (WebCore::Color::createUnCheked):
+        (Color):
+        * platform/graphics/cairo/ImageBufferCairo.cpp:
+        (WebCore::ImageBuffer::putByteArray):
+
 2012-06-20  Zeev Lieber  <[email protected]>
 
         [Chromium] Damage tracker is not used without partial swap, causing valid render passes to be removed

Modified: trunk/Source/WebCore/platform/graphics/Color.cpp (120904 => 120905)


--- trunk/Source/WebCore/platform/graphics/Color.cpp	2012-06-21 05:39:56 UTC (rev 120904)
+++ trunk/Source/WebCore/platform/graphics/Color.cpp	2012-06-21 06:08:47 UTC (rev 120905)
@@ -397,17 +397,18 @@
 
 Color colorFromPremultipliedARGB(unsigned pixelColor)
 {
-    RGBA32 rgba;
+    Color color;
 
     if (unsigned alpha = (pixelColor & 0xFF000000) >> 24) {
-        rgba = makeRGBA(((pixelColor & 0x00FF0000) >> 16) * 255 / alpha,
+        color = Color::createUnCheked(
+                        ((pixelColor & 0x00FF0000) >> 16) * 255 / alpha,
                         ((pixelColor & 0x0000FF00) >> 8) * 255 / alpha,
                          (pixelColor & 0x000000FF) * 255 / alpha,
                           alpha);
     } else
-        rgba = pixelColor;
+        color = Color(pixelColor);
 
-    return Color(rgba);
+    return color;
 }
 
 unsigned premultipliedARGBFromColor(const Color& color)

Modified: trunk/Source/WebCore/platform/graphics/Color.h (120904 => 120905)


--- trunk/Source/WebCore/platform/graphics/Color.h	2012-06-21 05:39:56 UTC (rev 120904)
+++ trunk/Source/WebCore/platform/graphics/Color.h	2012-06-21 06:08:47 UTC (rev 120905)
@@ -89,6 +89,17 @@
     explicit Color(const String&);
     explicit Color(const char*);
 
+    static Color createUnCheked(int r, int g, int b) 
+    {
+        RGBA32 color = 0xFF000000 | r << 16 | g << 8 | b;
+        return Color(color);
+    }
+    static Color createUnCheked(int r, int g, int b, int a) 
+    {
+        RGBA32 color = a << 24 | r << 16 | g << 8 | b;
+        return Color(color);
+    }
+
     // Returns the color serialized according to HTML5
     // - http://www.whatwg.org/specs/web-apps/current-work/#serialization-of-a-color
     String serialized() const;

Modified: trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp (120904 => 120905)


--- trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp	2012-06-21 05:39:56 UTC (rev 120904)
+++ trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp	2012-06-21 06:08:47 UTC (rev 120905)
@@ -241,10 +241,10 @@
         for (int x = 0; x < numColumns; x++) {
             int basex = x * 4;
             unsigned* pixel = row + x + destx;
-            Color pixelColor(srcRows[basex],
-                    srcRows[basex + 1],
-                    srcRows[basex + 2],
-                    srcRows[basex + 3]);
+            Color pixelColor = Color::createUnCheked(srcRows[basex],
+                                                     srcRows[basex + 1],
+                                                     srcRows[basex + 2],
+                                                     srcRows[basex + 3]);
             if (multiplied == Unmultiplied)
                 *pixel = premultipliedARGBFromColor(pixelColor);
             else
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to