| OLD | NEW |
| 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 18 matching lines...) Expand all Loading... |
| 29 #ifndef WEBPImageDecoder_h | 29 #ifndef WEBPImageDecoder_h |
| 30 #define WEBPImageDecoder_h | 30 #define WEBPImageDecoder_h |
| 31 | 31 |
| 32 #include "ImageDecoder.h" | 32 #include "ImageDecoder.h" |
| 33 | 33 |
| 34 #if USE(WEBP) | 34 #if USE(WEBP) |
| 35 | 35 |
| 36 #include "webp/decode.h" | 36 #include "webp/decode.h" |
| 37 #if USE(QCMSLIB) && (WEBP_DECODER_ABI_VERSION > 0x200) | 37 #if USE(QCMSLIB) && (WEBP_DECODER_ABI_VERSION > 0x200) |
| 38 #define QCMS_WEBP_COLOR_CORRECTION | 38 #define QCMS_WEBP_COLOR_CORRECTION |
| 39 #include "webp/demux.h" |
| 39 #endif | 40 #endif |
| 40 | 41 |
| 41 namespace WebCore { | 42 namespace WebCore { |
| 42 | 43 |
| 43 class WEBPImageDecoder : public ImageDecoder { | 44 class WEBPImageDecoder : public ImageDecoder { |
| 44 public: | 45 public: |
| 45 WEBPImageDecoder(ImageSource::AlphaOption, ImageSource::GammaAndColorProfile
Option); | 46 WEBPImageDecoder(ImageSource::AlphaOption, ImageSource::GammaAndColorProfile
Option); |
| 46 virtual ~WEBPImageDecoder(); | 47 virtual ~WEBPImageDecoder(); |
| 47 | 48 |
| 48 virtual String filenameExtension() const { return "webp"; } | 49 virtual String filenameExtension() const { return "webp"; } |
| 49 virtual bool isSizeAvailable(); | 50 virtual bool isSizeAvailable(); |
| 51 virtual size_t frameCount(); |
| 50 virtual ImageFrame* frameBufferAtIndex(size_t index); | 52 virtual ImageFrame* frameBufferAtIndex(size_t index); |
| 53 #ifdef QCMS_WEBP_COLOR_CORRECTION |
| 54 virtual void setData(SharedBuffer* data, bool allDataReceived); |
| 55 virtual int repetitionCount() const { return m_repetitionCount; } |
| 56 virtual void clearFrameBufferCache(size_t clearBeforeFrame); |
| 57 #endif |
| 51 | 58 |
| 52 private: | 59 private: |
| 53 bool decode(bool onlySize); | 60 bool decode(const uint8_t* dataBytes, size_t dataSize, bool onlySize, size_t
frameIndex); |
| 54 | 61 |
| 55 WebPIDecoder* m_decoder; | 62 WebPIDecoder* m_decoder; |
| 56 bool m_hasAlpha; | |
| 57 int m_formatFlags; | 63 int m_formatFlags; |
| 58 | 64 |
| 59 #ifdef QCMS_WEBP_COLOR_CORRECTION | 65 #ifdef QCMS_WEBP_COLOR_CORRECTION |
| 60 qcms_transform* colorTransform() const { return m_transform; } | 66 qcms_transform* colorTransform() const { return m_transform; } |
| 61 void createColorTransform(const char* data, size_t); | 67 void createColorTransform(const char* data, size_t); |
| 62 void readColorProfile(const uint8_t* data, size_t); | 68 void readColorProfile(); |
| 63 void applyColorProfile(const uint8_t* data, size_t, ImageFrame&); | 69 // Recreates demux object when new data is available, and sets canvas size,
format flags, |
| 70 // animation properties etc as appropriate. Returns true on success. On |
| 71 // failure, this will mark the image as failed. |
| 72 bool updateDemuxer(); |
| 73 // Called to initialize the frame buffer at the given index based on |
| 74 // the previous frame's disposal method. Returns true on success. On |
| 75 // failure, this will mark the image as failed. |
| 76 bool initFrameBuffer(const WebPIterator& fIter, size_t frameIndex); |
| 77 // Apply color profile, and perform necessary post-processing for frame disp
osal. |
| 78 void applyPostProcessing(size_t frameIndex); |
| 79 |
| 80 // Number of rows decoded and post-processed so far in the current frame. It |
| 81 // is used by applyPostProcessing() to decode and post-process incrementally
. |
| 82 int m_decodedHeight; |
| 83 |
| 84 bool m_haveAlreadyParsedThisData; |
| 85 WebPDemuxer* m_demux; |
| 86 WebPDemuxState m_demuxState; |
| 64 | 87 |
| 65 bool m_haveReadProfile; | 88 bool m_haveReadProfile; |
| 66 qcms_transform* m_transform; | 89 qcms_transform* m_transform; |
| 67 int m_decodedHeight; | 90 |
| 91 bool m_haveReadAnimParams; |
| 92 int m_repetitionCount; |
| 68 #else | 93 #else |
| 69 void applyColorProfile(const uint8_t*, size_t, ImageFrame&) { }; | 94 void applyPostProcessing(size_t frameIndex) { }; |
| 70 #endif | 95 #endif |
| 71 void clear(); | 96 void clearAll(); |
| 97 void clearDecoder(); |
| 72 }; | 98 }; |
| 73 | 99 |
| 74 } // namespace WebCore | 100 } // namespace WebCore |
| 75 | 101 |
| 76 #endif | 102 #endif |
| 77 | 103 |
| 78 #endif | 104 #endif |
| OLD | NEW |