| 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_CACHE_H_ | 5 #ifndef CC_TILES_SOFTWARE_IMAGE_DECODE_CACHE_H_ |
| 6 #define CC_TILES_SOFTWARE_IMAGE_DECODE_CACHE_H_ | 6 #define CC_TILES_SOFTWARE_IMAGE_DECODE_CACHE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 // Get the decoded draw image for the given key and draw_image. Note that this | 242 // Get the decoded draw image for the given key and draw_image. Note that this |
| 243 // function has to be called with no lock acquired, since it will acquire its | 243 // function has to be called with no lock acquired, since it will acquire its |
| 244 // own locks and might call DecodeImageInternal above. Also note that this | 244 // own locks and might call DecodeImageInternal above. Also note that this |
| 245 // function will use the provided key, even if | 245 // function will use the provided key, even if |
| 246 // ImageKey::FromDrawImage(draw_image) would return a different key. | 246 // ImageKey::FromDrawImage(draw_image) would return a different key. |
| 247 // Note that when used internally, we still require that | 247 // Note that when used internally, we still require that |
| 248 // DrawWithImageFinished() is called afterwards. | 248 // DrawWithImageFinished() is called afterwards. |
| 249 DecodedDrawImage GetDecodedImageForDrawInternal(const ImageKey& key, | 249 DecodedDrawImage GetDecodedImageForDrawInternal(const ImageKey& key, |
| 250 const DrawImage& draw_image); | 250 const DrawImage& draw_image); |
| 251 | 251 |
| 252 // GetOriginalImageDecode is called by DecodeImageInternal when the quality | 252 // GetOriginalSizeImageDecode is called by DecodeImageInternal when the |
| 253 // does not scale the image. Like DecodeImageInternal, it should be called | 253 // quality does not scale the image. Like DecodeImageInternal, it should be |
| 254 // with no lock acquired and it returns nullptr if the decoding failed. | 254 // called with no lock acquired and it returns nullptr if the decoding failed. |
| 255 std::unique_ptr<DecodedImage> GetOriginalImageDecode( | 255 std::unique_ptr<DecodedImage> GetOriginalSizeImageDecode( |
| 256 const ImageKey& key, |
| 256 sk_sp<const SkImage> image); | 257 sk_sp<const SkImage> image); |
| 257 | 258 |
| 258 // GetSubrectImageDecode is similar to GetOriginalImageDecode in that no scale | 259 // GetSubrectImageDecode is similar to GetOriginalSizeImageDecode in that no |
| 259 // is performed on the image. However, we extract a subrect (copy it out) and | 260 // scale is performed on the image. However, we extract a subrect (copy it |
| 260 // only return this subrect in order to cache a smaller amount of memory. Note | 261 // out) and only return this subrect in order to cache a smaller amount of |
| 261 // that this uses GetOriginalImageDecode to get the initial data, which | 262 // memory. Note that this uses GetOriginalSizeImageDecode to get the initial |
| 262 // ensures that we cache an unlocked version of the original image in case we | 263 // data, which ensures that we cache an unlocked version of the original image |
| 263 // need to extract multiple subrects (as would be the case in an atlas). | 264 // in case we need to extract multiple subrects (as would be the case in an |
| 265 // atlas). |
| 264 std::unique_ptr<DecodedImage> GetSubrectImageDecode( | 266 std::unique_ptr<DecodedImage> GetSubrectImageDecode( |
| 265 const ImageKey& key, | 267 const ImageKey& key, |
| 266 sk_sp<const SkImage> image); | 268 sk_sp<const SkImage> image); |
| 267 | 269 |
| 268 // GetScaledImageDecode is called by DecodeImageInternal when the quality | 270 // GetScaledImageDecode is called by DecodeImageInternal when the quality |
| 269 // requires the image be scaled. Like DecodeImageInternal, it should be | 271 // requires the image be scaled. Like DecodeImageInternal, it should be |
| 270 // called with no lock acquired and it returns nullptr if the decoding or | 272 // called with no lock acquired and it returns nullptr if the decoding or |
| 271 // scaling failed. | 273 // scaling failed. |
| 272 std::unique_ptr<DecodedImage> GetScaledImageDecode( | 274 std::unique_ptr<DecodedImage> GetScaledImageDecode( |
| 273 const ImageKey& key, | 275 const ImageKey& key, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 ResourceFormat format_; | 322 ResourceFormat format_; |
| 321 size_t max_items_in_cache_; | 323 size_t max_items_in_cache_; |
| 322 | 324 |
| 323 // Used to uniquely identify DecodedImages for memory traces. | 325 // Used to uniquely identify DecodedImages for memory traces. |
| 324 base::AtomicSequenceNumber next_tracing_id_; | 326 base::AtomicSequenceNumber next_tracing_id_; |
| 325 }; | 327 }; |
| 326 | 328 |
| 327 } // namespace cc | 329 } // namespace cc |
| 328 | 330 |
| 329 #endif // CC_TILES_SOFTWARE_IMAGE_DECODE_CACHE_H_ | 331 #endif // CC_TILES_SOFTWARE_IMAGE_DECODE_CACHE_H_ |
| OLD | NEW |