Chromium Code Reviews| 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 20 matching lines...) Expand all Loading... | |
| 31 // in the cache multiple times at different scales and filter qualities. | 31 // in the cache multiple times at different scales and filter qualities. |
| 32 class CC_EXPORT ImageDecodeControllerKey { | 32 class CC_EXPORT ImageDecodeControllerKey { |
| 33 public: | 33 public: |
| 34 static ImageDecodeControllerKey FromDrawImage(const DrawImage& image); | 34 static ImageDecodeControllerKey FromDrawImage(const DrawImage& image); |
| 35 | 35 |
| 36 bool operator==(const ImageDecodeControllerKey& other) const { | 36 bool operator==(const ImageDecodeControllerKey& other) const { |
| 37 // The image_id always has to be the same. However, after that all original | 37 // The image_id always has to be the same. However, after that all original |
| 38 // decodes are the same, so if we can use the original decode, return true. | 38 // decodes are the same, so if we can use the original decode, return true. |
| 39 // If not, then we have to compare every field. | 39 // If not, then we have to compare every field. |
| 40 return image_id_ == other.image_id_ && | 40 return image_id_ == other.image_id_ && |
| 41 can_use_original_decode_ == other.can_use_original_decode_ && | 41 can_use_original_decode_ == other.can_use_original_decode_ && |
|
ericrk
2016/03/24 20:01:21
I may have missed something here, was mainly looki
cblume
2016/03/24 20:59:50
I think I agree.
There is a special case to short
| |
| 42 (can_use_original_decode_ || | 42 (can_use_original_decode_ || |
| 43 (src_rect_ == other.src_rect_ && | 43 (src_rect_ == other.src_rect_ && |
| 44 target_size_ == other.target_size_ && | 44 target_size_ == other.target_size_ && |
| 45 filter_quality_ == other.filter_quality_)); | 45 filter_quality_ == other.filter_quality_)); |
| 46 } | 46 } |
| 47 | 47 |
| 48 bool operator!=(const ImageDecodeControllerKey& other) const { | 48 bool operator!=(const ImageDecodeControllerKey& other) const { |
| 49 return !(*this == other); | 49 return !(*this == other); |
| 50 } | 50 } |
| 51 | 51 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 // Get the decoded draw image for the given key and draw_image. Note that this | 178 // Get the decoded draw image for the given key and draw_image. Note that this |
| 179 // function has to be called with no lock acquired, since it will acquire its | 179 // function has to be called with no lock acquired, since it will acquire its |
| 180 // own locks and might call DecodeImageInternal above. Also note that this | 180 // own locks and might call DecodeImageInternal above. Also note that this |
| 181 // function will use the provided key, even if | 181 // function will use the provided key, even if |
| 182 // ImageKey::FromDrawImage(draw_image) would return a different key. | 182 // ImageKey::FromDrawImage(draw_image) would return a different key. |
| 183 // Note that when used internally, we still require that | 183 // Note that when used internally, we still require that |
| 184 // DrawWithImageFinished() is called afterwards. | 184 // DrawWithImageFinished() is called afterwards. |
| 185 DecodedDrawImage GetDecodedImageForDrawInternal(const ImageKey& key, | 185 DecodedDrawImage GetDecodedImageForDrawInternal(const ImageKey& key, |
| 186 const DrawImage& draw_image); | 186 const DrawImage& draw_image); |
| 187 | 187 |
| 188 struct DecodedImageResult { | |
| 189 DecodedImageResult(SkPixmap decoded_pixmap, | |
| 190 DrawImage original_size_draw_image, | |
| 191 DecodedDrawImage decoded_draw_image); | |
| 192 | |
| 193 SkPixmap decoded_pixmap_; | |
| 194 DrawImage original_size_draw_image_; | |
| 195 DecodedDrawImage decoded_draw_image_; | |
| 196 }; | |
| 197 | |
| 198 scoped_ptr<DecodedImage> DecodeImageNoneLowQuality(const ImageKey& key, | |
| 199 const SkImage& image); | |
|
ericrk
2016/03/24 16:06:59
nit: This function is not defined or used.
cblume
2016/03/24 18:45:10
Done.
| |
| 200 scoped_ptr<DecodedImage> DecodeImageMediumQuality(const ImageKey& key, | |
| 201 const SkImage& image); | |
| 202 scoped_ptr<DecodedImage> DecodeImageHighQuality(const ImageKey& key, | |
| 203 const SkImage& image); | |
| 204 | |
| 205 scoped_ptr<DecodedImage> GetOriginalImageDecode(const ImageKey& key, | |
| 206 const SkImage& image); | |
| 207 | |
| 208 DecodedImageResult DecodeImageOrUseCache(const ImageKey& key, | |
| 209 const SkImage& image); | |
| 210 | |
| 211 scoped_ptr<DecodedImage> ScaleImage( | |
| 212 const ImageKey& key, | |
| 213 const DecodedImageResult& decoded_image_result); | |
| 214 | |
| 188 void SanityCheckState(int line, bool lock_acquired); | 215 void SanityCheckState(int line, bool lock_acquired); |
| 189 void RefImage(const ImageKey& key); | 216 void RefImage(const ImageKey& key); |
| 190 void RefAtRasterImage(const ImageKey& key); | 217 void RefAtRasterImage(const ImageKey& key); |
| 191 void UnrefAtRasterImage(const ImageKey& key); | 218 void UnrefAtRasterImage(const ImageKey& key); |
| 192 | 219 |
| 193 // These functions indicate whether the images can be handled and cached by | 220 // These functions indicate whether the images can be handled and cached by |
| 194 // ImageDecodeController or whether they will fall through to Skia (with | 221 // ImageDecodeController or whether they will fall through to Skia (with |
| 195 // exception of possibly prerolling them). Over time these should return | 222 // exception of possibly prerolling them). Over time these should return |
| 196 // "false" in less cases, as the ImageDecodeController should start handling | 223 // "false" in less cases, as the ImageDecodeController should start handling |
| 197 // more of them. | 224 // more of them. |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 222 // image the first time we see it. This mimics the previous behavior and | 249 // 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. | 250 // should over time change as the compositor starts to handle more cases. |
| 224 std::unordered_set<uint32_t> prerolled_images_; | 251 std::unordered_set<uint32_t> prerolled_images_; |
| 225 | 252 |
| 226 ResourceFormat format_; | 253 ResourceFormat format_; |
| 227 }; | 254 }; |
| 228 | 255 |
| 229 } // namespace cc | 256 } // namespace cc |
| 230 | 257 |
| 231 #endif // CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_ | 258 #endif // CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_ |
| OLD | NEW |