Chromium Code Reviews| Index: cc/layers/video_layer_impl_unittest.cc |
| diff --git a/cc/layers/video_layer_impl_unittest.cc b/cc/layers/video_layer_impl_unittest.cc |
| index 7a17eefd09492186fcabce76b0b14b9790c1ffa3..9f587b46b1822abf8ea35dff722d1adb2ead81d2 100644 |
| --- a/cc/layers/video_layer_impl_unittest.cc |
| +++ b/cc/layers/video_layer_impl_unittest.cc |
| @@ -2,11 +2,13 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#include "cc/layers/video_layer.h" |
| #include "cc/layers/video_layer_impl.h" |
| #include "cc/layers/video_frame_provider_client_impl.h" |
| #include "cc/output/context_provider.h" |
| #include "cc/output/output_surface.h" |
| +#include "cc/quads/draw_quad.h" |
| #include "cc/test/fake_video_frame_provider.h" |
| #include "cc/test/layer_test_common.h" |
| #include "cc/trees/single_thread_proxy.h" |
| @@ -93,5 +95,190 @@ TEST(VideoLayerImplTest, DidBecomeActiveShouldSetActiveVideoLayer) { |
| EXPECT_EQ(video_layer_impl, client->active_video_layer()); |
| } |
| +TEST(VideoLayerImplTest, Rotated0) { |
| + gfx::Size layer_size(100, 50); |
| + gfx::Size viewport_size(1000, 500); |
| + |
| + LayerTestCommon::LayerImplTest impl; |
| + DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy()); |
| + |
| + scoped_refptr<media::VideoFrame> video_frame = |
| + media::VideoFrame::CreateFrame(media::VideoFrame::YV12, |
| + gfx::Size(20, 10), |
| + gfx::Rect(20, 10), |
| + gfx::Size(20, 10), |
| + base::TimeDelta()); |
| + FakeVideoFrameProvider provider; |
| + provider.set_frame(video_frame); |
| + |
| + scoped_refptr<VideoLayer> video_layer = VideoLayer::Create(&provider); |
| + video_layer->SetLayerTreeHost(impl.host()); |
| + video_layer->draw_properties().content_bounds = layer_size; |
| + video_layer->SetBounds(layer_size); |
| + video_layer->set_video_rotation(media::VIDEO_ROTATION_0); |
| + |
| + VideoLayerImpl* video_layer_impl = |
| + impl.AddChildToRoot<VideoLayerImpl>(&provider); |
| + |
| + video_layer->PushPropertiesTo(video_layer_impl); |
| + |
| + { |
| + SCOPED_TRACE("0 Degree Rotation"); |
| + // video_layer_impl->set_video_rotation(media::VIDEO_ROTATION_0); |
| + impl.CalcDrawProps(viewport_size); |
| + gfx::Rect occluded; |
| + impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); |
| + |
| + EXPECT_EQ(1u, impl.quad_list().size()); |
| + EXPECT_EQ(gfx::Size(100, 50), impl.quad_list()[0]->rect.size()); |
| + |
| + gfx::Point3F p1(100, 0, 0); |
| + gfx::Point3F p2(0, 50, 0); |
| + impl.quad_list()[0]->quadTransform().TransformPoint(&p1); |
| + impl.quad_list()[0]->quadTransform().TransformPoint(&p2); |
| + EXPECT_EQ(gfx::Point3F(100, 0, 0), p1); |
| + EXPECT_EQ(gfx::Point3F(0, 50, 0), p2); |
| + } |
| + video_layer->SetLayerTreeHost(NULL); |
|
enne (OOO)
2014/07/23 21:46:53
Why does this need to happen? Won't the VideoLayer
suderman
2014/07/23 23:27:01
In this case the LayerTreeHost is provided by impl
enne (OOO)
2014/07/23 23:39:26
The VideoLayer has a raw/weak pointer to the Layer
|
| +} |
| + |
| +TEST(VideoLayerImplTest, Rotated90) { |
| + gfx::Size layer_size(100, 50); |
| + gfx::Size viewport_size(1000, 500); |
| + |
| + LayerTestCommon::LayerImplTest impl; |
| + DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy()); |
| + |
| + scoped_refptr<media::VideoFrame> video_frame = |
| + media::VideoFrame::CreateFrame(media::VideoFrame::YV12, |
| + gfx::Size(20, 10), |
| + gfx::Rect(20, 10), |
| + gfx::Size(20, 10), |
| + base::TimeDelta()); |
| + FakeVideoFrameProvider provider; |
| + provider.set_frame(video_frame); |
| + |
| + scoped_refptr<VideoLayer> video_layer = VideoLayer::Create(&provider); |
| + video_layer->SetLayerTreeHost(impl.host()); |
| + video_layer->draw_properties().content_bounds = layer_size; |
| + video_layer->SetBounds(layer_size); |
| + video_layer->set_video_rotation(media::VIDEO_ROTATION_90); |
| + |
| + VideoLayerImpl* video_layer_impl = |
| + impl.AddChildToRoot<VideoLayerImpl>(&provider); |
| + |
| + video_layer->PushPropertiesTo(video_layer_impl); |
| + |
| + { |
| + SCOPED_TRACE("90 Degree Rotation"); |
| + impl.CalcDrawProps(viewport_size); |
| + gfx::Rect occluded; |
| + impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); |
| + |
| + EXPECT_EQ(1u, impl.quad_list().size()); |
| + EXPECT_EQ(gfx::Size(50, 100), impl.quad_list()[0]->rect.size()); |
| + |
| + gfx::Point3F p1(50, 0, 0); |
| + gfx::Point3F p2(0, 100, 0); |
| + impl.quad_list()[0]->quadTransform().TransformPoint(&p1); |
| + impl.quad_list()[0]->quadTransform().TransformPoint(&p2); |
| + EXPECT_EQ(gfx::Point3F(100, 50, 0), p1); |
| + EXPECT_EQ(gfx::Point3F(0, 0, 0), p2); |
| + } |
| + video_layer->SetLayerTreeHost(NULL); |
| +} |
| + |
| +TEST(VideoLayerImplTest, Rotated180) { |
| + gfx::Size layer_size(100, 50); |
| + gfx::Size viewport_size(1000, 500); |
| + |
| + LayerTestCommon::LayerImplTest impl; |
| + DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy()); |
| + |
| + scoped_refptr<media::VideoFrame> video_frame = |
| + media::VideoFrame::CreateFrame(media::VideoFrame::YV12, |
| + gfx::Size(20, 10), |
| + gfx::Rect(20, 10), |
| + gfx::Size(20, 10), |
| + base::TimeDelta()); |
| + FakeVideoFrameProvider provider; |
| + provider.set_frame(video_frame); |
| + |
| + scoped_refptr<VideoLayer> video_layer = VideoLayer::Create(&provider); |
| + video_layer->SetLayerTreeHost(impl.host()); |
| + video_layer->draw_properties().content_bounds = layer_size; |
| + video_layer->SetBounds(layer_size); |
| + video_layer->set_video_rotation(media::VIDEO_ROTATION_180); |
| + |
| + VideoLayerImpl* video_layer_impl = |
| + impl.AddChildToRoot<VideoLayerImpl>(&provider); |
| + |
| + video_layer->PushPropertiesTo(video_layer_impl); |
| + |
| + { |
| + SCOPED_TRACE("180 Degree Rotation"); |
| + impl.CalcDrawProps(viewport_size); |
| + gfx::Rect occluded; |
| + impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); |
| + |
| + EXPECT_EQ(1u, impl.quad_list().size()); |
| + EXPECT_EQ(gfx::Size(100, 50), impl.quad_list()[0]->rect.size()); |
| + |
| + gfx::Point3F p1(100, 0, 0); |
| + gfx::Point3F p2(0, 50, 0); |
| + impl.quad_list()[0]->quadTransform().TransformPoint(&p1); |
| + impl.quad_list()[0]->quadTransform().TransformPoint(&p2); |
| + EXPECT_EQ(gfx::Point3F(0, 50, 0), p1); |
| + EXPECT_EQ(gfx::Point3F(100, 0, 0), p2); |
| + } |
| + video_layer->SetLayerTreeHost(NULL); |
| +} |
| + |
| +TEST(VideoLayerImplTest, Rotated270) { |
| + gfx::Size layer_size(100, 50); |
| + gfx::Size viewport_size(1000, 500); |
| + |
| + LayerTestCommon::LayerImplTest impl; |
| + DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy()); |
| + |
| + scoped_refptr<media::VideoFrame> video_frame = |
| + media::VideoFrame::CreateFrame(media::VideoFrame::YV12, |
| + gfx::Size(20, 10), |
| + gfx::Rect(20, 10), |
| + gfx::Size(20, 10), |
| + base::TimeDelta()); |
| + FakeVideoFrameProvider provider; |
| + provider.set_frame(video_frame); |
| + |
| + scoped_refptr<VideoLayer> video_layer = VideoLayer::Create(&provider); |
| + video_layer->SetLayerTreeHost(impl.host()); |
| + video_layer->draw_properties().content_bounds = layer_size; |
| + video_layer->SetBounds(layer_size); |
| + video_layer->set_video_rotation(media::VIDEO_ROTATION_270); |
| + |
| + VideoLayerImpl* video_layer_impl = |
| + impl.AddChildToRoot<VideoLayerImpl>(&provider); |
| + |
| + video_layer->PushPropertiesTo(video_layer_impl); |
| + |
| + { |
| + SCOPED_TRACE("270 Degree Rotation"); |
| + impl.CalcDrawProps(viewport_size); |
| + gfx::Rect occluded; |
| + impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); |
| + |
| + EXPECT_EQ(1u, impl.quad_list().size()); |
| + EXPECT_EQ(gfx::Size(50, 100), impl.quad_list()[0]->rect.size()); |
| + |
| + gfx::Point3F p1(0, 100, 0); |
| + gfx::Point3F p2(50, 0, 0); |
| + impl.quad_list()[0]->quadTransform().TransformPoint(&p1); |
| + impl.quad_list()[0]->quadTransform().TransformPoint(&p2); |
| + EXPECT_EQ(gfx::Point3F(100, 50, 0), p1); |
| + EXPECT_EQ(gfx::Point3F(0, 0, 0), p2); |
| + } |
| + video_layer->SetLayerTreeHost(NULL); |
| +} |
| + |
| } // namespace |
| } // namespace cc |