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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 ~ImageFrameGenerator(); | 65 ~ImageFrameGenerator(); |
66 | 66 |
67 // Decodes and scales the specified frame indicated by |index|. Dimensions | 67 // Decodes and scales the specified frame indicated by |index|. Dimensions |
68 // and output format are specified in |info|. Decoded pixels are written | 68 // and output format are specified in |info|. Decoded pixels are written |
69 // into |pixels| with a stride of |rowBytes|. | 69 // into |pixels| with a stride of |rowBytes|. |
70 // | 70 // |
71 // Returns true if decoding was successful. | 71 // Returns true if decoding was successful. |
72 bool decodeAndScale(const SkImageInfo&, size_t index, void* pixels, size_t r
owBytes); | 72 bool decodeAndScale(const SkImageInfo&, size_t index, void* pixels, size_t r
owBytes); |
73 | 73 |
74 // Decodes YUV components directly into the provided memory planes. | 74 // Decodes YUV components directly into the provided memory planes. |
75 bool decodeToYUV(void* planes[3], size_t rowBytes[3]); | 75 bool decodeToYUV(SkISize componentSizes[3], void* planes[3], size_t rowBytes
[3]); |
76 | 76 |
77 void setData(PassRefPtr<SharedBuffer>, bool allDataReceived); | 77 void setData(PassRefPtr<SharedBuffer>, bool allDataReceived); |
78 | 78 |
79 // Creates a new SharedBuffer containing the data received so far. | 79 // Creates a new SharedBuffer containing the data received so far. |
80 void copyData(RefPtr<SharedBuffer>*, bool* allDataReceived); | 80 void copyData(RefPtr<SharedBuffer>*, bool* allDataReceived); |
81 | 81 |
82 SkISize getFullSize() const { return m_fullSize; } | 82 SkISize getFullSize() const { return m_fullSize; } |
83 | 83 |
84 bool isMultiFrame() const { return m_isMultiFrame; } | 84 bool isMultiFrame() const { return m_isMultiFrame; } |
85 | 85 |
86 // FIXME: Return alpha state for each frame. | 86 // FIXME: Return alpha state for each frame. |
87 bool hasAlpha(size_t); | 87 bool hasAlpha(size_t); |
88 | 88 |
89 bool getYUVComponentSizes(SkISize componentSizes[3]); | 89 bool getYUVComponentSizes(SkISize componentSizes[3]); |
90 | 90 |
91 private: | 91 private: |
92 class ExternalMemoryAllocator; | 92 class ExternalMemoryAllocator; |
93 friend class ImageFrameGeneratorTest; | 93 friend class ImageFrameGeneratorTest; |
94 friend class DeferredImageDecoderTest; | 94 friend class DeferredImageDecoderTest; |
95 // For testing. |factory| will overwrite the default ImageDecoder creation l
ogic if |factory->create()| returns non-zero. | 95 // For testing. |factory| will overwrite the default ImageDecoder creation l
ogic if |factory->create()| returns non-zero. |
96 void setImageDecoderFactory(PassOwnPtr<ImageDecoderFactory> factory) { m_ima
geDecoderFactory = factory; } | 96 void setImageDecoderFactory(PassOwnPtr<ImageDecoderFactory> factory) { m_ima
geDecoderFactory = factory; } |
97 | 97 |
98 void setHasAlpha(size_t index, bool hasAlpha); | 98 void setHasAlpha(size_t index, bool hasAlpha); |
99 | 99 |
| 100 void getYUVComponentSizes(const ImageDecoder*, SkISize componentSizes[3], bo
ol memoryAllocation); |
| 101 |
100 // These methods are called while m_decodeMutex is locked. | 102 // These methods are called while m_decodeMutex is locked. |
101 SkBitmap tryToResumeDecode(const SkISize& scaledSize, size_t index); | 103 SkBitmap tryToResumeDecode(const SkISize& scaledSize, size_t index); |
102 | 104 |
103 // Use the given decoder to decode. If a decoder is not given then try to cr
eate one. | 105 // Use the given decoder to decode. If a decoder is not given then try to cr
eate one. |
104 // Returns true if decoding was complete. | 106 // Returns true if decoding was complete. |
105 bool decode(size_t index, ImageDecoder**, SkBitmap*); | 107 bool decode(size_t index, ImageDecoder**, SkBitmap*); |
106 | 108 |
107 SkISize m_fullSize; | 109 SkISize m_fullSize; |
108 ThreadSafeDataTransport m_data; | 110 ThreadSafeDataTransport m_data; |
109 bool m_isMultiFrame; | 111 bool m_isMultiFrame; |
110 bool m_decodeFailedAndEmpty; | 112 bool m_decodeFailedAndEmpty; |
111 Vector<bool> m_hasAlpha; | 113 Vector<bool> m_hasAlpha; |
112 int m_decodeCount; | 114 int m_decodeCount; |
113 OwnPtr<ExternalMemoryAllocator> m_externalAllocator; | 115 OwnPtr<ExternalMemoryAllocator> m_externalAllocator; |
114 | 116 |
115 OwnPtr<ImageDecoderFactory> m_imageDecoderFactory; | 117 OwnPtr<ImageDecoderFactory> m_imageDecoderFactory; |
116 | 118 |
117 // Prevents multiple decode operations on the same data. | 119 // Prevents multiple decode operations on the same data. |
118 Mutex m_decodeMutex; | 120 Mutex m_decodeMutex; |
119 | 121 |
120 // Protect concurrent access to m_hasAlpha. | 122 // Protect concurrent access to m_hasAlpha. |
121 Mutex m_alphaMutex; | 123 Mutex m_alphaMutex; |
122 }; | 124 }; |
123 | 125 |
124 } // namespace blink | 126 } // namespace blink |
125 | 127 |
126 #endif | 128 #endif |
OLD | NEW |