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

Side by Side Diff: gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.cc

Issue 2912753002: Add gfx::GpuMemoryBuffer::shared_memory_handle() (Closed)
Patch Set: Created 3 years, 6 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 "gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h" 5 #include "gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 // static 159 // static
160 base::Closure GpuMemoryBufferImplSharedMemory::AllocateForTesting( 160 base::Closure GpuMemoryBufferImplSharedMemory::AllocateForTesting(
161 const gfx::Size& size, 161 const gfx::Size& size,
162 gfx::BufferFormat format, 162 gfx::BufferFormat format,
163 gfx::BufferUsage usage, 163 gfx::BufferUsage usage,
164 gfx::GpuMemoryBufferHandle* handle) { 164 gfx::GpuMemoryBufferHandle* handle) {
165 *handle = CreateGpuMemoryBuffer(handle->id, size, format); 165 *handle = CreateGpuMemoryBuffer(handle->id, size, format);
166 return base::Bind(&base::DoNothing); 166 return base::Bind(&base::DoNothing);
167 } 167 }
168 168
169 base::SharedMemoryHandle GpuMemoryBufferImplSharedMemory::shared_memory_handle()
170 const {
171 if (!shared_memory_)
172 return base::SharedMemoryHandle();
173 return shared_memory_->handle();
174 }
175
169 bool GpuMemoryBufferImplSharedMemory::Map() { 176 bool GpuMemoryBufferImplSharedMemory::Map() {
170 DCHECK(!mapped_); 177 DCHECK(!mapped_);
171 178
172 // Map the buffer first time Map() is called then keep it mapped for the 179 // Map the buffer first time Map() is called then keep it mapped for the
173 // lifetime of the buffer. This avoids mapping the buffer unless necessary. 180 // lifetime of the buffer. This avoids mapping the buffer unless necessary.
174 if (!shared_memory_->memory()) { 181 if (!shared_memory_->memory()) {
175 DCHECK_EQ(static_cast<size_t>(stride_), 182 DCHECK_EQ(static_cast<size_t>(stride_),
176 gfx::RowSizeForBufferFormat(size_.width(), format_, 0)); 183 gfx::RowSizeForBufferFormat(size_.width(), format_, 0));
177 size_t buffer_size = gfx::BufferSizeForBufferFormat(size_, format_); 184 size_t buffer_size = gfx::BufferSizeForBufferFormat(size_, format_);
178 // Note: offset_ != 0 is not common use-case. To keep it simple we 185 // Note: offset_ != 0 is not common use-case. To keep it simple we
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 return handle; 219 return handle;
213 } 220 }
214 221
215 base::trace_event::MemoryAllocatorDumpGuid 222 base::trace_event::MemoryAllocatorDumpGuid
216 GpuMemoryBufferImplSharedMemory::GetGUIDForTracing( 223 GpuMemoryBufferImplSharedMemory::GetGUIDForTracing(
217 uint64_t tracing_process_id) const { 224 uint64_t tracing_process_id) const {
218 return gfx::GetSharedMemoryGUIDForTracing(tracing_process_id, id_); 225 return gfx::GetSharedMemoryGUIDForTracing(tracing_process_id, id_);
219 } 226 }
220 227
221 } // namespace gpu 228 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698