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..fa01521e116ff0e65fc1beb8b0b43a43f448b4b7 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 = kRGBA_8888_SkColorType, |
+ RGB565 = kRGB_565_SkColorType |
+ }; |
+ |
typedef uint32_t PixelData; |
+ typedef uint16_t PixelData16; |
ImageFrame(); |
@@ -109,7 +116,8 @@ 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); |
+ // called from decoder before start writing pixel data |
scroggo_chromium
2015/10/19 20:41:36
I don't see how this says anything different from
aleksandar.stojiljkovic
2015/10/20 09:51:12
Updating it, "Must only be called once" is not nee
|
+ bool setSize(int newWidth, int newHeight, ColorType bitmapType = RGBA8888); |
// 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 +154,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 +192,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); |
aleksandar.stojiljkovic
2015/10/19 18:17:09
Dither: Don't know if it makes sense to use ordere
|
+ } |
+ |
// Notifies the SkBitmap if any pixels changed and resets the flag. |
inline void notifyBitmapIfPixelsChanged() |
{ |
@@ -218,6 +237,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 |