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

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

Issue 23740010: Revert 223162 "Update the nine patch layer to use UI resources" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 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 | Annotate | Revision Log
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 "cc/trees/layer_tree_host.h" 7 #include "cc/trees/layer_tree_host.h"
8 8
9 namespace cc { 9 namespace cc {
10 10
11 namespace {
12
13 UIResourceBitmap CreateMockUIResourceBitmap() {
14 SkBitmap skbitmap;
15 skbitmap.setConfig(SkBitmap::kARGB_8888_Config, 1, 1);
16 skbitmap.allocPixels();
17 skbitmap.setImmutable();
18 return UIResourceBitmap(skbitmap);
19 }
20
21 } // anonymous namespace
22
23 scoped_ptr<FakeScopedUIResource> FakeScopedUIResource::Create( 11 scoped_ptr<FakeScopedUIResource> FakeScopedUIResource::Create(
24 LayerTreeHost* host) { 12 LayerTreeHost* host) {
25 return make_scoped_ptr(new FakeScopedUIResource(host)); 13 return make_scoped_ptr(new FakeScopedUIResource(host));
26 } 14 }
27 15
28 FakeScopedUIResource::FakeScopedUIResource(LayerTreeHost* host) 16 FakeScopedUIResource::FakeScopedUIResource(LayerTreeHost* host) {
29 : ScopedUIResource(host, CreateMockUIResourceBitmap()) {
30 // The constructor of ScopedUIResource already created a resource so we need
31 // to delete the created resource to wipe the state clean.
32 host_->DeleteUIResource(id_);
33 ResetCounters(); 17 ResetCounters();
18 bitmap_ = UIResourceBitmap::Create(
19 new uint8_t[1],
20 UIResourceBitmap::RGBA8,
21 UIResourceBitmap::CLAMP_TO_EDGE,
22 gfx::Size(1, 1));
23 host_ = host;
34 id_ = host_->CreateUIResource(this); 24 id_ = host_->CreateUIResource(this);
35 } 25 }
36 26
37 UIResourceBitmap FakeScopedUIResource::GetBitmap(UIResourceId uid, 27 scoped_refptr<UIResourceBitmap> FakeScopedUIResource::GetBitmap(
38 bool resource_lost) { 28 UIResourceId uid,
29 bool resource_lost) {
39 resource_create_count++; 30 resource_create_count++;
40 if (resource_lost) 31 if (resource_lost)
41 lost_resource_count++; 32 lost_resource_count++;
42 return ScopedUIResource::GetBitmap(uid, resource_lost); 33 return ScopedUIResource::GetBitmap(uid, resource_lost);
43 } 34 }
44 35
45 void FakeScopedUIResource::ResetCounters() { 36 void FakeScopedUIResource::ResetCounters() {
46 resource_create_count = 0; 37 resource_create_count = 0;
47 lost_resource_count = 0; 38 lost_resource_count = 0;
48 } 39 }
49 40
50 } // namespace cc 41 } // namespace cc
OLDNEW
« no previous file with comments | « trunk/src/cc/test/fake_scoped_ui_resource.h ('k') | trunk/src/cc/test/layer_tree_json_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698