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

Unified Diff: third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp

Issue 1403393004: JPEGImageDecoder RGB565 and downsample support and related Skia imagegenerator changes Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Continued decoding fix and downscale combined Created 5 years, 2 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
Index: third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp
diff --git a/third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp b/third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp
index 3b75b8c146cb4f2e29ea3f220fac0f9797a9cdfd..bef0489f1176660c337d65235c86e03de0a9ef5b 100644
--- a/third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp
+++ b/third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp
@@ -46,7 +46,6 @@ ImageFrame& ImageFrame::operator=(const ImageFrame& other)
{
if (this == &other)
return *this;
-
m_bitmap = other.m_bitmap;
// Keep the pixels locked since we will be writing directly into the
// bitmap throughout this object's lifetime.
@@ -94,12 +93,18 @@ bool ImageFrame::copyBitmapData(const ImageFrame& other)
return other.m_bitmap.copyTo(&m_bitmap, other.m_bitmap.colorType());
}
-bool ImageFrame::setSize(int newWidth, int newHeight)
+bool ImageFrame::setSize(int newWidth, int newHeight, ColorType bitmapType)
{
- // setSize() should only be called once, it leaks memory otherwise.
- ASSERT(!width() && !height());
+ // shouldn't be called with the same size, though not a problem if it happens
+ ASSERT(m_bitmap.isNull() || hasSize(IntSize(newWidth, newHeight), bitmapType));
+ if (bitmapType == RGBA8888) {
+ m_bitmap.setInfo(SkImageInfo::MakeN32Premul(newWidth, newHeight));
+ } else if (bitmapType == RGB565) {
+ m_bitmap.setInfo(SkImageInfo::Make(newWidth, newHeight, kRGB_565_SkColorType, kOpaque_SkAlphaType));
+ } else {
+ ASSERT(false);
+ }
- m_bitmap.setInfo(SkImageInfo::MakeN32Premul(newWidth, newHeight));
if (!m_bitmap.tryAllocPixels(m_allocator, 0))
return false;

Powered by Google App Engine
This is Rietveld 408576698