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

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

Issue 2526683002: gpu: Rename AllocateGpuMemoryBuffer to CreateGpuMemoryBuffer. (Closed)
Patch Set: . Created 4 years 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 if (!shared_memory->CreateAndMapAnonymous(buffer_size)) 47 if (!shared_memory->CreateAndMapAnonymous(buffer_size))
48 return nullptr; 48 return nullptr;
49 49
50 return base::WrapUnique(new GpuMemoryBufferImplSharedMemory( 50 return base::WrapUnique(new GpuMemoryBufferImplSharedMemory(
51 id, size, format, callback, std::move(shared_memory), 0, 51 id, size, format, callback, std::move(shared_memory), 0,
52 gfx::RowSizeForBufferFormat(size.width(), format, 0))); 52 gfx::RowSizeForBufferFormat(size.width(), format, 0)));
53 } 53 }
54 54
55 // static 55 // static
56 gfx::GpuMemoryBufferHandle 56 gfx::GpuMemoryBufferHandle
57 GpuMemoryBufferImplSharedMemory::AllocateGpuMemoryBuffer( 57 GpuMemoryBufferImplSharedMemory::CreateGpuMemoryBuffer(
58 gfx::GpuMemoryBufferId id, 58 gfx::GpuMemoryBufferId id,
59 const gfx::Size& size, 59 const gfx::Size& size,
60 gfx::BufferFormat format) { 60 gfx::BufferFormat format) {
61 size_t buffer_size = 0u; 61 size_t buffer_size = 0u;
62 if (!gfx::BufferSizeForBufferFormatChecked(size, format, &buffer_size)) 62 if (!gfx::BufferSizeForBufferFormatChecked(size, format, &buffer_size))
63 return gfx::GpuMemoryBufferHandle(); 63 return gfx::GpuMemoryBufferHandle();
64 64
65 base::SharedMemory shared_memory; 65 base::SharedMemory shared_memory;
66 if (!shared_memory.CreateAnonymous(buffer_size)) 66 if (!shared_memory.CreateAnonymous(buffer_size))
67 return gfx::GpuMemoryBufferHandle(); 67 return gfx::GpuMemoryBufferHandle();
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 NOTREACHED(); 152 NOTREACHED();
153 return false; 153 return false;
154 } 154 }
155 155
156 // static 156 // static
157 base::Closure GpuMemoryBufferImplSharedMemory::AllocateForTesting( 157 base::Closure GpuMemoryBufferImplSharedMemory::AllocateForTesting(
158 const gfx::Size& size, 158 const gfx::Size& size,
159 gfx::BufferFormat format, 159 gfx::BufferFormat format,
160 gfx::BufferUsage usage, 160 gfx::BufferUsage usage,
161 gfx::GpuMemoryBufferHandle* handle) { 161 gfx::GpuMemoryBufferHandle* handle) {
162 *handle = AllocateGpuMemoryBuffer(handle->id, size, format); 162 *handle = CreateGpuMemoryBuffer(handle->id, size, format);
163 return base::Bind(&base::DoNothing); 163 return base::Bind(&base::DoNothing);
164 } 164 }
165 165
166 bool GpuMemoryBufferImplSharedMemory::Map() { 166 bool GpuMemoryBufferImplSharedMemory::Map() {
167 DCHECK(!mapped_); 167 DCHECK(!mapped_);
168 168
169 // Map the buffer first time Map() is called then keep it mapped for the 169 // Map the buffer first time Map() is called then keep it mapped for the
170 // lifetime of the buffer. This avoids mapping the buffer unless necessary. 170 // lifetime of the buffer. This avoids mapping the buffer unless necessary.
171 if (!shared_memory_->memory()) { 171 if (!shared_memory_->memory()) {
172 DCHECK_EQ(static_cast<size_t>(stride_), 172 DCHECK_EQ(static_cast<size_t>(stride_),
(...skipping 30 matching lines...) Expand all
203 gfx::GpuMemoryBufferHandle handle; 203 gfx::GpuMemoryBufferHandle handle;
204 handle.type = gfx::SHARED_MEMORY_BUFFER; 204 handle.type = gfx::SHARED_MEMORY_BUFFER;
205 handle.id = id_; 205 handle.id = id_;
206 handle.offset = offset_; 206 handle.offset = offset_;
207 handle.stride = stride_; 207 handle.stride = stride_;
208 handle.handle = shared_memory_->handle(); 208 handle.handle = shared_memory_->handle();
209 return handle; 209 return handle;
210 } 210 }
211 211
212 } // namespace gpu 212 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h ('k') | gpu/ipc/client/gpu_memory_buffer_impl_test_template.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698