Chromium Code Reviews| 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 20 matching lines...) Expand all Loading... | |
| 31 VideoFrameProvider* provider) { | 31 VideoFrameProvider* provider) { |
| 32 scoped_ptr<VideoLayerImpl> layer(new VideoLayerImpl(tree_impl, id)); | 32 scoped_ptr<VideoLayerImpl> layer(new VideoLayerImpl(tree_impl, id)); |
| 33 layer->SetProviderClientImpl(VideoFrameProviderClientImpl::Create(provider)); | 33 layer->SetProviderClientImpl(VideoFrameProviderClientImpl::Create(provider)); |
| 34 DCHECK(tree_impl->proxy()->IsImplThread()); | 34 DCHECK(tree_impl->proxy()->IsImplThread()); |
| 35 DCHECK(tree_impl->proxy()->IsMainThreadBlocked()); | 35 DCHECK(tree_impl->proxy()->IsMainThreadBlocked()); |
| 36 return layer.Pass(); | 36 return layer.Pass(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 VideoLayerImpl::VideoLayerImpl(LayerTreeImpl* tree_impl, int id) | 39 VideoLayerImpl::VideoLayerImpl(LayerTreeImpl* tree_impl, int id) |
| 40 : LayerImpl(tree_impl, id), | 40 : LayerImpl(tree_impl, id), |
| 41 frame_(NULL) {} | 41 frame_(NULL), |
| 42 video_rotation_(media::VIDEO_ROTATION_0) { | |
| 43 } | |
| 42 | 44 |
| 43 VideoLayerImpl::~VideoLayerImpl() { | 45 VideoLayerImpl::~VideoLayerImpl() { |
| 44 if (!provider_client_impl_->Stopped()) { | 46 if (!provider_client_impl_->Stopped()) { |
| 45 // In impl side painting, we may have a pending and active layer | 47 // In impl side painting, we may have a pending and active layer |
| 46 // associated with the video provider at the same time. Both have a ref | 48 // associated with the video provider at the same time. Both have a ref |
| 47 // on the VideoFrameProviderClientImpl, but we stop when the first | 49 // on the VideoFrameProviderClientImpl, but we stop when the first |
| 48 // LayerImpl (the one on the pending tree) is destroyed since we know | 50 // LayerImpl (the one on the pending tree) is destroyed since we know |
| 49 // the main thread is blocked for this commit. | 51 // the main thread is blocked for this commit. |
| 50 DCHECK(layer_tree_impl()->proxy()->IsImplThread()); | 52 DCHECK(layer_tree_impl()->proxy()->IsImplThread()); |
| 51 DCHECK(layer_tree_impl()->proxy()->IsMainThreadBlocked()); | 53 DCHECK(layer_tree_impl()->proxy()->IsMainThreadBlocked()); |
| 52 provider_client_impl_->Stop(); | 54 provider_client_impl_->Stop(); |
| 53 } | 55 } |
| 54 } | 56 } |
| 55 | 57 |
| 56 scoped_ptr<LayerImpl> VideoLayerImpl::CreateLayerImpl( | 58 scoped_ptr<LayerImpl> VideoLayerImpl::CreateLayerImpl( |
| 57 LayerTreeImpl* tree_impl) { | 59 LayerTreeImpl* tree_impl) { |
| 58 return scoped_ptr<LayerImpl>(new VideoLayerImpl(tree_impl, id())); | 60 VideoLayerImpl* impl = new VideoLayerImpl(tree_impl, id()); |
| 61 impl->set_video_rotation(video_rotation_); | |
| 62 return scoped_ptr<LayerImpl>(impl); | |
| 59 } | 63 } |
| 60 | 64 |
| 61 void VideoLayerImpl::PushPropertiesTo(LayerImpl* layer) { | 65 void VideoLayerImpl::PushPropertiesTo(LayerImpl* layer) { |
| 62 LayerImpl::PushPropertiesTo(layer); | 66 LayerImpl::PushPropertiesTo(layer); |
| 63 | 67 |
| 64 VideoLayerImpl* other = static_cast<VideoLayerImpl*>(layer); | 68 VideoLayerImpl* other = static_cast<VideoLayerImpl*>(layer); |
| 65 other->SetProviderClientImpl(provider_client_impl_); | 69 other->SetProviderClientImpl(provider_client_impl_); |
|
danakj
2014/07/11 21:04:29
pass the new rotation here, not in CreateLayerImpl
| |
| 66 } | 70 } |
| 67 | 71 |
| 68 void VideoLayerImpl::DidBecomeActive() { | 72 void VideoLayerImpl::DidBecomeActive() { |
| 69 provider_client_impl_->set_active_video_layer(this); | 73 provider_client_impl_->set_active_video_layer(this); |
| 70 } | 74 } |
| 71 | 75 |
| 72 bool VideoLayerImpl::WillDraw(DrawMode draw_mode, | 76 bool VideoLayerImpl::WillDraw(DrawMode draw_mode, |
| 73 ResourceProvider* resource_provider) { | 77 ResourceProvider* resource_provider) { |
| 74 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) | 78 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) |
| 75 return false; | 79 return false; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 } | 129 } |
| 126 | 130 |
| 127 void VideoLayerImpl::AppendQuads( | 131 void VideoLayerImpl::AppendQuads( |
| 128 RenderPass* render_pass, | 132 RenderPass* render_pass, |
| 129 const OcclusionTracker<LayerImpl>& occlusion_tracker, | 133 const OcclusionTracker<LayerImpl>& occlusion_tracker, |
| 130 AppendQuadsData* append_quads_data) { | 134 AppendQuadsData* append_quads_data) { |
| 131 DCHECK(frame_.get()); | 135 DCHECK(frame_.get()); |
| 132 | 136 |
| 133 SharedQuadState* shared_quad_state = | 137 SharedQuadState* shared_quad_state = |
| 134 render_pass->CreateAndAppendSharedQuadState(); | 138 render_pass->CreateAndAppendSharedQuadState(); |
| 135 PopulateSharedQuadState(shared_quad_state); | 139 PopulateSharedQuadState(shared_quad_state); |
|
danakj
2014/07/11 21:04:29
replace this with a call to SetAll (do this after
| |
| 136 | 140 |
| 141 gfx::Size bounds = content_bounds(); | |
|
danakj
2014/07/11 21:04:29
rotated_content_bounds
| |
| 142 gfx::Transform transform = shared_quad_state->content_to_target_transform; | |
| 143 switch (video_rotation_) { | |
| 144 case media::VIDEO_ROTATION_90: | |
| 145 transform.Rotate(90); | |
| 146 transform.Translate(0, -bounds.width()); | |
| 147 bounds = gfx::Size(bounds.height(), bounds.width()); | |
| 148 break; | |
| 149 case media::VIDEO_ROTATION_180: | |
| 150 transform.Rotate(180); | |
| 151 transform.Translate(-bounds.width(), -bounds.height()); | |
| 152 break; | |
| 153 case media::VIDEO_ROTATION_270: | |
| 154 transform.Rotate(270); | |
| 155 transform.Translate(-bounds.height(), 0); | |
| 156 bounds = gfx::Size(bounds.height(), bounds.width()); | |
| 157 default: | |
|
scherkus (not reviewing)
2014/07/11 18:54:07
try to avoid default where possible and instead ex
danakj
2014/07/11 21:04:29
+1
| |
| 158 break; | |
| 159 } | |
| 160 shared_quad_state->content_to_target_transform = transform; | |
|
danakj
2014/07/11 21:04:29
You want to Preconcat your transform onto the exis
| |
| 161 | |
| 137 AppendDebugBorderQuad( | 162 AppendDebugBorderQuad( |
| 138 render_pass, content_bounds(), shared_quad_state, append_quads_data); | 163 render_pass, bounds, shared_quad_state, append_quads_data); |
| 139 | 164 |
| 140 gfx::Rect quad_rect(content_bounds()); | 165 gfx::Rect quad_rect(bounds); |
| 141 gfx::Rect opaque_rect(contents_opaque() ? quad_rect : gfx::Rect()); | 166 gfx::Rect opaque_rect(contents_opaque() ? quad_rect : gfx::Rect()); |
| 142 gfx::Rect visible_rect = frame_->visible_rect(); | 167 gfx::Rect visible_rect = frame_->visible_rect(); |
| 143 gfx::Size coded_size = frame_->coded_size(); | 168 gfx::Size coded_size = frame_->coded_size(); |
| 144 | 169 |
| 145 gfx::Rect visible_quad_rect = occlusion_tracker.UnoccludedContentRect( | 170 gfx::Rect visible_quad_rect = occlusion_tracker.UnoccludedContentRect( |
| 146 quad_rect, draw_properties().target_space_transform); | 171 quad_rect, draw_properties().target_space_transform); |
| 147 if (visible_quad_rect.IsEmpty()) | 172 if (visible_quad_rect.IsEmpty()) |
| 148 return; | 173 return; |
| 149 | 174 |
| 150 // Pixels for macroblocked formats. | 175 // Pixels for macroblocked formats. |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 322 | 347 |
| 323 void VideoLayerImpl::ReleaseResources() { | 348 void VideoLayerImpl::ReleaseResources() { |
| 324 updater_.reset(); | 349 updater_.reset(); |
| 325 } | 350 } |
| 326 | 351 |
| 327 void VideoLayerImpl::SetNeedsRedraw() { | 352 void VideoLayerImpl::SetNeedsRedraw() { |
| 328 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::RectF(bounds()))); | 353 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::RectF(bounds()))); |
| 329 layer_tree_impl()->SetNeedsRedraw(); | 354 layer_tree_impl()->SetNeedsRedraw(); |
| 330 } | 355 } |
| 331 | 356 |
| 357 void VideoLayerImpl::set_video_rotation(media::VideoRotation video_rotation) { | |
|
danakj
2014/07/11 21:04:29
SetVideoRotation, this isn't inline
| |
| 358 video_rotation_ = video_rotation; | |
| 359 } | |
|
danakj
2014/07/11 21:04:29
You need to call NoteLayerPropertyChanged()
| |
| 360 | |
| 332 void VideoLayerImpl::SetProviderClientImpl( | 361 void VideoLayerImpl::SetProviderClientImpl( |
| 333 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl) { | 362 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl) { |
| 334 provider_client_impl_ = provider_client_impl; | 363 provider_client_impl_ = provider_client_impl; |
| 335 } | 364 } |
| 336 | 365 |
| 337 const char* VideoLayerImpl::LayerTypeAsString() const { | 366 const char* VideoLayerImpl::LayerTypeAsString() const { |
| 338 return "cc::VideoLayerImpl"; | 367 return "cc::VideoLayerImpl"; |
| 339 } | 368 } |
| 340 | 369 |
| 341 } // namespace cc | 370 } // namespace cc |
| OLD | NEW |