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/image_manager.h" | 5 #include "cc/tiles/image_manager.h" |
6 | 6 |
7 namespace cc { | 7 namespace cc { |
8 | 8 |
9 ImageManager::ImageManager() = default; | 9 ImageManager::ImageManager() = default; |
10 ImageManager::~ImageManager() = default; | 10 ImageManager::~ImageManager() = default; |
11 | 11 |
12 void ImageManager::SetImageDecodeController(ImageDecodeController* controller) { | 12 void ImageManager::SetImageDecodeController(ImageDecodeController* controller) { |
| 13 // We can only switch from null to non-null and back. |
| 14 DCHECK(controller || controller_); |
| 15 DCHECK(!controller || !controller_); |
| 16 |
| 17 if (!controller) { |
| 18 SetPredecodeImages(std::vector<DrawImage>(), |
| 19 ImageDecodeController::TracingInfo()); |
| 20 } |
13 controller_ = controller; | 21 controller_ = controller; |
14 } | 22 } |
15 | 23 |
16 void ImageManager::GetTasksForImagesAndRef( | 24 void ImageManager::GetTasksForImagesAndRef( |
17 std::vector<DrawImage>* images, | 25 std::vector<DrawImage>* images, |
18 std::vector<scoped_refptr<TileTask>>* tasks, | 26 std::vector<scoped_refptr<TileTask>>* tasks, |
19 const ImageDecodeController::TracingInfo& tracing_info) { | 27 const ImageDecodeController::TracingInfo& tracing_info) { |
20 DCHECK(controller_); | 28 DCHECK(controller_); |
21 for (auto it = images->begin(); it != images->end();) { | 29 for (auto it = images->begin(); it != images->end();) { |
22 scoped_refptr<TileTask> task; | 30 scoped_refptr<TileTask> task; |
(...skipping 13 matching lines...) Expand all Loading... |
36 DCHECK(controller_); | 44 DCHECK(controller_); |
37 for (auto image : images) | 45 for (auto image : images) |
38 controller_->UnrefImage(image); | 46 controller_->UnrefImage(image); |
39 } | 47 } |
40 | 48 |
41 void ImageManager::ReduceMemoryUsage() { | 49 void ImageManager::ReduceMemoryUsage() { |
42 DCHECK(controller_); | 50 DCHECK(controller_); |
43 controller_->ReduceCacheUsage(); | 51 controller_->ReduceCacheUsage(); |
44 } | 52 } |
45 | 53 |
| 54 std::vector<scoped_refptr<TileTask>> ImageManager::SetPredecodeImages( |
| 55 std::vector<DrawImage> images, |
| 56 const ImageDecodeController::TracingInfo& tracing_info) { |
| 57 std::vector<scoped_refptr<TileTask>> new_tasks; |
| 58 GetTasksForImagesAndRef(&images, &new_tasks, tracing_info); |
| 59 UnrefImages(predecode_locked_images_); |
| 60 predecode_locked_images_ = std::move(images); |
| 61 return new_tasks; |
| 62 } |
| 63 |
46 } // namespace cc | 64 } // namespace cc |
OLD | NEW |