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

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

Issue 1542513002: Switch to standard integer types in gpu/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 12 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>
10 #include <stdint.h>
11
9 #include "base/bits.h" 12 #include "base/bits.h"
10 #include "base/logging.h" 13 #include "base/logging.h"
11 #include "base/trace_event/trace_event.h" 14 #include "base/trace_event/trace_event.h"
12 #include "gpu/command_buffer/client/cmd_buffer_helper.h" 15 #include "gpu/command_buffer/client/cmd_buffer_helper.h"
13 16
14 namespace gpu { 17 namespace gpu {
15 18
16 TransferBuffer::TransferBuffer( 19 TransferBuffer::TransferBuffer(
17 CommandBufferHelper* helper) 20 CommandBufferHelper* helper)
18 : helper_(helper), 21 : helper_(helper),
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 unsigned int TransferBuffer::GetSize() const { 91 unsigned int TransferBuffer::GetSize() const {
89 return HaveBuffer() ? ring_buffer_->GetLargestFreeOrPendingSize() : 0; 92 return HaveBuffer() ? ring_buffer_->GetLargestFreeOrPendingSize() : 0;
90 } 93 }
91 94
92 unsigned int TransferBuffer::GetFreeSize() const { 95 unsigned int TransferBuffer::GetFreeSize() const {
93 return HaveBuffer() ? ring_buffer_->GetTotalFreeSizeNoWaiting() : 0; 96 return HaveBuffer() ? ring_buffer_->GetTotalFreeSizeNoWaiting() : 0;
94 } 97 }
95 98
96 void TransferBuffer::AllocateRingBuffer(unsigned int size) { 99 void TransferBuffer::AllocateRingBuffer(unsigned int size) {
97 for (;size >= min_buffer_size_; size /= 2) { 100 for (;size >= min_buffer_size_; size /= 2) {
98 int32 id = -1; 101 int32_t id = -1;
99 scoped_refptr<gpu::Buffer> buffer = 102 scoped_refptr<gpu::Buffer> buffer =
100 helper_->command_buffer()->CreateTransferBuffer(size, &id); 103 helper_->command_buffer()->CreateTransferBuffer(size, &id);
101 if (id != -1) { 104 if (id != -1) {
102 DCHECK(buffer.get()); 105 DCHECK(buffer.get());
103 buffer_ = buffer; 106 buffer_ = buffer;
104 ring_buffer_.reset(new RingBuffer( 107 ring_buffer_.reset(new RingBuffer(
105 alignment_, 108 alignment_,
106 result_size_, 109 result_size_,
107 buffer_->size() - result_size_, 110 buffer_->size() - result_size_,
108 helper_, 111 helper_,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 Release(); 215 Release();
213 // NOTE: we allocate buffers of size 0 so that HaveBuffer will be true, so 216 // NOTE: we allocate buffers of size 0 so that HaveBuffer will be true, so
214 // that address will return a pointer just like malloc, and so that GetShmId 217 // that address will return a pointer just like malloc, and so that GetShmId
215 // will be valid. That has the side effect that we'll insert a token on free. 218 // will be valid. That has the side effect that we'll insert a token on free.
216 // We could add code skip the token for a zero size buffer but it doesn't seem 219 // We could add code skip the token for a zero size buffer but it doesn't seem
217 // worth the complication. 220 // worth the complication.
218 buffer_ = transfer_buffer_->AllocUpTo(new_size, &size_); 221 buffer_ = transfer_buffer_->AllocUpTo(new_size, &size_);
219 } 222 }
220 223
221 } // namespace gpu 224 } // 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