diff options
Diffstat (limited to 'cc/test')
-rw-r--r-- | cc/test/fake_scoped_ui_resource.cc | 29 | ||||
-rw-r--r-- | cc/test/fake_scoped_ui_resource.h | 5 |
2 files changed, 21 insertions, 13 deletions
diff --git a/cc/test/fake_scoped_ui_resource.cc b/cc/test/fake_scoped_ui_resource.cc index ce5ee11..bf86f54 100644 --- a/cc/test/fake_scoped_ui_resource.cc +++ b/cc/test/fake_scoped_ui_resource.cc @@ -8,25 +8,34 @@ namespace cc { +namespace { + +UIResourceBitmap CreateMockUIResourceBitmap() { + SkBitmap skbitmap; + skbitmap.setConfig(SkBitmap::kARGB_8888_Config, 1, 1); + skbitmap.allocPixels(); + skbitmap.setImmutable(); + return UIResourceBitmap(skbitmap); +} + +} // anonymous namespace + scoped_ptr<FakeScopedUIResource> FakeScopedUIResource::Create( LayerTreeHost* host) { return make_scoped_ptr(new FakeScopedUIResource(host)); } -FakeScopedUIResource::FakeScopedUIResource(LayerTreeHost* host) { +FakeScopedUIResource::FakeScopedUIResource(LayerTreeHost* host) + : ScopedUIResource(host, CreateMockUIResourceBitmap()) { + // The constructor of ScopedUIResource already created a resource so we need + // to delete the created resource to wipe the state clean. + host_->DeleteUIResource(id_); ResetCounters(); - bitmap_ = UIResourceBitmap::Create( - new uint8_t[1], - UIResourceBitmap::RGBA8, - UIResourceBitmap::CLAMP_TO_EDGE, - gfx::Size(1, 1)); - host_ = host; id_ = host_->CreateUIResource(this); } -scoped_refptr<UIResourceBitmap> FakeScopedUIResource::GetBitmap( - UIResourceId uid, - bool resource_lost) { +UIResourceBitmap FakeScopedUIResource::GetBitmap(UIResourceId uid, + bool resource_lost) { resource_create_count++; if (resource_lost) lost_resource_count++; diff --git a/cc/test/fake_scoped_ui_resource.h b/cc/test/fake_scoped_ui_resource.h index 84c097f..970d7b0 100644 --- a/cc/test/fake_scoped_ui_resource.h +++ b/cc/test/fake_scoped_ui_resource.h @@ -16,9 +16,8 @@ class FakeScopedUIResource : public ScopedUIResource { public: static scoped_ptr<FakeScopedUIResource> Create(LayerTreeHost* host); - virtual scoped_refptr<UIResourceBitmap> GetBitmap( - UIResourceId uid, - bool resource_lost) OVERRIDE; + virtual UIResourceBitmap GetBitmap(UIResourceId uid, + bool resource_lost) OVERRIDE; void ResetCounters(); int resource_create_count; |