From 36f1290ca4b444a7960e8528cc5b8c9b23d53e4d Mon Sep 17 00:00:00 2001 From: "brettw@chromium.org" Date: Wed, 14 Jan 2009 17:15:18 +0000 Subject: Clean up some Skia logging stuff. This unfortunately doesn't re-enable it for the reasons mentioned in the TODO. But I made it work much better when it is enabled. Review URL: http://codereview.chromium.org/17394 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8019 0039d316-1c4b-4281-b951-d872f2087c98 --- skia/ext/google_logging.cc | 43 ++++++++++++++++++++------------------ skia/include/corecg/SkUserConfig.h | 28 ++++++++++++++++++------- 2 files changed, 43 insertions(+), 28 deletions(-) (limited to 'skia') 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 +#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 -- cgit v1.1