Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Unified Diff: Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp

Issue 9331005: Merge 106477 - [SKIA/CHROMIUM] Perform getImageData format conversions using Skia (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1025/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/platform/chromium/test_expectations.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
===================================================================
--- Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp (revision 106816)
+++ Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp (working copy)
@@ -226,65 +226,18 @@
|| rect.maxY() > size.height())
memset(data, 0, result->length());
- int originX = rect.x();
- int destX = 0;
- if (originX < 0) {
- destX = -originX;
- originX = 0;
- }
- int endX = rect.maxX();
- if (endX > size.width())
- endX = size.width();
- int numColumns = endX - originX;
-
- if (numColumns <= 0)
- return result.release();
-
- int originY = rect.y();
- int destY = 0;
- if (originY < 0) {
- destY = -originY;
- originY = 0;
- }
- int endY = rect.maxY();
- if (endY > size.height())
- endY = size.height();
- int numRows = endY - originY;
-
- if (numRows <= 0)
- return result.release();
-
- SkBitmap srcBitmap;
- if (!canvas->readPixels(SkIRect::MakeXYWH(originX, originY, numColumns, numRows), &srcBitmap))
- return result.release();
-
unsigned destBytesPerRow = 4 * rect.width();
- unsigned char* destRow = data + destY * destBytesPerRow + destX * 4;
+ SkBitmap destBitmap;
+ destBitmap.setConfig(SkBitmap::kARGB_8888_Config, rect.width(), rect.height(), destBytesPerRow);
+ destBitmap.setPixels(data);
- // Do conversion of byte order and alpha divide (if necessary)
- for (int y = 0; y < numRows; ++y) {
- SkPMColor* srcBitmapRow = srcBitmap.getAddr32(0, y);
- for (int x = 0; x < numColumns; ++x) {
- SkPMColor srcPMColor = srcBitmapRow[x];
- unsigned char* destPixel = &destRow[x * 4];
- if (multiplied == Unmultiplied) {
- unsigned char a = SkGetPackedA32(srcPMColor);
- destPixel[0] = a ? SkGetPackedR32(srcPMColor) * 255 / a : 0;
- destPixel[1] = a ? SkGetPackedG32(srcPMColor) * 255 / a : 0;
- destPixel[2] = a ? SkGetPackedB32(srcPMColor) * 255 / a : 0;
- destPixel[3] = a;
- } else {
- // Input and output are both pre-multiplied, we just need to re-arrange the
- // bytes from the bitmap format to RGBA.
- destPixel[0] = SkGetPackedR32(srcPMColor);
- destPixel[1] = SkGetPackedG32(srcPMColor);
- destPixel[2] = SkGetPackedB32(srcPMColor);
- destPixel[3] = SkGetPackedA32(srcPMColor);
- }
- }
- destRow += destBytesPerRow;
- }
+ SkCanvas::Config8888 config8888;
+ if (multiplied == Premultiplied)
+ config8888 = SkCanvas::kRGBA_Premul_Config8888;
+ else
+ config8888 = SkCanvas::kRGBA_Unpremul_Config8888;
+ canvas->readPixels(&destBitmap, rect.x(), rect.y(), config8888);
return result.release();
}
« no previous file with comments | « LayoutTests/platform/chromium/test_expectations.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698