430N/A/*
2362N/A * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
430N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
430N/A *
430N/A * This code is free software; you can redistribute it and/or modify it
430N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
430N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
430N/A *
430N/A * This code is distributed in the hope that it will be useful, but WITHOUT
430N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
430N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
430N/A * version 2 for more details (a copy is included in the LICENSE file that
430N/A * accompanied this code).
430N/A *
430N/A * You should have received a copy of the GNU General Public License version
430N/A * 2 along with this work; if not, write to the Free Software Foundation,
430N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
430N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
430N/A */
430N/A#pragma once
430N/A
430N/A#ifdef DEBUG
430N/A#define D3D_DEBUG_INFO
430N/A#endif // DEBUG
430N/A
430N/A#ifdef D3D_PPL_DLL
430N/A
430N/A
430N/A #ifndef WIN32_LEAN_AND_MEAN
430N/A #define WIN32_LEAN_AND_MEAN
430N/A #endif
430N/A
430N/A #ifdef D3DPIPELINE_EXPORTS
430N/A #define D3DPIPELINE_API __declspec(dllexport)
430N/A #else
430N/A #define D3DPIPELINE_API __declspec(dllimport)
430N/A #endif
430N/A
430N/A #include <windows.h>
430N/A #include <d3d9.h>
430N/A #include <DDErr.h>
430N/A #include "..\Import\Trace.h"
430N/A
430N/A #define DebugPrintD3DError(res, msg) \
430N/A DXTRACE_ERR(msg, res)
430N/A
430N/A#else
430N/A
430N/A #define D3DPIPELINE_API __declspec(dllexport)
430N/A
430N/A // this include ensures that with debug build we get
430N/A // awt's overridden debug "new" and "delete" operators
430N/A #include "awt.h"
430N/A
430N/A #include <windows.h>
430N/A #include <d3d9.h>
430N/A #include "Trace.h"
430N/A
430N/A #define DebugPrintD3DError(res, msg) \
430N/A J2dTraceLn1(J2D_TRACE_ERROR, "D3D Error: " ## msg ## " res=%d", res)
430N/A
430N/A#endif /*D3D_PPL_DLL*/
430N/A
430N/A// some helper macros
430N/A#define SAFE_RELEASE(RES) \
430N/Ado { \
430N/A if ((RES)!= NULL) { \
430N/A (RES)->Release(); \
430N/A (RES) = NULL; \
430N/A } \
430N/A} while (0);
430N/A
430N/A#define SAFE_DELETE(RES) \
430N/Ado { \
430N/A if ((RES)!= NULL) { \
430N/A delete (RES); \
430N/A (RES) = NULL; \
430N/A } \
430N/A} while (0);
430N/A
430N/A#ifdef DEBUG
430N/A#define SAFE_PRINTLN(RES) \
430N/Ado { \
430N/A if ((RES)!= NULL) { \
430N/A J2dTraceLn1(J2D_TRACE_VERBOSE, " " ## #RES ## "=0x%x", (RES)); \
430N/A } else { \
430N/A J2dTraceLn(J2D_TRACE_VERBOSE, " " ## #RES ## "=NULL"); \
430N/A } \
430N/A} while (0);
430N/A#else // DEBUG
430N/A#define SAFE_PRINTLN(RES)
430N/A#endif // DEBUG
430N/A
430N/A/*
430N/A * The following macros allow the caller to return (or continue) if the
430N/A * provided value is NULL. (The strange else clause is included below to
430N/A * allow for a trailing ';' after RETURN/CONTINUE_IF_NULL() invocations.)
430N/A */
430N/A#define ACT_IF_NULL(ACTION, value) \
430N/A if ((value) == NULL) { \
430N/A J2dTraceLn3(J2D_TRACE_ERROR, \
430N/A "%s is null in %s:%d", #value, __FILE__, __LINE__); \
430N/A ACTION; \
430N/A } else do { } while (0)
430N/A#define RETURN_IF_NULL(value) ACT_IF_NULL(return, value)
430N/A#define CONTINUE_IF_NULL(value) ACT_IF_NULL(continue, value)
430N/A#define RETURN_STATUS_IF_NULL(value, status) \
430N/A ACT_IF_NULL(return (status), value)
430N/A
430N/A#define RETURN_STATUS_IF_EXP_FAILED(EXPR) \
430N/A if (FAILED(res = (EXPR))) { \
430N/A DebugPrintD3DError(res, " " ## #EXPR ## " failed in " ## __FILE__); \
430N/A return res; \
430N/A } else do { } while (0)
430N/A
430N/A#define RETURN_STATUS_IF_FAILED(status) \
430N/A if (FAILED((status))) { \
430N/A DebugPrintD3DError((status), " failed in " ## __FILE__ ## ", return;");\
430N/A return (status); \
430N/A } else do { } while (0)