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

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: 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 8b36a9d13a53166dba14682903eda09c6d99d9e4..e4cc59703a4724c673d2d0cc9fdb7a6fc93c2f99 100644
--- a/Source/platform/graphics/ImageBuffer.cpp
+++ b/Source/platform/graphics/ImageBuffer.cpp
@@ -270,25 +270,17 @@ 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 = (multiplied == Premultiplied) ? kPremul_SkAlphaType : kUnpremul_SkAlphaType;
f(malita) 2014/03/18 16:08:24 SkAlphaType alphaType = ...
reed1 2014/03/18 19:39:38 Doh!
+ SkImageInfo info = SkImageInfo::Make(rect.width(), rect.height(), kRGBA_8888_SkColorType, alphaType);
- context->readPixels(&destBitmap, rect.x(), rect.y(), config8888);
+ if (!context->readPixels(info, result->data(), 4 * rect.width(), rect.x(), rect.y()))
+ return nullptr;
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