OLD | NEW |
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/trees/layer_tree_host.h" | 8 #include "cc/trees/layer_tree_host.h" |
9 | 9 |
10 namespace cc { | 10 namespace cc { |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 FakeScopedUIResource::FakeScopedUIResource(LayerTreeHost* host) | 26 FakeScopedUIResource::FakeScopedUIResource(LayerTreeHost* host) |
27 : ScopedUIResource(host, CreateMockUIResourceBitmap()) { | 27 : ScopedUIResource(host, CreateMockUIResourceBitmap()) { |
28 // The constructor of ScopedUIResource already created a resource so we need | 28 // The constructor of ScopedUIResource already created a resource so we need |
29 // to delete the created resource to wipe the state clean. | 29 // to delete the created resource to wipe the state clean. |
30 host_->DeleteUIResource(id_); | 30 host_->DeleteUIResource(id_); |
31 ResetCounters(); | 31 ResetCounters(); |
32 id_ = host_->CreateUIResource(this); | 32 id_ = host_->CreateUIResource(this); |
33 } | 33 } |
34 | 34 |
| 35 void FakeScopedUIResource::DeleteResource() { |
| 36 host_->DeleteUIResource(id_); |
| 37 id_ = 0; |
| 38 } |
| 39 |
35 UIResourceBitmap FakeScopedUIResource::GetBitmap(UIResourceId uid, | 40 UIResourceBitmap FakeScopedUIResource::GetBitmap(UIResourceId uid, |
36 bool resource_lost) { | 41 bool resource_lost) { |
37 resource_create_count++; | 42 resource_create_count++; |
38 if (resource_lost) | 43 if (resource_lost) |
39 lost_resource_count++; | 44 lost_resource_count++; |
40 return ScopedUIResource::GetBitmap(uid, resource_lost); | 45 return ScopedUIResource::GetBitmap(uid, resource_lost); |
41 } | 46 } |
42 | 47 |
43 void FakeScopedUIResource::ResetCounters() { | 48 void FakeScopedUIResource::ResetCounters() { |
44 resource_create_count = 0; | 49 resource_create_count = 0; |
45 lost_resource_count = 0; | 50 lost_resource_count = 0; |
46 } | 51 } |
47 | 52 |
48 } // namespace cc | 53 } // namespace cc |
OLD | NEW |