Path: blob/master/src/java.desktop/windows/native/libawt/java2d/d3d/D3DPipeline.h
41159 views
/*1* Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/24#pragma once2526#ifdef DEBUG27#define D3D_DEBUG_INFO28#endif // DEBUG2930#ifdef D3D_PPL_DLL313233#ifndef WIN32_LEAN_AND_MEAN34#define WIN32_LEAN_AND_MEAN35#endif3637#ifdef D3DPIPELINE_EXPORTS38#define D3DPIPELINE_API __declspec(dllexport)39#else40#define D3DPIPELINE_API __declspec(dllimport)41#endif4243#include <windows.h>44#include <d3d9.h>45#include <DDErr.h>46#include "..\Import\Trace.h"4748#define DebugPrintD3DError(res, msg) \49DXTRACE_ERR(msg, res)5051#else5253#define D3DPIPELINE_API __declspec(dllexport)5455// this include ensures that with debug build we get56// awt's overridden debug "new" and "delete" operators57#include "awt.h"5859#include <windows.h>60#include <d3d9.h>61#include "Trace.h"6263#define DebugPrintD3DError(res, msg) \64J2dTraceLn1(J2D_TRACE_ERROR, "D3D Error: " ## msg ## " res=%d", res)6566#endif /*D3D_PPL_DLL*/6768// some helper macros69#define SAFE_RELEASE(RES) \70do { \71if ((RES)!= NULL) { \72(RES)->Release(); \73(RES) = NULL; \74} \75} while (0);7677#define SAFE_DELETE(RES) \78do { \79if ((RES)!= NULL) { \80delete (RES); \81(RES) = NULL; \82} \83} while (0);8485#ifdef DEBUG86#define SAFE_PRINTLN(RES) \87do { \88if ((RES)!= NULL) { \89J2dTraceLn1(J2D_TRACE_VERBOSE, " " ## #RES ## "=0x%x", (RES)); \90} else { \91J2dTraceLn(J2D_TRACE_VERBOSE, " " ## #RES ## "=NULL"); \92} \93} while (0);94#else // DEBUG95#define SAFE_PRINTLN(RES)96#endif // DEBUG9798/*99* The following macros allow the caller to return (or continue) if the100* provided value is NULL. (The strange else clause is included below to101* allow for a trailing ';' after RETURN/CONTINUE_IF_NULL() invocations.)102*/103#define ACT_IF_NULL(ACTION, value) \104if ((value) == NULL) { \105J2dTraceLn3(J2D_TRACE_ERROR, \106"%s is null in %s:%d", #value, __FILE__, __LINE__); \107ACTION; \108} else do { } while (0)109#define RETURN_IF_NULL(value) ACT_IF_NULL(return, value)110#define CONTINUE_IF_NULL(value) ACT_IF_NULL(continue, value)111#define RETURN_STATUS_IF_NULL(value, status) \112ACT_IF_NULL(return (status), value)113114#define RETURN_STATUS_IF_EXP_FAILED(EXPR) \115if (FAILED(res = (EXPR))) { \116DebugPrintD3DError(res, " " ## #EXPR ## " failed in " ## __FILE__); \117return res; \118} else do { } while (0)119120#define RETURN_STATUS_IF_FAILED(status) \121if (FAILED((status))) { \122DebugPrintD3DError((status), " failed in " ## __FILE__ ## ", return;");\123return (status); \124} else do { } while (0)125126127