| 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/quad_sink.h" | 9 #include "cc/layers/quad_sink.h" |
| 10 #include "cc/layers/video_frame_provider_client_impl.h" | 10 #include "cc/layers/video_frame_provider_client_impl.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 LayerImpl::PushPropertiesTo(layer); | 61 LayerImpl::PushPropertiesTo(layer); |
| 62 | 62 |
| 63 VideoLayerImpl* other = static_cast<VideoLayerImpl*>(layer); | 63 VideoLayerImpl* other = static_cast<VideoLayerImpl*>(layer); |
| 64 other->SetProviderClientImpl(provider_client_impl_); | 64 other->SetProviderClientImpl(provider_client_impl_); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void VideoLayerImpl::DidBecomeActive() { | 67 void VideoLayerImpl::DidBecomeActive() { |
| 68 provider_client_impl_->set_active_video_layer(this); | 68 provider_client_impl_->set_active_video_layer(this); |
| 69 } | 69 } |
| 70 | 70 |
| 71 static void EmptyCallback(unsigned sync_point, bool lost_resource) {} | |
| 72 | |
| 73 void VideoLayerImpl::WillDraw(ResourceProvider* resource_provider) { | 71 void VideoLayerImpl::WillDraw(ResourceProvider* resource_provider) { |
| 74 LayerImpl::WillDraw(resource_provider); | 72 LayerImpl::WillDraw(resource_provider); |
| 75 | 73 |
| 76 // Explicitly acquire and release the provider mutex so it can be held from | 74 // Explicitly acquire and release the provider mutex so it can be held from |
| 77 // WillDraw to DidDraw. Since the compositor thread is in the middle of | 75 // WillDraw to DidDraw. Since the compositor thread is in the middle of |
| 78 // drawing, the layer will not be destroyed before DidDraw is called. | 76 // drawing, the layer will not be destroyed before DidDraw is called. |
| 79 // Therefore, the only thing that will prevent this lock from being released | 77 // Therefore, the only thing that will prevent this lock from being released |
| 80 // is the GPU process locking it. As the GPU process can't cause the | 78 // is the GPU process locking it. As the GPU process can't cause the |
| 81 // destruction of the provider (calling StopUsingProvider), holding this | 79 // destruction of the provider (calling StopUsingProvider), holding this |
| 82 // lock should not cause a deadlock. | 80 // lock should not cause a deadlock. |
| 83 frame_ = provider_client_impl_->AcquireLockAndCurrentFrame(); | 81 frame_ = provider_client_impl_->AcquireLockAndCurrentFrame(); |
| 84 | 82 |
| 85 if (!frame_) { | 83 if (!frame_) { |
| 86 // Drop any resources used by the updater if there is no frame to display. | 84 // Drop any resources used by the updater if there is no frame to display. |
| 87 updater_.reset(); | 85 updater_.reset(); |
| 88 | 86 |
| 89 provider_client_impl_->ReleaseLock(); | 87 provider_client_impl_->ReleaseLock(); |
| 90 return; | 88 return; |
| 91 } | 89 } |
| 92 | 90 |
| 93 if (!updater_) | 91 if (!updater_) |
| 94 updater_.reset(new VideoResourceUpdater(resource_provider)); | 92 updater_.reset(new VideoResourceUpdater(resource_provider)); |
| 95 | 93 |
| 96 VideoFrameExternalResources external_resources; | 94 VideoFrameExternalResources external_resources = |
| 97 if (frame_->format() == media::VideoFrame::NATIVE_TEXTURE) { | 95 updater_->CreateExternalResourcesFromVideoFrame(frame_); |
| 98 // TODO(danakj): To make this work for ubercomp, push this code out to | |
| 99 // WebMediaPlayer and have it set a callback so it knows it can reuse the | |
| 100 // texture. | |
| 101 TextureMailbox::ReleaseCallback empty_callback = base::Bind(&EmptyCallback); | |
| 102 external_resources = updater_->CreateForHardwarePlanes( | |
| 103 frame_, empty_callback); | |
| 104 } else { | |
| 105 external_resources = updater_->CreateForSoftwarePlanes(frame_); | |
| 106 } | |
| 107 | |
| 108 frame_resource_type_ = external_resources.type; | 96 frame_resource_type_ = external_resources.type; |
| 109 | 97 |
| 110 if (external_resources.type == | 98 if (external_resources.type == |
| 111 VideoFrameExternalResources::SOFTWARE_RESOURCE) { | 99 VideoFrameExternalResources::SOFTWARE_RESOURCE) { |
| 112 software_resources_ = external_resources.software_resources; | 100 software_resources_ = external_resources.software_resources; |
| 113 software_release_callback_ = | 101 software_release_callback_ = |
| 114 external_resources.software_release_callback; | 102 external_resources.software_release_callback; |
| 115 return; | 103 return; |
| 116 } | 104 } |
| 117 | 105 |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 void VideoLayerImpl::SetProviderClientImpl( | 292 void VideoLayerImpl::SetProviderClientImpl( |
| 305 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl) { | 293 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl) { |
| 306 provider_client_impl_ = provider_client_impl; | 294 provider_client_impl_ = provider_client_impl; |
| 307 } | 295 } |
| 308 | 296 |
| 309 const char* VideoLayerImpl::LayerTypeAsString() const { | 297 const char* VideoLayerImpl::LayerTypeAsString() const { |
| 310 return "VideoLayer"; | 298 return "VideoLayer"; |
| 311 } | 299 } |
| 312 | 300 |
| 313 } // namespace cc | 301 } // namespace cc |
| OLD | NEW |