1 | /* $Id: VBoxFBOverlayCommon.h 96407 2022-08-22 17:43:14Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - VBoxFrameBuffer Overlay classes declarations.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009-2022 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef MAIN_INCLUDED_SRC_src_helper_apps_OpenGLTest_VBoxFBOverlayCommon_h
|
---|
29 | #define MAIN_INCLUDED_SRC_src_helper_apps_OpenGLTest_VBoxFBOverlayCommon_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | #if 0 //defined(DEBUG_misha)
|
---|
35 | DECLINLINE(VOID) vboxDbgPrintF(LPCSTR szString, ...)
|
---|
36 | {
|
---|
37 | char szBuffer[4096] = {0};
|
---|
38 | va_list pArgList;
|
---|
39 | va_start(pArgList, szString);
|
---|
40 | _vsnprintf(szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]), szString, pArgList);
|
---|
41 | va_end(pArgList);
|
---|
42 |
|
---|
43 | OutputDebugStringA(szBuffer);
|
---|
44 | }
|
---|
45 |
|
---|
46 | # include "iprt/stream.h"
|
---|
47 | # define VBOXQGLLOG(_m) RTPrintf _m
|
---|
48 | # define VBOXQGLLOGREL(_m) do { RTPrintf _m ; LogRel( _m ); } while(0)
|
---|
49 | # define VBOXQGLDBGPRINT(_m) vboxDbgPrintF _m
|
---|
50 | #else
|
---|
51 | # define VBOXQGLLOG(_m) do {}while(0)
|
---|
52 | # define VBOXQGLLOGREL(_m) LogRel( _m )
|
---|
53 | # define VBOXQGLDBGPRINT(_m) do {}while(0)
|
---|
54 | #endif
|
---|
55 | #define VBOXQGLLOG_ENTER(_m) do {}while(0)
|
---|
56 | //do{VBOXQGLLOG(("==>[%s]:", __FUNCTION__)); VBOXQGLLOG(_m);}while(0)
|
---|
57 | #define VBOXQGLLOG_EXIT(_m) do {}while(0)
|
---|
58 | //do{VBOXQGLLOG(("<==[%s]:", __FUNCTION__)); VBOXQGLLOG(_m);}while(0)
|
---|
59 | #ifdef DEBUG
|
---|
60 | #define VBOXQGL_ASSERTNOERR() \
|
---|
61 | do { GLenum err = glGetError(); \
|
---|
62 | if(err != GL_NO_ERROR) VBOXQGLLOG(("gl error occurred (0x%x)\n", err)); \
|
---|
63 | Assert(err == GL_NO_ERROR); \
|
---|
64 | }while(0)
|
---|
65 |
|
---|
66 | #define VBOXQGL_CHECKERR(_op) \
|
---|
67 | do { \
|
---|
68 | glGetError(); \
|
---|
69 | _op \
|
---|
70 | VBOXQGL_ASSERTNOERR(); \
|
---|
71 | }while(0)
|
---|
72 | #else
|
---|
73 | #define VBOXQGL_ASSERTNOERR() \
|
---|
74 | do {}while(0)
|
---|
75 |
|
---|
76 | #define VBOXQGL_CHECKERR(_op) \
|
---|
77 | do { \
|
---|
78 | _op \
|
---|
79 | }while(0)
|
---|
80 | #endif
|
---|
81 |
|
---|
82 | #ifdef DEBUG
|
---|
83 | #include <iprt/time.h>
|
---|
84 |
|
---|
85 | #define VBOXGETTIME() RTTimeNanoTS()
|
---|
86 |
|
---|
87 | #define VBOXPRINTDIF(_nano, _m) do{\
|
---|
88 | uint64_t cur = VBOXGETTIME(); NOREF(cur); \
|
---|
89 | VBOXQGLLOG(_m); \
|
---|
90 | VBOXQGLLOG(("(%Lu)\n", cur - (_nano))); \
|
---|
91 | }while(0)
|
---|
92 |
|
---|
93 | class VBoxVHWADbgTimeCounter
|
---|
94 | {
|
---|
95 | public:
|
---|
96 | VBoxVHWADbgTimeCounter(const char* msg) {mTime = VBOXGETTIME(); mMsg=msg;}
|
---|
97 | ~VBoxVHWADbgTimeCounter() {VBOXPRINTDIF(mTime, (mMsg));}
|
---|
98 | private:
|
---|
99 | uint64_t mTime;
|
---|
100 | const char* mMsg;
|
---|
101 | };
|
---|
102 |
|
---|
103 | #define VBOXQGLLOG_METHODTIME(_m) VBoxVHWADbgTimeCounter _dbgTimeCounter(_m)
|
---|
104 |
|
---|
105 | #define VBOXQG_CHECKCONTEXT() \
|
---|
106 | { \
|
---|
107 | const GLubyte * str; \
|
---|
108 | VBOXQGL_CHECKERR( \
|
---|
109 | str = glGetString(GL_VERSION); \
|
---|
110 | ); \
|
---|
111 | Assert(str); \
|
---|
112 | if(str) \
|
---|
113 | { \
|
---|
114 | Assert(str[0]); \
|
---|
115 | } \
|
---|
116 | }
|
---|
117 | #else
|
---|
118 | #define VBOXQGLLOG_METHODTIME(_m)
|
---|
119 | #define VBOXQG_CHECKCONTEXT() do{}while(0)
|
---|
120 | #endif
|
---|
121 |
|
---|
122 | #define VBOXQGLLOG_QRECT(_p, _pr, _s) do{\
|
---|
123 | VBOXQGLLOG((_p " x(%d), y(%d), w(%d), h(%d)" _s, (_pr)->x(), (_pr)->y(), (_pr)->width(), (_pr)->height()));\
|
---|
124 | }while(0)
|
---|
125 |
|
---|
126 | #define VBOXQGLLOG_CKEY(_p, _pck, _s) do{\
|
---|
127 | VBOXQGLLOG((_p " l(0x%x), u(0x%x)" _s, (_pck)->lower(), (_pck)->upper()));\
|
---|
128 | }while(0)
|
---|
129 |
|
---|
130 | #endif /* !MAIN_INCLUDED_SRC_src_helper_apps_OpenGLTest_VBoxFBOverlayCommon_h */
|
---|
131 |
|
---|