Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(423)

Side by Side Diff: cc/tiles/image_manager.cc

Issue 2339703005: cc: Add ImageManager to keep all the image locking in the same place. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698