| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/ptr_util.h" |
| 11 #include "cc/layers/video_frame_provider_client_impl.h" | 12 #include "cc/layers/video_frame_provider_client_impl.h" |
| 12 #include "cc/quads/io_surface_draw_quad.h" | 13 #include "cc/quads/io_surface_draw_quad.h" |
| 13 #include "cc/quads/stream_video_draw_quad.h" | 14 #include "cc/quads/stream_video_draw_quad.h" |
| 14 #include "cc/quads/texture_draw_quad.h" | 15 #include "cc/quads/texture_draw_quad.h" |
| 15 #include "cc/quads/yuv_video_draw_quad.h" | 16 #include "cc/quads/yuv_video_draw_quad.h" |
| 16 #include "cc/resources/resource_provider.h" | 17 #include "cc/resources/resource_provider.h" |
| 17 #include "cc/resources/single_release_callback_impl.h" | 18 #include "cc/resources/single_release_callback_impl.h" |
| 18 #include "cc/trees/layer_tree_impl.h" | 19 #include "cc/trees/layer_tree_impl.h" |
| 19 #include "cc/trees/occlusion.h" | 20 #include "cc/trees/occlusion.h" |
| 20 #include "cc/trees/task_runner_provider.h" | 21 #include "cc/trees/task_runner_provider.h" |
| 21 #include "media/base/video_frame.h" | 22 #include "media/base/video_frame.h" |
| 22 | 23 |
| 23 #if defined(VIDEO_HOLE) | 24 #if defined(VIDEO_HOLE) |
| 24 #include "cc/quads/solid_color_draw_quad.h" | 25 #include "cc/quads/solid_color_draw_quad.h" |
| 25 #endif // defined(VIDEO_HOLE) | 26 #endif // defined(VIDEO_HOLE) |
| 26 | 27 |
| 27 namespace cc { | 28 namespace cc { |
| 28 | 29 |
| 29 // static | 30 // static |
| 30 scoped_ptr<VideoLayerImpl> VideoLayerImpl::Create( | 31 std::unique_ptr<VideoLayerImpl> VideoLayerImpl::Create( |
| 31 LayerTreeImpl* tree_impl, | 32 LayerTreeImpl* tree_impl, |
| 32 int id, | 33 int id, |
| 33 VideoFrameProvider* provider, | 34 VideoFrameProvider* provider, |
| 34 media::VideoRotation video_rotation) { | 35 media::VideoRotation video_rotation) { |
| 35 DCHECK(tree_impl->task_runner_provider()->IsMainThreadBlocked()); | 36 DCHECK(tree_impl->task_runner_provider()->IsMainThreadBlocked()); |
| 36 DCHECK(tree_impl->task_runner_provider()->IsImplThread()); | 37 DCHECK(tree_impl->task_runner_provider()->IsImplThread()); |
| 37 | 38 |
| 38 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl = | 39 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl = |
| 39 VideoFrameProviderClientImpl::Create( | 40 VideoFrameProviderClientImpl::Create( |
| 40 provider, tree_impl->GetVideoFrameControllerClient()); | 41 provider, tree_impl->GetVideoFrameControllerClient()); |
| 41 | 42 |
| 42 return make_scoped_ptr(new VideoLayerImpl( | 43 return base::WrapUnique(new VideoLayerImpl( |
| 43 tree_impl, id, std::move(provider_client_impl), video_rotation)); | 44 tree_impl, id, std::move(provider_client_impl), video_rotation)); |
| 44 } | 45 } |
| 45 | 46 |
| 46 VideoLayerImpl::VideoLayerImpl( | 47 VideoLayerImpl::VideoLayerImpl( |
| 47 LayerTreeImpl* tree_impl, | 48 LayerTreeImpl* tree_impl, |
| 48 int id, | 49 int id, |
| 49 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl, | 50 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl, |
| 50 media::VideoRotation video_rotation) | 51 media::VideoRotation video_rotation) |
| 51 : LayerImpl(tree_impl, id), | 52 : LayerImpl(tree_impl, id), |
| 52 provider_client_impl_(std::move(provider_client_impl)), | 53 provider_client_impl_(std::move(provider_client_impl)), |
| 53 frame_(nullptr), | 54 frame_(nullptr), |
| 54 video_rotation_(video_rotation) {} | 55 video_rotation_(video_rotation) {} |
| 55 | 56 |
| 56 VideoLayerImpl::~VideoLayerImpl() { | 57 VideoLayerImpl::~VideoLayerImpl() { |
| 57 if (!provider_client_impl_->Stopped()) { | 58 if (!provider_client_impl_->Stopped()) { |
| 58 // In impl side painting, we may have a pending and active layer | 59 // In impl side painting, we may have a pending and active layer |
| 59 // associated with the video provider at the same time. Both have a ref | 60 // associated with the video provider at the same time. Both have a ref |
| 60 // on the VideoFrameProviderClientImpl, but we stop when the first | 61 // on the VideoFrameProviderClientImpl, but we stop when the first |
| 61 // LayerImpl (the one on the pending tree) is destroyed since we know | 62 // LayerImpl (the one on the pending tree) is destroyed since we know |
| 62 // the main thread is blocked for this commit. | 63 // the main thread is blocked for this commit. |
| 63 DCHECK(layer_tree_impl()->task_runner_provider()->IsImplThread()); | 64 DCHECK(layer_tree_impl()->task_runner_provider()->IsImplThread()); |
| 64 DCHECK(layer_tree_impl()->task_runner_provider()->IsMainThreadBlocked()); | 65 DCHECK(layer_tree_impl()->task_runner_provider()->IsMainThreadBlocked()); |
| 65 provider_client_impl_->Stop(); | 66 provider_client_impl_->Stop(); |
| 66 } | 67 } |
| 67 } | 68 } |
| 68 | 69 |
| 69 scoped_ptr<LayerImpl> VideoLayerImpl::CreateLayerImpl( | 70 std::unique_ptr<LayerImpl> VideoLayerImpl::CreateLayerImpl( |
| 70 LayerTreeImpl* tree_impl) { | 71 LayerTreeImpl* tree_impl) { |
| 71 return make_scoped_ptr(new VideoLayerImpl( | 72 return base::WrapUnique(new VideoLayerImpl( |
| 72 tree_impl, id(), provider_client_impl_, video_rotation_)); | 73 tree_impl, id(), provider_client_impl_, video_rotation_)); |
| 73 } | 74 } |
| 74 | 75 |
| 75 void VideoLayerImpl::DidBecomeActive() { | 76 void VideoLayerImpl::DidBecomeActive() { |
| 76 provider_client_impl_->SetActiveVideoLayer(this); | 77 provider_client_impl_->SetActiveVideoLayer(this); |
| 77 } | 78 } |
| 78 | 79 |
| 79 bool VideoLayerImpl::WillDraw(DrawMode draw_mode, | 80 bool VideoLayerImpl::WillDraw(DrawMode draw_mode, |
| 80 ResourceProvider* resource_provider) { | 81 ResourceProvider* resource_provider) { |
| 81 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) | 82 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 void VideoLayerImpl::SetNeedsRedraw() { | 413 void VideoLayerImpl::SetNeedsRedraw() { |
| 413 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::Rect(bounds()))); | 414 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::Rect(bounds()))); |
| 414 layer_tree_impl()->SetNeedsRedraw(); | 415 layer_tree_impl()->SetNeedsRedraw(); |
| 415 } | 416 } |
| 416 | 417 |
| 417 const char* VideoLayerImpl::LayerTypeAsString() const { | 418 const char* VideoLayerImpl::LayerTypeAsString() const { |
| 418 return "cc::VideoLayerImpl"; | 419 return "cc::VideoLayerImpl"; |
| 419 } | 420 } |
| 420 | 421 |
| 421 } // namespace cc | 422 } // namespace cc |
| OLD | NEW |