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

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

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.h
diff --git a/third_party/WebKit/Source/platform/image-decoders/ImageFrame.h b/third_party/WebKit/Source/platform/image-decoders/ImageFrame.h
index fb7425755bd77887066531b171c6c8dc21c5b2d8..9566a6e4fe98ea4aac2349697cf8f034ec580fa3 100644
--- a/third_party/WebKit/Source/platform/image-decoders/ImageFrame.h
+++ b/third_party/WebKit/Source/platform/image-decoders/ImageFrame.h
@@ -66,7 +66,14 @@ public:
// overwrite the corresponding pixels).
BlendAtopBgcolor,
};
+
+ enum ColorType {
+ RGBA8888 = kN32_SkColorType,
+ RGB565 = kRGB_565_SkColorType
+ };
+
typedef uint32_t PixelData;
+ typedef uint16_t PixelData16;
ImageFrame();
@@ -107,9 +114,13 @@ public:
}
// Allocates space for the pixel data. Must be called before any pixels
- // are written. Must only be called once. Returns whether allocation
- // succeeded.
- bool setSize(int newWidth, int newHeight);
+ // are written. Returns whether allocation succeeded.
+ bool setSize(int newWidth, int newHeight, ColorType bitmapType = RGBA8888);
+ inline bool hasSize(const IntSize& size, ColorType bitmapType) const
+ {
+ // skip checking height, no stretching involved
+ return (m_bitmap.width() == size.width()) && (bitmapType == static_cast<ColorType>(m_bitmap.colorType()));
+ }
// Returns a caller-owned pointer to the underlying native image data.
// (Actual use: This pointer will be owned by BitmapImage and freed in
@@ -146,6 +157,12 @@ public:
return m_bitmap.getAddr32(x, y);
}
+ template<class T>
+ inline T* getAddrT(int x, int y)
+ {
+ ASSERT_NOT_REACHED();
+ }
+
inline void setRGBA(int x, int y, unsigned r, unsigned g, unsigned b, unsigned a)
{
setRGBA(getAddr(x, y), r, g, b, a);
@@ -178,6 +195,11 @@ public:
*dest = SkPackARGB32NoCheck(a, r, g, b);
}
+ static inline void setRGB565(PixelData16* dest, unsigned r, unsigned g, unsigned b)
+ {
+ *dest = SkDitherPack888ToRGB16(r, g, b);
+ }
+
// Notifies the SkBitmap if any pixels changed and resets the flag.
inline void notifyBitmapIfPixelsChanged()
{
@@ -218,6 +240,18 @@ private:
size_t m_requiredPreviousFrameIndex;
};
+template<>
+inline ImageFrame::PixelData* ImageFrame::getAddrT<ImageFrame::PixelData>(int x, int y)
+{
+ return m_bitmap.getAddr32(x, y);
+}
+
+template<>
+inline ImageFrame::PixelData16* ImageFrame::getAddrT<ImageFrame::PixelData16>(int x, int y)
+{
+ return m_bitmap.getAddr16(x, y);
+}
+
} // namespace blink
#endif

Powered by Google App Engine
This is Rietveld 408576698