| 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" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 gfx::Size(10, 10), | 40 gfx::Size(10, 10), |
| 41 gfx::Rect(10, 10), | 41 gfx::Rect(10, 10), |
| 42 gfx::Size(10, 10), | 42 gfx::Size(10, 10), |
| 43 base::TimeDelta()); | 43 base::TimeDelta()); |
| 44 FakeVideoFrameProvider provider; | 44 FakeVideoFrameProvider provider; |
| 45 provider.set_frame(video_frame); | 45 provider.set_frame(video_frame); |
| 46 | 46 |
| 47 VideoLayerImpl* video_layer_impl = | 47 VideoLayerImpl* video_layer_impl = |
| 48 impl.AddChildToRoot<VideoLayerImpl>(&provider, media::VIDEO_ROTATION_0); | 48 impl.AddChildToRoot<VideoLayerImpl>(&provider, media::VIDEO_ROTATION_0); |
| 49 video_layer_impl->SetBounds(layer_size); | 49 video_layer_impl->SetBounds(layer_size); |
| 50 video_layer_impl->SetContentBounds(layer_size); | |
| 51 video_layer_impl->SetDrawsContent(true); | 50 video_layer_impl->SetDrawsContent(true); |
| 52 | 51 |
| 53 impl.CalcDrawProps(viewport_size); | 52 impl.CalcDrawProps(viewport_size); |
| 54 | 53 |
| 55 { | 54 { |
| 56 SCOPED_TRACE("No occlusion"); | 55 SCOPED_TRACE("No occlusion"); |
| 57 gfx::Rect occluded; | 56 gfx::Rect occluded; |
| 58 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); | 57 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); |
| 59 | 58 |
| 60 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), | 59 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), |
| (...skipping 30 matching lines...) Expand all Loading... |
| 91 | 90 |
| 92 LayerTestCommon::LayerImplTest impl; | 91 LayerTestCommon::LayerImplTest impl; |
| 93 impl.host_impl()->SetViewportSize(layer_size); | 92 impl.host_impl()->SetViewportSize(layer_size); |
| 94 DebugSetImplThreadAndMainThreadBlocked(impl.proxy()); | 93 DebugSetImplThreadAndMainThreadBlocked(impl.proxy()); |
| 95 auto active_tree = impl.host_impl()->active_tree(); | 94 auto active_tree = impl.host_impl()->active_tree(); |
| 96 | 95 |
| 97 // Create a video layer with no frame on top of another layer. | 96 // Create a video layer with no frame on top of another layer. |
| 98 scoped_ptr<LayerImpl> layer_impl = LayerImpl::Create(active_tree, 3); | 97 scoped_ptr<LayerImpl> layer_impl = LayerImpl::Create(active_tree, 3); |
| 99 layer_impl->SetHasRenderSurface(true); | 98 layer_impl->SetHasRenderSurface(true); |
| 100 layer_impl->SetBounds(layer_size); | 99 layer_impl->SetBounds(layer_size); |
| 101 layer_impl->SetContentBounds(layer_size); | |
| 102 layer_impl->SetDrawsContent(true); | 100 layer_impl->SetDrawsContent(true); |
| 103 const auto& draw_properties = layer_impl->draw_properties(); | 101 const auto& draw_properties = layer_impl->draw_properties(); |
| 104 | 102 |
| 105 FakeVideoFrameProvider provider; | 103 FakeVideoFrameProvider provider; |
| 106 scoped_ptr<VideoLayerImpl> video_layer_impl = VideoLayerImpl::Create( | 104 scoped_ptr<VideoLayerImpl> video_layer_impl = VideoLayerImpl::Create( |
| 107 active_tree, 4, &provider, media::VIDEO_ROTATION_0); | 105 active_tree, 4, &provider, media::VIDEO_ROTATION_0); |
| 108 video_layer_impl->SetBounds(layer_size); | 106 video_layer_impl->SetBounds(layer_size); |
| 109 video_layer_impl->SetContentBounds(layer_size); | |
| 110 video_layer_impl->SetDrawsContent(true); | 107 video_layer_impl->SetDrawsContent(true); |
| 111 video_layer_impl->SetContentsOpaque(true); | 108 video_layer_impl->SetContentsOpaque(true); |
| 112 | 109 |
| 113 layer_impl->AddChild(video_layer_impl.Pass()); | 110 layer_impl->AddChild(video_layer_impl.Pass()); |
| 114 active_tree->SetRootLayer(layer_impl.Pass()); | 111 active_tree->SetRootLayer(layer_impl.Pass()); |
| 115 | 112 |
| 116 active_tree->BuildPropertyTreesForTesting(); | 113 active_tree->BuildPropertyTreesForTesting(); |
| 117 | 114 |
| 118 active_tree->UpdateDrawProperties(false); | 115 active_tree->UpdateDrawProperties(false); |
| 119 | 116 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 gfx::Size(20, 10), | 157 gfx::Size(20, 10), |
| 161 gfx::Rect(20, 10), | 158 gfx::Rect(20, 10), |
| 162 gfx::Size(20, 10), | 159 gfx::Size(20, 10), |
| 163 base::TimeDelta()); | 160 base::TimeDelta()); |
| 164 FakeVideoFrameProvider provider; | 161 FakeVideoFrameProvider provider; |
| 165 provider.set_frame(video_frame); | 162 provider.set_frame(video_frame); |
| 166 | 163 |
| 167 VideoLayerImpl* video_layer_impl = | 164 VideoLayerImpl* video_layer_impl = |
| 168 impl.AddChildToRoot<VideoLayerImpl>(&provider, media::VIDEO_ROTATION_0); | 165 impl.AddChildToRoot<VideoLayerImpl>(&provider, media::VIDEO_ROTATION_0); |
| 169 video_layer_impl->SetBounds(layer_size); | 166 video_layer_impl->SetBounds(layer_size); |
| 170 video_layer_impl->SetContentBounds(layer_size); | |
| 171 video_layer_impl->SetDrawsContent(true); | 167 video_layer_impl->SetDrawsContent(true); |
| 172 | 168 |
| 173 impl.CalcDrawProps(viewport_size); | 169 impl.CalcDrawProps(viewport_size); |
| 174 gfx::Rect occluded; | 170 gfx::Rect occluded; |
| 175 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); | 171 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); |
| 176 | 172 |
| 177 EXPECT_EQ(1u, impl.quad_list().size()); | 173 EXPECT_EQ(1u, impl.quad_list().size()); |
| 178 | 174 |
| 179 gfx::Point3F p1(0, impl.quad_list().front()->rect.height(), 0); | 175 gfx::Point3F p1(0, impl.quad_list().front()->rect.height(), 0); |
| 180 gfx::Point3F p2(impl.quad_list().front()->rect.width(), 0, 0); | 176 gfx::Point3F p2(impl.quad_list().front()->rect.width(), 0, 0); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 200 gfx::Size(20, 10), | 196 gfx::Size(20, 10), |
| 201 gfx::Rect(20, 10), | 197 gfx::Rect(20, 10), |
| 202 gfx::Size(20, 10), | 198 gfx::Size(20, 10), |
| 203 base::TimeDelta()); | 199 base::TimeDelta()); |
| 204 FakeVideoFrameProvider provider; | 200 FakeVideoFrameProvider provider; |
| 205 provider.set_frame(video_frame); | 201 provider.set_frame(video_frame); |
| 206 | 202 |
| 207 VideoLayerImpl* video_layer_impl = | 203 VideoLayerImpl* video_layer_impl = |
| 208 impl.AddChildToRoot<VideoLayerImpl>(&provider, media::VIDEO_ROTATION_90); | 204 impl.AddChildToRoot<VideoLayerImpl>(&provider, media::VIDEO_ROTATION_90); |
| 209 video_layer_impl->SetBounds(layer_size); | 205 video_layer_impl->SetBounds(layer_size); |
| 210 video_layer_impl->SetContentBounds(layer_size); | |
| 211 video_layer_impl->SetDrawsContent(true); | 206 video_layer_impl->SetDrawsContent(true); |
| 212 | 207 |
| 213 impl.CalcDrawProps(viewport_size); | 208 impl.CalcDrawProps(viewport_size); |
| 214 gfx::Rect occluded; | 209 gfx::Rect occluded; |
| 215 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); | 210 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); |
| 216 | 211 |
| 217 EXPECT_EQ(1u, impl.quad_list().size()); | 212 EXPECT_EQ(1u, impl.quad_list().size()); |
| 218 | 213 |
| 219 gfx::Point3F p1(0, impl.quad_list().front()->rect.height(), 0); | 214 gfx::Point3F p1(0, impl.quad_list().front()->rect.height(), 0); |
| 220 gfx::Point3F p2(impl.quad_list().front()->rect.width(), 0, 0); | 215 gfx::Point3F p2(impl.quad_list().front()->rect.width(), 0, 0); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 240 gfx::Size(20, 10), | 235 gfx::Size(20, 10), |
| 241 gfx::Rect(20, 10), | 236 gfx::Rect(20, 10), |
| 242 gfx::Size(20, 10), | 237 gfx::Size(20, 10), |
| 243 base::TimeDelta()); | 238 base::TimeDelta()); |
| 244 FakeVideoFrameProvider provider; | 239 FakeVideoFrameProvider provider; |
| 245 provider.set_frame(video_frame); | 240 provider.set_frame(video_frame); |
| 246 | 241 |
| 247 VideoLayerImpl* video_layer_impl = | 242 VideoLayerImpl* video_layer_impl = |
| 248 impl.AddChildToRoot<VideoLayerImpl>(&provider, media::VIDEO_ROTATION_180); | 243 impl.AddChildToRoot<VideoLayerImpl>(&provider, media::VIDEO_ROTATION_180); |
| 249 video_layer_impl->SetBounds(layer_size); | 244 video_layer_impl->SetBounds(layer_size); |
| 250 video_layer_impl->SetContentBounds(layer_size); | |
| 251 video_layer_impl->SetDrawsContent(true); | 245 video_layer_impl->SetDrawsContent(true); |
| 252 | 246 |
| 253 impl.CalcDrawProps(viewport_size); | 247 impl.CalcDrawProps(viewport_size); |
| 254 gfx::Rect occluded; | 248 gfx::Rect occluded; |
| 255 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); | 249 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); |
| 256 | 250 |
| 257 EXPECT_EQ(1u, impl.quad_list().size()); | 251 EXPECT_EQ(1u, impl.quad_list().size()); |
| 258 | 252 |
| 259 gfx::Point3F p1(0, impl.quad_list().front()->rect.height(), 0); | 253 gfx::Point3F p1(0, impl.quad_list().front()->rect.height(), 0); |
| 260 gfx::Point3F p2(impl.quad_list().front()->rect.width(), 0, 0); | 254 gfx::Point3F p2(impl.quad_list().front()->rect.width(), 0, 0); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 280 gfx::Size(20, 10), | 274 gfx::Size(20, 10), |
| 281 gfx::Rect(20, 10), | 275 gfx::Rect(20, 10), |
| 282 gfx::Size(20, 10), | 276 gfx::Size(20, 10), |
| 283 base::TimeDelta()); | 277 base::TimeDelta()); |
| 284 FakeVideoFrameProvider provider; | 278 FakeVideoFrameProvider provider; |
| 285 provider.set_frame(video_frame); | 279 provider.set_frame(video_frame); |
| 286 | 280 |
| 287 VideoLayerImpl* video_layer_impl = | 281 VideoLayerImpl* video_layer_impl = |
| 288 impl.AddChildToRoot<VideoLayerImpl>(&provider, media::VIDEO_ROTATION_270); | 282 impl.AddChildToRoot<VideoLayerImpl>(&provider, media::VIDEO_ROTATION_270); |
| 289 video_layer_impl->SetBounds(layer_size); | 283 video_layer_impl->SetBounds(layer_size); |
| 290 video_layer_impl->SetContentBounds(layer_size); | |
| 291 video_layer_impl->SetDrawsContent(true); | 284 video_layer_impl->SetDrawsContent(true); |
| 292 | 285 |
| 293 impl.CalcDrawProps(viewport_size); | 286 impl.CalcDrawProps(viewport_size); |
| 294 gfx::Rect occluded; | 287 gfx::Rect occluded; |
| 295 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); | 288 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); |
| 296 | 289 |
| 297 EXPECT_EQ(1u, impl.quad_list().size()); | 290 EXPECT_EQ(1u, impl.quad_list().size()); |
| 298 | 291 |
| 299 gfx::Point3F p1(0, impl.quad_list().front()->rect.height(), 0); | 292 gfx::Point3F p1(0, impl.quad_list().front()->rect.height(), 0); |
| 300 gfx::Point3F p2(impl.quad_list().front()->rect.width(), 0, 0); | 293 gfx::Point3F p2(impl.quad_list().front()->rect.width(), 0, 0); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 324 scoped_refptr<media::VideoFrame> video_frame = media::VideoFrame::CreateFrame( | 317 scoped_refptr<media::VideoFrame> video_frame = media::VideoFrame::CreateFrame( |
| 325 media::VideoFrame::YV12, gfx::Size(20, 10), gfx::Rect(20, 10), | 318 media::VideoFrame::YV12, gfx::Size(20, 10), gfx::Rect(20, 10), |
| 326 gfx::Size(20, 10), base::TimeDelta()); | 319 gfx::Size(20, 10), base::TimeDelta()); |
| 327 | 320 |
| 328 FakeVideoFrameProvider provider; | 321 FakeVideoFrameProvider provider; |
| 329 provider.set_frame(video_frame); | 322 provider.set_frame(video_frame); |
| 330 | 323 |
| 331 VideoLayerImpl* video_layer_impl = | 324 VideoLayerImpl* video_layer_impl = |
| 332 impl.AddChildToRoot<VideoLayerImpl>(&provider, media::VIDEO_ROTATION_0); | 325 impl.AddChildToRoot<VideoLayerImpl>(&provider, media::VIDEO_ROTATION_0); |
| 333 video_layer_impl->SetBounds(layer_size); | 326 video_layer_impl->SetBounds(layer_size); |
| 334 video_layer_impl->SetContentBounds(layer_size); | |
| 335 video_layer_impl->SetDrawsContent(true); | 327 video_layer_impl->SetDrawsContent(true); |
| 336 | 328 |
| 337 gfx::Rect occluded; | 329 gfx::Rect occluded; |
| 338 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); | 330 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); |
| 339 | 331 |
| 340 EXPECT_EQ(1u, impl.quad_list().size()); | 332 EXPECT_EQ(1u, impl.quad_list().size()); |
| 341 const DrawQuad* draw_quad = impl.quad_list().ElementAt(0); | 333 const DrawQuad* draw_quad = impl.quad_list().ElementAt(0); |
| 342 ASSERT_EQ(DrawQuad::YUV_VIDEO_CONTENT, draw_quad->material); | 334 ASSERT_EQ(DrawQuad::YUV_VIDEO_CONTENT, draw_quad->material); |
| 343 | 335 |
| 344 const YUVVideoDrawQuad* yuv_draw_quad = | 336 const YUVVideoDrawQuad* yuv_draw_quad = |
| (...skipping 20 matching lines...) Expand all Loading... |
| 365 base::Bind(EmptyCallback), gfx::Size(10, 10), gfx::Rect(10, 10), | 357 base::Bind(EmptyCallback), gfx::Size(10, 10), gfx::Rect(10, 10), |
| 366 gfx::Size(10, 10), base::TimeDelta()); | 358 gfx::Size(10, 10), base::TimeDelta()); |
| 367 video_frame->metadata()->SetBoolean(media::VideoFrameMetadata::ALLOW_OVERLAY, | 359 video_frame->metadata()->SetBoolean(media::VideoFrameMetadata::ALLOW_OVERLAY, |
| 368 true); | 360 true); |
| 369 FakeVideoFrameProvider provider; | 361 FakeVideoFrameProvider provider; |
| 370 provider.set_frame(video_frame); | 362 provider.set_frame(video_frame); |
| 371 | 363 |
| 372 VideoLayerImpl* video_layer_impl = | 364 VideoLayerImpl* video_layer_impl = |
| 373 impl.AddChildToRoot<VideoLayerImpl>(&provider, media::VIDEO_ROTATION_0); | 365 impl.AddChildToRoot<VideoLayerImpl>(&provider, media::VIDEO_ROTATION_0); |
| 374 video_layer_impl->SetBounds(layer_size); | 366 video_layer_impl->SetBounds(layer_size); |
| 375 video_layer_impl->SetContentBounds(layer_size); | |
| 376 video_layer_impl->SetDrawsContent(true); | 367 video_layer_impl->SetDrawsContent(true); |
| 377 | 368 |
| 378 gfx::Rect occluded; | 369 gfx::Rect occluded; |
| 379 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); | 370 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); |
| 380 | 371 |
| 381 EXPECT_EQ(1u, impl.quad_list().size()); | 372 EXPECT_EQ(1u, impl.quad_list().size()); |
| 382 const DrawQuad* draw_quad = impl.quad_list().ElementAt(0); | 373 const DrawQuad* draw_quad = impl.quad_list().ElementAt(0); |
| 383 ASSERT_EQ(DrawQuad::YUV_VIDEO_CONTENT, draw_quad->material); | 374 ASSERT_EQ(DrawQuad::YUV_VIDEO_CONTENT, draw_quad->material); |
| 384 | 375 |
| 385 const YUVVideoDrawQuad* yuv_draw_quad = | 376 const YUVVideoDrawQuad* yuv_draw_quad = |
| 386 static_cast<const YUVVideoDrawQuad*>(draw_quad); | 377 static_cast<const YUVVideoDrawQuad*>(draw_quad); |
| 387 EXPECT_EQ(yuv_draw_quad->uv_tex_size.height(), | 378 EXPECT_EQ(yuv_draw_quad->uv_tex_size.height(), |
| 388 (yuv_draw_quad->ya_tex_size.height() + 1) / 2); | 379 (yuv_draw_quad->ya_tex_size.height() + 1) / 2); |
| 389 EXPECT_EQ(yuv_draw_quad->uv_tex_size.width(), | 380 EXPECT_EQ(yuv_draw_quad->uv_tex_size.width(), |
| 390 (yuv_draw_quad->ya_tex_size.width() + 1) / 2); | 381 (yuv_draw_quad->ya_tex_size.width() + 1) / 2); |
| 391 } | 382 } |
| 392 | 383 |
| 393 } // namespace | 384 } // namespace |
| 394 } // namespace cc | 385 } // namespace cc |
| OLD | NEW |