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

Side by Side Diff: cc/output/texture_mailbox_deleter.cc

Issue 1455023002: cc: Replace Pass() with std::move() in some subdirs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pass-cc
Patch Set: pass-cc2: . Created 5 years, 1 month 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/output/software_renderer_unittest.cc ('k') | cc/quads/draw_polygon.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/output/texture_mailbox_deleter.h" 5 #include "cc/output/texture_mailbox_deleter.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 const scoped_refptr<ContextProvider>& context_provider, 50 const scoped_refptr<ContextProvider>& context_provider,
51 unsigned texture_id) { 51 unsigned texture_id) {
52 // This callback owns a reference on the |context_provider|. It must be 52 // This callback owns a reference on the |context_provider|. It must be
53 // destroyed on the impl thread. Upon destruction of this class, the 53 // destroyed on the impl thread. Upon destruction of this class, the
54 // callback must immediately be destroyed. 54 // callback must immediately be destroyed.
55 scoped_ptr<SingleReleaseCallback> impl_callback = 55 scoped_ptr<SingleReleaseCallback> impl_callback =
56 SingleReleaseCallback::Create(base::Bind(&DeleteTextureOnImplThread, 56 SingleReleaseCallback::Create(base::Bind(&DeleteTextureOnImplThread,
57 context_provider, 57 context_provider,
58 texture_id)); 58 texture_id));
59 59
60 impl_callbacks_.push_back(impl_callback.Pass()); 60 impl_callbacks_.push_back(std::move(impl_callback));
61 61
62 // The raw pointer to the impl-side callback is valid as long as this 62 // The raw pointer to the impl-side callback is valid as long as this
63 // class is alive. So we guard it with a WeakPtr. 63 // class is alive. So we guard it with a WeakPtr.
64 ReleaseCallback run_impl_callback( 64 ReleaseCallback run_impl_callback(
65 base::Bind(&TextureMailboxDeleter::RunDeleteTextureOnImplThread, 65 base::Bind(&TextureMailboxDeleter::RunDeleteTextureOnImplThread,
66 weak_ptr_factory_.GetWeakPtr(), impl_callbacks_.back().get())); 66 weak_ptr_factory_.GetWeakPtr(), impl_callbacks_.back().get()));
67 67
68 // Provide a callback for the main thread that posts back to the impl 68 // Provide a callback for the main thread that posts back to the impl
69 // thread. 69 // thread.
70 scoped_ptr<SingleReleaseCallback> main_callback; 70 scoped_ptr<SingleReleaseCallback> main_callback;
71 if (impl_task_runner_) { 71 if (impl_task_runner_) {
72 main_callback = SingleReleaseCallback::Create(base::Bind( 72 main_callback = SingleReleaseCallback::Create(base::Bind(
73 &PostTaskFromMainToImplThread, impl_task_runner_, run_impl_callback)); 73 &PostTaskFromMainToImplThread, impl_task_runner_, run_impl_callback));
74 } else { 74 } else {
75 main_callback = SingleReleaseCallback::Create(run_impl_callback); 75 main_callback = SingleReleaseCallback::Create(run_impl_callback);
76 } 76 }
77 77
78 return main_callback.Pass(); 78 return main_callback;
79 } 79 }
80 80
81 void TextureMailboxDeleter::RunDeleteTextureOnImplThread( 81 void TextureMailboxDeleter::RunDeleteTextureOnImplThread(
82 SingleReleaseCallback* impl_callback, 82 SingleReleaseCallback* impl_callback,
83 const gpu::SyncToken& sync_token, 83 const gpu::SyncToken& sync_token,
84 bool is_lost) { 84 bool is_lost) {
85 for (size_t i = 0; i < impl_callbacks_.size(); ++i) { 85 for (size_t i = 0; i < impl_callbacks_.size(); ++i) {
86 if (impl_callbacks_[i].get() == impl_callback) { 86 if (impl_callbacks_[i].get() == impl_callback) {
87 // Run the callback, then destroy it here on the impl thread. 87 // Run the callback, then destroy it here on the impl thread.
88 impl_callbacks_[i]->Run(sync_token, is_lost); 88 impl_callbacks_[i]->Run(sync_token, is_lost);
89 impl_callbacks_.erase(impl_callbacks_.begin() + i); 89 impl_callbacks_.erase(impl_callbacks_.begin() + i);
90 return; 90 return;
91 } 91 }
92 } 92 }
93 93
94 NOTREACHED() << "The Callback returned by GetDeleteCallback() was called " 94 NOTREACHED() << "The Callback returned by GetDeleteCallback() was called "
95 << "more than once."; 95 << "more than once.";
96 } 96 }
97 97
98 } // namespace cc 98 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/software_renderer_unittest.cc ('k') | cc/quads/draw_polygon.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698