| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 // LayerImpl (the one on the pending tree) is destroyed since we know | 52 // LayerImpl (the one on the pending tree) is destroyed since we know |
| 53 // the main thread is blocked for this commit. | 53 // the main thread is blocked for this commit. |
| 54 DCHECK(layer_tree_impl()->proxy()->IsImplThread()); | 54 DCHECK(layer_tree_impl()->proxy()->IsImplThread()); |
| 55 DCHECK(layer_tree_impl()->proxy()->IsMainThreadBlocked()); | 55 DCHECK(layer_tree_impl()->proxy()->IsMainThreadBlocked()); |
| 56 provider_client_impl_->Stop(); | 56 provider_client_impl_->Stop(); |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 | 59 |
| 60 scoped_ptr<LayerImpl> VideoLayerImpl::CreateLayerImpl( | 60 scoped_ptr<LayerImpl> VideoLayerImpl::CreateLayerImpl( |
| 61 LayerTreeImpl* tree_impl) { | 61 LayerTreeImpl* tree_impl) { |
| 62 return make_scoped_ptr(new VideoLayerImpl(tree_impl, id(), video_rotation_)); | 62 VideoLayerImpl* impl = new VideoLayerImpl(tree_impl, id(), video_rotation_); |
| 63 return scoped_ptr<LayerImpl>(impl); |
| 63 } | 64 } |
| 64 | 65 |
| 65 void VideoLayerImpl::PushPropertiesTo(LayerImpl* layer) { | 66 void VideoLayerImpl::PushPropertiesTo(LayerImpl* layer) { |
| 66 LayerImpl::PushPropertiesTo(layer); | 67 LayerImpl::PushPropertiesTo(layer); |
| 67 | 68 |
| 68 VideoLayerImpl* other = static_cast<VideoLayerImpl*>(layer); | 69 VideoLayerImpl* other = static_cast<VideoLayerImpl*>(layer); |
| 69 other->SetProviderClientImpl(provider_client_impl_); | 70 other->SetProviderClientImpl(provider_client_impl_); |
| 70 } | 71 } |
| 71 | 72 |
| 72 void VideoLayerImpl::DidBecomeActive() { | 73 void VideoLayerImpl::DidBecomeActive() { |
| 73 provider_client_impl_->set_active_video_layer(this); | 74 provider_client_impl_->set_active_video_layer(this); |
| 74 } | 75 } |
| 75 | 76 |
| 76 bool VideoLayerImpl::WillDraw(DrawMode draw_mode, | 77 bool VideoLayerImpl::WillDraw(DrawMode draw_mode, |
| 77 ResourceProvider* resource_provider) { | 78 ResourceProvider* resource_provider) { |
| 78 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) | 79 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) |
| 79 return false; | 80 return false; |
| 80 | 81 |
| 81 // Explicitly acquire and release the provider mutex so it can be held from | 82 // Explicitly acquire and release the provider mutex so it can be held from |
| 82 // WillDraw to DidDraw. Since the compositor thread is in the middle of | 83 // WillDraw to DidDraw. Since the compositor thread is in the middle of |
| 83 // drawing, the layer will not be destroyed before DidDraw is called. | 84 // drawing, the layer will not be destroyed before DidDraw is called. |
| 84 // Therefore, the only thing that will prevent this lock from being released | 85 // Therefore, the only thing that will prevent this lock from being released |
| 85 // is the GPU process locking it. As the GPU process can't cause the | 86 // is the GPU process locking it. As the GPU process can't cause the |
| 86 // destruction of the provider (calling StopUsingProvider), holding this | 87 // destruction of the provider (calling StopUsingProvider), holding this |
| 87 // lock should not cause a deadlock. | 88 // lock should not cause a deadlock. |
| 88 frame_ = provider_client_impl_->AcquireLockAndCurrentFrame(); | 89 frame_ = provider_client_impl_->AcquireLockAndCurrentFrame(); |
| 89 | 90 |
| 90 if (!frame_.get()) { | 91 if (!frame_.get()) { |
| 91 // Drop any resources used by the updater if there is no frame to display. | 92 // Drop any resources used by the updater if there is no frame to display. |
| 92 updater_ = nullptr; | 93 updater_.reset(); |
| 93 | 94 |
| 94 provider_client_impl_->ReleaseLock(); | 95 provider_client_impl_->ReleaseLock(); |
| 95 return false; | 96 return false; |
| 96 } | 97 } |
| 97 | 98 |
| 98 if (!LayerImpl::WillDraw(draw_mode, resource_provider)) | 99 if (!LayerImpl::WillDraw(draw_mode, resource_provider)) |
| 99 return false; | 100 return false; |
| 100 | 101 |
| 101 if (!updater_) { | 102 if (!updater_) { |
| 102 updater_.reset( | 103 updater_.reset( |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 frame_resources_.clear(); | 351 frame_resources_.clear(); |
| 351 } | 352 } |
| 352 | 353 |
| 353 provider_client_impl_->PutCurrentFrame(frame_); | 354 provider_client_impl_->PutCurrentFrame(frame_); |
| 354 frame_ = NULL; | 355 frame_ = NULL; |
| 355 | 356 |
| 356 provider_client_impl_->ReleaseLock(); | 357 provider_client_impl_->ReleaseLock(); |
| 357 } | 358 } |
| 358 | 359 |
| 359 void VideoLayerImpl::ReleaseResources() { | 360 void VideoLayerImpl::ReleaseResources() { |
| 360 updater_ = nullptr; | 361 updater_.reset(); |
| 361 } | 362 } |
| 362 | 363 |
| 363 void VideoLayerImpl::SetNeedsRedraw() { | 364 void VideoLayerImpl::SetNeedsRedraw() { |
| 364 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::RectF(bounds()))); | 365 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::RectF(bounds()))); |
| 365 layer_tree_impl()->SetNeedsRedraw(); | 366 layer_tree_impl()->SetNeedsRedraw(); |
| 366 } | 367 } |
| 367 | 368 |
| 368 void VideoLayerImpl::SetProviderClientImpl( | 369 void VideoLayerImpl::SetProviderClientImpl( |
| 369 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl) { | 370 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl) { |
| 370 provider_client_impl_ = provider_client_impl; | 371 provider_client_impl_ = provider_client_impl; |
| 371 } | 372 } |
| 372 | 373 |
| 373 const char* VideoLayerImpl::LayerTypeAsString() const { | 374 const char* VideoLayerImpl::LayerTypeAsString() const { |
| 374 return "cc::VideoLayerImpl"; | 375 return "cc::VideoLayerImpl"; |
| 375 } | 376 } |
| 376 | 377 |
| 377 } // namespace cc | 378 } // namespace cc |
| OLD | NEW |