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 |
| 252 TEST(VideoLayerImplTest, SoftwareVideoFrameGeneratesYUVQuad) { |
| 253 gfx::Size layer_size(1000, 1000); |
| 254 gfx::Size viewport_size(1000, 1000); |
| 255 |
| 256 LayerTestCommon::LayerImplTest impl; |
| 257 DebugSetImplThreadAndMainThreadBlocked(impl.proxy()); |
| 258 |
| 259 gpu::MailboxHolder mailbox_holder; |
| 260 mailbox_holder.mailbox.name[0] = 1; |
| 261 |
| 262 scoped_refptr<media::VideoFrame> video_frame = media::VideoFrame::CreateFrame( |
| 263 media::VideoFrame::YV12, gfx::Size(20, 10), gfx::Rect(20, 10), |
| 264 gfx::Size(20, 10), base::TimeDelta()); |
| 265 |
| 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(), |
| 285 (yuv_draw_quad->ya_tex_size.height() + 1) / 2); |
| 286 EXPECT_EQ(yuv_draw_quad->uv_tex_size.width(), |
| 287 (yuv_draw_quad->ya_tex_size.width() + 1) / 2); |
| 288 } |
| 289 |
| 290 TEST(VideoLayerImplTest, NativeYUVFrameGeneratesYUVQuad) { |
| 291 gfx::Size layer_size(1000, 1000); |
| 292 gfx::Size viewport_size(1000, 1000); |
| 293 |
| 294 LayerTestCommon::LayerImplTest impl; |
| 295 DebugSetImplThreadAndMainThreadBlocked(impl.proxy()); |
| 296 |
| 297 gpu::MailboxHolder mailbox_holder; |
| 298 mailbox_holder.mailbox.name[0] = 1; |
| 299 |
| 300 scoped_refptr<media::VideoFrame> video_frame = |
| 301 media::VideoFrame::WrapYUV420NativeTextures( |
| 302 mailbox_holder, mailbox_holder, mailbox_holder, |
| 303 base::Bind(EmptyCallback), gfx::Size(10, 10), gfx::Rect(10, 10), |
| 304 gfx::Size(10, 10), base::TimeDelta(), true); |
| 305 FakeVideoFrameProvider provider; |
| 306 provider.set_frame(video_frame); |
| 307 |
| 308 VideoLayerImpl* video_layer_impl = |
| 309 impl.AddChildToRoot<VideoLayerImpl>(&provider, media::VIDEO_ROTATION_0); |
| 310 video_layer_impl->SetBounds(layer_size); |
| 311 video_layer_impl->SetContentBounds(layer_size); |
| 312 video_layer_impl->SetDrawsContent(true); |
| 313 |
| 314 gfx::Rect occluded; |
| 315 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); |
| 316 |
| 317 EXPECT_EQ(1u, impl.quad_list().size()); |
| 318 const DrawQuad* draw_quad = impl.quad_list().ElementAt(0); |
| 319 ASSERT_EQ(DrawQuad::YUV_VIDEO_CONTENT, draw_quad->material); |
| 320 |
| 321 const YUVVideoDrawQuad* yuv_draw_quad = |
| 322 static_cast<const YUVVideoDrawQuad*>(draw_quad); |
| 323 EXPECT_EQ(yuv_draw_quad->uv_tex_size.height(), |
| 324 (yuv_draw_quad->ya_tex_size.height() + 1) / 2); |
| 325 EXPECT_EQ(yuv_draw_quad->uv_tex_size.width(), |
| 326 (yuv_draw_quad->ya_tex_size.width() + 1) / 2); |
| 327 } |
| 328 |
248 } // namespace | 329 } // namespace |
249 } // namespace cc | 330 } // namespace cc |
OLD | NEW |