Chromium Code Reviews| Index: Source/core/platform/graphics/DecodingImageGenerator.h |
| diff --git a/Source/core/platform/graphics/test/MockDiscardablePixelRef.h b/Source/core/platform/graphics/DecodingImageGenerator.h |
| similarity index 59% |
| copy from Source/core/platform/graphics/test/MockDiscardablePixelRef.h |
| copy to Source/core/platform/graphics/DecodingImageGenerator.h |
| index c1bd7fe21d71d15a94bd881cc323536daf43c256..f23fd4a6fda3f73ef129af20b425fa37e94a601e 100644 |
| --- a/Source/core/platform/graphics/test/MockDiscardablePixelRef.h |
| +++ b/Source/core/platform/graphics/DecodingImageGenerator.h |
| @@ -23,46 +23,41 @@ |
| * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| */ |
| -#ifndef MockDiscardablePixelRef_h |
| +#ifndef DecodingImageGenerator_h |
| +#define DecodingImageGenerator_h |
| -#include "SkBitmap.h" |
| -#include "SkPixelRef.h" |
| +#include "SkImageGenerator.h" |
| +#include "SkImageInfo.h" |
| -namespace WebCore { |
| +#include "wtf/RefPtr.h" |
| -class MockDiscardablePixelRef : public SkPixelRef { |
| -public: |
| - MockDiscardablePixelRef() : discarded(false) { setURI("discardable"); } |
| - ~MockDiscardablePixelRef() { } |
| +class SkData; |
| - void discard() |
| - { |
| - ASSERT(!m_lockedMemory); |
| - discarded = true; |
| - } |
| +namespace WebCore { |
| - SK_DECLARE_UNFLATTENABLE_OBJECT() |
| +class ImageFrameGenerator; |
| -protected: |
| - // SkPixelRef implementation. |
| - virtual void* onLockPixels(SkColorTable**) |
| - { |
| - if (discarded) |
| - return 0; |
| - m_lockedMemory = &discarded; |
| - return m_lockedMemory; |
| - } |
| +// Implements SkImageGenerator and used by SkPixelRef to populate a discardable |
| +// memory with decoded pixels. |
| +// |
| +// This class does not own an ImageDecode. It does not own encoded data. It serves |
| +// as and adapter to ImageFrameGenerator which actually performs decoding. |
|
Stephen White
2013/12/05 21:52:14
Naming nit: if it's an adapter, maybe it should ha
Alpha Left Google
2013/12/08 00:30:11
I prefer to keep this name. It sounds awkward to c
|
| +class DecodingImageGenerator : public SkImageGenerator { |
| +public: |
| + DecodingImageGenerator(PassRefPtr<ImageFrameGenerator>, const SkImageInfo&, size_t index); |
| + virtual ~DecodingImageGenerator(); |
| - virtual void onUnlockPixels() |
| - { |
| - m_lockedMemory = 0; |
| - } |
| + // SkImageGenerator implementation. |
| + virtual SkData* refEncodedData(); |
| + virtual bool getInfo(SkImageInfo*); |
| + virtual bool getPixels(const SkImageInfo&, void* pixels, size_t rowBytes); |
| private: |
| - void* m_lockedMemory; |
| - bool discarded; |
| + RefPtr<ImageFrameGenerator> m_frameGenerator; |
| + SkImageInfo m_imageInfo; |
| + size_t m_frameIndex; |
| }; |
| } // namespace WebCore |
| -#endif // MockDiscardablePixelRef_h |
| +#endif // DecodingImageGenerator_h_ |