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 #include "cc/tiles/decoded_image_tracker.h" | 5 #include "cc/tiles/decoded_image_tracker.h" |
6 | 6 |
7 namespace cc { | 7 namespace cc { |
8 namespace { | 8 namespace { |
9 const int kNumFramesToLock = 2; | 9 const int kNumFramesToLock = 2; |
10 } // namespace | 10 } // namespace |
11 | 11 |
12 DecodedImageTracker::DecodedImageTracker() = default; | 12 DecodedImageTracker::DecodedImageTracker() = default; |
13 DecodedImageTracker::~DecodedImageTracker() { | 13 DecodedImageTracker::~DecodedImageTracker() { |
14 for (auto& pair : locked_images_) | 14 for (auto& pair : locked_images_) |
15 image_controller_->UnlockImageDecode(pair.first); | 15 image_controller_->UnlockImageDecode(pair.first); |
16 } | 16 } |
17 | 17 |
18 void DecodedImageTracker::QueueImageDecode( | 18 void DecodedImageTracker::QueueImageDecode( |
19 const PaintImage& image, | 19 const PaintImage& image, |
20 const base::Callback<void(bool)>& callback) { | 20 const base::Callback<void(bool)>& callback) { |
21 DCHECK(image_controller_); | 21 DCHECK(image_controller_); |
22 // Queue the decode in the image controller, but switch out the callback for | 22 // Queue the decode in the image controller, but switch out the callback for |
23 // our own. | 23 // our own. |
| 24 |
| 25 // TODO(ccameron): The target color space specified here should match the |
| 26 // target color space that will be used at rasterization time. Leave this |
| 27 // unspecified now, since that will match the rasterization-time color |
| 28 // space while color correct rendering is disabled. |
| 29 gfx::ColorSpace target_color_space; |
| 30 |
| 31 auto image_bounds = image.sk_image()->bounds(); |
| 32 // TODO(khushalsagar): Eliminate the use of an incorrect id here and have all |
| 33 // call-sites provide PaintImage to the ImageController. |
| 34 DrawImage draw_image(image, image_bounds, kNone_SkFilterQuality, |
| 35 SkMatrix::I(), target_color_space); |
24 image_controller_->QueueImageDecode( | 36 image_controller_->QueueImageDecode( |
25 image.sk_image(), base::Bind(&DecodedImageTracker::ImageDecodeFinished, | 37 draw_image, base::Bind(&DecodedImageTracker::ImageDecodeFinished, |
26 base::Unretained(this), callback)); | 38 base::Unretained(this), callback)); |
27 } | 39 } |
28 | 40 |
29 void DecodedImageTracker::NotifyFrameFinished() { | 41 void DecodedImageTracker::NotifyFrameFinished() { |
30 // Go through the images and if the frame ref count goes to 0, unlock the | 42 // Go through the images and if the frame ref count goes to 0, unlock the |
31 // image in the controller. | 43 // image in the controller. |
32 for (auto it = locked_images_.begin(); it != locked_images_.end();) { | 44 for (auto it = locked_images_.begin(); it != locked_images_.end();) { |
33 auto id = it->first; | 45 auto id = it->first; |
34 int& ref_count = it->second; | 46 int& ref_count = it->second; |
35 if (--ref_count != 0) { | 47 if (--ref_count != 0) { |
36 ++it; | 48 ++it; |
(...skipping 10 matching lines...) Expand all Loading... |
47 ImageController::ImageDecodeResult result) { | 59 ImageController::ImageDecodeResult result) { |
48 if (result == ImageController::ImageDecodeResult::SUCCESS) | 60 if (result == ImageController::ImageDecodeResult::SUCCESS) |
49 locked_images_.push_back(std::make_pair(id, kNumFramesToLock)); | 61 locked_images_.push_back(std::make_pair(id, kNumFramesToLock)); |
50 bool decode_succeeded = | 62 bool decode_succeeded = |
51 result == ImageController::ImageDecodeResult::SUCCESS || | 63 result == ImageController::ImageDecodeResult::SUCCESS || |
52 result == ImageController::ImageDecodeResult::DECODE_NOT_REQUIRED; | 64 result == ImageController::ImageDecodeResult::DECODE_NOT_REQUIRED; |
53 callback.Run(decode_succeeded); | 65 callback.Run(decode_succeeded); |
54 } | 66 } |
55 | 67 |
56 } // namespace cc | 68 } // namespace cc |
OLD | NEW |