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_->Stopped()) { |
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_->Stop(); |
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 if (!provider_client_impl_->Started()) |
| 75 provider_client_impl_->Start(this); |
76 } | 76 } |
77 | 77 |
78 bool VideoLayerImpl::WillDraw(DrawMode draw_mode, | 78 bool VideoLayerImpl::WillDraw(DrawMode draw_mode, |
79 ResourceProvider* resource_provider) { | 79 ResourceProvider* resource_provider) { |
80 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) | 80 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) |
81 return false; | 81 return false; |
82 | 82 |
83 // Explicitly acquire and release the provider mutex so it can be held from | 83 // Explicitly acquire and release the provider mutex so it can be held from |
84 // WillDraw to DidDraw. Since the compositor thread is in the middle of | 84 // WillDraw to DidDraw. Since the compositor thread is in the middle of |
85 // drawing, the layer will not be destroyed before DidDraw is called. | 85 // drawing, the layer will not be destroyed before DidDraw is called. |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 | 357 |
358 void VideoLayerImpl::ReleaseResources() { | 358 void VideoLayerImpl::ReleaseResources() { |
359 updater_ = nullptr; | 359 updater_ = nullptr; |
360 } | 360 } |
361 | 361 |
362 void VideoLayerImpl::SetNeedsRedraw() { | 362 void VideoLayerImpl::SetNeedsRedraw() { |
363 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::Rect(bounds()))); | 363 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::Rect(bounds()))); |
364 layer_tree_impl()->SetNeedsRedraw(); | 364 layer_tree_impl()->SetNeedsRedraw(); |
365 } | 365 } |
366 | 366 |
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 { | 367 const char* VideoLayerImpl::LayerTypeAsString() const { |
373 return "cc::VideoLayerImpl"; | 368 return "cc::VideoLayerImpl"; |
374 } | 369 } |
375 | 370 |
376 } // namespace cc | 371 } // namespace cc |
OLD | NEW |