OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_ | 5 #ifndef CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_ |
6 #define CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_ | 6 #define CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <unordered_map> | 10 #include <unordered_map> |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 using ImageKey = ImageDecodeControllerKey; | 96 using ImageKey = ImageDecodeControllerKey; |
97 using ImageKeyHash = ImageDecodeControllerKeyHash; | 97 using ImageKeyHash = ImageDecodeControllerKeyHash; |
98 | 98 |
99 explicit SoftwareImageDecodeController(ResourceFormat format); | 99 explicit SoftwareImageDecodeController(ResourceFormat format); |
100 SoftwareImageDecodeController(); | 100 SoftwareImageDecodeController(); |
101 ~SoftwareImageDecodeController() override; | 101 ~SoftwareImageDecodeController() override; |
102 | 102 |
103 // ImageDecodeController overrides. | 103 // ImageDecodeController overrides. |
104 bool GetTaskForImageAndRef(const DrawImage& image, | 104 bool GetTaskForImageAndRef(const DrawImage& image, |
105 uint64_t prepare_tiles_id, | 105 uint64_t prepare_tiles_id, |
106 scoped_refptr<ImageDecodeTask>* task) override; | 106 scoped_refptr<DependencyTask>* task) override; |
107 void UnrefImage(const DrawImage& image) override; | 107 void UnrefImage(const DrawImage& image) override; |
108 DecodedDrawImage GetDecodedImageForDraw(const DrawImage& image) override; | 108 DecodedDrawImage GetDecodedImageForDraw(const DrawImage& image) override; |
109 void DrawWithImageFinished(const DrawImage& image, | 109 void DrawWithImageFinished(const DrawImage& image, |
110 const DecodedDrawImage& decoded_image) override; | 110 const DecodedDrawImage& decoded_image) override; |
111 void ReduceCacheUsage() override; | 111 void ReduceCacheUsage() override; |
112 | 112 |
113 // Decode the given image and store it in the cache. This is only called by an | 113 // Decode the given image and store it in the cache. This is only called by an |
114 // image decode task from a worker thread. | 114 // image decode task from a worker thread. |
115 void DecodeImage(const ImageKey& key, const DrawImage& image); | 115 void DecodeImage(const ImageKey& key, const DrawImage& image); |
116 | 116 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 void RefAtRasterImage(const ImageKey& key); | 190 void RefAtRasterImage(const ImageKey& key); |
191 void UnrefAtRasterImage(const ImageKey& key); | 191 void UnrefAtRasterImage(const ImageKey& key); |
192 | 192 |
193 // These functions indicate whether the images can be handled and cached by | 193 // These functions indicate whether the images can be handled and cached by |
194 // ImageDecodeController or whether they will fall through to Skia (with | 194 // ImageDecodeController or whether they will fall through to Skia (with |
195 // exception of possibly prerolling them). Over time these should return | 195 // exception of possibly prerolling them). Over time these should return |
196 // "false" in less cases, as the ImageDecodeController should start handling | 196 // "false" in less cases, as the ImageDecodeController should start handling |
197 // more of them. | 197 // more of them. |
198 bool CanHandleImage(const ImageKey& key); | 198 bool CanHandleImage(const ImageKey& key); |
199 | 199 |
200 std::unordered_map<ImageKey, scoped_refptr<ImageDecodeTask>, ImageKeyHash> | 200 std::unordered_map<ImageKey, scoped_refptr<DependencyTask>, ImageKeyHash> |
201 pending_image_tasks_; | 201 pending_image_tasks_; |
202 | 202 |
203 // The members below this comment can only be accessed if the lock is held to | 203 // The members below this comment can only be accessed if the lock is held to |
204 // ensure that they are safe to access on multiple threads. | 204 // ensure that they are safe to access on multiple threads. |
205 base::Lock lock_; | 205 base::Lock lock_; |
206 | 206 |
207 using ImageMRUCache = | 207 using ImageMRUCache = |
208 base::HashingMRUCache<ImageKey, scoped_ptr<DecodedImage>, ImageKeyHash>; | 208 base::HashingMRUCache<ImageKey, scoped_ptr<DecodedImage>, ImageKeyHash>; |
209 | 209 |
210 // Decoded images and ref counts (predecode path). | 210 // Decoded images and ref counts (predecode path). |
(...skipping 11 matching lines...) Expand all Loading... |
222 // image the first time we see it. This mimics the previous behavior and | 222 // image the first time we see it. This mimics the previous behavior and |
223 // should over time change as the compositor starts to handle more cases. | 223 // should over time change as the compositor starts to handle more cases. |
224 std::unordered_set<uint32_t> prerolled_images_; | 224 std::unordered_set<uint32_t> prerolled_images_; |
225 | 225 |
226 ResourceFormat format_; | 226 ResourceFormat format_; |
227 }; | 227 }; |
228 | 228 |
229 } // namespace cc | 229 } // namespace cc |
230 | 230 |
231 #endif // CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_ | 231 #endif // CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_ |
OLD | NEW |