Title: [90831] trunk/Source/WebCore
Revision
90831
Author
[email protected]
Date
2011-07-12 11:31:53 -0700 (Tue, 12 Jul 2011)

Log Message

[skia] optimize getImageData to avoid a copy when not needed. lockPixels() now does the right thing.
https://bugs.webkit.org/show_bug.cgi?id=64302

Patch by Mike Reed <[email protected]> on 2011-07-12
Reviewed by Stephen White.

No new tests. Just an optimization for getImageData(), existing <canvas> tests apply

* platform/graphics/skia/ImageBufferSkia.cpp:
(WebCore::getImageData):
(WebCore::putImageData):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (90830 => 90831)


--- trunk/Source/WebCore/ChangeLog	2011-07-12 18:20:16 UTC (rev 90830)
+++ trunk/Source/WebCore/ChangeLog	2011-07-12 18:31:53 UTC (rev 90831)
@@ -1,3 +1,16 @@
+2011-07-12  Mike Reed  <[email protected]>
+
+        [skia] optimize getImageData to avoid a copy when not needed. lockPixels() now does the right thing.
+        https://bugs.webkit.org/show_bug.cgi?id=64302
+
+        Reviewed by Stephen White.
+
+        No new tests. Just an optimization for getImageData(), existing <canvas> tests apply
+
+        * platform/graphics/skia/ImageBufferSkia.cpp:
+        (WebCore::getImageData):
+        (WebCore::putImageData):
+
 2011-07-12  Pavel Feldman  <[email protected]>
 
         Web Inspector: introduce UserMetrics for collecting stats in Chromium port.

Modified: trunk/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp (90830 => 90831)


--- trunk/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp	2011-07-12 18:20:16 UTC (rev 90830)
+++ trunk/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp	2011-07-12 18:31:53 UTC (rev 90831)
@@ -223,7 +223,10 @@
     unsigned destBytesPerRow = 4 * rect.width();
 
     SkBitmap srcBitmap;
-    srcDevice.readPixels(SkIRect::MakeXYWH(originX, originY, numColumns, numRows), &srcBitmap);
+    SkIRect srcRect = SkIRect::MakeXYWH(originX, originY, numColumns, numRows);
+    if (!srcDevice.accessBitmap(false).extractSubset(&srcBitmap, srcRect))
+        return result.release();
+    SkAutoLockPixels alp(srcBitmap);
 
     unsigned char* destRow = data + destY * destBytesPerRow + destX * 4;
 
@@ -298,10 +301,8 @@
 
     unsigned srcBytesPerRow = 4 * sourceSize.width();
 
-    SkBitmap deviceBitmap = dstDevice->accessBitmap(true);
-
-    // If the device's bitmap doesn't have pixels we will make a temp and call writePixels on the device.
-    bool temporaryBitmap = !!deviceBitmap.getTexture();
+    const SkBitmap& deviceBitmap = dstDevice->accessBitmap(true);
+    bool temporaryBitmap = !deviceBitmap.lockPixelsAreWritable();
     SkBitmap destBitmap;
 
     if (temporaryBitmap) {
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to