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

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

Issue 1134663005: cc: Video layers without a frame should not occlude (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: missed const on android Created 5 years, 7 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/video_layer_impl.cc ('k') | cc/test/fake_video_frame_provider.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/video_layer_impl.h" 5 #include "cc/layers/video_layer_impl.h"
6 6
7 #include "cc/layers/video_frame_provider_client_impl.h" 7 #include "cc/layers/video_frame_provider_client_impl.h"
8 #include "cc/output/context_provider.h" 8 #include "cc/output/context_provider.h"
9 #include "cc/output/output_surface.h" 9 #include "cc/output/output_surface.h"
10 #include "cc/quads/draw_quad.h" 10 #include "cc/quads/draw_quad.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 size_t partially_occluded_count = 0; 78 size_t partially_occluded_count = 0;
79 LayerTestCommon::VerifyQuadsAreOccluded( 79 LayerTestCommon::VerifyQuadsAreOccluded(
80 impl.quad_list(), occluded, &partially_occluded_count); 80 impl.quad_list(), occluded, &partially_occluded_count);
81 // The layer outputs one quad, which is partially occluded. 81 // The layer outputs one quad, which is partially occluded.
82 EXPECT_EQ(1u, impl.quad_list().size()); 82 EXPECT_EQ(1u, impl.quad_list().size());
83 EXPECT_EQ(1u, partially_occluded_count); 83 EXPECT_EQ(1u, partially_occluded_count);
84 } 84 }
85 } 85 }
86 86
87 TEST(VideoLayerImplTest, OccludesOtherLayers) {
88 gfx::Size layer_size(1000, 1000);
89 gfx::Rect visible(layer_size);
90
91 LayerTestCommon::LayerImplTest impl;
92 impl.host_impl()->SetViewportSize(layer_size);
93 DebugSetImplThreadAndMainThreadBlocked(impl.proxy());
94 auto active_tree = impl.host_impl()->active_tree();
95
96 // Create a video layer with no frame on top of another layer.
97 scoped_ptr<LayerImpl> layer_impl = LayerImpl::Create(active_tree, 3);
98 layer_impl->SetHasRenderSurface(true);
99 layer_impl->SetBounds(layer_size);
100 layer_impl->SetContentBounds(layer_size);
101 layer_impl->SetDrawsContent(true);
102 const auto& draw_properties = layer_impl->draw_properties();
103
104 FakeVideoFrameProvider provider;
105 scoped_ptr<VideoLayerImpl> video_layer_impl = VideoLayerImpl::Create(
106 active_tree, 4, &provider, media::VIDEO_ROTATION_0);
107 video_layer_impl->SetBounds(layer_size);
108 video_layer_impl->SetContentBounds(layer_size);
109 video_layer_impl->SetDrawsContent(true);
110 video_layer_impl->SetContentsOpaque(true);
111
112 layer_impl->AddChild(video_layer_impl.Pass());
113 active_tree->SetRootLayer(layer_impl.Pass());
114
115 active_tree->UpdateDrawProperties(false);
116
117 // We don't have a frame yet, so the video doesn't occlude the layer below it.
118 EXPECT_FALSE(draw_properties.occlusion_in_content_space.IsOccluded(visible));
119
120 scoped_refptr<media::VideoFrame> video_frame = media::VideoFrame::CreateFrame(
121 media::VideoFrame::YV12, gfx::Size(10, 10), gfx::Rect(10, 10),
122 gfx::Size(10, 10), base::TimeDelta());
123 provider.set_frame(video_frame);
124 active_tree->set_needs_update_draw_properties();
125 active_tree->UpdateDrawProperties(false);
126
127 // We have a frame now, so the video occludes the layer below it.
128 EXPECT_TRUE(draw_properties.occlusion_in_content_space.IsOccluded(visible));
129 }
130
87 TEST(VideoLayerImplTest, DidBecomeActiveShouldSetActiveVideoLayer) { 131 TEST(VideoLayerImplTest, DidBecomeActiveShouldSetActiveVideoLayer) {
88 LayerTestCommon::LayerImplTest impl; 132 LayerTestCommon::LayerImplTest impl;
89 DebugSetImplThreadAndMainThreadBlocked(impl.proxy()); 133 DebugSetImplThreadAndMainThreadBlocked(impl.proxy());
90 134
91 FakeVideoFrameProvider provider; 135 FakeVideoFrameProvider provider;
92 VideoLayerImpl* video_layer_impl = 136 VideoLayerImpl* video_layer_impl =
93 impl.AddChildToRoot<VideoLayerImpl>(&provider, media::VIDEO_ROTATION_0); 137 impl.AddChildToRoot<VideoLayerImpl>(&provider, media::VIDEO_ROTATION_0);
94 138
95 VideoFrameProviderClientImpl* client = 139 VideoFrameProviderClientImpl* client =
96 static_cast<VideoFrameProviderClientImpl*>(provider.client()); 140 static_cast<VideoFrameProviderClientImpl*>(provider.client());
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 gfx::Point3F p1(0, impl.quad_list().front()->rect.height(), 0); 284 gfx::Point3F p1(0, impl.quad_list().front()->rect.height(), 0);
241 gfx::Point3F p2(impl.quad_list().front()->rect.width(), 0, 0); 285 gfx::Point3F p2(impl.quad_list().front()->rect.width(), 0, 0);
242 impl.quad_list().front()->quadTransform().TransformPoint(&p1); 286 impl.quad_list().front()->quadTransform().TransformPoint(&p1);
243 impl.quad_list().front()->quadTransform().TransformPoint(&p2); 287 impl.quad_list().front()->quadTransform().TransformPoint(&p2);
244 EXPECT_EQ(gfx::Point3F(100, 50, 0), p1); 288 EXPECT_EQ(gfx::Point3F(100, 50, 0), p1);
245 EXPECT_EQ(gfx::Point3F(0, 0, 0), p2); 289 EXPECT_EQ(gfx::Point3F(0, 0, 0), p2);
246 } 290 }
247 291
248 } // namespace 292 } // namespace
249 } // namespace cc 293 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/video_layer_impl.cc ('k') | cc/test/fake_video_frame_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698