| 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/layers/append_quads_data.h" | 5 #include "cc/layers/append_quads_data.h" |
| 6 #include "cc/layers/layer_impl.h" | 6 #include "cc/layers/layer_impl.h" |
| 7 #include "cc/layers/render_pass_sink.h" | 7 #include "cc/layers/render_pass_sink.h" |
| 8 #include "cc/layers/render_surface_impl.h" | 8 #include "cc/layers/render_surface_impl.h" |
| 9 #include "cc/quads/shared_quad_state.h" | 9 #include "cc/quads/shared_quad_state.h" |
| 10 #include "cc/test/fake_compositor_frame_sink.h" | 10 #include "cc/test/fake_compositor_frame_sink.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 94 |
| 95 TEST(RenderSurfaceTest, SanityCheckSurfaceCreatesCorrectSharedQuadState) { | 95 TEST(RenderSurfaceTest, SanityCheckSurfaceCreatesCorrectSharedQuadState) { |
| 96 FakeImplTaskRunnerProvider task_runner_provider; | 96 FakeImplTaskRunnerProvider task_runner_provider; |
| 97 TestTaskGraphRunner task_graph_runner; | 97 TestTaskGraphRunner task_graph_runner; |
| 98 std::unique_ptr<CompositorFrameSink> compositor_frame_sink = | 98 std::unique_ptr<CompositorFrameSink> compositor_frame_sink = |
| 99 FakeCompositorFrameSink::Create3d(); | 99 FakeCompositorFrameSink::Create3d(); |
| 100 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); | 100 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); |
| 101 std::unique_ptr<LayerImpl> root_layer = | 101 std::unique_ptr<LayerImpl> root_layer = |
| 102 LayerImpl::Create(host_impl.active_tree(), 1); | 102 LayerImpl::Create(host_impl.active_tree(), 1); |
| 103 | 103 |
| 104 int owning_layer_id = 2; |
| 104 std::unique_ptr<LayerImpl> owning_layer = | 105 std::unique_ptr<LayerImpl> owning_layer = |
| 105 LayerImpl::Create(host_impl.active_tree(), 2); | 106 LayerImpl::Create(host_impl.active_tree(), owning_layer_id); |
| 106 owning_layer->SetHasRenderSurface(true); | 107 owning_layer->test_properties()->force_render_surface = true; |
| 107 ASSERT_TRUE(owning_layer->render_surface()); | |
| 108 | 108 |
| 109 SkBlendMode blend_mode = SkBlendMode::kSoftLight; | 109 SkBlendMode blend_mode = SkBlendMode::kSoftLight; |
| 110 owning_layer->test_properties()->blend_mode = blend_mode; | 110 owning_layer->test_properties()->blend_mode = blend_mode; |
| 111 RenderSurfaceImpl* render_surface = owning_layer->render_surface(); | |
| 112 | 111 |
| 113 root_layer->test_properties()->AddChild(std::move(owning_layer)); | 112 root_layer->test_properties()->AddChild(std::move(owning_layer)); |
| 114 host_impl.active_tree()->SetRootLayerForTesting(std::move(root_layer)); | 113 host_impl.active_tree()->SetRootLayerForTesting(std::move(root_layer)); |
| 115 host_impl.SetVisible(true); | 114 host_impl.SetVisible(true); |
| 116 host_impl.InitializeRenderer(compositor_frame_sink.get()); | 115 host_impl.InitializeRenderer(compositor_frame_sink.get()); |
| 117 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 116 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
| 118 host_impl.active_tree()->UpdateDrawProperties(false /* update_lcd_text */); | 117 host_impl.active_tree()->UpdateDrawProperties(false /* update_lcd_text */); |
| 119 | 118 |
| 119 ASSERT_TRUE( |
| 120 host_impl.active_tree()->LayerById(owning_layer_id)->render_surface()); |
| 121 RenderSurfaceImpl* render_surface = |
| 122 host_impl.active_tree()->LayerById(owning_layer_id)->render_surface(); |
| 123 |
| 120 gfx::Rect content_rect(0, 0, 50, 50); | 124 gfx::Rect content_rect(0, 0, 50, 50); |
| 121 gfx::Rect clip_rect(5, 5, 40, 40); | 125 gfx::Rect clip_rect(5, 5, 40, 40); |
| 122 gfx::Transform origin; | 126 gfx::Transform origin; |
| 123 origin.Translate(30, 40); | 127 origin.Translate(30, 40); |
| 124 | 128 |
| 125 render_surface->SetContentRectForTesting(content_rect); | 129 render_surface->SetContentRectForTesting(content_rect); |
| 126 render_surface->SetClipRect(clip_rect); | 130 render_surface->SetClipRect(clip_rect); |
| 127 render_surface->SetDrawOpacity(1.f); | 131 render_surface->SetDrawOpacity(1.f); |
| 128 render_surface->SetDrawTransform(origin); | 132 render_surface->SetDrawTransform(origin); |
| 129 | 133 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 ASSERT_EQ(1u, pass_sink.RenderPasses().size()); | 206 ASSERT_EQ(1u, pass_sink.RenderPasses().size()); |
| 203 RenderPass* pass = pass_sink.RenderPasses()[0].get(); | 207 RenderPass* pass = pass_sink.RenderPasses()[0].get(); |
| 204 | 208 |
| 205 EXPECT_EQ(2, pass->id); | 209 EXPECT_EQ(2, pass->id); |
| 206 EXPECT_EQ(content_rect, pass->output_rect); | 210 EXPECT_EQ(content_rect, pass->output_rect); |
| 207 EXPECT_EQ(origin, pass->transform_to_root_target); | 211 EXPECT_EQ(origin, pass->transform_to_root_target); |
| 208 } | 212 } |
| 209 | 213 |
| 210 } // namespace | 214 } // namespace |
| 211 } // namespace cc | 215 } // namespace cc |
| OLD | NEW |