Chromium Code Reviews| Index: third_party/WebKit/Source/platform/graphics/ImageFrameGenerator.h |
| diff --git a/third_party/WebKit/Source/platform/graphics/ImageFrameGenerator.h b/third_party/WebKit/Source/platform/graphics/ImageFrameGenerator.h |
| index a177341eb26952ef934cffeeb18943f947fa3976..7852d995b4a17fa4ad3b94812540aadd74766f1c 100644 |
| --- a/third_party/WebKit/Source/platform/graphics/ImageFrameGenerator.h |
| +++ b/third_party/WebKit/Source/platform/graphics/ImageFrameGenerator.h |
| @@ -27,7 +27,8 @@ |
| #define ImageFrameGenerator_h |
| #include "platform/PlatformExport.h" |
| -#include "platform/graphics/ThreadSafeDataTransport.h" |
| +#include "platform/image-decoders/SegmentReader.h" |
| +#include "skia/ext/refptr.h" |
| #include "third_party/skia/include/core/SkBitmap.h" |
| #include "third_party/skia/include/core/SkSize.h" |
| #include "third_party/skia/include/core/SkTypes.h" |
| @@ -46,7 +47,6 @@ class SkData; |
| namespace blink { |
| class ImageDecoder; |
| -class SharedBuffer; |
| class PLATFORM_EXPORT ImageDecoderFactory { |
| USING_FAST_MALLOC(ImageDecoderFactory); |
| @@ -60,27 +60,21 @@ public: |
| class PLATFORM_EXPORT ImageFrameGenerator final : public ThreadSafeRefCounted<ImageFrameGenerator> { |
| WTF_MAKE_NONCOPYABLE(ImageFrameGenerator); |
| public: |
| - static PassRefPtr<ImageFrameGenerator> create(const SkISize& fullSize, PassRefPtr<SharedBuffer> data, bool allDataReceived, bool isMultiFrame = false) |
| + static PassRefPtr<ImageFrameGenerator> create(const SkISize& fullSize, bool isMultiFrame = false) |
| { |
| - return adoptRef(new ImageFrameGenerator(fullSize, data, allDataReceived, isMultiFrame)); |
| + return adoptRef(new ImageFrameGenerator(fullSize, isMultiFrame)); |
| } |
| ~ImageFrameGenerator(); |
| - void setData(PassRefPtr<SharedBuffer>, bool allDataReceived); |
| - |
| - // Return our encoded image data. Caller takes ownership and must unref the data |
| - // according to the contract SkImageGenerator::refEncodedData. Returns null if |
| - // the data is has not been fully received. |
| - SkData* refEncodedData(); |
| - |
| // Decodes and scales the specified frame at |index|. The dimensions and output |
| // format are given in SkImageInfo. Decoded pixels are written into |pixels| with |
| // a stride of |rowBytes|. Returns true if decoding was successful. |
| - bool decodeAndScale(size_t index, const SkImageInfo&, void* pixels, size_t rowBytes); |
| + bool decodeAndScale(SegmentReader*, bool allDataReceived, size_t index, const SkImageInfo&, void* pixels, size_t rowBytes); |
| // Decodes YUV components directly into the provided memory planes. |
| - bool decodeToYUV(size_t index, SkISize componentSizes[3], void* planes[3], size_t rowBytes[3]); |
| + // Must not be called unless getYUVCompenentSizes has been called and returned true. |
|
Peter Kasting
2016/03/23 02:42:58
Nit: Component
scroggo_chromium
2016/03/24 13:59:45
Done.
|
| + bool decodeToYUV(SegmentReader*, size_t index, SkISize componentSizes[3], void* planes[3], size_t rowBytes[3]); |
| const SkISize& getFullSize() const { return m_fullSize; } |
| @@ -89,10 +83,12 @@ public: |
| bool hasAlpha(size_t index); |
| - bool getYUVComponentSizes(SkISize componentSizes[3]); |
| + // Must not be called unless the SkROBuffer has all the data. |
| + // FIXME: YUV decoding does not currently support progressive decoding. |
| + bool getYUVComponentSizes(SegmentReader*, SkISize componentSizes[3]); |
| private: |
| - ImageFrameGenerator(const SkISize& fullSize, PassRefPtr<SharedBuffer>, bool allDataReceived, bool isMultiFrame); |
| + ImageFrameGenerator(const SkISize& fullSize, bool isMultiFrame); |
| friend class ImageFrameGeneratorTest; |
| friend class DeferredImageDecoderTest; |
| @@ -101,26 +97,20 @@ private: |
| void setHasAlpha(size_t index, bool hasAlpha); |
| - // These methods are called while m_decodeMutex is locked. |
| - SkBitmap tryToResumeDecode(size_t index, const SkISize& scaledSize); |
| - bool decode(size_t index, ImageDecoder**, SkBitmap*); |
| - |
| - SkISize m_fullSize; |
| + // FIXME: Change the parameter to take an SkBitmap::Allocator, and no need for declaring this class. |
|
Peter Kasting
2016/03/23 02:42:58
Are you planning to do that in this CL?
scroggo_chromium
2016/03/24 13:59:45
Done.
|
| + class ExternalMemoryAllocator; |
| + SkBitmap tryToResumeDecode(SegmentReader*, bool allDataReceived, size_t index, const SkISize& scaledSize, ExternalMemoryAllocator*); |
| + // This method is called while m_decodeMutex is locked. |
|
Peter Kasting
2016/03/23 02:42:58
Nit: Unclear what this means: can be called while,
scroggo_chromium
2016/03/24 13:59:45
Should. Done.
|
| + bool decode(SegmentReader*, bool allDataReceived, size_t index, ImageDecoder**, SkBitmap*, ExternalMemoryAllocator*); |
| - // ThreadSafeDataTransport is referenced by this class and m_encodedData. |
| - // In case that ImageFrameGenerator get's deleted before m_encodedData, |
| - // m_encodedData would hold the reference to it (and underlying data). |
| - RefPtr<ThreadSafeDataTransport> m_data; |
| + const SkISize m_fullSize; |
| - bool m_isMultiFrame; |
| + const bool m_isMultiFrame; |
| bool m_decodeFailed; |
| size_t m_frameCount; |
| Vector<bool> m_hasAlpha; |
| Vector<bool> m_frameComplete; |
| - class ExternalMemoryAllocator; |
| - OwnPtr<ExternalMemoryAllocator> m_externalAllocator; |
| - |
| OwnPtr<ImageDecoderFactory> m_imageDecoderFactory; |
| // Prevents multiple decode operations on the same data. |
| @@ -128,13 +118,6 @@ private: |
| // Protect concurrent access to m_hasAlpha. |
| Mutex m_alphaMutex; |
| - |
| - // Our encoded image data returned in refEncodedData. |
| - SkData* m_encodedData; |
| - |
| -#if COMPILER(MSVC) |
| - friend struct ::WTF::OwnedPtrDeleter<ExternalMemoryAllocator>; |
| -#endif |
| }; |
| } // namespace blink |