| 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 23 matching lines...) Expand all Loading... |
| 34 new VideoLayerImpl(tree_impl, id, video_rotation)); | 34 new VideoLayerImpl(tree_impl, id, video_rotation)); |
| 35 layer->SetProviderClientImpl(VideoFrameProviderClientImpl::Create(provider)); | 35 layer->SetProviderClientImpl(VideoFrameProviderClientImpl::Create(provider)); |
| 36 DCHECK(tree_impl->proxy()->IsImplThread()); | 36 DCHECK(tree_impl->proxy()->IsImplThread()); |
| 37 DCHECK(tree_impl->proxy()->IsMainThreadBlocked()); | 37 DCHECK(tree_impl->proxy()->IsMainThreadBlocked()); |
| 38 return layer.Pass(); | 38 return layer.Pass(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 VideoLayerImpl::VideoLayerImpl(LayerTreeImpl* tree_impl, | 41 VideoLayerImpl::VideoLayerImpl(LayerTreeImpl* tree_impl, |
| 42 int id, | 42 int id, |
| 43 media::VideoRotation video_rotation) | 43 media::VideoRotation video_rotation) |
| 44 : LayerImpl(tree_impl, id), frame_(NULL), video_rotation_(video_rotation) { | 44 : LayerImpl(tree_impl, id), |
| 45 frame_(nullptr), |
| 46 video_rotation_(video_rotation) { |
| 45 } | 47 } |
| 46 | 48 |
| 47 VideoLayerImpl::~VideoLayerImpl() { | 49 VideoLayerImpl::~VideoLayerImpl() { |
| 48 if (!provider_client_impl_->Stopped()) { | 50 if (!provider_client_impl_->Stopped()) { |
| 49 // In impl side painting, we may have a pending and active layer | 51 // In impl side painting, we may have a pending and active layer |
| 50 // associated with the video provider at the same time. Both have a ref | 52 // associated with the video provider at the same time. Both have a ref |
| 51 // on the VideoFrameProviderClientImpl, but we stop when the first | 53 // on the VideoFrameProviderClientImpl, but we stop when the first |
| 52 // LayerImpl (the one on the pending tree) is destroyed since we know | 54 // LayerImpl (the one on the pending tree) is destroyed since we know |
| 53 // the main thread is blocked for this commit. | 55 // the main thread is blocked for this commit. |
| 54 DCHECK(layer_tree_impl()->proxy()->IsImplThread()); | 56 DCHECK(layer_tree_impl()->proxy()->IsImplThread()); |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 | 346 |
| 345 software_resources_.clear(); | 347 software_resources_.clear(); |
| 346 software_release_callback_.Reset(); | 348 software_release_callback_.Reset(); |
| 347 } else { | 349 } else { |
| 348 for (size_t i = 0; i < frame_resources_.size(); ++i) | 350 for (size_t i = 0; i < frame_resources_.size(); ++i) |
| 349 resource_provider->DeleteResource(frame_resources_[i]); | 351 resource_provider->DeleteResource(frame_resources_[i]); |
| 350 frame_resources_.clear(); | 352 frame_resources_.clear(); |
| 351 } | 353 } |
| 352 | 354 |
| 353 provider_client_impl_->PutCurrentFrame(frame_); | 355 provider_client_impl_->PutCurrentFrame(frame_); |
| 354 frame_ = NULL; | 356 frame_ = nullptr; |
| 355 | 357 |
| 356 provider_client_impl_->ReleaseLock(); | 358 provider_client_impl_->ReleaseLock(); |
| 357 } | 359 } |
| 358 | 360 |
| 359 void VideoLayerImpl::ReleaseResources() { | 361 void VideoLayerImpl::ReleaseResources() { |
| 360 updater_ = nullptr; | 362 updater_ = nullptr; |
| 361 } | 363 } |
| 362 | 364 |
| 363 void VideoLayerImpl::SetNeedsRedraw() { | 365 void VideoLayerImpl::SetNeedsRedraw() { |
| 364 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::RectF(bounds()))); | 366 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::RectF(bounds()))); |
| 365 layer_tree_impl()->SetNeedsRedraw(); | 367 layer_tree_impl()->SetNeedsRedraw(); |
| 366 } | 368 } |
| 367 | 369 |
| 368 void VideoLayerImpl::SetProviderClientImpl( | 370 void VideoLayerImpl::SetProviderClientImpl( |
| 369 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl) { | 371 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl) { |
| 370 provider_client_impl_ = provider_client_impl; | 372 provider_client_impl_ = provider_client_impl; |
| 371 } | 373 } |
| 372 | 374 |
| 373 const char* VideoLayerImpl::LayerTypeAsString() const { | 375 const char* VideoLayerImpl::LayerTypeAsString() const { |
| 374 return "cc::VideoLayerImpl"; | 376 return "cc::VideoLayerImpl"; |
| 375 } | 377 } |
| 376 | 378 |
| 377 } // namespace cc | 379 } // namespace cc |
| OLD | NEW |