| OLD | NEW |
| 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/service/buffer_manager.h" | 5 #include "gpu/command_buffer/service/buffer_manager.h" |
| 6 #include "base/logging.h" | 6 #include "base/logging.h" |
| 7 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 7 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 8 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 8 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 9 | 9 |
| 10 namespace gpu { | 10 namespace gpu { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 target_(0), | 59 target_(0), |
| 60 size_(0), | 60 size_(0), |
| 61 usage_(GL_STATIC_DRAW), | 61 usage_(GL_STATIC_DRAW), |
| 62 shadowed_(false) { | 62 shadowed_(false) { |
| 63 } | 63 } |
| 64 | 64 |
| 65 BufferManager::BufferInfo::~BufferInfo() { } | 65 BufferManager::BufferInfo::~BufferInfo() { } |
| 66 | 66 |
| 67 void BufferManager::BufferInfo::SetInfo( | 67 void BufferManager::BufferInfo::SetInfo( |
| 68 GLsizeiptr size, GLenum usage, bool shadow) { | 68 GLsizeiptr size, GLenum usage, bool shadow) { |
| 69 DCHECK(!IsDeleted()); | |
| 70 usage_ = usage; | 69 usage_ = usage; |
| 71 if (size != size_ || shadow != shadowed_) { | 70 if (size != size_ || shadow != shadowed_) { |
| 72 shadowed_ = shadow; | 71 shadowed_ = shadow; |
| 73 size_ = size; | 72 size_ = size; |
| 74 ClearCache(); | 73 ClearCache(); |
| 75 if (shadowed_) { | 74 if (shadowed_) { |
| 76 shadow_.reset(new int8[size]); | 75 shadow_.reset(new int8[size]); |
| 77 memset(shadow_.get(), 0, size); | 76 memset(shadow_.get(), 0, size); |
| 78 } | 77 } |
| 79 } | 78 } |
| 80 } | 79 } |
| 81 | 80 |
| 82 bool BufferManager::BufferInfo::SetRange( | 81 bool BufferManager::BufferInfo::SetRange( |
| 83 GLintptr offset, GLsizeiptr size, const GLvoid * data) { | 82 GLintptr offset, GLsizeiptr size, const GLvoid * data) { |
| 84 DCHECK(!IsDeleted()); | |
| 85 if (offset < 0 || offset + size < offset || offset + size > size_) { | 83 if (offset < 0 || offset + size < offset || offset + size > size_) { |
| 86 return false; | 84 return false; |
| 87 } | 85 } |
| 88 if (shadowed_) { | 86 if (shadowed_) { |
| 89 memcpy(shadow_.get() + offset, data, size); | 87 memcpy(shadow_.get() + offset, data, size); |
| 90 ClearCache(); | 88 ClearCache(); |
| 91 } | 89 } |
| 92 return true; | 90 return true; |
| 93 } | 91 } |
| 94 | 92 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 116 for (; element < end; ++element) { | 114 for (; element < end; ++element) { |
| 117 if (*element > max_value) { | 115 if (*element > max_value) { |
| 118 max_value = *element; | 116 max_value = *element; |
| 119 } | 117 } |
| 120 } | 118 } |
| 121 return max_value; | 119 return max_value; |
| 122 } | 120 } |
| 123 | 121 |
| 124 bool BufferManager::BufferInfo::GetMaxValueForRange( | 122 bool BufferManager::BufferInfo::GetMaxValueForRange( |
| 125 GLuint offset, GLsizei count, GLenum type, GLuint* max_value) { | 123 GLuint offset, GLsizei count, GLenum type, GLuint* max_value) { |
| 126 DCHECK(!IsDeleted()); | |
| 127 Range range(offset, count, type); | 124 Range range(offset, count, type); |
| 128 RangeToMaxValueMap::iterator it = range_set_.find(range); | 125 RangeToMaxValueMap::iterator it = range_set_.find(range); |
| 129 if (it != range_set_.end()) { | 126 if (it != range_set_.end()) { |
| 130 *max_value = it->second; | 127 *max_value = it->second; |
| 131 return true; | 128 return true; |
| 132 } | 129 } |
| 133 | 130 |
| 134 uint32 size; | 131 uint32 size; |
| 135 if (!SafeMultiplyUint32( | 132 if (!SafeMultiplyUint32( |
| 136 count, GLES2Util::GetGLTypeSizeForTexturesAndBuffers(type), &size)) { | 133 count, GLES2Util::GetGLTypeSizeForTexturesAndBuffers(type), &size)) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 if (info->target() == 0) { | 205 if (info->target() == 0) { |
| 209 info->set_target(target); | 206 info->set_target(target); |
| 210 } | 207 } |
| 211 return true; | 208 return true; |
| 212 } | 209 } |
| 213 | 210 |
| 214 } // namespace gles2 | 211 } // namespace gles2 |
| 215 } // namespace gpu | 212 } // namespace gpu |
| 216 | 213 |
| 217 | 214 |
| OLD | NEW |