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

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

Issue 500243002: Remove implicit conversions from scoped_refptr to T* in gpu/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert silliness Created 6 years, 3 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 "base/bits.h" 9 #include "base/bits.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 buffer_id_ = -1; 58 buffer_id_ = -1;
59 buffer_ = NULL; 59 buffer_ = NULL;
60 result_buffer_ = NULL; 60 result_buffer_ = NULL;
61 result_shm_offset_ = 0; 61 result_shm_offset_ = 0;
62 ring_buffer_.reset(); 62 ring_buffer_.reset();
63 bytes_since_last_flush_ = 0; 63 bytes_since_last_flush_ = 0;
64 } 64 }
65 } 65 }
66 66
67 bool TransferBuffer::HaveBuffer() const { 67 bool TransferBuffer::HaveBuffer() const {
68 DCHECK(buffer_id_ == -1 || buffer_); 68 DCHECK(buffer_id_ == -1 || buffer_.get());
69 return buffer_id_ != -1; 69 return buffer_id_ != -1;
70 } 70 }
71 71
72 RingBuffer::Offset TransferBuffer::GetOffset(void* pointer) const { 72 RingBuffer::Offset TransferBuffer::GetOffset(void* pointer) const {
73 return ring_buffer_->GetOffset(pointer); 73 return ring_buffer_->GetOffset(pointer);
74 } 74 }
75 75
76 void TransferBuffer::FreePendingToken(void* p, unsigned int token) { 76 void TransferBuffer::FreePendingToken(void* p, unsigned int token) {
77 ring_buffer_->FreePendingToken(p, token); 77 ring_buffer_->FreePendingToken(p, token);
78 if (bytes_since_last_flush_ >= size_to_flush_ && size_to_flush_ > 0) { 78 if (bytes_since_last_flush_ >= size_to_flush_ && size_to_flush_ > 0) {
79 helper_->Flush(); 79 helper_->Flush();
80 bytes_since_last_flush_ = 0; 80 bytes_since_last_flush_ = 0;
81 } 81 }
82 } 82 }
83 83
84 void TransferBuffer::AllocateRingBuffer(unsigned int size) { 84 void TransferBuffer::AllocateRingBuffer(unsigned int size) {
85 for (;size >= min_buffer_size_; size /= 2) { 85 for (;size >= min_buffer_size_; size /= 2) {
86 int32 id = -1; 86 int32 id = -1;
87 scoped_refptr<gpu::Buffer> buffer = 87 scoped_refptr<gpu::Buffer> buffer =
88 helper_->command_buffer()->CreateTransferBuffer(size, &id); 88 helper_->command_buffer()->CreateTransferBuffer(size, &id);
89 if (id != -1) { 89 if (id != -1) {
90 DCHECK(buffer); 90 DCHECK(buffer.get());
91 buffer_ = buffer; 91 buffer_ = buffer;
92 ring_buffer_.reset(new RingBuffer( 92 ring_buffer_.reset(new RingBuffer(
93 alignment_, 93 alignment_,
94 result_size_, 94 result_size_,
95 buffer_->size() - result_size_, 95 buffer_->size() - result_size_,
96 helper_, 96 helper_,
97 static_cast<char*>(buffer_->memory()) + result_size_)); 97 static_cast<char*>(buffer_->memory()) + result_size_));
98 buffer_id_ = id; 98 buffer_id_ = id;
99 result_buffer_ = buffer_->memory(); 99 result_buffer_ = buffer_->memory();
100 result_shm_offset_ = 0; 100 result_shm_offset_ = 0;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 Release(); 192 Release();
193 // NOTE: we allocate buffers of size 0 so that HaveBuffer will be true, so 193 // NOTE: we allocate buffers of size 0 so that HaveBuffer will be true, so
194 // that address will return a pointer just like malloc, and so that GetShmId 194 // that address will return a pointer just like malloc, and so that GetShmId
195 // will be valid. That has the side effect that we'll insert a token on free. 195 // will be valid. That has the side effect that we'll insert a token on free.
196 // We could add code skip the token for a zero size buffer but it doesn't seem 196 // We could add code skip the token for a zero size buffer but it doesn't seem
197 // worth the complication. 197 // worth the complication.
198 buffer_ = transfer_buffer_->AllocUpTo(new_size, &size_); 198 buffer_ = transfer_buffer_->AllocUpTo(new_size, &size_);
199 } 199 }
200 200
201 } // namespace gpu 201 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/mapped_memory.cc ('k') | gpu/command_buffer/service/async_pixel_transfer_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698