Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Side by Side Diff: cc/layers/video_layer_impl.cc

Issue 609663003: cc: Remove use of PassAs() and constructor-casting with scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cc-passas: PassAs-presubmit-warning Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/video_layer.cc ('k') | cc/output/bsp_tree.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // LayerImpl (the one on the pending tree) is destroyed since we know 52 // LayerImpl (the one on the pending tree) is destroyed since we know
53 // the main thread is blocked for this commit. 53 // the main thread is blocked for this commit.
54 DCHECK(layer_tree_impl()->proxy()->IsImplThread()); 54 DCHECK(layer_tree_impl()->proxy()->IsImplThread());
55 DCHECK(layer_tree_impl()->proxy()->IsMainThreadBlocked()); 55 DCHECK(layer_tree_impl()->proxy()->IsMainThreadBlocked());
56 provider_client_impl_->Stop(); 56 provider_client_impl_->Stop();
57 } 57 }
58 } 58 }
59 59
60 scoped_ptr<LayerImpl> VideoLayerImpl::CreateLayerImpl( 60 scoped_ptr<LayerImpl> VideoLayerImpl::CreateLayerImpl(
61 LayerTreeImpl* tree_impl) { 61 LayerTreeImpl* tree_impl) {
62 VideoLayerImpl* impl = new VideoLayerImpl(tree_impl, id(), video_rotation_); 62 return make_scoped_ptr(new VideoLayerImpl(tree_impl, id(), video_rotation_));
63 return scoped_ptr<LayerImpl>(impl);
64 } 63 }
65 64
66 void VideoLayerImpl::PushPropertiesTo(LayerImpl* layer) { 65 void VideoLayerImpl::PushPropertiesTo(LayerImpl* layer) {
67 LayerImpl::PushPropertiesTo(layer); 66 LayerImpl::PushPropertiesTo(layer);
68 67
69 VideoLayerImpl* other = static_cast<VideoLayerImpl*>(layer); 68 VideoLayerImpl* other = static_cast<VideoLayerImpl*>(layer);
70 other->SetProviderClientImpl(provider_client_impl_); 69 other->SetProviderClientImpl(provider_client_impl_);
71 } 70 }
72 71
73 void VideoLayerImpl::DidBecomeActive() { 72 void VideoLayerImpl::DidBecomeActive() {
74 provider_client_impl_->set_active_video_layer(this); 73 provider_client_impl_->set_active_video_layer(this);
75 } 74 }
76 75
77 bool VideoLayerImpl::WillDraw(DrawMode draw_mode, 76 bool VideoLayerImpl::WillDraw(DrawMode draw_mode,
78 ResourceProvider* resource_provider) { 77 ResourceProvider* resource_provider) {
79 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) 78 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE)
80 return false; 79 return false;
81 80
82 // Explicitly acquire and release the provider mutex so it can be held from 81 // Explicitly acquire and release the provider mutex so it can be held from
83 // WillDraw to DidDraw. Since the compositor thread is in the middle of 82 // WillDraw to DidDraw. Since the compositor thread is in the middle of
84 // drawing, the layer will not be destroyed before DidDraw is called. 83 // drawing, the layer will not be destroyed before DidDraw is called.
85 // Therefore, the only thing that will prevent this lock from being released 84 // Therefore, the only thing that will prevent this lock from being released
86 // is the GPU process locking it. As the GPU process can't cause the 85 // is the GPU process locking it. As the GPU process can't cause the
87 // destruction of the provider (calling StopUsingProvider), holding this 86 // destruction of the provider (calling StopUsingProvider), holding this
88 // lock should not cause a deadlock. 87 // lock should not cause a deadlock.
89 frame_ = provider_client_impl_->AcquireLockAndCurrentFrame(); 88 frame_ = provider_client_impl_->AcquireLockAndCurrentFrame();
90 89
91 if (!frame_.get()) { 90 if (!frame_.get()) {
92 // Drop any resources used by the updater if there is no frame to display. 91 // Drop any resources used by the updater if there is no frame to display.
93 updater_.reset(); 92 updater_ = nullptr;
94 93
95 provider_client_impl_->ReleaseLock(); 94 provider_client_impl_->ReleaseLock();
96 return false; 95 return false;
97 } 96 }
98 97
99 if (!LayerImpl::WillDraw(draw_mode, resource_provider)) 98 if (!LayerImpl::WillDraw(draw_mode, resource_provider))
100 return false; 99 return false;
101 100
102 if (!updater_) { 101 if (!updater_) {
103 updater_.reset( 102 updater_.reset(
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 frame_resources_.clear(); 350 frame_resources_.clear();
352 } 351 }
353 352
354 provider_client_impl_->PutCurrentFrame(frame_); 353 provider_client_impl_->PutCurrentFrame(frame_);
355 frame_ = NULL; 354 frame_ = NULL;
356 355
357 provider_client_impl_->ReleaseLock(); 356 provider_client_impl_->ReleaseLock();
358 } 357 }
359 358
360 void VideoLayerImpl::ReleaseResources() { 359 void VideoLayerImpl::ReleaseResources() {
361 updater_.reset(); 360 updater_ = nullptr;
362 } 361 }
363 362
364 void VideoLayerImpl::SetNeedsRedraw() { 363 void VideoLayerImpl::SetNeedsRedraw() {
365 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::RectF(bounds()))); 364 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::RectF(bounds())));
366 layer_tree_impl()->SetNeedsRedraw(); 365 layer_tree_impl()->SetNeedsRedraw();
367 } 366 }
368 367
369 void VideoLayerImpl::SetProviderClientImpl( 368 void VideoLayerImpl::SetProviderClientImpl(
370 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl) { 369 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl) {
371 provider_client_impl_ = provider_client_impl; 370 provider_client_impl_ = provider_client_impl;
372 } 371 }
373 372
374 const char* VideoLayerImpl::LayerTypeAsString() const { 373 const char* VideoLayerImpl::LayerTypeAsString() const {
375 return "cc::VideoLayerImpl"; 374 return "cc::VideoLayerImpl";
376 } 375 }
377 376
378 } // namespace cc 377 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/video_layer.cc ('k') | cc/output/bsp_tree.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698