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

Unified Diff: Source/platform/graphics/ImageBuffer.cpp

Issue 203443004: use new readPixels, as old version using Config8888 is deprecated (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: return the image buffer, even if readPixels fails Created 6 years, 9 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 | « Source/platform/graphics/GraphicsContext.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/graphics/ImageBuffer.cpp
diff --git a/Source/platform/graphics/ImageBuffer.cpp b/Source/platform/graphics/ImageBuffer.cpp
index 4061b3da4ae5643486ae32565ba5161d715af0a4..dc908a14d25ff5ff746488cbe12f8a82fd09d0f3 100644
--- a/Source/platform/graphics/ImageBuffer.cpp
+++ b/Source/platform/graphics/ImageBuffer.cpp
@@ -300,25 +300,16 @@ PassRefPtr<Uint8ClampedArray> getImageData(const IntRect& rect, GraphicsContext*
RefPtr<Uint8ClampedArray> result = Uint8ClampedArray::createUninitialized(rect.width() * rect.height() * 4);
- unsigned char* data = result->data();
-
if (rect.x() < 0
|| rect.y() < 0
|| rect.maxX() > size.width()
|| rect.maxY() > size.height())
result->zeroFill();
- unsigned destBytesPerRow = 4 * rect.width();
- SkBitmap destBitmap;
- destBitmap.installPixels(SkImageInfo::MakeN32Premul(rect.width(), rect.height()), data, destBytesPerRow);
-
- SkCanvas::Config8888 config8888;
- if (multiplied == Premultiplied)
- config8888 = SkCanvas::kRGBA_Premul_Config8888;
- else
- config8888 = SkCanvas::kRGBA_Unpremul_Config8888;
+ SkAlphaType alphaType = (multiplied == Premultiplied) ? kPremul_SkAlphaType : kUnpremul_SkAlphaType;
+ SkImageInfo info = SkImageInfo::Make(rect.width(), rect.height(), kRGBA_8888_SkColorType, alphaType);
- context->readPixels(&destBitmap, rect.x(), rect.y(), config8888);
+ context->readPixels(info, result->data(), 4 * rect.width(), rect.x(), rect.y());
return result.release();
}
« no previous file with comments | « Source/platform/graphics/GraphicsContext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698