| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef GPU_COMMAND_BUFFER_COMMON_LOGGING_H_ | 5 #ifndef GPU_COMMAND_BUFFER_COMMON_LOGGING_H_ |
| 6 #define GPU_COMMAND_BUFFER_COMMON_LOGGING_H_ | 6 #define GPU_COMMAND_BUFFER_COMMON_LOGGING_H_ |
| 7 | 7 |
| 8 #include <assert.h> | 8 #include <assert.h> |
| 9 | 9 |
| 10 #include <ostream> | 10 #include <ostream> |
| 11 | 11 |
| 12 #include "gpu/command_buffer/common/gles2_utils_export.h" |
| 13 |
| 12 // Windows defines an ERROR macro. | 14 // Windows defines an ERROR macro. |
| 13 #ifdef ERROR | 15 #ifdef ERROR |
| 14 #undef ERROR | 16 #undef ERROR |
| 15 #endif | 17 #endif |
| 16 | 18 |
| 17 namespace gpu { | 19 namespace gpu { |
| 18 | 20 |
| 19 // Members are uppercase instead of kCamelCase for consistency with base log | 21 // Members are uppercase instead of kCamelCase for consistency with base log |
| 20 // severity enum. | 22 // severity enum. |
| 21 enum LogLevel { | 23 enum LogLevel { |
| 22 INFO, | 24 INFO, |
| 23 WARNING, | 25 WARNING, |
| 24 ERROR, | 26 ERROR, |
| 25 FATAL | 27 FATAL |
| 26 }; | 28 }; |
| 27 | 29 |
| 28 // This is a very simple logger for use in command buffer code. Common and | 30 // This is a very simple logger for use in command buffer code. Common and |
| 29 // command buffer code cannot be dependent on base. It just outputs the message | 31 // command buffer code cannot be dependent on base. It just outputs the message |
| 30 // to stderr. | 32 // to stderr. |
| 31 class Logger { | 33 class GLES2_UTILS_EXPORT Logger { |
| 32 public: | 34 public: |
| 33 Logger(bool condition, LogLevel level) | 35 Logger(bool condition, LogLevel level) |
| 34 : condition_(condition), | 36 : condition_(condition), |
| 35 level_(level) { | 37 level_(level) { |
| 36 } | 38 } |
| 37 | 39 |
| 38 template <typename X> | 40 template <typename X> |
| 39 static Logger CheckTrue(const X& x, | 41 static Logger CheckTrue(const X& x, |
| 40 const char* file, int line, | 42 const char* file, int line, |
| 41 const char* x_name, | 43 const char* x_name, |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 if (GPU_DEBUG_IS_ON) \ | 212 if (GPU_DEBUG_IS_ON) \ |
| 211 ::gpu::Logger::CheckLessEqual( \ | 213 ::gpu::Logger::CheckLessEqual( \ |
| 212 (X), (Y), __FILE__, __LINE__, #X, #Y, "GPU_DCHECK_LE") | 214 (X), (Y), __FILE__, __LINE__, #X, #Y, "GPU_DCHECK_LE") |
| 213 #define GPU_DLOG(LEVEL) if (GPU_DEBUG_IS_ON) ::gpu::Logger(true, LEVEL) | 215 #define GPU_DLOG(LEVEL) if (GPU_DEBUG_IS_ON) ::gpu::Logger(true, LEVEL) |
| 214 | 216 |
| 215 | 217 |
| 216 | 218 |
| 217 #define GPU_NOTREACHED() GPU_DCHECK(false) | 219 #define GPU_NOTREACHED() GPU_DCHECK(false) |
| 218 | 220 |
| 219 #endif // GPU_COMMAND_BUFFER_COMMON_LOGGING_H_ | 221 #endif // GPU_COMMAND_BUFFER_COMMON_LOGGING_H_ |
| OLD | NEW |