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.h" |
5 #include "cc/layers/video_layer_impl.h" | 6 #include "cc/layers/video_layer_impl.h" |
6 | 7 |
7 #include "cc/layers/video_frame_provider_client_impl.h" | 8 #include "cc/layers/video_frame_provider_client_impl.h" |
8 #include "cc/output/context_provider.h" | 9 #include "cc/output/context_provider.h" |
9 #include "cc/output/output_surface.h" | 10 #include "cc/output/output_surface.h" |
| 11 #include "cc/quads/draw_quad.h" |
10 #include "cc/test/fake_video_frame_provider.h" | 12 #include "cc/test/fake_video_frame_provider.h" |
11 #include "cc/test/layer_test_common.h" | 13 #include "cc/test/layer_test_common.h" |
12 #include "cc/trees/single_thread_proxy.h" | 14 #include "cc/trees/single_thread_proxy.h" |
13 #include "media/base/video_frame.h" | 15 #include "media/base/video_frame.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
15 | 17 |
16 namespace cc { | 18 namespace cc { |
17 namespace { | 19 namespace { |
18 | 20 |
19 TEST(VideoLayerImplTest, Occlusion) { | 21 TEST(VideoLayerImplTest, Occlusion) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 88 |
87 VideoFrameProviderClientImpl* client = | 89 VideoFrameProviderClientImpl* client = |
88 static_cast<VideoFrameProviderClientImpl*>(provider.client()); | 90 static_cast<VideoFrameProviderClientImpl*>(provider.client()); |
89 ASSERT_TRUE(client); | 91 ASSERT_TRUE(client); |
90 EXPECT_FALSE(client->active_video_layer()); | 92 EXPECT_FALSE(client->active_video_layer()); |
91 | 93 |
92 video_layer_impl->DidBecomeActive(); | 94 video_layer_impl->DidBecomeActive(); |
93 EXPECT_EQ(video_layer_impl, client->active_video_layer()); | 95 EXPECT_EQ(video_layer_impl, client->active_video_layer()); |
94 } | 96 } |
95 | 97 |
| 98 TEST(VideoLayerImplTest, Rotated0) { |
| 99 gfx::Size layer_size(100, 50); |
| 100 gfx::Size viewport_size(1000, 500); |
| 101 |
| 102 LayerTestCommon::LayerImplTest impl; |
| 103 DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy()); |
| 104 |
| 105 scoped_refptr<media::VideoFrame> video_frame = |
| 106 media::VideoFrame::CreateFrame(media::VideoFrame::YV12, |
| 107 gfx::Size(20, 10), |
| 108 gfx::Rect(20, 10), |
| 109 gfx::Size(20, 10), |
| 110 base::TimeDelta()); |
| 111 FakeVideoFrameProvider provider; |
| 112 provider.set_frame(video_frame); |
| 113 |
| 114 scoped_refptr<VideoLayer> video_layer = VideoLayer::Create(&provider); |
| 115 impl.host()->SetRootLayer(video_layer); |
| 116 video_layer->draw_properties().content_bounds = layer_size; |
| 117 video_layer->SetBounds(layer_size); |
| 118 video_layer->set_video_rotation(media::VIDEO_ROTATION_0); |
| 119 |
| 120 VideoLayerImpl* video_layer_impl = |
| 121 impl.AddChildToRoot<VideoLayerImpl>(&provider); |
| 122 |
| 123 video_layer->PushPropertiesTo(video_layer_impl); |
| 124 |
| 125 { |
| 126 SCOPED_TRACE("0 Degree Rotation"); |
| 127 // video_layer_impl->set_video_rotation(media::VIDEO_ROTATION_0); |
| 128 impl.CalcDrawProps(viewport_size); |
| 129 gfx::Rect occluded; |
| 130 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); |
| 131 |
| 132 EXPECT_EQ(1u, impl.quad_list().size()); |
| 133 EXPECT_EQ(gfx::Size(100, 50), impl.quad_list()[0]->rect.size()); |
| 134 |
| 135 gfx::Point3F p1(100, 0, 0); |
| 136 gfx::Point3F p2(0, 50, 0); |
| 137 impl.quad_list()[0]->quadTransform().TransformPoint(&p1); |
| 138 impl.quad_list()[0]->quadTransform().TransformPoint(&p2); |
| 139 EXPECT_EQ(gfx::Point3F(100, 0, 0), p1); |
| 140 EXPECT_EQ(gfx::Point3F(0, 50, 0), p2); |
| 141 } |
| 142 } |
| 143 |
| 144 TEST(VideoLayerImplTest, Rotated90) { |
| 145 gfx::Size layer_size(100, 50); |
| 146 gfx::Size viewport_size(1000, 500); |
| 147 |
| 148 LayerTestCommon::LayerImplTest impl; |
| 149 DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy()); |
| 150 |
| 151 scoped_refptr<media::VideoFrame> video_frame = |
| 152 media::VideoFrame::CreateFrame(media::VideoFrame::YV12, |
| 153 gfx::Size(20, 10), |
| 154 gfx::Rect(20, 10), |
| 155 gfx::Size(20, 10), |
| 156 base::TimeDelta()); |
| 157 FakeVideoFrameProvider provider; |
| 158 provider.set_frame(video_frame); |
| 159 |
| 160 scoped_refptr<VideoLayer> video_layer = VideoLayer::Create(&provider); |
| 161 impl.host()->SetRootLayer(video_layer); |
| 162 video_layer->draw_properties().content_bounds = layer_size; |
| 163 video_layer->SetBounds(layer_size); |
| 164 video_layer->set_video_rotation(media::VIDEO_ROTATION_90); |
| 165 |
| 166 VideoLayerImpl* video_layer_impl = |
| 167 impl.AddChildToRoot<VideoLayerImpl>(&provider); |
| 168 |
| 169 video_layer->PushPropertiesTo(video_layer_impl); |
| 170 |
| 171 { |
| 172 SCOPED_TRACE("90 Degree Rotation"); |
| 173 impl.CalcDrawProps(viewport_size); |
| 174 gfx::Rect occluded; |
| 175 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); |
| 176 |
| 177 EXPECT_EQ(1u, impl.quad_list().size()); |
| 178 EXPECT_EQ(gfx::Size(50, 100), impl.quad_list()[0]->rect.size()); |
| 179 |
| 180 gfx::Point3F p1(50, 0, 0); |
| 181 gfx::Point3F p2(0, 100, 0); |
| 182 impl.quad_list()[0]->quadTransform().TransformPoint(&p1); |
| 183 impl.quad_list()[0]->quadTransform().TransformPoint(&p2); |
| 184 EXPECT_EQ(gfx::Point3F(100, 50, 0), p1); |
| 185 EXPECT_EQ(gfx::Point3F(0, 0, 0), p2); |
| 186 } |
| 187 } |
| 188 |
| 189 TEST(VideoLayerImplTest, Rotated180) { |
| 190 gfx::Size layer_size(100, 50); |
| 191 gfx::Size viewport_size(1000, 500); |
| 192 |
| 193 LayerTestCommon::LayerImplTest impl; |
| 194 DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy()); |
| 195 |
| 196 scoped_refptr<media::VideoFrame> video_frame = |
| 197 media::VideoFrame::CreateFrame(media::VideoFrame::YV12, |
| 198 gfx::Size(20, 10), |
| 199 gfx::Rect(20, 10), |
| 200 gfx::Size(20, 10), |
| 201 base::TimeDelta()); |
| 202 FakeVideoFrameProvider provider; |
| 203 provider.set_frame(video_frame); |
| 204 |
| 205 scoped_refptr<VideoLayer> video_layer = VideoLayer::Create(&provider); |
| 206 impl.host()->SetRootLayer(video_layer); |
| 207 video_layer->draw_properties().content_bounds = layer_size; |
| 208 video_layer->SetBounds(layer_size); |
| 209 video_layer->set_video_rotation(media::VIDEO_ROTATION_180); |
| 210 |
| 211 VideoLayerImpl* video_layer_impl = |
| 212 impl.AddChildToRoot<VideoLayerImpl>(&provider); |
| 213 |
| 214 video_layer->PushPropertiesTo(video_layer_impl); |
| 215 |
| 216 { |
| 217 SCOPED_TRACE("180 Degree Rotation"); |
| 218 impl.CalcDrawProps(viewport_size); |
| 219 gfx::Rect occluded; |
| 220 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); |
| 221 |
| 222 EXPECT_EQ(1u, impl.quad_list().size()); |
| 223 EXPECT_EQ(gfx::Size(100, 50), impl.quad_list()[0]->rect.size()); |
| 224 |
| 225 gfx::Point3F p1(100, 0, 0); |
| 226 gfx::Point3F p2(0, 50, 0); |
| 227 impl.quad_list()[0]->quadTransform().TransformPoint(&p1); |
| 228 impl.quad_list()[0]->quadTransform().TransformPoint(&p2); |
| 229 EXPECT_EQ(gfx::Point3F(0, 50, 0), p1); |
| 230 EXPECT_EQ(gfx::Point3F(100, 0, 0), p2); |
| 231 } |
| 232 } |
| 233 |
| 234 TEST(VideoLayerImplTest, Rotated270) { |
| 235 gfx::Size layer_size(100, 50); |
| 236 gfx::Size viewport_size(1000, 500); |
| 237 |
| 238 LayerTestCommon::LayerImplTest impl; |
| 239 DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy()); |
| 240 |
| 241 scoped_refptr<media::VideoFrame> video_frame = |
| 242 media::VideoFrame::CreateFrame(media::VideoFrame::YV12, |
| 243 gfx::Size(20, 10), |
| 244 gfx::Rect(20, 10), |
| 245 gfx::Size(20, 10), |
| 246 base::TimeDelta()); |
| 247 FakeVideoFrameProvider provider; |
| 248 provider.set_frame(video_frame); |
| 249 |
| 250 scoped_refptr<VideoLayer> video_layer = VideoLayer::Create(&provider); |
| 251 impl.host()->SetRootLayer(video_layer); |
| 252 video_layer->draw_properties().content_bounds = layer_size; |
| 253 video_layer->SetBounds(layer_size); |
| 254 video_layer->set_video_rotation(media::VIDEO_ROTATION_270); |
| 255 |
| 256 VideoLayerImpl* video_layer_impl = |
| 257 impl.AddChildToRoot<VideoLayerImpl>(&provider); |
| 258 |
| 259 video_layer->PushPropertiesTo(video_layer_impl); |
| 260 |
| 261 { |
| 262 SCOPED_TRACE("270 Degree Rotation"); |
| 263 impl.CalcDrawProps(viewport_size); |
| 264 gfx::Rect occluded; |
| 265 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); |
| 266 |
| 267 EXPECT_EQ(1u, impl.quad_list().size()); |
| 268 EXPECT_EQ(gfx::Size(50, 100), impl.quad_list()[0]->rect.size()); |
| 269 |
| 270 gfx::Point3F p1(0, 100, 0); |
| 271 gfx::Point3F p2(50, 0, 0); |
| 272 impl.quad_list()[0]->quadTransform().TransformPoint(&p1); |
| 273 impl.quad_list()[0]->quadTransform().TransformPoint(&p2); |
| 274 EXPECT_EQ(gfx::Point3F(100, 50, 0), p1); |
| 275 EXPECT_EQ(gfx::Point3F(0, 0, 0), p2); |
| 276 } |
| 277 } |
| 278 |
96 } // namespace | 279 } // namespace |
97 } // namespace cc | 280 } // namespace cc |
OLD | NEW |