| 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 // Get the decoded draw image for the given key and draw_image. Note that this | 177 // Get the decoded draw image for the given key and draw_image. Note that this |
| 178 // function has to be called with no lock acquired, since it will acquire its | 178 // function has to be called with no lock acquired, since it will acquire its |
| 179 // own locks and might call DecodeImageInternal above. Also note that this | 179 // own locks and might call DecodeImageInternal above. Also note that this |
| 180 // function will use the provided key, even if | 180 // function will use the provided key, even if |
| 181 // ImageKey::FromDrawImage(draw_image) would return a different key. | 181 // ImageKey::FromDrawImage(draw_image) would return a different key. |
| 182 // Note that when used internally, we still require that | 182 // Note that when used internally, we still require that |
| 183 // DrawWithImageFinished() is called afterwards. | 183 // DrawWithImageFinished() is called afterwards. |
| 184 DecodedDrawImage GetDecodedImageForDrawInternal(const ImageKey& key, | 184 DecodedDrawImage GetDecodedImageForDrawInternal(const ImageKey& key, |
| 185 const DrawImage& draw_image); | 185 const DrawImage& draw_image); |
| 186 | 186 |
| 187 struct DecodedImageResult { |
| 188 DecodedImageResult(SkPixmap decoded_pixmap, |
| 189 DrawImage original_size_draw_image, |
| 190 DecodedDrawImage decoded_draw_image); |
| 191 |
| 192 SkPixmap decoded_pixmap_; |
| 193 DrawImage original_size_draw_image_; |
| 194 DecodedDrawImage decoded_draw_image_; |
| 195 }; |
| 196 |
| 197 scoped_ptr<DecodedImage> DecodeImageNoneLowQuality(const ImageKey& key, |
| 198 const SkImage& image); |
| 199 scoped_ptr<DecodedImage> DecodeImageMediumQuality(const ImageKey& key, |
| 200 const SkImage& image); |
| 201 scoped_ptr<DecodedImage> DecodeImageHighQuality(const ImageKey& key, |
| 202 const SkImage& image); |
| 203 |
| 204 scoped_ptr<DecodedImage> AttemptToUseOriginalImage(const ImageKey& key, |
| 205 const SkImage& image); |
| 206 |
| 207 DecodedImageResult DecodeImageOrUseCache(const ImageKey& key, |
| 208 const SkImage& image); |
| 209 |
| 210 scoped_ptr<DecodedImage> ScaleImage( |
| 211 const ImageKey& key, |
| 212 const DecodedImageResult& decoded_image_result); |
| 213 |
| 187 void SanityCheckState(int line, bool lock_acquired); | 214 void SanityCheckState(int line, bool lock_acquired); |
| 188 void RefImage(const ImageKey& key); | 215 void RefImage(const ImageKey& key); |
| 189 void RefAtRasterImage(const ImageKey& key); | 216 void RefAtRasterImage(const ImageKey& key); |
| 190 void UnrefAtRasterImage(const ImageKey& key); | 217 void UnrefAtRasterImage(const ImageKey& key); |
| 191 | 218 |
| 192 // These functions indicate whether the images can be handled and cached by | |
| 193 // ImageDecodeController or whether they will fall through to Skia (with | |
| 194 // exception of possibly prerolling them). Over time these should return | |
| 195 // "false" in less cases, as the ImageDecodeController should start handling | |
| 196 // more of them. | |
| 197 bool CanHandleImage(const ImageKey& key); | |
| 198 | |
| 199 std::unordered_map<ImageKey, scoped_refptr<ImageDecodeTask>, ImageKeyHash> | 219 std::unordered_map<ImageKey, scoped_refptr<ImageDecodeTask>, ImageKeyHash> |
| 200 pending_image_tasks_; | 220 pending_image_tasks_; |
| 201 | 221 |
| 202 // The members below this comment can only be accessed if the lock is held to | 222 // The members below this comment can only be accessed if the lock is held to |
| 203 // ensure that they are safe to access on multiple threads. | 223 // ensure that they are safe to access on multiple threads. |
| 204 base::Lock lock_; | 224 base::Lock lock_; |
| 205 | 225 |
| 206 using ImageMRUCache = | 226 using ImageMRUCache = |
| 207 base::HashingMRUCache<ImageKey, scoped_ptr<DecodedImage>, ImageKeyHash>; | 227 base::HashingMRUCache<ImageKey, scoped_ptr<DecodedImage>, ImageKeyHash>; |
| 208 | 228 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 221 // image the first time we see it. This mimics the previous behavior and | 241 // image the first time we see it. This mimics the previous behavior and |
| 222 // should over time change as the compositor starts to handle more cases. | 242 // should over time change as the compositor starts to handle more cases. |
| 223 std::unordered_set<uint32_t> prerolled_images_; | 243 std::unordered_set<uint32_t> prerolled_images_; |
| 224 | 244 |
| 225 ResourceFormat format_; | 245 ResourceFormat format_; |
| 226 }; | 246 }; |
| 227 | 247 |
| 228 } // namespace cc | 248 } // namespace cc |
| 229 | 249 |
| 230 #endif // CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_ | 250 #endif // CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_ |
| OLD | NEW |