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

Side by Side Diff: trunk/src/cc/trees/layer_tree_host_impl_unittest.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
« no previous file with comments | « trunk/src/cc/trees/layer_tree_host_impl.cc ('k') | trunk/src/cc/trees/layer_tree_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
3078 // Specify an overhang bitmap to use. 3073 // Specify an overhang bitmap to use.
3079 UIResourceBitmap ui_resource_bitmap(skbitmap, UIResourceBitmap::REPEAT); 3074 scoped_refptr<UIResourceBitmap> ui_resource_bitmap(UIResourceBitmap::Create(
3075 new uint8_t[4],
3076 UIResourceBitmap::RGBA8,
3077 UIResourceBitmap::REPEAT,
3078 gfx::Size(1, 1)));
3080 UIResourceId ui_resource_id = 12345; 3079 UIResourceId ui_resource_id = 12345;
3081 host_impl_->CreateUIResource(ui_resource_id, ui_resource_bitmap); 3080 host_impl_->CreateUIResource(ui_resource_id, ui_resource_bitmap);
3082 host_impl_->SetOverhangUIResource(ui_resource_id, gfx::Size(32, 32)); 3081 host_impl_->SetOverhangUIResource(ui_resource_id, gfx::Size(32, 32));
3083 set_gutter_quad_material(DrawQuad::TEXTURE_CONTENT); 3082 set_gutter_quad_material(DrawQuad::TEXTURE_CONTENT);
3084 set_gutter_texture_size(gfx::Size(32, 32)); 3083 set_gutter_texture_size(gfx::Size(32, 32));
3085 3084
3086 TestLayerCoversFullViewport(); 3085 TestLayerCoversFullViewport();
3087 TestEmptyLayer(); 3086 TestEmptyLayer();
3088 TestLayerInMiddleOfViewport(); 3087 TestLayerInMiddleOfViewport();
3089 TestLayerIsLargerThanViewport(); 3088 TestLayerIsLargerThanViewport();
(...skipping 3445 matching lines...) Expand 10 before | Expand all | Expand 10 after
6535 6534
6536 TEST_F(LayerTreeHostImplTest, UIResourceManagement) { 6535 TEST_F(LayerTreeHostImplTest, UIResourceManagement) {
6537 scoped_ptr<TestWebGraphicsContext3D> context = 6536 scoped_ptr<TestWebGraphicsContext3D> context =
6538 TestWebGraphicsContext3D::Create(); 6537 TestWebGraphicsContext3D::Create();
6539 TestWebGraphicsContext3D* context3d = context.get(); 6538 TestWebGraphicsContext3D* context3d = context.get();
6540 scoped_ptr<OutputSurface> output_surface = CreateFakeOutputSurface(); 6539 scoped_ptr<OutputSurface> output_surface = CreateFakeOutputSurface();
6541 host_impl_->InitializeRenderer(output_surface.Pass()); 6540 host_impl_->InitializeRenderer(output_surface.Pass());
6542 6541
6543 EXPECT_EQ(0u, context3d->NumTextures()); 6542 EXPECT_EQ(0u, context3d->NumTextures());
6544 6543
6545 SkBitmap skbitmap;
6546 skbitmap.setConfig(SkBitmap::kARGB_8888_Config, 1, 1);
6547 skbitmap.allocPixels();
6548 skbitmap.setImmutable();
6549
6550 UIResourceId ui_resource_id = 1; 6544 UIResourceId ui_resource_id = 1;
6551 UIResourceBitmap bitmap(skbitmap); 6545 scoped_refptr<UIResourceBitmap> bitmap = UIResourceBitmap::Create(
6546 new uint8_t[1],
6547 UIResourceBitmap::RGBA8,
6548 UIResourceBitmap::CLAMP_TO_EDGE,
6549 gfx::Size(1, 1));
6552 host_impl_->CreateUIResource(ui_resource_id, bitmap); 6550 host_impl_->CreateUIResource(ui_resource_id, bitmap);
6553 EXPECT_EQ(1u, context3d->NumTextures()); 6551 EXPECT_EQ(1u, context3d->NumTextures());
6554 ResourceProvider::ResourceId id1 = 6552 ResourceProvider::ResourceId id1 =
6555 host_impl_->ResourceIdForUIResource(ui_resource_id); 6553 host_impl_->ResourceIdForUIResource(ui_resource_id);
6556 EXPECT_NE(0u, id1); 6554 EXPECT_NE(0u, id1);
6557 6555
6558 // Multiple requests with the same id is allowed. The previous texture is 6556 // Multiple requests with the same id is allowed. The previous texture is
6559 // deleted. 6557 // deleted.
6560 host_impl_->CreateUIResource(ui_resource_id, bitmap); 6558 host_impl_->CreateUIResource(ui_resource_id, bitmap);
6561 EXPECT_EQ(1u, context3d->NumTextures()); 6559 EXPECT_EQ(1u, context3d->NumTextures());
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
6618 host_impl_.reset(); 6616 host_impl_.reset();
6619 6617
6620 // The CopyOutputResult's callback was cancelled, the CopyOutputResult 6618 // The CopyOutputResult's callback was cancelled, the CopyOutputResult
6621 // released, and the texture deleted. 6619 // released, and the texture deleted.
6622 EXPECT_TRUE(context_provider->HasOneRef()); 6620 EXPECT_TRUE(context_provider->HasOneRef());
6623 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); 6621 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures());
6624 } 6622 }
6625 6623
6626 } // namespace 6624 } // namespace
6627 } // namespace cc 6625 } // namespace cc
OLDNEW
« no previous file with comments | « trunk/src/cc/trees/layer_tree_host_impl.cc ('k') | trunk/src/cc/trees/layer_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698