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