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

Side by Side Diff: Source/core/platform/image-decoders/webp/WEBPImageDecoder.h

Issue 13980003: Add animation support for WebP images (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 6 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 14 matching lines...) Expand all
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #ifndef WEBPImageDecoder_h 29 #ifndef WEBPImageDecoder_h
30 #define WEBPImageDecoder_h 30 #define WEBPImageDecoder_h
31 31
32 #include "core/platform/image-decoders/ImageDecoder.h" 32 #include "core/platform/image-decoders/ImageDecoder.h"
33 33
34 #include "webp/decode.h" 34 #include "webp/decode.h"
35 #if USE(QCMSLIB) && (WEBP_DECODER_ABI_VERSION > 0x200) 35 #if (WEBP_DECODER_ABI_VERSION > 0x200)
36 #include "webp/demux.h"
37 #define WEBP_ICC_ANIMATION_SUPPORT
38 #if USE(QCMSLIB)
36 #define QCMS_WEBP_COLOR_CORRECTION 39 #define QCMS_WEBP_COLOR_CORRECTION
37 #endif 40 #endif
41 #endif
38 42
39 namespace WebCore { 43 namespace WebCore {
40 44
41 class WEBPImageDecoder : public ImageDecoder { 45 class WEBPImageDecoder : public ImageDecoder {
42 public: 46 public:
43 WEBPImageDecoder(ImageSource::AlphaOption, ImageSource::GammaAndColorProfile Option); 47 WEBPImageDecoder(ImageSource::AlphaOption, ImageSource::GammaAndColorProfile Option);
44 virtual ~WEBPImageDecoder(); 48 virtual ~WEBPImageDecoder();
45 49
46 virtual String filenameExtension() const { return "webp"; } 50 virtual String filenameExtension() OVERRIDE const { return "webp"; }
47 virtual bool isSizeAvailable(); 51 virtual bool isSizeAvailable() OVERRIDE;
48 virtual ImageFrame* frameBufferAtIndex(size_t); 52 virtual size_t frameCount() OVERRIDE;
53 virtual ImageFrame* frameBufferAtIndex(size_t index) OVERRIDE;
Noel Gordon 2013/06/13 15:50:17 nit: s/index//
urvang (Google) 2013/06/14 01:13:13 Done.
54 #ifdef WEBP_ICC_ANIMATION_SUPPORT
55 virtual void setData(SharedBuffer* data, bool allDataReceived) OVERRIDE;
56 virtual int repetitionCount() const OVERRIDE;
57 virtual bool frameIsCompleteAtIndex(size_t) const OVERRIDE;
58 virtual float frameDurationAtIndex(size_t) const OVERRIDE;
59 virtual size_t clearCacheExceptFrame(size_t) OVERRIDE;
60 #endif
49 61
50 private: 62 private:
51 bool decode(bool onlySize); 63 bool decode(const uint8_t* dataBytes, size_t dataSize, bool onlySize, size_t frameIndex);
52 64
53 WebPIDecoder* m_decoder; 65 WebPIDecoder* m_decoder;
54 WebPDecBuffer m_decoderBuffer; 66 WebPDecBuffer m_decoderBuffer;
55 bool m_hasAlpha;
56 int m_formatFlags; 67 int m_formatFlags;
57 68
58 #ifdef QCMS_WEBP_COLOR_CORRECTION 69 #ifdef QCMS_WEBP_COLOR_CORRECTION
59 qcms_transform* colorTransform() const { return m_transform; } 70 qcms_transform* colorTransform() const { return m_transform; }
60 void createColorTransform(const char* data, size_t); 71 void createColorTransform(const char* data, size_t);
61 void readColorProfile(const uint8_t* data, size_t); 72 void readColorProfile();
62 void applyColorProfile(const uint8_t* data, size_t, ImageFrame&);
63 73
64 bool m_haveReadProfile; 74 bool m_haveReadProfile;
65 qcms_transform* m_transform; 75 qcms_transform* m_transform;
66 int m_decodedHeight; 76 #endif
77
78 #ifdef WEBP_ICC_ANIMATION_SUPPORT
79 bool updateDemuxer();
80 // Called to initialize the frame buffer at the given index based on
81 // the previous frame's disposal method. Returns true on success. On
82 // failure, marks the image as failed.
83 bool initFrameBuffer(const WebPIterator&, size_t frameIndex);
84 void applyPostProcessing(size_t frameIndex);
85 virtual void clearFrameBuffer(size_t frameIndex) OVERRIDE;
86
87 WebPDemuxer* m_demux;
88 WebPDemuxState m_demuxState;
89 bool m_haveAlreadyParsedThisData;
90 bool m_haveReadAnimationParameters;
91 int m_repetitionCount;
92 int m_decodedHeight; // Number of rows decoded and post-processed so far in the current frame.
67 #else 93 #else
68 void applyColorProfile(const uint8_t*, size_t, ImageFrame&) { }; 94 void applyPostProcessing(size_t) { };
69 #endif 95 #endif
96
70 void clear(); 97 void clear();
98 void clearDecoder();
71 }; 99 };
72 100
73 } // namespace WebCore 101 } // namespace WebCore
74 102
75 #endif 103 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698