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: 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: updated dchecks in ui_resource_bitmap 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 3050 matching lines...) Expand 10 before | Expand all | Expand 10 after
3061 TestLayerIsLargerThanViewport(); 3061 TestLayerIsLargerThanViewport();
3062 } 3062 }
3063 3063
3064 TEST_F(LayerTreeHostImplViewportCoveredTest, ViewportCoveredOverhangBitmap) { 3064 TEST_F(LayerTreeHostImplViewportCoveredTest, ViewportCoveredOverhangBitmap) {
3065 bool always_draw = false; 3065 bool always_draw = false;
3066 CreateLayerTreeHostImpl(always_draw); 3066 CreateLayerTreeHostImpl(always_draw);
3067 3067
3068 host_impl_->SetViewportSize(DipSizeToPixelSize(viewport_size_)); 3068 host_impl_->SetViewportSize(DipSizeToPixelSize(viewport_size_));
3069 SetupActiveTreeLayers(); 3069 SetupActiveTreeLayers();
3070 3070
3071 SkBitmap skbitmap;
3072 skbitmap.setConfig(SkBitmap::kARGB_8888_Config, 2, 2);
3073 skbitmap.allocPixels();
3074 skbitmap.setImmutable();
3075
3071 // Specify an overhang bitmap to use. 3076 // Specify an overhang bitmap to use.
3072 scoped_refptr<UIResourceBitmap> ui_resource_bitmap(UIResourceBitmap::Create( 3077 UIResourceBitmap ui_resource_bitmap(skbitmap, UIResourceBitmap::REPEAT);
3073 new uint8_t[4],
3074 UIResourceBitmap::RGBA8,
3075 UIResourceBitmap::REPEAT,
3076 gfx::Size(1, 1)));
3077 UIResourceId ui_resource_id = 12345; 3078 UIResourceId ui_resource_id = 12345;
3078 host_impl_->CreateUIResource(ui_resource_id, ui_resource_bitmap); 3079 host_impl_->CreateUIResource(ui_resource_id, ui_resource_bitmap);
3079 host_impl_->SetOverhangUIResource(ui_resource_id, gfx::Size(32, 32)); 3080 host_impl_->SetOverhangUIResource(ui_resource_id, gfx::Size(32, 32));
3080 set_gutter_quad_material(DrawQuad::TEXTURE_CONTENT); 3081 set_gutter_quad_material(DrawQuad::TEXTURE_CONTENT);
3081 set_gutter_texture_size(gfx::Size(32, 32)); 3082 set_gutter_texture_size(gfx::Size(32, 32));
3082 3083
3083 TestLayerCoversFullViewport(); 3084 TestLayerCoversFullViewport();
3084 TestEmptyLayer(); 3085 TestEmptyLayer();
3085 TestLayerInMiddleOfViewport(); 3086 TestLayerInMiddleOfViewport();
3086 TestLayerIsLargerThanViewport(); 3087 TestLayerIsLargerThanViewport();
(...skipping 3457 matching lines...) Expand 10 before | Expand all | Expand 10 after
6544 6545
6545 TEST_F(LayerTreeHostImplTest, UIResourceManagement) { 6546 TEST_F(LayerTreeHostImplTest, UIResourceManagement) {
6546 scoped_ptr<TestWebGraphicsContext3D> context = 6547 scoped_ptr<TestWebGraphicsContext3D> context =
6547 TestWebGraphicsContext3D::Create(); 6548 TestWebGraphicsContext3D::Create();
6548 TestWebGraphicsContext3D* context3d = context.get(); 6549 TestWebGraphicsContext3D* context3d = context.get();
6549 scoped_ptr<OutputSurface> output_surface = CreateFakeOutputSurface(); 6550 scoped_ptr<OutputSurface> output_surface = CreateFakeOutputSurface();
6550 host_impl_->InitializeRenderer(output_surface.Pass()); 6551 host_impl_->InitializeRenderer(output_surface.Pass());
6551 6552
6552 EXPECT_EQ(0u, context3d->NumTextures()); 6553 EXPECT_EQ(0u, context3d->NumTextures());
6553 6554
6555 SkBitmap skbitmap;
6556 skbitmap.setConfig(SkBitmap::kARGB_8888_Config, 1, 1);
6557 skbitmap.allocPixels();
6558 skbitmap.setImmutable();
6559
6554 UIResourceId ui_resource_id = 1; 6560 UIResourceId ui_resource_id = 1;
6555 scoped_refptr<UIResourceBitmap> bitmap = UIResourceBitmap::Create( 6561 UIResourceBitmap bitmap(skbitmap);
6556 new uint8_t[1],
6557 UIResourceBitmap::RGBA8,
6558 UIResourceBitmap::CLAMP_TO_EDGE,
6559 gfx::Size(1, 1));
6560 host_impl_->CreateUIResource(ui_resource_id, bitmap); 6562 host_impl_->CreateUIResource(ui_resource_id, bitmap);
6561 EXPECT_EQ(1u, context3d->NumTextures()); 6563 EXPECT_EQ(1u, context3d->NumTextures());
6562 ResourceProvider::ResourceId id1 = 6564 ResourceProvider::ResourceId id1 =
6563 host_impl_->ResourceIdForUIResource(ui_resource_id); 6565 host_impl_->ResourceIdForUIResource(ui_resource_id);
6564 EXPECT_NE(0u, id1); 6566 EXPECT_NE(0u, id1);
6565 6567
6566 // Multiple requests with the same id is allowed. The previous texture is 6568 // Multiple requests with the same id is allowed. The previous texture is
6567 // deleted. 6569 // deleted.
6568 host_impl_->CreateUIResource(ui_resource_id, bitmap); 6570 host_impl_->CreateUIResource(ui_resource_id, bitmap);
6569 EXPECT_EQ(1u, context3d->NumTextures()); 6571 EXPECT_EQ(1u, context3d->NumTextures());
(...skipping 15 matching lines...) Expand all
6585 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id)); 6587 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id));
6586 EXPECT_EQ(0u, context3d->NumTextures()); 6588 EXPECT_EQ(0u, context3d->NumTextures());
6587 6589
6588 // Should not change state for multiple deletion on one UIResourceId 6590 // Should not change state for multiple deletion on one UIResourceId
6589 host_impl_->DeleteUIResource(ui_resource_id); 6591 host_impl_->DeleteUIResource(ui_resource_id);
6590 EXPECT_EQ(0u, context3d->NumTextures()); 6592 EXPECT_EQ(0u, context3d->NumTextures());
6591 } 6593 }
6592 6594
6593 } // namespace 6595 } // namespace
6594 } // namespace cc 6596 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698