| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "cc/layers/video_frame_provider_client_impl.h" | 9 #include "cc/layers/video_frame_provider_client_impl.h" |
| 10 #include "cc/quads/io_surface_draw_quad.h" | 10 #include "cc/quads/io_surface_draw_quad.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #endif // defined(VIDEO_HOLE) | 23 #endif // defined(VIDEO_HOLE) |
| 24 | 24 |
| 25 namespace cc { | 25 namespace cc { |
| 26 | 26 |
| 27 // static | 27 // static |
| 28 scoped_ptr<VideoLayerImpl> VideoLayerImpl::Create( | 28 scoped_ptr<VideoLayerImpl> VideoLayerImpl::Create( |
| 29 LayerTreeImpl* tree_impl, | 29 LayerTreeImpl* tree_impl, |
| 30 int id, | 30 int id, |
| 31 VideoFrameProvider* provider, | 31 VideoFrameProvider* provider, |
| 32 media::VideoRotation video_rotation) { | 32 media::VideoRotation video_rotation) { |
| 33 scoped_ptr<VideoLayerImpl> layer( | 33 DCHECK(tree_impl->proxy()->IsMainThreadBlocked()); |
| 34 new VideoLayerImpl(tree_impl, id, video_rotation)); | |
| 35 layer->SetProviderClientImpl(VideoFrameProviderClientImpl::Create(provider)); | |
| 36 DCHECK(tree_impl->proxy()->IsImplThread()); | 34 DCHECK(tree_impl->proxy()->IsImplThread()); |
| 37 DCHECK(tree_impl->proxy()->IsMainThreadBlocked()); | 35 |
| 38 return layer.Pass(); | 36 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl = |
| 37 VideoFrameProviderClientImpl::Create(provider); |
| 38 |
| 39 return make_scoped_ptr( |
| 40 new VideoLayerImpl(tree_impl, id, provider_client_impl, video_rotation)); |
| 39 } | 41 } |
| 40 | 42 |
| 41 VideoLayerImpl::VideoLayerImpl(LayerTreeImpl* tree_impl, | 43 VideoLayerImpl::VideoLayerImpl( |
| 42 int id, | 44 LayerTreeImpl* tree_impl, |
| 43 media::VideoRotation video_rotation) | 45 int id, |
| 46 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl, |
| 47 media::VideoRotation video_rotation) |
| 44 : LayerImpl(tree_impl, id), | 48 : LayerImpl(tree_impl, id), |
| 49 provider_client_impl_(provider_client_impl), |
| 45 frame_(nullptr), | 50 frame_(nullptr), |
| 46 video_rotation_(video_rotation) { | 51 video_rotation_(video_rotation) { |
| 47 } | 52 } |
| 48 | 53 |
| 49 VideoLayerImpl::~VideoLayerImpl() { | 54 VideoLayerImpl::~VideoLayerImpl() { |
| 50 if (!provider_client_impl_->Stopped()) { | 55 if (!provider_client_impl_->Destroyed()) { |
| 51 // In impl side painting, we may have a pending and active layer | 56 // In impl side painting, we may have a pending and active layer |
| 52 // associated with the video provider at the same time. Both have a ref | 57 // associated with the video provider at the same time. Both have a ref |
| 53 // on the VideoFrameProviderClientImpl, but we stop when the first | 58 // on the VideoFrameProviderClientImpl, but we stop when the first |
| 54 // LayerImpl (the one on the pending tree) is destroyed since we know | 59 // LayerImpl (the one on the pending tree) is destroyed since we know |
| 55 // the main thread is blocked for this commit. | 60 // the main thread is blocked for this commit. |
| 56 DCHECK(layer_tree_impl()->proxy()->IsImplThread()); | 61 DCHECK(layer_tree_impl()->proxy()->IsImplThread()); |
| 57 DCHECK(layer_tree_impl()->proxy()->IsMainThreadBlocked()); | 62 DCHECK(layer_tree_impl()->proxy()->IsMainThreadBlocked()); |
| 58 provider_client_impl_->Stop(); | 63 provider_client_impl_->Destroy(); |
| 59 } | 64 } |
| 60 } | 65 } |
| 61 | 66 |
| 62 scoped_ptr<LayerImpl> VideoLayerImpl::CreateLayerImpl( | 67 scoped_ptr<LayerImpl> VideoLayerImpl::CreateLayerImpl( |
| 63 LayerTreeImpl* tree_impl) { | 68 LayerTreeImpl* tree_impl) { |
| 64 return make_scoped_ptr(new VideoLayerImpl(tree_impl, id(), video_rotation_)); | 69 return make_scoped_ptr(new VideoLayerImpl( |
| 65 } | 70 tree_impl, id(), provider_client_impl_, video_rotation_)); |
| 66 | |
| 67 void VideoLayerImpl::PushPropertiesTo(LayerImpl* layer) { | |
| 68 LayerImpl::PushPropertiesTo(layer); | |
| 69 | |
| 70 VideoLayerImpl* other = static_cast<VideoLayerImpl*>(layer); | |
| 71 other->SetProviderClientImpl(provider_client_impl_); | |
| 72 } | 71 } |
| 73 | 72 |
| 74 void VideoLayerImpl::DidBecomeActive() { | 73 void VideoLayerImpl::DidBecomeActive() { |
| 75 provider_client_impl_->SetActiveVideoLayer(this); | 74 provider_client_impl_->SetActiveVideoLayer(this); |
| 76 } | 75 } |
| 77 | 76 |
| 78 bool VideoLayerImpl::WillDraw(DrawMode draw_mode, | 77 bool VideoLayerImpl::WillDraw(DrawMode draw_mode, |
| 79 ResourceProvider* resource_provider) { | 78 ResourceProvider* resource_provider) { |
| 80 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) | 79 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) |
| 81 return false; | 80 return false; |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 } | 267 } |
| 269 case VideoFrameExternalResources::STREAM_TEXTURE_RESOURCE: { | 268 case VideoFrameExternalResources::STREAM_TEXTURE_RESOURCE: { |
| 270 DCHECK_EQ(frame_resources_.size(), 1u); | 269 DCHECK_EQ(frame_resources_.size(), 1u); |
| 271 if (frame_resources_.size() < 1u) | 270 if (frame_resources_.size() < 1u) |
| 272 break; | 271 break; |
| 273 gfx::Transform scale; | 272 gfx::Transform scale; |
| 274 scale.Scale(tex_width_scale, tex_height_scale); | 273 scale.Scale(tex_width_scale, tex_height_scale); |
| 275 StreamVideoDrawQuad* stream_video_quad = | 274 StreamVideoDrawQuad* stream_video_quad = |
| 276 render_pass->CreateAndAppendDrawQuad<StreamVideoDrawQuad>(); | 275 render_pass->CreateAndAppendDrawQuad<StreamVideoDrawQuad>(); |
| 277 stream_video_quad->SetNew( | 276 stream_video_quad->SetNew( |
| 278 shared_quad_state, | 277 shared_quad_state, quad_rect, opaque_rect, visible_quad_rect, |
| 279 quad_rect, | |
| 280 opaque_rect, | |
| 281 visible_quad_rect, | |
| 282 frame_resources_[0], | 278 frame_resources_[0], |
| 283 scale * provider_client_impl_->stream_texture_matrix()); | 279 scale * provider_client_impl_->StreamTextureMatrix()); |
| 284 break; | 280 break; |
| 285 } | 281 } |
| 286 case VideoFrameExternalResources::IO_SURFACE: { | 282 case VideoFrameExternalResources::IO_SURFACE: { |
| 287 DCHECK_EQ(frame_resources_.size(), 1u); | 283 DCHECK_EQ(frame_resources_.size(), 1u); |
| 288 if (frame_resources_.size() < 1u) | 284 if (frame_resources_.size() < 1u) |
| 289 break; | 285 break; |
| 290 IOSurfaceDrawQuad* io_surface_quad = | 286 IOSurfaceDrawQuad* io_surface_quad = |
| 291 render_pass->CreateAndAppendDrawQuad<IOSurfaceDrawQuad>(); | 287 render_pass->CreateAndAppendDrawQuad<IOSurfaceDrawQuad>(); |
| 292 io_surface_quad->SetNew(shared_quad_state, | 288 io_surface_quad->SetNew(shared_quad_state, |
| 293 quad_rect, | 289 quad_rect, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 | 353 |
| 358 void VideoLayerImpl::ReleaseResources() { | 354 void VideoLayerImpl::ReleaseResources() { |
| 359 updater_ = nullptr; | 355 updater_ = nullptr; |
| 360 } | 356 } |
| 361 | 357 |
| 362 void VideoLayerImpl::SetNeedsRedraw() { | 358 void VideoLayerImpl::SetNeedsRedraw() { |
| 363 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::Rect(bounds()))); | 359 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::Rect(bounds()))); |
| 364 layer_tree_impl()->SetNeedsRedraw(); | 360 layer_tree_impl()->SetNeedsRedraw(); |
| 365 } | 361 } |
| 366 | 362 |
| 367 void VideoLayerImpl::SetProviderClientImpl( | |
| 368 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl) { | |
| 369 provider_client_impl_ = provider_client_impl; | |
| 370 } | |
| 371 | |
| 372 const char* VideoLayerImpl::LayerTypeAsString() const { | 363 const char* VideoLayerImpl::LayerTypeAsString() const { |
| 373 return "cc::VideoLayerImpl"; | 364 return "cc::VideoLayerImpl"; |
| 374 } | 365 } |
| 375 | 366 |
| 376 } // namespace cc | 367 } // namespace cc |
| OLD | NEW |