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

Side by Side Diff: cc/test/fake_scoped_ui_resource.cc

Issue 2322943003: cc: Move UI Resource management out of LayerTreeHost. (Closed)
Patch Set: virtual dtor 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
« no previous file with comments | « cc/test/fake_scoped_ui_resource.h ('k') | cc/trees/layer_tree.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/test/fake_scoped_ui_resource.h" 5 #include "cc/test/fake_scoped_ui_resource.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "cc/resources/ui_resource_manager.h"
8 #include "cc/trees/layer_tree_host.h" 9 #include "cc/trees/layer_tree_host.h"
9 10
10 namespace cc { 11 namespace cc {
11 12
12 namespace { 13 namespace {
13 14
14 UIResourceBitmap CreateMockUIResourceBitmap() { 15 UIResourceBitmap CreateMockUIResourceBitmap() {
15 bool is_opaque = false; 16 bool is_opaque = false;
16 return UIResourceBitmap(gfx::Size(1, 1), is_opaque); 17 return UIResourceBitmap(gfx::Size(1, 1), is_opaque);
17 } 18 }
18 19
19 } // anonymous namespace 20 } // anonymous namespace
20 21
21 std::unique_ptr<FakeScopedUIResource> FakeScopedUIResource::Create( 22 std::unique_ptr<FakeScopedUIResource> FakeScopedUIResource::Create(
22 LayerTreeHost* host) { 23 UIResourceManager* ui_resource_manager) {
23 return base::WrapUnique(new FakeScopedUIResource(host)); 24 return base::WrapUnique(new FakeScopedUIResource(ui_resource_manager));
24 } 25 }
25 26
26 FakeScopedUIResource::FakeScopedUIResource(LayerTreeHost* host) 27 FakeScopedUIResource::FakeScopedUIResource(
27 : ScopedUIResource(host, CreateMockUIResourceBitmap()) { 28 UIResourceManager* ui_resource_manager)
29 : ScopedUIResource(ui_resource_manager, CreateMockUIResourceBitmap()) {
28 // The constructor of ScopedUIResource already created a resource so we need 30 // The constructor of ScopedUIResource already created a resource so we need
29 // to delete the created resource to wipe the state clean. 31 // to delete the created resource to wipe the state clean.
30 host_->DeleteUIResource(id_); 32 ui_resource_manager_->DeleteUIResource(id_);
31 ResetCounters(); 33 ResetCounters();
32 id_ = host_->CreateUIResource(this); 34 id_ = ui_resource_manager_->CreateUIResource(this);
33 } 35 }
34 36
35 void FakeScopedUIResource::DeleteResource() { 37 void FakeScopedUIResource::DeleteResource() {
36 host_->DeleteUIResource(id_); 38 ui_resource_manager_->DeleteUIResource(id_);
37 id_ = 0; 39 id_ = 0;
38 } 40 }
39 41
40 UIResourceBitmap FakeScopedUIResource::GetBitmap(UIResourceId uid, 42 UIResourceBitmap FakeScopedUIResource::GetBitmap(UIResourceId uid,
41 bool resource_lost) { 43 bool resource_lost) {
42 resource_create_count++; 44 resource_create_count++;
43 if (resource_lost) 45 if (resource_lost)
44 lost_resource_count++; 46 lost_resource_count++;
45 return ScopedUIResource::GetBitmap(uid, resource_lost); 47 return ScopedUIResource::GetBitmap(uid, resource_lost);
46 } 48 }
47 49
48 void FakeScopedUIResource::ResetCounters() { 50 void FakeScopedUIResource::ResetCounters() {
49 resource_create_count = 0; 51 resource_create_count = 0;
50 lost_resource_count = 0; 52 lost_resource_count = 0;
51 } 53 }
52 54
53 } // namespace cc 55 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/fake_scoped_ui_resource.h ('k') | cc/trees/layer_tree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698