Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "cc/tiles/image_manager.h" | |
| 6 | |
| 7 namespace cc { | |
| 8 | |
| 9 ImageManager::ImageManager() = default; | |
| 10 ImageManager::~ImageManager() = default; | |
| 11 | |
| 12 void ImageManager::SetImageDecodeController(ImageDecodeController* controller) { | |
| 13 controller_ = controller; | |
|
enne (OOO)
2016/09/15 17:42:15
This is an awkward API. I realize that the image
vmpstr
2016/09/15 18:16:35
So you're absolutely right that this can change. F
enne (OOO)
2016/09/15 18:27:02
Ok, that's fine if you want to just handle it here
| |
| 14 } | |
| 15 | |
| 16 void ImageManager::GetTasksForImagesAndRef( | |
| 17 std::vector<DrawImage>* images, | |
| 18 std::vector<scoped_refptr<TileTask>>* tasks, | |
| 19 const ImageDecodeController::TracingInfo& tracing_info) { | |
| 20 DCHECK(controller_); | |
| 21 for (auto it = images->begin(); it != images->end();) { | |
| 22 scoped_refptr<TileTask> task; | |
| 23 bool need_to_unref_when_finished = | |
| 24 controller_->GetTaskForImageAndRef(*it, tracing_info, &task); | |
| 25 if (task) | |
| 26 tasks->push_back(std::move(task)); | |
| 27 | |
| 28 if (need_to_unref_when_finished) | |
| 29 ++it; | |
| 30 else | |
| 31 it = images->erase(it); | |
| 32 } | |
| 33 } | |
| 34 | |
| 35 void ImageManager::UnrefImages(const std::vector<DrawImage>& images) { | |
| 36 DCHECK(controller_); | |
| 37 for (auto image : images) | |
| 38 controller_->UnrefImage(image); | |
| 39 } | |
| 40 | |
| 41 void ImageManager::ReduceMemoryUsage() { | |
| 42 DCHECK(controller_); | |
| 43 controller_->ReduceCacheUsage(); | |
| 44 } | |
| 45 | |
| 46 } // namespace cc | |
| OLD | NEW |