Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: cc/layers/render_surface_unittest.cc

Issue 2164833002: Use surface contents scale from effect tree (3) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/layer_impl.cc ('k') | cc/trees/draw_property_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_impl_task_runner_provider.h" 10 #include "cc/test/fake_impl_task_runner_provider.h"
11 #include "cc/test/fake_layer_tree_host_impl.h" 11 #include "cc/test/fake_layer_tree_host_impl.h"
12 #include "cc/test/fake_output_surface.h"
12 #include "cc/test/geometry_test_utils.h" 13 #include "cc/test/geometry_test_utils.h"
13 #include "cc/test/mock_occlusion_tracker.h" 14 #include "cc/test/mock_occlusion_tracker.h"
14 #include "cc/test/test_shared_bitmap_manager.h" 15 #include "cc/test/test_shared_bitmap_manager.h"
15 #include "cc/test/test_task_graph_runner.h" 16 #include "cc/test/test_task_graph_runner.h"
16 #include "cc/trees/layer_tree_impl.h" 17 #include "cc/trees/layer_tree_impl.h"
17 #include "cc/trees/single_thread_proxy.h" 18 #include "cc/trees/single_thread_proxy.h"
18 #include "testing/gmock/include/gmock/gmock.h" 19 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 #include "ui/gfx/transform.h" 21 #include "ui/gfx/transform.h"
21 22
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 render_surface->SetDrawTransform(dummy_matrix)); 82 render_surface->SetDrawTransform(dummy_matrix));
82 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE( 83 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(
83 render_surface->SetReplicaDrawTransform(dummy_matrix)); 84 render_surface->SetReplicaDrawTransform(dummy_matrix));
84 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(render_surface->ClearLayerLists()); 85 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(render_surface->ClearLayerLists());
85 } 86 }
86 87
87 TEST(RenderSurfaceTest, SanityCheckSurfaceCreatesCorrectSharedQuadState) { 88 TEST(RenderSurfaceTest, SanityCheckSurfaceCreatesCorrectSharedQuadState) {
88 FakeImplTaskRunnerProvider task_runner_provider; 89 FakeImplTaskRunnerProvider task_runner_provider;
89 TestSharedBitmapManager shared_bitmap_manager; 90 TestSharedBitmapManager shared_bitmap_manager;
90 TestTaskGraphRunner task_graph_runner; 91 TestTaskGraphRunner task_graph_runner;
92 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d();
91 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 93 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
92 &task_graph_runner); 94 &task_graph_runner);
93 std::unique_ptr<LayerImpl> root_layer = 95 std::unique_ptr<LayerImpl> root_layer =
94 LayerImpl::Create(host_impl.active_tree(), 1); 96 LayerImpl::Create(host_impl.active_tree(), 1);
95 97
96 std::unique_ptr<LayerImpl> owning_layer = 98 std::unique_ptr<LayerImpl> owning_layer =
97 LayerImpl::Create(host_impl.active_tree(), 2); 99 LayerImpl::Create(host_impl.active_tree(), 2);
98 owning_layer->SetHasRenderSurface(true); 100 owning_layer->SetHasRenderSurface(true);
99 ASSERT_TRUE(owning_layer->render_surface()); 101 ASSERT_TRUE(owning_layer->render_surface());
100 102
101 SkXfermode::Mode blend_mode = SkXfermode::kSoftLight_Mode; 103 SkXfermode::Mode blend_mode = SkXfermode::kSoftLight_Mode;
102 owning_layer->SetBlendMode(blend_mode); 104 owning_layer->SetBlendMode(blend_mode);
103 RenderSurfaceImpl* render_surface = owning_layer->render_surface(); 105 RenderSurfaceImpl* render_surface = owning_layer->render_surface();
104 106
105 root_layer->test_properties()->AddChild(std::move(owning_layer)); 107 root_layer->test_properties()->AddChild(std::move(owning_layer));
106 host_impl.active_tree()->SetRootLayerForTesting(std::move(root_layer)); 108 host_impl.active_tree()->SetRootLayerForTesting(std::move(root_layer));
109 host_impl.SetVisible(true);
110 host_impl.InitializeRenderer(output_surface.get());
107 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); 111 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting();
112 host_impl.active_tree()->UpdateDrawProperties(false /* update_lcd_text */);
108 113
109 gfx::Rect content_rect(0, 0, 50, 50); 114 gfx::Rect content_rect(0, 0, 50, 50);
110 gfx::Rect clip_rect(5, 5, 40, 40); 115 gfx::Rect clip_rect(5, 5, 40, 40);
111 gfx::Transform origin; 116 gfx::Transform origin;
112 origin.Translate(30, 40); 117 origin.Translate(30, 40);
113 118
114 render_surface->SetContentRectForTesting(content_rect); 119 render_surface->SetContentRectForTesting(content_rect);
115 render_surface->SetClipRect(clip_rect); 120 render_surface->SetClipRect(clip_rect);
116 render_surface->SetDrawOpacity(1.f); 121 render_surface->SetDrawOpacity(1.f);
117 122
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 ASSERT_EQ(1u, pass_sink.RenderPasses().size()); 188 ASSERT_EQ(1u, pass_sink.RenderPasses().size());
184 RenderPass* pass = pass_sink.RenderPasses()[0].get(); 189 RenderPass* pass = pass_sink.RenderPasses()[0].get();
185 190
186 EXPECT_EQ(RenderPassId(2, 0), pass->id); 191 EXPECT_EQ(RenderPassId(2, 0), pass->id);
187 EXPECT_EQ(content_rect, pass->output_rect); 192 EXPECT_EQ(content_rect, pass->output_rect);
188 EXPECT_EQ(origin, pass->transform_to_root_target); 193 EXPECT_EQ(origin, pass->transform_to_root_target);
189 } 194 }
190 195
191 } // namespace 196 } // namespace
192 } // namespace cc 197 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.cc ('k') | cc/trees/draw_property_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698