Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // This file contains the ErrorState class. | |
| 6 | |
| 7 #ifndef GPU_COMMAND_BUFFER_SERVICE_ERROR_STATE_H_ | |
| 8 #define GPU_COMMAND_BUFFER_SERVICE_ERROR_STATE_H_ | |
| 9 | |
| 10 #include "base/compiler_specific.h" | |
| 11 #include "gpu/command_buffer/common/types.h" | |
| 12 #include "gpu/gpu_export.h" | |
| 13 | |
| 14 namespace gpu { | |
| 15 namespace gles2 { | |
| 16 | |
| 17 class Logger; | |
| 18 | |
| 19 // Use these macro to synthesize GL errors instead of calling the error_state | |
| 20 // functions directly as they will propogate the __FILE__ and __LINE__. | |
| 21 | |
| 22 // Use to synthesize a GL error on the error_state. | |
| 23 #define ERRORSTATE_SET_GL_ERROR(error_state, error, function_name, msg) \ | |
| 24 error_state->SetGLError(__FILE__, __LINE__, error, function_name, msg) | |
| 25 | |
| 26 // Use to synthesize an INVALID_ENUM GL error on the error_state. Will attempt | |
| 27 // to expand the enum to a string. | |
| 28 #define ERRORSTATE_SET_GL_ERROR_INVALID_ENUM( \ | |
| 29 error_state, function_name, value, label) \ | |
| 30 error_state->SetGLErrorInvalidEnum( \ | |
| 31 __FILE__, __LINE__, function_name, value, label) | |
| 32 | |
| 33 // Use to synthesize a GL error on the error_state for an invalid enum based | |
| 34 // parameter. Will attempt to expand the parameter to a string. | |
| 35 #define ERRORSTATE_SET_GL_ERROR_INVALID_PARAM( \ | |
| 36 error_state, error, function_name, pname, param) \ | |
| 37 error_state->SetGLErrorInvalidParam( \ | |
| 38 __FILE__, __LINE__, error, function_name, pname, param) | |
| 39 | |
| 40 // Use to move all pending error to the wrapper so on your next GL call | |
| 41 // you can see if that call generates an error. | |
| 42 #define ERRORSTATE_COPY_REAL_GL_ERRORS_TO_WRAPPER(error_state, function_name) \ | |
| 43 error_state->CopyRealGLErrorsToWrapper(__FILE__, __LINE__, function_name) | |
| 44 // Use to look at the real GL error and still pass it on to the user. | |
| 45 #define ERRORSTATE_PEEK_GL_ERROR(error_state, function_name) \ | |
| 46 error_state->PeekGLError(__FILE__, __LINE__, function_name) | |
| 47 // Use to clear all current GL errors. FAILS if there are any. | |
| 48 #define ERRORSTATE_CLEAR_REAL_GL_ERRORS(error_state, function_name) \ | |
| 49 error_state->ClearRealGLErrors(__FILE__, __LINE__, function_name) | |
| 50 | |
| 51 // TODO: Look into the current_decoder_error_ in gles2_cmd_decoder.cc. | |
| 52 // Should it also be moved into here? | |
| 53 | |
| 54 class GPU_EXPORT ErrorState { | |
| 55 public: | |
| 56 virtual ~ErrorState(); | |
| 57 | |
| 58 // TODO - sanely separate setters from getters. | |
| 59 // TODO - make some things const. | |
| 60 virtual uint32 GetGLError() = 0; | |
| 61 | |
| 62 virtual void SetGLError( | |
| 63 const char* filename, | |
| 64 int line, | |
| 65 unsigned int error, | |
| 66 const char* function_name, | |
| 67 const char* msg) = 0; | |
| 68 virtual void SetGLErrorInvalidEnum( | |
| 69 const char* filename, | |
| 70 int line, | |
| 71 const char* function_name, | |
| 72 unsigned int value, | |
| 73 const char* label) = 0; | |
| 74 virtual void SetGLErrorInvalidParam( | |
| 75 const char* filename, | |
| 76 int line, | |
| 77 unsigned int error, | |
| 78 const char* function_name, | |
| 79 unsigned int pname, | |
| 80 int param) = 0; | |
| 81 | |
| 82 // Gets the GLError and stores it in our wrapper. Effectively | |
| 83 // this lets us peek at the error without losing it. | |
| 84 virtual unsigned int PeekGLError( | |
| 85 const char* filename, int line, const char* function_name) = 0; | |
| 86 | |
| 87 // Copies the real GL errors to the wrapper. This is so we can | |
| 88 // make sure there are no native GL errors before calling some GL function | |
| 89 // so that on return we know any error generated was for that specific | |
| 90 // command. | |
| 91 virtual void CopyRealGLErrorsToWrapper( | |
| 92 const char* filename, int line, const char* function_name) = 0; | |
| 93 | |
| 94 // Clear all real GL errors. This is to prevent the client from seeing any | |
| 95 // errors caused by GL calls that it was not responsible for issuing. | |
| 96 virtual void ClearRealGLErrors( | |
| 97 const char* filename, int line, const char* function_name) = 0; | |
| 98 | |
| 99 protected: | |
| 100 ErrorState(); | |
| 101 | |
| 102 DISALLOW_COPY_AND_ASSIGN(ErrorState); | |
| 103 }; | |
| 104 | |
| 105 class ErrorStateImpl : public ErrorState { | |
|
dsinclair
2013/04/17 00:39:09
Does this need to be in the public header or can i
kloveless
2013/04/17 14:58:01
Done.
| |
| 106 public: | |
| 107 explicit ErrorStateImpl(Logger* logger); | |
| 108 virtual ~ErrorStateImpl(); | |
| 109 | |
| 110 virtual uint32 GetGLError() OVERRIDE; | |
| 111 | |
| 112 virtual void SetGLError( | |
| 113 const char* filename, | |
| 114 int line, | |
| 115 unsigned int error, | |
| 116 const char* function_name, | |
| 117 const char* msg) OVERRIDE; | |
| 118 virtual void SetGLErrorInvalidEnum( | |
| 119 const char* filename, | |
| 120 int line, | |
| 121 const char* function_name, | |
| 122 unsigned int value, | |
| 123 const char* label) OVERRIDE; | |
| 124 virtual void SetGLErrorInvalidParam( | |
| 125 const char* filename, | |
| 126 int line, | |
| 127 unsigned int error, | |
| 128 const char* function_name, | |
| 129 unsigned int pname, | |
| 130 int param) OVERRIDE; | |
| 131 | |
| 132 virtual unsigned int PeekGLError( | |
| 133 const char* filename, int line, const char* function_name) OVERRIDE; | |
| 134 | |
| 135 virtual void CopyRealGLErrorsToWrapper( | |
| 136 const char* filename, int line, const char* function_name) OVERRIDE; | |
| 137 | |
| 138 virtual void ClearRealGLErrors( | |
| 139 const char* filename, int line, const char* function_name) OVERRIDE; | |
| 140 | |
| 141 private: | |
| 142 // The last error message set. | |
| 143 std::string last_error_; | |
| 144 // Current GL error bits. | |
| 145 uint32 error_bits_; | |
| 146 | |
| 147 Logger* logger_; | |
| 148 | |
| 149 DISALLOW_COPY_AND_ASSIGN(ErrorStateImpl); | |
| 150 }; | |
| 151 | |
| 152 } // namespace gles2 | |
| 153 } // namespace gpu | |
| 154 | |
| 155 #endif // GPU_COMMAND_BUFFER_SERVICE_ERROR_STATE_H_ | |
| OLD | NEW |