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

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

Issue 2892423004: cc: make texture draw quad of video overlay candidate. (Closed)
Patch Set: add unittests Created 3 years, 6 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') | no next file » | 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "cc/layers/video_frame_provider_client_impl.h" 9 #include "cc/layers/video_frame_provider_client_impl.h"
10 #include "cc/output/context_provider.h" 10 #include "cc/output/context_provider.h"
11 #include "cc/output/output_surface.h" 11 #include "cc/output/output_surface.h"
12 #include "cc/quads/draw_quad.h" 12 #include "cc/quads/draw_quad.h"
13 #include "cc/quads/stream_video_draw_quad.h"
14 #include "cc/quads/texture_draw_quad.h"
13 #include "cc/quads/yuv_video_draw_quad.h" 15 #include "cc/quads/yuv_video_draw_quad.h"
14 #include "cc/test/fake_video_frame_provider.h" 16 #include "cc/test/fake_video_frame_provider.h"
15 #include "cc/test/layer_test_common.h" 17 #include "cc/test/layer_test_common.h"
16 #include "cc/trees/single_thread_proxy.h" 18 #include "cc/trees/single_thread_proxy.h"
17 #include "media/base/video_frame.h" 19 #include "media/base/video_frame.h"
18 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
19 21
20 namespace cc { 22 namespace cc {
21 namespace { 23 namespace {
22 24
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 ASSERT_EQ(DrawQuad::YUV_VIDEO_CONTENT, draw_quad->material); 368 ASSERT_EQ(DrawQuad::YUV_VIDEO_CONTENT, draw_quad->material);
367 369
368 const YUVVideoDrawQuad* yuv_draw_quad = 370 const YUVVideoDrawQuad* yuv_draw_quad =
369 static_cast<const YUVVideoDrawQuad*>(draw_quad); 371 static_cast<const YUVVideoDrawQuad*>(draw_quad);
370 EXPECT_EQ(yuv_draw_quad->uv_tex_size.height(), 372 EXPECT_EQ(yuv_draw_quad->uv_tex_size.height(),
371 (yuv_draw_quad->ya_tex_size.height() + 1) / 2); 373 (yuv_draw_quad->ya_tex_size.height() + 1) / 2);
372 EXPECT_EQ(yuv_draw_quad->uv_tex_size.width(), 374 EXPECT_EQ(yuv_draw_quad->uv_tex_size.width(),
373 (yuv_draw_quad->ya_tex_size.width() + 1) / 2); 375 (yuv_draw_quad->ya_tex_size.width() + 1) / 2);
374 } 376 }
375 377
378 TEST(VideoLayerImplTest, NativeARGBFrameGeneratesStreamVideoQuad) {
379 gfx::Size layer_size(1000, 1000);
380 gfx::Size viewport_size(1000, 1000);
381
382 LayerTestCommon::LayerImplTest impl;
383 DebugSetImplThreadAndMainThreadBlocked(impl.task_runner_provider());
384
385 gpu::MailboxHolder mailbox_holders[media::VideoFrame::kMaxPlanes];
386 mailbox_holders[0].texture_target = GL_TEXTURE_EXTERNAL_OES;
387 mailbox_holders[0].mailbox.name[0] = 1;
388
389 gfx::Size resource_size = gfx::Size(10, 10);
390 scoped_refptr<media::VideoFrame> video_frame =
391 media::VideoFrame::WrapNativeTextures(
392 media::PIXEL_FORMAT_ARGB, mailbox_holders, base::Bind(EmptyCallback),
393 resource_size, gfx::Rect(10, 10), resource_size, base::TimeDelta());
394 ASSERT_TRUE(video_frame);
395 video_frame->metadata()->SetBoolean(media::VideoFrameMetadata::ALLOW_OVERLAY,
396 true);
397 FakeVideoFrameProvider provider;
398 provider.set_frame(video_frame);
399
400 VideoLayerImpl* video_layer_impl =
401 impl.AddChildToRoot<VideoLayerImpl>(&provider, media::VIDEO_ROTATION_0);
402 video_layer_impl->SetBounds(layer_size);
403 video_layer_impl->SetDrawsContent(true);
404 impl.host_impl()->active_tree()->BuildLayerListAndPropertyTreesForTesting();
405
406 gfx::Rect occluded;
407 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded);
408
409 EXPECT_EQ(1u, impl.quad_list().size());
410 const DrawQuad* draw_quad = impl.quad_list().ElementAt(0);
411 ASSERT_EQ(DrawQuad::STREAM_VIDEO_CONTENT, draw_quad->material);
412
413 const StreamVideoDrawQuad* video_draw_quad =
414 StreamVideoDrawQuad::MaterialCast(draw_quad);
415 EXPECT_EQ(video_draw_quad->resource_size_in_pixels(), resource_size);
416 }
417
418 TEST(VideoLayerImplTest, NativeARGBFrameGeneratesTextureQuad) {
419 gfx::Size layer_size(1000, 1000);
420 gfx::Size viewport_size(1000, 1000);
421
422 LayerTestCommon::LayerImplTest impl;
423 DebugSetImplThreadAndMainThreadBlocked(impl.task_runner_provider());
424
425 gpu::MailboxHolder mailbox_holders[media::VideoFrame::kMaxPlanes];
426 mailbox_holders[0].texture_target = GL_TEXTURE_2D;
427 mailbox_holders[0].mailbox.name[0] = 1;
428
429 gfx::Size resource_size = gfx::Size(10, 10);
430 scoped_refptr<media::VideoFrame> video_frame =
431 media::VideoFrame::WrapNativeTextures(
432 media::PIXEL_FORMAT_ARGB, mailbox_holders, base::Bind(EmptyCallback),
433 resource_size, gfx::Rect(10, 10), resource_size, base::TimeDelta());
434 ASSERT_TRUE(video_frame);
435 video_frame->metadata()->SetBoolean(media::VideoFrameMetadata::ALLOW_OVERLAY,
436 true);
437 FakeVideoFrameProvider provider;
438 provider.set_frame(video_frame);
439
440 VideoLayerImpl* video_layer_impl =
441 impl.AddChildToRoot<VideoLayerImpl>(&provider, media::VIDEO_ROTATION_0);
442 video_layer_impl->SetBounds(layer_size);
443 video_layer_impl->SetDrawsContent(true);
444 impl.host_impl()->active_tree()->BuildLayerListAndPropertyTreesForTesting();
445
446 gfx::Rect occluded;
447 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded);
448
449 EXPECT_EQ(1u, impl.quad_list().size());
450 const DrawQuad* draw_quad = impl.quad_list().ElementAt(0);
451 ASSERT_EQ(DrawQuad::TEXTURE_CONTENT, draw_quad->material);
452
453 const TextureDrawQuad* texture_draw_quad =
454 TextureDrawQuad::MaterialCast(draw_quad);
455 EXPECT_EQ(texture_draw_quad->resource_size_in_pixels(), resource_size);
456 }
457
376 } // namespace 458 } // namespace
377 } // namespace cc 459 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/video_layer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698