| 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(ErrorStateClient* client, Logger* logger); | 19 explicit ErrorStateImpl(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_; | |
| 67 Logger* logger_; | 66 Logger* logger_; |
| 68 | 67 |
| 69 DISALLOW_COPY_AND_ASSIGN(ErrorStateImpl); | 68 DISALLOW_COPY_AND_ASSIGN(ErrorStateImpl); |
| 70 }; | 69 }; |
| 71 | 70 |
| 72 ErrorState::ErrorState() {} | 71 ErrorState::ErrorState() {} |
| 73 | 72 |
| 74 ErrorState::~ErrorState() {} | 73 ErrorState::~ErrorState() {} |
| 75 | 74 |
| 76 ErrorState* ErrorState::Create(ErrorStateClient* client, Logger* logger) { | 75 ErrorState* ErrorState::Create(Logger* logger) { |
| 77 return new ErrorStateImpl(client, logger); | 76 return new ErrorStateImpl(logger); |
| 78 } | 77 } |
| 79 | 78 |
| 80 ErrorStateImpl::ErrorStateImpl(ErrorStateClient* client, Logger* logger) | 79 ErrorStateImpl::ErrorStateImpl(Logger* logger) |
| 81 : error_bits_(0), client_(client), logger_(logger) {} | 80 : error_bits_(0), |
| 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(); | |
| 130 } | 128 } |
| 131 | 129 |
| 132 void ErrorStateImpl::SetGLErrorInvalidEnum( | 130 void ErrorStateImpl::SetGLErrorInvalidEnum( |
| 133 const char* filename, | 131 const char* filename, |
| 134 int line, | 132 int line, |
| 135 const char* function_name, | 133 const char* function_name, |
| 136 unsigned int value, | 134 unsigned int value, |
| 137 const char* label) { | 135 const char* label) { |
| 138 SetGLError(filename, line, GL_INVALID_ENUM, function_name, | 136 SetGLError(filename, line, GL_INVALID_ENUM, function_name, |
| 139 (std::string(label) + " was " + | 137 (std::string(label) + " was " + |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 GLES2Util::GetStringEnum(error) + " : " + | 194 GLES2Util::GetStringEnum(error) + " : " + |
| 197 function_name + ": was unhandled"); | 195 function_name + ": was unhandled"); |
| 198 NOTREACHED() << "GL error " << error << " was unhandled."; | 196 NOTREACHED() << "GL error " << error << " was unhandled."; |
| 199 } | 197 } |
| 200 } | 198 } |
| 201 } | 199 } |
| 202 | 200 |
| 203 } // namespace gles2 | 201 } // namespace gles2 |
| 204 } // namespace gpu | 202 } // namespace gpu |
| 205 | 203 |
| OLD | NEW |