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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 void copyData(RefPtr<SharedBuffer>*, bool* allDataReceived); | 79 void copyData(RefPtr<SharedBuffer>*, bool* allDataReceived); |
80 | 80 |
81 SkISize getFullSize() const { return m_fullSize; } | 81 SkISize getFullSize() const { return m_fullSize; } |
82 | 82 |
83 bool isMultiFrame() const { return m_isMultiFrame; } | 83 bool isMultiFrame() const { return m_isMultiFrame; } |
84 | 84 |
85 // FIXME: Return alpha state for each frame. | 85 // FIXME: Return alpha state for each frame. |
86 bool hasAlpha(size_t); | 86 bool hasAlpha(size_t); |
87 | 87 |
88 private: | 88 private: |
| 89 class ExternalMemoryAllocator; |
89 friend class ImageFrameGeneratorTest; | 90 friend class ImageFrameGeneratorTest; |
90 friend class DeferredImageDecoderTest; | 91 friend class DeferredImageDecoderTest; |
91 // For testing. |factory| will overwrite the default ImageDecoder creation l
ogic if |factory->create()| returns non-zero. | 92 // For testing. |factory| will overwrite the default ImageDecoder creation l
ogic if |factory->create()| returns non-zero. |
92 void setImageDecoderFactory(PassOwnPtr<ImageDecoderFactory> factory) { m_ima
geDecoderFactory = factory; } | 93 void setImageDecoderFactory(PassOwnPtr<ImageDecoderFactory> factory) { m_ima
geDecoderFactory = factory; } |
93 // For testing. | 94 // For testing. |
94 SkBitmap::Allocator* allocator() const { return m_allocator.get(); } | 95 SkBitmap::Allocator* allocator() const { return m_discardableAllocator.get()
; } |
95 void setAllocator(PassOwnPtr<SkBitmap::Allocator> allocator) { m_allocator =
allocator; } | 96 void setAllocator(PassOwnPtr<SkBitmap::Allocator> allocator) { m_discardable
Allocator = allocator; } |
96 | 97 |
97 // These methods are called while m_decodeMutex is locked. | 98 // These methods are called while m_decodeMutex is locked. |
98 const ScaledImageFragment* tryToLockCompleteCache(const SkISize& scaledSize,
size_t index); | 99 const ScaledImageFragment* tryToLockCompleteCache(const SkISize& scaledSize,
size_t index); |
99 const ScaledImageFragment* tryToResumeDecode(const SkISize& scaledSize, size
_t index); | 100 const ScaledImageFragment* tryToResumeDecode(const SkISize& scaledSize, size
_t index); |
100 | 101 |
101 // Use the given decoder to decode. If a decoder is not given then try to cr
eate one. | 102 // Use the given decoder to decode. If a decoder is not given then try to cr
eate one. |
102 PassOwnPtr<ScaledImageFragment> decode(size_t index, ImageDecoder**); | 103 PassOwnPtr<ScaledImageFragment> decode(size_t index, ImageDecoder**); |
103 | 104 |
104 // Return the next generation ID of a new image object. This is used | 105 // Return the next generation ID of a new image object. This is used |
105 // to identify images of the same frame from different stages of | 106 // to identify images of the same frame from different stages of |
106 // progressive decode. | 107 // progressive decode. |
107 size_t nextGenerationId() { return m_decodeCount++; } | 108 size_t nextGenerationId() { return m_decodeCount++; } |
108 | 109 |
109 SkISize m_fullSize; | 110 SkISize m_fullSize; |
110 ThreadSafeDataTransport m_data; | 111 ThreadSafeDataTransport m_data; |
111 bool m_isMultiFrame; | 112 bool m_isMultiFrame; |
112 bool m_decodeFailedAndEmpty; | 113 bool m_decodeFailedAndEmpty; |
113 Vector<bool> m_hasAlpha; | 114 Vector<bool> m_hasAlpha; |
114 size_t m_decodeCount; | 115 size_t m_decodeCount; |
115 OwnPtr<SkBitmap::Allocator> m_allocator; | 116 OwnPtr<SkBitmap::Allocator> m_discardableAllocator; |
| 117 OwnPtr<ExternalMemoryAllocator> m_externalAllocator; |
116 | 118 |
117 OwnPtr<ImageDecoderFactory> m_imageDecoderFactory; | 119 OwnPtr<ImageDecoderFactory> m_imageDecoderFactory; |
118 | 120 |
119 // Prevents multiple decode operations on the same data. | 121 // Prevents multiple decode operations on the same data. |
120 Mutex m_decodeMutex; | 122 Mutex m_decodeMutex; |
121 | 123 |
122 // Protect concurrent access to m_hasAlpha. | 124 // Protect concurrent access to m_hasAlpha. |
123 Mutex m_alphaMutex; | 125 Mutex m_alphaMutex; |
124 }; | 126 }; |
125 | 127 |
126 } // namespace WebCore | 128 } // namespace WebCore |
127 | 129 |
128 #endif | 130 #endif |
OLD | NEW |