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

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

Issue 609663003: cc: Remove use of PassAs() and constructor-casting with scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cc-passas: PassAs-presubmit-warning Created 6 years, 2 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/delegated_renderer_layer_impl.cc ('k') | cc/layers/heads_up_display_layer.cc » ('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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/delegated_renderer_layer_impl.h" 5 #include "cc/layers/delegated_renderer_layer_impl.h"
6 6
7 #include "cc/base/scoped_ptr_vector.h" 7 #include "cc/base/scoped_ptr_vector.h"
8 #include "cc/layers/solid_color_layer_impl.h" 8 #include "cc/layers/solid_color_layer_impl.h"
9 #include "cc/quads/render_pass_draw_quad.h" 9 #include "cc/quads/render_pass_draw_quad.h"
10 #include "cc/quads/solid_color_draw_quad.h" 10 #include "cc/quads/solid_color_draw_quad.h"
(...skipping 22 matching lines...) Expand all
33 class DelegatedRendererLayerImplTest : public testing::Test { 33 class DelegatedRendererLayerImplTest : public testing::Test {
34 public: 34 public:
35 DelegatedRendererLayerImplTest() 35 DelegatedRendererLayerImplTest()
36 : proxy_(), 36 : proxy_(),
37 always_impl_thread_and_main_thread_blocked_(&proxy_) { 37 always_impl_thread_and_main_thread_blocked_(&proxy_) {
38 LayerTreeSettings settings; 38 LayerTreeSettings settings;
39 settings.minimum_occlusion_tracking_size = gfx::Size(); 39 settings.minimum_occlusion_tracking_size = gfx::Size();
40 40
41 host_impl_.reset( 41 host_impl_.reset(
42 new FakeLayerTreeHostImpl(settings, &proxy_, &shared_bitmap_manager_)); 42 new FakeLayerTreeHostImpl(settings, &proxy_, &shared_bitmap_manager_));
43 host_impl_->InitializeRenderer( 43 host_impl_->InitializeRenderer(FakeOutputSurface::Create3d());
44 FakeOutputSurface::Create3d().PassAs<OutputSurface>());
45 host_impl_->SetViewportSize(gfx::Size(10, 10)); 44 host_impl_->SetViewportSize(gfx::Size(10, 10));
46 } 45 }
47 46
48 protected: 47 protected:
49 FakeProxy proxy_; 48 FakeProxy proxy_;
50 DebugScopedSetImplThreadAndMainThreadBlocked 49 DebugScopedSetImplThreadAndMainThreadBlocked
51 always_impl_thread_and_main_thread_blocked_; 50 always_impl_thread_and_main_thread_blocked_;
52 TestSharedBitmapManager shared_bitmap_manager_; 51 TestSharedBitmapManager shared_bitmap_manager_;
53 scoped_ptr<LayerTreeHostImpl> host_impl_; 52 scoped_ptr<LayerTreeHostImpl> host_impl_;
54 }; 53 };
55 54
56 class DelegatedRendererLayerImplTestSimple 55 class DelegatedRendererLayerImplTestSimple
57 : public DelegatedRendererLayerImplTest { 56 : public DelegatedRendererLayerImplTest {
58 public: 57 public:
59 DelegatedRendererLayerImplTestSimple() 58 DelegatedRendererLayerImplTestSimple()
60 : DelegatedRendererLayerImplTest() { 59 : DelegatedRendererLayerImplTest() {
61 scoped_ptr<LayerImpl> root_layer = SolidColorLayerImpl::Create( 60 scoped_ptr<LayerImpl> root_layer =
62 host_impl_->active_tree(), 1).PassAs<LayerImpl>(); 61 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1);
63 scoped_ptr<LayerImpl> layer_before = SolidColorLayerImpl::Create( 62 scoped_ptr<LayerImpl> layer_before =
64 host_impl_->active_tree(), 2).PassAs<LayerImpl>(); 63 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2);
65 scoped_ptr<LayerImpl> layer_after = SolidColorLayerImpl::Create( 64 scoped_ptr<LayerImpl> layer_after =
66 host_impl_->active_tree(), 3).PassAs<LayerImpl>(); 65 SolidColorLayerImpl::Create(host_impl_->active_tree(), 3);
67 scoped_ptr<FakeDelegatedRendererLayerImpl> delegated_renderer_layer = 66 scoped_ptr<FakeDelegatedRendererLayerImpl> delegated_renderer_layer =
68 FakeDelegatedRendererLayerImpl::Create(host_impl_->active_tree(), 4); 67 FakeDelegatedRendererLayerImpl::Create(host_impl_->active_tree(), 4);
69 68
70 host_impl_->SetViewportSize(gfx::Size(100, 100)); 69 host_impl_->SetViewportSize(gfx::Size(100, 100));
71 root_layer->SetBounds(gfx::Size(100, 100)); 70 root_layer->SetBounds(gfx::Size(100, 100));
72 71
73 layer_before->SetPosition(gfx::Point(20, 20)); 72 layer_before->SetPosition(gfx::Point(20, 20));
74 layer_before->SetBounds(gfx::Size(14, 14)); 73 layer_before->SetBounds(gfx::Size(14, 14));
75 layer_before->SetContentBounds(gfx::Size(14, 14)); 74 layer_before->SetContentBounds(gfx::Size(14, 14));
76 layer_before->SetDrawsContent(true); 75 layer_before->SetDrawsContent(true);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 // The RenderPasses should be taken by the layer. 112 // The RenderPasses should be taken by the layer.
114 EXPECT_EQ(0u, delegated_render_passes.size()); 113 EXPECT_EQ(0u, delegated_render_passes.size());
115 114
116 root_layer_ = root_layer.get(); 115 root_layer_ = root_layer.get();
117 layer_before_ = layer_before.get(); 116 layer_before_ = layer_before.get();
118 layer_after_ = layer_after.get(); 117 layer_after_ = layer_after.get();
119 delegated_renderer_layer_ = delegated_renderer_layer.get(); 118 delegated_renderer_layer_ = delegated_renderer_layer.get();
120 119
121 // Force the delegated RenderPasses to come before the RenderPass from 120 // Force the delegated RenderPasses to come before the RenderPass from
122 // layer_after. 121 // layer_after.
123 layer_after->AddChild(delegated_renderer_layer.PassAs<LayerImpl>()); 122 layer_after->AddChild(delegated_renderer_layer.Pass());
124 root_layer->AddChild(layer_after.Pass()); 123 root_layer->AddChild(layer_after.Pass());
125 124
126 // Get the RenderPass generated by layer_before to come before the delegated 125 // Get the RenderPass generated by layer_before to come before the delegated
127 // RenderPasses. 126 // RenderPasses.
128 root_layer->AddChild(layer_before.Pass()); 127 root_layer->AddChild(layer_before.Pass());
129 host_impl_->active_tree()->SetRootLayer(root_layer.Pass()); 128 host_impl_->active_tree()->SetRootLayer(root_layer.Pass());
130 } 129 }
131 130
132 protected: 131 protected:
133 LayerImpl* root_layer_; 132 LayerImpl* root_layer_;
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 625
627 delegated_renderer_layer->SetFrameDataForRenderPasses( 626 delegated_renderer_layer->SetFrameDataForRenderPasses(
628 delegated_device_scale_factor_, &delegated_render_passes); 627 delegated_device_scale_factor_, &delegated_render_passes);
629 628
630 // The RenderPasses should be taken by the layer. 629 // The RenderPasses should be taken by the layer.
631 EXPECT_EQ(0u, delegated_render_passes.size()); 630 EXPECT_EQ(0u, delegated_render_passes.size());
632 631
633 root_layer_ = root_layer.get(); 632 root_layer_ = root_layer.get();
634 delegated_renderer_layer_ = delegated_renderer_layer.get(); 633 delegated_renderer_layer_ = delegated_renderer_layer.get();
635 634
636 root_layer->AddChild(delegated_renderer_layer.PassAs<LayerImpl>()); 635 root_layer->AddChild(delegated_renderer_layer.Pass());
637 host_impl_->active_tree()->SetRootLayer(root_layer.Pass()); 636 host_impl_->active_tree()->SetRootLayer(root_layer.Pass());
638 } 637 }
639 638
640 void VerifyRenderPasses( 639 void VerifyRenderPasses(
641 const LayerTreeHostImpl::FrameData& frame, 640 const LayerTreeHostImpl::FrameData& frame,
642 size_t num_render_passes, 641 size_t num_render_passes,
643 const SharedQuadState** root_delegated_shared_quad_state, 642 const SharedQuadState** root_delegated_shared_quad_state,
644 const SharedQuadState** contrib_delegated_shared_quad_state) { 643 const SharedQuadState** contrib_delegated_shared_quad_state) {
645 ASSERT_EQ(num_render_passes, frame.render_passes.size()); 644 ASSERT_EQ(num_render_passes, frame.render_passes.size());
646 // The contributing render pass in the DelegatedRendererLayer. 645 // The contributing render pass in the DelegatedRendererLayer.
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 gfx::Rect clip_rect(21, 27, 23, 21); 1068 gfx::Rect clip_rect(21, 27, 23, 21);
1070 1069
1071 clip_layer->SetPosition(clip_rect.origin()); 1070 clip_layer->SetPosition(clip_rect.origin());
1072 clip_layer->SetBounds(clip_rect.size()); 1071 clip_layer->SetBounds(clip_rect.size());
1073 clip_layer->SetContentBounds(clip_rect.size()); 1072 clip_layer->SetContentBounds(clip_rect.size());
1074 clip_layer->SetMasksToBounds(true); 1073 clip_layer->SetMasksToBounds(true);
1075 1074
1076 origin_layer->SetPosition( 1075 origin_layer->SetPosition(
1077 gfx::PointAtOffsetFromOrigin(-clip_rect.OffsetFromOrigin())); 1076 gfx::PointAtOffsetFromOrigin(-clip_rect.OffsetFromOrigin()));
1078 1077
1079 origin_layer->AddChild(delegated_renderer_layer.PassAs<LayerImpl>()); 1078 origin_layer->AddChild(delegated_renderer_layer.Pass());
1080 clip_layer->AddChild(origin_layer.Pass()); 1079 clip_layer->AddChild(origin_layer.Pass());
1081 root_layer->AddChild(clip_layer.Pass()); 1080 root_layer->AddChild(clip_layer.Pass());
1082 } else { 1081 } else {
1083 root_layer->AddChild(delegated_renderer_layer.PassAs<LayerImpl>()); 1082 root_layer->AddChild(delegated_renderer_layer.Pass());
1084 } 1083 }
1085 1084
1086 host_impl_->active_tree()->SetRootLayer(root_layer.Pass()); 1085 host_impl_->active_tree()->SetRootLayer(root_layer.Pass());
1087 } 1086 }
1088 1087
1089 protected: 1088 protected:
1090 LayerImpl* root_layer_; 1089 LayerImpl* root_layer_;
1091 DelegatedRendererLayerImpl* delegated_renderer_layer_; 1090 DelegatedRendererLayerImpl* delegated_renderer_layer_;
1092 bool root_delegated_render_pass_is_clipped_; 1091 bool root_delegated_render_pass_is_clipped_;
1093 bool clip_delegated_renderer_layer_; 1092 bool clip_delegated_renderer_layer_;
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1323 EXPECT_EQ(gfx::Rect(5, 5, 40, 40).ToString(), 1322 EXPECT_EQ(gfx::Rect(5, 5, 40, 40).ToString(),
1324 root_delegated_shared_quad_state->clip_rect.ToString()); 1323 root_delegated_shared_quad_state->clip_rect.ToString());
1325 // Quads came with a clip rect. 1324 // Quads came with a clip rect.
1326 EXPECT_TRUE(root_delegated_shared_quad_state->is_clipped); 1325 EXPECT_TRUE(root_delegated_shared_quad_state->is_clipped);
1327 1326
1328 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1327 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1329 host_impl_->DidDrawAllLayers(frame); 1328 host_impl_->DidDrawAllLayers(frame);
1330 } 1329 }
1331 1330
1332 TEST_F(DelegatedRendererLayerImplTest, InvalidRenderPassDrawQuad) { 1331 TEST_F(DelegatedRendererLayerImplTest, InvalidRenderPassDrawQuad) {
1333 scoped_ptr<LayerImpl> root_layer = LayerImpl::Create( 1332 scoped_ptr<LayerImpl> root_layer =
1334 host_impl_->active_tree(), 1).PassAs<LayerImpl>(); 1333 LayerImpl::Create(host_impl_->active_tree(), 1);
1335 scoped_ptr<FakeDelegatedRendererLayerImpl> delegated_renderer_layer = 1334 scoped_ptr<FakeDelegatedRendererLayerImpl> delegated_renderer_layer =
1336 FakeDelegatedRendererLayerImpl::Create(host_impl_->active_tree(), 4); 1335 FakeDelegatedRendererLayerImpl::Create(host_impl_->active_tree(), 4);
1337 1336
1338 host_impl_->SetViewportSize(gfx::Size(100, 100)); 1337 host_impl_->SetViewportSize(gfx::Size(100, 100));
1339 1338
1340 delegated_renderer_layer->SetPosition(gfx::Point(3, 3)); 1339 delegated_renderer_layer->SetPosition(gfx::Point(3, 3));
1341 delegated_renderer_layer->SetBounds(gfx::Size(10, 10)); 1340 delegated_renderer_layer->SetBounds(gfx::Size(10, 10));
1342 delegated_renderer_layer->SetContentBounds(gfx::Size(10, 10)); 1341 delegated_renderer_layer->SetContentBounds(gfx::Size(10, 10));
1343 delegated_renderer_layer->SetDrawsContent(true); 1342 delegated_renderer_layer->SetDrawsContent(true);
1344 1343
(...skipping 13 matching lines...) Expand all
1358 1357
1359 // But a render pass quad refers to it. 1358 // But a render pass quad refers to it.
1360 AddRenderPassQuad(pass1, missing_pass.get()); 1359 AddRenderPassQuad(pass1, missing_pass.get());
1361 1360
1362 delegated_renderer_layer->SetFrameDataForRenderPasses( 1361 delegated_renderer_layer->SetFrameDataForRenderPasses(
1363 1.f, &delegated_render_passes); 1362 1.f, &delegated_render_passes);
1364 1363
1365 // The RenderPasses should be taken by the layer. 1364 // The RenderPasses should be taken by the layer.
1366 EXPECT_EQ(0u, delegated_render_passes.size()); 1365 EXPECT_EQ(0u, delegated_render_passes.size());
1367 1366
1368 root_layer->AddChild(delegated_renderer_layer.PassAs<LayerImpl>()); 1367 root_layer->AddChild(delegated_renderer_layer.Pass());
1369 host_impl_->active_tree()->SetRootLayer(root_layer.Pass()); 1368 host_impl_->active_tree()->SetRootLayer(root_layer.Pass());
1370 1369
1371 LayerTreeHostImpl::FrameData frame; 1370 LayerTreeHostImpl::FrameData frame;
1372 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 1371 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1373 1372
1374 // The DelegatedRendererLayerImpl should drop the bad RenderPassDrawQuad. 1373 // The DelegatedRendererLayerImpl should drop the bad RenderPassDrawQuad.
1375 ASSERT_EQ(1u, frame.render_passes.size()); 1374 ASSERT_EQ(1u, frame.render_passes.size());
1376 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 1375 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
1377 EXPECT_EQ(DrawQuad::SOLID_COLOR, 1376 EXPECT_EQ(DrawQuad::SOLID_COLOR,
1378 frame.render_passes[0]->quad_list.front()->material); 1377 frame.render_passes[0]->quad_list.front()->material);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1566 scoped_ptr<DelegatedRendererLayerImpl> other_layer = 1565 scoped_ptr<DelegatedRendererLayerImpl> other_layer =
1567 DelegatedRendererLayerImpl::Create(host_impl_->active_tree(), 6); 1566 DelegatedRendererLayerImpl::Create(host_impl_->active_tree(), 6);
1568 1567
1569 delegated_renderer_layer_impl->PushPropertiesTo(other_layer.get()); 1568 delegated_renderer_layer_impl->PushPropertiesTo(other_layer.get());
1570 1569
1571 EXPECT_EQ(0.5f, other_layer->inverse_device_scale_factor()); 1570 EXPECT_EQ(0.5f, other_layer->inverse_device_scale_factor());
1572 } 1571 }
1573 1572
1574 } // namespace 1573 } // namespace
1575 } // namespace cc 1574 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/delegated_renderer_layer_impl.cc ('k') | cc/layers/heads_up_display_layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698