11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 #pragma once 26 27 #ifdef DEBUG 28 #define D3D_DEBUG_INFO 29 #endif // DEBUG 30 31 #ifdef D3D_PPL_DLL 32 33 34 #ifndef WIN32_LEAN_AND_MEAN 35 #define WIN32_LEAN_AND_MEAN 36 #endif 37 38 #ifdef D3DPIPELINE_EXPORTS 39 #define D3DPIPELINE_API __declspec(dllexport) 40 #else 41 #define D3DPIPELINE_API __declspec(dllimport) 42 #endif 43 44 #include <windows.h> 45 #include <d3d9.h> 46 #include <DDErr.h> 47 #include "..\Import\Trace.h" 48 49 #define DebugPrintD3DError(res, msg) \ 50 DXTRACE_ERR(msg, res) 87 #define SAFE_PRINTLN(RES) \ 88 do { \ 89 if ((RES)!= NULL) { \ 90 J2dTraceLn1(J2D_TRACE_VERBOSE, " " ## #RES ## "=0x%x", (RES)); \ 91 } else { \ 92 J2dTraceLn(J2D_TRACE_VERBOSE, " " ## #RES ## "=NULL"); \ 93 } \ 94 } while (0); 95 #else // DEBUG 96 #define SAFE_PRINTLN(RES) 97 #endif // DEBUG 98 99 /* 100 * The following macros allow the caller to return (or continue) if the 101 * provided value is NULL. (The strange else clause is included below to 102 * allow for a trailing ';' after RETURN/CONTINUE_IF_NULL() invocations.) 103 */ 104 #define ACT_IF_NULL(ACTION, value) \ 105 if ((value) == NULL) { \ 106 J2dTraceLn3(J2D_TRACE_ERROR, \ 107 "%s is null in %s:%d", #value, __FILE__, __LINE__); \ 108 ACTION; \ 109 } else do { } while (0) 110 #define RETURN_IF_NULL(value) ACT_IF_NULL(return, value) 111 #define CONTINUE_IF_NULL(value) ACT_IF_NULL(continue, value) 112 #define RETURN_STATUS_IF_NULL(value, status) \ 113 ACT_IF_NULL(return (status), value) 114 115 #define RETURN_STATUS_IF_EXP_FAILED(EXPR) \ 116 if (FAILED(res = (EXPR))) { \ 117 DebugPrintD3DError(res, " " ## #EXPR ## " failed in " ## __FILE__); \ 118 return res; \ 119 } else do { } while (0) 120 121 #define RETURN_STATUS_IF_FAILED(status) \ 122 if (FAILED((status))) { \ 123 DebugPrintD3DError((status), " failed in " ## __FILE__ ## ", return;");\ 124 return (status); \ 125 } else do { } while (0) | 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 #pragma once 26 27 #ifdef DEBUG 28 #define D3D_DEBUG_INFO 29 #endif // DEBUG 30 31 /* Use THIS_FILE when it is available. */ 32 #ifndef THIS_FILE 33 #define THIS_FILE THIS_FILE 34 #endif 35 36 #ifdef D3D_PPL_DLL 37 38 39 #ifndef WIN32_LEAN_AND_MEAN 40 #define WIN32_LEAN_AND_MEAN 41 #endif 42 43 #ifdef D3DPIPELINE_EXPORTS 44 #define D3DPIPELINE_API __declspec(dllexport) 45 #else 46 #define D3DPIPELINE_API __declspec(dllimport) 47 #endif 48 49 #include <windows.h> 50 #include <d3d9.h> 51 #include <DDErr.h> 52 #include "..\Import\Trace.h" 53 54 #define DebugPrintD3DError(res, msg) \ 55 DXTRACE_ERR(msg, res) 92 #define SAFE_PRINTLN(RES) \ 93 do { \ 94 if ((RES)!= NULL) { \ 95 J2dTraceLn1(J2D_TRACE_VERBOSE, " " ## #RES ## "=0x%x", (RES)); \ 96 } else { \ 97 J2dTraceLn(J2D_TRACE_VERBOSE, " " ## #RES ## "=NULL"); \ 98 } \ 99 } while (0); 100 #else // DEBUG 101 #define SAFE_PRINTLN(RES) 102 #endif // DEBUG 103 104 /* 105 * The following macros allow the caller to return (or continue) if the 106 * provided value is NULL. (The strange else clause is included below to 107 * allow for a trailing ';' after RETURN/CONTINUE_IF_NULL() invocations.) 108 */ 109 #define ACT_IF_NULL(ACTION, value) \ 110 if ((value) == NULL) { \ 111 J2dTraceLn3(J2D_TRACE_ERROR, \ 112 "%s is null in %s:%d", #value, THIS_FILE, __LINE__); \ 113 ACTION; \ 114 } else do { } while (0) 115 #define RETURN_IF_NULL(value) ACT_IF_NULL(return, value) 116 #define CONTINUE_IF_NULL(value) ACT_IF_NULL(continue, value) 117 #define RETURN_STATUS_IF_NULL(value, status) \ 118 ACT_IF_NULL(return (status), value) 119 120 #define RETURN_STATUS_IF_EXP_FAILED(EXPR) \ 121 if (FAILED(res = (EXPR))) { \ 122 DebugPrintD3DError(res, " " ## #EXPR ## " failed in " ## THIS_FILE); \ 123 return res; \ 124 } else do { } while (0) 125 126 #define RETURN_STATUS_IF_FAILED(status) \ 127 if (FAILED((status))) { \ 128 DebugPrintD3DError((status), " failed in " ## THIS_FILE ## ", return;");\ 129 return (status); \ 130 } else do { } while (0) |