OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 if (shadowed_) { | 72 if (shadowed_) { |
73 shadow_.reset(new int8[size]); | 73 shadow_.reset(new int8[size]); |
74 memset(shadow_.get(), 0, size); | 74 memset(shadow_.get(), 0, size); |
75 } | 75 } |
76 } | 76 } |
77 } | 77 } |
78 | 78 |
79 bool BufferManager::BufferInfo::SetRange( | 79 bool BufferManager::BufferInfo::SetRange( |
80 GLintptr offset, GLsizeiptr size, const GLvoid * data) { | 80 GLintptr offset, GLsizeiptr size, const GLvoid * data) { |
81 DCHECK(!IsDeleted()); | 81 DCHECK(!IsDeleted()); |
82 if (offset + size < offset || offset + size > size_) { | 82 if (offset < 0 || offset + size < offset || offset + size > size_) { |
83 return false; | 83 return false; |
84 } | 84 } |
85 if (shadowed_) { | 85 if (shadowed_) { |
86 memcpy(shadow_.get() + offset, data, size); | 86 memcpy(shadow_.get() + offset, data, size); |
87 ClearCache(); | 87 ClearCache(); |
88 } | 88 } |
89 return true; | 89 return true; |
90 } | 90 } |
91 | 91 |
92 const void* BufferManager::BufferInfo::GetRange( | 92 const void* BufferManager::BufferInfo::GetRange( |
93 GLintptr offset, GLsizeiptr size) const { | 93 GLintptr offset, GLsizeiptr size) const { |
94 if (!shadowed_ || (offset + size < offset || offset + size > size_)) { | 94 if (!shadowed_) { |
| 95 return NULL; |
| 96 } |
| 97 if (offset < 0 || offset + size < offset || offset + size > size_) { |
95 return NULL; | 98 return NULL; |
96 } | 99 } |
97 return shadow_.get() + offset; | 100 return shadow_.get() + offset; |
98 } | 101 } |
99 | 102 |
100 void BufferManager::BufferInfo::ClearCache() { | 103 void BufferManager::BufferInfo::ClearCache() { |
101 range_set_.clear(); | 104 range_set_.clear(); |
102 } | 105 } |
103 | 106 |
104 template <typename T> | 107 template <typename T> |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 if (info->target() == 0) { | 204 if (info->target() == 0) { |
202 info->set_target(target); | 205 info->set_target(target); |
203 } | 206 } |
204 return true; | 207 return true; |
205 } | 208 } |
206 | 209 |
207 } // namespace gles2 | 210 } // namespace gles2 |
208 } // namespace gpu | 211 } // namespace gpu |
209 | 212 |
210 | 213 |
OLD | NEW |