Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| (...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 751 } | 751 } |
| 752 | 752 |
| 753 Buffer* BufferManager::RequestBufferAccess(ContextState* context_state, | 753 Buffer* BufferManager::RequestBufferAccess(ContextState* context_state, |
| 754 GLenum target, | 754 GLenum target, |
| 755 GLintptr offset, | 755 GLintptr offset, |
| 756 GLsizeiptr size, | 756 GLsizeiptr size, |
| 757 const char* func_name) { | 757 const char* func_name) { |
| 758 DCHECK(context_state); | 758 DCHECK(context_state); |
| 759 ErrorState* error_state = context_state->GetErrorState(); | 759 ErrorState* error_state = context_state->GetErrorState(); |
| 760 | 760 |
| 761 std::string msg_tag = base::StringPrintf("bound to target 0x%04x", target); | |
| 762 Buffer* buffer = GetBufferInfoForTarget(context_state, target); | 761 Buffer* buffer = GetBufferInfoForTarget(context_state, target); |
| 763 if (!RequestBufferAccess(error_state, buffer, func_name, msg_tag.c_str())) { | 762 if (!RequestBufferAccess(error_state, buffer, func_name, |
| 763 "bound to target 0x%04x", target)) { | |
| 764 return nullptr; | 764 return nullptr; |
| 765 } | 765 } |
| 766 if (!buffer->CheckRange(offset, size)) { | 766 if (!buffer->CheckRange(offset, size)) { |
| 767 std::string msg = base::StringPrintf( | 767 std::string msg = base::StringPrintf( |
| 768 "%s : offset/size out of range", msg_tag.c_str()); | 768 "bound to target 0x%04x : offset/size out of range", target); |
| 769 ERRORSTATE_SET_GL_ERROR( | 769 ERRORSTATE_SET_GL_ERROR( |
| 770 error_state, GL_INVALID_VALUE, func_name, msg.c_str()); | 770 error_state, GL_INVALID_VALUE, func_name, msg.c_str()); |
| 771 return nullptr; | 771 return nullptr; |
| 772 } | 772 } |
| 773 return buffer; | 773 return buffer; |
| 774 } | 774 } |
| 775 | 775 |
| 776 Buffer* BufferManager::RequestBufferAccess(ContextState* context_state, | 776 Buffer* BufferManager::RequestBufferAccess(ContextState* context_state, |
| 777 GLenum target, | 777 GLenum target, |
| 778 const char* func_name) { | 778 const char* func_name) { |
| 779 DCHECK(context_state); | 779 DCHECK(context_state); |
| 780 ErrorState* error_state = context_state->GetErrorState(); | 780 ErrorState* error_state = context_state->GetErrorState(); |
| 781 | 781 |
| 782 std::string msg_tag = base::StringPrintf("bound to target 0x%04x", target); | |
| 783 Buffer* buffer = GetBufferInfoForTarget(context_state, target); | 782 Buffer* buffer = GetBufferInfoForTarget(context_state, target); |
| 784 return RequestBufferAccess( | 783 return RequestBufferAccess( |
| 785 error_state, buffer, func_name, msg_tag.c_str()) ? buffer : nullptr; | 784 error_state, buffer, func_name, |
| 785 "bound to target 0x%04x", target) ? buffer : nullptr; | |
| 786 } | 786 } |
| 787 | 787 |
| 788 bool BufferManager::RequestBufferAccess(ErrorState* error_state, | 788 bool BufferManager::RequestBufferAccess(ErrorState* error_state, |
| 789 Buffer* buffer, | 789 Buffer* buffer, |
| 790 const char* func_name, | 790 const char* func_name, |
| 791 const char* message_tag) { | 791 const char* error_message_format, ...) { |
| 792 DCHECK(error_state); | 792 DCHECK(error_state); |
| 793 | 793 |
| 794 if (!buffer || buffer->IsDeleted()) { | 794 va_list varargs; |
| 795 std::string msg = base::StringPrintf("%s : no buffer", message_tag); | 795 va_start(varargs, error_message_format); |
| 796 ERRORSTATE_SET_GL_ERROR(error_state, GL_INVALID_OPERATION, func_name, | 796 bool result = RequestBufferAccessV(error_state, buffer, func_name, |
| 797 msg.c_str()); | 797 error_message_format, varargs); |
| 798 return false; | 798 va_end(varargs); |
| 799 } | 799 return result; |
| 800 if (buffer->GetMappedRange()) { | |
| 801 std::string msg = base::StringPrintf("%s : buffer is mapped", message_tag); | |
| 802 ERRORSTATE_SET_GL_ERROR(error_state, GL_INVALID_OPERATION, func_name, | |
| 803 msg.c_str()); | |
| 804 return false; | |
| 805 } | |
| 806 return true; | |
| 807 } | 800 } |
| 808 | 801 |
| 809 bool BufferManager::RequestBufferAccess(ErrorState* error_state, | 802 bool BufferManager::RequestBufferAccess(ErrorState* error_state, |
| 810 Buffer* buffer, | 803 Buffer* buffer, |
| 811 GLintptr offset, | 804 GLintptr offset, |
| 812 GLsizeiptr size, | 805 GLsizeiptr size, |
| 813 const char* func_name, | 806 const char* func_name, |
| 814 const char* message_tag) { | 807 const char* error_message) { |
| 815 if (!RequestBufferAccess(error_state, buffer, func_name, message_tag)) { | 808 if (!RequestBufferAccess(error_state, buffer, func_name, error_message)) { |
| 816 return false; | 809 return false; |
| 817 } | 810 } |
| 818 if (!buffer->CheckRange(offset, size)) { | 811 if (!buffer->CheckRange(offset, size)) { |
| 819 std::string msg = base::StringPrintf( | 812 std::string msg = base::StringPrintf( |
| 820 "%s : offset/size out of range", message_tag); | 813 "%s : offset/size out of range", error_message); |
| 821 ERRORSTATE_SET_GL_ERROR( | 814 ERRORSTATE_SET_GL_ERROR( |
| 822 error_state, GL_INVALID_OPERATION, func_name, msg.c_str()); | 815 error_state, GL_INVALID_OPERATION, func_name, msg.c_str()); |
| 823 return false; | 816 return false; |
| 824 } | 817 } |
| 825 return true; | 818 return true; |
| 826 } | 819 } |
| 827 | 820 |
| 828 bool BufferManager::RequestBuffersAccess( | 821 bool BufferManager::RequestBuffersAccess( |
| 829 ErrorState* error_state, | 822 ErrorState* error_state, |
| 830 const IndexedBufferBindingHost* bindings, | 823 const IndexedBufferBindingHost* bindings, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 869 void BufferManager::IncreaseMappedBufferCount() { | 862 void BufferManager::IncreaseMappedBufferCount() { |
| 870 DCHECK_GT(std::numeric_limits<uint32_t>::max(), mapped_buffer_count_); | 863 DCHECK_GT(std::numeric_limits<uint32_t>::max(), mapped_buffer_count_); |
| 871 mapped_buffer_count_++; | 864 mapped_buffer_count_++; |
| 872 } | 865 } |
| 873 | 866 |
| 874 void BufferManager::DecreaseMappedBufferCount() { | 867 void BufferManager::DecreaseMappedBufferCount() { |
| 875 DCHECK_LT(0u, mapped_buffer_count_); | 868 DCHECK_LT(0u, mapped_buffer_count_); |
| 876 mapped_buffer_count_--; | 869 mapped_buffer_count_--; |
| 877 } | 870 } |
| 878 | 871 |
| 872 bool BufferManager::RequestBufferAccessV(ErrorState* error_state, | |
|
Ken Russell (switch to Gerrit)
2016/11/02 18:29:01
While there's only one caller of this now, it simp
| |
| 873 Buffer* buffer, | |
| 874 const char* func_name, | |
| 875 const char* error_message_format, | |
| 876 va_list varargs) { | |
| 877 DCHECK(error_state); | |
| 878 | |
| 879 if (!buffer || buffer->IsDeleted()) { | |
| 880 std::string message_tag = base::StringPrintV(error_message_format, varargs); | |
| 881 std::string msg = base::StringPrintf("%s : no buffer", message_tag.c_str()); | |
| 882 ERRORSTATE_SET_GL_ERROR(error_state, GL_INVALID_OPERATION, func_name, | |
| 883 msg.c_str()); | |
| 884 return false; | |
| 885 } | |
| 886 if (buffer->GetMappedRange()) { | |
| 887 std::string message_tag = base::StringPrintV(error_message_format, varargs); | |
| 888 std::string msg = base::StringPrintf("%s : buffer is mapped", | |
| 889 message_tag.c_str()); | |
| 890 ERRORSTATE_SET_GL_ERROR(error_state, GL_INVALID_OPERATION, func_name, | |
| 891 msg.c_str()); | |
| 892 return false; | |
| 893 } | |
| 894 return true; | |
| 895 } | |
| 896 | |
| 879 } // namespace gles2 | 897 } // namespace gles2 |
| 880 } // namespace gpu | 898 } // namespace gpu |
| OLD | NEW |