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

Unified Diff: content/common/gpu/client/gpu_channel_host.cc

Issue 654223006: Cleanup GpuMemoryBuffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: content/common/gpu/client/gpu_channel_host.cc
diff --git a/content/common/gpu/client/gpu_channel_host.cc b/content/common/gpu/client/gpu_channel_host.cc
index f7f5d823eedb84285f08f16f93c8b609bcd80793..0de380288fe04c617040f06e33e3cb05f067f423 100644
--- a/content/common/gpu/client/gpu_channel_host.cc
+++ b/content/common/gpu/client/gpu_channel_host.cc
@@ -50,7 +50,8 @@ GpuChannelHost::GpuChannelHost(
cc::GpuMemoryBufferManager* gpu_memory_buffer_manager)
: factory_(factory),
gpu_info_(gpu_info),
- gpu_memory_buffer_manager_(gpu_memory_buffer_manager) {
+ gpu_memory_buffer_manager_(gpu_memory_buffer_manager),
+ next_signal_id_(0) {
next_transfer_buffer_id_.GetNext();
next_image_id_.GetNext();
next_route_id_.GetNext();
@@ -319,6 +320,63 @@ int32 GpuChannelHost::GenerateRouteID() {
return next_route_id_.GetNext();
}
+void GpuChannelHost::WaitForPendingGpuMemoryBufferUsageToComplete(
+ const base::Closure& callback) {
+ uint32 signal_id = next_signal_id_++;
+ signal_tasks_.insert(std::make_pair(signal_id, callback));
+
+ factory_->GetMainLoop()->PostTask(
+ FROM_HERE,
+ base::Bind(
+ &GpuChannelHost::WaitForPendingGpuMemoryBufferUsageToCompleteOnMain,
+ base::Unretained(this),
+ signal_id));
+}
+
+void GpuChannelHost::WaitForPendingGpuMemoryBufferUsageToCompleteOnMain(
+ uint32 id) {
+ AutoLock lock(context_lock_);
+
+ size_t num_proxies = proxies_.size();
+ signal_counters_.insert(std::make_pair(id, num_proxies));
reveman 2014/10/21 20:27:58 Instead of signal_counters_ and signal_tasks_ maps
alexst (slow to review) 2014/10/22 14:47:08 That's a good idea, it deals with proxy removal cl
reveman 2014/10/22 16:20:08 hm, does it matter when you can guaranteed that it
+
+ if (!num_proxies) {
+ OnSignalSyncPoint(id);
+ return;
+ }
+
+ for (ProxyMap::iterator it = proxies_.begin(); it != proxies_.end(); it++) {
+ uint32 sync_point = it->second->InsertSyncPoint();
+ it->second->SignalSyncPoint(
+ sync_point,
+ base::Bind(
+ &GpuChannelHost::OnSignalSyncPoint, base::Unretained(this), id));
+ }
+}
+
+void GpuChannelHost::OnSignalSyncPoint(uint32 id) {
+ SignalCounterMap::iterator it = signal_counters_.find(id);
+ DCHECK(it != signal_counters_.end());
+ it->second--;
+
+ if (it->second <= 0) {
+ factory_->GetIOLoopProxy()->PostTask(
+ FROM_HERE,
+ base::Bind(&GpuChannelHost::ProcessSignalCounterOnIO,
+ base::Unretained(this),
+ id));
+ }
+}
+
+void GpuChannelHost::ProcessSignalCounterOnIO(uint32 id) {
+ SignalTaskMap::iterator it = signal_tasks_.find(id);
+ DCHECK(it != signal_tasks_.end());
+
+ base::Closure callback = it->second;
+ signal_tasks_.erase(it);
+ callback.Run();
+}
+
GpuChannelHost::~GpuChannelHost() {
// channel_ must be destroyed on the main thread.
if (!factory_->IsMainThread())
« content/common/gpu/client/gpu_channel_host.h ('K') | « content/common/gpu/client/gpu_channel_host.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698