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 21 matching lines...) Expand all Loading... | |
32 #include "platform/PlatformExport.h" | 32 #include "platform/PlatformExport.h" |
33 #include "platform/graphics/ThreadSafeDataTransport.h" | 33 #include "platform/graphics/ThreadSafeDataTransport.h" |
34 #include "wtf/PassOwnPtr.h" | 34 #include "wtf/PassOwnPtr.h" |
35 #include "wtf/PassRefPtr.h" | 35 #include "wtf/PassRefPtr.h" |
36 #include "wtf/RefCounted.h" | 36 #include "wtf/RefCounted.h" |
37 #include "wtf/RefPtr.h" | 37 #include "wtf/RefPtr.h" |
38 #include "wtf/ThreadingPrimitives.h" | 38 #include "wtf/ThreadingPrimitives.h" |
39 #include "wtf/ThreadSafeRefCounted.h" | 39 #include "wtf/ThreadSafeRefCounted.h" |
40 #include "wtf/Vector.h" | 40 #include "wtf/Vector.h" |
41 | 41 |
42 class SkData; | |
43 | |
42 namespace blink { | 44 namespace blink { |
43 | 45 |
44 class ImageDecoder; | 46 class ImageDecoder; |
45 class SharedBuffer; | 47 class SharedBuffer; |
46 | 48 |
47 class PLATFORM_EXPORT ImageDecoderFactory { | 49 class PLATFORM_EXPORT ImageDecoderFactory { |
48 WTF_MAKE_NONCOPYABLE(ImageDecoderFactory); | 50 WTF_MAKE_NONCOPYABLE(ImageDecoderFactory); |
49 public: | 51 public: |
50 ImageDecoderFactory() {} | 52 ImageDecoderFactory() {} |
51 virtual ~ImageDecoderFactory() { } | 53 virtual ~ImageDecoderFactory() { } |
(...skipping 16 matching lines...) Expand all Loading... | |
68 // into |pixels| with a stride of |rowBytes|. | 70 // into |pixels| with a stride of |rowBytes|. |
69 // | 71 // |
70 // Returns true if decoding was successful. | 72 // Returns true if decoding was successful. |
71 bool decodeAndScale(const SkImageInfo&, size_t index, void* pixels, size_t r owBytes); | 73 bool decodeAndScale(const SkImageInfo&, size_t index, void* pixels, size_t r owBytes); |
72 | 74 |
73 // Decodes YUV components directly into the provided memory planes. | 75 // Decodes YUV components directly into the provided memory planes. |
74 bool decodeToYUV(SkISize componentSizes[3], void* planes[3], size_t rowBytes [3]); | 76 bool decodeToYUV(SkISize componentSizes[3], void* planes[3], size_t rowBytes [3]); |
75 | 77 |
76 void setData(PassRefPtr<SharedBuffer>, bool allDataReceived); | 78 void setData(PassRefPtr<SharedBuffer>, bool allDataReceived); |
77 | 79 |
78 // Creates a new SharedBuffer containing the data received so far. | 80 // Returns pointer to SkData. Caller needs to unref it, according to contrac t in |
79 void copyData(RefPtr<SharedBuffer>*, bool* allDataReceived); | 81 // SkImageGenerator::refEncodedData. |
82 SkData* refEncodedData(); | |
scroggo
2015/12/03 14:59:59
Can this be const?
aleksandar.stojiljkovic
2015/12/03 21:17:09
Done.
| |
80 | 83 |
81 SkISize getFullSize() const { return m_fullSize; } | 84 SkISize getFullSize() const { return m_fullSize; } |
82 | 85 |
83 bool isMultiFrame() const { return m_isMultiFrame; } | 86 bool isMultiFrame() const { return m_isMultiFrame; } |
84 | 87 |
85 // FIXME: Return alpha state for each frame. | 88 // FIXME: Return alpha state for each frame. |
86 bool hasAlpha(size_t); | 89 bool hasAlpha(size_t); |
87 | 90 |
88 bool getYUVComponentSizes(SkISize componentSizes[3]); | 91 bool getYUVComponentSizes(SkISize componentSizes[3]); |
89 | 92 |
90 private: | 93 private: |
91 class ExternalMemoryAllocator; | 94 class ExternalMemoryAllocator; |
92 friend class ImageFrameGeneratorTest; | 95 friend class ImageFrameGeneratorTest; |
93 friend class DeferredImageDecoderTest; | 96 friend class DeferredImageDecoderTest; |
94 // For testing. |factory| will overwrite the default ImageDecoder creation l ogic if |factory->create()| returns non-zero. | 97 // For testing. |factory| will overwrite the default ImageDecoder creation l ogic if |factory->create()| returns non-zero. |
95 void setImageDecoderFactory(PassOwnPtr<ImageDecoderFactory> factory) { m_ima geDecoderFactory = factory; } | 98 void setImageDecoderFactory(PassOwnPtr<ImageDecoderFactory> factory) { m_ima geDecoderFactory = factory; } |
96 | 99 |
97 void setHasAlpha(size_t index, bool hasAlpha); | 100 void setHasAlpha(size_t index, bool hasAlpha); |
98 | 101 |
99 // These methods are called while m_decodeMutex is locked. | 102 // These methods are called while m_decodeMutex is locked. |
100 SkBitmap tryToResumeDecode(const SkISize& scaledSize, size_t index); | 103 SkBitmap tryToResumeDecode(const SkISize& scaledSize, size_t index); |
101 | 104 |
102 // 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. |
103 // Returns true if decoding was complete. | 106 // Returns true if decoding was complete. |
104 bool decode(size_t index, ImageDecoder**, SkBitmap*); | 107 bool decode(size_t index, ImageDecoder**, SkBitmap*); |
105 | 108 |
106 SkISize m_fullSize; | 109 SkISize m_fullSize; |
107 ThreadSafeDataTransport m_data; | 110 RefPtr<ThreadSafeDataTransport> m_data; |
chrishtr
2015/12/03 17:51:51
What does making this a RefPtr achieve?
aleksandar.stojiljkovic
2015/12/03 21:17:09
Done.
| |
108 bool m_isMultiFrame; | 111 bool m_isMultiFrame; |
109 bool m_decodeFailedAndEmpty; | 112 bool m_decodeFailedAndEmpty; |
110 Vector<bool> m_hasAlpha; | 113 Vector<bool> m_hasAlpha; |
111 int m_decodeCount; | 114 int m_decodeCount; |
112 Vector<bool> m_frameComplete; | 115 Vector<bool> m_frameComplete; |
113 size_t m_frameCount; | 116 size_t m_frameCount; |
114 OwnPtr<ExternalMemoryAllocator> m_externalAllocator; | 117 OwnPtr<ExternalMemoryAllocator> m_externalAllocator; |
115 | 118 |
116 OwnPtr<ImageDecoderFactory> m_imageDecoderFactory; | 119 OwnPtr<ImageDecoderFactory> m_imageDecoderFactory; |
117 | 120 |
118 // Prevents multiple decode operations on the same data. | 121 // Prevents multiple decode operations on the same data. |
119 Mutex m_decodeMutex; | 122 Mutex m_decodeMutex; |
120 | 123 |
121 // Protect concurrent access to m_hasAlpha. | 124 // Protect concurrent access to m_hasAlpha. |
122 Mutex m_alphaMutex; | 125 Mutex m_alphaMutex; |
123 }; | 126 }; |
124 | 127 |
125 } // namespace blink | 128 } // namespace blink |
126 | 129 |
127 #endif | 130 #endif |
OLD | NEW |