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

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 22870016: Update the nine patch layer to use UI resources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ccameron's fix for exisiting nine-patch uses 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
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 3052 matching lines...) Expand 10 before | Expand all | Expand 10 after
3063 TestLayerIsLargerThanViewport(); 3063 TestLayerIsLargerThanViewport();
3064 } 3064 }
3065 3065
3066 TEST_F(LayerTreeHostImplViewportCoveredTest, ViewportCoveredOverhangBitmap) { 3066 TEST_F(LayerTreeHostImplViewportCoveredTest, ViewportCoveredOverhangBitmap) {
3067 bool always_draw = false; 3067 bool always_draw = false;
3068 CreateLayerTreeHostImpl(always_draw); 3068 CreateLayerTreeHostImpl(always_draw);
3069 3069
3070 host_impl_->SetViewportSize(DipSizeToPixelSize(viewport_size_)); 3070 host_impl_->SetViewportSize(DipSizeToPixelSize(viewport_size_));
3071 SetupActiveTreeLayers(); 3071 SetupActiveTreeLayers();
3072 3072
3073 SkBitmap skbitmap;
3074 skbitmap.setConfig(SkBitmap::kARGB_8888_Config, 2, 2);
3075 skbitmap.allocPixels();
3076 skbitmap.setImmutable();
3077
3073 // Specify an overhang bitmap to use. 3078 // Specify an overhang bitmap to use.
3074 scoped_refptr<UIResourceBitmap> ui_resource_bitmap(UIResourceBitmap::Create( 3079 UIResourceBitmap ui_resource_bitmap(skbitmap, UIResourceBitmap::REPEAT);
3075 new uint8_t[4],
3076 UIResourceBitmap::RGBA8,
3077 UIResourceBitmap::REPEAT,
3078 gfx::Size(1, 1)));
3079 UIResourceId ui_resource_id = 12345; 3080 UIResourceId ui_resource_id = 12345;
3080 host_impl_->CreateUIResource(ui_resource_id, ui_resource_bitmap); 3081 host_impl_->CreateUIResource(ui_resource_id, ui_resource_bitmap);
3081 host_impl_->SetOverhangUIResource(ui_resource_id, gfx::Size(32, 32)); 3082 host_impl_->SetOverhangUIResource(ui_resource_id, gfx::Size(32, 32));
3082 set_gutter_quad_material(DrawQuad::TEXTURE_CONTENT); 3083 set_gutter_quad_material(DrawQuad::TEXTURE_CONTENT);
3083 set_gutter_texture_size(gfx::Size(32, 32)); 3084 set_gutter_texture_size(gfx::Size(32, 32));
3084 3085
3085 TestLayerCoversFullViewport(); 3086 TestLayerCoversFullViewport();
3086 TestEmptyLayer(); 3087 TestEmptyLayer();
3087 TestLayerInMiddleOfViewport(); 3088 TestLayerInMiddleOfViewport();
3088 TestLayerIsLargerThanViewport(); 3089 TestLayerIsLargerThanViewport();
(...skipping 3445 matching lines...) Expand 10 before | Expand all | Expand 10 after
6534 6535
6535 TEST_F(LayerTreeHostImplTest, UIResourceManagement) { 6536 TEST_F(LayerTreeHostImplTest, UIResourceManagement) {
6536 scoped_ptr<TestWebGraphicsContext3D> context = 6537 scoped_ptr<TestWebGraphicsContext3D> context =
6537 TestWebGraphicsContext3D::Create(); 6538 TestWebGraphicsContext3D::Create();
6538 TestWebGraphicsContext3D* context3d = context.get(); 6539 TestWebGraphicsContext3D* context3d = context.get();
6539 scoped_ptr<OutputSurface> output_surface = CreateFakeOutputSurface(); 6540 scoped_ptr<OutputSurface> output_surface = CreateFakeOutputSurface();
6540 host_impl_->InitializeRenderer(output_surface.Pass()); 6541 host_impl_->InitializeRenderer(output_surface.Pass());
6541 6542
6542 EXPECT_EQ(0u, context3d->NumTextures()); 6543 EXPECT_EQ(0u, context3d->NumTextures());
6543 6544
6545 SkBitmap skbitmap;
6546 skbitmap.setConfig(SkBitmap::kARGB_8888_Config, 1, 1);
6547 skbitmap.allocPixels();
6548 skbitmap.setImmutable();
6549
6544 UIResourceId ui_resource_id = 1; 6550 UIResourceId ui_resource_id = 1;
6545 scoped_refptr<UIResourceBitmap> bitmap = UIResourceBitmap::Create( 6551 UIResourceBitmap bitmap(skbitmap);
6546 new uint8_t[1],
6547 UIResourceBitmap::RGBA8,
6548 UIResourceBitmap::CLAMP_TO_EDGE,
6549 gfx::Size(1, 1));
6550 host_impl_->CreateUIResource(ui_resource_id, bitmap); 6552 host_impl_->CreateUIResource(ui_resource_id, bitmap);
6551 EXPECT_EQ(1u, context3d->NumTextures()); 6553 EXPECT_EQ(1u, context3d->NumTextures());
6552 ResourceProvider::ResourceId id1 = 6554 ResourceProvider::ResourceId id1 =
6553 host_impl_->ResourceIdForUIResource(ui_resource_id); 6555 host_impl_->ResourceIdForUIResource(ui_resource_id);
6554 EXPECT_NE(0u, id1); 6556 EXPECT_NE(0u, id1);
6555 6557
6556 // Multiple requests with the same id is allowed. The previous texture is 6558 // Multiple requests with the same id is allowed. The previous texture is
6557 // deleted. 6559 // deleted.
6558 host_impl_->CreateUIResource(ui_resource_id, bitmap); 6560 host_impl_->CreateUIResource(ui_resource_id, bitmap);
6559 EXPECT_EQ(1u, context3d->NumTextures()); 6561 EXPECT_EQ(1u, context3d->NumTextures());
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
6616 host_impl_.reset(); 6618 host_impl_.reset();
6617 6619
6618 // The CopyOutputResult's callback was cancelled, the CopyOutputResult 6620 // The CopyOutputResult's callback was cancelled, the CopyOutputResult
6619 // released, and the texture deleted. 6621 // released, and the texture deleted.
6620 EXPECT_TRUE(context_provider->HasOneRef()); 6622 EXPECT_TRUE(context_provider->HasOneRef());
6621 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); 6623 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures());
6622 } 6624 }
6623 6625
6624 } // namespace 6626 } // namespace
6625 } // namespace cc 6627 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698