OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "cc/test/fake_scoped_ui_resource.h" |
| 6 |
| 7 #include "cc/trees/layer_tree_host.h" |
| 8 |
| 9 namespace cc { |
| 10 |
| 11 scoped_refptr<FakeScopedUIResource> FakeScopedUIResource::Create() { |
| 12 return make_scoped_refptr(new FakeScopedUIResource()); |
| 13 } |
| 14 |
| 15 FakeScopedUIResource::FakeScopedUIResource() |
| 16 : ScopedUIResource(NULL, NULL), |
| 17 resource_create_count(0), |
| 18 lost_resource_count(0) { |
| 19 bitmap_ = UIResourceBitmap::Create( |
| 20 new uint8_t[1], UIResourceBitmap::RGBA8, gfx::Size(1, 1)); |
| 21 } |
| 22 |
| 23 scoped_refptr<UIResourceBitmap> FakeScopedUIResource::GetFakeBitmap( |
| 24 bool resource_lost) { |
| 25 resource_create_count++; |
| 26 if (resource_lost) |
| 27 lost_resource_count++; |
| 28 return bitmap_; |
| 29 } |
| 30 |
| 31 void FakeScopedUIResource::CreateResource(LayerTreeHost* host) { |
| 32 id_ = host->CreateUIResource( |
| 33 base::Bind(&FakeScopedUIResource::GetFakeBitmap, this)); |
| 34 } |
| 35 |
| 36 void FakeScopedUIResource::DeleteResource(LayerTreeHost* host) { |
| 37 if (host && id_) |
| 38 host->DeleteUIResource(id_); |
| 39 } |
| 40 |
| 41 void FakeScopedUIResource::ResetCounters() { |
| 42 resource_create_count = 0; |
| 43 lost_resource_count = 0; |
| 44 } |
| 45 |
| 46 } // namespace cc |
OLD | NEW |