Chromium Code Reviews| Index: gpu/command_buffer/service/buffer_manager.cc |
| diff --git a/gpu/command_buffer/service/buffer_manager.cc b/gpu/command_buffer/service/buffer_manager.cc |
| index e7528ec0c71185d388d2936c6be8fd939729c36f..638a20803ce9436ad0fde4802f412a0b1722f4d4 100644 |
| --- a/gpu/command_buffer/service/buffer_manager.cc |
| +++ b/gpu/command_buffer/service/buffer_manager.cc |
| @@ -758,14 +758,14 @@ Buffer* BufferManager::RequestBufferAccess(ContextState* context_state, |
| DCHECK(context_state); |
| ErrorState* error_state = context_state->GetErrorState(); |
| - std::string msg_tag = base::StringPrintf("bound to target 0x%04x", target); |
| Buffer* buffer = GetBufferInfoForTarget(context_state, target); |
| - if (!RequestBufferAccess(error_state, buffer, func_name, msg_tag.c_str())) { |
| + if (!RequestBufferAccess(error_state, buffer, func_name, |
| + "bound to target 0x%04x", target)) { |
| return nullptr; |
| } |
| if (!buffer->CheckRange(offset, size)) { |
| std::string msg = base::StringPrintf( |
| - "%s : offset/size out of range", msg_tag.c_str()); |
| + "bound to target 0x%04x : offset/size out of range", target); |
| ERRORSTATE_SET_GL_ERROR( |
| error_state, GL_INVALID_VALUE, func_name, msg.c_str()); |
| return nullptr; |
| @@ -779,31 +779,24 @@ Buffer* BufferManager::RequestBufferAccess(ContextState* context_state, |
| DCHECK(context_state); |
| ErrorState* error_state = context_state->GetErrorState(); |
| - std::string msg_tag = base::StringPrintf("bound to target 0x%04x", target); |
| Buffer* buffer = GetBufferInfoForTarget(context_state, target); |
| return RequestBufferAccess( |
| - error_state, buffer, func_name, msg_tag.c_str()) ? buffer : nullptr; |
| + error_state, buffer, func_name, |
| + "bound to target 0x%04x", target) ? buffer : nullptr; |
| } |
| bool BufferManager::RequestBufferAccess(ErrorState* error_state, |
| Buffer* buffer, |
| const char* func_name, |
| - const char* message_tag) { |
| + const char* error_message_format, ...) { |
| DCHECK(error_state); |
| - if (!buffer || buffer->IsDeleted()) { |
| - std::string msg = base::StringPrintf("%s : no buffer", message_tag); |
| - ERRORSTATE_SET_GL_ERROR(error_state, GL_INVALID_OPERATION, func_name, |
| - msg.c_str()); |
| - return false; |
| - } |
| - if (buffer->GetMappedRange()) { |
| - std::string msg = base::StringPrintf("%s : buffer is mapped", message_tag); |
| - ERRORSTATE_SET_GL_ERROR(error_state, GL_INVALID_OPERATION, func_name, |
| - msg.c_str()); |
| - return false; |
| - } |
| - return true; |
| + va_list varargs; |
| + va_start(varargs, error_message_format); |
| + bool result = RequestBufferAccessV(error_state, buffer, func_name, |
| + error_message_format, varargs); |
| + va_end(varargs); |
| + return result; |
| } |
| bool BufferManager::RequestBufferAccess(ErrorState* error_state, |
| @@ -811,13 +804,13 @@ bool BufferManager::RequestBufferAccess(ErrorState* error_state, |
| GLintptr offset, |
| GLsizeiptr size, |
| const char* func_name, |
| - const char* message_tag) { |
| - if (!RequestBufferAccess(error_state, buffer, func_name, message_tag)) { |
| + const char* error_message) { |
| + if (!RequestBufferAccess(error_state, buffer, func_name, error_message)) { |
| return false; |
| } |
| if (!buffer->CheckRange(offset, size)) { |
| std::string msg = base::StringPrintf( |
| - "%s : offset/size out of range", message_tag); |
| + "%s : offset/size out of range", error_message); |
| ERRORSTATE_SET_GL_ERROR( |
| error_state, GL_INVALID_OPERATION, func_name, msg.c_str()); |
| return false; |
| @@ -876,5 +869,30 @@ void BufferManager::DecreaseMappedBufferCount() { |
| mapped_buffer_count_--; |
| } |
| +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
|
| + Buffer* buffer, |
| + const char* func_name, |
| + const char* error_message_format, |
| + va_list varargs) { |
| + DCHECK(error_state); |
| + |
| + if (!buffer || buffer->IsDeleted()) { |
| + std::string message_tag = base::StringPrintV(error_message_format, varargs); |
| + std::string msg = base::StringPrintf("%s : no buffer", message_tag.c_str()); |
| + ERRORSTATE_SET_GL_ERROR(error_state, GL_INVALID_OPERATION, func_name, |
| + msg.c_str()); |
| + return false; |
| + } |
| + if (buffer->GetMappedRange()) { |
| + std::string message_tag = base::StringPrintV(error_message_format, varargs); |
| + std::string msg = base::StringPrintf("%s : buffer is mapped", |
| + message_tag.c_str()); |
| + ERRORSTATE_SET_GL_ERROR(error_state, GL_INVALID_OPERATION, func_name, |
| + msg.c_str()); |
| + return false; |
| + } |
| + return true; |
| +} |
| + |
| } // namespace gles2 |
| } // namespace gpu |