| 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 1491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1502 scoped_ptr<LayerTilingData> tiling_data = | 1502 scoped_ptr<LayerTilingData> tiling_data = |
| 1503 LayerTilingData::Create(gfx::Size(10, 10), | 1503 LayerTilingData::Create(gfx::Size(10, 10), |
| 1504 LayerTilingData::NO_BORDER_TEXELS); | 1504 LayerTilingData::NO_BORDER_TEXELS); |
| 1505 tiling_data->SetBounds(bounds()); | 1505 tiling_data->SetBounds(bounds()); |
| 1506 SetTilingData(*tiling_data.get()); | 1506 SetTilingData(*tiling_data.get()); |
| 1507 set_skips_draw(skips_draw); | 1507 set_skips_draw(skips_draw); |
| 1508 if (!tile_missing) { | 1508 if (!tile_missing) { |
| 1509 ResourceProvider::ResourceId resource = | 1509 ResourceProvider::ResourceId resource = |
| 1510 resource_provider->CreateResource(gfx::Size(1, 1), | 1510 resource_provider->CreateResource(gfx::Size(1, 1), |
| 1511 GL_RGBA, | 1511 GL_RGBA, |
| 1512 GL_CLAMP_TO_EDGE, |
| 1512 ResourceProvider::TextureUsageAny); | 1513 ResourceProvider::TextureUsageAny); |
| 1513 resource_provider->AllocateForTesting(resource); | 1514 resource_provider->AllocateForTesting(resource); |
| 1514 PushTileProperties(0, 0, resource, gfx::Rect(), false); | 1515 PushTileProperties(0, 0, resource, gfx::Rect(), false); |
| 1515 } | 1516 } |
| 1516 if (animating) | 1517 if (animating) |
| 1517 AddAnimatedTransformToLayer(this, 10.0, 3, 0); | 1518 AddAnimatedTransformToLayer(this, 10.0, 3, 0); |
| 1518 } | 1519 } |
| 1519 }; | 1520 }; |
| 1520 | 1521 |
| 1521 TEST_F(LayerTreeHostImplTest, PrepareToDrawFailsWhenAnimationUsesCheckerboard) { | 1522 TEST_F(LayerTreeHostImplTest, PrepareToDrawFailsWhenAnimationUsesCheckerboard) { |
| (...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2593 ResourceProvider* resource_provider) | 2594 ResourceProvider* resource_provider) |
| 2594 : LayerImpl(tree_impl, id), | 2595 : LayerImpl(tree_impl, id), |
| 2595 blend_(false), | 2596 blend_(false), |
| 2596 has_render_surface_(false), | 2597 has_render_surface_(false), |
| 2597 quads_appended_(false), | 2598 quads_appended_(false), |
| 2598 quad_rect_(5, 5, 5, 5), | 2599 quad_rect_(5, 5, 5, 5), |
| 2599 quad_visible_rect_(5, 5, 5, 5), | 2600 quad_visible_rect_(5, 5, 5, 5), |
| 2600 resource_id_(resource_provider->CreateResource( | 2601 resource_id_(resource_provider->CreateResource( |
| 2601 gfx::Size(1, 1), | 2602 gfx::Size(1, 1), |
| 2602 GL_RGBA, | 2603 GL_RGBA, |
| 2604 GL_CLAMP_TO_EDGE, |
| 2603 ResourceProvider::TextureUsageAny)) { | 2605 ResourceProvider::TextureUsageAny)) { |
| 2604 resource_provider->AllocateForTesting(resource_id_); | 2606 resource_provider->AllocateForTesting(resource_id_); |
| 2605 SetAnchorPoint(gfx::PointF()); | 2607 SetAnchorPoint(gfx::PointF()); |
| 2606 SetBounds(gfx::Size(10, 10)); | 2608 SetBounds(gfx::Size(10, 10)); |
| 2607 SetContentBounds(gfx::Size(10, 10)); | 2609 SetContentBounds(gfx::Size(10, 10)); |
| 2608 SetDrawsContent(true); | 2610 SetDrawsContent(true); |
| 2609 } | 2611 } |
| 2610 | 2612 |
| 2611 bool blend_; | 2613 bool blend_; |
| 2612 bool has_render_surface_; | 2614 bool has_render_surface_; |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2986 } | 2988 } |
| 2987 return num_gutter_quads; | 2989 return num_gutter_quads; |
| 2988 } | 2990 } |
| 2989 | 2991 |
| 2990 // Make sure that the texture coordinates match their expectations. | 2992 // Make sure that the texture coordinates match their expectations. |
| 2991 void ValidateTextureDrawQuads(const QuadList& quad_list) { | 2993 void ValidateTextureDrawQuads(const QuadList& quad_list) { |
| 2992 for (size_t i = 0; i < quad_list.size(); ++i) { | 2994 for (size_t i = 0; i < quad_list.size(); ++i) { |
| 2993 if (quad_list[i]->material == DrawQuad::TEXTURE_CONTENT) { | 2995 if (quad_list[i]->material == DrawQuad::TEXTURE_CONTENT) { |
| 2994 TextureDrawQuad* quad = reinterpret_cast<TextureDrawQuad*>( | 2996 TextureDrawQuad* quad = reinterpret_cast<TextureDrawQuad*>( |
| 2995 quad_list[i]); | 2997 quad_list[i]); |
| 2996 EXPECT_EQ(quad->uv_top_left.x(), | 2998 EXPECT_EQ(quad->rect.x() / |
| 2997 quad->rect.x() / | 2999 static_cast<float>(gutter_texture_size_.width()), |
| 2998 static_cast<float>(gutter_texture_size_.width())); | 3000 quad->uv_top_left.x()); |
| 2999 EXPECT_EQ(quad->uv_top_left.y(), | 3001 EXPECT_EQ(quad->rect.y() / |
| 3000 quad->rect.y() / | 3002 static_cast<float>(gutter_texture_size_.height()), |
| 3001 static_cast<float>(gutter_texture_size_.height())); | 3003 quad->uv_top_left.y()); |
| 3002 EXPECT_EQ(quad->uv_bottom_right.x(), | 3004 EXPECT_EQ((quad->rect.x() + quad->rect.width()) / |
| 3003 (quad->rect.x() + quad->rect.width()) / | 3005 static_cast<float>(gutter_texture_size_.width()), |
| 3004 static_cast<float>(gutter_texture_size_.width())); | 3006 quad->uv_bottom_right.x()); |
| 3005 EXPECT_EQ(quad->uv_bottom_right.y(), | 3007 EXPECT_EQ((quad->rect.y() + quad->rect.height()) / |
| 3006 (quad->rect.y() + quad->rect.height()) / | 3008 static_cast<float>(gutter_texture_size_.height()), |
| 3007 static_cast<float>(gutter_texture_size_.height())); | 3009 quad->uv_bottom_right.y()); |
| 3010 EXPECT_EQ(GL_REPEAT, |
| 3011 host_impl_->resource_provider()->WrapModeForTesting( |
| 3012 quad->resource_id)); |
| 3008 } | 3013 } |
| 3009 } | 3014 } |
| 3010 } | 3015 } |
| 3011 | 3016 |
| 3012 DrawQuad::Material gutter_quad_material_; | 3017 DrawQuad::Material gutter_quad_material_; |
| 3013 gfx::Size gutter_texture_size_; | 3018 gfx::Size gutter_texture_size_; |
| 3014 gfx::Size viewport_size_; | 3019 gfx::Size viewport_size_; |
| 3015 BlendStateCheckLayer* child_; | 3020 BlendStateCheckLayer* child_; |
| 3016 bool did_activate_pending_tree_; | 3021 bool did_activate_pending_tree_; |
| 3017 }; | 3022 }; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3030 | 3035 |
| 3031 TEST_F(LayerTreeHostImplViewportCoveredTest, ViewportCoveredOverhangBitmap) { | 3036 TEST_F(LayerTreeHostImplViewportCoveredTest, ViewportCoveredOverhangBitmap) { |
| 3032 bool always_draw = false; | 3037 bool always_draw = false; |
| 3033 CreateLayerTreeHostImpl(always_draw); | 3038 CreateLayerTreeHostImpl(always_draw); |
| 3034 | 3039 |
| 3035 host_impl_->SetViewportSize(viewport_size_); | 3040 host_impl_->SetViewportSize(viewport_size_); |
| 3036 SetupActiveTreeLayers(); | 3041 SetupActiveTreeLayers(); |
| 3037 | 3042 |
| 3038 // Specify an overhang bitmap to use. | 3043 // Specify an overhang bitmap to use. |
| 3039 scoped_refptr<UIResourceBitmap> ui_resource_bitmap(UIResourceBitmap::Create( | 3044 scoped_refptr<UIResourceBitmap> ui_resource_bitmap(UIResourceBitmap::Create( |
| 3040 new uint8_t[4], UIResourceBitmap::RGBA8, gfx::Size(1, 1))); | 3045 new uint8_t[4], |
| 3046 UIResourceBitmap::RGBA8, |
| 3047 UIResourceBitmap::REPEAT, |
| 3048 gfx::Size(1, 1))); |
| 3041 UIResourceId ui_resource_id = 12345; | 3049 UIResourceId ui_resource_id = 12345; |
| 3042 host_impl_->CreateUIResource(ui_resource_id, ui_resource_bitmap); | 3050 host_impl_->CreateUIResource(ui_resource_id, ui_resource_bitmap); |
| 3043 host_impl_->SetOverhangUIResource(ui_resource_id, gfx::Size(32, 32)); | 3051 host_impl_->SetOverhangUIResource(ui_resource_id, gfx::Size(32, 32)); |
| 3044 set_gutter_quad_material(DrawQuad::TEXTURE_CONTENT); | 3052 set_gutter_quad_material(DrawQuad::TEXTURE_CONTENT); |
| 3045 set_gutter_texture_size(gfx::Size(32, 32)); | 3053 set_gutter_texture_size(gfx::Size(32, 32)); |
| 3046 | 3054 |
| 3047 TestLayerCoversFullViewport(); | 3055 TestLayerCoversFullViewport(); |
| 3048 TestEmptyLayer(); | 3056 TestEmptyLayer(); |
| 3049 TestLayerInMiddleOfViewport(); | 3057 TestLayerInMiddleOfViewport(); |
| 3050 TestLayerIsLargerThanViewport(); | 3058 TestLayerIsLargerThanViewport(); |
| (...skipping 3352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6403 scoped_ptr<TestWebGraphicsContext3D> context = | 6411 scoped_ptr<TestWebGraphicsContext3D> context = |
| 6404 TestWebGraphicsContext3D::Create(); | 6412 TestWebGraphicsContext3D::Create(); |
| 6405 TestWebGraphicsContext3D* context3d = context.get(); | 6413 TestWebGraphicsContext3D* context3d = context.get(); |
| 6406 scoped_ptr<OutputSurface> output_surface = CreateFakeOutputSurface(); | 6414 scoped_ptr<OutputSurface> output_surface = CreateFakeOutputSurface(); |
| 6407 host_impl_->InitializeRenderer(output_surface.Pass()); | 6415 host_impl_->InitializeRenderer(output_surface.Pass()); |
| 6408 | 6416 |
| 6409 EXPECT_EQ(0u, context3d->NumTextures()); | 6417 EXPECT_EQ(0u, context3d->NumTextures()); |
| 6410 | 6418 |
| 6411 UIResourceId ui_resource_id = 1; | 6419 UIResourceId ui_resource_id = 1; |
| 6412 scoped_refptr<UIResourceBitmap> bitmap = UIResourceBitmap::Create( | 6420 scoped_refptr<UIResourceBitmap> bitmap = UIResourceBitmap::Create( |
| 6413 new uint8_t[1], UIResourceBitmap::RGBA8, gfx::Size(1, 1)); | 6421 new uint8_t[1], |
| 6422 UIResourceBitmap::RGBA8, |
| 6423 UIResourceBitmap::CLAMP_TO_EDGE, |
| 6424 gfx::Size(1, 1)); |
| 6414 host_impl_->CreateUIResource(ui_resource_id, bitmap); | 6425 host_impl_->CreateUIResource(ui_resource_id, bitmap); |
| 6415 EXPECT_EQ(1u, context3d->NumTextures()); | 6426 EXPECT_EQ(1u, context3d->NumTextures()); |
| 6416 ResourceProvider::ResourceId id1 = | 6427 ResourceProvider::ResourceId id1 = |
| 6417 host_impl_->ResourceIdForUIResource(ui_resource_id); | 6428 host_impl_->ResourceIdForUIResource(ui_resource_id); |
| 6418 EXPECT_NE(0u, id1); | 6429 EXPECT_NE(0u, id1); |
| 6419 | 6430 |
| 6420 // Multiple requests with the same id is allowed. The previous texture is | 6431 // Multiple requests with the same id is allowed. The previous texture is |
| 6421 // deleted. | 6432 // deleted. |
| 6422 host_impl_->CreateUIResource(ui_resource_id, bitmap); | 6433 host_impl_->CreateUIResource(ui_resource_id, bitmap); |
| 6423 EXPECT_EQ(1u, context3d->NumTextures()); | 6434 EXPECT_EQ(1u, context3d->NumTextures()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 6439 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id)); | 6450 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id)); |
| 6440 EXPECT_EQ(0u, context3d->NumTextures()); | 6451 EXPECT_EQ(0u, context3d->NumTextures()); |
| 6441 | 6452 |
| 6442 // Should not change state for multiple deletion on one UIResourceId | 6453 // Should not change state for multiple deletion on one UIResourceId |
| 6443 host_impl_->DeleteUIResource(ui_resource_id); | 6454 host_impl_->DeleteUIResource(ui_resource_id); |
| 6444 EXPECT_EQ(0u, context3d->NumTextures()); | 6455 EXPECT_EQ(0u, context3d->NumTextures()); |
| 6445 } | 6456 } |
| 6446 | 6457 |
| 6447 } // namespace | 6458 } // namespace |
| 6448 } // namespace cc | 6459 } // namespace cc |
| OLD | NEW |