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

Side by Side Diff: gpu/command_buffer/client/transfer_buffer.cc

Issue 2910093004: Add TransferBufferInterface::shared_memory_handle() (Closed)
Patch Set: (rebase) 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // A class to Manage a growing transfer buffer. 5 // A class to Manage a growing transfer buffer.
6 6
7 #include "gpu/command_buffer/client/transfer_buffer.h" 7 #include "gpu/command_buffer/client/transfer_buffer.h"
8 8
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.h>
11 11
12 #include "base/bits.h" 12 #include "base/bits.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/shared_memory_handle.h"
14 #include "base/trace_event/trace_event.h" 15 #include "base/trace_event/trace_event.h"
15 #include "gpu/command_buffer/client/cmd_buffer_helper.h" 16 #include "gpu/command_buffer/client/cmd_buffer_helper.h"
16 17
17 namespace gpu { 18 namespace gpu {
18 19
19 TransferBuffer::TransferBuffer( 20 TransferBuffer::TransferBuffer(
20 CommandBufferHelper* helper) 21 CommandBufferHelper* helper)
21 : helper_(helper), 22 : helper_(helper),
22 result_size_(0), 23 result_size_(0),
23 default_buffer_size_(0), 24 default_buffer_size_(0),
24 min_buffer_size_(0), 25 min_buffer_size_(0),
25 max_buffer_size_(0), 26 max_buffer_size_(0),
26 alignment_(0), 27 alignment_(0),
27 size_to_flush_(0), 28 size_to_flush_(0),
28 bytes_since_last_flush_(0), 29 bytes_since_last_flush_(0),
29 buffer_id_(-1), 30 buffer_id_(-1),
30 result_buffer_(NULL), 31 result_buffer_(NULL),
31 result_shm_offset_(0), 32 result_shm_offset_(0),
32 usable_(true) { 33 usable_(true) {
33 } 34 }
34 35
35 TransferBuffer::~TransferBuffer() { 36 TransferBuffer::~TransferBuffer() {
36 Free(); 37 Free();
37 } 38 }
38 39
40 base::SharedMemoryHandle TransferBuffer::shared_memory_handle() const {
41 if (!HaveBuffer())
42 return base::SharedMemoryHandle();
43 if (!buffer_->backing())
44 return base::SharedMemoryHandle();
45 return buffer_->backing()->shared_memory_handle();
46 }
47
39 bool TransferBuffer::Initialize( 48 bool TransferBuffer::Initialize(
40 unsigned int default_buffer_size, 49 unsigned int default_buffer_size,
41 unsigned int result_size, 50 unsigned int result_size,
42 unsigned int min_buffer_size, 51 unsigned int min_buffer_size,
43 unsigned int max_buffer_size, 52 unsigned int max_buffer_size,
44 unsigned int alignment, 53 unsigned int alignment,
45 unsigned int size_to_flush) { 54 unsigned int size_to_flush) {
46 result_size_ = result_size; 55 result_size_ = result_size;
47 default_buffer_size_ = default_buffer_size; 56 default_buffer_size_ = default_buffer_size;
48 min_buffer_size_ = min_buffer_size; 57 min_buffer_size_ = min_buffer_size;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 Release(); 224 Release();
216 // NOTE: we allocate buffers of size 0 so that HaveBuffer will be true, so 225 // NOTE: we allocate buffers of size 0 so that HaveBuffer will be true, so
217 // that address will return a pointer just like malloc, and so that GetShmId 226 // that address will return a pointer just like malloc, and so that GetShmId
218 // will be valid. That has the side effect that we'll insert a token on free. 227 // will be valid. That has the side effect that we'll insert a token on free.
219 // We could add code skip the token for a zero size buffer but it doesn't seem 228 // We could add code skip the token for a zero size buffer but it doesn't seem
220 // worth the complication. 229 // worth the complication.
221 buffer_ = transfer_buffer_->AllocUpTo(new_size, &size_); 230 buffer_ = transfer_buffer_->AllocUpTo(new_size, &size_);
222 } 231 }
223 232
224 } // namespace gpu 233 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/transfer_buffer.h ('k') | gpu/command_buffer/client/transfer_buffer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698