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

Side by Side Diff: content/browser/gpu/browser_gpu_memory_buffer_manager.cc

Issue 1139903005: Add PERSISTENT_MAP usage for GpuMemoryBuffers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: persistentmap: rebase Created 5 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/gpu/browser_gpu_memory_buffer_manager.h" 5 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
6 6
7 #include "base/atomic_sequence_num.h" 7 #include "base/atomic_sequence_num.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 const gfx::Size& size, 92 const gfx::Size& size,
93 gfx::GpuMemoryBuffer::Format format, 93 gfx::GpuMemoryBuffer::Format format,
94 gfx::GpuMemoryBuffer::Usage usage, 94 gfx::GpuMemoryBuffer::Usage usage,
95 int32 surface_id) { 95 int32 surface_id) {
96 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO)); 96 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO));
97 97
98 // Fallback to shared memory buffer if |format| and |usage| are not supported 98 // Fallback to shared memory buffer if |format| and |usage| are not supported
99 // by factory. 99 // by factory.
100 if (!gpu_memory_buffer_factory_host_->IsGpuMemoryBufferConfigurationSupported( 100 if (!gpu_memory_buffer_factory_host_->IsGpuMemoryBufferConfigurationSupported(
101 format, usage)) { 101 format, usage)) {
102 DCHECK(GpuMemoryBufferImplSharedMemory::IsFormatSupported(format)); 102 DCHECK(GpuMemoryBufferImplSharedMemory::IsFormatSupported(format))
103 DCHECK_EQ(usage, gfx::GpuMemoryBuffer::MAP); 103 << format;
104 DCHECK(GpuMemoryBufferImplSharedMemory::IsUsageSupported(usage)) << usage;
104 return GpuMemoryBufferImplSharedMemory::Create( 105 return GpuMemoryBufferImplSharedMemory::Create(
105 g_next_gpu_memory_buffer_id.GetNext(), size, format); 106 g_next_gpu_memory_buffer_id.GetNext(), size, format);
106 } 107 }
107 108
108 AllocateGpuMemoryBufferRequest request(size, format, usage, gpu_client_id_, 109 AllocateGpuMemoryBufferRequest request(size, format, usage, gpu_client_id_,
109 surface_id); 110 surface_id);
110 BrowserThread::PostTask( 111 BrowserThread::PostTask(
111 BrowserThread::IO, 112 BrowserThread::IO,
112 FROM_HERE, 113 FROM_HERE,
113 base::Bind(&BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferOnIO, 114 base::Bind(&BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferOnIO,
(...skipping 21 matching lines...) Expand all
135 136
136 BufferMap& buffers = clients_[child_client_id]; 137 BufferMap& buffers = clients_[child_client_id];
137 DCHECK(buffers.find(new_id) == buffers.end()); 138 DCHECK(buffers.find(new_id) == buffers.end());
138 139
139 // Fallback to shared memory buffer if |format| and |usage| are not supported 140 // Fallback to shared memory buffer if |format| and |usage| are not supported
140 // by factory. 141 // by factory.
141 if (!gpu_memory_buffer_factory_host_->IsGpuMemoryBufferConfigurationSupported( 142 if (!gpu_memory_buffer_factory_host_->IsGpuMemoryBufferConfigurationSupported(
142 format, usage)) { 143 format, usage)) {
143 // Early out if we cannot fallback to shared memory buffer. 144 // Early out if we cannot fallback to shared memory buffer.
144 if (!GpuMemoryBufferImplSharedMemory::IsFormatSupported(format) || 145 if (!GpuMemoryBufferImplSharedMemory::IsFormatSupported(format) ||
145 !GpuMemoryBufferImplSharedMemory::IsSizeValidForFormat(size, format) || 146 !GpuMemoryBufferImplSharedMemory::IsUsageSupported(usage) ||
146 usage != gfx::GpuMemoryBuffer::MAP) { 147 !GpuMemoryBufferImplSharedMemory::IsSizeValidForFormat(size, format)) {
147 callback.Run(gfx::GpuMemoryBufferHandle()); 148 callback.Run(gfx::GpuMemoryBufferHandle());
148 return; 149 return;
149 } 150 }
150 151
151 buffers[new_id] = BufferInfo(size, format, gfx::SHARED_MEMORY_BUFFER); 152 buffers[new_id] = BufferInfo(size, format, gfx::SHARED_MEMORY_BUFFER);
152 callback.Run(GpuMemoryBufferImplSharedMemory::AllocateForChildProcess( 153 callback.Run(GpuMemoryBufferImplSharedMemory::AllocateForChildProcess(
153 new_id, size, format, child_process_handle)); 154 new_id, size, format, child_process_handle));
154 return; 155 return;
155 } 156 }
156 157
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 DCHECK_NE(handle.type, gfx::SHARED_MEMORY_BUFFER); 351 DCHECK_NE(handle.type, gfx::SHARED_MEMORY_BUFFER);
351 352
352 // Store the type of this buffer so it can be cleaned up if the child 353 // Store the type of this buffer so it can be cleaned up if the child
353 // process is removed. 354 // process is removed.
354 buffer_it->second.type = handle.type; 355 buffer_it->second.type = handle.type;
355 356
356 callback.Run(handle); 357 callback.Run(handle);
357 } 358 }
358 359
359 } // namespace content 360 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gpu/browser_gpu_channel_host_factory.cc ('k') | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698