OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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/gles2_cmd_decoder_passthrough.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "ui/gl/gl_version_info.h" | 8 #include "ui/gl/gl_version_info.h" |
9 | 9 |
10 namespace gpu { | 10 namespace gpu { |
(...skipping 2716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2727 return error::kNoError; | 2727 return error::kNoError; |
2728 } | 2728 } |
2729 | 2729 |
2730 error::Error GLES2DecoderPassthroughImpl::DoMapBufferRange( | 2730 error::Error GLES2DecoderPassthroughImpl::DoMapBufferRange( |
2731 GLenum target, | 2731 GLenum target, |
2732 GLintptr offset, | 2732 GLintptr offset, |
2733 GLsizeiptr size, | 2733 GLsizeiptr size, |
2734 GLbitfield access, | 2734 GLbitfield access, |
2735 void* ptr, | 2735 void* ptr, |
2736 int32_t data_shm_id, | 2736 int32_t data_shm_id, |
2737 uint32_t data_shm_offset) { | 2737 uint32_t data_shm_offset, |
| 2738 uint32_t* result) { |
2738 FlushErrors(); | 2739 FlushErrors(); |
2739 | 2740 |
2740 GLbitfield filtered_access = access; | 2741 GLbitfield filtered_access = access; |
2741 | 2742 |
2742 // Always filter out GL_MAP_UNSYNCHRONIZED_BIT to get rid of undefined | 2743 // Always filter out GL_MAP_UNSYNCHRONIZED_BIT to get rid of undefined |
2743 // behaviors. | 2744 // behaviors. |
2744 filtered_access = (filtered_access & ~GL_MAP_UNSYNCHRONIZED_BIT); | 2745 filtered_access = (filtered_access & ~GL_MAP_UNSYNCHRONIZED_BIT); |
2745 | 2746 |
2746 if ((filtered_access & GL_MAP_INVALIDATE_BUFFER_BIT) != 0) { | 2747 if ((filtered_access & GL_MAP_INVALIDATE_BUFFER_BIT) != 0) { |
2747 // To be on the safe side, always map GL_MAP_INVALIDATE_BUFFER_BIT to | 2748 // To be on the safe side, always map GL_MAP_INVALIDATE_BUFFER_BIT to |
2748 // GL_MAP_INVALIDATE_RANGE_BIT. | 2749 // GL_MAP_INVALIDATE_RANGE_BIT. |
2749 filtered_access = (filtered_access & ~GL_MAP_INVALIDATE_BUFFER_BIT); | 2750 filtered_access = (filtered_access & ~GL_MAP_INVALIDATE_BUFFER_BIT); |
2750 filtered_access = (filtered_access | GL_MAP_INVALIDATE_RANGE_BIT); | 2751 filtered_access = (filtered_access | GL_MAP_INVALIDATE_RANGE_BIT); |
2751 } | 2752 } |
2752 if ((filtered_access & GL_MAP_INVALIDATE_RANGE_BIT) == 0) { | 2753 if ((filtered_access & GL_MAP_INVALIDATE_RANGE_BIT) == 0) { |
2753 // If this user intends to use this buffer without invalidating the data, we | 2754 // If this user intends to use this buffer without invalidating the data, we |
2754 // need to also add GL_MAP_READ_BIT to preserve the original data when | 2755 // need to also add GL_MAP_READ_BIT to preserve the original data when |
2755 // copying it to shared memory. | 2756 // copying it to shared memory. |
2756 filtered_access = (filtered_access | GL_MAP_READ_BIT); | 2757 filtered_access = (filtered_access | GL_MAP_READ_BIT); |
2757 } | 2758 } |
2758 | 2759 |
2759 void* mapped_ptr = glMapBufferRange(target, offset, size, filtered_access); | 2760 void* mapped_ptr = glMapBufferRange(target, offset, size, filtered_access); |
2760 if (FlushErrors() || mapped_ptr == nullptr) { | 2761 if (FlushErrors() || mapped_ptr == nullptr) { |
2761 // Had an error while mapping, don't copy any data | 2762 // Had an error while mapping, don't copy any data |
| 2763 *result = 0; |
2762 return error::kNoError; | 2764 return error::kNoError; |
2763 } | 2765 } |
2764 | 2766 |
2765 if ((filtered_access & GL_MAP_INVALIDATE_RANGE_BIT) == 0) { | 2767 if ((filtered_access & GL_MAP_INVALIDATE_RANGE_BIT) == 0) { |
2766 memcpy(ptr, mapped_ptr, size); | 2768 memcpy(ptr, mapped_ptr, size); |
2767 } | 2769 } |
2768 | 2770 |
2769 // Track the mapping of this buffer so that data can be synchronized when it | 2771 // Track the mapping of this buffer so that data can be synchronized when it |
2770 // is unmapped | 2772 // is unmapped |
2771 DCHECK(bound_buffers_.find(target) != bound_buffers_.end()); | 2773 DCHECK(bound_buffers_.find(target) != bound_buffers_.end()); |
2772 GLuint client_buffer = bound_buffers_.at(target); | 2774 GLuint client_buffer = bound_buffers_.at(target); |
2773 | 2775 |
2774 MappedBuffer mapped_buffer_info; | 2776 MappedBuffer mapped_buffer_info; |
2775 mapped_buffer_info.size = size; | 2777 mapped_buffer_info.size = size; |
2776 mapped_buffer_info.access = filtered_access; | 2778 mapped_buffer_info.access = filtered_access; |
2777 mapped_buffer_info.map_ptr = static_cast<uint8_t*>(mapped_ptr); | 2779 mapped_buffer_info.map_ptr = static_cast<uint8_t*>(mapped_ptr); |
2778 mapped_buffer_info.data_shm_id = data_shm_id; | 2780 mapped_buffer_info.data_shm_id = data_shm_id; |
2779 mapped_buffer_info.data_shm_offset = data_shm_offset; | 2781 mapped_buffer_info.data_shm_offset = data_shm_offset; |
2780 | 2782 |
2781 DCHECK(resources_->mapped_buffer_map.find(client_buffer) == | 2783 DCHECK(resources_->mapped_buffer_map.find(client_buffer) == |
2782 resources_->mapped_buffer_map.end()); | 2784 resources_->mapped_buffer_map.end()); |
2783 resources_->mapped_buffer_map.insert( | 2785 resources_->mapped_buffer_map.insert( |
2784 std::make_pair(client_buffer, mapped_buffer_info)); | 2786 std::make_pair(client_buffer, mapped_buffer_info)); |
2785 | 2787 |
| 2788 *result = 1; |
2786 return error::kNoError; | 2789 return error::kNoError; |
2787 } | 2790 } |
2788 | 2791 |
2789 error::Error GLES2DecoderPassthroughImpl::DoUnmapBuffer(GLenum target) { | 2792 error::Error GLES2DecoderPassthroughImpl::DoUnmapBuffer(GLenum target) { |
2790 auto bound_buffers_iter = bound_buffers_.find(target); | 2793 auto bound_buffers_iter = bound_buffers_.find(target); |
2791 if (bound_buffers_iter == bound_buffers_.end() || | 2794 if (bound_buffers_iter == bound_buffers_.end() || |
2792 bound_buffers_iter->second == 0) { | 2795 bound_buffers_iter->second == 0) { |
2793 InsertError(GL_INVALID_OPERATION, "No buffer bound to this target."); | 2796 InsertError(GL_INVALID_OPERATION, "No buffer bound to this target."); |
2794 return error::kNoError; | 2797 return error::kNoError; |
2795 } | 2798 } |
(...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3969 } | 3972 } |
3970 | 3973 |
3971 error::Error GLES2DecoderPassthroughImpl::DoSetEnableDCLayersCHROMIUM( | 3974 error::Error GLES2DecoderPassthroughImpl::DoSetEnableDCLayersCHROMIUM( |
3972 GLboolean enable) { | 3975 GLboolean enable) { |
3973 NOTIMPLEMENTED(); | 3976 NOTIMPLEMENTED(); |
3974 return error::kNoError; | 3977 return error::kNoError; |
3975 } | 3978 } |
3976 | 3979 |
3977 } // namespace gles2 | 3980 } // namespace gles2 |
3978 } // namespace gpu | 3981 } // namespace gpu |
OLD | NEW |