OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/command_buffer/service/command_buffer_service.h" | 5 #include "gpu/command_buffer/service/command_buffer_service.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 } | 42 } |
43 | 43 |
44 if (size <= 0 || size > kMaxCommandBufferSize) { | 44 if (size <= 0 || size > kMaxCommandBufferSize) { |
45 LOG(ERROR) << "Failed because command buffer size was invalid."; | 45 LOG(ERROR) << "Failed because command buffer size was invalid."; |
46 return false; | 46 return false; |
47 } | 47 } |
48 | 48 |
49 num_entries_ = size / sizeof(CommandBufferEntry); | 49 num_entries_ = size / sizeof(CommandBufferEntry); |
50 | 50 |
51 SharedMemory shared_memory; | 51 SharedMemory shared_memory; |
52 if (!shared_memory.CreateAnonymous(size)) { | 52 if (!shared_memory.CreateAnonymous(size, false)) { |
53 LOG(ERROR) << "Failed to create shared memory for command buffer."; | 53 LOG(ERROR) << "Failed to create shared memory for command buffer."; |
54 return true; | 54 return true; |
55 } | 55 } |
56 | 56 |
57 return Initialize(&shared_memory, size); | 57 return Initialize(&shared_memory, size); |
58 } | 58 } |
59 | 59 |
60 bool CommandBufferService::Initialize(base::SharedMemory* buffer, int32 size) { | 60 bool CommandBufferService::Initialize(base::SharedMemory* buffer, int32 size) { |
61 // Fail if already initialized. | 61 // Fail if already initialized. |
62 if (ring_buffer_.shared_memory) { | 62 if (ring_buffer_.shared_memory) { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 } | 138 } |
139 | 139 |
140 void CommandBufferService::SetGetOffset(int32 get_offset) { | 140 void CommandBufferService::SetGetOffset(int32 get_offset) { |
141 DCHECK(get_offset >= 0 && get_offset < num_entries_); | 141 DCHECK(get_offset >= 0 && get_offset < num_entries_); |
142 get_offset_ = get_offset; | 142 get_offset_ = get_offset; |
143 } | 143 } |
144 | 144 |
145 int32 CommandBufferService::CreateTransferBuffer(size_t size, | 145 int32 CommandBufferService::CreateTransferBuffer(size_t size, |
146 int32 id_request) { | 146 int32 id_request) { |
147 SharedMemory buffer; | 147 SharedMemory buffer; |
148 if (!buffer.CreateAnonymous(size)) | 148 if (!buffer.CreateAnonymous(size, false)) |
149 return -1; | 149 return -1; |
150 | 150 |
151 return RegisterTransferBuffer(&buffer, size, id_request); | 151 return RegisterTransferBuffer(&buffer, size, id_request); |
152 } | 152 } |
153 | 153 |
154 int32 CommandBufferService::RegisterTransferBuffer( | 154 int32 CommandBufferService::RegisterTransferBuffer( |
155 base::SharedMemory* shared_memory, size_t size, int32 id_request) { | 155 base::SharedMemory* shared_memory, size_t size, int32 id_request) { |
156 // Check we haven't exceeded the range that fits in a 32-bit integer. | 156 // Check we haven't exceeded the range that fits in a 32-bit integer. |
157 if (unused_registered_object_elements_.empty()) { | 157 if (unused_registered_object_elements_.empty()) { |
158 if (registered_objects_.size() > std::numeric_limits<uint32>::max()) | 158 if (registered_objects_.size() > std::numeric_limits<uint32>::max()) |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 Callback0::Type* callback) { | 268 Callback0::Type* callback) { |
269 put_offset_change_callback_.reset(callback); | 269 put_offset_change_callback_.reset(callback); |
270 } | 270 } |
271 | 271 |
272 void CommandBufferService::SetParseErrorCallback( | 272 void CommandBufferService::SetParseErrorCallback( |
273 Callback0::Type* callback) { | 273 Callback0::Type* callback) { |
274 parse_error_callback_.reset(callback); | 274 parse_error_callback_.reset(callback); |
275 } | 275 } |
276 | 276 |
277 } // namespace gpu | 277 } // namespace gpu |
OLD | NEW |