| 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 21 matching lines...) Expand all Loading... |
| 32 #define ICOImageDecoder_h | 32 #define ICOImageDecoder_h |
| 33 | 33 |
| 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 | 36 |
| 37 namespace blink { | 37 namespace blink { |
| 38 | 38 |
| 39 class PNGImageDecoder; | 39 class PNGImageDecoder; |
| 40 | 40 |
| 41 // This class decodes the ICO and CUR image formats. | 41 // This class decodes the ICO and CUR image formats. |
| 42 class PLATFORM_EXPORT ICOImageDecoder : public ImageDecoder { | 42 class PLATFORM_EXPORT ICOImageDecoder final : public ImageDecoder { |
| 43 public: | 43 public: |
| 44 ICOImageDecoder(AlphaOption, GammaAndColorProfileOption, size_t maxDecodedBy
tes); | 44 ICOImageDecoder(AlphaOption, GammaAndColorProfileOption, size_t maxDecodedBy
tes); |
| 45 ~ICOImageDecoder() override; | 45 ~ICOImageDecoder() override; |
| 46 | 46 |
| 47 // ImageDecoder: | 47 // ImageDecoder: |
| 48 String filenameExtension() const override { return "ico"; } | 48 String filenameExtension() const override { return "ico"; } |
| 49 void onSetData(SharedBuffer*) override; | 49 void onSetData(SharedBuffer*) override; |
| 50 IntSize size() const override; | 50 IntSize size() const override; |
| 51 IntSize frameSizeAtIndex(size_t) const override; | 51 IntSize frameSizeAtIndex(size_t) const override; |
| 52 bool setSize(unsigned width, unsigned height) override; | 52 bool setSize(unsigned width, unsigned height) override; |
| 53 // CAUTION: setFailed() deletes all readers and decoders. Be careful to | 53 // CAUTION: setFailed() deletes all readers and decoders. Be careful to |
| 54 // avoid accessing deleted memory, especially when calling this from | 54 // avoid accessing deleted memory, especially when calling this from |
| 55 // inside BMPImageReader! | 55 // inside BMPImageReader! |
| 56 bool setFailed() override; | 56 bool setFailed() override; |
| 57 bool hotSpot(IntPoint&) const override; | 57 bool hotSpot(IntPoint&) const override; |
| 58 | 58 |
| 59 private: | 59 private: |
| 60 enum ImageType { | 60 enum ImageType { |
| 61 Unknown, | 61 Unknown, |
| 62 BMP, | 62 BMP, |
| 63 PNG, | 63 PNG, |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 enum FileType { | 66 enum FileType { |
| 67 ICON = 1, | 67 ICON = 1, |
| 68 CURSOR = 2, | 68 CURSOR = 2, |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 struct IconDirectoryEntry { | 71 struct IconDirectoryEntry { |
| 72 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 72 IntSize m_size; | 73 IntSize m_size; |
| 73 uint16_t m_bitCount; | 74 uint16_t m_bitCount; |
| 74 IntPoint m_hotSpot; | 75 IntPoint m_hotSpot; |
| 75 uint32_t m_imageOffset; | 76 uint32_t m_imageOffset; |
| 76 }; | 77 }; |
| 77 | 78 |
| 78 // Returns true if |a| is a preferable icon entry to |b|. | 79 // Returns true if |a| is a preferable icon entry to |b|. |
| 79 // Larger sizes, or greater bitdepths at the same size, are preferable. | 80 // Larger sizes, or greater bitdepths at the same size, are preferable. |
| 80 static bool compareEntries(const IconDirectoryEntry& a, const IconDirectoryE
ntry& b); | 81 static bool compareEntries(const IconDirectoryEntry& a, const IconDirectoryE
ntry& b); |
| 81 | 82 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 PNGDecoders m_pngDecoders; | 163 PNGDecoders m_pngDecoders; |
| 163 | 164 |
| 164 // Valid only while a BMPImageReader is decoding, this holds the size | 165 // Valid only while a BMPImageReader is decoding, this holds the size |
| 165 // for the particular entry being decoded. | 166 // for the particular entry being decoded. |
| 166 IntSize m_frameSize; | 167 IntSize m_frameSize; |
| 167 }; | 168 }; |
| 168 | 169 |
| 169 } // namespace blink | 170 } // namespace blink |
| 170 | 171 |
| 171 #endif | 172 #endif |
| OLD | NEW |