| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 emluate GLES2 over command buffers. | 5 // A class to emluate GLES2 over command buffers. |
| 6 | 6 |
| 7 #include "../client/gles2_implementation.h" | 7 #include "../client/gles2_implementation.h" |
| 8 #include <GLES2/gles2_command_buffer.h> | 8 #include <GLES2/gles2_command_buffer.h> |
| 9 #include "../client/mapped_memory.h" | 9 #include "../client/mapped_memory.h" |
| 10 #include "../common/gles2_cmd_utils.h" | 10 #include "../common/gles2_cmd_utils.h" |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 if (total_size > array_buffer_size_) { | 304 if (total_size > array_buffer_size_) { |
| 305 gl->BufferData(GL_ARRAY_BUFFER, total_size, NULL, GL_DYNAMIC_DRAW); | 305 gl->BufferData(GL_ARRAY_BUFFER, total_size, NULL, GL_DYNAMIC_DRAW); |
| 306 array_buffer_size_ = total_size; | 306 array_buffer_size_ = total_size; |
| 307 } | 307 } |
| 308 for (GLuint ii = 0; ii < max_vertex_attribs_; ++ii) { | 308 for (GLuint ii = 0; ii < max_vertex_attribs_; ++ii) { |
| 309 VertexAttribInfo& info = vertex_attrib_infos_[ii]; | 309 VertexAttribInfo& info = vertex_attrib_infos_[ii]; |
| 310 if (info.IsClientSide() && info.enabled()) { | 310 if (info.IsClientSide() && info.enabled()) { |
| 311 size_t bytes_per_element = | 311 size_t bytes_per_element = |
| 312 GLES2Util::GetGLTypeSizeForTexturesAndBuffers(info.type()) * | 312 GLES2Util::GetGLTypeSizeForTexturesAndBuffers(info.type()) * |
| 313 info.size(); | 313 info.size(); |
| 314 GLsizei real_stride = | 314 GLsizei real_stride = info.stride() ? |
| 315 info.stride() ? info.stride() : bytes_per_element; | 315 info.stride() : static_cast<GLsizei>(bytes_per_element); |
| 316 GLsizei bytes_collected = CollectData( | 316 GLsizei bytes_collected = CollectData( |
| 317 info.pointer(), bytes_per_element, real_stride, num_elements); | 317 info.pointer(), bytes_per_element, real_stride, num_elements); |
| 318 gl->BufferSubData( | 318 gl->BufferSubData( |
| 319 GL_ARRAY_BUFFER, array_buffer_offset_, bytes_collected, | 319 GL_ARRAY_BUFFER, array_buffer_offset_, bytes_collected, |
| 320 collection_buffer_.get()); | 320 collection_buffer_.get()); |
| 321 gl_helper->VertexAttribPointer( | 321 gl_helper->VertexAttribPointer( |
| 322 ii, info.size(), info.type(), info.normalized(), 0, | 322 ii, info.size(), info.type(), info.normalized(), 0, |
| 323 array_buffer_offset_); | 323 array_buffer_offset_); |
| 324 array_buffer_offset_ += RoundUpToMultipleOf4(bytes_collected); | 324 array_buffer_offset_ += RoundUpToMultipleOf4(bytes_collected); |
| 325 GPU_DCHECK_LE(array_buffer_offset_, array_buffer_size_); | 325 GPU_DCHECK_LE(array_buffer_offset_, array_buffer_size_); |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 } | 807 } |
| 808 if (shader == 0) { | 808 if (shader == 0) { |
| 809 SetGLError(GL_INVALID_VALUE, "glShaderSource shader == 0"); | 809 SetGLError(GL_INVALID_VALUE, "glShaderSource shader == 0"); |
| 810 return; | 810 return; |
| 811 } | 811 } |
| 812 | 812 |
| 813 // Compute the total size. | 813 // Compute the total size. |
| 814 uint32 total_size = 1; | 814 uint32 total_size = 1; |
| 815 for (GLsizei ii = 0; ii < count; ++ii) { | 815 for (GLsizei ii = 0; ii < count; ++ii) { |
| 816 if (source[ii]) { | 816 if (source[ii]) { |
| 817 total_size += | 817 total_size += (length && length[ii] >= 0) ? |
| 818 (length && length[ii] >= 0) ? length[ii] : strlen(source[ii]); | 818 static_cast<size_t>(length[ii]) : strlen(source[ii]); |
| 819 } | 819 } |
| 820 } | 820 } |
| 821 | 821 |
| 822 // Concatenate all the strings in to a bucket on the service. | 822 // Concatenate all the strings in to a bucket on the service. |
| 823 helper_->SetBucketSize(kResultBucketId, total_size); | 823 helper_->SetBucketSize(kResultBucketId, total_size); |
| 824 uint32 max_size = transfer_buffer_.GetLargestFreeOrPendingSize(); | 824 uint32 max_size = transfer_buffer_.GetLargestFreeOrPendingSize(); |
| 825 uint32 offset = 0; | 825 uint32 offset = 0; |
| 826 for (GLsizei ii = 0; ii <= count; ++ii) { | 826 for (GLsizei ii = 0; ii <= count; ++ii) { |
| 827 const char* src = ii < count ? source[ii] : ""; | 827 const char* src = ii < count ? source[ii] : ""; |
| 828 if (src) { | 828 if (src) { |
| 829 uint32 size = ii < count ? (length ? length[ii] : strlen(src)) : 1; | 829 uint32 size = ii < count ? |
| 830 (length ? static_cast<size_t>(length[ii]) : strlen(src)) : 1; |
| 830 while (size) { | 831 while (size) { |
| 831 uint32 part_size = std::min(size, max_size); | 832 uint32 part_size = std::min(size, max_size); |
| 832 void* buffer = transfer_buffer_.Alloc(part_size); | 833 void* buffer = transfer_buffer_.Alloc(part_size); |
| 833 memcpy(buffer, src, part_size); | 834 memcpy(buffer, src, part_size); |
| 834 helper_->SetBucketData(kResultBucketId, offset, part_size, | 835 helper_->SetBucketData(kResultBucketId, offset, part_size, |
| 835 transfer_buffer_id_, | 836 transfer_buffer_id_, |
| 836 transfer_buffer_.GetOffset(buffer)); | 837 transfer_buffer_.GetOffset(buffer)); |
| 837 transfer_buffer_.FreePendingToken(buffer, helper_->InsertToken()); | 838 transfer_buffer_.FreePendingToken(buffer, helper_->InsertToken()); |
| 838 offset += part_size; | 839 offset += part_size; |
| 839 src += part_size; | 840 src += part_size; |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1559 const MappedTexture& mt = it->second; | 1560 const MappedTexture& mt = it->second; |
| 1560 helper_->TexSubImage2D( | 1561 helper_->TexSubImage2D( |
| 1561 mt.target, mt.level, mt.xoffset, mt.yoffset, mt.width, mt.height, | 1562 mt.target, mt.level, mt.xoffset, mt.yoffset, mt.width, mt.height, |
| 1562 mt.format, mt.type, mt.shm_id, mt.shm_offset); | 1563 mt.format, mt.type, mt.shm_id, mt.shm_offset); |
| 1563 mapped_memory_->FreePendingToken(mt.shm_memory, helper_->InsertToken()); | 1564 mapped_memory_->FreePendingToken(mt.shm_memory, helper_->InsertToken()); |
| 1564 mapped_textures_.erase(it); | 1565 mapped_textures_.erase(it); |
| 1565 } | 1566 } |
| 1566 | 1567 |
| 1567 } // namespace gles2 | 1568 } // namespace gles2 |
| 1568 } // namespace gpu | 1569 } // namespace gpu |
| OLD | NEW |