OLD | NEW |
---|---|
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" |
11 #include "cc/quads/yuv_video_draw_quad.h" | |
11 #include "cc/test/fake_video_frame_provider.h" | 12 #include "cc/test/fake_video_frame_provider.h" |
12 #include "cc/test/layer_test_common.h" | 13 #include "cc/test/layer_test_common.h" |
13 #include "cc/trees/single_thread_proxy.h" | 14 #include "cc/trees/single_thread_proxy.h" |
14 #include "media/base/video_frame.h" | 15 #include "media/base/video_frame.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
16 | 17 |
17 namespace cc { | 18 namespace cc { |
18 namespace { | 19 namespace { |
19 | 20 |
20 // NOTE: We cannot use DebugScopedSetImplThreadAndMainThreadBlocked in these | 21 // NOTE: We cannot use DebugScopedSetImplThreadAndMainThreadBlocked in these |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 EXPECT_EQ(1u, impl.quad_list().size()); | 239 EXPECT_EQ(1u, impl.quad_list().size()); |
239 | 240 |
240 gfx::Point3F p1(0, impl.quad_list().front()->rect.height(), 0); | 241 gfx::Point3F p1(0, impl.quad_list().front()->rect.height(), 0); |
241 gfx::Point3F p2(impl.quad_list().front()->rect.width(), 0, 0); | 242 gfx::Point3F p2(impl.quad_list().front()->rect.width(), 0, 0); |
242 impl.quad_list().front()->quadTransform().TransformPoint(&p1); | 243 impl.quad_list().front()->quadTransform().TransformPoint(&p1); |
243 impl.quad_list().front()->quadTransform().TransformPoint(&p2); | 244 impl.quad_list().front()->quadTransform().TransformPoint(&p2); |
244 EXPECT_EQ(gfx::Point3F(100, 50, 0), p1); | 245 EXPECT_EQ(gfx::Point3F(100, 50, 0), p1); |
245 EXPECT_EQ(gfx::Point3F(0, 0, 0), p2); | 246 EXPECT_EQ(gfx::Point3F(0, 0, 0), p2); |
246 } | 247 } |
247 | 248 |
249 void EmptyCallback(unsigned sync_point) { | |
250 } | |
251 TEST(VideoLayerImplTest, NativeYUVFrameGeneratesYUVQuad) { | |
danakj
2015/05/14 23:08:33
whitespace
Daniele Castagna
2015/05/14 23:26:20
Blank line missing? Done.
| |
252 gfx::Size layer_size(1000, 1000); | |
253 gfx::Size viewport_size(1000, 1000); | |
254 | |
255 LayerTestCommon::LayerImplTest impl; | |
256 DebugSetImplThreadAndMainThreadBlocked(impl.proxy()); | |
257 | |
258 gpu::MailboxHolder mailbox_holder; | |
259 mailbox_holder.mailbox.name[0] = 1; | |
260 | |
261 scoped_refptr<media::VideoFrame> video_frame = | |
262 media::VideoFrame::WrapYUV420NativeTextures( | |
danakj
2015/05/14 23:08:33
mind adding a test for the non-native path too whi
Daniele Castagna
2015/05/14 23:26:20
Done.
| |
263 mailbox_holder, mailbox_holder, mailbox_holder, | |
264 base::Bind(EmptyCallback), gfx::Size(10, 10), gfx::Rect(10, 10), | |
265 gfx::Size(10, 10), base::TimeDelta(), true); | |
266 FakeVideoFrameProvider provider; | |
267 provider.set_frame(video_frame); | |
268 | |
269 VideoLayerImpl* video_layer_impl = | |
270 impl.AddChildToRoot<VideoLayerImpl>(&provider, media::VIDEO_ROTATION_0); | |
271 video_layer_impl->SetBounds(layer_size); | |
272 video_layer_impl->SetContentBounds(layer_size); | |
273 video_layer_impl->SetDrawsContent(true); | |
274 | |
275 gfx::Rect occluded; | |
276 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); | |
277 | |
278 EXPECT_EQ(1u, impl.quad_list().size()); | |
279 const DrawQuad* draw_quad = impl.quad_list().ElementAt(0); | |
280 ASSERT_EQ(DrawQuad::YUV_VIDEO_CONTENT, draw_quad->material); | |
281 | |
282 const YUVVideoDrawQuad* yuv_draw_quad = | |
283 static_cast<const YUVVideoDrawQuad*>(draw_quad); | |
284 EXPECT_EQ(yuv_draw_quad->uv_tex_size.height() * 2, | |
285 yuv_draw_quad->ya_tex_size.height()); | |
286 EXPECT_EQ(yuv_draw_quad->uv_tex_size.width() * 2, | |
287 yuv_draw_quad->ya_tex_size.width()); | |
288 } | |
289 | |
248 } // namespace | 290 } // namespace |
249 } // namespace cc | 291 } // namespace cc |
OLD | NEW |