| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 } | 64 } |
| 65 | 65 |
| 66 ImageFrameGenerator(const SkISize& fullSize, PassRefPtr<SharedBuffer>, bool
allDataReceived, bool isMultiFrame); | 66 ImageFrameGenerator(const SkISize& fullSize, PassRefPtr<SharedBuffer>, bool
allDataReceived, bool isMultiFrame); |
| 67 ~ImageFrameGenerator(); | 67 ~ImageFrameGenerator(); |
| 68 | 68 |
| 69 // Decodes and scales the specified frame indicated by |index|. Dimensions | 69 // Decodes and scales the specified frame indicated by |index|. Dimensions |
| 70 // and output format are specified in |info|. Decoded pixels are written | 70 // and output format are specified in |info|. Decoded pixels are written |
| 71 // into |pixels| with a stride of |rowBytes|. | 71 // into |pixels| with a stride of |rowBytes|. |
| 72 // | 72 // |
| 73 // Returns true if decoding was successful. | 73 // Returns true if decoding was successful. |
| 74 bool decodeAndScale(const SkImageInfo&, size_t index, void* pixels, size_t r
owBytes); | 74 bool decodeAndScale(const SkImageInfo&, size_t index, void* pixels, size_t r
owBytes, SkPMColor ctable[] = nullptr, int* ctableCount = nullptr); |
| 75 | 75 |
| 76 // Decodes YUV components directly into the provided memory planes. | 76 // Decodes YUV components directly into the provided memory planes. |
| 77 bool decodeToYUV(SkISize componentSizes[3], void* planes[3], size_t rowBytes
[3]); | 77 bool decodeToYUV(SkISize componentSizes[3], void* planes[3], size_t rowBytes
[3]); |
| 78 | 78 |
| 79 void setData(PassRefPtr<SharedBuffer>, bool allDataReceived); | 79 void setData(PassRefPtr<SharedBuffer>, bool allDataReceived); |
| 80 | 80 |
| 81 // Creates a new SharedBuffer containing the data received so far. | 81 // Creates a new SharedBuffer containing the data received so far. |
| 82 void copyData(RefPtr<SharedBuffer>*, bool* allDataReceived); | 82 void copyData(RefPtr<SharedBuffer>*, bool* allDataReceived); |
| 83 | 83 |
| 84 SkISize getFullSize() const { return m_fullSize; } | 84 SkISize getFullSize() const { return m_fullSize; } |
| 85 | 85 |
| 86 bool isMultiFrame() const { return m_isMultiFrame; } | 86 bool isMultiFrame() const { return m_isMultiFrame; } |
| 87 | 87 |
| 88 // FIXME: Return alpha state for each frame. | 88 // FIXME: Return alpha state for each frame. |
| 89 bool hasAlpha(size_t); | 89 bool hasAlpha(size_t); |
| 90 | 90 |
| 91 bool getYUVComponentSizes(SkISize componentSizes[3]); | 91 bool getYUVComponentSizes(SkISize componentSizes[3]); |
| 92 | 92 |
| 93 // Specifies that there is decoder support, to optimize when to call canDeco
deTo(). |
| 94 void setDecoderCanDecodeToIndex8(bool canIt) { m_decoderCanDecodeToIndex8 =
canIt; } |
| 95 bool canDecodeTo(size_t index, SkColorType outputType); |
| 96 |
| 93 private: | 97 private: |
| 94 class ExternalMemoryAllocator; | 98 class ExternalMemoryAllocator; |
| 95 friend class ImageFrameGeneratorTest; | 99 friend class ImageFrameGeneratorTest; |
| 96 friend class DeferredImageDecoderTest; | 100 friend class DeferredImageDecoderTest; |
| 97 // For testing. |factory| will overwrite the default ImageDecoder creation l
ogic if |factory->create()| returns non-zero. | 101 // For testing. |factory| will overwrite the default ImageDecoder creation l
ogic if |factory->create()| returns non-zero. |
| 98 void setImageDecoderFactory(PassOwnPtr<ImageDecoderFactory> factory) { m_ima
geDecoderFactory = factory; } | 102 void setImageDecoderFactory(PassOwnPtr<ImageDecoderFactory> factory) { m_ima
geDecoderFactory = factory; } |
| 99 | 103 |
| 100 void setHasAlpha(size_t index, bool hasAlpha); | 104 void setHasAlpha(size_t index, bool hasAlpha); |
| 101 | 105 |
| 102 // These methods are called while m_decodeMutex is locked. | 106 // These methods are called while m_decodeMutex is locked. |
| 103 SkBitmap tryToResumeDecode(const SkISize& scaledSize, size_t index); | 107 SkBitmap tryToResumeDecode(const SkISize& scaledSize, size_t index, SkColorT
ype outputColor); |
| 104 | 108 |
| 105 // Use the given decoder to decode. If a decoder is not given then try to cr
eate one. | 109 // Use the given decoder to decode. If a decoder is not given then try to cr
eate one. |
| 106 // Returns true if decoding was complete. | 110 // Returns true if decoding was complete. |
| 107 bool decode(size_t index, ImageDecoder**, SkBitmap*); | 111 bool decode(size_t index, ImageDecoder**, SkBitmap*, SkColorType); |
| 108 | 112 |
| 109 SkISize m_fullSize; | 113 SkISize m_fullSize; |
| 110 ThreadSafeDataTransport m_data; | 114 ThreadSafeDataTransport m_data; |
| 111 bool m_isMultiFrame; | 115 bool m_isMultiFrame; |
| 112 bool m_decodeFailedAndEmpty; | 116 bool m_decodeFailedAndEmpty; |
| 113 Vector<bool> m_hasAlpha; | 117 Vector<bool> m_hasAlpha; |
| 114 int m_decodeCount; | 118 int m_decodeCount; |
| 115 Vector<bool> m_frameComplete; | 119 Vector<bool> m_frameComplete; |
| 116 size_t m_frameCount; | 120 size_t m_frameCount; |
| 117 OwnPtr<ExternalMemoryAllocator> m_externalAllocator; | 121 OwnPtr<ExternalMemoryAllocator> m_externalAllocator; |
| 118 | 122 |
| 119 OwnPtr<ImageDecoderFactory> m_imageDecoderFactory; | 123 OwnPtr<ImageDecoderFactory> m_imageDecoderFactory; |
| 120 | 124 |
| 121 // Prevents multiple decode operations on the same data. | 125 // Prevents multiple decode operations on the same data. |
| 122 Mutex m_decodeMutex; | 126 Mutex m_decodeMutex; |
| 123 | 127 |
| 124 // Protect concurrent access to m_hasAlpha. | 128 // Protect concurrent access to m_hasAlpha. |
| 125 Mutex m_alphaMutex; | 129 Mutex m_alphaMutex; |
| 126 | 130 |
| 127 #if COMPILER(MSVC) | 131 #if COMPILER(MSVC) |
| 128 friend struct ::WTF::OwnedPtrDeleter<ExternalMemoryAllocator>; | 132 friend struct ::WTF::OwnedPtrDeleter<ExternalMemoryAllocator>; |
| 129 #endif | 133 #endif |
| 134 bool m_decoderCanDecodeToIndex8; |
| 130 }; | 135 }; |
| 131 | 136 |
| 132 } // namespace blink | 137 } // namespace blink |
| 133 | 138 |
| 134 #endif | 139 #endif |
| OLD | NEW |