| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/error_state.h" | 5 #include "gpu/command_buffer/service/error_state.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 11 #include "gpu/command_buffer/service/logger.h" | 11 #include "gpu/command_buffer/service/logger.h" |
| 12 #include "ui/gl/gl_bindings.h" | 12 #include "ui/gl/gl_bindings.h" |
| 13 | 13 |
| 14 namespace gpu { | 14 namespace gpu { |
| 15 namespace gles2 { | 15 namespace gles2 { |
| 16 | 16 |
| 17 class ErrorStateImpl : public ErrorState { | 17 class ErrorStateImpl : public ErrorState { |
| 18 public: | 18 public: |
| 19 explicit ErrorStateImpl(Logger* logger); | 19 explicit ErrorStateImpl(ErrorStateClient* client, Logger* logger); |
| 20 virtual ~ErrorStateImpl(); | 20 virtual ~ErrorStateImpl(); |
| 21 | 21 |
| 22 virtual uint32 GetGLError() OVERRIDE; | 22 virtual uint32 GetGLError() OVERRIDE; |
| 23 | 23 |
| 24 virtual void SetGLError( | 24 virtual void SetGLError( |
| 25 const char* filename, | 25 const char* filename, |
| 26 int line, | 26 int line, |
| 27 unsigned int error, | 27 unsigned int error, |
| 28 const char* function_name, | 28 const char* function_name, |
| 29 const char* msg) OVERRIDE; | 29 const char* msg) OVERRIDE; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 56 | 56 |
| 57 virtual void ClearRealGLErrors( | 57 virtual void ClearRealGLErrors( |
| 58 const char* filename, int line, const char* function_name) OVERRIDE; | 58 const char* filename, int line, const char* function_name) OVERRIDE; |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 // The last error message set. | 61 // The last error message set. |
| 62 std::string last_error_; | 62 std::string last_error_; |
| 63 // Current GL error bits. | 63 // Current GL error bits. |
| 64 uint32 error_bits_; | 64 uint32 error_bits_; |
| 65 | 65 |
| 66 ErrorStateClient* client_; |
| 66 Logger* logger_; | 67 Logger* logger_; |
| 67 | 68 |
| 68 DISALLOW_COPY_AND_ASSIGN(ErrorStateImpl); | 69 DISALLOW_COPY_AND_ASSIGN(ErrorStateImpl); |
| 69 }; | 70 }; |
| 70 | 71 |
| 71 ErrorState::ErrorState() {} | 72 ErrorState::ErrorState() {} |
| 72 | 73 |
| 73 ErrorState::~ErrorState() {} | 74 ErrorState::~ErrorState() {} |
| 74 | 75 |
| 75 ErrorState* ErrorState::Create(Logger* logger) { | 76 ErrorState* ErrorState::Create(ErrorStateClient* client, Logger* logger) { |
| 76 return new ErrorStateImpl(logger); | 77 return new ErrorStateImpl(client, logger); |
| 77 } | 78 } |
| 78 | 79 |
| 79 ErrorStateImpl::ErrorStateImpl(Logger* logger) | 80 ErrorStateImpl::ErrorStateImpl(ErrorStateClient* client, Logger* logger) |
| 80 : error_bits_(0), | 81 : error_bits_(0), client_(client), logger_(logger) {} |
| 81 logger_(logger) {} | |
| 82 | 82 |
| 83 ErrorStateImpl::~ErrorStateImpl() {} | 83 ErrorStateImpl::~ErrorStateImpl() {} |
| 84 | 84 |
| 85 uint32 ErrorStateImpl::GetGLError() { | 85 uint32 ErrorStateImpl::GetGLError() { |
| 86 // Check the GL error first, then our wrapped error. | 86 // Check the GL error first, then our wrapped error. |
| 87 GLenum error = glGetError(); | 87 GLenum error = glGetError(); |
| 88 if (error == GL_NO_ERROR && error_bits_ != 0) { | 88 if (error == GL_NO_ERROR && error_bits_ != 0) { |
| 89 for (uint32 mask = 1; mask != 0; mask = mask << 1) { | 89 for (uint32 mask = 1; mask != 0; mask = mask << 1) { |
| 90 if ((error_bits_ & mask) != 0) { | 90 if ((error_bits_ & mask) != 0) { |
| 91 error = GLES2Util::GLErrorBitToGLError(mask); | 91 error = GLES2Util::GLErrorBitToGLError(mask); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 118 const char* msg) { | 118 const char* msg) { |
| 119 if (msg) { | 119 if (msg) { |
| 120 last_error_ = msg; | 120 last_error_ = msg; |
| 121 logger_->LogMessage( | 121 logger_->LogMessage( |
| 122 filename, line, | 122 filename, line, |
| 123 std::string("GL ERROR :") + | 123 std::string("GL ERROR :") + |
| 124 GLES2Util::GetStringEnum(error) + " : " + | 124 GLES2Util::GetStringEnum(error) + " : " + |
| 125 function_name + ": " + msg); | 125 function_name + ": " + msg); |
| 126 } | 126 } |
| 127 error_bits_ |= GLES2Util::GLErrorToErrorBit(error); | 127 error_bits_ |= GLES2Util::GLErrorToErrorBit(error); |
| 128 if (error == GL_OUT_OF_MEMORY) |
| 129 client_->OnOutOfMemoryError(); |
| 128 } | 130 } |
| 129 | 131 |
| 130 void ErrorStateImpl::SetGLErrorInvalidEnum( | 132 void ErrorStateImpl::SetGLErrorInvalidEnum( |
| 131 const char* filename, | 133 const char* filename, |
| 132 int line, | 134 int line, |
| 133 const char* function_name, | 135 const char* function_name, |
| 134 unsigned int value, | 136 unsigned int value, |
| 135 const char* label) { | 137 const char* label) { |
| 136 SetGLError(filename, line, GL_INVALID_ENUM, function_name, | 138 SetGLError(filename, line, GL_INVALID_ENUM, function_name, |
| 137 (std::string(label) + " was " + | 139 (std::string(label) + " was " + |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 GLES2Util::GetStringEnum(error) + " : " + | 196 GLES2Util::GetStringEnum(error) + " : " + |
| 195 function_name + ": was unhandled"); | 197 function_name + ": was unhandled"); |
| 196 NOTREACHED() << "GL error " << error << " was unhandled."; | 198 NOTREACHED() << "GL error " << error << " was unhandled."; |
| 197 } | 199 } |
| 198 } | 200 } |
| 199 } | 201 } |
| 200 | 202 |
| 201 } // namespace gles2 | 203 } // namespace gles2 |
| 202 } // namespace gpu | 204 } // namespace gpu |
| 203 | 205 |
| OLD | NEW |