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

Side by Side Diff: cc/resources/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/resources/scoped_ui_resource.h ('k') | cc/resources/ui_resource_manager.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/resources/scoped_ui_resource.h" 5 #include "cc/resources/scoped_ui_resource.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "cc/trees/layer_tree_host.h" 9 #include "cc/resources/ui_resource_manager.h"
10 10
11 namespace cc { 11 namespace cc {
12 12
13 std::unique_ptr<ScopedUIResource> ScopedUIResource::Create( 13 std::unique_ptr<ScopedUIResource> ScopedUIResource::Create(
14 LayerTreeHost* host, 14 UIResourceManager* ui_resource_manager,
15 const UIResourceBitmap& bitmap) { 15 const UIResourceBitmap& bitmap) {
16 return base::WrapUnique(new ScopedUIResource(host, bitmap)); 16 return base::WrapUnique(new ScopedUIResource(ui_resource_manager, bitmap));
17 } 17 }
18 18
19 ScopedUIResource::ScopedUIResource(LayerTreeHost* host, 19 ScopedUIResource::ScopedUIResource(UIResourceManager* ui_resource_manager,
20 const UIResourceBitmap& bitmap) 20 const UIResourceBitmap& bitmap)
21 : bitmap_(bitmap), host_(host) { 21 : bitmap_(bitmap), ui_resource_manager_(ui_resource_manager) {
22 DCHECK(host_); 22 DCHECK(ui_resource_manager_);
23 id_ = host_->CreateUIResource(this); 23 id_ = ui_resource_manager_->CreateUIResource(this);
24 } 24 }
25 25
26 // User must make sure that host is still valid before this object goes out of 26 // User must make sure that host is still valid before this object goes out of
27 // scope. 27 // scope.
28 ScopedUIResource::~ScopedUIResource() { 28 ScopedUIResource::~ScopedUIResource() {
29 if (id_) { 29 if (id_) {
30 DCHECK(host_); 30 DCHECK(ui_resource_manager_);
31 host_->DeleteUIResource(id_); 31 ui_resource_manager_->DeleteUIResource(id_);
32 } 32 }
33 } 33 }
34 34
35 UIResourceBitmap ScopedUIResource::GetBitmap(UIResourceId uid, 35 UIResourceBitmap ScopedUIResource::GetBitmap(UIResourceId uid,
36 bool resource_lost) { 36 bool resource_lost) {
37 return bitmap_; 37 return bitmap_;
38 } 38 }
39 39
40 } // namespace cc 40 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/scoped_ui_resource.h ('k') | cc/resources/ui_resource_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698