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

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

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