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

Side by Side Diff: cc/layers/texture_layer.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/surface_layer_impl.cc ('k') | cc/layers/texture_layer_impl.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 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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/texture_layer.h" 5 #include "cc/layers/texture_layer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 client_ = NULL; 48 client_ = NULL;
49 ClearTexture(); 49 ClearTexture();
50 UpdateDrawsContent(HasDrawableContent()); 50 UpdateDrawsContent(HasDrawableContent());
51 } 51 }
52 52
53 void TextureLayer::ClearTexture() { 53 void TextureLayer::ClearTexture() {
54 SetTextureMailbox(TextureMailbox(), scoped_ptr<SingleReleaseCallback>()); 54 SetTextureMailbox(TextureMailbox(), scoped_ptr<SingleReleaseCallback>());
55 } 55 }
56 56
57 scoped_ptr<LayerImpl> TextureLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) { 57 scoped_ptr<LayerImpl> TextureLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) {
58 return TextureLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>(); 58 return TextureLayerImpl::Create(tree_impl, id());
59 } 59 }
60 60
61 void TextureLayer::SetFlipped(bool flipped) { 61 void TextureLayer::SetFlipped(bool flipped) {
62 if (flipped_ == flipped) 62 if (flipped_ == flipped)
63 return; 63 return;
64 flipped_ = flipped; 64 flipped_ = flipped;
65 SetNeedsCommit(); 65 SetNeedsCommit();
66 } 66 }
67 67
68 void TextureLayer::SetUV(const gfx::PointF& top_left, 68 void TextureLayer::SetUV(const gfx::PointF& top_left,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 DCHECK(!mailbox.IsValid() || !holder_ref_ || 123 DCHECK(!mailbox.IsValid() || !holder_ref_ ||
124 !mailbox.Equals(holder_ref_->holder()->mailbox()) || 124 !mailbox.Equals(holder_ref_->holder()->mailbox()) ||
125 allow_mailbox_reuse); 125 allow_mailbox_reuse);
126 DCHECK_EQ(mailbox.IsValid(), !!release_callback); 126 DCHECK_EQ(mailbox.IsValid(), !!release_callback);
127 127
128 // If we never commited the mailbox, we need to release it here. 128 // If we never commited the mailbox, we need to release it here.
129 if (mailbox.IsValid()) { 129 if (mailbox.IsValid()) {
130 holder_ref_ = 130 holder_ref_ =
131 TextureMailboxHolder::Create(mailbox, release_callback.Pass()); 131 TextureMailboxHolder::Create(mailbox, release_callback.Pass());
132 } else { 132 } else {
133 holder_ref_.reset(); 133 holder_ref_ = nullptr;
134 } 134 }
135 needs_set_mailbox_ = true; 135 needs_set_mailbox_ = true;
136 // If we are within a commit, no need to do it again immediately after. 136 // If we are within a commit, no need to do it again immediately after.
137 if (requires_commit) 137 if (requires_commit)
138 SetNeedsCommit(); 138 SetNeedsCommit();
139 else 139 else
140 SetNeedsPushProperties(); 140 SetNeedsPushProperties();
141 141
142 UpdateDrawsContent(HasDrawableContent()); 142 UpdateDrawsContent(HasDrawableContent());
143 // The active frame needs to be replaced and the mailbox returned before the 143 // The active frame needs to be replaced and the mailbox returned before the
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 } 289 }
290 290
291 TextureLayer::TextureMailboxHolder::~TextureMailboxHolder() { 291 TextureLayer::TextureMailboxHolder::~TextureMailboxHolder() {
292 DCHECK_EQ(0u, internal_references_); 292 DCHECK_EQ(0u, internal_references_);
293 } 293 }
294 294
295 scoped_ptr<TextureLayer::TextureMailboxHolder::MainThreadReference> 295 scoped_ptr<TextureLayer::TextureMailboxHolder::MainThreadReference>
296 TextureLayer::TextureMailboxHolder::Create( 296 TextureLayer::TextureMailboxHolder::Create(
297 const TextureMailbox& mailbox, 297 const TextureMailbox& mailbox,
298 scoped_ptr<SingleReleaseCallback> release_callback) { 298 scoped_ptr<SingleReleaseCallback> release_callback) {
299 return scoped_ptr<MainThreadReference>(new MainThreadReference( 299 return make_scoped_ptr(new MainThreadReference(
300 new TextureMailboxHolder(mailbox, release_callback.Pass()))); 300 new TextureMailboxHolder(mailbox, release_callback.Pass())));
301 } 301 }
302 302
303 void TextureLayer::TextureMailboxHolder::Return(uint32 sync_point, 303 void TextureLayer::TextureMailboxHolder::Return(uint32 sync_point,
304 bool is_lost) { 304 bool is_lost) {
305 base::AutoLock lock(arguments_lock_); 305 base::AutoLock lock(arguments_lock_);
306 sync_point_ = sync_point; 306 sync_point_ = sync_point;
307 is_lost_ = is_lost; 307 is_lost_ = is_lost;
308 } 308 }
309 309
310 scoped_ptr<SingleReleaseCallbackImpl> 310 scoped_ptr<SingleReleaseCallbackImpl>
311 TextureLayer::TextureMailboxHolder::GetCallbackForImplThread() { 311 TextureLayer::TextureMailboxHolder::GetCallbackForImplThread() {
312 // We can't call GetCallbackForImplThread if we released the main thread 312 // We can't call GetCallbackForImplThread if we released the main thread
313 // reference. 313 // reference.
314 DCHECK_GT(internal_references_, 0u); 314 DCHECK_GT(internal_references_, 0u);
315 InternalAddRef(); 315 InternalAddRef();
316 return SingleReleaseCallbackImpl::Create( 316 return SingleReleaseCallbackImpl::Create(
317 base::Bind(&TextureMailboxHolder::ReturnAndReleaseOnImplThread, this)); 317 base::Bind(&TextureMailboxHolder::ReturnAndReleaseOnImplThread, this));
318 } 318 }
319 319
320 void TextureLayer::TextureMailboxHolder::InternalAddRef() { 320 void TextureLayer::TextureMailboxHolder::InternalAddRef() {
321 ++internal_references_; 321 ++internal_references_;
322 } 322 }
323 323
324 void TextureLayer::TextureMailboxHolder::InternalRelease() { 324 void TextureLayer::TextureMailboxHolder::InternalRelease() {
325 DCHECK(main_thread_checker_.CalledOnValidThread()); 325 DCHECK(main_thread_checker_.CalledOnValidThread());
326 if (!--internal_references_) { 326 if (!--internal_references_) {
327 release_callback_->Run(sync_point_, is_lost_); 327 release_callback_->Run(sync_point_, is_lost_);
328 mailbox_ = TextureMailbox(); 328 mailbox_ = TextureMailbox();
329 release_callback_.reset(); 329 release_callback_ = nullptr;
330 } 330 }
331 } 331 }
332 332
333 void TextureLayer::TextureMailboxHolder::ReturnAndReleaseOnImplThread( 333 void TextureLayer::TextureMailboxHolder::ReturnAndReleaseOnImplThread(
334 uint32 sync_point, 334 uint32 sync_point,
335 bool is_lost, 335 bool is_lost,
336 BlockingTaskRunner* main_thread_task_runner) { 336 BlockingTaskRunner* main_thread_task_runner) {
337 Return(sync_point, is_lost); 337 Return(sync_point, is_lost);
338 main_thread_task_runner->PostTask( 338 main_thread_task_runner->PostTask(
339 FROM_HERE, base::Bind(&TextureMailboxHolder::InternalRelease, this)); 339 FROM_HERE, base::Bind(&TextureMailboxHolder::InternalRelease, this));
340 } 340 }
341 341
342 } // namespace cc 342 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/surface_layer_impl.cc ('k') | cc/layers/texture_layer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698