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

Side by Side Diff: gpu/command_buffer/service/buffer_manager.cc

Issue 1001833005: Update from https://crrev.com/320343 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Supress Created 5 years, 9 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
« no previous file with comments | « gpu/command_buffer/service/buffer_manager.h ('k') | gpu/command_buffer/service/feature_info.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "gpu/command_buffer/service/buffer_manager.h" 5 #include "gpu/command_buffer/service/buffer_manager.h"
6 #include <limits> 6 #include <limits>
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
9 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 9 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
10 #include "gpu/command_buffer/service/context_state.h" 10 #include "gpu/command_buffer/service/context_state.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 void BufferManager::StartTracking(Buffer* /* buffer */) { 68 void BufferManager::StartTracking(Buffer* /* buffer */) {
69 ++buffer_count_; 69 ++buffer_count_;
70 } 70 }
71 71
72 void BufferManager::StopTracking(Buffer* buffer) { 72 void BufferManager::StopTracking(Buffer* buffer) {
73 memory_tracker_->TrackMemFree(buffer->size()); 73 memory_tracker_->TrackMemFree(buffer->size());
74 --buffer_count_; 74 --buffer_count_;
75 } 75 }
76 76
77 Buffer::MappedRange::MappedRange(
78 GLintptr offset, GLsizeiptr size, GLenum access, void* pointer,
79 scoped_refptr<gpu::Buffer> shm)
80 : offset(offset),
81 size(size),
82 access(access),
83 pointer(pointer),
84 shm(shm) {
85 DCHECK(pointer);
86 DCHECK(shm.get() && GetShmPointer());
87 }
88
89 Buffer::MappedRange::~MappedRange() {
90 }
91
92 void* Buffer::MappedRange::GetShmPointer() const {
93 DCHECK(shm.get());
94 return shm->GetDataAddress(static_cast<unsigned int>(offset),
95 static_cast<unsigned int>(size));
96 }
97
77 Buffer::Buffer(BufferManager* manager, GLuint service_id) 98 Buffer::Buffer(BufferManager* manager, GLuint service_id)
78 : manager_(manager), 99 : manager_(manager),
79 size_(0), 100 size_(0),
80 deleted_(false), 101 deleted_(false),
81 shadowed_(false), 102 shadowed_(false),
82 is_client_side_array_(false), 103 is_client_side_array_(false),
83 service_id_(service_id), 104 service_id_(service_id),
84 target_(0), 105 target_(0),
85 usage_(GL_STATIC_DRAW) { 106 usage_(GL_STATIC_DRAW) {
86 manager_->StartTracking(this); 107 manager_->StartTracking(this);
(...skipping 25 matching lines...) Expand all
112 shadow_.reset(); 133 shadow_.reset();
113 } 134 }
114 } 135 }
115 if (shadowed_) { 136 if (shadowed_) {
116 if (data) { 137 if (data) {
117 memcpy(shadow_.get(), data, size); 138 memcpy(shadow_.get(), data, size);
118 } else { 139 } else {
119 memset(shadow_.get(), 0, size); 140 memset(shadow_.get(), 0, size);
120 } 141 }
121 } 142 }
143 mapped_range_.reset(nullptr);
122 } 144 }
123 145
124 bool Buffer::CheckRange( 146 bool Buffer::CheckRange(
125 GLintptr offset, GLsizeiptr size) const { 147 GLintptr offset, GLsizeiptr size) const {
126 int32 end = 0; 148 int32 end = 0;
127 return offset >= 0 && size >= 0 && 149 return offset >= 0 && size >= 0 &&
128 offset <= std::numeric_limits<int32>::max() && 150 offset <= std::numeric_limits<int32>::max() &&
129 size <= std::numeric_limits<int32>::max() && 151 size <= std::numeric_limits<int32>::max() &&
130 SafeAddInt32(offset, size, &end) && end <= size_; 152 SafeAddInt32(offset, size, &end) && end <= size_;
131 } 153 }
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 } 412 }
391 if (buffer->target() == 0) { 413 if (buffer->target() == 0) {
392 buffer->set_target(target); 414 buffer->set_target(target);
393 } 415 }
394 return true; 416 return true;
395 } 417 }
396 418
397 // Since one BufferManager can be shared by multiple decoders, ContextState is 419 // Since one BufferManager can be shared by multiple decoders, ContextState is
398 // passed in each time and not just passed in during initialization. 420 // passed in each time and not just passed in during initialization.
399 Buffer* BufferManager::GetBufferInfoForTarget( 421 Buffer* BufferManager::GetBufferInfoForTarget(
400 ContextState* state, GLenum target) { 422 ContextState* state, GLenum target) const {
401 DCHECK(target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER); 423 switch (target) {
402 if (target == GL_ARRAY_BUFFER) { 424 case GL_ARRAY_BUFFER:
403 return state->bound_array_buffer.get(); 425 return state->bound_array_buffer.get();
404 } else { 426 case GL_ELEMENT_ARRAY_BUFFER:
405 return state->vertex_attrib_manager->element_array_buffer(); 427 return state->vertex_attrib_manager->element_array_buffer();
428 case GL_COPY_READ_BUFFER:
429 case GL_COPY_WRITE_BUFFER:
430 case GL_PIXEL_PACK_BUFFER:
431 case GL_PIXEL_UNPACK_BUFFER:
432 case GL_TRANSFORM_FEEDBACK_BUFFER:
433 case GL_UNIFORM_BUFFER:
434 NOTIMPLEMENTED();
435 return nullptr;
436 default:
437 NOTREACHED();
438 return nullptr;
406 } 439 }
407 } 440 }
408 441
409 } // namespace gles2 442 } // namespace gles2
410 } // namespace gpu 443 } // namespace gpu
411 444
412 445
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/buffer_manager.h ('k') | gpu/command_buffer/service/feature_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698