summaryrefslogtreecommitdiffstats
path: root/cc/test/fake_scoped_ui_resource.cc
diff options
context:
space:
mode:
authorpowei@chromium.org <powei@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-12 06:18:19 +0000
committerpowei@chromium.org <powei@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-12 06:18:19 +0000
commit4d600d105c6f07a13a365bebc9d35025b563d966 (patch)
tree4e0ecb719e59e0a0dbfe0d01f157381a752246c1 /cc/test/fake_scoped_ui_resource.cc
parent5c13605d33248e0c6dcf89e06513bc05f015d5fb (diff)
downloadchromium_src-4d600d105c6f07a13a365bebc9d35025b563d966.zip
chromium_src-4d600d105c6f07a13a365bebc9d35025b563d966.tar.gz
chromium_src-4d600d105c6f07a13a365bebc9d35025b563d966.tar.bz2
Update the nine patch layer to use UI resources
The old nine-patch layer used priority resource manager for requesting textures. This patch updates the nine-patch layer to use the UI resource manager. this patch clarifies the semantics of the aperture in both image and layer The new semantics corresponds to existing logic on the android-side. Changes have been made to UIResourceBitmap to use SkPixelRef as ref-counted of the bitmap content. The android-side changes: https://gerrit-int.chromium.org/#/c/43103/ BUG=276482,276487 Review URL: https://chromiumcodereview.appspot.com/22870016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222732 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/test/fake_scoped_ui_resource.cc')
-rw-r--r--cc/test/fake_scoped_ui_resource.cc29
1 files changed, 19 insertions, 10 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++;