Index: gpu/command_buffer/service/error_state.h |
diff --git a/gpu/command_buffer/service/error_state.h b/gpu/command_buffer/service/error_state.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c894248092786a736b2e1867f921806af4f22f1c |
--- /dev/null |
+++ b/gpu/command_buffer/service/error_state.h |
@@ -0,0 +1,155 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+// This file contains the ErrorState class. |
+ |
+#ifndef GPU_COMMAND_BUFFER_SERVICE_ERROR_STATE_H_ |
+#define GPU_COMMAND_BUFFER_SERVICE_ERROR_STATE_H_ |
+ |
+#include "base/compiler_specific.h" |
+#include "gpu/command_buffer/common/types.h" |
+#include "gpu/gpu_export.h" |
+ |
+namespace gpu { |
+namespace gles2 { |
+ |
+class Logger; |
+ |
+// Use these macro to synthesize GL errors instead of calling the error_state |
+// functions directly as they will propogate the __FILE__ and __LINE__. |
+ |
+// Use to synthesize a GL error on the error_state. |
+#define ERRORSTATE_SET_GL_ERROR(error_state, error, function_name, msg) \ |
+ error_state->SetGLError(__FILE__, __LINE__, error, function_name, msg) |
+ |
+// Use to synthesize an INVALID_ENUM GL error on the error_state. Will attempt |
+// to expand the enum to a string. |
+#define ERRORSTATE_SET_GL_ERROR_INVALID_ENUM( \ |
+ error_state, function_name, value, label) \ |
+ error_state->SetGLErrorInvalidEnum( \ |
+ __FILE__, __LINE__, function_name, value, label) |
+ |
+// Use to synthesize a GL error on the error_state for an invalid enum based |
+// parameter. Will attempt to expand the parameter to a string. |
+#define ERRORSTATE_SET_GL_ERROR_INVALID_PARAM( \ |
+ error_state, error, function_name, pname, param) \ |
+ error_state->SetGLErrorInvalidParam( \ |
+ __FILE__, __LINE__, error, function_name, pname, param) |
+ |
+// Use to move all pending error to the wrapper so on your next GL call |
+// you can see if that call generates an error. |
+#define ERRORSTATE_COPY_REAL_GL_ERRORS_TO_WRAPPER(error_state, function_name) \ |
+ error_state->CopyRealGLErrorsToWrapper(__FILE__, __LINE__, function_name) |
+// Use to look at the real GL error and still pass it on to the user. |
+#define ERRORSTATE_PEEK_GL_ERROR(error_state, function_name) \ |
+ error_state->PeekGLError(__FILE__, __LINE__, function_name) |
+// Use to clear all current GL errors. FAILS if there are any. |
+#define ERRORSTATE_CLEAR_REAL_GL_ERRORS(error_state, function_name) \ |
+ error_state->ClearRealGLErrors(__FILE__, __LINE__, function_name) |
+ |
+// TODO: Look into the current_decoder_error_ in gles2_cmd_decoder.cc. |
+// Should it also be moved into here? |
+ |
+class GPU_EXPORT ErrorState { |
+ public: |
+ virtual ~ErrorState(); |
+ |
+ // TODO - sanely separate setters from getters. |
+ // TODO - make some things const. |
+ virtual uint32 GetGLError() = 0; |
+ |
+ virtual void SetGLError( |
+ const char* filename, |
+ int line, |
+ unsigned int error, |
+ const char* function_name, |
+ const char* msg) = 0; |
+ virtual void SetGLErrorInvalidEnum( |
+ const char* filename, |
+ int line, |
+ const char* function_name, |
+ unsigned int value, |
+ const char* label) = 0; |
+ virtual void SetGLErrorInvalidParam( |
+ const char* filename, |
+ int line, |
+ unsigned int error, |
+ const char* function_name, |
+ unsigned int pname, |
+ int param) = 0; |
+ |
+ // Gets the GLError and stores it in our wrapper. Effectively |
+ // this lets us peek at the error without losing it. |
+ virtual unsigned int PeekGLError( |
+ const char* filename, int line, const char* function_name) = 0; |
+ |
+ // Copies the real GL errors to the wrapper. This is so we can |
+ // make sure there are no native GL errors before calling some GL function |
+ // so that on return we know any error generated was for that specific |
+ // command. |
+ virtual void CopyRealGLErrorsToWrapper( |
+ const char* filename, int line, const char* function_name) = 0; |
+ |
+ // Clear all real GL errors. This is to prevent the client from seeing any |
+ // errors caused by GL calls that it was not responsible for issuing. |
+ virtual void ClearRealGLErrors( |
+ const char* filename, int line, const char* function_name) = 0; |
+ |
+ protected: |
+ ErrorState(); |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ErrorState); |
+}; |
+ |
+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.
|
+ public: |
+ explicit ErrorStateImpl(Logger* logger); |
+ virtual ~ErrorStateImpl(); |
+ |
+ virtual uint32 GetGLError() OVERRIDE; |
+ |
+ virtual void SetGLError( |
+ const char* filename, |
+ int line, |
+ unsigned int error, |
+ const char* function_name, |
+ const char* msg) OVERRIDE; |
+ virtual void SetGLErrorInvalidEnum( |
+ const char* filename, |
+ int line, |
+ const char* function_name, |
+ unsigned int value, |
+ const char* label) OVERRIDE; |
+ virtual void SetGLErrorInvalidParam( |
+ const char* filename, |
+ int line, |
+ unsigned int error, |
+ const char* function_name, |
+ unsigned int pname, |
+ int param) OVERRIDE; |
+ |
+ virtual unsigned int PeekGLError( |
+ const char* filename, int line, const char* function_name) OVERRIDE; |
+ |
+ virtual void CopyRealGLErrorsToWrapper( |
+ const char* filename, int line, const char* function_name) OVERRIDE; |
+ |
+ virtual void ClearRealGLErrors( |
+ const char* filename, int line, const char* function_name) OVERRIDE; |
+ |
+ private: |
+ // The last error message set. |
+ std::string last_error_; |
+ // Current GL error bits. |
+ uint32 error_bits_; |
+ |
+ Logger* logger_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ErrorStateImpl); |
+}; |
+ |
+} // namespace gles2 |
+} // namespace gpu |
+ |
+#endif // GPU_COMMAND_BUFFER_SERVICE_ERROR_STATE_H_ |