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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 LayerImpl::PushPropertiesTo(layer); | 62 LayerImpl::PushPropertiesTo(layer); |
63 | 63 |
64 VideoLayerImpl* other = static_cast<VideoLayerImpl*>(layer); | 64 VideoLayerImpl* other = static_cast<VideoLayerImpl*>(layer); |
65 other->SetProviderClientImpl(provider_client_impl_); | 65 other->SetProviderClientImpl(provider_client_impl_); |
66 } | 66 } |
67 | 67 |
68 void VideoLayerImpl::DidBecomeActive() { | 68 void VideoLayerImpl::DidBecomeActive() { |
69 provider_client_impl_->set_active_video_layer(this); | 69 provider_client_impl_->set_active_video_layer(this); |
70 } | 70 } |
71 | 71 |
72 void VideoLayerImpl::WillDraw(ResourceProvider* resource_provider) { | 72 bool VideoLayerImpl::WillDraw(DrawMode draw_mode, |
73 LayerImpl::WillDraw(resource_provider); | 73 ResourceProvider* resource_provider) { |
74 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) | |
75 return false; | |
74 | 76 |
75 // Explicitly acquire and release the provider mutex so it can be held from | 77 // Explicitly acquire and release the provider mutex so it can be held from |
76 // WillDraw to DidDraw. Since the compositor thread is in the middle of | 78 // WillDraw to DidDraw. Since the compositor thread is in the middle of |
77 // drawing, the layer will not be destroyed before DidDraw is called. | 79 // drawing, the layer will not be destroyed before DidDraw is called. |
78 // Therefore, the only thing that will prevent this lock from being released | 80 // Therefore, the only thing that will prevent this lock from being released |
79 // is the GPU process locking it. As the GPU process can't cause the | 81 // is the GPU process locking it. As the GPU process can't cause the |
80 // destruction of the provider (calling StopUsingProvider), holding this | 82 // destruction of the provider (calling StopUsingProvider), holding this |
81 // lock should not cause a deadlock. | 83 // lock should not cause a deadlock. |
82 frame_ = provider_client_impl_->AcquireLockAndCurrentFrame(); | 84 frame_ = provider_client_impl_->AcquireLockAndCurrentFrame(); |
83 | 85 |
84 if (!frame_.get()) { | 86 if (!frame_.get()) { |
85 // Drop any resources used by the updater if there is no frame to display. | 87 // Drop any resources used by the updater if there is no frame to display. |
86 updater_.reset(); | 88 updater_.reset(); |
87 | 89 |
88 provider_client_impl_->ReleaseLock(); | 90 provider_client_impl_->ReleaseLock(); |
89 return; | 91 return false; |
90 } | 92 } |
91 | 93 |
94 LayerImpl::WillDraw(draw_mode, resource_provider); | |
danakj
2013/06/04 15:30:44
In other layers we always return this value. Shoul
| |
95 | |
92 if (!updater_) | 96 if (!updater_) |
93 updater_.reset(new VideoResourceUpdater(resource_provider)); | 97 updater_.reset(new VideoResourceUpdater(resource_provider)); |
94 | 98 |
95 VideoFrameExternalResources external_resources; | 99 VideoFrameExternalResources external_resources; |
96 if (frame_->format() == media::VideoFrame::NATIVE_TEXTURE) | 100 if (frame_->format() == media::VideoFrame::NATIVE_TEXTURE) |
97 external_resources = updater_->CreateForHardwarePlanes(frame_); | 101 external_resources = updater_->CreateForHardwarePlanes(frame_); |
98 else | 102 else |
99 external_resources = updater_->CreateForSoftwarePlanes(frame_); | 103 external_resources = updater_->CreateForSoftwarePlanes(frame_); |
100 | 104 |
101 frame_resource_type_ = external_resources.type; | 105 frame_resource_type_ = external_resources.type; |
102 | 106 |
103 if (external_resources.type == | 107 if (external_resources.type == |
104 VideoFrameExternalResources::SOFTWARE_RESOURCE) { | 108 VideoFrameExternalResources::SOFTWARE_RESOURCE) { |
105 software_resources_ = external_resources.software_resources; | 109 software_resources_ = external_resources.software_resources; |
106 software_release_callback_ = | 110 software_release_callback_ = |
107 external_resources.software_release_callback; | 111 external_resources.software_release_callback; |
108 return; | 112 return true; |
109 } | 113 } |
110 | 114 |
111 if (external_resources.hardware_resource) { | 115 if (external_resources.hardware_resource) { |
112 hardware_resource_ = external_resources.hardware_resource; | 116 hardware_resource_ = external_resources.hardware_resource; |
113 hardware_release_callback_ = | 117 hardware_release_callback_ = |
114 external_resources.hardware_release_callback; | 118 external_resources.hardware_release_callback; |
115 return; | 119 return true; |
116 } | 120 } |
117 | 121 |
118 for (size_t i = 0; i < external_resources.mailboxes.size(); ++i) { | 122 for (size_t i = 0; i < external_resources.mailboxes.size(); ++i) { |
119 frame_resources_.push_back( | 123 frame_resources_.push_back( |
120 resource_provider->CreateResourceFromTextureMailbox( | 124 resource_provider->CreateResourceFromTextureMailbox( |
121 external_resources.mailboxes[i])); | 125 external_resources.mailboxes[i])); |
122 } | 126 } |
127 | |
128 return true; | |
123 } | 129 } |
124 | 130 |
125 void VideoLayerImpl::AppendQuads(QuadSink* quad_sink, | 131 void VideoLayerImpl::AppendQuads(QuadSink* quad_sink, |
126 AppendQuadsData* append_quads_data) { | 132 AppendQuadsData* append_quads_data) { |
127 if (!frame_.get()) | 133 DCHECK(frame_.get()); |
128 return; | |
129 | 134 |
130 SharedQuadState* shared_quad_state = | 135 SharedQuadState* shared_quad_state = |
131 quad_sink->UseSharedQuadState(CreateSharedQuadState()); | 136 quad_sink->UseSharedQuadState(CreateSharedQuadState()); |
132 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); | 137 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); |
133 | 138 |
134 gfx::Rect quad_rect(content_bounds()); | 139 gfx::Rect quad_rect(content_bounds()); |
135 gfx::Rect opaque_rect(contents_opaque() ? quad_rect : gfx::Rect()); | 140 gfx::Rect opaque_rect(contents_opaque() ? quad_rect : gfx::Rect()); |
136 gfx::Rect visible_rect = frame_->visible_rect(); | 141 gfx::Rect visible_rect = frame_->visible_rect(); |
137 gfx::Size coded_size = frame_->coded_size(); | 142 gfx::Size coded_size = frame_->coded_size(); |
138 | 143 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
273 #endif | 278 #endif |
274 case VideoFrameExternalResources::NONE: | 279 case VideoFrameExternalResources::NONE: |
275 NOTIMPLEMENTED(); | 280 NOTIMPLEMENTED(); |
276 break; | 281 break; |
277 } | 282 } |
278 } | 283 } |
279 | 284 |
280 void VideoLayerImpl::DidDraw(ResourceProvider* resource_provider) { | 285 void VideoLayerImpl::DidDraw(ResourceProvider* resource_provider) { |
281 LayerImpl::DidDraw(resource_provider); | 286 LayerImpl::DidDraw(resource_provider); |
282 | 287 |
283 if (!frame_.get()) | 288 DCHECK(frame_.get()); |
284 return; | |
285 | 289 |
286 if (frame_resource_type_ == | 290 if (frame_resource_type_ == |
287 VideoFrameExternalResources::SOFTWARE_RESOURCE) { | 291 VideoFrameExternalResources::SOFTWARE_RESOURCE) { |
288 for (size_t i = 0; i < software_resources_.size(); ++i) | 292 for (size_t i = 0; i < software_resources_.size(); ++i) |
289 software_release_callback_.Run(0, false); | 293 software_release_callback_.Run(0, false); |
290 | 294 |
291 software_resources_.clear(); | 295 software_resources_.clear(); |
292 software_release_callback_.Reset(); | 296 software_release_callback_.Reset(); |
293 } else if (hardware_resource_) { | 297 } else if (hardware_resource_) { |
294 hardware_release_callback_.Run(0, false); | 298 hardware_release_callback_.Run(0, false); |
(...skipping 23 matching lines...) Expand all Loading... | |
318 void VideoLayerImpl::SetProviderClientImpl( | 322 void VideoLayerImpl::SetProviderClientImpl( |
319 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl) { | 323 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl) { |
320 provider_client_impl_ = provider_client_impl; | 324 provider_client_impl_ = provider_client_impl; |
321 } | 325 } |
322 | 326 |
323 const char* VideoLayerImpl::LayerTypeAsString() const { | 327 const char* VideoLayerImpl::LayerTypeAsString() const { |
324 return "cc::VideoLayerImpl"; | 328 return "cc::VideoLayerImpl"; |
325 } | 329 } |
326 | 330 |
327 } // namespace cc | 331 } // namespace cc |
OLD | NEW |