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 2975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2986 } | 2986 } |
2987 return num_gutter_quads; | 2987 return num_gutter_quads; |
2988 } | 2988 } |
2989 | 2989 |
2990 // Make sure that the texture coordinates match their expectations. | 2990 // Make sure that the texture coordinates match their expectations. |
2991 void ValidateTextureDrawQuads(const QuadList& quad_list) { | 2991 void ValidateTextureDrawQuads(const QuadList& quad_list) { |
2992 for (size_t i = 0; i < quad_list.size(); ++i) { | 2992 for (size_t i = 0; i < quad_list.size(); ++i) { |
2993 if (quad_list[i]->material == DrawQuad::TEXTURE_CONTENT) { | 2993 if (quad_list[i]->material == DrawQuad::TEXTURE_CONTENT) { |
2994 TextureDrawQuad* quad = reinterpret_cast<TextureDrawQuad*>( | 2994 TextureDrawQuad* quad = reinterpret_cast<TextureDrawQuad*>( |
2995 quad_list[i]); | 2995 quad_list[i]); |
2996 EXPECT_EQ(quad->uv_top_left.x(), | 2996 EXPECT_EQ(quad->rect.x() / |
2997 quad->rect.x() / | 2997 static_cast<float>(gutter_texture_size_.width()), |
2998 static_cast<float>(gutter_texture_size_.width())); | 2998 quad->uv_top_left.x()); |
2999 EXPECT_EQ(quad->uv_top_left.y(), | 2999 EXPECT_EQ(quad->rect.y() / |
3000 quad->rect.y() / | 3000 static_cast<float>(gutter_texture_size_.height()), |
3001 static_cast<float>(gutter_texture_size_.height())); | 3001 quad->uv_top_left.y()); |
3002 EXPECT_EQ(quad->uv_bottom_right.x(), | 3002 EXPECT_EQ((quad->rect.x() + quad->rect.width()) / |
3003 (quad->rect.x() + quad->rect.width()) / | 3003 static_cast<float>(gutter_texture_size_.width()), |
3004 static_cast<float>(gutter_texture_size_.width())); | 3004 quad->uv_bottom_right.x()); |
3005 EXPECT_EQ(quad->uv_bottom_right.y(), | 3005 EXPECT_EQ((quad->rect.y() + quad->rect.height()) / |
3006 (quad->rect.y() + quad->rect.height()) / | 3006 static_cast<float>(gutter_texture_size_.height()), |
3007 static_cast<float>(gutter_texture_size_.height())); | 3007 quad->uv_bottom_right.y()); |
| 3008 EXPECT_EQ(GL_REPEAT, |
| 3009 host_impl_->resource_provider()->WrapModeForTesting( |
| 3010 quad->resource_id)); |
3008 } | 3011 } |
3009 } | 3012 } |
3010 } | 3013 } |
3011 | 3014 |
3012 DrawQuad::Material gutter_quad_material_; | 3015 DrawQuad::Material gutter_quad_material_; |
3013 gfx::Size gutter_texture_size_; | 3016 gfx::Size gutter_texture_size_; |
3014 gfx::Size viewport_size_; | 3017 gfx::Size viewport_size_; |
3015 BlendStateCheckLayer* child_; | 3018 BlendStateCheckLayer* child_; |
3016 bool did_activate_pending_tree_; | 3019 bool did_activate_pending_tree_; |
3017 }; | 3020 }; |
(...skipping 12 matching lines...) Expand all Loading... |
3030 | 3033 |
3031 TEST_F(LayerTreeHostImplViewportCoveredTest, ViewportCoveredOverhangBitmap) { | 3034 TEST_F(LayerTreeHostImplViewportCoveredTest, ViewportCoveredOverhangBitmap) { |
3032 bool always_draw = false; | 3035 bool always_draw = false; |
3033 CreateLayerTreeHostImpl(always_draw); | 3036 CreateLayerTreeHostImpl(always_draw); |
3034 | 3037 |
3035 host_impl_->SetViewportSize(viewport_size_); | 3038 host_impl_->SetViewportSize(viewport_size_); |
3036 SetupActiveTreeLayers(); | 3039 SetupActiveTreeLayers(); |
3037 | 3040 |
3038 // Specify an overhang bitmap to use. | 3041 // Specify an overhang bitmap to use. |
3039 scoped_refptr<UIResourceBitmap> ui_resource_bitmap(UIResourceBitmap::Create( | 3042 scoped_refptr<UIResourceBitmap> ui_resource_bitmap(UIResourceBitmap::Create( |
3040 new uint8_t[4], UIResourceBitmap::RGBA8, gfx::Size(1, 1))); | 3043 new uint8_t[4], |
| 3044 UIResourceBitmap::RGBA8, |
| 3045 UIResourceBitmap::REPEAT, |
| 3046 gfx::Size(1, 1))); |
3041 UIResourceId ui_resource_id = 12345; | 3047 UIResourceId ui_resource_id = 12345; |
3042 host_impl_->CreateUIResource(ui_resource_id, ui_resource_bitmap); | 3048 host_impl_->CreateUIResource(ui_resource_id, ui_resource_bitmap); |
3043 host_impl_->SetOverhangUIResource(ui_resource_id, gfx::Size(32, 32)); | 3049 host_impl_->SetOverhangUIResource(ui_resource_id, gfx::Size(32, 32)); |
3044 set_gutter_quad_material(DrawQuad::TEXTURE_CONTENT); | 3050 set_gutter_quad_material(DrawQuad::TEXTURE_CONTENT); |
3045 set_gutter_texture_size(gfx::Size(32, 32)); | 3051 set_gutter_texture_size(gfx::Size(32, 32)); |
3046 | 3052 |
3047 TestLayerCoversFullViewport(); | 3053 TestLayerCoversFullViewport(); |
3048 TestEmptyLayer(); | 3054 TestEmptyLayer(); |
3049 TestLayerInMiddleOfViewport(); | 3055 TestLayerInMiddleOfViewport(); |
3050 TestLayerIsLargerThanViewport(); | 3056 TestLayerIsLargerThanViewport(); |
(...skipping 3352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6403 scoped_ptr<TestWebGraphicsContext3D> context = | 6409 scoped_ptr<TestWebGraphicsContext3D> context = |
6404 TestWebGraphicsContext3D::Create(); | 6410 TestWebGraphicsContext3D::Create(); |
6405 TestWebGraphicsContext3D* context3d = context.get(); | 6411 TestWebGraphicsContext3D* context3d = context.get(); |
6406 scoped_ptr<OutputSurface> output_surface = CreateFakeOutputSurface(); | 6412 scoped_ptr<OutputSurface> output_surface = CreateFakeOutputSurface(); |
6407 host_impl_->InitializeRenderer(output_surface.Pass()); | 6413 host_impl_->InitializeRenderer(output_surface.Pass()); |
6408 | 6414 |
6409 EXPECT_EQ(0u, context3d->NumTextures()); | 6415 EXPECT_EQ(0u, context3d->NumTextures()); |
6410 | 6416 |
6411 UIResourceId ui_resource_id = 1; | 6417 UIResourceId ui_resource_id = 1; |
6412 scoped_refptr<UIResourceBitmap> bitmap = UIResourceBitmap::Create( | 6418 scoped_refptr<UIResourceBitmap> bitmap = UIResourceBitmap::Create( |
6413 new uint8_t[1], UIResourceBitmap::RGBA8, gfx::Size(1, 1)); | 6419 new uint8_t[1], |
| 6420 UIResourceBitmap::RGBA8, |
| 6421 UIResourceBitmap::CLAMP_TO_EDGE, |
| 6422 gfx::Size(1, 1)); |
6414 host_impl_->CreateUIResource(ui_resource_id, bitmap); | 6423 host_impl_->CreateUIResource(ui_resource_id, bitmap); |
6415 EXPECT_EQ(1u, context3d->NumTextures()); | 6424 EXPECT_EQ(1u, context3d->NumTextures()); |
6416 ResourceProvider::ResourceId id1 = | 6425 ResourceProvider::ResourceId id1 = |
6417 host_impl_->ResourceIdForUIResource(ui_resource_id); | 6426 host_impl_->ResourceIdForUIResource(ui_resource_id); |
6418 EXPECT_NE(0u, id1); | 6427 EXPECT_NE(0u, id1); |
6419 | 6428 |
6420 // Multiple requests with the same id is allowed. The previous texture is | 6429 // Multiple requests with the same id is allowed. The previous texture is |
6421 // deleted. | 6430 // deleted. |
6422 host_impl_->CreateUIResource(ui_resource_id, bitmap); | 6431 host_impl_->CreateUIResource(ui_resource_id, bitmap); |
6423 EXPECT_EQ(1u, context3d->NumTextures()); | 6432 EXPECT_EQ(1u, context3d->NumTextures()); |
(...skipping 15 matching lines...) Expand all Loading... |
6439 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id)); | 6448 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id)); |
6440 EXPECT_EQ(0u, context3d->NumTextures()); | 6449 EXPECT_EQ(0u, context3d->NumTextures()); |
6441 | 6450 |
6442 // Should not change state for multiple deletion on one UIResourceId | 6451 // Should not change state for multiple deletion on one UIResourceId |
6443 host_impl_->DeleteUIResource(ui_resource_id); | 6452 host_impl_->DeleteUIResource(ui_resource_id); |
6444 EXPECT_EQ(0u, context3d->NumTextures()); | 6453 EXPECT_EQ(0u, context3d->NumTextures()); |
6445 } | 6454 } |
6446 | 6455 |
6447 } // namespace | 6456 } // namespace |
6448 } // namespace cc | 6457 } // namespace cc |
OLD | NEW |