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 18 matching lines...) Expand all Loading... |
29 #include "cc/output/compositor_frame_metadata.h" | 29 #include "cc/output/compositor_frame_metadata.h" |
30 #include "cc/output/gl_renderer.h" | 30 #include "cc/output/gl_renderer.h" |
31 #include "cc/quads/render_pass_draw_quad.h" | 31 #include "cc/quads/render_pass_draw_quad.h" |
32 #include "cc/quads/solid_color_draw_quad.h" | 32 #include "cc/quads/solid_color_draw_quad.h" |
33 #include "cc/quads/texture_draw_quad.h" | 33 #include "cc/quads/texture_draw_quad.h" |
34 #include "cc/quads/tile_draw_quad.h" | 34 #include "cc/quads/tile_draw_quad.h" |
35 #include "cc/resources/layer_tiling_data.h" | 35 #include "cc/resources/layer_tiling_data.h" |
36 #include "cc/test/animation_test_common.h" | 36 #include "cc/test/animation_test_common.h" |
37 #include "cc/test/fake_output_surface.h" | 37 #include "cc/test/fake_output_surface.h" |
38 #include "cc/test/fake_output_surface_client.h" | 38 #include "cc/test/fake_output_surface_client.h" |
| 39 #include "cc/test/fake_picture_layer_impl.h" |
| 40 #include "cc/test/fake_picture_pile_impl.h" |
39 #include "cc/test/fake_proxy.h" | 41 #include "cc/test/fake_proxy.h" |
40 #include "cc/test/fake_rendering_stats_instrumentation.h" | 42 #include "cc/test/fake_rendering_stats_instrumentation.h" |
41 #include "cc/test/fake_video_frame_provider.h" | 43 #include "cc/test/fake_video_frame_provider.h" |
42 #include "cc/test/geometry_test_utils.h" | 44 #include "cc/test/geometry_test_utils.h" |
43 #include "cc/test/layer_test_common.h" | 45 #include "cc/test/layer_test_common.h" |
44 #include "cc/test/render_pass_test_common.h" | 46 #include "cc/test/render_pass_test_common.h" |
45 #include "cc/trees/layer_tree_impl.h" | 47 #include "cc/trees/layer_tree_impl.h" |
46 #include "cc/trees/single_thread_proxy.h" | 48 #include "cc/trees/single_thread_proxy.h" |
47 #include "media/base/media.h" | 49 #include "media/base/media.h" |
48 #include "testing/gmock/include/gmock/gmock.h" | 50 #include "testing/gmock/include/gmock/gmock.h" |
49 #include "testing/gtest/include/gtest/gtest.h" | 51 #include "testing/gtest/include/gtest/gtest.h" |
| 52 #include "ui/gfx/rect_conversions.h" |
50 #include "ui/gfx/size_conversions.h" | 53 #include "ui/gfx/size_conversions.h" |
51 #include "ui/gfx/vector2d_conversions.h" | 54 #include "ui/gfx/vector2d_conversions.h" |
52 | 55 |
53 using ::testing::Mock; | 56 using ::testing::Mock; |
54 using ::testing::Return; | 57 using ::testing::Return; |
55 using ::testing::AnyNumber; | 58 using ::testing::AnyNumber; |
56 using ::testing::AtLeast; | 59 using ::testing::AtLeast; |
57 using ::testing::_; | 60 using ::testing::_; |
58 using media::VideoFrame; | 61 using media::VideoFrame; |
59 | 62 |
(...skipping 5982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6042 // by 20/50 and 10/50 | 6045 // by 20/50 and 10/50 |
6043 EXPECT_EQ(gfx::ScaleRect(gfx::RectF(20.f, 10.f, 10.f, 20.f), | 6046 EXPECT_EQ(gfx::ScaleRect(gfx::RectF(20.f, 10.f, 10.f, 20.f), |
6044 1.f / 50.f).ToString(), | 6047 1.f / 50.f).ToString(), |
6045 render_pass_quad->mask_uv_rect.ToString()); | 6048 render_pass_quad->mask_uv_rect.ToString()); |
6046 | 6049 |
6047 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); | 6050 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); |
6048 host_impl_->DidDrawAllLayers(frame); | 6051 host_impl_->DidDrawAllLayers(frame); |
6049 } | 6052 } |
6050 } | 6053 } |
6051 | 6054 |
| 6055 class GLRendererWithSetupQuadForAntialiasing : public GLRenderer { |
| 6056 public: |
| 6057 using GLRenderer::SetupQuadForAntialiasing; |
| 6058 }; |
| 6059 |
| 6060 TEST_F(LayerTreeHostImplTest, FarAwayQuadsDontNeedAA) { |
| 6061 // Due to precision issues (especially on Android), sometimes far |
| 6062 // away quads can end up thinking they need AA. |
| 6063 float device_scale_factor = 4.f / 3.f; |
| 6064 host_impl_->SetDeviceScaleFactor(device_scale_factor); |
| 6065 gfx::Size root_size(2000, 1000); |
| 6066 gfx::Size device_viewport_size = |
| 6067 gfx::ToCeiledSize(gfx::ScaleSize(root_size, device_scale_factor)); |
| 6068 host_impl_->SetViewportSize(device_viewport_size); |
| 6069 |
| 6070 host_impl_->CreatePendingTree(); |
| 6071 host_impl_->pending_tree() |
| 6072 ->SetPageScaleFactorAndLimits(1.f, 1.f / 16.f, 16.f); |
| 6073 |
| 6074 scoped_ptr<LayerImpl> scoped_root = |
| 6075 LayerImpl::Create(host_impl_->pending_tree(), 1); |
| 6076 LayerImpl* root = scoped_root.get(); |
| 6077 |
| 6078 host_impl_->pending_tree()->SetRootLayer(scoped_root.Pass()); |
| 6079 |
| 6080 scoped_ptr<LayerImpl> scoped_scrolling_layer = |
| 6081 LayerImpl::Create(host_impl_->pending_tree(), 2); |
| 6082 LayerImpl* scrolling_layer = scoped_scrolling_layer.get(); |
| 6083 root->AddChild(scoped_scrolling_layer.Pass()); |
| 6084 |
| 6085 gfx::Size content_layer_bounds(100000, 100); |
| 6086 gfx::Size pile_tile_size(3000, 3000); |
| 6087 scoped_refptr<FakePicturePileImpl> pile(FakePicturePileImpl::CreateFilledPile( |
| 6088 pile_tile_size, content_layer_bounds)); |
| 6089 |
| 6090 scoped_ptr<FakePictureLayerImpl> scoped_content_layer = |
| 6091 FakePictureLayerImpl::CreateWithPile(host_impl_->pending_tree(), 3, pile); |
| 6092 LayerImpl* content_layer = scoped_content_layer.get(); |
| 6093 scrolling_layer->AddChild(scoped_content_layer.PassAs<LayerImpl>()); |
| 6094 content_layer->SetBounds(content_layer_bounds); |
| 6095 content_layer->SetDrawsContent(true); |
| 6096 |
| 6097 root->SetBounds(root_size); |
| 6098 |
| 6099 gfx::Vector2d scroll_offset(100000, 0); |
| 6100 scrolling_layer->SetScrollable(true); |
| 6101 scrolling_layer->SetMaxScrollOffset(scroll_offset); |
| 6102 scrolling_layer->SetScrollOffset(scroll_offset); |
| 6103 |
| 6104 host_impl_->ActivatePendingTree(); |
| 6105 |
| 6106 host_impl_->active_tree()->UpdateDrawProperties(); |
| 6107 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size()); |
| 6108 |
| 6109 LayerTreeHostImpl::FrameData frame; |
| 6110 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 6111 |
| 6112 ASSERT_EQ(1u, frame.render_passes.size()); |
| 6113 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size()); |
| 6114 const DrawQuad* quad = frame.render_passes[0]->quad_list[0]; |
| 6115 |
| 6116 float edge[24]; |
| 6117 gfx::QuadF device_layer_quad; |
| 6118 bool antialiased = |
| 6119 GLRendererWithSetupQuadForAntialiasing::SetupQuadForAntialiasing( |
| 6120 quad->quadTransform(), quad, &device_layer_quad, edge); |
| 6121 EXPECT_FALSE(antialiased); |
| 6122 |
| 6123 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); |
| 6124 host_impl_->DidDrawAllLayers(frame); |
| 6125 } |
| 6126 |
| 6127 |
6052 class CompositorFrameMetadataTest : public LayerTreeHostImplTest { | 6128 class CompositorFrameMetadataTest : public LayerTreeHostImplTest { |
6053 public: | 6129 public: |
6054 CompositorFrameMetadataTest() | 6130 CompositorFrameMetadataTest() |
6055 : swap_buffers_complete_(0) {} | 6131 : swap_buffers_complete_(0) {} |
6056 | 6132 |
6057 virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE { | 6133 virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE { |
6058 swap_buffers_complete_++; | 6134 swap_buffers_complete_++; |
6059 } | 6135 } |
6060 | 6136 |
6061 int swap_buffers_complete_; | 6137 int swap_buffers_complete_; |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6376 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id)); | 6452 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id)); |
6377 EXPECT_EQ(0u, context3d->NumTextures()); | 6453 EXPECT_EQ(0u, context3d->NumTextures()); |
6378 | 6454 |
6379 // Should not change state for multiple deletion on one UIResourceId | 6455 // Should not change state for multiple deletion on one UIResourceId |
6380 host_impl_->DeleteUIResource(ui_resource_id); | 6456 host_impl_->DeleteUIResource(ui_resource_id); |
6381 EXPECT_EQ(0u, context3d->NumTextures()); | 6457 EXPECT_EQ(0u, context3d->NumTextures()); |
6382 } | 6458 } |
6383 | 6459 |
6384 } // namespace | 6460 } // namespace |
6385 } // namespace cc | 6461 } // namespace cc |
OLD | NEW |