sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Panic and logging functions common to both the DirectGDI adaptation layer and sl@0: // associated modules/interfaces. sl@0: // sl@0: // sl@0: sl@0: #ifndef DIRECTGDIPANICS_H sl@0: #define DIRECTGDIPANICS_H sl@0: sl@0: #include sl@0: #include sl@0: sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype sl@0: */ sl@0: sl@0: #ifndef SYMBIAN_PANIC_CATEGORY sl@0: #error SYMBIAN_PANIC_CATEGORY not defined. sl@0: #endif sl@0: sl@0: /** Helper macros for the assert and panic macros. sl@0: */ sl@0: #define GRAPHICS_SOURCE_FILENAME(sourceFileName) _LIT(KSourceFileName, sourceFileName); sl@0: #define GRAPHICS_ASSERT_CONDITION(condition) _LIT(KPanicCondition, condition); sl@0: #define GRAPHICS_LOG_MESSAGE(literalMessage) _LIT(KLogMessage, # literalMessage); sl@0: sl@0: #define GRAPHICS_ASSERT_ALWAYS(condition, panicCode) \ sl@0: if (!(condition)) \ sl@0: { \ sl@0: GRAPHICS_SOURCE_FILENAME(__FILE__); \ sl@0: GRAPHICS_ASSERT_CONDITION(#condition); \ sl@0: DirectGdi::PanicWithDebugLog(SYMBIAN_PANIC_CATEGORY, panicCode, KSourceFileName, __LINE__, &KPanicCondition); \ sl@0: } sl@0: sl@0: #define GRAPHICS_PANIC_ALWAYS(panicCode) \ sl@0: { \ sl@0: GRAPHICS_SOURCE_FILENAME(__FILE__); \ sl@0: DirectGdi::PanicWithDebugLog(SYMBIAN_PANIC_CATEGORY, panicCode, KSourceFileName, __LINE__, NULL); \ sl@0: } sl@0: sl@0: #define GRAPHICS_LOG_ALWAYS(message) \ sl@0: { \ sl@0: GRAPHICS_SOURCE_FILENAME(__FILE__);\ sl@0: GRAPHICS_LOG_MESSAGE(message); \ sl@0: DirectGdi::Log(KSourceFileName, __LINE__, KLogMessage); \ sl@0: } sl@0: sl@0: #define GRAPHICS_LOGD_ALWAYS(message) \ sl@0: { \ sl@0: GRAPHICS_SOURCE_FILENAME(__FILE__);\ sl@0: DirectGdi::Log(KSourceFileName, __LINE__, message); \ sl@0: } sl@0: sl@0: /** sl@0: Define "debug only" macros ONLY when this is a debug build. sl@0: */ sl@0: #ifdef _DEBUG sl@0: #define GRAPHICS_LOG_DEBUG(literalMessage) GRAPHICS_LOG_ALWAYS(literalMessage) // Paste parameter literally to log sl@0: #define GRAPHICS_LOGD_DEBUG(TDesCRefMessage) GRAPHICS_LOGD_ALWAYS(TDesCRefMessage) // Treat message as const TDesC& sl@0: #define GRAPHICS_ASSERT_DEBUG(condition, panicCode) GRAPHICS_ASSERT_ALWAYS(condition, panicCode) sl@0: #define GRAPHICS_PANIC_DEBUG(panicCode) GRAPHICS_PANIC_ALWAYS(panicCode) sl@0: #else sl@0: #define GRAPHICS_LOG_DEBUG(literalMessage) sl@0: #define GRAPHICS_LOGD_DEBUG(TDesCRefMessage) sl@0: #define GRAPHICS_ASSERT_DEBUG(condition, panicCode) sl@0: #define GRAPHICS_PANIC_DEBUG(panicCode) sl@0: #endif // _DEBUG sl@0: sl@0: sl@0: // Cannot enable DirectGDI calltrace unless in debug mode. sl@0: #ifndef _DEBUG sl@0: #undef ENABLE_DIRECTGDI_CALLTRACE sl@0: #endif sl@0: sl@0: #ifdef ENABLE_DIRECTGDI_CALLTRACE sl@0: #define GRAPHICS_TRACE(functionName) RDebug::Print(_L(functionName)); sl@0: #define GRAPHICS_TRACE1(functionName, p) RDebug::Printf(functionName, p); sl@0: #define GRAPHICS_TRACE2(functionName, p1, p2) RDebug::Printf(functionName, p1, p2); sl@0: #else sl@0: #define GRAPHICS_TRACE(functionName) sl@0: #define GRAPHICS_TRACE1(functionName, p) sl@0: #define GRAPHICS_TRACE2(functionName, p1, p2) sl@0: #endif sl@0: sl@0: #endif // DIRECTGDIPANICS_H