| OLD | NEW |
| 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 3057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3068 TestLayerIsLargerThanViewport(); | 3068 TestLayerIsLargerThanViewport(); |
| 3069 } | 3069 } |
| 3070 | 3070 |
| 3071 TEST_F(LayerTreeHostImplViewportCoveredTest, ViewportCoveredOverhangBitmap) { | 3071 TEST_F(LayerTreeHostImplViewportCoveredTest, ViewportCoveredOverhangBitmap) { |
| 3072 bool always_draw = false; | 3072 bool always_draw = false; |
| 3073 CreateLayerTreeHostImpl(always_draw); | 3073 CreateLayerTreeHostImpl(always_draw); |
| 3074 | 3074 |
| 3075 host_impl_->SetViewportSize(DipSizeToPixelSize(viewport_size_)); | 3075 host_impl_->SetViewportSize(DipSizeToPixelSize(viewport_size_)); |
| 3076 SetupActiveTreeLayers(); | 3076 SetupActiveTreeLayers(); |
| 3077 | 3077 |
| 3078 SkBitmap skbitmap; |
| 3079 skbitmap.setConfig(SkBitmap::kARGB_8888_Config, 2, 2); |
| 3080 skbitmap.allocPixels(); |
| 3081 skbitmap.setImmutable(); |
| 3082 |
| 3078 // Specify an overhang bitmap to use. | 3083 // Specify an overhang bitmap to use. |
| 3079 scoped_refptr<UIResourceBitmap> ui_resource_bitmap(UIResourceBitmap::Create( | 3084 UIResourceBitmap ui_resource_bitmap(skbitmap, UIResourceBitmap::REPEAT); |
| 3080 new uint8_t[4], | |
| 3081 UIResourceBitmap::RGBA8, | |
| 3082 UIResourceBitmap::REPEAT, | |
| 3083 gfx::Size(1, 1))); | |
| 3084 UIResourceId ui_resource_id = 12345; | 3085 UIResourceId ui_resource_id = 12345; |
| 3085 host_impl_->CreateUIResource(ui_resource_id, ui_resource_bitmap); | 3086 host_impl_->CreateUIResource(ui_resource_id, ui_resource_bitmap); |
| 3086 host_impl_->SetOverhangUIResource(ui_resource_id, gfx::Size(32, 32)); | 3087 host_impl_->SetOverhangUIResource(ui_resource_id, gfx::Size(32, 32)); |
| 3087 set_gutter_quad_material(DrawQuad::TEXTURE_CONTENT); | 3088 set_gutter_quad_material(DrawQuad::TEXTURE_CONTENT); |
| 3088 set_gutter_texture_size(gfx::Size(32, 32)); | 3089 set_gutter_texture_size(gfx::Size(32, 32)); |
| 3089 | 3090 |
| 3090 TestLayerCoversFullViewport(); | 3091 TestLayerCoversFullViewport(); |
| 3091 TestEmptyLayer(); | 3092 TestEmptyLayer(); |
| 3092 TestLayerInMiddleOfViewport(); | 3093 TestLayerInMiddleOfViewport(); |
| 3093 TestLayerIsLargerThanViewport(); | 3094 TestLayerIsLargerThanViewport(); |
| (...skipping 3446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6540 | 6541 |
| 6541 TEST_F(LayerTreeHostImplTest, UIResourceManagement) { | 6542 TEST_F(LayerTreeHostImplTest, UIResourceManagement) { |
| 6542 scoped_ptr<TestWebGraphicsContext3D> context = | 6543 scoped_ptr<TestWebGraphicsContext3D> context = |
| 6543 TestWebGraphicsContext3D::Create(); | 6544 TestWebGraphicsContext3D::Create(); |
| 6544 TestWebGraphicsContext3D* context3d = context.get(); | 6545 TestWebGraphicsContext3D* context3d = context.get(); |
| 6545 scoped_ptr<OutputSurface> output_surface = CreateFakeOutputSurface(); | 6546 scoped_ptr<OutputSurface> output_surface = CreateFakeOutputSurface(); |
| 6546 host_impl_->InitializeRenderer(output_surface.Pass()); | 6547 host_impl_->InitializeRenderer(output_surface.Pass()); |
| 6547 | 6548 |
| 6548 EXPECT_EQ(0u, context3d->NumTextures()); | 6549 EXPECT_EQ(0u, context3d->NumTextures()); |
| 6549 | 6550 |
| 6551 SkBitmap skbitmap; |
| 6552 skbitmap.setConfig(SkBitmap::kARGB_8888_Config, 1, 1); |
| 6553 skbitmap.allocPixels(); |
| 6554 skbitmap.setImmutable(); |
| 6555 |
| 6550 UIResourceId ui_resource_id = 1; | 6556 UIResourceId ui_resource_id = 1; |
| 6551 scoped_refptr<UIResourceBitmap> bitmap = UIResourceBitmap::Create( | 6557 UIResourceBitmap bitmap(skbitmap); |
| 6552 new uint8_t[1], | |
| 6553 UIResourceBitmap::RGBA8, | |
| 6554 UIResourceBitmap::CLAMP_TO_EDGE, | |
| 6555 gfx::Size(1, 1)); | |
| 6556 host_impl_->CreateUIResource(ui_resource_id, bitmap); | 6558 host_impl_->CreateUIResource(ui_resource_id, bitmap); |
| 6557 EXPECT_EQ(1u, context3d->NumTextures()); | 6559 EXPECT_EQ(1u, context3d->NumTextures()); |
| 6558 ResourceProvider::ResourceId id1 = | 6560 ResourceProvider::ResourceId id1 = |
| 6559 host_impl_->ResourceIdForUIResource(ui_resource_id); | 6561 host_impl_->ResourceIdForUIResource(ui_resource_id); |
| 6560 EXPECT_NE(0u, id1); | 6562 EXPECT_NE(0u, id1); |
| 6561 | 6563 |
| 6562 // Multiple requests with the same id is allowed. The previous texture is | 6564 // Multiple requests with the same id is allowed. The previous texture is |
| 6563 // deleted. | 6565 // deleted. |
| 6564 host_impl_->CreateUIResource(ui_resource_id, bitmap); | 6566 host_impl_->CreateUIResource(ui_resource_id, bitmap); |
| 6565 EXPECT_EQ(1u, context3d->NumTextures()); | 6567 EXPECT_EQ(1u, context3d->NumTextures()); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6622 host_impl_.reset(); | 6624 host_impl_.reset(); |
| 6623 | 6625 |
| 6624 // The CopyOutputResult's callback was cancelled, the CopyOutputResult | 6626 // The CopyOutputResult's callback was cancelled, the CopyOutputResult |
| 6625 // released, and the texture deleted. | 6627 // released, and the texture deleted. |
| 6626 EXPECT_TRUE(context_provider->HasOneRef()); | 6628 EXPECT_TRUE(context_provider->HasOneRef()); |
| 6627 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); | 6629 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); |
| 6628 } | 6630 } |
| 6629 | 6631 |
| 6630 } // namespace | 6632 } // namespace |
| 6631 } // namespace cc | 6633 } // namespace cc |
| OLD | NEW |