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

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: . 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 DCHECK(usage == gfx::GpuMemoryBuffer::MAP ||
104 usage == gfx::GpuMemoryBuffer::PERSISTENT_MAP)
105 << usage;
reveman 2015/05/19 16:12:12 Do you mind adding a GpuMemoryBufferImplSharedMemo
danakj 2015/05/19 22:19:43 Done.
104 return GpuMemoryBufferImplSharedMemory::Create( 106 return GpuMemoryBufferImplSharedMemory::Create(
105 g_next_gpu_memory_buffer_id.GetNext(), size, format); 107 g_next_gpu_memory_buffer_id.GetNext(), size, format);
106 } 108 }
107 109
108 AllocateGpuMemoryBufferRequest request(size, format, usage, gpu_client_id_, 110 AllocateGpuMemoryBufferRequest request(size, format, usage, gpu_client_id_,
109 surface_id); 111 surface_id);
110 BrowserThread::PostTask( 112 BrowserThread::PostTask(
111 BrowserThread::IO, 113 BrowserThread::IO,
112 FROM_HERE, 114 FROM_HERE,
113 base::Bind(&BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferOnIO, 115 base::Bind(&BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferOnIO,
(...skipping 21 matching lines...) Expand all
135 137
136 BufferMap& buffers = clients_[child_client_id]; 138 BufferMap& buffers = clients_[child_client_id];
137 DCHECK(buffers.find(new_id) == buffers.end()); 139 DCHECK(buffers.find(new_id) == buffers.end());
138 140
139 // Fallback to shared memory buffer if |format| and |usage| are not supported 141 // Fallback to shared memory buffer if |format| and |usage| are not supported
140 // by factory. 142 // by factory.
141 if (!gpu_memory_buffer_factory_host_->IsGpuMemoryBufferConfigurationSupported( 143 if (!gpu_memory_buffer_factory_host_->IsGpuMemoryBufferConfigurationSupported(
142 format, usage)) { 144 format, usage)) {
143 // Early out if we cannot fallback to shared memory buffer. 145 // Early out if we cannot fallback to shared memory buffer.
144 if (!GpuMemoryBufferImplSharedMemory::IsFormatSupported(format) || 146 if (!GpuMemoryBufferImplSharedMemory::IsFormatSupported(format) ||
145 !GpuMemoryBufferImplSharedMemory::IsSizeValidForFormat(size, format) || 147 !GpuMemoryBufferImplSharedMemory::IsSizeValidForFormat(size, format)) {
146 usage != gfx::GpuMemoryBuffer::MAP) {
147 callback.Run(gfx::GpuMemoryBufferHandle()); 148 callback.Run(gfx::GpuMemoryBufferHandle());
148 return; 149 return;
149 } 150 }
151 if (usage != gfx::GpuMemoryBuffer::MAP &&
152 usage != gfx::GpuMemoryBuffer::PERSISTENT_MAP) {
153 callback.Run(gfx::GpuMemoryBufferHandle());
154 return;
155 }
150 156
151 buffers[new_id] = BufferInfo(size, format, gfx::SHARED_MEMORY_BUFFER); 157 buffers[new_id] = BufferInfo(size, format, gfx::SHARED_MEMORY_BUFFER);
152 callback.Run(GpuMemoryBufferImplSharedMemory::AllocateForChildProcess( 158 callback.Run(GpuMemoryBufferImplSharedMemory::AllocateForChildProcess(
153 new_id, size, format, child_process_handle)); 159 new_id, size, format, child_process_handle));
154 return; 160 return;
155 } 161 }
156 162
157 // Note: Handling of cases where the child process is removed before the 163 // Note: Handling of cases where the child process is removed before the
158 // allocation completes is less subtle if we set the buffer type to 164 // allocation completes is less subtle if we set the buffer type to
159 // EMPTY_BUFFER here and verify that this has not changed when allocation 165 // EMPTY_BUFFER here and verify that this has not changed when allocation
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 DCHECK_NE(handle.type, gfx::SHARED_MEMORY_BUFFER); 356 DCHECK_NE(handle.type, gfx::SHARED_MEMORY_BUFFER);
351 357
352 // Store the type of this buffer so it can be cleaned up if the child 358 // Store the type of this buffer so it can be cleaned up if the child
353 // process is removed. 359 // process is removed.
354 buffer_it->second.type = handle.type; 360 buffer_it->second.type = handle.type;
355 361
356 callback.Run(handle); 362 callback.Run(handle);
357 } 363 }
358 364
359 } // namespace content 365 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698