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

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

Issue 1168853002: Use mapped memory for uploading large textures. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Same fix for TexImage3D, also share uploading code. Created 5 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) 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/client/mapped_memory.h" 5 #include "gpu/command_buffer/client/mapped_memory.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 if (!chunk->InUse()) { 133 if (!chunk->InUse()) {
134 cmd_buf->DestroyTransferBuffer(chunk->shm_id()); 134 cmd_buf->DestroyTransferBuffer(chunk->shm_id());
135 allocated_memory_ -= chunk->GetSize(); 135 allocated_memory_ -= chunk->GetSize();
136 iter = chunks_.erase(iter); 136 iter = chunks_.erase(iter);
137 } else { 137 } else {
138 ++iter; 138 ++iter;
139 } 139 }
140 } 140 }
141 } 141 }
142 142
143 void ScopedMappedMemoryPtr::Release() {
144 if (buffer_) {
145 mapped_memory_manager_->FreePendingToken(buffer_, helper_->InsertToken());
146 buffer_ = nullptr;
147 size_ = 0;
148 shm_id_ = 0;
149 shm_offset_ = 0;
150
151 if (flush_after_release_)
152 helper_->CommandBufferHelper::Flush();
153 }
154 }
155
156 void ScopedMappedMemoryPtr::Reset(unsigned int new_size) {
157 Release();
158
159 if (new_size) {
160 buffer_ = mapped_memory_manager_->Alloc(size_, &shm_id_, &shm_offset_);
161 size_ = buffer_ ? new_size : 0;
162 }
163 }
164
143 } // namespace gpu 165 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698