diff options
-rw-r--r-- | skia/ext/google_logging.cc | 43 | ||||
-rw-r--r-- | skia/include/corecg/SkUserConfig.h | 28 |
2 files changed, 43 insertions, 28 deletions
diff --git a/skia/ext/google_logging.cc b/skia/ext/google_logging.cc index c69d873..72328b8 100644 --- a/skia/ext/google_logging.cc +++ b/skia/ext/google_logging.cc @@ -1,20 +1,23 @@ -// Copyright (c) 2009 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 provides integration with Google-style "base/logging.h" assertions
-// for Skia SkASSERT. If you don't want this, you can link with another file
-// that provides integration with the logging of your choice.
-
-#include "base/logging.h"
-#include "base/string_util.h"
-
-void SkDebugf_FileLine(const char* file, int line, const char* format, ...) {
- va_list ap;
- va_start(ap, format);
-
- std::string msg;
- StringAppendV(&msg, format, ap);
-
- logging::LogMessage(file, line, logging::LOG_ERROR).stream() << msg;
-}
+// Copyright (c) 2009 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 provides integration with Google-style "base/logging.h" assertions +// for Skia SkASSERT. If you don't want this, you can link with another file +// that provides integration with the logging of your choice. + +#include "base/logging.h" +#include "base/string_util.h" + +void SkDebugf_FileLine(const char* file, int line, bool fatal, + const char* format, ...) { + va_list ap; + va_start(ap, format); + + std::string msg; + StringAppendV(&msg, format, ap); + + logging::LogMessage(file, line, + fatal ? logging::LOG_FATAL : logging::LOG_INFO).stream() + << msg; +} diff --git a/skia/include/corecg/SkUserConfig.h b/skia/include/corecg/SkUserConfig.h index 3b5885f..34340e1 100644 --- a/skia/include/corecg/SkUserConfig.h +++ b/skia/include/corecg/SkUserConfig.h @@ -87,12 +87,16 @@ #undef SK_SCALAR_IS_FIXED // Log the file and line number for assertions. -#define SkDebugf(...) SkDebugf_FileLine(__FILE__, __LINE__, __VA_ARGS__) -void SkDebugf_FileLine(const char* file, int line, const char* format, ...); -#include <stdio.h> +#define SkDebugf(...) SkDebugf_FileLine(__FILE__, __LINE__, false, __VA_ARGS__) +void SkDebugf_FileLine(const char* file, int line, bool fatal, + const char* format, ...); + +// Marking the debug print as "fatal" will cause a debug break, so we don't need +// a separate crash call here. #define SK_DEBUGBREAK(cond) do { if (!(cond)) { \ - SkDebugf("%s:%d: failed assertion \"%s\"\n", \ - __FILE__, __LINE__, #cond); SK_CRASH(); } } while (false) + SkDebugf_FileLine(__FILE__, __LINE__, true, \ + "%s:%d: failed assertion \"%s\"\n", \ + __FILE__, __LINE__, #cond); } } while (false) #if defined(SK_BUILD_FOR_WIN32) @@ -150,12 +154,20 @@ typedef unsigned uint32_t; #endif -// FIXME(brettw) re-enable this when we fix the crashes. +// The default crash macro writes to badbeef which can cause some strange +// problems. Instead, pipe this through to the logging function as a fatal +// assertion. +#define SK_CRASH() SkDebugf_FileLine(__FILE__, __LINE__, true, "SK_CRASH") + +// TODO(brettw) bug 6373: Re-enable Skia assertions. This is blocked on fixing +// some of our transparency handling which generates purposely-invalid colors, +// in turn causing assertions. //#ifndef NDEBUG // #define SK_DEBUG // #undef SK_RELEASE -// REMOVE ME -#undef SK_SUPPORT_UNITTEST + #undef SK_SUPPORT_UNITTEST // This is only necessary in debug mode since + // we've disabled assertions. When we re-enable + // them, this line can be removed. //#else #define SK_RELEASE #undef SK_DEBUG |