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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 return result.ValueOrDefault(std::numeric_limits<size_t>::max()); | 67 return result.ValueOrDefault(std::numeric_limits<size_t>::max()); |
| 68 } | 68 } |
| 69 | 69 |
| 70 std::string ToString() const; | 70 std::string ToString() const; |
| 71 | 71 |
| 72 private: | 72 private: |
| 73 ImageDecodeControllerKey(uint32_t image_id, | 73 ImageDecodeControllerKey(uint32_t image_id, |
| 74 const gfx::Rect& src_rect, | 74 const gfx::Rect& src_rect, |
| 75 const gfx::Size& size, | 75 const gfx::Size& size, |
| 76 SkFilterQuality filter_quality, | 76 SkFilterQuality filter_quality, |
| 77 bool can_use_original_decode); | 77 bool can_use_original_decode_); |
|
ericrk
2016/03/29 23:23:10
nit: remove the "_"
cblume
2016/03/31 18:28:53
Done.
| |
| 78 | 78 |
| 79 uint32_t image_id_; | 79 uint32_t image_id_; |
| 80 gfx::Rect src_rect_; | 80 gfx::Rect src_rect_; |
| 81 gfx::Size target_size_; | 81 gfx::Size target_size_; |
| 82 SkFilterQuality filter_quality_; | 82 SkFilterQuality filter_quality_; |
| 83 bool can_use_original_decode_; | 83 bool can_use_original_decode_; |
| 84 size_t hash_; | 84 size_t hash_; |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 // Hash function for the above ImageDecodeControllerKey. | 87 // Hash function for the above ImageDecodeControllerKey. |
| (...skipping 90 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> DecodeImageMediumQuality(const ImageKey& key, | |
| 199 const SkImage& image); | |
| 200 scoped_ptr<DecodedImage> DecodeImageHighQuality(const ImageKey& key, | |
| 201 const SkImage& image); | |
| 202 | |
| 203 scoped_ptr<DecodedImage> GetOriginalImageDecode(const ImageKey& key, | |
| 204 const SkImage& image); | |
| 205 | |
| 206 DecodedImageResult DecodeImageOrUseCache(const ImageKey& key, | |
| 207 const SkImage& image); | |
| 208 | |
| 209 scoped_ptr<DecodedImage> ScaleImage( | |
| 210 const ImageKey& key, | |
| 211 const DecodedImageResult& decoded_image_result); | |
| 212 | |
| 188 void SanityCheckState(int line, bool lock_acquired); | 213 void SanityCheckState(int line, bool lock_acquired); |
| 189 void RefImage(const ImageKey& key); | 214 void RefImage(const ImageKey& key); |
| 190 void RefAtRasterImage(const ImageKey& key); | 215 void RefAtRasterImage(const ImageKey& key); |
| 191 void UnrefAtRasterImage(const ImageKey& key); | 216 void UnrefAtRasterImage(const ImageKey& key); |
| 192 | 217 |
| 193 // These functions indicate whether the images can be handled and cached by | 218 // These functions indicate whether the images can be handled and cached by |
| 194 // ImageDecodeController or whether they will fall through to Skia (with | 219 // ImageDecodeController or whether they will fall through to Skia (with |
| 195 // exception of possibly prerolling them). Over time these should return | 220 // exception of possibly prerolling them). Over time these should return |
| 196 // "false" in less cases, as the ImageDecodeController should start handling | 221 // "false" in less cases, as the ImageDecodeController should start handling |
| 197 // more of them. | 222 // more of them. |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 222 // image the first time we see it. This mimics the previous behavior and | 247 // 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. | 248 // should over time change as the compositor starts to handle more cases. |
| 224 std::unordered_set<uint32_t> prerolled_images_; | 249 std::unordered_set<uint32_t> prerolled_images_; |
| 225 | 250 |
| 226 ResourceFormat format_; | 251 ResourceFormat format_; |
| 227 }; | 252 }; |
| 228 | 253 |
| 229 } // namespace cc | 254 } // namespace cc |
| 230 | 255 |
| 231 #endif // CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_ | 256 #endif // CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_ |
| OLD | NEW |