Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2008, 2009, Google Inc. All rights reserved. | 2 * Copyright (c) 2008, 2009, 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 #include "platform/image-decoders/FastSharedBufferReader.h" | 34 #include "platform/image-decoders/FastSharedBufferReader.h" |
| 35 #include "platform/image-decoders/bmp/BMPImageReader.h" | 35 #include "platform/image-decoders/bmp/BMPImageReader.h" |
| 36 #include <memory> | 36 #include <memory> |
| 37 | 37 |
| 38 namespace blink { | 38 namespace blink { |
| 39 | 39 |
| 40 class PNGImageDecoder; | 40 class PNGImageDecoder; |
| 41 | 41 |
| 42 // This class decodes the ICO and CUR image formats. | 42 // This class decodes the ICO and CUR image formats. |
| 43 class PLATFORM_EXPORT ICOImageDecoder final : public ImageDecoder { | 43 class PLATFORM_EXPORT ICOImageDecoder final : public ImageDecoder { |
| 44 WTF_MAKE_NONCOPYABLE(ICOImageDecoder); | |
|
scroggo_chromium
2016/06/24 21:36:24
Weird that this wasn't here before...
| |
| 44 public: | 45 public: |
| 45 ICOImageDecoder(AlphaOption, GammaAndColorProfileOption, size_t maxDecodedBy tes); | 46 ICOImageDecoder(AlphaOption, GammaAndColorProfileOption, size_t maxDecodedBy tes); |
| 46 ~ICOImageDecoder() override; | 47 ~ICOImageDecoder() override; |
| 47 | 48 |
| 48 // ImageDecoder: | 49 // ImageDecoder: |
| 49 String filenameExtension() const override { return "ico"; } | 50 String filenameExtension() const override { return "ico"; } |
| 50 void onSetData(SegmentReader*) override; | 51 void onSetData(SegmentReader*) override; |
| 51 IntSize size() const override; | 52 IntSize size() const override; |
| 52 IntSize frameSizeAtIndex(size_t) const override; | 53 IntSize frameSizeAtIndex(size_t) const override; |
| 53 bool setSize(unsigned width, unsigned height) override; | 54 bool setSize(unsigned width, unsigned height) override; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 77 IntPoint m_hotSpot; | 78 IntPoint m_hotSpot; |
| 78 uint32_t m_imageOffset; | 79 uint32_t m_imageOffset; |
| 79 uint32_t m_byteSize; | 80 uint32_t m_byteSize; |
| 80 }; | 81 }; |
| 81 | 82 |
| 82 // Returns true if |a| is a preferable icon entry to |b|. | 83 // Returns true if |a| is a preferable icon entry to |b|. |
| 83 // Larger sizes, or greater bitdepths at the same size, are preferable. | 84 // Larger sizes, or greater bitdepths at the same size, are preferable. |
| 84 static bool compareEntries(const IconDirectoryEntry& a, const IconDirectoryE ntry& b); | 85 static bool compareEntries(const IconDirectoryEntry& a, const IconDirectoryE ntry& b); |
| 85 | 86 |
| 86 // ImageDecoder: | 87 // ImageDecoder: |
| 87 virtual void decodeSize() { decode(0, true); } | 88 void decodeSize() override { decode(0, true); } |
| 88 size_t decodeFrameCount() override; | 89 size_t decodeFrameCount() override; |
| 89 void decode(size_t index) override { decode(index, false); } | 90 void decode(size_t index) override { decode(index, false); } |
| 90 | 91 |
| 91 // TODO (scroggo): These functions are identical to functions in BMPImageRea der. Share code? | 92 // TODO (scroggo): These functions are identical to functions in BMPImageRea der. Share code? |
| 92 inline uint8_t readUint8(size_t offset) const | 93 inline uint8_t readUint8(size_t offset) const |
| 93 { | 94 { |
| 94 return m_fastReader.getOneByte(m_decodedOffset + offset); | 95 return m_fastReader.getOneByte(m_decodedOffset + offset); |
| 95 } | 96 } |
| 96 | 97 |
| 97 inline uint16_t readUint16(int offset) const | 98 inline uint16_t readUint16(int offset) const |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 // BMPImageReader takes over this will not be updated further. | 153 // BMPImageReader takes over this will not be updated further. |
| 153 size_t m_decodedOffset; | 154 size_t m_decodedOffset; |
| 154 | 155 |
| 155 // Which type of file (ICO/CUR) this is. | 156 // Which type of file (ICO/CUR) this is. |
| 156 FileType m_fileType; | 157 FileType m_fileType; |
| 157 | 158 |
| 158 // The headers for the ICO. | 159 // The headers for the ICO. |
| 159 typedef Vector<IconDirectoryEntry> IconDirectoryEntries; | 160 typedef Vector<IconDirectoryEntry> IconDirectoryEntries; |
| 160 IconDirectoryEntries m_dirEntries; | 161 IconDirectoryEntries m_dirEntries; |
| 161 | 162 |
| 163 // Count of directory entries is parsed from header before initializing | |
| 164 // m_dirEntries. m_dirEntries is populated only when full header | |
| 165 // information including directory entries is available. | |
| 166 size_t m_dirEntriesCount; | |
| 167 | |
| 162 // The image decoders for the various frames. | 168 // The image decoders for the various frames. |
| 163 typedef Vector<std::unique_ptr<BMPImageReader>> BMPReaders; | 169 typedef Vector<std::unique_ptr<BMPImageReader>> BMPReaders; |
| 164 BMPReaders m_bmpReaders; | 170 BMPReaders m_bmpReaders; |
| 165 typedef Vector<std::unique_ptr<PNGImageDecoder>> PNGDecoders; | 171 typedef Vector<std::unique_ptr<PNGImageDecoder>> PNGDecoders; |
| 166 PNGDecoders m_pngDecoders; | 172 PNGDecoders m_pngDecoders; |
| 167 | 173 |
| 168 // Valid only while a BMPImageReader is decoding, this holds the size | 174 // Valid only while a BMPImageReader is decoding, this holds the size |
| 169 // for the particular entry being decoded. | 175 // for the particular entry being decoded. |
| 170 IntSize m_frameSize; | 176 IntSize m_frameSize; |
| 171 }; | 177 }; |
| 172 | 178 |
| 173 } // namespace blink | 179 } // namespace blink |
| 174 | 180 |
| 175 #endif | 181 #endif |
| OLD | NEW |