- Timestamp:
- Apr 4, 2018 12:20:08 PM (7 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxVideo/HGSMIBase.cpp
r71590 r71651 165 165 166 166 /* Allocate the IO buffer. */ 167 p = (VBVACONF32 *)VBoxHGSMIBufferAlloc(pCtx, sizeof(*p), HGSMI_CH_VBVA, 168 VBVA_QUERY_CONF32); 167 p = (VBVACONF32 *)VBoxHGSMIBufferAlloc(pCtx, sizeof(*p), HGSMI_CH_VBVA, VBVA_QUERY_CONF32); 169 168 if (!p) 170 169 return VERR_NO_MEMORY; -
trunk/src/VBox/Devices/Graphics/HGSMI/HGSMIHost.cpp
r71629 r71651 1535 1535 1536 1536 int rc; 1537 PHGSMIINSTANCE pIns = (PHGSMIINSTANCE)RTMemAllocZ(sizeof 1537 PHGSMIINSTANCE pIns = (PHGSMIINSTANCE)RTMemAllocZ(sizeof(HGSMIINSTANCE) + cbContext); 1538 1538 if (pIns) 1539 1539 { 1540 rc = HGSMIAreaInitialize 1540 rc = HGSMIAreaInitialize(&pIns->area, pu8MemBase, cbMem, offBase); 1541 1541 if (RT_SUCCESS (rc)) 1542 rc = RTCritSectInit 1542 rc = RTCritSectInit(&pIns->instanceCritSect); 1543 1543 if (RT_SUCCESS (rc)) 1544 rc = RTCritSectInit 1544 rc = RTCritSectInit(&pIns->hostHeapCritSect); 1545 1545 if (RT_SUCCESS (rc)) 1546 rc = RTCritSectInit 1546 rc = RTCritSectInit(&pIns->hostFIFOCritSect); 1547 1547 if (RT_SUCCESS (rc)) 1548 1548 { … … 1575 1575 } 1576 1576 1577 uint32_t HGSMIReset 1577 uint32_t HGSMIReset(PHGSMIINSTANCE pIns) 1578 1578 { 1579 1579 uint32_t flags = 0; … … 1592 1592 1593 1593 #ifdef VBOX_WITH_WDDM 1594 while (hgsmiProcessGuestCmdCompletion(pIns) != HGSMIOFFSET_VOID)1594 while (hgsmiProcessGuestCmdCompletion(pIns) != HGSMIOFFSET_VOID) 1595 1595 {} 1596 1596 #endif -
trunk/src/VBox/Devices/Graphics/HGSMI/HGSMIHost.h
r71619 r71651 28 28 typedef struct HGSMIINSTANCE *PHGSMIINSTANCE; 29 29 30 /* Callback for the guest notification about a new host buffer. */30 /** Callback for the guest notification about a new host buffer. */ 31 31 typedef DECLCALLBACK(void) FNHGSMINOTIFYGUEST(void *pvCallback); 32 32 typedef FNHGSMINOTIFYGUEST *PFNHGSMINOTIFYGUEST; -
trunk/src/VBox/Frontends/VBoxFB/Framebuffer.cpp
r69500 r71651 1 /* $Id$ */ 1 2 /** @file 2 * 3 * VBox frontends: Framebuffer (FB, DirectFB): 4 * Implementation of VBoxDirectFB class 3 * VBoxFB - implementation of VBoxDirectFB class. 5 4 */ 6 5 … … 348 347 } 349 348 350 NS_IMETHODIMP VBoxDirectFB::ProcessVHWACommand(PRUint8 *command) 351 { 349 NS_IMETHODIMP VBoxDirectFB::ProcessVHWACommand(PRUint8 *command, LONG enmCmd, BOOL fGuestCmd) 350 { 351 RT_NOREF(command, enmCmd, fGuestCmd); 352 352 return NS_ERROR_NOT_IMPLEMENTED; 353 353 } -
trunk/src/VBox/Frontends/VBoxFB/Framebuffer.h
r69500 r71651 1 1 /** @file 2 * 3 * VBox frontends: Framebuffer (FB, DirectFB): 4 * Declaration of VBoxDirectFB class 2 * VBoxFB - Declaration of VBoxDirectFB class. 5 3 */ 6 4 … … 51 49 NS_IMETHOD SetVisibleRegion(PRUint8 *aRectangles, PRUint32 aCount); 52 50 53 NS_IMETHOD ProcessVHWACommand(PRUint8 *pCommand );51 NS_IMETHOD ProcessVHWACommand(PRUint8 *pCommand, LONG enmCmd, BOOL fGuestCmd); 54 52 55 53 NS_IMETHOD Notify3DEvent(PRUint32 type, PRUint8 *reserved); … … 70 68 71 69 72 #endif // __H_FRAMEBUFFER70 #endif // !__H_FRAMEBUFFER 73 71 -
trunk/src/VBox/Frontends/VBoxSDL/Framebuffer.cpp
r69500 r71651 621 621 } 622 622 623 STDMETHODIMP VBoxSDLFB::ProcessVHWACommand(BYTE *pCommand )624 { 625 RT_NOREF(pCommand );623 STDMETHODIMP VBoxSDLFB::ProcessVHWACommand(BYTE *pCommand, LONG enmCmd, BOOL fGuestCmd) 624 { 625 RT_NOREF(pCommand, enmCmd, fGuestCmd); 626 626 return E_NOTIMPL; 627 627 } -
trunk/src/VBox/Frontends/VBoxSDL/Framebuffer.h
r69500 r71651 95 95 STDMETHOD(SetVisibleRegion)(BYTE *aRectangles, ULONG aCount); 96 96 97 STDMETHOD(ProcessVHWACommand)(BYTE *pCommand );97 STDMETHOD(ProcessVHWACommand)(BYTE *pCommand, LONG enmCmd, BOOL fGuestCmd); 98 98 99 99 STDMETHOD(Notify3DEvent)(ULONG uType, ComSafeArrayIn(BYTE, aData)); -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.cpp
r71626 r71651 15 15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 16 16 */ 17 #if defined(VBOX_GUI_USE_QGL) 18 17 18 #if defined(VBOX_GUI_USE_QGL) /* entire file */ 19 20 /********************************************************************************************************************************* 21 * Header Files * 22 *********************************************************************************************************************************/ 19 23 #ifdef VBOX_WITH_PRECOMPILED_HEADERS 20 24 # include <precomp.h> … … 51 55 # include <iprt/asm.h> 52 56 # include <iprt/semaphore.h> 57 # include <VBox/AssertGuest.h> 53 58 54 59 # include <VBox/VBoxGL2D.h> … … 73 78 74 79 80 /********************************************************************************************************************************* 81 * Defined Constants And Macros * 82 *********************************************************************************************************************************/ 75 83 #ifdef VBOXQGL_PROF_BASE 76 84 # ifdef VBOXQGL_DBG_SURF … … 89 97 #define VBOXQGL_STATE_VERSION 3 90 98 99 //#define VBOXQGLOVERLAY_STATE_NAMEBASE "QGLOverlayVHWAData" 100 //#define VBOXQGLOVERLAY_STATE_VERSION 1 101 102 #ifdef DEBUG_misha 103 //# define VBOXQGL_STATE_DEBUG 104 #endif 105 106 #ifdef VBOXQGL_STATE_DEBUG 107 #define VBOXQGL_STATE_START_MAGIC 0x12345678 108 #define VBOXQGL_STATE_STOP_MAGIC 0x87654321 109 110 #define VBOXQGL_STATE_SURFSTART_MAGIC 0x9abcdef1 111 #define VBOXQGL_STATE_SURFSTOP_MAGIC 0x1fedcba9 112 113 #define VBOXQGL_STATE_OVERLAYSTART_MAGIC 0x13579bdf 114 #define VBOXQGL_STATE_OVERLAYSTOP_MAGIC 0xfdb97531 115 116 #define VBOXQGL_SAVE_START(_pSSM) do{ int rc = SSMR3PutU32(_pSSM, VBOXQGL_STATE_START_MAGIC); AssertRC(rc);}while(0) 117 #define VBOXQGL_SAVE_STOP(_pSSM) do{ int rc = SSMR3PutU32(_pSSM, VBOXQGL_STATE_STOP_MAGIC); AssertRC(rc);}while(0) 118 119 #define VBOXQGL_SAVE_SURFSTART(_pSSM) do{ int rc = SSMR3PutU32(_pSSM, VBOXQGL_STATE_SURFSTART_MAGIC); AssertRC(rc);}while(0) 120 #define VBOXQGL_SAVE_SURFSTOP(_pSSM) do{ int rc = SSMR3PutU32(_pSSM, VBOXQGL_STATE_SURFSTOP_MAGIC); AssertRC(rc);}while(0) 121 122 #define VBOXQGL_SAVE_OVERLAYSTART(_pSSM) do{ int rc = SSMR3PutU32(_pSSM, VBOXQGL_STATE_OVERLAYSTART_MAGIC); AssertRC(rc);}while(0) 123 #define VBOXQGL_SAVE_OVERLAYSTOP(_pSSM) do{ int rc = SSMR3PutU32(_pSSM, VBOXQGL_STATE_OVERLAYSTOP_MAGIC); AssertRC(rc);}while(0) 124 125 #define VBOXQGL_LOAD_CHECK(_pSSM, _v) \ 126 do{ \ 127 uint32_t _u32; \ 128 int rcCheck = SSMR3GetU32(_pSSM, &_u32); AssertRC(rcCheck); \ 129 if (_u32 != (_v)) \ 130 { \ 131 VBOXQGLLOG(("load error: expected magic (0x%x), but was (0x%x)\n", (_v), _u32));\ 132 }\ 133 Assert(_u32 == (_v)); \ 134 }while(0) 135 136 #define VBOXQGL_LOAD_START(_pSSM) VBOXQGL_LOAD_CHECK(_pSSM, VBOXQGL_STATE_START_MAGIC) 137 #define VBOXQGL_LOAD_STOP(_pSSM) VBOXQGL_LOAD_CHECK(_pSSM, VBOXQGL_STATE_STOP_MAGIC) 138 139 #define VBOXQGL_LOAD_SURFSTART(_pSSM) VBOXQGL_LOAD_CHECK(_pSSM, VBOXQGL_STATE_SURFSTART_MAGIC) 140 #define VBOXQGL_LOAD_SURFSTOP(_pSSM) VBOXQGL_LOAD_CHECK(_pSSM, VBOXQGL_STATE_SURFSTOP_MAGIC) 141 142 #define VBOXQGL_LOAD_OVERLAYSTART(_pSSM) VBOXQGL_LOAD_CHECK(_pSSM, VBOXQGL_STATE_OVERLAYSTART_MAGIC) 143 #define VBOXQGL_LOAD_OVERLAYSTOP(_pSSM) VBOXQGL_LOAD_CHECK(_pSSM, VBOXQGL_STATE_OVERLAYSTOP_MAGIC) 144 145 #else 146 147 #define VBOXQGL_SAVE_START(_pSSM) do{}while(0) 148 #define VBOXQGL_SAVE_STOP(_pSSM) do{}while(0) 149 150 #define VBOXQGL_SAVE_SURFSTART(_pSSM) do{}while(0) 151 #define VBOXQGL_SAVE_SURFSTOP(_pSSM) do{}while(0) 152 153 #define VBOXQGL_SAVE_OVERLAYSTART(_pSSM) do{}while(0) 154 #define VBOXQGL_SAVE_OVERLAYSTOP(_pSSM) do{}while(0) 155 156 #define VBOXQGL_LOAD_START(_pSSM) do{}while(0) 157 #define VBOXQGL_LOAD_STOP(_pSSM) do{}while(0) 158 159 #define VBOXQGL_LOAD_SURFSTART(_pSSM) do{}while(0) 160 #define VBOXQGL_LOAD_SURFSTOP(_pSSM) do{}while(0) 161 162 #define VBOXQGL_LOAD_OVERLAYSTART(_pSSM) do{}while(0) 163 #define VBOXQGL_LOAD_OVERLAYSTOP(_pSSM) do{}while(0) 164 165 #endif 166 167 /********************************************************************************************************************************* 168 * Global Variables * 169 *********************************************************************************************************************************/ 170 static VBoxVHWAInfo g_VBoxVHWASupportInfo; 171 static bool g_bVBoxVHWAChecked = false; 172 static bool g_bVBoxVHWASupported = false; 173 174 91 175 #ifdef DEBUG 92 VBoxVHWADbgTimer::VBoxVHWADbgTimer(uint32_t cPeriods) : 93 mPeriodSum(0LL), 94 mPrevTime(0LL), 95 mcFrames(0LL), 96 mcPeriods(cPeriods), 97 miPeriod(0) 176 177 VBoxVHWADbgTimer::VBoxVHWADbgTimer(uint32_t cPeriods) 178 : mPeriodSum(0) 179 , mPrevTime(0) 180 , mcFrames(0) 181 , mcPeriods(cPeriods) 182 , miPeriod(0) 98 183 { 99 184 mpaPeriods = new uint64_t[cPeriods]; … … 109 194 { 110 195 uint64_t cur = VBOXGETTIME(); 111 if (mPrevTime)196 if (mPrevTime) 112 197 { 113 198 uint64_t curPeriod = cur - mPrevTime; … … 120 205 ++mcFrames; 121 206 } 122 #endif 123 124 //#define VBOXQGLOVERLAY_STATE_NAMEBASE "QGLOverlayVHWAData" 125 //#define VBOXQGLOVERLAY_STATE_VERSION 1 126 127 #ifdef DEBUG_misha 128 //# define VBOXQGL_STATE_DEBUG 129 #endif 130 131 #ifdef VBOXQGL_STATE_DEBUG 132 #define VBOXQGL_STATE_START_MAGIC 0x12345678 133 #define VBOXQGL_STATE_STOP_MAGIC 0x87654321 134 135 #define VBOXQGL_STATE_SURFSTART_MAGIC 0x9abcdef1 136 #define VBOXQGL_STATE_SURFSTOP_MAGIC 0x1fedcba9 137 138 #define VBOXQGL_STATE_OVERLAYSTART_MAGIC 0x13579bdf 139 #define VBOXQGL_STATE_OVERLAYSTOP_MAGIC 0xfdb97531 140 141 #define VBOXQGL_SAVE_START(_pSSM) do{ int rc = SSMR3PutU32(_pSSM, VBOXQGL_STATE_START_MAGIC); AssertRC(rc);}while(0) 142 #define VBOXQGL_SAVE_STOP(_pSSM) do{ int rc = SSMR3PutU32(_pSSM, VBOXQGL_STATE_STOP_MAGIC); AssertRC(rc);}while(0) 143 144 #define VBOXQGL_SAVE_SURFSTART(_pSSM) do{ int rc = SSMR3PutU32(_pSSM, VBOXQGL_STATE_SURFSTART_MAGIC); AssertRC(rc);}while(0) 145 #define VBOXQGL_SAVE_SURFSTOP(_pSSM) do{ int rc = SSMR3PutU32(_pSSM, VBOXQGL_STATE_SURFSTOP_MAGIC); AssertRC(rc);}while(0) 146 147 #define VBOXQGL_SAVE_OVERLAYSTART(_pSSM) do{ int rc = SSMR3PutU32(_pSSM, VBOXQGL_STATE_OVERLAYSTART_MAGIC); AssertRC(rc);}while(0) 148 #define VBOXQGL_SAVE_OVERLAYSTOP(_pSSM) do{ int rc = SSMR3PutU32(_pSSM, VBOXQGL_STATE_OVERLAYSTOP_MAGIC); AssertRC(rc);}while(0) 149 150 #define VBOXQGL_LOAD_CHECK(_pSSM, _v) \ 151 do{ \ 152 uint32_t _u32; \ 153 int rc = SSMR3GetU32(_pSSM, &_u32); AssertRC(rc); \ 154 if(_u32 != (_v)) \ 155 { \ 156 VBOXQGLLOG(("load error: expected magic (0x%x), but was (0x%x)\n", (_v), _u32));\ 157 }\ 158 Assert(_u32 == (_v)); \ 159 }while(0) 160 161 #define VBOXQGL_LOAD_START(_pSSM) VBOXQGL_LOAD_CHECK(_pSSM, VBOXQGL_STATE_START_MAGIC) 162 #define VBOXQGL_LOAD_STOP(_pSSM) VBOXQGL_LOAD_CHECK(_pSSM, VBOXQGL_STATE_STOP_MAGIC) 163 164 #define VBOXQGL_LOAD_SURFSTART(_pSSM) VBOXQGL_LOAD_CHECK(_pSSM, VBOXQGL_STATE_SURFSTART_MAGIC) 165 #define VBOXQGL_LOAD_SURFSTOP(_pSSM) VBOXQGL_LOAD_CHECK(_pSSM, VBOXQGL_STATE_SURFSTOP_MAGIC) 166 167 #define VBOXQGL_LOAD_OVERLAYSTART(_pSSM) VBOXQGL_LOAD_CHECK(_pSSM, VBOXQGL_STATE_OVERLAYSTART_MAGIC) 168 #define VBOXQGL_LOAD_OVERLAYSTOP(_pSSM) VBOXQGL_LOAD_CHECK(_pSSM, VBOXQGL_STATE_OVERLAYSTOP_MAGIC) 169 170 #else 171 172 #define VBOXQGL_SAVE_START(_pSSM) do{}while(0) 173 #define VBOXQGL_SAVE_STOP(_pSSM) do{}while(0) 174 175 #define VBOXQGL_SAVE_SURFSTART(_pSSM) do{}while(0) 176 #define VBOXQGL_SAVE_SURFSTOP(_pSSM) do{}while(0) 177 178 #define VBOXQGL_SAVE_OVERLAYSTART(_pSSM) do{}while(0) 179 #define VBOXQGL_SAVE_OVERLAYSTOP(_pSSM) do{}while(0) 180 181 #define VBOXQGL_LOAD_START(_pSSM) do{}while(0) 182 #define VBOXQGL_LOAD_STOP(_pSSM) do{}while(0) 183 184 #define VBOXQGL_LOAD_SURFSTART(_pSSM) do{}while(0) 185 #define VBOXQGL_LOAD_SURFSTOP(_pSSM) do{}while(0) 186 187 #define VBOXQGL_LOAD_OVERLAYSTART(_pSSM) do{}while(0) 188 #define VBOXQGL_LOAD_OVERLAYSTOP(_pSSM) do{}while(0) 189 190 #endif 191 192 static VBoxVHWAInfo g_VBoxVHWASupportInfo; 193 static bool g_bVBoxVHWAChecked = false; 194 static bool g_bVBoxVHWASupported = false; 207 208 #endif /* DEBUG */ 209 195 210 196 211 class VBoxVHWAEntriesCache … … 231 246 static struct VBOXVHWACMD * vhwaHHCmdCreate(VBOXVHWACMD_TYPE type, size_t size) 232 247 { 233 char *buf = (char *)malloc(VBOXVHWACMD_SIZE_FROMBODYSIZE(size));248 char *buf = (char *)malloc(VBOXVHWACMD_SIZE_FROMBODYSIZE(size)); 234 249 memset(buf, 0, size); 235 250 VBOXVHWACMD *pCmd = (VBOXVHWACMD *)buf; … … 241 256 static const VBoxVHWAInfo & vboxVHWAGetSupportInfo(const QGLContext *pContext) 242 257 { 243 if (!g_VBoxVHWASupportInfo.isInitialized())244 { 245 if (pContext)258 if (!g_VBoxVHWASupportInfo.isInitialized()) 259 { 260 if (pContext) 246 261 { 247 262 g_VBoxVHWASupportInfo.init(pContext); … … 252 267 const QGLContext *pContext = ctx.makeCurrent(); 253 268 Assert(pContext); 254 if (pContext)269 if (pContext) 255 270 { 256 271 g_VBoxVHWASupportInfo.init(pContext); … … 318 333 } 319 334 320 uint32_t VBoxVHWAHandleTable::put(void * 335 uint32_t VBoxVHWAHandleTable::put(void *data) 321 336 { 322 337 Assert(data); 323 if (!data)338 if (!data) 324 339 return VBOXVHWA_SURFHANDLE_INVALID; 325 340 326 if (mcUsage == mcSize)341 if (mcUsage == mcSize) 327 342 { 328 343 /** @todo resize */ … … 331 346 332 347 Assert(mcUsage < mcSize); 333 if (mcUsage >= mcSize)348 if (mcUsage >= mcSize) 334 349 return VBOXVHWA_SURFHANDLE_INVALID; 335 350 336 for (int k = 0; k < 2; ++k)351 for (int k = 0; k < 2; ++k) 337 352 { 338 353 Assert(mCursor != 0); 339 for (uint32_t i = mCursor; i < mcSize; ++i)340 { 341 if (!mTable[i])354 for (uint32_t i = mCursor; i < mcSize; ++i) 355 { 356 if (!mTable[i]) 342 357 { 343 358 doPut(i, data); … … 355 370 bool VBoxVHWAHandleTable::mapPut(uint32_t h, void * data) 356 371 { 357 if (mcSize <= h)372 if (mcSize <= h) 358 373 return false; 359 if (h == 0)374 if (h == 0) 360 375 return false; 361 if (mTable[h])376 if (mTable[h]) 362 377 return false; 363 378 … … 379 394 void* val = mTable[h]; 380 395 Assert(val); 381 if (val)396 if (val) 382 397 { 383 398 doRemove(h); … … 398 413 } 399 414 400 static VBoxVHWATextureImage* vboxVHWAImageCreate(const QRect & aRect, const VBoxVHWAColorFormat & aFormat, class VBoxVHWAGlProgramMngr * pMgr, VBOXVHWAIMG_TYPE flags) 415 static VBoxVHWATextureImage *vboxVHWAImageCreate(const QRect & aRect, const VBoxVHWAColorFormat & aFormat, 416 class VBoxVHWAGlProgramMngr * pMgr, VBOXVHWAIMG_TYPE flags) 401 417 { 402 418 bool bCanLinearNonFBO = false; … … 408 424 409 425 const VBoxVHWAInfo & info = vboxVHWAGetSupportInfo(NULL); 410 if ((flags & VBOXVHWAIMG_PBO) && !info.getGlInfo().isPBOSupported())426 if ((flags & VBOXVHWAIMG_PBO) && !info.getGlInfo().isPBOSupported()) 411 427 flags &= ~VBOXVHWAIMG_PBO; 412 428 413 if ((flags & VBOXVHWAIMG_PBOIMG) &&429 if ((flags & VBOXVHWAIMG_PBOIMG) && 414 430 (!info.getGlInfo().isPBOSupported() || !info.getGlInfo().isPBOOffsetSupported())) 415 431 flags &= ~VBOXVHWAIMG_PBOIMG; 416 432 417 if ((flags & VBOXVHWAIMG_FBO) && !info.getGlInfo().isFBOSupported())433 if ((flags & VBOXVHWAIMG_FBO) && !info.getGlInfo().isFBOSupported()) 418 434 flags &= ~VBOXVHWAIMG_FBO; 419 435 420 436 /* ensure we don't create a PBO-based texture in case we use a PBO-based image */ 421 if (flags & VBOXVHWAIMG_PBOIMG)437 if (flags & VBOXVHWAIMG_PBOIMG) 422 438 flags &= ~VBOXVHWAIMG_PBO; 423 439 424 if (flags & VBOXVHWAIMG_FBO)425 { 426 if (flags & VBOXVHWAIMG_PBOIMG)440 if (flags & VBOXVHWAIMG_FBO) 441 { 442 if (flags & VBOXVHWAIMG_PBOIMG) 427 443 { 428 444 VBOXQGLLOG(("FBO PBO Image\n")); … … 439 455 } 440 456 441 if (flags & VBOXVHWAIMG_PBOIMG)457 if (flags & VBOXVHWAIMG_PBOIMG) 442 458 { 443 459 VBOXQGLLOG(("PBO Image\n")); … … 449 465 } 450 466 451 static VBoxVHWATexture* vboxVHWATextureCreate(const QGLContext * pContext, const QRect & aRect, const VBoxVHWAColorFormat & aFormat, uint32_t bytesPerLine, VBOXVHWAIMG_TYPE flags) 467 static VBoxVHWATexture* vboxVHWATextureCreate(const QGLContext * pContext, const QRect & aRect, 468 const VBoxVHWAColorFormat & aFormat, uint32_t bytesPerLine, VBOXVHWAIMG_TYPE flags) 452 469 { 453 470 const VBoxVHWAInfo & info = vboxVHWAGetSupportInfo(pContext); 454 471 GLint scaleFunc = (flags & VBOXVHWAIMG_LINEAR) ? GL_LINEAR : GL_NEAREST; 455 if ((flags & VBOXVHWAIMG_PBO) && info.getGlInfo().isPBOSupported())472 if ((flags & VBOXVHWAIMG_PBO) && info.getGlInfo().isPBOSupported()) 456 473 { 457 474 VBOXQGLLOG(("VBoxVHWATextureNP2RectPBO\n")); 458 475 return new VBoxVHWATextureNP2RectPBO(aRect, aFormat, bytesPerLine, scaleFunc); 459 476 } 460 else if (info.getGlInfo().isTextureRectangleSupported())477 else if (info.getGlInfo().isTextureRectangleSupported()) 461 478 { 462 479 VBOXQGLLOG(("VBoxVHWATextureNP2Rect\n")); 463 480 return new VBoxVHWATextureNP2Rect(aRect, aFormat, bytesPerLine, scaleFunc); 464 481 } 465 else if (info.getGlInfo().isTextureNP2Supported())482 else if (info.getGlInfo().isTextureNP2Supported()) 466 483 { 467 484 VBOXQGLLOG(("VBoxVHWATextureNP2\n")); … … 475 492 { 476 493 public: 477 VBoxVHWAGlShaderComponent(const char *aRcName, GLenum aType) :478 mRcName(aRcName),479 mType(aType),480 mInitialized(false)494 VBoxVHWAGlShaderComponent(const char *aRcName, GLenum aType) 495 : mRcName(aRcName) 496 , mType(aType) 497 , mInitialized(false) 481 498 { NOREF(mType); } 482 499 … … 495 512 int VBoxVHWAGlShaderComponent::init() 496 513 { 497 if (isInitialized())514 if (isInitialized()) 498 515 return VINF_ALREADY_INITIALIZED; 499 516 … … 526 543 mcComponents = other.mcComponents; 527 544 mType = other.mType; 528 if (mcComponents)545 if (mcComponents) 529 546 { 530 547 maComponents = new VBoxVHWAGlShaderComponent*[mcComponents]; … … 538 555 mcComponents = other.mcComponents; 539 556 mType = other.mType; 540 if (mcComponents)557 if (mcComponents) 541 558 { 542 559 maComponents = new VBoxVHWAGlShaderComponent*[mcComponents]; … … 571 588 length = new GLint[mcComponents]; 572 589 sources = new const char*[mcComponents]; 573 for (int i = 0; i < mcComponents; i++)590 for (int i = 0; i < mcComponents; i++) 574 591 { 575 592 length[i] = -1; 576 593 rc = maComponents[i]->init(); 577 594 AssertRC(rc); 578 if (RT_FAILURE(rc))595 if (RT_FAILURE(rc)) 579 596 break; 580 597 sources[i] = maComponents[i]->contents(); 581 598 } 582 599 583 if (RT_SUCCESS(rc))600 if (RT_SUCCESS(rc)) 584 601 { 585 602 #ifdef DEBUG 586 603 VBOXQGLLOG(("\ncompiling shaders:\n------------\n")); 587 for(int i = 0; i < mcComponents; i++) 588 { 604 for (int i = 0; i < mcComponents; i++) 589 605 VBOXQGLLOG(("**********\n%s\n***********\n", sources[i])); 590 }591 606 VBOXQGLLOG(("------------\n")); 592 607 #endif … … 614 629 615 630 Assert(compiled); 616 if (compiled)631 if (compiled) 617 632 { 618 633 rc = VINF_SUCCESS; … … 656 671 { 657 672 Assert(acShaders); 658 if (acShaders)673 if (acShaders) 659 674 { 660 675 mShaders = new VBoxVHWAGlShader[acShaders]; 661 for (int i = 0; i < acShaders; i++)676 for (int i = 0; i < acShaders; i++) 662 677 { 663 678 mShaders[i] = *apShaders[i]; … … 671 686 uninit(); 672 687 673 if (mShaders)688 if (mShaders) 674 689 { 675 690 delete[] mShaders; … … 680 695 { 681 696 Assert(!isInitialized()); 682 if (isInitialized())697 if (isInitialized()) 683 698 return VINF_ALREADY_INITIALIZED; 684 699 685 700 Assert(mcShaders); 686 if (!mcShaders)701 if (!mcShaders) 687 702 return VERR_GENERAL_FAILURE; 688 703 689 704 int rc = VINF_SUCCESS; 690 for (int i = 0; i < mcShaders; i++)705 for (int i = 0; i < mcShaders; i++) 691 706 { 692 707 int rc = mShaders[i].init(); 693 708 AssertRC(rc); 694 if (RT_FAILURE(rc))709 if (RT_FAILURE(rc)) 695 710 { 696 711 break; 697 712 } 698 713 } 699 if (RT_FAILURE(rc))714 if (RT_FAILURE(rc)) 700 715 { 701 716 return rc; … … 704 719 mProgram = vboxglCreateProgram(); 705 720 Assert(mProgram); 706 if (mProgram)707 { 708 for (int i = 0; i < mcShaders; i++)721 if (mProgram) 722 { 723 for (int i = 0; i < mcShaders; i++) 709 724 { 710 725 VBOXQGL_CHECKERR( … … 729 744 #endif 730 745 731 if (linked)746 if (linked) 732 747 { 733 748 return VINF_SUCCESS; … … 744 759 void VBoxVHWAGlProgram::uninit() 745 760 { 746 if (!isInitialized())761 if (!isInitialized()) 747 762 return; 748 763 … … 839 854 }; 840 855 841 VBoxVHWAGlProgramVHWA::VBoxVHWAGlProgramVHWA(uint32_t type, uint32_t fourcc, VBoxVHWAGlShader ** apShaders, int acShaders) : 842 VBoxVHWAGlProgram(apShaders, acShaders), 843 mType(type), 844 mFourcc(fourcc), 845 mDstUpperR(0.0), mDstUpperG(0.0), mDstUpperB(0.0), 846 mUniDstUpperColor(-1), 847 mDstLowerR(0.0), mDstLowerG(0.0), mDstLowerB(0.0), 848 mUniDstLowerColor(-1), 849 mSrcUpperR(0.0), mSrcUpperG(0.0), mSrcUpperB(0.0), 850 mUniSrcUpperColor(-1), 851 mSrcLowerR(0.0), mSrcLowerG(0.0), mSrcLowerB(0.0), 852 mUniSrcLowerColor(-1), 853 mDstTex(-1), 854 mUniDstTex(-1), 855 mSrcTex(-1), 856 mUniSrcTex(-1), 857 mVTex(-1), 858 mUniVTex(-1), 859 mUTex(-1), 860 mUniUTex(-1) 856 VBoxVHWAGlProgramVHWA::VBoxVHWAGlProgramVHWA(uint32_t type, uint32_t fourcc, VBoxVHWAGlShader **apShaders, int acShaders) 857 : VBoxVHWAGlProgram(apShaders, acShaders) 858 , mType(type) 859 , mFourcc(fourcc) 860 , mDstUpperR(0.0) 861 , mDstUpperG(0.0) 862 , mDstUpperB(0.0) 863 , mUniDstUpperColor(-1) 864 , mDstLowerR(0.0) 865 , mDstLowerG(0.0) 866 , mDstLowerB(0.0) 867 , mUniDstLowerColor(-1) 868 , mSrcUpperR(0.0) 869 , mSrcUpperG(0.0) 870 , mSrcUpperB(0.0) 871 , mUniSrcUpperColor(-1) 872 , mSrcLowerR(0.0) 873 , mSrcLowerG(0.0) 874 , mSrcLowerB(0.0) 875 , mUniSrcLowerColor(-1) 876 , mDstTex(-1) 877 , mUniDstTex(-1) 878 , mSrcTex(-1) 879 , mUniSrcTex(-1) 880 , mVTex(-1) 881 , mUniVTex(-1) 882 , mUTex(-1) 883 , mUniUTex(-1) 861 884 {} 862 885 … … 864 887 { 865 888 int rc = VBoxVHWAGlProgram::init(); 866 if (RT_FAILURE(rc))889 if (RT_FAILURE(rc)) 867 890 return rc; 868 if (rc == VINF_ALREADY_INITIALIZED)891 if (rc == VINF_ALREADY_INITIALIZED) 869 892 return rc; 870 893 … … 878 901 mUniSrcTex = vboxglGetUniformLocation(program(), "uSrcTex"); 879 902 Assert(mUniSrcTex != -1); 880 if (mUniSrcTex == -1)903 if (mUniSrcTex == -1) 881 904 break; 882 905 … … 887 910 ++tex; 888 911 889 if (type() & VBOXVHWA_PROGRAM_SRCCOLORKEY)912 if (type() & VBOXVHWA_PROGRAM_SRCCOLORKEY) 890 913 { 891 914 mUniSrcLowerColor = vboxglGetUniformLocation(program(), "uSrcClr"); 892 915 Assert(mUniSrcLowerColor != -1); 893 if (mUniSrcLowerColor == -1)916 if (mUniSrcLowerColor == -1) 894 917 break; 895 918 … … 901 924 } 902 925 903 if (type() & VBOXVHWA_PROGRAM_COLORCONV)926 if (type() & VBOXVHWA_PROGRAM_COLORCONV) 904 927 { 905 928 switch(fourcc()) … … 909 932 mUniVTex = vboxglGetUniformLocation(program(), "uVTex"); 910 933 Assert(mUniVTex != -1); 911 if (mUniVTex == -1)934 if (mUniVTex == -1) 912 935 break; 913 936 … … 920 943 mUniUTex = vboxglGetUniformLocation(program(), "uUTex"); 921 944 Assert(mUniUTex != -1); 922 if (mUniUTex == -1)945 if (mUniUTex == -1) 923 946 break; 924 947 VBOXQGL_CHECKERR( … … 940 963 } 941 964 942 if (type() & VBOXVHWA_PROGRAM_DSTCOLORKEY)965 if (type() & VBOXVHWA_PROGRAM_DSTCOLORKEY) 943 966 { 944 967 945 968 mUniDstTex = vboxglGetUniformLocation(program(), "uDstTex"); 946 969 Assert(mUniDstTex != -1); 947 if (mUniDstTex == -1)970 if (mUniDstTex == -1) 948 971 break; 949 972 VBOXQGL_CHECKERR( … … 955 978 mUniDstLowerColor = vboxglGetUniformLocation(program(), "uDstClr"); 956 979 Assert(mUniDstLowerColor != -1); 957 if (mUniDstLowerColor == -1)980 if (mUniDstLowerColor == -1) 958 981 break; 959 982 … … 970 993 971 994 stop(); 972 if (rc == VINF_SUCCESS)995 if (rc == VINF_SUCCESS) 973 996 return VINF_SUCCESS; 974 997 … … 981 1004 { 982 1005 Assert(isInitialized()); 983 if (!isInitialized())1006 if (!isInitialized()) 984 1007 return VERR_GENERAL_FAILURE; 985 if (mDstUpperR == r && mDstUpperG == g && mDstUpperB == b)1008 if (mDstUpperR == r && mDstUpperG == g && mDstUpperB == b) 986 1009 return VINF_ALREADY_INITIALIZED; 987 1010 vboxglUniform4f(mUniDstUpperColor, r, g, b, 0.0); … … 995 1018 { 996 1019 Assert(isInitialized()); 997 if (!isInitialized())1020 if (!isInitialized()) 998 1021 return VERR_GENERAL_FAILURE; 999 if (mDstLowerR == r && mDstLowerG == g && mDstLowerB == b)1022 if (mDstLowerR == r && mDstLowerG == g && mDstLowerB == b) 1000 1023 return VINF_ALREADY_INITIALIZED; 1001 1024 … … 1013 1036 { 1014 1037 Assert(isInitialized()); 1015 if (!isInitialized())1038 if (!isInitialized()) 1016 1039 return VERR_GENERAL_FAILURE; 1017 if (mSrcUpperR == r && mSrcUpperG == g && mSrcUpperB == b)1040 if (mSrcUpperR == r && mSrcUpperG == g && mSrcUpperB == b) 1018 1041 return VINF_ALREADY_INITIALIZED; 1019 1042 vboxglUniform4f(mUniSrcUpperColor, r, g, b, 0.0); … … 1027 1050 { 1028 1051 Assert(isInitialized()); 1029 if (!isInitialized())1052 if (!isInitialized()) 1030 1053 return VERR_GENERAL_FAILURE; 1031 if (mSrcLowerR == r && mSrcLowerG == g && mSrcLowerB == b)1054 if (mSrcLowerR == r && mSrcLowerG == g && mSrcLowerB == b) 1032 1055 return VINF_ALREADY_INITIALIZED; 1033 1056 VBOXQGL_CHECKERR( … … 1043 1066 { 1044 1067 public: 1045 VBoxVHWAGlProgramMngr() :1046 mShaderCConvApplyAYUV(":/cconvApplyAYUV.c", GL_FRAGMENT_SHADER),1047 mShaderCConvAYUV(":/cconvAYUV.c", GL_FRAGMENT_SHADER),1048 mShaderCConvBGR(":/cconvBGR.c", GL_FRAGMENT_SHADER),1049 mShaderCConvUYVY(":/cconvUYVY.c", GL_FRAGMENT_SHADER),1050 mShaderCConvYUY2(":/cconvYUY2.c", GL_FRAGMENT_SHADER),1051 mShaderCConvYV12(":/cconvYV12.c", GL_FRAGMENT_SHADER),1052 mShaderSplitBGRA(":/splitBGRA.c", GL_FRAGMENT_SHADER),1053 mShaderCKeyDst(":/ckeyDst.c", GL_FRAGMENT_SHADER),1054 mShaderCKeyDst2(":/ckeyDst2.c", GL_FRAGMENT_SHADER),1055 mShaderMainOverlay(":/mainOverlay.c", GL_FRAGMENT_SHADER),1056 mShaderMainOverlayNoCKey(":/mainOverlayNoCKey.c", GL_FRAGMENT_SHADER),1057 mShaderMainOverlayNoDiscard(":/mainOverlayNoDiscard.c", GL_FRAGMENT_SHADER),1058 mShaderMainOverlayNoDiscard2(":/mainOverlayNoDiscard2.c", GL_FRAGMENT_SHADER)1068 VBoxVHWAGlProgramMngr() 1069 : mShaderCConvApplyAYUV(":/cconvApplyAYUV.c", GL_FRAGMENT_SHADER) 1070 , mShaderCConvAYUV(":/cconvAYUV.c", GL_FRAGMENT_SHADER) 1071 , mShaderCConvBGR(":/cconvBGR.c", GL_FRAGMENT_SHADER) 1072 , mShaderCConvUYVY(":/cconvUYVY.c", GL_FRAGMENT_SHADER) 1073 , mShaderCConvYUY2(":/cconvYUY2.c", GL_FRAGMENT_SHADER) 1074 , mShaderCConvYV12(":/cconvYV12.c", GL_FRAGMENT_SHADER) 1075 , mShaderSplitBGRA(":/splitBGRA.c", GL_FRAGMENT_SHADER) 1076 , mShaderCKeyDst(":/ckeyDst.c", GL_FRAGMENT_SHADER) 1077 , mShaderCKeyDst2(":/ckeyDst2.c", GL_FRAGMENT_SHADER) 1078 , mShaderMainOverlay(":/mainOverlay.c", GL_FRAGMENT_SHADER) 1079 , mShaderMainOverlayNoCKey(":/mainOverlayNoCKey.c", GL_FRAGMENT_SHADER) 1080 , mShaderMainOverlayNoDiscard(":/mainOverlayNoDiscard.c", GL_FRAGMENT_SHADER) 1081 , mShaderMainOverlayNoDiscard2(":/mainOverlayNoDiscard2.c", GL_FRAGMENT_SHADER) 1059 1082 {} 1060 1083 1061 VBoxVHWAGlProgramVHWA * 1084 VBoxVHWAGlProgramVHWA *getProgram(uint32_t type, const VBoxVHWAColorFormat * pFrom, const VBoxVHWAColorFormat * pTo); 1062 1085 1063 1086 void stopCurrentProgram() … … 1068 1091 } 1069 1092 private: 1070 VBoxVHWAGlProgramVHWA * searchProgram(uint32_t type, uint32_t fourcc, bool bCreate); 1071 1072 VBoxVHWAGlProgramVHWA * createProgram(uint32_t type, uint32_t fourcc); 1093 VBoxVHWAGlProgramVHWA *searchProgram(uint32_t type, uint32_t fourcc, bool bCreate); 1094 VBoxVHWAGlProgramVHWA *createProgram(uint32_t type, uint32_t fourcc); 1073 1095 1074 1096 typedef std::list <VBoxVHWAGlProgramVHWA*> ProgramList; … … 1097 1119 }; 1098 1120 1099 VBoxVHWAGlProgramVHWA * 1100 { 1101 VBoxVHWAGlShaderComponent * 1121 VBoxVHWAGlProgramVHWA *VBoxVHWAGlProgramMngr::createProgram(uint32_t type, uint32_t fourcc) 1122 { 1123 VBoxVHWAGlShaderComponent *apShaders[16]; 1102 1124 uint32_t cShaders = 0; 1103 1125 … … 1107 1129 cShaders++; 1108 1130 1109 if (!!(type & VBOXVHWA_PROGRAM_DSTCOLORKEY)1131 if (!!(type & VBOXVHWA_PROGRAM_DSTCOLORKEY) 1110 1132 && !(type & VBOXVHWA_PROGRAM_COLORKEYNODISCARD)) 1111 1133 { 1112 if (fourcc == FOURCC_YV12)1134 if (fourcc == FOURCC_YV12) 1113 1135 { 1114 1136 apShaders[cShaders++] = &mShaderCKeyDst2; … … 1120 1142 } 1121 1143 1122 if (type & VBOXVHWA_PROGRAM_SRCCOLORKEY)1144 if (type & VBOXVHWA_PROGRAM_SRCCOLORKEY) 1123 1145 { 1124 1146 AssertFailed(); … … 1128 1150 bool bFound = false; 1129 1151 1130 // if (type & VBOXVHWA_PROGRAM_COLORCONV)1131 { 1132 if (fourcc == FOURCC_UYVY)1152 // if (type & VBOXVHWA_PROGRAM_COLORCONV) 1153 { 1154 if (fourcc == FOURCC_UYVY) 1133 1155 { 1134 1156 apShaders[cShaders++] = &mShaderCConvUYVY; 1135 1157 bFound = true; 1136 1158 } 1137 else if (fourcc == FOURCC_YUY2)1159 else if (fourcc == FOURCC_YUY2) 1138 1160 { 1139 1161 apShaders[cShaders++] = &mShaderCConvYUY2; 1140 1162 bFound = true; 1141 1163 } 1142 else if (fourcc == FOURCC_YV12)1164 else if (fourcc == FOURCC_YV12) 1143 1165 { 1144 1166 apShaders[cShaders++] = &mShaderCConvYV12; 1145 1167 bFound = true; 1146 1168 } 1147 else if (fourcc == FOURCC_AYUV)1169 else if (fourcc == FOURCC_AYUV) 1148 1170 { 1149 1171 apShaders[cShaders++] = &mShaderCConvAYUV; … … 1152 1174 } 1153 1175 1154 if (bFound)1176 if (bFound) 1155 1177 { 1156 1178 type |= VBOXVHWA_PROGRAM_COLORCONV; … … 1163 1185 } 1164 1186 1165 if(type & VBOXVHWA_PROGRAM_DSTCOLORKEY) 1166 { 1167 if(type & VBOXVHWA_PROGRAM_COLORKEYNODISCARD) 1168 { 1169 if(fourcc == FOURCC_YV12) 1170 { 1187 if (type & VBOXVHWA_PROGRAM_DSTCOLORKEY) 1188 { 1189 if (type & VBOXVHWA_PROGRAM_COLORKEYNODISCARD) 1190 { 1191 if (fourcc == FOURCC_YV12) 1171 1192 apShaders[cShaders++] = &mShaderMainOverlayNoDiscard2; 1172 }1173 1193 else 1174 {1175 1194 apShaders[cShaders++] = &mShaderMainOverlayNoDiscard; 1176 }1177 1195 } 1178 1196 else 1179 {1180 1197 apShaders[cShaders++] = &mShaderMainOverlay; 1181 }1182 1198 } 1183 1199 else … … 1204 1220 type &= VBOXVHWA_SUPPORTED_PROGRAM; 1205 1221 1206 if (pFrom && pFrom->fourcc())1222 if (pFrom && pFrom->fourcc()) 1207 1223 { 1208 1224 fourcc = pFrom->fourcc(); … … 1210 1226 } 1211 1227 else 1212 { 1213 type &= (~VBOXVHWA_PROGRAM_COLORCONV); 1214 } 1215 1216 if(!(type & VBOXVHWA_PROGRAM_DSTCOLORKEY) 1217 && !(type & VBOXVHWA_PROGRAM_SRCCOLORKEY)) 1218 { 1219 type &= (~VBOXVHWA_PROGRAM_COLORKEYNODISCARD); 1220 } 1221 1222 if(type) 1228 type &= ~VBOXVHWA_PROGRAM_COLORCONV; 1229 1230 if ( !(type & VBOXVHWA_PROGRAM_DSTCOLORKEY) 1231 && !(type & VBOXVHWA_PROGRAM_SRCCOLORKEY)) 1232 type &= ~VBOXVHWA_PROGRAM_COLORKEYNODISCARD; 1233 1234 if (type) 1223 1235 return searchProgram(type, fourcc, true); 1224 1236 return NULL; … … 1227 1239 VBoxVHWAGlProgramVHWA * VBoxVHWAGlProgramMngr::searchProgram(uint32_t type, uint32_t fourcc, bool bCreate) 1228 1240 { 1229 for (ProgramList::const_iterator it = mPrograms.begin(); 1230 it != mPrograms.end(); ++ it) 1241 for (ProgramList::const_iterator it = mPrograms.begin(); it != mPrograms.end(); ++ it) 1231 1242 { 1232 1243 if (!(*it)->matches(type, fourcc)) 1233 {1234 1244 continue; 1235 }1236 1245 return *it; 1237 1246 } 1238 if (bCreate)1247 if (bCreate) 1239 1248 { 1240 1249 VBoxVHWAGlProgramVHWA *pProgram = createProgram(type, fourcc); 1241 if (pProgram)1250 if (pProgram) 1242 1251 { 1243 1252 mPrograms.push_back(pProgram); … … 1251 1260 { 1252 1261 Assert(addr); 1253 if(!addr) return; 1254 if(addr == mAddress) return; 1255 1256 if(mFreeAddress) 1257 { 1262 if (!addr) 1263 return; 1264 if (addr == mAddress) 1265 return; 1266 1267 if (mFreeAddress) 1258 1268 free(mAddress); 1259 }1260 1269 1261 1270 mAddress = addr; … … 1285 1294 1286 1295 VBoxVHWASurfaceBase::VBoxVHWASurfaceBase(class VBoxVHWAImage *pImage, 1287 const QSize & aSize, 1288 const QRect & aTargRect, 1289 const QRect & aSrcRect, 1290 const QRect & aVisTargRect, 1291 VBoxVHWAColorFormat & aColorFormat, 1292 VBoxVHWAColorKey * pSrcBltCKey, VBoxVHWAColorKey * pDstBltCKey, 1293 VBoxVHWAColorKey * pSrcOverlayCKey, VBoxVHWAColorKey * pDstOverlayCKey, 1294 VBOXVHWAIMG_TYPE aImgFlags) : 1295 mRect(0,0,aSize.width(),aSize.height()), 1296 mAddress(NULL), 1297 mpSrcBltCKey(NULL), 1298 mpDstBltCKey(NULL), 1299 mpSrcOverlayCKey(NULL), 1300 mpDstOverlayCKey(NULL), 1301 mpDefaultDstOverlayCKey(NULL), 1302 mpDefaultSrcOverlayCKey(NULL), 1303 mLockCount(0), 1304 mFreeAddress(false), 1305 mbNotIntersected(false), 1306 mComplexList(NULL), 1307 mpPrimary(NULL), 1308 mHGHandle(VBOXVHWA_SURFHANDLE_INVALID), 1309 mpImage(pImage) 1296 const QSize &aSize, 1297 const QRect &aTargRect, 1298 const QRect &aSrcRect, 1299 const QRect &aVisTargRect, 1300 VBoxVHWAColorFormat &aColorFormat, 1301 VBoxVHWAColorKey *pSrcBltCKey, 1302 VBoxVHWAColorKey *pDstBltCKey, 1303 VBoxVHWAColorKey *pSrcOverlayCKey, 1304 VBoxVHWAColorKey *pDstOverlayCKey, 1305 VBOXVHWAIMG_TYPE aImgFlags) 1306 : mRect(0,0,aSize.width(),aSize.height()) 1307 , mAddress(NULL) 1308 , mpSrcBltCKey(NULL) 1309 , mpDstBltCKey(NULL) 1310 , mpSrcOverlayCKey(NULL) 1311 , mpDstOverlayCKey(NULL) 1312 , mpDefaultDstOverlayCKey(NULL) 1313 , mpDefaultSrcOverlayCKey(NULL) 1314 , mLockCount(0) 1315 , mFreeAddress(false) 1316 , mbNotIntersected(false) 1317 , mComplexList(NULL) 1318 , mpPrimary(NULL) 1319 , mHGHandle(VBOXVHWA_SURFHANDLE_INVALID) 1320 , mpImage(pImage) 1310 1321 #ifdef DEBUG 1311 , 1312 cFlipsCurr(0), 1313 cFlipsTarg(0) 1322 , cFlipsCurr(0) 1323 , cFlipsTarg(0) 1314 1324 #endif 1315 1325 { … … 1337 1347 { 1338 1348 int last = ASMBitLastSetS32(val); 1339 if (last>1)1349 if (last>1) 1340 1350 { 1341 1351 last--; 1342 if ((1 << last) != val)1352 if ((1 << last) != val) 1343 1353 { 1344 1354 Assert((1 << last) < val); … … 1355 1365 switch(format) 1356 1366 { 1357 case GL_COLOR_INDEX:1358 case GL_RED:1359 case GL_GREEN:1360 case GL_BLUE:1361 case GL_ALPHA:1362 case GL_LUMINANCE:1363 numComponents = 1;1364 break;1365 case GL_RGB:1366 case GL_BGR_EXT:1367 numComponents = 3;1368 break;1369 case GL_RGBA:1370 case GL_BGRA_EXT:1371 numComponents = 4;1372 break;1373 case GL_LUMINANCE_ALPHA:1374 numComponents = 2;1375 break;1376 default:1377 AssertFailed();1378 break;1367 case GL_COLOR_INDEX: 1368 case GL_RED: 1369 case GL_GREEN: 1370 case GL_BLUE: 1371 case GL_ALPHA: 1372 case GL_LUMINANCE: 1373 numComponents = 1; 1374 break; 1375 case GL_RGB: 1376 case GL_BGR_EXT: 1377 numComponents = 3; 1378 break; 1379 case GL_RGBA: 1380 case GL_BGRA_EXT: 1381 numComponents = 4; 1382 break; 1383 case GL_LUMINANCE_ALPHA: 1384 numComponents = 2; 1385 break; 1386 default: 1387 AssertFailed(); 1388 break; 1379 1389 } 1380 1390 … … 1382 1392 switch(type) 1383 1393 { 1384 case GL_UNSIGNED_BYTE:1385 case GL_BYTE:1386 componentSize = 1;1387 break;1388 //case GL_BITMAP:1389 case GL_UNSIGNED_SHORT:1390 case GL_SHORT:1391 componentSize = 2;1392 break;1393 case GL_UNSIGNED_INT:1394 case GL_INT:1395 case GL_FLOAT:1396 componentSize = 4;1397 break;1398 default:1399 AssertFailed();1400 break;1394 case GL_UNSIGNED_BYTE: 1395 case GL_BYTE: 1396 componentSize = 1; 1397 break; 1398 //case GL_BITMAP: 1399 case GL_UNSIGNED_SHORT: 1400 case GL_SHORT: 1401 componentSize = 2; 1402 break; 1403 case GL_UNSIGNED_INT: 1404 case GL_INT: 1405 case GL_FLOAT: 1406 componentSize = 4; 1407 break; 1408 default: 1409 AssertFailed(); 1410 break; 1401 1411 } 1402 1412 return numComponents * componentSize; … … 1407 1417 delete mImage; 1408 1418 1409 if (mAddress && mFreeAddress)1419 if (mAddress && mFreeAddress) 1410 1420 { 1411 1421 free(mAddress); … … 1421 1431 void VBoxVHWASurfaceBase::init(VBoxVHWASurfaceBase * pPrimary, uchar *pvMem) 1422 1432 { 1423 if (pPrimary)1433 if (pPrimary) 1424 1434 { 1425 1435 VBOXQGL_CHECKERR( … … 1432 1442 #ifdef DEBUG_misha 1433 1443 int tex0Size = mImage->component(0)->memSize(); 1434 if (pPrimary)1444 if (pPrimary) 1435 1445 { 1436 1446 memset(address, 0xff, tex0Size); 1437 1447 Assert(size >= tex0Size); 1438 if(size > tex0Size) 1439 { 1448 if (size > tex0Size) 1440 1449 memset(address + tex0Size, 0x0, size - tex0Size); 1441 }1442 1450 } 1443 1451 else … … 1445 1453 memset(address, 0x0f, tex0Size); 1446 1454 Assert(size >= tex0Size); 1447 if(size > tex0Size) 1448 { 1455 if (size > tex0Size) 1449 1456 memset(address + tex0Size, 0x3f, size - tex0Size); 1450 }1451 1457 } 1452 1458 #else … … 1457 1463 mpPrimary = pPrimary; 1458 1464 1459 if (pvMem)1465 if (pvMem) 1460 1466 { 1461 1467 mAddress = pvMem; … … 1478 1484 Assert(mRect.contains(mUpdateMem2TexRect.rect())); 1479 1485 1480 if (pPrimary)1486 if (pPrimary) 1481 1487 { 1482 1488 VBOXQGLLOG(("restoring to tex 0")); … … 1488 1494 } 1489 1495 1490 void VBoxVHWATexture::doUpdate(uchar * pAddress, const QRect *pRect)1496 void VBoxVHWATexture::doUpdate(uchar *pAddress, const QRect *pRect) 1491 1497 { 1492 1498 GLenum tt = texTarget(); 1493 if(pRect) 1494 { 1499 if (pRect) 1495 1500 Assert(mRect.contains(*pRect)); 1496 }1497 1501 else 1498 {1499 1502 pRect = &mRect; 1500 }1501 1503 1502 1504 Assert(glIsTexture(mTexture)); … … 1510 1512 int height = pRect->height()/mColorFormat.heightCompression(); 1511 1513 1512 uchar * 1514 uchar *address = pAddress + pointOffsetTex(x, y); 1513 1515 1514 1516 VBOXQGL_CHECKERR( … … 1532 1534 void VBoxVHWATexture::texCoord(int x, int y) 1533 1535 { 1534 glTexCoord2f(((float)x)/mTexRect.width()/mColorFormat.widthCompression(), ((float)y)/mTexRect.height()/mColorFormat.heightCompression()); 1536 glTexCoord2f(((float)x)/mTexRect.width()/mColorFormat.widthCompression(), 1537 ((float)y)/mTexRect.height()/mColorFormat.heightCompression()); 1535 1538 } 1536 1539 1537 1540 void VBoxVHWATexture::multiTexCoord(GLenum texUnit, int x, int y) 1538 1541 { 1539 vboxglMultiTexCoord2f(texUnit, ((float)x)/mTexRect.width()/mColorFormat.widthCompression(), ((float)y)/mTexRect.height()/mColorFormat.heightCompression()); 1542 vboxglMultiTexCoord2f(texUnit, ((float)x)/mTexRect.width()/mColorFormat.widthCompression(), 1543 ((float)y)/mTexRect.height()/mColorFormat.heightCompression()); 1540 1544 } 1541 1545 1542 1546 void VBoxVHWATexture::uninit() 1543 1547 { 1544 if(mTexture) 1545 { 1548 if (mTexture) 1546 1549 glDeleteTextures(1,&mTexture); 1547 1548 } 1549 1550 VBoxVHWATexture::VBoxVHWATexture(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, uint32_t bytesPerLine, GLint scaleFuncttion) : 1551 mAddress(NULL),1552 mTexture(0),1553 mBytesPerPixel(0),1554 mBytesPerPixelTex(0),1555 mBytesPerLine(0),1556 1557 { 1558 mColorFormat = aFormat;1559 mRect = aRect;1560 mBytesPerPixel = mColorFormat.bitsPerPixel()/8;1561 mBytesPerPixelTex = mColorFormat.bitsPerPixelTex() /8;1562 mBytesPerLine = bytesPerLine ? bytesPerLine : mBytesPerPixel * mRect.width();1563 GLsizei wdt = VBoxVHWASurfaceBase::makePowerOf2(mRect.width()/mColorFormat.widthCompression());1564 GLsizei hgt = VBoxVHWASurfaceBase::makePowerOf2(mRect.height()/mColorFormat.heightCompression());1550 } 1551 1552 VBoxVHWATexture::VBoxVHWATexture(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, 1553 uint32_t bytesPerLine, GLint scaleFuncttion) 1554 : mAddress(NULL) 1555 , mTexture(0) 1556 , mBytesPerPixel(0) 1557 , mBytesPerPixelTex(0) 1558 , mBytesPerLine(0) 1559 , mScaleFuncttion(scaleFuncttion) 1560 { 1561 mColorFormat = aFormat; 1562 mRect = aRect; 1563 mBytesPerPixel = mColorFormat.bitsPerPixel() / 8; 1564 mBytesPerPixelTex = mColorFormat.bitsPerPixelTex() / 8; 1565 mBytesPerLine = bytesPerLine ? bytesPerLine : mBytesPerPixel * mRect.width(); 1566 GLsizei wdt = VBoxVHWASurfaceBase::makePowerOf2(mRect.width() / mColorFormat.widthCompression()); 1567 GLsizei hgt = VBoxVHWASurfaceBase::makePowerOf2(mRect.height() / mColorFormat.heightCompression()); 1565 1568 mTexRect = QRect(0,0,wdt,hgt); 1566 1569 } … … 1663 1666 } 1664 1667 1665 GLenum VBoxVHWATextureNP2Rect::texTarget() {return GL_TEXTURE_RECTANGLE; } 1668 GLenum VBoxVHWATextureNP2Rect::texTarget() 1669 { 1670 return GL_TEXTURE_RECTANGLE; 1671 } 1666 1672 1667 1673 bool VBoxVHWASurfaceBase::synchTexMem(const QRect * pRect) 1668 1674 { 1669 if(pRect) 1670 { 1675 if (pRect) 1671 1676 Assert(mRect.contains(*pRect)); 1672 } 1673 1674 if(mUpdateMem2TexRect.isClear()) 1677 1678 if (mUpdateMem2TexRect.isClear()) 1675 1679 return false; 1676 1680 1677 if (pRect && !mUpdateMem2TexRect.rect().intersects(*pRect))1681 if (pRect && !mUpdateMem2TexRect.rect().intersects(*pRect)) 1678 1682 return false; 1679 1683 … … 1698 1702 } 1699 1703 1700 void VBoxVHWATextureNP2RectPBO::doUpdate(uchar * pAddress, const QRect *pRect)1704 void VBoxVHWATextureNP2RectPBO::doUpdate(uchar *pAddress, const QRect *pRect) 1701 1705 { 1702 1706 Q_UNUSED(pAddress); … … 1711 1715 ); 1712 1716 Assert(buf); 1713 if (buf)1717 if (buf) 1714 1718 { 1715 1719 memcpy(buf, mAddress, memSize()); … … 1757 1761 GLvoid *buf = vboxglMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY); 1758 1762 Assert(buf); 1759 if (buf)1763 if (buf) 1760 1764 { 1761 1765 memcpy(buf, mAddress, memSize()); … … 1771 1775 { 1772 1776 Assert(!mpMappedAllignedBuffer); 1773 if (!mpMappedAllignedBuffer)1777 if (!mpMappedAllignedBuffer) 1774 1778 { 1775 1779 VBOXQGL_CHECKERR( … … 1798 1802 { 1799 1803 Assert(mpMappedAllignedBuffer); 1800 if (mpMappedAllignedBuffer)1804 if (mpMappedAllignedBuffer) 1801 1805 { 1802 1806 VBOXQGL_CHECKERR( … … 1834 1838 } 1835 1839 1836 void VBoxVHWATextureNP2RectPBOMapped::doUpdate(uchar * pAddress, const QRect *pRect)1840 void VBoxVHWATextureNP2RectPBOMapped::doUpdate(uchar *pAddress, const QRect *pRect) 1837 1841 { 1838 1842 Q_UNUSED(pAddress); … … 1843 1847 ); 1844 1848 1845 if (mpMappedAllignedBuffer)1849 if (mpMappedAllignedBuffer) 1846 1850 { 1847 1851 bool unmapped; … … 1862 1866 } 1863 1867 1864 int VBoxVHWASurfaceBase::lock(const QRect * 1868 int VBoxVHWASurfaceBase::lock(const QRect *pRect, uint32_t flags) 1865 1869 { 1866 1870 Q_UNUSED(flags); 1867 1871 1868 if(pRect) 1869 { 1872 if (pRect) 1870 1873 Assert(mRect.contains(*pRect)); 1871 }1872 1874 1873 1875 Assert(mLockCount >= 0); 1874 if (pRect && pRect->isEmpty())1876 if (pRect && pRect->isEmpty()) 1875 1877 return VERR_GENERAL_FAILURE; 1876 if (mLockCount < 0)1878 if (mLockCount < 0) 1877 1879 return VERR_GENERAL_FAILURE; 1878 1880 … … 1895 1897 } 1896 1898 1897 void VBoxVHWASurfaceBase::setRectValues (const QRect & aTargRect, const QRect &aSrcRect)1899 void VBoxVHWASurfaceBase::setRectValues (const QRect &aTargRect, const QRect &aSrcRect) 1898 1900 { 1899 1901 mTargRect = aTargRect; … … 1901 1903 } 1902 1904 1903 void VBoxVHWASurfaceBase::setVisibleRectValues (const QRect & 1905 void VBoxVHWASurfaceBase::setVisibleRectValues (const QRect &aVisTargRect) 1904 1906 { 1905 1907 mVisibleTargRect = aVisTargRect.intersected(mTargRect); 1906 if(mVisibleTargRect.isEmpty() || mTargRect.isEmpty()) 1907 { 1908 if (mVisibleTargRect.isEmpty() || mTargRect.isEmpty()) 1908 1909 mVisibleSrcRect.setSize(QSize(0, 0)); 1909 }1910 1910 else 1911 1911 { … … 1939 1939 void VBoxVHWASurfaceBase::setRects(const QRect & aTargRect, const QRect & aSrcRect) 1940 1940 { 1941 if(mTargRect != aTargRect || mSrcRect != aSrcRect) 1942 { 1941 if (mTargRect != aTargRect || mSrcRect != aSrcRect) 1943 1942 setRectValues(aTargRect, aSrcRect); 1944 }1945 1943 } 1946 1944 … … 1952 1950 } 1953 1951 1954 void VBoxVHWASurfaceBase::updateVisibility (VBoxVHWASurfaceBase *pPrimary, const QRect & aVisibleTargRect, bool bNotIntersected, bool bForce)1955 { 1956 if(bForce || aVisibleTargRect.intersected(mTargRect) != mVisibleTargRect) 1957 {1952 void VBoxVHWASurfaceBase::updateVisibility(VBoxVHWASurfaceBase *pPrimary, const QRect & aVisibleTargRect, 1953 bool bNotIntersected, bool bForce) 1954 { 1955 if (bForce || aVisibleTargRect.intersected(mTargRect) != mVisibleTargRect) 1958 1956 setVisibleRectValues(aVisibleTargRect); 1959 }1960 1957 1961 1958 mpPrimary = pPrimary; … … 1967 1964 void VBoxVHWASurfaceBase::initDisplay() 1968 1965 { 1969 if (mVisibleTargRect.isEmpty() || mVisibleSrcRect.isEmpty())1966 if (mVisibleTargRect.isEmpty() || mVisibleSrcRect.isEmpty()) 1970 1967 { 1971 1968 Assert(mVisibleTargRect.isEmpty() && mVisibleSrcRect.isEmpty()); … … 1974 1971 } 1975 1972 1976 int rc = mImage->initDisplay(mpPrimary ? mpPrimary->mImage : NULL, &mVisibleTargRect, &mVisibleSrcRect, getActiveDstOverlayCKey(mpPrimary), getActiveSrcOverlayCKey(), mbNotIntersected); 1973 int rc = mImage->initDisplay(mpPrimary ? mpPrimary->mImage : NULL, &mVisibleTargRect, &mVisibleSrcRect, 1974 getActiveDstOverlayCKey(mpPrimary), getActiveSrcOverlayCKey(), mbNotIntersected); 1977 1975 AssertRC(rc); 1978 1976 } … … 1980 1978 void VBoxVHWASurfaceBase::updatedMem(const QRect *rec) 1981 1979 { 1982 if(rec) 1983 { 1980 if (rec) 1984 1981 Assert(mRect.contains(*rec)); 1985 }1986 1982 mUpdateMem2TexRect.add(*rec); 1987 1983 } … … 1991 1987 Assert(mImage->displayInitialized()); 1992 1988 1993 if (mVisibleTargRect.isEmpty())1989 if (mVisibleTargRect.isEmpty()) 1994 1990 { 1995 1991 /* nothing to display, i.e. the surface is not visible, … … 1998 1994 return false; 1999 1995 } 2000 else 2001 { 2002 Assert(!mVisibleSrcRect.isEmpty()); 2003 } 1996 Assert(!mVisibleSrcRect.isEmpty()); 2004 1997 2005 1998 bForce |= synchTexMem(&mVisibleSrcRect); 2006 1999 2007 2000 const VBoxVHWAColorKey * pDstCKey = getActiveDstOverlayCKey(pPrimary); 2008 if(pPrimary && pDstCKey) 2009 { 2001 if (pPrimary && pDstCKey) 2010 2002 bForce |= pPrimary->synchTexMem(&mVisibleTargRect); 2011 } 2012 2013 if(!bForce) 2003 2004 if (!bForce) 2014 2005 return false; 2015 2006 … … 2028 2019 { 2029 2020 public: 2030 VBoxGLContext (const QGLFormat & format ) :2031 QGLContext(format),2032 mAllowDoneCurrent(true)2021 VBoxGLContext (const QGLFormat & format ) 2022 : QGLContext(format) 2023 , mAllowDoneCurrent(true) 2033 2024 { 2034 2025 } … … 2036 2027 void doneCurrent() 2037 2028 { 2038 if (!mAllowDoneCurrent)2029 if (!mAllowDoneCurrent) 2039 2030 return; 2040 2031 QGLContext::doneCurrent(); … … 2048 2039 2049 2040 2050 VBoxGLWgt::VBoxGLWgt(VBoxVHWAImage * pImage, 2051 QWidget* parent, const QGLWidget* shareWidget) 2052 2053 : QGLWidget(new VBoxGLContext(shareWidget->format()), parent, shareWidget), 2054 mpImage(pImage) 2041 VBoxGLWgt::VBoxGLWgt(VBoxVHWAImage *pImage, QWidget *parent, const QGLWidget *shareWidget) 2042 : QGLWidget(new VBoxGLContext(shareWidget->format()), parent, shareWidget) 2043 , mpImage(pImage) 2055 2044 { 2056 2045 /* work-around to disable done current needed to old ATI drivers on Linux */ 2057 VBoxGLContext *pc = (VBoxGLContext *)context();2046 VBoxGLContext *pc = (VBoxGLContext *)context(); 2058 2047 pc->allowDoneCurrent (false); 2059 2048 Assert(isSharing()); … … 2062 2051 2063 2052 VBoxVHWAImage::VBoxVHWAImage () 2064 : mSurfHandleTable(128) ,/* 128 should be enough */2065 mRepaintNeeded(false),2066 // mbVGASurfCreated(false),2067 mConstructingList(NULL),2068 mcRemaining2Contruct(0),2069 mSettings(NULL)2053 : mSurfHandleTable(128) /* 128 should be enough */ 2054 , mRepaintNeeded(false) 2055 // , mbVGASurfCreated(false) 2056 , mConstructingList(NULL) 2057 , mcRemaining2Contruct(0) 2058 , mSettings(NULL) 2070 2059 #ifdef VBOXVHWA_PROFILE_FPS 2071 , 2072 mFPSCounter(64), 2073 mbNewFrame(false) 2060 , mFPSCounter(64) 2061 , mbNewFrame(false) 2074 2062 #endif 2075 2063 { … … 2085 2073 } 2086 2074 2087 const QGLFormat & 2075 const QGLFormat &VBoxVHWAImage::vboxGLFormat() 2088 2076 { 2089 2077 static QGLFormat vboxFormat = QGLFormat(); … … 2109 2097 2110 2098 #ifdef VBOXVHWA_OLD_COORD 2111 void VBoxVHWAImage::doSetupMatrix(const QSize & 2099 void VBoxVHWAImage::doSetupMatrix(const QSize &aSize, bool bInverted) 2112 2100 { 2113 2101 VBOXQGL_CHECKERR( 2114 2102 glLoadIdentity(); 2115 2103 ); 2116 if (bInverted)2104 if (bInverted) 2117 2105 { 2118 2106 VBOXQGL_CHECKERR( 2119 glScalef(1.0f /aSize.width(), 1.0f/aSize.height(), 1.0f);2107 glScalef(1.0f / aSize.width(), 1.0f / aSize.height(), 1.0f); 2120 2108 ); 2121 2109 } … … 2127 2115 ); 2128 2116 VBOXQGL_CHECKERR( 2129 glScalef(1.0f /aSize.width(), 1.0f/aSize.height(), 1.0f);2117 glScalef(1.0f / aSize.width(), 1.0f / aSize.height(), 1.0f); 2130 2118 ); 2131 2119 VBOXQGL_CHECKERR( … … 2149 2137 glLoadIdentity(); 2150 2138 2151 if (bInverted)2139 if (bInverted) 2152 2140 glOrtho(0., (GLdouble)display.width(), (GLdouble)display.height(), 0., -1., 1.); 2153 2141 else … … 2158 2146 } 2159 2147 2160 int VBoxVHWAImage::reset(VHWACommandList * 2161 { 2162 VBOXVHWACMD * 2148 int VBoxVHWAImage::reset(VHWACommandList *pCmdList) 2149 { 2150 VBOXVHWACMD *pCmd; 2163 2151 const OverlayList & overlays = mDisplay.overlays(); 2164 for (OverlayList::const_iterator oIt = overlays.begin(); 2165 oIt != overlays.end(); ++ oIt) 2152 for (OverlayList::const_iterator oIt = overlays.begin(); oIt != overlays.end(); ++ oIt) 2166 2153 { 2167 2154 VBoxVHWASurfList * pSurfList = *oIt; 2168 if (pSurfList->current())2155 if (pSurfList->current()) 2169 2156 { 2170 2157 /* 1. hide overlay */ … … 2179 2166 /* 2. destroy overlay */ 2180 2167 const SurfList & surfaces = pSurfList->surfaces(); 2181 2182 for (SurfList::const_iterator sIt = surfaces.begin(); 2183 sIt != surfaces.end(); ++ sIt) 2168 for (SurfList::const_iterator sIt = surfaces.begin(); sIt != surfaces.end(); ++ sIt) 2184 2169 { 2185 2170 VBoxVHWASurfaceBase *pCurSurf = (*sIt); … … 2194 2179 /* 3. destroy primaries */ 2195 2180 const SurfList & surfaces = mDisplay.primaries().surfaces(); 2196 for (SurfList::const_iterator sIt = surfaces.begin(); 2197 sIt != surfaces.end(); ++ sIt) 2181 for (SurfList::const_iterator sIt = surfaces.begin(); sIt != surfaces.end(); ++ sIt) 2198 2182 { 2199 2183 VBoxVHWASurfaceBase *pCurSurf = (*sIt); 2200 if (pCurSurf->handle() != VBOXVHWA_SURFHANDLE_INVALID)2184 if (pCurSurf->handle() != VBOXVHWA_SURFHANDLE_INVALID) 2201 2185 { 2202 2186 pCmd = vhwaHHCmdCreate(VBOXVHWACMD_TYPE_SURF_DESTROY, sizeof(VBOXVHWACMD_SURF_DESTROY)); … … 2218 2202 const VBoxVHWAInfo & info = vboxVHWAGetSupportInfo(NULL); 2219 2203 2220 if (!(pCmd->SurfInfo.flags & VBOXVHWA_SD_CAPS))2204 if (!(pCmd->SurfInfo.flags & VBOXVHWA_SD_CAPS)) 2221 2205 { 2222 2206 AssertFailed(); … … 2225 2209 } 2226 2210 #ifdef VBOXVHWA_ALLOW_PRIMARY_AND_OVERLAY_ONLY 2227 if (pCmd->SurfInfo.surfCaps & VBOXVHWA_SCAPS_OFFSCREENPLAIN)2211 if (pCmd->SurfInfo.surfCaps & VBOXVHWA_SCAPS_OFFSCREENPLAIN) 2228 2212 { 2229 2213 #ifdef DEBUGVHWASTRICT … … 2235 2219 #endif 2236 2220 2237 if (pCmd->SurfInfo.surfCaps & VBOXVHWA_SCAPS_PRIMARYSURFACE)2238 { 2239 if (pCmd->SurfInfo.surfCaps & VBOXVHWA_SCAPS_COMPLEX)2221 if (pCmd->SurfInfo.surfCaps & VBOXVHWA_SCAPS_PRIMARYSURFACE) 2222 { 2223 if (pCmd->SurfInfo.surfCaps & VBOXVHWA_SCAPS_COMPLEX) 2240 2224 { 2241 2225 #ifdef DEBUG_misha … … 2310 2294 } 2311 2295 2312 int VBoxVHWAImage::vhwaSurfaceCreate 2296 int VBoxVHWAImage::vhwaSurfaceCreate(struct VBOXVHWACMD_SURF_CREATE RT_UNTRUSTED_VOLATILE_GUEST *pCmd) 2313 2297 { 2314 2298 VBOXQGLLOG_ENTER (("\n")); 2315 2299 2316 2300 uint32_t handle = VBOXVHWA_SURFHANDLE_INVALID; 2317 if (pCmd->SurfInfo.hSurf != VBOXVHWA_SURFHANDLE_INVALID)2301 if (pCmd->SurfInfo.hSurf != VBOXVHWA_SURFHANDLE_INVALID) 2318 2302 { 2319 2303 handle = pCmd->SurfInfo.hSurf; 2320 if (mSurfHandleTable.get(handle))2304 if (mSurfHandleTable.get(handle)) 2321 2305 { 2322 2306 AssertFailed(); … … 2338 2322 VBoxVHWAColorKey *pDstOverlayCKey = NULL, DstOverlayCKey; 2339 2323 VBoxVHWAColorKey *pSrcOverlayCKey = NULL, SrcOverlayCKey; 2340 if (pCmd->SurfInfo.flags & VBOXVHWA_SD_CKDESTBLT)2324 if (pCmd->SurfInfo.flags & VBOXVHWA_SD_CKDESTBLT) 2341 2325 { 2342 2326 DstBltCKey = VBoxVHWAColorKey(pCmd->SurfInfo.DstBltCK.high, pCmd->SurfInfo.DstBltCK.low); 2343 2327 pDstBltCKey = &DstBltCKey; 2344 2328 } 2345 if (pCmd->SurfInfo.flags & VBOXVHWA_SD_CKSRCBLT)2329 if (pCmd->SurfInfo.flags & VBOXVHWA_SD_CKSRCBLT) 2346 2330 { 2347 2331 SrcBltCKey = VBoxVHWAColorKey(pCmd->SurfInfo.SrcBltCK.high, pCmd->SurfInfo.SrcBltCK.low); 2348 2332 pSrcBltCKey = &SrcBltCKey; 2349 2333 } 2350 if (pCmd->SurfInfo.flags & VBOXVHWA_SD_CKDESTOVERLAY)2334 if (pCmd->SurfInfo.flags & VBOXVHWA_SD_CKDESTOVERLAY) 2351 2335 { 2352 2336 DstOverlayCKey = VBoxVHWAColorKey(pCmd->SurfInfo.DstOverlayCK.high, pCmd->SurfInfo.DstOverlayCK.low); 2353 2337 pDstOverlayCKey = &DstOverlayCKey; 2354 2338 } 2355 if (pCmd->SurfInfo.flags & VBOXVHWA_SD_CKSRCOVERLAY)2339 if (pCmd->SurfInfo.flags & VBOXVHWA_SD_CKSRCOVERLAY) 2356 2340 { 2357 2341 SrcOverlayCKey = VBoxVHWAColorKey(pCmd->SurfInfo.SrcOverlayCK.high, pCmd->SurfInfo.SrcOverlayCK.low); … … 2363 2347 bNoPBO = true; 2364 2348 bPrimary = true; 2365 VBoxVHWASurfaceBase * 2349 VBoxVHWASurfaceBase *pVga = vgaSurface(); 2366 2350 #ifdef VBOX_WITH_WDDM 2367 2351 uchar * addr = vboxVRAMAddressFromOffset(pCmd->SurfInfo.offSurface); … … 2376 2360 2377 2361 reportedFormat = VBoxVHWAColorFormat(pCmd->SurfInfo.PixelFormat.c.rgbBitCount, 2378 pCmd->SurfInfo.PixelFormat.m1.rgbRBitMask,2379 pCmd->SurfInfo.PixelFormat.m2.rgbGBitMask,2380 pCmd->SurfInfo.PixelFormat.m3.rgbBBitMask);2362 pCmd->SurfInfo.PixelFormat.m1.rgbRBitMask, 2363 pCmd->SurfInfo.PixelFormat.m2.rgbGBitMask, 2364 pCmd->SurfInfo.PixelFormat.m3.rgbBBitMask); 2381 2365 2382 2366 if (pVga->handle() == VBOXVHWA_SURFHANDLE_INVALID … … 2384 2368 { 2385 2369 Assert(pCmd->SurfInfo.PixelFormat.flags & VBOXVHWA_PF_RGB); 2386 // if (pCmd->SurfInfo.PixelFormat.flags & VBOXVHWA_PF_RGB)2370 // if (pCmd->SurfInfo.PixelFormat.flags & VBOXVHWA_PF_RGB) 2387 2371 { 2388 2372 Assert(pCmd->SurfInfo.width == pVga->width()); 2389 2373 Assert(pCmd->SurfInfo.height == pVga->height()); 2390 // if (pCmd->SurfInfo.width == pVga->width()2374 // if (pCmd->SurfInfo.width == pVga->width() 2391 2375 // && pCmd->SurfInfo.height == pVga->height()) 2392 2376 { 2393 2377 // the assert below is incorrect in case the Framebuffer is working in "not using VRAM" mode 2394 2378 // Assert(pVga->pixelFormat().equals(format)); 2395 // if (pVga->pixelFormat().equals(format))2379 // if (pVga->pixelFormat().equals(format)) 2396 2380 { 2397 2381 surf = pVga; … … 2411 2395 } 2412 2396 } 2413 else if (pCmd->SurfInfo.surfCaps & VBOXVHWA_SCAPS_OFFSCREENPLAIN)2397 else if (pCmd->SurfInfo.surfCaps & VBOXVHWA_SCAPS_OFFSCREENPLAIN) 2414 2398 { 2415 2399 bNoPBO = true; 2416 2400 } 2417 2401 2418 if (!surf)2402 if (!surf) 2419 2403 { 2420 2404 VBOXVHWAIMG_TYPE fFlags = 0; 2421 if (!bNoPBO)2405 if (!bNoPBO) 2422 2406 { 2423 2407 fFlags |= VBOXVHWAIMG_PBO | VBOXVHWAIMG_PBOIMG | VBOXVHWAIMG_LINEAR; 2424 if (mSettings->isStretchLinearEnabled())2408 if (mSettings->isStretchLinearEnabled()) 2425 2409 fFlags |= VBOXVHWAIMG_FBO; 2426 2410 } … … 2433 2417 else if (pCmd->SurfInfo.PixelFormat.flags & VBOXVHWA_PF_RGB) 2434 2418 format = VBoxVHWAColorFormat(pCmd->SurfInfo.PixelFormat.c.rgbBitCount, 2435 2436 2437 2419 pCmd->SurfInfo.PixelFormat.m1.rgbRBitMask, 2420 pCmd->SurfInfo.PixelFormat.m2.rgbGBitMask, 2421 pCmd->SurfInfo.PixelFormat.m3.rgbBBitMask); 2438 2422 else if (pCmd->SurfInfo.PixelFormat.flags & VBOXVHWA_PF_FOURCC) 2439 2423 format = VBoxVHWAColorFormat(pCmd->SurfInfo.PixelFormat.fourCC); 2440 2424 else 2441 Assert Breakpoint();2425 AssertFailed(); 2442 2426 2443 2427 if (format.isValid()) 2444 2428 { 2445 2429 surf = new VBoxVHWASurfaceBase(this, 2446 surfSize,2447 primaryRect,2448 QRect(0, 0, surfSize.width(), surfSize.height()),2449 mViewport,2450 format,2451 pSrcBltCKey, pDstBltCKey, pSrcOverlayCKey, pDstOverlayCKey,2430 surfSize, 2431 primaryRect, 2432 QRect(0, 0, surfSize.width(), surfSize.height()), 2433 mViewport, 2434 format, 2435 pSrcBltCKey, pDstBltCKey, pSrcOverlayCKey, pDstOverlayCKey, 2452 2436 #ifdef VBOXVHWA_USE_TEXGROUP 2453 0,2454 #endif 2455 fFlags);2437 0, 2438 #endif 2439 fFlags); 2456 2440 } 2457 2441 else 2458 2442 { 2459 Assert Breakpoint();2443 AssertFailed(); 2460 2444 VBOXQGLLOG_EXIT(("pSurf (0x%p)\n",surf)); 2461 2445 return VERR_GENERAL_FAILURE; 2462 2446 } 2463 2447 2464 uchar * 2448 uchar *addr = vboxVRAMAddressFromOffset(pCmd->SurfInfo.offSurface); 2465 2449 surf->init(mDisplay.getPrimary(), addr); 2466 2450 2467 if (pCmd->SurfInfo.surfCaps & VBOXVHWA_SCAPS_OVERLAY)2451 if (pCmd->SurfInfo.surfCaps & VBOXVHWA_SCAPS_OVERLAY) 2468 2452 { 2469 2453 #ifdef DEBUG_misha … … 2471 2455 #endif 2472 2456 2473 if (!mConstructingList)2457 if (!mConstructingList) 2474 2458 { 2475 2459 mConstructingList = new VBoxVHWASurfList(); … … 2480 2464 mConstructingList->add(surf); 2481 2465 mcRemaining2Contruct--; 2482 if(!mcRemaining2Contruct) 2483 { 2466 if (!mcRemaining2Contruct) 2484 2467 mConstructingList = NULL; 2485 }2486 2468 } 2487 2469 else … … 2494 2476 Assert(pCmd->SurfInfo.surfCaps & VBOXVHWA_SCAPS_VISIBLE); 2495 2477 #endif 2496 if (bPrimary)2478 if (bPrimary) 2497 2479 { 2498 2480 Assert(surf->getComplexList() == mDisplay.getVGA()->getComplexList()); … … 2503 2485 } 2504 2486 else 2505 {2506 2487 Assert(pCmd->SurfInfo.surfCaps & VBOXVHWA_SCAPS_PRIMARYSURFACE); 2507 }2508 2488 2509 2489 Assert(mDisplay.getVGA() == mDisplay.getPrimary()); … … 2530 2510 } 2531 2511 2532 if (handle != VBOXVHWA_SURFHANDLE_INVALID)2512 if (handle != VBOXVHWA_SURFHANDLE_INVALID) 2533 2513 { 2534 2514 bool bSuccess = mSurfHandleTable.mapPut(handle, surf); 2535 2515 Assert(bSuccess); 2536 if (!bSuccess)2516 if (!bSuccess) 2537 2517 { 2538 2518 /** @todo this is very bad, should not be here */ … … 2570 2550 format = VBoxVHWAColorFormat(pCmd->SurfInfo.PixelFormat.fourCC); 2571 2551 else 2572 Assert Breakpoint();2552 AssertFailed(); 2573 2553 2574 2554 Assert(format.isValid()); … … 2584 2564 } 2585 2565 #endif 2566 2586 2567 int VBoxVHWAImage::vhwaSurfaceDestroy(struct VBOXVHWACMD_SURF_DESTROY RT_UNTRUSTED_VOLATILE_GUEST *pCmd) 2587 2568 { … … 2591 2572 2592 2573 VBOXQGLLOG_ENTER(("pSurf (0x%x)\n",pSurf)); 2593 if (pList != mDisplay.getVGA()->getComplexList())2574 if (pList != mDisplay.getVGA()->getComplexList()) 2594 2575 { 2595 2576 Assert(pList); 2596 2577 pList->remove(pSurf); 2597 if (pList->surfaces().empty())2578 if (pList->surfaces().empty()) 2598 2579 { 2599 2580 mDisplay.removeOverlay(pList); 2600 if (pList == mConstructingList)2581 if (pList == mConstructingList) 2601 2582 { 2602 2583 mConstructingList = NULL; … … 2612 2593 Assert(pList); 2613 2594 Assert(pList->size() >= 1); 2614 if (pList->size() > 1)2615 { 2616 if (pSurf == mDisplay.getVGA())2595 if (pList->size() > 1) 2596 { 2597 if (pSurf == mDisplay.getVGA()) 2617 2598 { 2618 2599 const SurfList & surfaces = pList->surfaces(); … … 2650 2631 } 2651 2632 2652 #define VBOXVHWA_CONSTRUCT_QRECT_FROM_RECTL_RB( _pr) \2653 QRect((_pr)->left,\2654 (_pr)->top,\2655 (_pr)->right - (_pr)->left + 1,\2656 (_pr)->bottom - (_pr)->top + 1)2657 2658 #define VBOXVHWA_CONSTRUCT_QRECT_FROM_RECTL_WH( _pr) \2659 QRect((_pr)->left,\2660 (_pr)->top,\2661 (_pr)->right - (_pr)->left,\2662 (_pr)->bottom - (_pr)->top)2633 #define VBOXVHWA_CONSTRUCT_QRECT_FROM_RECTL_RB(a_pr) \ 2634 QRect((a_pr)->left, \ 2635 (a_pr)->top, \ 2636 (a_pr)->right - (a_pr)->left + 1, \ 2637 (a_pr)->bottom - (a_pr)->top + 1) 2638 2639 #define VBOXVHWA_CONSTRUCT_QRECT_FROM_RECTL_WH(a_pr) \ 2640 QRect((a_pr)->left, \ 2641 (a_pr)->top, \ 2642 (a_pr)->right - (a_pr)->left, \ 2643 (a_pr)->bottom - (a_pr)->top) 2663 2644 2664 2645 int VBoxVHWAImage::vhwaSurfaceLock(struct VBOXVHWACMD_SURF_LOCK RT_UNTRUSTED_VOLATILE_GUEST *pCmd) … … 2682 2663 * other surfaces receive unlock only once becoming visible, e.g. on DdFlip 2683 2664 * Ensure this is so*/ 2684 if (pSurf != mDisplay.getPrimary())2665 if (pSurf != mDisplay.getPrimary()) 2685 2666 { 2686 2667 const OverlayList & overlays = mDisplay.overlays(); 2687 2668 bool bFound = false; 2688 2669 2689 if (!mDisplay.isPrimary(pSurf))2670 if (!mDisplay.isPrimary(pSurf)) 2690 2671 { 2691 2672 for (OverlayList::const_iterator it = overlays.begin(); … … 2693 2674 { 2694 2675 VBoxVHWASurfList * pSurfList = *it; 2695 if (pSurfList->current() == pSurf)2676 if (pSurfList->current() == pSurf) 2696 2677 { 2697 2678 bFound = true; … … 2707 2688 #endif 2708 2689 VBOXQGLLOG_ENTER(("pSurf (0x%x)\n",pSurf)); 2709 if (pCmd->u.in.xUpdatedMemValid)2690 if (pCmd->u.in.xUpdatedMemValid) 2710 2691 { 2711 2692 QRect r = VBOXVHWA_CONSTRUCT_QRECT_FROM_RECTL_WH(&pCmd->u.in.xUpdatedMemRect); … … 2730 2711 vboxCheckUpdateAddress (pTargSurf, pCmd->u.in.offTargSurface); 2731 2712 2732 if (pCmd->u.in.xUpdatedTargMemValid)2713 if (pCmd->u.in.xUpdatedTargMemValid) 2733 2714 { 2734 2715 QRect r = VBOXVHWA_CONSTRUCT_QRECT_FROM_RECTL_WH(&pCmd->u.in.xUpdatedTargMemRect); … … 2755 2736 struct VBOXVHWACMD_SURF_OVERLAY_UPDATE RT_UNTRUSTED_VOLATILE_GUEST *pCmd) 2756 2737 { 2757 if (pCmd->u.in.flags & VBOXVHWA_OVER_KEYDEST)2738 if (pCmd->u.in.flags & VBOXVHWA_OVER_KEYDEST) 2758 2739 { 2759 2740 VBOXQGLLOG((", KEYDEST")); … … 2767 2748 pSrcSurf->setOverriddenDstOverlayCKey(NULL); 2768 2749 } 2769 else if (pCmd->u.in.flags & VBOXVHWA_OVER_KEYDESTOVERRIDE)2750 else if (pCmd->u.in.flags & VBOXVHWA_OVER_KEYDESTOVERRIDE) 2770 2751 { 2771 2752 VBOXQGLLOG((", KEYDESTOVERRIDE")); … … 2799 2780 } 2800 2781 2801 if (pCmd->u.in.flags & VBOXVHWA_OVER_KEYSRC)2782 if (pCmd->u.in.flags & VBOXVHWA_OVER_KEYSRC) 2802 2783 { 2803 2784 VBOXQGLLOG((", KEYSRC")); 2804 2785 pSrcSurf->resetDefaultSrcOverlayCKey(); 2805 2786 } 2806 else if (pCmd->u.in.flags & VBOXVHWA_OVER_KEYSRCOVERRIDE)2787 else if (pCmd->u.in.flags & VBOXVHWA_OVER_KEYSRCOVERRIDE) 2807 2788 { 2808 2789 VBOXQGLLOG((", KEYSRCOVERRIDE")); … … 2816 2797 } 2817 2798 VBOXQGLLOG(("\n")); 2818 if (pDstSurf)2799 if (pDstSurf) 2819 2800 { 2820 2801 QRect dstRect = VBOXVHWA_CONSTRUCT_QRECT_FROM_RECTL_WH(&pCmd->u.in.dstRect); … … 2841 2822 VBoxVHWASurfaceBase *pDstSurf = NULL; 2842 2823 2843 if (pCmd->u.in.hDstSurf)2824 if (pCmd->u.in.hDstSurf) 2844 2825 { 2845 2826 pDstSurf = handle2Surface(pCmd->u.in.hDstSurf); … … 2852 2833 Assert(pDstSurf->getComplexList() == mDisplay.getVGA()->getComplexList()); 2853 2834 2854 if (pCmd->u.in.flags & VBOXVHWA_OVER_SHOW)2855 { 2856 if (pDstSurf != mDisplay.getPrimary())2835 if (pCmd->u.in.flags & VBOXVHWA_OVER_SHOW) 2836 { 2837 if (pDstSurf != mDisplay.getPrimary()) 2857 2838 { 2858 2839 mDisplay.updateVGA(pDstSurf); … … 2863 2844 2864 2845 #ifdef VBOX_WITH_WDDM 2865 if (pCmd->u.in.xFlags & VBOXVHWACMD_SURF_OVERLAY_UPDATE_F_SRCMEMRECT)2846 if (pCmd->u.in.xFlags & VBOXVHWACMD_SURF_OVERLAY_UPDATE_F_SRCMEMRECT) 2866 2847 { 2867 2848 QRect r = VBOXVHWA_CONSTRUCT_QRECT_FROM_RECTL_WH(&pCmd->u.in.xUpdatedSrcMemRect); 2868 2849 pSrcSurf->updatedMem(&r); 2869 2850 } 2870 if (pCmd->u.in.xFlags & VBOXVHWACMD_SURF_OVERLAY_UPDATE_F_DSTMEMRECT)2851 if (pCmd->u.in.xFlags & VBOXVHWACMD_SURF_OVERLAY_UPDATE_F_DSTMEMRECT) 2871 2852 { 2872 2853 QRect r = VBOXVHWA_CONSTRUCT_QRECT_FROM_RECTL_WH(&pCmd->u.in.xUpdatedDstMemRect); … … 2884 2865 } 2885 2866 2886 if (pCmd->u.in.flags & VBOXVHWA_OVER_HIDE)2867 if (pCmd->u.in.flags & VBOXVHWA_OVER_HIDE) 2887 2868 { 2888 2869 VBOXQGLLOG(("hide\n")); 2889 2870 pList->setCurrentVisible(NULL); 2890 2871 } 2891 else if (pCmd->u.in.flags & VBOXVHWA_OVER_SHOW)2872 else if (pCmd->u.in.flags & VBOXVHWA_OVER_SHOW) 2892 2873 { 2893 2874 VBOXQGLLOG(("show\n")); … … 2944 2925 { 2945 2926 VBoxVHWASurfaceBase *pSurf = handle2Surface(pCmd->u.in.hSurf); 2946 2947 VBOXQGLLOG_ENTER(("pSurf (0x%x)\n",pSurf)); 2927 VBOXQGLLOG_ENTER(("pSurf (0x%x)\n", pSurf)); 2948 2928 2949 2929 vboxCheckUpdateAddress (pSurf, pCmd->u.in.offSurface); … … 2981 2961 bool bEnabled = false; 2982 2962 const VBoxVHWAInfo & info = vboxVHWAGetSupportInfo(NULL); 2983 if (info.isVHWASupported())2963 if (info.isVHWASupported()) 2984 2964 { 2985 2965 Assert(pCmd->u.in.guestVersion.maj == VBOXVHWA_VERSION_MAJ); 2986 if (pCmd->u.in.guestVersion.maj == VBOXVHWA_VERSION_MAJ)2966 if (pCmd->u.in.guestVersion.maj == VBOXVHWA_VERSION_MAJ) 2987 2967 { 2988 2968 Assert(pCmd->u.in.guestVersion.min == VBOXVHWA_VERSION_MIN); 2989 if (pCmd->u.in.guestVersion.min == VBOXVHWA_VERSION_MIN)2969 if (pCmd->u.in.guestVersion.min == VBOXVHWA_VERSION_MIN) 2990 2970 { 2991 2971 Assert(pCmd->u.in.guestVersion.bld == VBOXVHWA_VERSION_BLD); 2992 if (pCmd->u.in.guestVersion.bld == VBOXVHWA_VERSION_BLD)2972 if (pCmd->u.in.guestVersion.bld == VBOXVHWA_VERSION_BLD) 2993 2973 { 2994 2974 Assert(pCmd->u.in.guestVersion.reserved == VBOXVHWA_VERSION_RSV); 2995 if (pCmd->u.in.guestVersion.reserved == VBOXVHWA_VERSION_RSV)2975 if (pCmd->u.in.guestVersion.reserved == VBOXVHWA_VERSION_RSV) 2996 2976 { 2997 2977 bEnabled = true; … … 3012 2992 // | VBOXVHWA_CAPS_BLTCOLORFILL not supported, although adding it is trivial 3013 2993 // | VBOXVHWA_CAPS_BLTFOURCC set below if shader support is available 3014 3015 3016 2994 VBOXVHWA_CAPS_OVERLAY 2995 | VBOXVHWA_CAPS_OVERLAYSTRETCH 2996 | VBOXVHWA_CAPS_OVERLAYCANTCLIP 3017 2997 // | VBOXVHWA_CAPS_OVERLAYFOURCC set below if shader support is available 3018 2998 ; 3019 2999 3020 3000 /** @todo check if we could use DDSCAPS_ALPHA instead of colorkeying */ … … 3030 3010 pCmd->u.out.curOverlays = 0; 3031 3011 3032 pCmd->u.out.surfaceCaps = 3033 VBOXVHWA_SCAPS_PRIMARYSURFACE 3012 pCmd->u.out.surfaceCaps = VBOXVHWA_SCAPS_PRIMARYSURFACE 3034 3013 #ifndef VBOXVHWA_ALLOW_PRIMARY_AND_OVERLAY_ONLY 3035 | VBOXVHWA_SCAPS_OFFSCREENPLAIN3036 #endif 3037 | VBOXVHWA_SCAPS_FLIP3038 | VBOXVHWA_SCAPS_LOCALVIDMEM3039 | VBOXVHWA_SCAPS_OVERLAY3040 // | VBOXVHWA_SCAPS_BACKBUFFER3041 // | VBOXVHWA_SCAPS_FRONTBUFFER3042 // | VBOXVHWA_SCAPS_VIDEOMEMORY3043 // | VBOXVHWA_SCAPS_COMPLEX3044 // | VBOXVHWA_SCAPS_VISIBLE3045 ;3046 3047 if (info.getGlInfo().isFragmentShaderSupported() && info.getGlInfo().getMultiTexNumSupported() >= 2)3014 | VBOXVHWA_SCAPS_OFFSCREENPLAIN 3015 #endif 3016 | VBOXVHWA_SCAPS_FLIP 3017 | VBOXVHWA_SCAPS_LOCALVIDMEM 3018 | VBOXVHWA_SCAPS_OVERLAY 3019 // | VBOXVHWA_SCAPS_BACKBUFFER 3020 // | VBOXVHWA_SCAPS_FRONTBUFFER 3021 // | VBOXVHWA_SCAPS_VIDEOMEMORY 3022 // | VBOXVHWA_SCAPS_COMPLEX 3023 // | VBOXVHWA_SCAPS_VISIBLE 3024 ; 3025 3026 if (info.getGlInfo().isFragmentShaderSupported() && info.getGlInfo().getMultiTexNumSupported() >= 2) 3048 3027 { 3049 3028 pCmd->u.out.caps |= VBOXVHWA_CAPS_COLORKEY 3050 | VBOXVHWA_CAPS_COLORKEYHWASSIST 3051 ; 3052 3053 pCmd->u.out.colorKeyCaps = 3054 // VBOXVHWA_CKEYCAPS_DESTBLT | VBOXVHWA_CKEYCAPS_DESTBLTCLRSPACE | VBOXVHWA_CKEYCAPS_SRCBLT| VBOXVHWA_CKEYCAPS_SRCBLTCLRSPACE | 3055 // VBOXVHWA_CKEYCAPS_SRCOVERLAY | VBOXVHWA_CKEYCAPS_SRCOVERLAYONEACTIVE | 3056 VBOXVHWA_CKEYCAPS_DESTOVERLAY | 3057 VBOXVHWA_CKEYCAPS_DESTOVERLAYONEACTIVE; 3058 ; 3059 3060 if(info.getGlInfo().isTextureRectangleSupported()) 3029 | VBOXVHWA_CAPS_COLORKEYHWASSIST; 3030 3031 pCmd->u.out.colorKeyCaps = 0 3032 // | VBOXVHWA_CKEYCAPS_DESTBLT | VBOXVHWA_CKEYCAPS_DESTBLTCLRSPACE 3033 // | VBOXVHWA_CKEYCAPS_SRCBLT| VBOXVHWA_CKEYCAPS_SRCBLTCLRSPACE 3034 // | VBOXVHWA_CKEYCAPS_SRCOVERLAY | VBOXVHWA_CKEYCAPS_SRCOVERLAYONEACTIVE 3035 | VBOXVHWA_CKEYCAPS_DESTOVERLAY 3036 | VBOXVHWA_CKEYCAPS_DESTOVERLAYONEACTIVE; 3037 3038 if (info.getGlInfo().isTextureRectangleSupported()) 3061 3039 { 3062 3040 pCmd->u.out.caps |= VBOXVHWA_CAPS_OVERLAYFOURCC 3063 // | VBOXVHWA_CAPS_BLTFOURCC 3064 ; 3065 3066 pCmd->u.out.colorKeyCaps |= 3067 // VBOXVHWA_CKEYCAPS_SRCOVERLAYYUV | 3068 VBOXVHWA_CKEYCAPS_DESTOVERLAYYUV; 3041 // | VBOXVHWA_CAPS_BLTFOURCC 3069 3042 ; 3043 3044 pCmd->u.out.colorKeyCaps |= 0 3045 // | VBOXVHWA_CKEYCAPS_SRCOVERLAYYUV 3046 | VBOXVHWA_CKEYCAPS_DESTOVERLAYYUV; 3070 3047 3071 3048 // pCmd->u.out.caps2 |= VBOXVHWA_CAPS2_COPYFOURCC; … … 3083 3060 VBOXQGLLOG_ENTER(("\n")); 3084 3061 3085 const VBoxVHWAInfo & 3062 const VBoxVHWAInfo &info = vboxVHWAGetSupportInfo(NULL); 3086 3063 uint32_t aFourcc[VBOXVHWA_NUMFOURCC]; 3087 3064 int num = mSettings->getIntersection(info, VBOXVHWA_NUMFOURCC, aFourcc); 3088 3065 Assert(pCmd->numFourCC >= (uint32_t)num); 3089 if (pCmd->numFourCC < (uint32_t)num)3066 if (pCmd->numFourCC < (uint32_t)num) 3090 3067 return VERR_GENERAL_FAILURE; 3091 3068 3092 3069 pCmd->numFourCC = (uint32_t)num; 3093 memcpy((void *) pCmd->FourCC, aFourcc, num * sizeof(aFourcc[0]));3070 memcpy((void *)&pCmd->FourCC[0], aFourcc, num * sizeof(aFourcc[0])); 3094 3071 return VINF_SUCCESS; 3095 3072 } … … 3108 3085 //} 3109 3086 3110 int VBoxVHWAImage::vhwaSaveSurface(struct SSMHANDLE * 3087 int VBoxVHWAImage::vhwaSaveSurface(struct SSMHANDLE *pSSM, VBoxVHWASurfaceBase *pSurf, uint32_t surfCaps) 3111 3088 { 3112 3089 VBOXQGL_SAVE_SURFSTART(pSSM); … … 3114 3091 uint64_t u64 = vboxVRAMOffset(pSurf); 3115 3092 int rc; 3116 rc = SSMR3PutU32(pSSM, pSurf->handle()); AssertRC(rc); 3117 rc = SSMR3PutU64(pSSM, u64); AssertRC(rc); 3118 rc = SSMR3PutU32(pSSM, pSurf->width()); AssertRC(rc); 3119 rc = SSMR3PutU32(pSSM, pSurf->height()); AssertRC(rc); 3120 rc = SSMR3PutU32(pSSM, surfCaps); AssertRC(rc); 3093 rc = SSMR3PutU32(pSSM, pSurf->handle()); 3094 rc = SSMR3PutU64(pSSM, u64); 3095 rc = SSMR3PutU32(pSSM, pSurf->width()); 3096 rc = SSMR3PutU32(pSSM, pSurf->height()); 3097 rc = SSMR3PutU32(pSSM, surfCaps); 3098 3121 3099 uint32_t flags = 0; 3122 const VBoxVHWAColorKey * pDstBltCKey = pSurf->dstBltCKey(); 3123 const VBoxVHWAColorKey * pSrcBltCKey = pSurf->srcBltCKey(); 3124 const VBoxVHWAColorKey * pDstOverlayCKey = pSurf->dstOverlayCKey(); 3125 const VBoxVHWAColorKey * pSrcOverlayCKey = pSurf->srcOverlayCKey(); 3126 if(pDstBltCKey) 3127 { 3100 const VBoxVHWAColorKey *pDstBltCKey = pSurf->dstBltCKey(); 3101 const VBoxVHWAColorKey *pSrcBltCKey = pSurf->srcBltCKey(); 3102 const VBoxVHWAColorKey *pDstOverlayCKey = pSurf->dstOverlayCKey(); 3103 const VBoxVHWAColorKey *pSrcOverlayCKey = pSurf->srcOverlayCKey(); 3104 if (pDstBltCKey) 3128 3105 flags |= VBOXVHWA_SD_CKDESTBLT; 3129 } 3130 if(pSrcBltCKey) 3131 { 3106 if (pSrcBltCKey) 3132 3107 flags |= VBOXVHWA_SD_CKSRCBLT; 3133 } 3134 if(pDstOverlayCKey) 3135 { 3108 if (pDstOverlayCKey) 3136 3109 flags |= VBOXVHWA_SD_CKDESTOVERLAY; 3137 } 3138 if(pSrcOverlayCKey) 3139 { 3110 if (pSrcOverlayCKey) 3140 3111 flags |= VBOXVHWA_SD_CKSRCOVERLAY; 3141 }3142 3143 rc = SSMR3PutU32(pSSM, flags); AssertRC(rc);3144 if(pDstBltCKey)3145 {3146 rc = SSMR3PutU32(pSSM, pDstBltCKey-> lower()); AssertRC(rc);3147 rc = SSMR3PutU32(pSSM, pDstBltCKey->upper()); AssertRC(rc);3148 }3149 if(pSrcBltCKey)3150 {3151 rc = SSMR3PutU32(pSSM, pSrcBltCKey-> lower()); AssertRC(rc);3152 rc = SSMR3PutU32(pSSM, pSrcBltCKey->upper()); AssertRC(rc);3153 }3154 if(pDstOverlayCKey)3155 {3156 rc = SSMR3PutU32(pSSM, pDstOverlayCKey-> lower()); AssertRC(rc);3157 rc = SSMR3PutU32(pSSM, pDstOverlayCKey->upper()); AssertRC(rc);3158 }3159 if(pSrcOverlayCKey)3160 {3161 rc = SSMR3PutU32(pSSM, pSrcOverlayCKey-> lower()); AssertRC(rc);3162 rc = SSMR3PutU32(pSSM, pSrcOverlayCKey->upper()); AssertRC(rc);3163 }3112 rc = SSMR3PutU32(pSSM, flags); 3113 3114 if (pDstBltCKey) 3115 { 3116 rc = SSMR3PutU32(pSSM, pDstBltCKey->lower()); 3117 rc = SSMR3PutU32(pSSM, pDstBltCKey->upper()); 3118 } 3119 if (pSrcBltCKey) 3120 { 3121 rc = SSMR3PutU32(pSSM, pSrcBltCKey->lower()); 3122 rc = SSMR3PutU32(pSSM, pSrcBltCKey->upper()); 3123 } 3124 if (pDstOverlayCKey) 3125 { 3126 rc = SSMR3PutU32(pSSM, pDstOverlayCKey->lower()); 3127 rc = SSMR3PutU32(pSSM, pDstOverlayCKey->upper()); 3128 } 3129 if (pSrcOverlayCKey) 3130 { 3131 rc = SSMR3PutU32(pSSM, pSrcOverlayCKey->lower()); 3132 rc = SSMR3PutU32(pSSM, pSrcOverlayCKey->upper()); 3133 } 3134 AssertRCReturn(rc, rc); 3164 3135 3165 3136 const VBoxVHWAColorFormat & format = pSurf->pixelFormat(); 3166 3137 flags = 0; 3167 if (format.fourcc())3138 if (format.fourcc()) 3168 3139 { 3169 3140 flags |= VBOXVHWA_PF_FOURCC; 3170 rc = SSMR3PutU32(pSSM, flags); AssertRC(rc);3171 rc = SSMR3PutU32(pSSM, format.fourcc()); AssertRC(rc);3141 rc = SSMR3PutU32(pSSM, flags); 3142 rc = SSMR3PutU32(pSSM, format.fourcc()); 3172 3143 } 3173 3144 else 3174 3145 { 3175 3146 flags |= VBOXVHWA_PF_RGB; 3176 rc = SSMR3PutU32(pSSM, flags); AssertRC(rc); 3177 rc = SSMR3PutU32(pSSM, format.bitsPerPixel()); AssertRC(rc); 3178 rc = SSMR3PutU32(pSSM, format.r().mask()); AssertRC(rc); 3179 rc = SSMR3PutU32(pSSM, format.g().mask()); AssertRC(rc); 3180 rc = SSMR3PutU32(pSSM, format.b().mask()); AssertRC(rc); 3181 rc = SSMR3PutU32(pSSM, format.a().mask()); AssertRC(rc); 3182 } 3147 rc = SSMR3PutU32(pSSM, flags); 3148 rc = SSMR3PutU32(pSSM, format.bitsPerPixel()); 3149 rc = SSMR3PutU32(pSSM, format.r().mask()); 3150 rc = SSMR3PutU32(pSSM, format.g().mask()); 3151 rc = SSMR3PutU32(pSSM, format.b().mask()); 3152 rc = SSMR3PutU32(pSSM, format.a().mask()); 3153 } 3154 AssertRCReturn(rc, rc); 3183 3155 3184 3156 VBOXQGL_SAVE_SURFSTOP(pSSM); 3185 3186 3157 return rc; 3187 3158 } … … 3204 3175 rc = SSMR3GetU32(pSSM, &u32); AssertRC(rc); 3205 3176 pCreateSurf->SurfInfo.hSurf = (VBOXVHWA_SURFHANDLE)u32; 3206 if(RT_SUCCESS(rc)) 3207 { 3208 rc = SSMR3GetU64(pSSM, &pCreateSurf->SurfInfo.offSurface); AssertRC(rc); 3209 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.width); AssertRC(rc); 3210 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.height); AssertRC(rc); 3211 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.surfCaps); AssertRC(rc); 3212 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.flags); AssertRC(rc); 3213 if(pCreateSurf->SurfInfo.flags & VBOXVHWA_SD_CKDESTBLT) 3214 { 3215 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.DstBltCK.low); AssertRC(rc); 3216 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.DstBltCK.high); AssertRC(rc); 3217 } 3218 if(pCreateSurf->SurfInfo.flags & VBOXVHWA_SD_CKSRCBLT) 3219 { 3220 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.SrcBltCK.low); AssertRC(rc); 3221 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.SrcBltCK.high); AssertRC(rc); 3222 } 3223 if(pCreateSurf->SurfInfo.flags & VBOXVHWA_SD_CKDESTOVERLAY) 3224 { 3225 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.DstOverlayCK.low); AssertRC(rc); 3226 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.DstOverlayCK.high); AssertRC(rc); 3227 } 3228 if(pCreateSurf->SurfInfo.flags & VBOXVHWA_SD_CKSRCOVERLAY) 3229 { 3230 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.SrcOverlayCK.low); AssertRC(rc); 3231 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.SrcOverlayCK.high); AssertRC(rc); 3232 } 3233 3234 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.PixelFormat.flags); AssertRC(rc); 3235 if(pCreateSurf->SurfInfo.PixelFormat.flags & VBOXVHWA_PF_RGB) 3236 { 3237 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.PixelFormat.c.rgbBitCount); AssertRC(rc); 3238 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.PixelFormat.m1.rgbRBitMask); AssertRC(rc); 3239 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.PixelFormat.m2.rgbGBitMask); AssertRC(rc); 3240 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.PixelFormat.m3.rgbBBitMask); AssertRC(rc); 3241 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.PixelFormat.m4.rgbABitMask); AssertRC(rc); 3242 } 3243 else if(pCreateSurf->SurfInfo.PixelFormat.flags & VBOXVHWA_PF_FOURCC) 3244 { 3245 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.PixelFormat.fourCC); AssertRC(rc); 3177 if (RT_SUCCESS(rc)) 3178 { 3179 rc = SSMR3GetU64(pSSM, &pCreateSurf->SurfInfo.offSurface); AssertRC(rc); 3180 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.width); AssertRC(rc); 3181 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.height); AssertRC(rc); 3182 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.surfCaps); AssertRC(rc); 3183 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.flags); AssertRC(rc); 3184 if (pCreateSurf->SurfInfo.flags & VBOXVHWA_SD_CKDESTBLT) 3185 { 3186 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.DstBltCK.low); AssertRC(rc); 3187 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.DstBltCK.high); AssertRC(rc); 3188 } 3189 if (pCreateSurf->SurfInfo.flags & VBOXVHWA_SD_CKSRCBLT) 3190 { 3191 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.SrcBltCK.low); AssertRC(rc); 3192 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.SrcBltCK.high); AssertRC(rc); 3193 } 3194 if (pCreateSurf->SurfInfo.flags & VBOXVHWA_SD_CKDESTOVERLAY) 3195 { 3196 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.DstOverlayCK.low); AssertRC(rc); 3197 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.DstOverlayCK.high); AssertRC(rc); 3198 } 3199 if (pCreateSurf->SurfInfo.flags & VBOXVHWA_SD_CKSRCOVERLAY) 3200 { 3201 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.SrcOverlayCK.low); AssertRC(rc); 3202 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.SrcOverlayCK.high); AssertRC(rc); 3203 } 3204 3205 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.PixelFormat.flags); AssertRC(rc); 3206 if (pCreateSurf->SurfInfo.PixelFormat.flags & VBOXVHWA_PF_RGB) 3207 { 3208 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.PixelFormat.c.rgbBitCount); AssertRC(rc); 3209 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.PixelFormat.m1.rgbRBitMask); AssertRC(rc); 3210 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.PixelFormat.m2.rgbGBitMask); AssertRC(rc); 3211 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.PixelFormat.m3.rgbBBitMask); AssertRC(rc); 3212 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.PixelFormat.m4.rgbABitMask); AssertRC(rc); 3213 } 3214 else if (pCreateSurf->SurfInfo.PixelFormat.flags & VBOXVHWA_PF_FOURCC) 3215 { 3216 rc = SSMR3GetU32(pSSM, &pCreateSurf->SurfInfo.PixelFormat.fourCC); 3217 AssertRC(rc); 3246 3218 } 3247 3219 else … … 3249 3221 AssertFailed(); 3250 3222 } 3251 3252 if(cBackBuffers) 3223 AssertRCReturnStmt(rc, free(buf), rc); 3224 3225 if (cBackBuffers) 3253 3226 { 3254 3227 pCreateSurf->SurfInfo.cBackBuffers = cBackBuffers; … … 3258 3231 pCmdList->push_back(pCmd); 3259 3232 // vboxExecOnResize(&VBoxVHWAImage::vboxDoVHWACmdAndFree, pCmd); AssertRC(rc); 3260 // if (RT_SUCCESS(rc))3233 // if (RT_SUCCESS(rc)) 3261 3234 // { 3262 3235 // rc = pCmd->rc; … … 3284 3257 bool bSaveSrcCKey = false; 3285 3258 3286 if (bVisible)3259 if (bVisible) 3287 3260 { 3288 3261 flags |= VBOXVHWA_OVER_SHOW; … … 3293 3266 } 3294 3267 3295 if (!dstCKey)3268 if (!dstCKey) 3296 3269 { 3297 3270 flags |= VBOXVHWA_OVER_KEYDEST; 3298 3271 } 3299 else if (defaultDstCKey)3272 else if (defaultDstCKey) 3300 3273 { 3301 3274 flags |= VBOXVHWA_OVER_KEYDESTOVERRIDE; … … 3303 3276 } 3304 3277 3305 if (srcCKey == defaultSrcCKey)3278 if (srcCKey == defaultSrcCKey) 3306 3279 { 3307 3280 flags |= VBOXVHWA_OVER_KEYSRC; 3308 3281 } 3309 else if (srcCKey)3282 else if (srcCKey) 3310 3283 { 3311 3284 flags |= VBOXVHWA_OVER_KEYSRCOVERRIDE; … … 3313 3286 } 3314 3287 3315 int rc = SSMR3PutU32(pSSM, flags); AssertRC(rc);3316 3317 rc = SSMR3PutU32(pSSM, mDisplay.getPrimary()->handle()); AssertRC(rc);3318 rc = SSMR3PutU32(pSSM, pSurf->handle()); AssertRC(rc);3319 3320 if (bSaveDstCKey)3321 { 3322 rc = SSMR3PutU32(pSSM, dstCKey->lower()); AssertRC(rc);3323 rc = SSMR3PutU32(pSSM, dstCKey->upper()); AssertRC(rc);3324 } 3325 if (bSaveSrcCKey)3326 { 3327 rc = SSMR3PutU32(pSSM, srcCKey->lower()); AssertRC(rc);3328 rc = SSMR3PutU32(pSSM, srcCKey->upper()); AssertRC(rc);3288 int rc = SSMR3PutU32(pSSM, flags); 3289 3290 rc = SSMR3PutU32(pSSM, mDisplay.getPrimary()->handle()); 3291 rc = SSMR3PutU32(pSSM, pSurf->handle()); 3292 3293 if (bSaveDstCKey) 3294 { 3295 rc = SSMR3PutU32(pSSM, dstCKey->lower()); 3296 rc = SSMR3PutU32(pSSM, dstCKey->upper()); 3297 } 3298 if (bSaveSrcCKey) 3299 { 3300 rc = SSMR3PutU32(pSSM, srcCKey->lower()); 3301 rc = SSMR3PutU32(pSSM, srcCKey->upper()); 3329 3302 } 3330 3303 3331 3304 int x1, x2, y1, y2; 3332 3305 pSurf->targRect().getCoords(&x1, &y1, &x2, &y2); 3333 rc = SSMR3PutS32(pSSM, x1); AssertRC(rc);3334 rc = SSMR3PutS32(pSSM, x2+1); AssertRC(rc);3335 rc = SSMR3PutS32(pSSM, y1); AssertRC(rc);3336 rc = SSMR3PutS32(pSSM, y2+1); AssertRC(rc);3306 rc = SSMR3PutS32(pSSM, x1); 3307 rc = SSMR3PutS32(pSSM, x2+1); 3308 rc = SSMR3PutS32(pSSM, y1); 3309 rc = SSMR3PutS32(pSSM, y2+1); 3337 3310 3338 3311 pSurf->srcRect().getCoords(&x1, &y1, &x2, &y2); 3339 rc = SSMR3PutS32(pSSM, x1); AssertRC(rc); 3340 rc = SSMR3PutS32(pSSM, x2+1); AssertRC(rc); 3341 rc = SSMR3PutS32(pSSM, y1); AssertRC(rc); 3342 rc = SSMR3PutS32(pSSM, y2+1); AssertRC(rc); 3312 rc = SSMR3PutS32(pSSM, x1); 3313 rc = SSMR3PutS32(pSSM, x2+1); 3314 rc = SSMR3PutS32(pSSM, y1); 3315 rc = SSMR3PutS32(pSSM, y2+1); 3316 AssertRCReturn(rc, rc); 3343 3317 3344 3318 VBOXQGL_SAVE_OVERLAYSTOP(pSSM); … … 3372 3346 pUpdateOverlay->u.in.offSrcSurface = VBOXVHWA_OFFSET64_VOID; 3373 3347 3374 if (pUpdateOverlay->u.in.flags & VBOXVHWA_OVER_KEYDESTOVERRIDE)3375 { 3376 rc = SSMR3GetU32(pSSM, &pUpdateOverlay->u.in.desc.DstCK.low); AssertRC(rc);3348 if (pUpdateOverlay->u.in.flags & VBOXVHWA_OVER_KEYDESTOVERRIDE) 3349 { 3350 rc = SSMR3GetU32(pSSM, &pUpdateOverlay->u.in.desc.DstCK.low); AssertRC(rc); 3377 3351 rc = SSMR3GetU32(pSSM, &pUpdateOverlay->u.in.desc.DstCK.high); AssertRC(rc); 3378 3352 } 3379 3353 3380 if (pUpdateOverlay->u.in.flags & VBOXVHWA_OVER_KEYSRCOVERRIDE)3381 { 3382 rc = SSMR3GetU32(pSSM, &pUpdateOverlay->u.in.desc.SrcCK.low); AssertRC(rc);3354 if (pUpdateOverlay->u.in.flags & VBOXVHWA_OVER_KEYSRCOVERRIDE) 3355 { 3356 rc = SSMR3GetU32(pSSM, &pUpdateOverlay->u.in.desc.SrcCK.low); AssertRC(rc); 3383 3357 rc = SSMR3GetU32(pSSM, &pUpdateOverlay->u.in.desc.SrcCK.high); AssertRC(rc); 3384 3358 } 3385 3359 3386 rc = SSMR3GetS32(pSSM, &pUpdateOverlay->u.in.dstRect.left); AssertRC(rc);3387 rc = SSMR3GetS32(pSSM, &pUpdateOverlay->u.in.dstRect.right); AssertRC(rc);3388 rc = SSMR3GetS32(pSSM, &pUpdateOverlay->u.in.dstRect.top); AssertRC(rc);3360 rc = SSMR3GetS32(pSSM, &pUpdateOverlay->u.in.dstRect.left); AssertRC(rc); 3361 rc = SSMR3GetS32(pSSM, &pUpdateOverlay->u.in.dstRect.right); AssertRC(rc); 3362 rc = SSMR3GetS32(pSSM, &pUpdateOverlay->u.in.dstRect.top); AssertRC(rc); 3389 3363 rc = SSMR3GetS32(pSSM, &pUpdateOverlay->u.in.dstRect.bottom); AssertRC(rc); 3390 3364 3391 rc = SSMR3GetS32(pSSM, &pUpdateOverlay->u.in.srcRect.left); AssertRC(rc); 3392 rc = SSMR3GetS32(pSSM, &pUpdateOverlay->u.in.srcRect.right); AssertRC(rc); 3393 rc = SSMR3GetS32(pSSM, &pUpdateOverlay->u.in.srcRect.top); AssertRC(rc); 3394 rc = SSMR3GetS32(pSSM, &pUpdateOverlay->u.in.srcRect.bottom); AssertRC(rc); 3365 rc = SSMR3GetS32(pSSM, &pUpdateOverlay->u.in.srcRect.left); AssertRC(rc); 3366 rc = SSMR3GetS32(pSSM, &pUpdateOverlay->u.in.srcRect.right); AssertRC(rc); 3367 rc = SSMR3GetS32(pSSM, &pUpdateOverlay->u.in.srcRect.top); AssertRC(rc); 3368 rc = SSMR3GetS32(pSSM, &pUpdateOverlay->u.in.srcRect.bottom); 3369 AssertRCReturnStmt(rc, free(buf), rc); 3395 3370 3396 3371 pCmdList->push_back(pCmd); … … 3402 3377 } 3403 3378 3404 void VBoxVHWAImage::vhwaSaveExecVoid(struct SSMHANDLE * 3379 void VBoxVHWAImage::vhwaSaveExecVoid(struct SSMHANDLE *pSSM) 3405 3380 { 3406 3381 VBOXQGL_SAVE_START(pSSM); 3407 int rc = SSMR3PutU32(pSSM, 0); AssertRC(rc); /* 0 primaries */3382 SSMR3PutU32(pSSM, 0); /* 0 primaries */ 3408 3383 VBOXQGL_SAVE_STOP(pSSM); 3409 3384 } 3410 3385 3411 void VBoxVHWAImage::vhwaSaveExec(struct SSMHANDLE * 3386 void VBoxVHWAImage::vhwaSaveExec(struct SSMHANDLE *pSSM) 3412 3387 { 3413 3388 VBOXQGL_SAVE_START(pSSM); … … 3432 3407 const SurfList & primaryList = mDisplay.primaries().surfaces(); 3433 3408 uint32_t cPrimary = (uint32_t)primaryList.size(); 3434 if (cPrimary &&3409 if (cPrimary && 3435 3410 (mDisplay.getVGA() == NULL || mDisplay.getVGA()->handle() == VBOXVHWA_SURFHANDLE_INVALID)) 3436 3411 { … … 3438 3413 } 3439 3414 3440 int rc = SSMR3PutU32(pSSM, cPrimary); AssertRC(rc); 3441 if(cPrimary) 3442 { 3443 for (SurfList::const_iterator pr = primaryList.begin(); 3444 pr != primaryList.end(); ++ pr) 3415 int rc = SSMR3PutU32(pSSM, cPrimary); 3416 if (cPrimary) 3417 { 3418 for (SurfList::const_iterator pr = primaryList.begin(); pr != primaryList.end(); ++ pr) 3445 3419 { 3446 3420 VBoxVHWASurfaceBase *pSurf = *pr; … … 3448 3422 bool bVisible = (pSurf == mDisplay.getPrimary()); 3449 3423 uint32_t flags = VBOXVHWA_SCAPS_PRIMARYSURFACE; 3450 if (bVisible)3424 if (bVisible) 3451 3425 flags |= VBOXVHWA_SCAPS_VISIBLE; 3452 3426 3453 if (pSurf->handle() != VBOXVHWA_SURFHANDLE_INVALID)3427 if (pSurf->handle() != VBOXVHWA_SURFHANDLE_INVALID) 3454 3428 { 3455 rc = vhwaSaveSurface(pSSM, *pr, flags); AssertRC(rc);3429 rc = vhwaSaveSurface(pSSM, *pr, flags); 3456 3430 #ifdef DEBUG 3457 3431 --cPrimary; … … 3470 3444 3471 3445 const OverlayList & overlays = mDisplay.overlays(); 3472 rc = SSMR3PutU32(pSSM, (uint32_t)overlays.size()); AssertRC(rc); 3473 3474 for (OverlayList::const_iterator it = overlays.begin(); 3475 it != overlays.end(); ++ it) 3446 rc = SSMR3PutU32(pSSM, (uint32_t)overlays.size()); 3447 3448 for (OverlayList::const_iterator it = overlays.begin(); it != overlays.end(); ++ it) 3476 3449 { 3477 3450 VBoxVHWASurfList * pSurfList = *it; … … 3479 3452 uint32_t cSurfs = (uint32_t)surfaces.size(); 3480 3453 uint32_t flags = VBOXVHWA_SCAPS_OVERLAY; 3481 if (cSurfs > 1)3454 if (cSurfs > 1) 3482 3455 flags |= VBOXVHWA_SCAPS_COMPLEX; 3483 rc = SSMR3PutU32(pSSM, cSurfs); AssertRC(rc); 3484 for (SurfList::const_iterator sit = surfaces.begin(); 3485 sit != surfaces.end(); ++ sit) 3486 { 3487 rc = vhwaSaveSurface(pSSM, *sit, flags); AssertRC(rc); 3488 } 3456 rc = SSMR3PutU32(pSSM, cSurfs); 3457 for (SurfList::const_iterator sit = surfaces.begin(); sit != surfaces.end(); ++ sit) 3458 rc = vhwaSaveSurface(pSSM, *sit, flags); 3489 3459 3490 3460 bool bVisible = true; 3491 3461 VBoxVHWASurfaceBase * pOverlayData = pSurfList->current(); 3492 if (!pOverlayData)3462 if (!pOverlayData) 3493 3463 { 3494 3464 pOverlayData = surfaces.front(); … … 3496 3466 } 3497 3467 3498 rc = vhwaSaveOverlayData(pSSM, pOverlayData, bVisible); AssertRC(rc);3468 rc = vhwaSaveOverlayData(pSSM, pOverlayData, bVisible); 3499 3469 } 3500 3470 } … … 3505 3475 int VBoxVHWAImage::vhwaLoadVHWAEnable(VHWACommandList * pCmdList) 3506 3476 { 3507 char *buf = (char *)malloc(sizeof(VBOXVHWACMD));3477 char *buf = (char *)malloc(sizeof(VBOXVHWACMD)); 3508 3478 Assert(buf); 3509 if (buf)3479 if (buf) 3510 3480 { 3511 3481 memset(buf, 0, sizeof(VBOXVHWACMD)); … … 3524 3494 VBOXQGL_LOAD_START(pSSM); 3525 3495 3526 if (u32Version > VBOXQGL_STATE_VERSION)3496 if (u32Version > VBOXQGL_STATE_VERSION) 3527 3497 return VERR_VERSION_MISMATCH; 3528 3498 … … 3531 3501 3532 3502 rc = vhwaLoadVHWAEnable(pCmdList); AssertRC(rc); 3533 if (RT_SUCCESS(rc))3503 if (RT_SUCCESS(rc)) 3534 3504 { 3535 3505 rc = SSMR3GetU32(pSSM, &u32); AssertRC(rc); 3536 if (RT_SUCCESS(rc))3537 { 3538 if (u32Version == 1U && u32 == (~0U)) /* work around the v1 bug */3506 if (RT_SUCCESS(rc)) 3507 { 3508 if (u32Version == 1U && u32 == UINT32_MAX) /* work around the v1 bug */ 3539 3509 u32 = 0; 3540 if (u32)3510 if (u32) 3541 3511 { 3542 for (uint32_t i = 0; i < u32; ++i)3512 for (uint32_t i = 0; i < u32; ++i) 3543 3513 { 3544 rc = vhwaLoadSurface(pCmdList, pSSM, 0, u32Version); AssertRC(rc); 3545 if(RT_FAILURE(rc)) 3546 break; 3514 rc = vhwaLoadSurface(pCmdList, pSSM, 0, u32Version); 3515 AssertRCBreak(rc); 3547 3516 } 3548 3517 3549 if (RT_SUCCESS(rc))3518 if (RT_SUCCESS(rc)) 3550 3519 { 3551 3520 rc = SSMR3GetU32(pSSM, &u32); AssertRC(rc); 3552 if (RT_SUCCESS(rc))3521 if (RT_SUCCESS(rc)) 3553 3522 { 3554 for (uint32_t i = 0; i < u32; ++i)3523 for (uint32_t i = 0; i < u32; ++i) 3555 3524 { 3556 3525 uint32_t cSurfs; 3557 3526 rc = SSMR3GetU32(pSSM, &cSurfs); AssertRC(rc); 3558 for (uint32_t j = 0; j < cSurfs; ++j)3527 for (uint32_t j = 0; j < cSurfs; ++j) 3559 3528 { 3560 rc = vhwaLoadSurface(pCmdList, pSSM, cSurfs - 1, u32Version); AssertRC(rc); 3561 if(RT_FAILURE(rc)) 3562 break; 3529 rc = vhwaLoadSurface(pCmdList, pSSM, cSurfs - 1, u32Version); 3530 AssertRCBreak(rc); 3563 3531 } 3564 3532 3565 if (RT_SUCCESS(rc))3533 if (RT_SUCCESS(rc)) 3566 3534 { 3567 rc = vhwaLoadOverlayData(pCmdList, pSSM, u32Version); AssertRC(rc); 3535 rc = vhwaLoadOverlayData(pCmdList, pSSM, u32Version); 3536 AssertRCBreak(rc); 3568 3537 } 3569 3570 if(RT_FAILURE(rc)) 3571 { 3538 else 3572 3539 break; 3573 }3574 3540 } 3575 3541 } … … 3577 3543 } 3578 3544 #ifdef VBOXQGL_STATE_DEBUG 3579 else if (u32Version == 1) /* read the 0 overlay count to ensure the following VBOXQGL_LOAD_STOP succeeds */3545 else if (u32Version == 1) /* read the 0 overlay count to ensure the following VBOXQGL_LOAD_STOP succeeds */ 3580 3546 { 3581 rc = SSMR3GetU32(pSSM, &u32); AssertRC(rc); 3582 Assert(u32 == 0); 3547 rc = SSMR3GetU32(pSSM, &u32); 3548 AssertRC(rc); 3549 Assert(u32 == 0 || RT_FAILURE(rc)); 3583 3550 } 3584 3551 #endif … … 3623 3590 } 3624 3591 3625 uchar * 3592 uchar *VBoxVHWAImage::vboxVRAMAddressFromOffset(uint64_t offset) 3626 3593 { 3627 3594 /** @todo check vramSize() */ 3628 return (offset != VBOXVHWA_OFFSET64_VOID) ? ((uint8_t *)vramBase()) + offset : NULL;3629 } 3630 3631 uint64_t VBoxVHWAImage::vboxVRAMOffsetFromAddress(uchar *addr)3632 { 3633 return uint64_t(addr - ((uchar *)vramBase()));3634 } 3635 3636 uint64_t VBoxVHWAImage::vboxVRAMOffset(VBoxVHWASurfaceBase * 3595 return (offset != VBOXVHWA_OFFSET64_VOID) ? ((uint8_t *)vramBase()) + offset : NULL; 3596 } 3597 3598 uint64_t VBoxVHWAImage::vboxVRAMOffsetFromAddress(uchar *addr) 3599 { 3600 return uint64_t(addr - ((uchar *)vramBase())); 3601 } 3602 3603 uint64_t VBoxVHWAImage::vboxVRAMOffset(VBoxVHWASurfaceBase *pSurf) 3637 3604 { 3638 3605 return pSurf->addressAlocated() ? VBOXVHWA_OFFSET64_VOID : vboxVRAMOffsetFromAddress(pSurf->address()); … … 3644 3611 3645 3612 int g_iCur = 0; 3646 VBoxVHWASurfaceBase * 3647 3648 void VBoxVHWAImage::vboxDoTestSurfaces(void *context)3649 { 3650 if (g_iCur >= RT_ELEMENTS(g_apSurf))3613 VBoxVHWASurfaceBase *g_apSurf[] = {NULL, NULL, NULL}; 3614 3615 void VBoxVHWAImage::vboxDoTestSurfaces(void *context) 3616 { 3617 if (g_iCur >= RT_ELEMENTS(g_apSurf)) 3651 3618 g_iCur = 0; 3652 3619 VBoxVHWASurfaceBase * pSurf1 = g_apSurf[g_iCur]; 3653 if(pSurf1) 3654 { 3620 if (pSurf1) 3655 3621 pSurf1->getComplexList()->setCurrentVisible(pSurf1); 3656 }3657 3622 } 3658 3623 #endif … … 3663 3628 mViewport = aRect; 3664 3629 3665 const SurfList & primaryList = mDisplay.primaries().surfaces(); 3666 3667 for (SurfList::const_iterator pr = primaryList.begin(); 3668 pr != primaryList.end(); ++ pr) 3630 const SurfList &primaryList = mDisplay.primaries().surfaces(); 3631 3632 for (SurfList::const_iterator pr = primaryList.begin(); pr != primaryList.end(); ++pr) 3669 3633 { 3670 3634 VBoxVHWASurfaceBase *pSurf = *pr; … … 3678 3642 bool bDisplayPrimary = true; 3679 3643 3680 for (OverlayList::const_iterator it = overlays.begin(); 3681 it != overlays.end(); ++ it) 3682 { 3683 VBoxVHWASurfList * pSurfList = *it; 3684 const SurfList & surfaces = pSurfList->surfaces(); 3685 if(surfaces.size()) 3644 for (OverlayList::const_iterator it = overlays.begin(); it != overlays.end(); ++it) 3645 { 3646 VBoxVHWASurfList *pSurfList = *it; 3647 const SurfList &surfaces = pSurfList->surfaces(); 3648 if (surfaces.size()) 3686 3649 { 3687 3650 bool bNotIntersected = !overInter.isEmpty() && surfaces.front()->targRect().contains(overInter); … … 3716 3679 bool VBoxVHWAImage::hasVisibleOverlays() 3717 3680 { 3718 const OverlayList & overlays = mDisplay.overlays(); 3719 for (OverlayList::const_iterator it = overlays.begin(); 3720 it != overlays.end(); ++ it) 3681 const OverlayList &overlays = mDisplay.overlays(); 3682 for (OverlayList::const_iterator it = overlays.begin(); it != overlays.end(); ++ it) 3721 3683 { 3722 3684 VBoxVHWASurfList * pSurfList = *it; 3723 if (pSurfList->current() != NULL)3685 if (pSurfList->current() != NULL) 3724 3686 return true; 3725 3687 } … … 3729 3691 QRect VBoxVHWAImage::overlaysRectUnion() 3730 3692 { 3731 const OverlayList & 3693 const OverlayList &overlays = mDisplay.overlays(); 3732 3694 VBoxVHWADirtyRect un; 3733 for (OverlayList::const_iterator it = overlays.begin(); 3734 it != overlays.end(); ++ it) 3735 { 3736 VBoxVHWASurfaceBase * pOverlay = (*it)->current(); 3737 if(pOverlay != NULL) 3738 { 3695 for (OverlayList::const_iterator it = overlays.begin(); it != overlays.end(); ++ it) 3696 { 3697 VBoxVHWASurfaceBase *pOverlay = (*it)->current(); 3698 if (pOverlay != NULL) 3739 3699 un.add(pOverlay->targRect()); 3740 }3741 3700 } 3742 3701 return un.toRect(); … … 3745 3704 QRect VBoxVHWAImage::overlaysRectIntersection() 3746 3705 { 3747 const OverlayList & 3706 const OverlayList &overlays = mDisplay.overlays(); 3748 3707 QRect rect; 3749 3708 VBoxVHWADirtyRect un; 3750 for (OverlayList::const_iterator it = overlays.begin(); 3751 it != overlays.end(); ++ it) 3752 { 3753 VBoxVHWASurfaceBase * pOverlay = (*it)->current(); 3754 if(pOverlay != NULL) 3755 { 3756 if(rect.isNull()) 3757 { 3709 for (OverlayList::const_iterator it = overlays.begin(); it != overlays.end(); ++ it) 3710 { 3711 VBoxVHWASurfaceBase *pOverlay = (*it)->current(); 3712 if (pOverlay != NULL) 3713 { 3714 if (rect.isNull()) 3758 3715 rect = pOverlay->targRect(); 3759 }3760 3716 else 3761 3717 { 3762 3718 rect = rect.intersected(pOverlay->targRect()); 3763 if (rect.isNull())3719 if (rect.isNull()) 3764 3720 break; 3765 3721 } … … 3769 3725 } 3770 3726 3771 void VBoxVHWAImage::vboxDoUpdateRect(const QRect * 3727 void VBoxVHWAImage::vboxDoUpdateRect(const QRect *pRect) 3772 3728 { 3773 3729 mDisplay.getPrimary()->updatedMem(pRect); 3774 3730 } 3775 3731 3776 void VBoxVHWAImage::resize(const VBoxFBSizeInfo & 3732 void VBoxVHWAImage::resize(const VBoxFBSizeInfo &size) 3777 3733 { 3778 3734 VBOXQGL_CHECKERR( … … 3860 3816 else 3861 3817 { 3862 Assert Breakpoint();3818 AssertFailed(); 3863 3819 fallback = true; 3864 3820 } … … 3867 3823 { 3868 3824 /* we should never come to fallback more now */ 3869 Assert Breakpoint();3825 AssertFailed(); 3870 3826 /* we don't support either the pixel format or the color depth, 3871 3827 * fallback to a self-provided 32bpp RGB buffer */ … … 3878 3834 } 3879 3835 3880 ulong bytesPerPixel = bitsPerPixel /8;3836 ulong bytesPerPixel = bitsPerPixel / 8; 3881 3837 const QSize scaledSize = size.scaledSize(); 3882 3838 const ulong displayWidth = scaledSize.isValid() ? scaledSize.width() : bytesPerLine / bytesPerPixel; … … 3884 3840 3885 3841 #ifdef VBOXQGL_DBG_SURF 3886 for (int i = 0; i < RT_ELEMENTS(g_apSurf); i++)3842 for (int i = 0; i < RT_ELEMENTS(g_apSurf); i++) 3887 3843 { 3888 3844 VBoxVHWASurfaceBase * pSurf1 = g_apSurf[i]; 3889 if (pSurf1)3845 if (pSurf1) 3890 3846 { 3891 3847 VBoxVHWASurfList *pConstructingList = pSurf1->getComplexList(); 3892 3848 delete pSurf1; 3893 if (pConstructingList)3849 if (pConstructingList) 3894 3850 delete pConstructingList; 3895 3851 } … … 3897 3853 #endif 3898 3854 3899 VBoxVHWASurfaceBase * 3900 if (pDisplay)3855 VBoxVHWASurfaceBase *pDisplay = mDisplay.setVGA(NULL); 3856 if (pDisplay) 3901 3857 delete pDisplay; 3902 3858 … … 3905 3861 QRect dispRect(0, 0, displayWidth, displayHeight); 3906 3862 pDisplay = new VBoxVHWASurfaceBase(this, 3907 dispSize, 3908 dispRect, 3909 dispRect, 3910 dispRect, /* we do not know viewport at the stage of precise, set as a disp rect, it will be updated on repaint */ 3911 format, 3912 (VBoxVHWAColorKey*)NULL, (VBoxVHWAColorKey*)NULL, (VBoxVHWAColorKey*)NULL, (VBoxVHWAColorKey*)NULL, 3863 dispSize, 3864 dispRect, 3865 dispRect, 3866 dispRect, /* we do not know viewport at the stage of precise, set as a 3867 disp rect, it will be updated on repaint */ 3868 format, 3869 NULL, NULL, NULL, NULL, 3913 3870 #ifdef VBOXVHWA_USE_TEXGROUP 3914 0,3915 #endif 3916 0 /* VBOXVHWAIMG_TYPE fFlags */);3871 0, 3872 #endif 3873 0 /* VBOXVHWAIMG_TYPE fFlags */); 3917 3874 pDisplay->init(NULL, fUsesGuestVram ? size.VRAM() : NULL); 3918 3875 mDisplay.setVGA(pDisplay); … … 3927 3884 uint32_t height = 60; 3928 3885 3929 for (int i = 0; i < RT_ELEMENTS(g_apSurf); i++)3886 for (int i = 0; i < RT_ELEMENTS(g_apSurf); i++) 3930 3887 { 3931 3888 VBoxVHWAColorFormat tmpFormat(FOURCC_YV12); 3932 3889 QSize tmpSize(width, height) ; 3933 3890 VBoxVHWASurfaceBase *pSurf1 = new VBoxVHWASurfaceBase(this, tmpSize, 3934 mDisplay.getPrimary()->rect(),3935 QRect(0, 0, width, height),3936 mViewport,3937 tmpFormat,3938 NULL, NULL, NULL, &VBoxVHWAColorKey(0,0),3891 mDisplay.getPrimary()->rect(), 3892 QRect(0, 0, width, height), 3893 mViewport, 3894 tmpFormat, 3895 NULL, NULL, NULL, &VBoxVHWAColorKey(0,0), 3939 3896 #ifdef VBOXVHWA_USE_TEXGROUP 3940 0,3941 #endif 3942 false);3897 0, 3898 #endif 3899 false); 3943 3900 3944 3901 Assert(mDisplay.getVGA()); … … 3946 3903 uchar *addr = pSurf1->address(); 3947 3904 uchar cur = 0; 3948 for (uint32_t k = 0; k < width*height; k++)3905 for (uint32_t k = 0; k < width*height; k++) 3949 3906 { 3950 3907 addr[k] = cur; … … 3964 3921 updateCmd.u.in.hSrcSurf = (VBOXVHWA_SURFHANDLE)g_apSurf[0]; 3965 3922 updateCmd.u.in.hDstSurf = (VBOXVHWA_SURFHANDLE)pDisplay; 3966 updateCmd.u.in.flags = 3967 VBOXVHWA_OVER_SHOW 3968 | VBOXVHWA_OVER_KEYDESTOVERRIDE; 3923 updateCmd.u.in.flags = VBOXVHWA_OVER_SHOW 3924 | VBOXVHWA_OVER_KEYDESTOVERRIDE; 3969 3925 3970 3926 updateCmd.u.in.desc.DstCK.high = 1; … … 3973 3929 updateCmd.u.in.dstRect.left = 0; 3974 3930 updateCmd.u.in.dstRect.right = pDisplay->width(); 3975 updateCmd.u.in.dstRect.top = (pDisplay->height() - height) /2;3931 updateCmd.u.in.dstRect.top = (pDisplay->height() - height) / 2; 3976 3932 updateCmd.u.in.dstRect.bottom = updateCmd.u.in.dstRect.top + height; 3977 3933 … … 3988 3944 #endif 3989 3945 3990 // if (!mOnResizeCmdList.empty())3946 // if (!mOnResizeCmdList.empty()) 3991 3947 // { 3992 3948 // for (VHWACommandList::const_iterator it = mOnResizeCmdList.begin(); … … 4006 3962 } 4007 3963 4008 VBoxVHWAColorFormat::VBoxVHWAColorFormat (uint32_t bitsPerPixel, uint32_t r, uint32_t g, uint32_t b) :4009 mWidthCompression (1),4010 mHeightCompression(1)4011 { 4012 init 4013 } 4014 4015 VBoxVHWAColorFormat::VBoxVHWAColorFormat (uint32_t fourcc) :4016 mWidthCompression (1),4017 mHeightCompression(1)4018 { 4019 init 4020 } 4021 4022 void VBoxVHWAColorFormat::init 3964 VBoxVHWAColorFormat::VBoxVHWAColorFormat (uint32_t bitsPerPixel, uint32_t r, uint32_t g, uint32_t b) 3965 : mWidthCompression(1) 3966 , mHeightCompression(1) 3967 { 3968 init(bitsPerPixel, r, g, b); 3969 } 3970 3971 VBoxVHWAColorFormat::VBoxVHWAColorFormat(uint32_t fourcc) 3972 : mWidthCompression(1) 3973 , mHeightCompression(1) 3974 { 3975 init(fourcc); 3976 } 3977 3978 void VBoxVHWAColorFormat::init(uint32_t fourcc) 4023 3979 { 4024 3980 mDataFormat = fourcc; … … 4026 3982 mFormat = GL_BGRA_EXT;//GL_RGBA; 4027 3983 mType = GL_UNSIGNED_BYTE; 4028 mR = VBoxVHWAColorComponent 4029 mG = VBoxVHWAColorComponent 4030 mB = VBoxVHWAColorComponent 4031 mA = VBoxVHWAColorComponent 3984 mR = VBoxVHWAColorComponent(0xff); 3985 mG = VBoxVHWAColorComponent(0xff); 3986 mB = VBoxVHWAColorComponent(0xff); 3987 mA = VBoxVHWAColorComponent(0xff); 4032 3988 mBitsPerPixelTex = 32; 4033 3989 … … 4056 4012 } 4057 4013 4058 void VBoxVHWAColorFormat::init 4014 void VBoxVHWAColorFormat::init(uint32_t bitsPerPixel, uint32_t r, uint32_t g, uint32_t b) 4059 4015 { 4060 4016 mBitsPerPixel = bitsPerPixel; … … 4067 4023 mFormat = GL_BGRA_EXT;//GL_RGBA; 4068 4024 mType = GL_UNSIGNED_BYTE; 4069 mR = VBoxVHWAColorComponent 4070 mG = VBoxVHWAColorComponent 4071 mB = VBoxVHWAColorComponent 4025 mR = VBoxVHWAColorComponent(r); 4026 mG = VBoxVHWAColorComponent(g); 4027 mB = VBoxVHWAColorComponent(b); 4072 4028 break; 4073 4029 case 24: … … 4078 4034 mFormat = GL_BGR_EXT; 4079 4035 mType = GL_UNSIGNED_BYTE; 4080 mR = VBoxVHWAColorComponent 4081 mG = VBoxVHWAColorComponent 4082 mB = VBoxVHWAColorComponent 4036 mR = VBoxVHWAColorComponent(r); 4037 mG = VBoxVHWAColorComponent(g); 4038 mB = VBoxVHWAColorComponent(b); 4083 4039 break; 4084 4040 case 16: … … 4088 4044 mInternalFormat = GL_RGB5; 4089 4045 mFormat = GL_BGR_EXT; 4090 mType = GL_UNSIGNED_BYTE; /* TODO"??? */4091 mR = VBoxVHWAColorComponent 4092 mG = VBoxVHWAColorComponent 4093 mB = VBoxVHWAColorComponent 4046 mType = GL_UNSIGNED_BYTE; /** @todo ??? */ 4047 mR = VBoxVHWAColorComponent(r); 4048 mG = VBoxVHWAColorComponent(g); 4049 mB = VBoxVHWAColorComponent(b); 4094 4050 break; 4095 4051 case 8: … … 4100 4056 mFormat = GL_RED;//GL_RGB; 4101 4057 mType = GL_UNSIGNED_BYTE; 4102 mR = VBoxVHWAColorComponent 4058 mR = VBoxVHWAColorComponent(0xff); 4103 4059 break; 4104 4060 case 1: … … 4109 4065 mFormat = GL_COLOR_INDEX; 4110 4066 mType = GL_BITMAP; 4111 mR = VBoxVHWAColorComponent 4067 mR = VBoxVHWAColorComponent(0x1); 4112 4068 break; 4113 4069 default: … … 4121 4077 } 4122 4078 4123 bool VBoxVHWAColorFormat::equals (const VBoxVHWAColorFormat &other) const4124 { 4125 if (fourcc())4079 bool VBoxVHWAColorFormat::equals(const VBoxVHWAColorFormat &other) const 4080 { 4081 if (fourcc()) 4126 4082 return fourcc() == other.fourcc(); 4127 if (other.fourcc())4083 if (other.fourcc()) 4128 4084 return false; 4129 4085 … … 4133 4089 VBoxVHWAColorComponent::VBoxVHWAColorComponent (uint32_t aMask) 4134 4090 { 4135 unsigned f = ASMBitFirstSetU32 4136 if (f)4091 unsigned f = ASMBitFirstSetU32(aMask); 4092 if (f) 4137 4093 { 4138 4094 mOffset = f - 1; 4139 f = ASMBitFirstSetU32 (~(aMask >> mOffset)); 4140 if(f) 4141 { 4095 f = ASMBitFirstSetU32(~(aMask >> mOffset)); 4096 if (f) 4142 4097 mcBits = f - 1; 4143 }4144 4098 else 4145 {4146 4099 mcBits = 32 - mOffset; 4147 } 4148 4149 Assert (mcBits); 4100 4101 Assert(mcBits); 4150 4102 mMask = (((uint32_t)0xffffffff) >> (32 - mcBits)) << mOffset; 4151 Assert 4103 Assert(mMask == aMask); 4152 4104 4153 4105 mRange = (mMask >> mOffset) + 1; … … 4162 4114 } 4163 4115 4164 void VBoxVHWAColorFormat::pixel2Normalized 4165 { 4166 *r = mR.colorValNorm 4167 *g = mG.colorValNorm 4168 *b = mB.colorValNorm 4169 } 4170 4171 VBoxQGLOverlay::VBoxQGLOverlay 4172 : mpOverlayWgt (NULL),4173 mpViewport (NULL),4174 mGlOn (false),4175 mOverlayWidgetVisible (false),4176 mOverlayVisible (false),4177 mGlCurrent (false),4178 mProcessingCommands (false),4179 mNeedOverlayRepaint (false),4180 mNeedSetVisible (false),4181 mCmdPipe (),4182 mSettings (),4183 mpSession(),4184 mpShareWgt (NULL),4185 4116 void VBoxVHWAColorFormat::pixel2Normalized(uint32_t pix, float *r, float *g, float *b) const 4117 { 4118 *r = mR.colorValNorm(pix); 4119 *g = mG.colorValNorm(pix); 4120 *b = mB.colorValNorm(pix); 4121 } 4122 4123 VBoxQGLOverlay::VBoxQGLOverlay() 4124 : mpOverlayWgt(NULL) 4125 , mpViewport(NULL) 4126 , mGlOn(false) 4127 , mOverlayWidgetVisible(false) 4128 , mOverlayVisible(false) 4129 , mGlCurrent(false) 4130 , mProcessingCommands(false) 4131 , mNeedOverlayRepaint(false) 4132 , mNeedSetVisible(false) 4133 , mCmdPipe() 4134 , mSettings() 4135 , mpSession() 4136 , mpShareWgt(NULL) 4137 , m_id(0) 4186 4138 { 4187 4139 /* postpone the gl widget initialization to avoid conflict with 3D on Mac */ 4188 4140 } 4189 4141 4190 void VBoxQGLOverlay::init(QWidget *pViewport, QObject *pPostEventObject, CSession *aSession, uint32_t id)4142 void VBoxQGLOverlay::init(QWidget *pViewport, QObject *pPostEventObject, CSession *aSession, uint32_t id) 4191 4143 { 4192 4144 mpViewport = pViewport; … … 4200 4152 { 4201 4153 public: 4202 VBoxGLShareWgt() :4203 QGLWidget(new VBoxGLContext(VBoxVHWAImage::vboxGLFormat()))4154 VBoxGLShareWgt() 4155 : QGLWidget(new VBoxGLContext(VBoxVHWAImage::vboxGLFormat())) 4204 4156 { 4205 4157 /* work-around to disable done current needed to old ATI drivers on Linux */ 4206 VBoxGLContext *pc = (VBoxGLContext *)context();4207 pc->allowDoneCurrent 4158 VBoxGLContext *pc = (VBoxGLContext *)context(); 4159 pc->allowDoneCurrent(false); 4208 4160 } 4209 4161 … … 4217 4169 void VBoxQGLOverlay::initGl() 4218 4170 { 4219 if (mpOverlayWgt)4171 if (mpOverlayWgt) 4220 4172 { 4221 4173 Assert(mpShareWgt); … … 4234 4186 4235 4187 mOverlayWidgetVisible = true; /* to ensure it is set hidden with vboxShowOverlay */ 4236 vboxShowOverlay 4237 4238 mpOverlayWgt->setMouseTracking 4188 vboxShowOverlay(false); 4189 4190 mpOverlayWgt->setMouseTracking(true); 4239 4191 } 4240 4192 … … 4273 4225 } 4274 4226 4275 static DECLCALLBACK(void) vbvaVHWAHHCommandFreeCmd(void * pContext)4276 { 4277 free(p Context);4227 static DECLCALLBACK(void) vbvaVHWAHHCommandFreeCmd(void *pvContext) 4228 { 4229 free(pvContext); 4278 4230 } 4279 4231 … … 4285 4237 if (RT_SUCCESS(rc)) 4286 4238 { 4287 for (VHWACommandList::const_iterator sIt = list.begin(); 4288 sIt != list.end(); ++ sIt) 4239 for (VHWACommandList::const_iterator sIt = list.begin(); sIt != list.end(); ++ sIt) 4289 4240 { 4290 4241 VBOXVHWACMD *pCmd = (*sIt); 4291 4242 VBOXVHWA_HH_CALLBACK_SET(pCmd, vbvaVHWAHHCommandFreeCmd, pCmd); 4292 mCmdPipe.postCmd(VBOXVHWA_PIPECMD_VHWA, pCmd );4243 mCmdPipe.postCmd(VBOXVHWA_PIPECMD_VHWA, pCmd, pCmd->enmCmd, false /*fGuestCmd*/); 4293 4244 } 4294 4245 } … … 4296 4247 } 4297 4248 4298 int VBoxQGLOverlay::onVHWACommand(struct VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCmd) 4299 { 4300 Log(("VHWA Command >>> %#p, %d\n", pCmd, pCmd->enmCmd)); 4301 switch(pCmd->enmCmd) 4249 int VBoxQGLOverlay::onVHWACommand(struct VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCmd, 4250 int /*VBOXVHWACMD_TYPE*/ enmCmdInt, bool fGuestCmd) 4251 { 4252 VBOXVHWACMD_TYPE const enmCmd = (VBOXVHWACMD_TYPE)enmCmdInt; 4253 Log(("VHWA Command >>> %#p, %d\n", pCmd, enmCmd)); 4254 switch (enmCmd) 4302 4255 { 4303 4256 case VBOXVHWACMD_TYPE_SURF_FLIP: … … 4307 4260 case VBOXVHWACMD_TYPE_HH_CONSTRUCT: 4308 4261 { 4262 pCmd->Flags &= ~VBOXVHWACMD_FLAG_HG_ASYNCH; 4263 ASSERT_GUEST_STMT_RETURN(!fGuestCmd, pCmd->rc = VERR_ACCESS_DENIED, VINF_SUCCESS); 4309 4264 VBOXVHWACMD_HH_CONSTRUCT *pBody = VBOXVHWACMD_BODY_HOST_HEAP(pCmd, VBOXVHWACMD_HH_CONSTRUCT); 4265 pCmd->rc = vhwaConstruct(pBody); 4266 Log(("VHWA Command <<< Sync %#p, %d\n", pCmd, enmCmd)); 4267 return VINF_SUCCESS; 4268 } 4269 4270 case VBOXVHWACMD_TYPE_HH_RESET: 4271 { 4310 4272 pCmd->Flags &= ~VBOXVHWACMD_FLAG_HG_ASYNCH; 4311 pCmd->rc = vhwaConstruct(pBody); 4312 Log(("VHWA Command <<< Sync %#p, %d\n", pCmd, pCmd->enmCmd)); 4313 return VINF_SUCCESS; 4314 } 4315 case VBOXVHWACMD_TYPE_HH_RESET: 4316 { 4273 ASSERT_GUEST_STMT_RETURN(!fGuestCmd, pCmd->rc = VERR_ACCESS_DENIED, VINF_SUCCESS); 4317 4274 /* we do not post a reset command to the gui thread since this may lead to a deadlock 4318 4275 * when reset is initiated by the gui thread*/ 4319 pCmd->Flags &= ~VBOXVHWACMD_FLAG_HG_ASYNCH;4320 4276 pCmd->rc = reset(); 4321 Log(("VHWA Command <<< Sync %#p, %d\n", pCmd, pCmd->enmCmd));4277 Log(("VHWA Command <<< Sync %#p, %d\n", pCmd, enmCmd)); 4322 4278 return VINF_SUCCESS; 4323 4279 } 4280 4324 4281 case VBOXVHWACMD_TYPE_HH_ENABLE: 4325 4282 pCmd->Flags &= ~VBOXVHWACMD_FLAG_HG_ASYNCH; 4283 ASSERT_GUEST_STMT_RETURN(!fGuestCmd, pCmd->rc = VERR_ACCESS_DENIED, VINF_SUCCESS); 4326 4284 pCmd->rc = VINF_SUCCESS; 4327 Log(("VHWA Command <<< Sync %#p, %d\n", pCmd, pCmd->enmCmd));4285 Log(("VHWA Command <<< Sync %#p, %d\n", pCmd, enmCmd)); 4328 4286 return VINF_SUCCESS; 4287 4329 4288 case VBOXVHWACMD_TYPE_HH_DISABLE: 4330 4289 pCmd->Flags &= ~VBOXVHWACMD_FLAG_HG_ASYNCH; 4290 ASSERT_GUEST_STMT_RETURN(!fGuestCmd, pCmd->rc = VERR_ACCESS_DENIED, VINF_SUCCESS); 4331 4291 pCmd->rc = VINF_SUCCESS; 4332 Log(("VHWA Command <<< Sync %#p, %d\n", pCmd, pCmd->enmCmd));4292 Log(("VHWA Command <<< Sync %#p, %d\n", pCmd, enmCmd)); 4333 4293 return VINF_SUCCESS; 4294 4334 4295 case VBOXVHWACMD_TYPE_HH_SAVESTATE_SAVEBEGIN: 4296 pCmd->Flags &= ~VBOXVHWACMD_FLAG_HG_ASYNCH; 4297 ASSERT_GUEST_STMT_RETURN(!fGuestCmd, pCmd->rc = VERR_ACCESS_DENIED, VINF_SUCCESS); 4335 4298 mCmdPipe.disable(); 4299 pCmd->rc = VINF_SUCCESS; 4300 Log(("VHWA Command <<< Sync %#p, %d\n", pCmd, enmCmd)); 4301 return VINF_SUCCESS; 4302 4303 case VBOXVHWACMD_TYPE_HH_SAVESTATE_SAVEEND: 4304 ASSERT_GUEST_STMT_RETURN(!fGuestCmd, pCmd->rc = VERR_ACCESS_DENIED, VINF_SUCCESS); 4336 4305 pCmd->Flags &= ~VBOXVHWACMD_FLAG_HG_ASYNCH; 4306 mCmdPipe.enable(); 4337 4307 pCmd->rc = VINF_SUCCESS; 4338 Log(("VHWA Command <<< Sync %#p, %d\n", pCmd, pCmd->enmCmd));4308 Log(("VHWA Command <<< Sync %#p, %d\n", pCmd, enmCmd)); 4339 4309 return VINF_SUCCESS; 4340 case VBOXVHWACMD_TYPE_HH_SAVESTATE_SAVEEND: 4341 mCmdPipe.enable(); 4310 4311 case VBOXVHWACMD_TYPE_HH_SAVESTATE_SAVEPERFORM: 4312 { 4342 4313 pCmd->Flags &= ~VBOXVHWACMD_FLAG_HG_ASYNCH; 4343 pCmd->rc = VINF_SUCCESS; 4344 Log(("VHWA Command <<< Sync %#p, %d\n", pCmd, pCmd->enmCmd)); 4345 return VINF_SUCCESS; 4346 case VBOXVHWACMD_TYPE_HH_SAVESTATE_SAVEPERFORM: 4347 { 4314 ASSERT_GUEST_STMT_RETURN(!fGuestCmd, pCmd->rc = VERR_ACCESS_DENIED, VINF_SUCCESS); 4348 4315 VBOXVHWACMD_HH_SAVESTATE_SAVEPERFORM *pSave = VBOXVHWACMD_BODY_HOST_HEAP(pCmd, VBOXVHWACMD_HH_SAVESTATE_SAVEPERFORM); 4349 4316 PSSMHANDLE pSSM = pSave->pSSM; 4350 4317 int rc = SSMR3PutU32(pSSM, VBOXQGL_STATE_VERSION); AssertRC(rc); 4351 4318 if (RT_SUCCESS(rc)) 4352 {4353 4319 vhwaSaveExec(pSSM); 4354 } 4320 pCmd->rc = rc; 4321 Log(("VHWA Command <<< Sync %#p, %d\n", pCmd, enmCmd)); 4322 return VINF_SUCCESS; 4323 } 4324 case VBOXVHWACMD_TYPE_HH_SAVESTATE_LOADPERFORM: 4325 { 4355 4326 pCmd->Flags &= ~VBOXVHWACMD_FLAG_HG_ASYNCH; 4356 pCmd->rc = rc; 4357 Log(("VHWA Command <<< Sync %#p, %d\n", pCmd, pCmd->enmCmd)); 4358 return VINF_SUCCESS; 4359 } 4360 case VBOXVHWACMD_TYPE_HH_SAVESTATE_LOADPERFORM: 4361 { 4327 ASSERT_GUEST_STMT_RETURN(!fGuestCmd, pCmd->rc = VERR_ACCESS_DENIED, VINF_SUCCESS); 4362 4328 VBOXVHWACMD_HH_SAVESTATE_LOADPERFORM *pLoad = VBOXVHWACMD_BODY_HOST_HEAP(pCmd, VBOXVHWACMD_HH_SAVESTATE_LOADPERFORM); 4363 4329 PSSMHANDLE pSSM = pLoad->pSSM; … … 4366 4332 if (RT_SUCCESS(rc)) 4367 4333 { 4368 rc = vhwaLoadExec(pSSM, u32Version); AssertRC(rc); 4334 rc = vhwaLoadExec(pSSM, u32Version); 4335 AssertRC(rc); 4369 4336 } 4370 4337 else … … 4376 4343 rc = VINF_SUCCESS; 4377 4344 } 4378 pCmd->Flags &= ~VBOXVHWACMD_FLAG_HG_ASYNCH;4379 4345 pCmd->rc = rc; 4380 Log(("VHWA Command <<< Sync %#p, %d\n", pCmd, pCmd->enmCmd));4346 Log(("VHWA Command <<< Sync %#p, %d\n", pCmd, enmCmd)); 4381 4347 return VINF_SUCCESS; 4382 4348 } 4349 4383 4350 case VBOXVHWACMD_TYPE_QUERY_INFO1: 4384 4351 { … … 4392 4359 /* do NOT break!! make it proceed asynchronously */ 4393 4360 } 4361 4394 4362 default: 4395 4363 break; 4396 4364 } 4397 4365 4398 Log(("VHWA Command --- Going Async %#p, %d\n", pCmd, pCmd->enmCmd));4366 Log(("VHWA Command --- Going Async %#p, %d\n", pCmd, enmCmd)); 4399 4367 /* indicate that we process and complete the command asynchronously */ 4400 4368 pCmd->Flags |= VBOXVHWACMD_FLAG_HG_ASYNCH; 4401 4369 4402 mCmdPipe.postCmd(VBOXVHWA_PIPECMD_VHWA, (void *)pCmd );4370 mCmdPipe.postCmd(VBOXVHWA_PIPECMD_VHWA, (void *)pCmd, enmCmd, fGuestCmd); 4403 4371 return VINF_CALLBACK_RETURN; 4404 4372 4405 4373 } 4406 4374 4407 void VBoxQGLOverlay::onVHWACommandEvent(QEvent * 4408 { 4409 VBoxVHWACommandProcessEvent *pVhwaEvent = (VBoxVHWACommandProcessEvent *)pEvent;4375 void VBoxQGLOverlay::onVHWACommandEvent(QEvent *pEvent) 4376 { 4377 VBoxVHWACommandProcessEvent *pVhwaEvent = (VBoxVHWACommandProcessEvent *)pEvent; 4410 4378 /* sanity actually */ 4411 4379 pVhwaEvent->setProcessed(); … … 4427 4395 } 4428 4396 4429 bool VBoxQGLOverlay::onNotifyUpdate(ULONG uX, ULONG uY, 4430 ULONG uW, ULONG uH) 4397 bool VBoxQGLOverlay::onNotifyUpdate(ULONG uX, ULONG uY, ULONG uW, ULONG uH) 4431 4398 { 4432 4399 /* Prepare corresponding viewport part: */ … … 4439 4406 { 4440 4407 /* Calculate corresponding scale-factors: */ 4441 const double xScaleFactor = mSizeInfo.visualState() == UIVisualStateType_Scale ?4442 4443 const double yScaleFactor = mSizeInfo.visualState() == UIVisualStateType_Scale ?4444 4408 const double xScaleFactor = mSizeInfo.visualState() == UIVisualStateType_Scale 4409 ? (double)scaledSize.width() / mSizeInfo.width() : dScaleFactor; 4410 const double yScaleFactor = mSizeInfo.visualState() == UIVisualStateType_Scale 4411 ? (double)scaledSize.height() / mSizeInfo.height() : dScaleFactor; 4445 4412 /* Adjust corresponding viewport part: */ 4446 4413 rect.moveTo((int)floor((double)rect.x() * xScaleFactor) - 1, … … 4466 4433 * so no not check for m_fUnused here, 4467 4434 * mOverlay will store the required info for us */ 4468 mCmdPipe.postCmd(VBOXVHWA_PIPECMD_PAINT, &rect );4435 mCmdPipe.postCmd(VBOXVHWA_PIPECMD_PAINT, &rect, -1, false); 4469 4436 4470 4437 return true; 4471 4438 } 4472 4439 4473 void VBoxQGLOverlay::onResizeEventPostprocess (const VBoxFBSizeInfo &re, const QPoint &topLeft)4440 void VBoxQGLOverlay::onResizeEventPostprocess(const VBoxFBSizeInfo &re, const QPoint &topLeft) 4474 4441 { 4475 4442 mSizeInfo = re; … … 4494 4461 if (!mOnResizeCmdList.empty()) 4495 4462 { 4496 for (VHWACommandList::const_iterator it = mOnResizeCmdList.begin(); 4497 it != mOnResizeCmdList.end(); ++ it) 4498 { 4499 VBOXVHWACMD * pCmd = (*it); 4500 vboxDoVHWACmdExec(pCmd); 4463 for (VHWACommandList::const_iterator it = mOnResizeCmdList.begin(); it != mOnResizeCmdList.end(); ++ it) 4464 { 4465 VBOXVHWACMD *pCmd = (*it); 4466 vboxDoVHWACmdExec(pCmd, pCmd->enmCmd, false); 4501 4467 free(pCmd); 4502 4468 } … … 4510 4476 void VBoxQGLOverlay::repaintMain() 4511 4477 { 4512 if (mMainDirtyRect.isClear())4478 if (mMainDirtyRect.isClear()) 4513 4479 return; 4514 4480 4515 4481 const QRect &rect = mMainDirtyRect.rect(); 4516 if(mOverlayWidgetVisible) 4517 { 4518 if(mOverlayViewport.contains(rect)) 4482 if (mOverlayWidgetVisible) 4483 if (mOverlayViewport.contains(rect)) 4519 4484 return; 4520 } 4521 4522 mpViewport->repaint (rect.x() - mContentsTopLeft.x(),4523 rect.y() - mContentsTopLeft.y(),4524 rect.width(),rect.height());4485 4486 mpViewport->repaint(rect.x() - mContentsTopLeft.x(), 4487 rect.y() - mContentsTopLeft.y(), 4488 rect.width(), 4489 rect.height()); 4525 4490 4526 4491 mMainDirtyRect.clear(); 4527 4492 } 4528 4493 4529 void VBoxQGLOverlay::vboxDoVHWACmd(void RT_UNTRUSTED_VOLATILE_GUEST * cmd)4530 { 4531 vboxDoVHWACmdExec( cmd);4494 void VBoxQGLOverlay::vboxDoVHWACmd(void RT_UNTRUSTED_VOLATILE_GUEST *pvCmd, int /*VBOXVHWACMD_TYPE*/ enmCmd, bool fGuestCmd) 4495 { 4496 vboxDoVHWACmdExec(pvCmd, enmCmd, fGuestCmd); 4532 4497 4533 4498 CDisplay display = mpSession->GetConsole().GetDisplay(); 4534 Assert 4535 4536 Log(("VHWA Command <<< Async %#p, %d\n", cmd, ((VBOXVHWACMD *)cmd)->enmCmd));4537 4538 display.CompleteVHWACommand((BYTE *)cmd);4499 Assert(!display.isNull()); 4500 4501 Log(("VHWA Command <<< Async %#p, %d\n", pvCmd, enmCmd)); 4502 4503 display.CompleteVHWACommand((BYTE *)pvCmd); 4539 4504 } 4540 4505 4541 4506 bool VBoxQGLOverlay::vboxSynchGl() 4542 4507 { 4543 VBoxVHWASurfaceBase * 4544 if (pVGA4545 && mSizeInfo.pixelFormat()== pVGA->pixelFormat().toVBoxPixelFormat()4546 && mSizeInfo.VRAM()== pVGA->address()4547 4548 4549 && mSizeInfo.width()== pVGA->width()4550 && mSizeInfo.height()== pVGA->height()4551 4508 VBoxVHWASurfaceBase *pVGA = mOverlayImage.vgaSurface(); 4509 if ( pVGA 4510 && mSizeInfo.pixelFormat() == pVGA->pixelFormat().toVBoxPixelFormat() 4511 && mSizeInfo.VRAM() == pVGA->address() 4512 && mSizeInfo.bitsPerPixel() == pVGA->bitsPerPixel() 4513 && mSizeInfo.bytesPerLine() == pVGA->bytesPerLine() 4514 && mSizeInfo.width() == pVGA->width() 4515 && mSizeInfo.height() == pVGA->height() 4516 ) 4552 4517 { 4553 4518 return false; … … 4561 4526 void VBoxQGLOverlay::vboxSetGlOn(bool on) 4562 4527 { 4563 if (on == mGlOn)4528 if (on == mGlOn) 4564 4529 return; 4565 4530 4566 4531 mGlOn = on; 4567 4532 4568 if (on)4533 if (on) 4569 4534 { 4570 4535 /* need to ensure we have gl functions initialized */ … … 4590 4555 void VBoxQGLOverlay::vboxDoCheckUpdateViewport() 4591 4556 { 4592 if (!mOverlayVisible)4557 if (!mOverlayVisible) 4593 4558 { 4594 4559 vboxShowOverlay(false); … … 4601 4566 QRect overVp = fbVp.intersected(mOverlayViewport); 4602 4567 4603 if(overVp.isEmpty()) 4604 { 4568 if (overVp.isEmpty()) 4605 4569 vboxShowOverlay(false); 4606 }4607 4570 else 4608 4571 { 4609 if (overVp != mOverlayImage.vboxViewport())4572 if (overVp != mOverlayImage.vboxViewport()) 4610 4573 { 4611 4574 makeCurrent(); … … 4627 4590 void VBoxQGLOverlay::vboxShowOverlay(bool show) 4628 4591 { 4629 if (mOverlayWidgetVisible != show)4592 if (mOverlayWidgetVisible != show) 4630 4593 { 4631 4594 mpOverlayWgt->setVisible(show); 4632 4595 mOverlayWidgetVisible = show; 4633 4596 mGlCurrent = false; 4634 if(!show) 4635 { 4597 if (!show) 4636 4598 mMainDirtyRect.add(mOverlayImage.vboxViewport()); 4637 } 4638 } 4639 } 4640 4641 void VBoxQGLOverlay::vboxCheckUpdateOverlay(const QRect & rect) 4599 } 4600 } 4601 4602 void VBoxQGLOverlay::vboxCheckUpdateOverlay(const QRect &rect) 4642 4603 { 4643 4604 QRect overRect(mpOverlayWgt->pos(), mpOverlayWgt->size()); 4644 if (overRect.x() != rect.x() || overRect.y() != rect.y())4605 if (overRect.x() != rect.x() || overRect.y() != rect.y()) 4645 4606 { 4646 4607 #if defined(RT_OS_WINDOWS) … … 4653 4614 } 4654 4615 4655 if (overRect.width() != rect.width() || overRect.height() != rect.height())4616 if (overRect.width() != rect.width() || overRect.height() != rect.height()) 4656 4617 { 4657 4618 #if defined(RT_OS_WINDOWS) … … 4665 4626 } 4666 4627 4667 void VBoxQGLOverlay::addMainDirtyRect(const QRect & 4628 void VBoxQGLOverlay::addMainDirtyRect(const QRect &aRect) 4668 4629 { 4669 4630 mMainDirtyRect.add(aRect); 4670 if (mGlOn)4631 if (mGlOn) 4671 4632 { 4672 4633 mOverlayImage.vboxDoUpdateRect(&aRect); … … 4678 4639 { 4679 4640 int rc = mOverlayImage.vhwaSurfaceUnlock(pCmd); 4680 VBoxVHWASurfaceBase * 4681 const VBoxVHWADirtyRect & 4641 VBoxVHWASurfaceBase *pVGA = mOverlayImage.vgaSurface(); 4642 const VBoxVHWADirtyRect &rect = pVGA->getDirtyRect(); 4682 4643 mNeedOverlayRepaint = true; 4683 if(!rect.isClear()) 4684 { 4644 if (!rect.isClear()) 4685 4645 mMainDirtyRect.add(rect); 4686 }4687 4646 return rc; 4688 4647 } 4689 4648 4690 void VBoxQGLOverlay::vboxDoVHWACmdExec(void RT_UNTRUSTED_VOLATILE_GUEST * cmd)4691 { 4692 struct VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCmd = (struct VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *) cmd;4693 VBOXVHWACMD_TYPE enmCmd = pCmd->enmCmd;4694 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 4649 void VBoxQGLOverlay::vboxDoVHWACmdExec(void RT_UNTRUSTED_VOLATILE_GUEST *pvCmd, int /*VBOXVHWACMD_TYPE*/ enmCmdInt, bool fGuestCmd) 4650 { 4651 struct VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCmd = (struct VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *)pvCmd; 4652 VBOXVHWACMD_TYPE enmCmd = (VBOXVHWACMD_TYPE)enmCmdInt; 4653 4695 4654 switch (enmCmd) 4696 4655 { … … 4703 4662 pCmd->rc = mOverlayImage.vhwaSurfaceCanCreate(pBody); 4704 4663 Assert(!mGlOn == !mOverlayImage.hasSurfaces()); 4705 } break; 4664 break; 4665 } 4666 4706 4667 case VBOXVHWACMD_TYPE_SURF_CREATE: 4707 4668 { … … 4712 4673 vboxSetGlOn(true); 4713 4674 pCmd->rc = mOverlayImage.vhwaSurfaceCreate(pBody); 4714 if (!mOverlayImage.hasSurfaces())4675 if (!mOverlayImage.hasSurfaces()) 4715 4676 { 4716 4677 vboxSetGlOn(false); … … 4719 4680 { 4720 4681 mOverlayVisible = mOverlayImage.hasVisibleOverlays(); 4721 if (mOverlayVisible)4682 if (mOverlayVisible) 4722 4683 { 4723 4684 mOverlayViewport = mOverlayImage.overlaysRectUnion(); … … 4728 4689 4729 4690 Assert(!mGlOn == !mOverlayImage.hasSurfaces()); 4730 } break; 4691 break; 4692 } 4693 4731 4694 case VBOXVHWACMD_TYPE_SURF_DESTROY: 4732 4695 { … … 4736 4699 makeCurrent(); 4737 4700 pCmd->rc = mOverlayImage.vhwaSurfaceDestroy(pBody); 4738 if (!mOverlayImage.hasSurfaces())4701 if (!mOverlayImage.hasSurfaces()) 4739 4702 { 4740 4703 vboxSetGlOn(false); … … 4743 4706 { 4744 4707 mOverlayVisible = mOverlayImage.hasVisibleOverlays(); 4745 if (mOverlayVisible)4708 if (mOverlayVisible) 4746 4709 { 4747 4710 mOverlayViewport = mOverlayImage.overlaysRectUnion(); … … 4751 4714 } 4752 4715 Assert(!mGlOn == !mOverlayImage.hasSurfaces()); 4753 } break; 4716 break; 4717 } 4718 4754 4719 case VBOXVHWACMD_TYPE_SURF_LOCK: 4755 4720 { … … 4760 4725 pCmd->rc = mOverlayImage.vhwaSurfaceLock(pBody); 4761 4726 Assert(!mGlOn == !mOverlayImage.hasSurfaces()); 4762 } break; 4727 break; 4728 } 4729 4763 4730 case VBOXVHWACMD_TYPE_SURF_UNLOCK: 4764 4731 { … … 4770 4737 Assert(!mGlOn == !mOverlayImage.hasSurfaces()); 4771 4738 /* mNeedOverlayRepaint is set inside the vhwaSurfaceUnlock */ 4772 } break; 4739 break; 4740 } 4741 4773 4742 case VBOXVHWACMD_TYPE_SURF_BLT: 4774 4743 { … … 4780 4749 mNeedOverlayRepaint = true; 4781 4750 Assert(!mGlOn == !mOverlayImage.hasSurfaces()); 4782 } break; 4751 break; 4752 } 4753 4783 4754 case VBOXVHWACMD_TYPE_SURF_FLIP: 4784 4755 { … … 4790 4761 mNeedOverlayRepaint = true; 4791 4762 Assert(!mGlOn == !mOverlayImage.hasSurfaces()); 4792 } break; 4763 break; 4764 } 4765 4793 4766 case VBOXVHWACMD_TYPE_SURF_OVERLAY_UPDATE: 4794 4767 { … … 4799 4772 pCmd->rc = mOverlayImage.vhwaSurfaceOverlayUpdate(pBody); 4800 4773 mOverlayVisible = mOverlayImage.hasVisibleOverlays(); 4801 if (mOverlayVisible)4774 if (mOverlayVisible) 4802 4775 { 4803 4776 mOverlayViewport = mOverlayImage.overlaysRectUnion(); … … 4806 4779 mNeedOverlayRepaint = true; 4807 4780 Assert(!mGlOn == !mOverlayImage.hasSurfaces()); 4808 } break; 4781 break; 4782 } 4783 4809 4784 case VBOXVHWACMD_TYPE_SURF_OVERLAY_SETPOSITION: 4810 4785 { … … 4815 4790 pCmd->rc = mOverlayImage.vhwaSurfaceOverlaySetPosition(pBody); 4816 4791 mOverlayVisible = mOverlayImage.hasVisibleOverlays(); 4817 if (mOverlayVisible)4792 if (mOverlayVisible) 4818 4793 { 4819 4794 mOverlayViewport = mOverlayImage.overlaysRectUnion(); … … 4822 4797 mNeedOverlayRepaint = true; 4823 4798 Assert(!mGlOn == !mOverlayImage.hasSurfaces()); 4824 } break; 4799 break; 4800 } 4801 4825 4802 #ifdef VBOX_WITH_WDDM 4826 4803 case VBOXVHWACMD_TYPE_SURF_COLORFILL: … … 4833 4810 mNeedOverlayRepaint = true; 4834 4811 Assert(!mGlOn == !mOverlayImage.hasSurfaces()); 4835 } break; 4812 break; 4813 } 4836 4814 #endif 4837 4815 case VBOXVHWACMD_TYPE_SURF_COLORKEY_SET: … … 4846 4824 mNeedOverlayRepaint = true; 4847 4825 Assert(!mGlOn == !mOverlayImage.hasSurfaces()); 4848 } break; 4826 break; 4827 } 4828 4849 4829 case VBOXVHWACMD_TYPE_QUERY_INFO1: 4850 4830 { … … 4855 4835 pCmd->rc = mOverlayImage.vhwaQueryInfo1(pBody); 4856 4836 Assert(!mGlOn == !mOverlayImage.hasSurfaces()); 4857 } break; 4837 break; 4838 } 4839 4858 4840 case VBOXVHWACMD_TYPE_QUERY_INFO2: 4859 4841 { … … 4864 4846 pCmd->rc = mOverlayImage.vhwaQueryInfo2(pBody); 4865 4847 Assert(!mGlOn == !mOverlayImage.hasSurfaces()); 4866 } break; 4848 break; 4849 } 4850 4867 4851 case VBOXVHWACMD_TYPE_ENABLE: 4868 4852 Assert(!mGlOn == !mOverlayImage.hasSurfaces()); … … 4871 4855 pCmd->rc = VINF_SUCCESS; 4872 4856 break; 4857 4873 4858 case VBOXVHWACMD_TYPE_DISABLE: 4874 4859 pCmd->rc = VINF_SUCCESS; 4875 4860 break; 4861 4876 4862 case VBOXVHWACMD_TYPE_HH_CONSTRUCT: 4877 4863 { 4864 ASSERT_GUEST_STMT_RETURN_VOID(!fGuestCmd, pCmd->rc = VERR_ACCESS_DENIED); 4878 4865 VBOXVHWACMD_HH_CONSTRUCT *pBody = VBOXVHWACMD_BODY_HOST_HEAP(pCmd, VBOXVHWACMD_HH_CONSTRUCT); 4879 4866 Assert(!mGlOn == !mOverlayImage.hasSurfaces()); 4880 4867 pCmd->rc = vhwaConstruct(pBody); 4881 4868 Assert(!mGlOn == !mOverlayImage.hasSurfaces()); 4882 } break; 4869 break; 4870 } 4871 4883 4872 #ifdef VBOX_WITH_WDDM 4884 4873 case VBOXVHWACMD_TYPE_SURF_GETINFO: … … 4888 4877 pCmd->rc = mOverlayImage.vhwaSurfaceGetInfo(pBody); 4889 4878 Assert(!mGlOn == !mOverlayImage.hasSurfaces()); 4890 } break; 4891 #endif 4879 break; 4880 } 4881 #endif 4882 4892 4883 default: 4893 4884 AssertFailed(); … … 4908 4899 { 4909 4900 Assert(uPass == SSM_PASS_FINAL); NOREF(uPass); 4910 VBoxQGLOverlay * fb = (VBoxQGLOverlay*)pvUser;4901 VBoxQGLOverlay *fb = (VBoxQGLOverlay *)pvUser; 4911 4902 return fb->vhwaLoadExec(pSSM, u32Version); 4912 4903 } 4913 4904 4914 int VBoxQGLOverlay::vhwaLoadExec(struct SSMHANDLE * 4905 int VBoxQGLOverlay::vhwaLoadExec(struct SSMHANDLE *pSSM, uint32_t u32Version) 4915 4906 { 4916 4907 int rc = VBoxVHWAImage::vhwaLoadExec(&mOnResizeCmdList, pSSM, u32Version); … … 4927 4918 } 4928 4919 4929 void VBoxQGLOverlay::vhwaSaveExec(struct SSMHANDLE * 4920 void VBoxQGLOverlay::vhwaSaveExec(struct SSMHANDLE *pSSM) 4930 4921 { 4931 4922 mOverlayImage.vhwaSaveExec(pSSM); … … 4942 4933 char * pszName = nameFuf; 4943 4934 sprintf(pszName, "%s%d", VBOXQGL_STATE_NAMEBASE, intsId); 4944 int rc = SSMR3RegisterExternal( 4945 pUVM, /* The VM handle*/ 4946 pszName, /* Data unit name. */ 4947 intsId, /* The instance identifier of the data unit. 4948 * This must together with the name be unique. */ 4949 VBOXQGL_STATE_VERSION, /* Data layout version number. */ 4950 128, /* The approximate amount of data in the unit. 4951 * Only for progress indicators. */ 4952 NULL, NULL, NULL, /* pfnLiveXxx */ 4953 NULL, /* Prepare save callback, optional. */ 4954 NULL, //vboxQGLOverlaySaveExec, /* Execute save callback, optional. */ 4955 NULL, /* Done save callback, optional. */ 4956 NULL, /* Prepare load callback, optional. */ 4957 vboxQGLOverlayLoadExec, /* Execute load callback, optional. */ 4958 NULL, /* Done load callback, optional. */ 4959 this /* User argument. */ 4960 ); 4935 int rc = SSMR3RegisterExternal(pUVM, /* The VM handle*/ 4936 pszName, /* Data unit name. */ 4937 intsId, /* The instance identifier of the data unit. 4938 * This must together with the name be unique. */ 4939 VBOXQGL_STATE_VERSION, /* Data layout version number. */ 4940 128, /* The approximate amount of data in the unit. 4941 * Only for progress indicators. */ 4942 NULL, NULL, NULL, /* pfnLiveXxx */ 4943 NULL, /* Prepare save callback, optional. */ 4944 NULL, //vboxQGLOverlaySaveExec, /* Execute save callback, optional. */ 4945 NULL, /* Done save callback, optional. */ 4946 NULL, /* Prepare load callback, optional. */ 4947 vboxQGLOverlayLoadExec, /* Execute load callback, optional. */ 4948 NULL, /* Done load callback, optional. */ 4949 this /* User argument. */ 4950 ); 4961 4951 AssertRC(rc); 4962 4952 if (RT_SUCCESS(rc)) … … 4972 4962 { 4973 4963 #ifndef DEBUG_misha 4974 if (!g_bVBoxVHWAChecked)4964 if (!g_bVBoxVHWAChecked) 4975 4965 #endif 4976 4966 { … … 5000 4990 addMainDirtyRect(pCmd->rect()); 5001 4991 break; 4992 5002 4993 #ifdef VBOX_WITH_VIDEOHWACCEL 5003 4994 case VBOXVHWA_PIPECMD_VHWA: 5004 vboxDoVHWACmd(pCmd->vhwaCmd ());4995 vboxDoVHWACmd(pCmd->vhwaCmdPtr(), pCmd->vhwaCmdType(), pCmd->vhwaIsGuestCmd()); 5005 4996 break; 4997 5006 4998 case VBOXVHWA_PIPECMD_FUNC: 5007 4999 { … … 5016 5008 } 5017 5009 5018 VBoxVHWACommandElementProcessor::VBoxVHWACommandElementProcessor() :5019 m_pNotifyObject(NULL),5020 mpCurCmd(NULL),5021 mbResetting(false),5022 mcDisabled(0)5010 VBoxVHWACommandElementProcessor::VBoxVHWACommandElementProcessor() 5011 : m_pNotifyObject(NULL) 5012 , mpCurCmd(NULL) 5013 , mbResetting(false) 5014 , mcDisabled(0) 5023 5015 { 5024 5016 int rc = RTCritSectInit(&mCritSect); … … 5045 5037 } 5046 5038 5047 void VBoxVHWACommandElementProcessor::postCmd(VBOXVHWA_PIPECMD_TYPE aType, void *pvData) 5039 void VBoxVHWACommandElementProcessor::postCmd(VBOXVHWA_PIPECMD_TYPE aType, void *pvData, 5040 int /*VBOXVHWACMD_TYPE*/ enmCmd, bool fGuestCmd) 5048 5041 { 5049 5042 QObject *pNotifyObject = NULL; … … 5054 5047 RTCritSectEnter(&mCritSect); 5055 5048 5056 VBoxVHWACommandElement * 5057 if (!pCmd)5049 VBoxVHWACommandElement *pCmd = m_pCmdEntryCache->alloc(); 5050 if (!pCmd) 5058 5051 { 5059 5052 VBOXQGLLOG(("!!!no more free elements!!!\n")); … … 5065 5058 #endif 5066 5059 } 5067 pCmd->setData(aType, pvData );5060 pCmd->setData(aType, pvData, enmCmd, fGuestCmd); 5068 5061 5069 5062 /* 2. if can add to current*/ … … 5081 5074 { 5082 5075 VBoxVHWACommandProcessEvent *pCurrentEvent = new VBoxVHWACommandProcessEvent(); 5083 QApplication::postEvent 5076 QApplication::postEvent(pNotifyObject, pCurrentEvent); 5084 5077 m_NotifyObjectRefs.dec(); 5085 5078 } … … 5108 5101 { 5109 5102 /* NULL can not be references */ 5110 Assert 5103 Assert(!m_NotifyObjectRefs.refs()); 5111 5104 } 5112 5105 … … 5135 5128 { 5136 5129 /* cEventsNeeded can only be != 0 if pNotifyObject is valid */ 5137 Assert 5130 Assert(pNotifyObject); 5138 5131 for (int i = 0; i < cEventsNeeded; ++i) 5139 5132 { … … 5147 5140 void VBoxVHWACommandElementProcessor::doneCmd() 5148 5141 { 5149 VBoxVHWACommandElement * 5142 VBoxVHWACommandElement *pEl; 5150 5143 RTCritSectEnter(&mCritSect); 5151 5144 pEl = mpCurCmd; … … 5158 5151 } 5159 5152 5160 VBoxVHWACommandElement * 5161 { 5162 VBoxVHWACommandElement * 5153 VBoxVHWACommandElement *VBoxVHWACommandElementProcessor::getCmd() 5154 { 5155 VBoxVHWACommandElement *pEl = NULL; 5163 5156 RTCritSectEnter(&mCritSect); 5164 5157 … … 5173 5166 if (mcDisabled) 5174 5167 { 5175 QObject * 5168 QObject *pNotifyObject = NULL; 5176 5169 5177 5170 if (!RTListIsEmpty(&mCommandList)) … … 5211 5204 void VBoxVHWACommandElementProcessor::reset(CDisplay *pDisplay) 5212 5205 { 5213 VBoxVHWACommandElement *pCur, *pNext;5214 5215 5206 RTCritSectEnter(&mCritSect); 5216 5207 5217 5208 mbResetting = true; 5218 5209 5219 if (mpCurCmd)5220 { 5221 for (;;)5210 if (mpCurCmd) 5211 { 5212 for (;;) 5222 5213 { 5223 5214 RTCritSectLeave(&mCritSect); … … 5225 5216 RTCritSectEnter(&mCritSect); 5226 5217 /* it is assumed no one sends any new commands while reset is in progress */ 5227 if (!mpCurCmd)5218 if (!mpCurCmd) 5228 5219 { 5229 5220 break; … … 5234 5225 RTCritSectLeave(&mCritSect); 5235 5226 5227 VBoxVHWACommandElement *pCur, *pNext; 5236 5228 RTListForEachSafeCpp(&mCommandList, pCur, pNext, VBoxVHWACommandElement, ListNode) 5237 5229 { 5238 switch (pCur->type())5230 switch (pCur->type()) 5239 5231 { 5240 5232 #ifdef VBOX_WITH_VIDEOHWACCEL 5241 case VBOXVHWA_PIPECMD_VHWA: 5242 { 5243 struct VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCmd = pCur->vhwaCmd(); 5244 pCmd->rc = VERR_INVALID_STATE; 5245 Log(("VHWA Command <<< Async RESET %#p, %d\n", pCmd, pCmd->enmCmd)); 5246 pDisplay->CompleteVHWACommand((BYTE *)pCmd); 5247 } 5248 break; 5249 case VBOXVHWA_PIPECMD_FUNC: 5250 /* should not happen, don't handle this for now */ 5251 AssertFailed(); 5252 break; 5253 #endif 5254 case VBOXVHWA_PIPECMD_PAINT: 5255 break; 5256 default: 5257 /* should not happen, don't handle this for now */ 5258 AssertFailed(); 5259 break; 5233 case VBOXVHWA_PIPECMD_VHWA: 5234 { 5235 struct VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCmd = pCur->vhwaCmdPtr(); 5236 pCmd->rc = VERR_INVALID_STATE; 5237 Log(("VHWA Command <<< Async RESET %#p, %d\n", pCmd, pCmd->enmCmd)); 5238 pDisplay->CompleteVHWACommand((BYTE *)pCmd); 5239 } 5240 break; 5241 5242 case VBOXVHWA_PIPECMD_FUNC: 5243 /* should not happen, don't handle this for now */ 5244 AssertFailed(); 5245 break; 5246 #endif 5247 case VBOXVHWA_PIPECMD_PAINT: 5248 break; 5249 5250 default: 5251 /* should not happen, don't handle this for now */ 5252 AssertFailed(); 5253 break; 5260 5254 } 5261 5255 … … 5271 5265 } 5272 5266 5273 #define VBOXVHWACOMMANDELEMENTLISTBEGIN_MAGIC 0x89abcdef5274 #define VBOXVHWACOMMANDELEMENTLISTEND_MAGIC 0xfedcba985275 5276 int VBoxVHWACommandElementProcessor::loadExec (struct SSMHANDLE *pSSM, uint32_t u32Version, void *pvVRAM)5267 #define VBOXVHWACOMMANDELEMENTLISTBEGIN_MAGIC UINT32_C(0x89abcdef) 5268 #define VBOXVHWACOMMANDELEMENTLISTEND_MAGIC UINT32_C(0xfedcba98) 5269 5270 int VBoxVHWACommandElementProcessor::loadExec(struct SSMHANDLE *pSSM, uint32_t u32Version, void *pvVRAM) 5277 5271 { 5278 5272 uint32_t u32; 5273 5274 Q_UNUSED(u32Version); 5275 5276 int rc = SSMR3GetU32(pSSM, &u32); 5277 AssertRCReturn(rc, rc); 5278 AssertReturn(u32 == VBOXVHWACOMMANDELEMENTLISTBEGIN_MAGIC, VERR_INVALID_MAGIC); 5279 5280 SSMR3GetU32(pSSM, &u32); 5279 5281 bool b; 5282 rc = SSMR3GetBool(pSSM, &b); 5283 AssertRCReturn(rc, rc); 5284 5285 // m_NotifyObjectRefs = VBoxVHWARefCounter(u32); 5286 bool fContinue = true; 5287 do 5288 { 5289 rc = SSMR3GetU32(pSSM, &u32); 5290 AssertRCReturn(rc, rc); 5291 5292 bool fNewEvent; 5293 switch (u32) 5294 { 5295 case VBOXVHWA_PIPECMD_PAINT: 5296 { 5297 int x,y,w,h; 5298 rc = SSMR3GetS32(pSSM, &x); 5299 rc = SSMR3GetS32(pSSM, &y); 5300 rc = SSMR3GetS32(pSSM, &w); 5301 rc = SSMR3GetS32(pSSM, &h); 5302 rc = SSMR3GetBool(pSSM, &fNewEvent); 5303 AssertRCReturn(rc, rc); 5304 5305 QRect r = QRect(x, y, w, h); 5306 postCmd(VBOXVHWA_PIPECMD_PAINT, &r, -1, false); 5307 break; 5308 } 5309 5310 case VBOXVHWA_PIPECMD_VHWA: 5311 { 5312 uint32_t offCmd; 5313 rc = SSMR3GetU32(pSSM, &offCmd); 5314 rc = SSMR3GetBool(pSSM, &fNewEvent); 5315 AssertRCReturn(rc, rc); 5316 5317 VBOXVHWACMD *pCmd = (VBOXVHWACMD *)(((uint8_t *)pvVRAM) + offCmd); 5318 postCmd(VBOXVHWA_PIPECMD_VHWA, pCmd, pCmd->enmCmd, true); 5319 break; 5320 } 5321 5322 case VBOXVHWACOMMANDELEMENTLISTEND_MAGIC: 5323 fContinue = false; 5324 break; 5325 5326 default: 5327 AssertLogRelMsgFailed(("u32=%#x\n", u32)); 5328 break; 5329 } 5330 5331 } while (fContinue && RT_SUCCESS(rc)); 5332 5333 return rc; 5334 } 5335 5336 void VBoxVHWACommandElementProcessor::saveExec(struct SSMHANDLE *pSSM, void *pvVRAM) 5337 { 5280 5338 int rc; 5281 5339 5282 Q_UNUSED(u32Version); 5283 5284 rc = SSMR3GetU32(pSSM, &u32); AssertRC(rc); 5285 if (RT_SUCCESS(rc)) 5286 { 5287 Assert(u32 == VBOXVHWACOMMANDELEMENTLISTBEGIN_MAGIC); 5288 if (u32 == VBOXVHWACOMMANDELEMENTLISTBEGIN_MAGIC) 5289 { 5290 rc = SSMR3GetU32(pSSM, &u32); 5291 rc = SSMR3GetBool(pSSM, &b); AssertRC(rc); 5292 // m_NotifyObjectRefs = VBoxVHWARefCounter(u32); 5293 bool bContinue = true; 5294 do 5295 { 5296 rc = SSMR3GetU32(pSSM, &u32); AssertRC(rc); 5297 if (RT_SUCCESS(rc)) 5298 { 5299 bool bNewEvent; 5300 switch (u32) 5301 { 5302 case VBOXVHWA_PIPECMD_PAINT: 5303 { 5304 int x,y,w,h; 5305 rc = SSMR3GetS32(pSSM, &x); AssertRC(rc); 5306 rc = SSMR3GetS32(pSSM, &y); AssertRC(rc); 5307 rc = SSMR3GetS32(pSSM, &w); AssertRC(rc); 5308 rc = SSMR3GetS32(pSSM, &h); AssertRC(rc); 5309 5310 rc = SSMR3GetBool(pSSM, &bNewEvent); AssertRC(rc); 5311 5312 if (RT_SUCCESS(rc)) 5313 { 5314 QRect r = QRect(x, y, w, h); 5315 postCmd(VBOXVHWA_PIPECMD_PAINT, &r); 5316 } 5317 break; 5318 } 5319 case VBOXVHWA_PIPECMD_VHWA: 5320 { 5321 uint32_t offCmd; 5322 rc = SSMR3GetU32(pSSM, &offCmd); AssertRC(rc); 5323 5324 rc = SSMR3GetBool(pSSM, &bNewEvent); AssertRC(rc); 5325 5326 if (RT_SUCCESS(rc)) 5327 { 5328 postCmd(VBOXVHWA_PIPECMD_VHWA, (VBOXVHWACMD*)(((uint8_t*)pvVRAM) + offCmd)); 5329 } 5330 break; 5331 } 5332 case VBOXVHWACOMMANDELEMENTLISTEND_MAGIC: 5333 { 5334 bContinue = false; 5335 break; 5336 } 5337 default: 5338 AssertFailed(); 5339 break; 5340 } 5341 5342 } 5343 5344 } while(bContinue && RT_SUCCESS(rc)); 5345 } 5346 else 5347 { 5348 rc = VERR_INVALID_MAGIC; 5349 } 5350 } 5351 5352 return rc; 5353 } 5354 5355 void VBoxVHWACommandElementProcessor::saveExec (struct SSMHANDLE * pSSM, void *pvVRAM) 5356 { 5357 int rc; 5358 5359 rc = SSMR3PutU32(pSSM, VBOXVHWACOMMANDELEMENTLISTBEGIN_MAGIC); AssertRC(rc); 5360 rc = SSMR3PutU32(pSSM, m_NotifyObjectRefs.refs()); AssertRC(rc); 5361 rc = SSMR3PutBool(pSSM, true); AssertRC(rc); 5340 rc = SSMR3PutU32(pSSM, VBOXVHWACOMMANDELEMENTLISTBEGIN_MAGIC); 5341 rc = SSMR3PutU32(pSSM, m_NotifyObjectRefs.refs()); 5342 rc = SSMR3PutBool(pSSM, true); 5343 AssertRC(rc); 5362 5344 5363 5345 VBoxVHWACommandElement *pCur; 5364 5346 RTListForEachCpp(&mCommandList, pCur, VBoxVHWACommandElement, ListNode) 5365 5347 { 5366 rc = SSMR3PutU32(pSSM, pCur->type()); AssertRC(rc);5367 5348 5368 5349 switch (pCur->type()) 5369 5350 { 5370 5351 case VBOXVHWA_PIPECMD_PAINT: 5371 rc = SSMR3PutS32(pSSM, pCur->rect().x()); AssertRC(rc); 5372 rc = SSMR3PutS32(pSSM, pCur->rect().y()); AssertRC(rc); 5373 rc = SSMR3PutS32(pSSM, pCur->rect().width()); AssertRC(rc); 5374 rc = SSMR3PutS32(pSSM, pCur->rect().height()); AssertRC(rc); 5375 rc = SSMR3PutBool(pSSM, true); AssertRC(rc); 5352 rc = SSMR3PutU32(pSSM, pCur->type()); 5353 rc = SSMR3PutS32(pSSM, pCur->rect().x()); 5354 rc = SSMR3PutS32(pSSM, pCur->rect().y()); 5355 rc = SSMR3PutS32(pSSM, pCur->rect().width()); 5356 rc = SSMR3PutS32(pSSM, pCur->rect().height()); 5357 rc = SSMR3PutBool(pSSM, true); 5358 AssertRC(rc); 5376 5359 break; 5360 5377 5361 case VBOXVHWA_PIPECMD_VHWA: 5378 { 5379 rc = SSMR3PutU32(pSSM, (uint32_t)((uintptr_t)((uint8_t*)pCur->vhwaCmd() - (uint8_t*)pvVRAM))); AssertRC(rc); 5380 rc = SSMR3PutBool(pSSM, true); AssertRC(rc); 5362 if (pCur->vhwaIsGuestCmd()) 5363 { 5364 rc = SSMR3PutU32(pSSM, pCur->type()); 5365 rc = SSMR3PutU32(pSSM, (uint32_t)(uintptr_t)pCur->vhwaCmdPtr() - (uintptr_t)pvVRAM); 5366 rc = SSMR3PutBool(pSSM, true); 5367 AssertRC(rc); 5368 } 5381 5369 break; 5382 } 5370 5383 5371 default: 5384 5372 AssertFailed(); … … 5387 5375 } 5388 5376 5389 rc = SSMR3PutU32(pSSM, VBOXVHWACOMMANDELEMENTLISTEND_MAGIC); AssertRC(rc); 5377 rc = SSMR3PutU32(pSSM, VBOXVHWACOMMANDELEMENTLISTEND_MAGIC); 5378 AssertRC(rc); 5390 5379 } 5391 5380 … … 5394 5383 RTCritSectEnter(&mCritSect); 5395 5384 5396 if (mpCurCmd)5397 { 5398 for (;;)5385 if (mpCurCmd) 5386 { 5387 for (;;) 5399 5388 { 5400 5389 RTCritSectLeave(&mCritSect); … … 5402 5391 RTCritSectEnter(&mCritSect); 5403 5392 /* it is assumed no one sends any new commands while reset is in progress */ 5404 if (!mpCurCmd)5393 if (!mpCurCmd) 5405 5394 { 5406 5395 break; … … 5432 5421 5433 5422 /* static */ 5434 uint32_t VBoxVHWATextureImage::calcBytesPerLine(const VBoxVHWAColorFormat & 5435 { 5436 uint32_t pitch = (format.bitsPerPixel() * width + 7) /8;5423 uint32_t VBoxVHWATextureImage::calcBytesPerLine(const VBoxVHWAColorFormat &format, int width) 5424 { 5425 uint32_t pitch = (format.bitsPerPixel() * width + 7) / 8; 5437 5426 switch (format.fourcc()) 5438 5427 { … … 5442 5431 pitch = (pitch + 7) & ~7; 5443 5432 break; 5433 5444 5434 default: 5445 5435 pitch = (pitch + 3) & ~3; … … 5450 5440 5451 5441 /* static */ 5452 uint32_t VBoxVHWATextureImage::calcMemSize(const VBoxVHWAColorFormat & 5442 uint32_t VBoxVHWATextureImage::calcMemSize(const VBoxVHWAColorFormat &format, int width, int height) 5453 5443 { 5454 5444 uint32_t pitch = calcBytesPerLine(format, width); … … 5458 5448 /* we have 3 separate planes here 5459 5449 * Y - pitch x height 5460 * U - pitch /2 x height/25461 * V - pitch /2 x height/25450 * U - pitch / 2 x height / 2 5451 * V - pitch / 2 x height / 2 5462 5452 * */ 5463 5453 return 3 * pitch * height / 2; 5464 break; 5454 5465 5455 default: 5466 5456 return pitch * height; 5467 break;5468 5469 } 5470 5471 VBoxVHWATextureImage::VBoxVHWATextureImage(const QRect &size, const VBoxVHWAColorFormat &format, class VBoxVHWAGlProgramMngr * aMgr, VBOXVHWAIMG_TYPE flags) : 5472 mVisibleDisplay(0),5473 mpProgram(0),5474 mProgramMngr(aMgr),5475 mpDst(NULL),5476 mpDstCKey(NULL),5477 mpSrcCKey(NULL),5478 5457 } 5458 } 5459 5460 VBoxVHWATextureImage::VBoxVHWATextureImage(const QRect &size, const VBoxVHWAColorFormat &format, 5461 class VBoxVHWAGlProgramMngr * aMgr, VBOXVHWAIMG_TYPE flags) 5462 : mVisibleDisplay(0) 5463 , mpProgram(0) 5464 , mProgramMngr(aMgr) 5465 , mpDst(NULL) 5466 , mpDstCKey(NULL) 5467 , mpSrcCKey(NULL) 5468 , mbNotIntersected(false) 5479 5469 { 5480 5470 uint32_t pitch = calcBytesPerLine(format, size.width()); … … 5482 5472 mpTex[0] = vboxVHWATextureCreate(NULL, size, format, pitch, flags); 5483 5473 mColorFormat = format; 5484 if (mColorFormat.fourcc() == FOURCC_YV12)5485 { 5486 QRect rect(size.x() /2,size.y()/2,size.width()/2,size.height()/2);5487 mpTex[1] = vboxVHWATextureCreate(NULL, rect, format, pitch /2, flags);5488 mpTex[2] = vboxVHWATextureCreate(NULL, rect, format, pitch /2, flags);5474 if (mColorFormat.fourcc() == FOURCC_YV12) 5475 { 5476 QRect rect(size.x() / 2,size.y() / 2,size.width() / 2,size.height() / 2); 5477 mpTex[1] = vboxVHWATextureCreate(NULL, rect, format, pitch / 2, flags); 5478 mpTex[2] = vboxVHWATextureCreate(NULL, rect, format, pitch / 2, flags); 5489 5479 mcTex = 3; 5490 5480 } 5491 5481 else 5492 {5493 5482 mcTex = 1; 5494 }5495 5483 } 5496 5484 5497 5485 void VBoxVHWATextureImage::deleteDisplayList() 5498 5486 { 5499 if (mVisibleDisplay)5487 if (mVisibleDisplay) 5500 5488 { 5501 5489 glDeleteLists(mVisibleDisplay, 1); … … 5510 5498 } 5511 5499 5512 void VBoxVHWATextureImage::draw(VBoxVHWATextureImage *pDst, const QRect * pDstRect, const QRect *pSrcRect)5500 void VBoxVHWATextureImage::draw(VBoxVHWATextureImage *pDst, const QRect *pDstRect, const QRect *pSrcRect) 5513 5501 { 5514 5502 int tx1, ty1, tx2, ty2; 5515 5503 pSrcRect->getCoords(&tx1, &ty1, &tx2, &ty2); 5504 5516 5505 int bx1, by1, bx2, by2; 5517 5506 pDstRect->getCoords(&bx1, &by1, &bx2, &by2); 5507 5518 5508 tx2++; ty2++;bx2++; by2++; 5519 5509 5520 5510 glBegin(GL_QUADS); 5521 5511 uint32_t c = texCoord(GL_TEXTURE0, tx1, ty1); 5522 if(pDst) 5523 { 5512 if (pDst) 5524 5513 pDst->texCoord(GL_TEXTURE0 + c, bx1, by1); 5525 }5526 5514 glVertex2i(bx1, by1); 5527 5515 5528 5516 texCoord(GL_TEXTURE0, tx1, ty2); 5529 if(pDst) 5530 { 5517 if (pDst) 5531 5518 pDst->texCoord(GL_TEXTURE0 + c, bx1, by2); 5532 }5533 5519 glVertex2i(bx1, by2); 5534 5520 5535 5521 texCoord(GL_TEXTURE0, tx2, ty2); 5536 if(pDst) 5537 { 5522 if (pDst) 5538 5523 pDst->texCoord(GL_TEXTURE0 + c, bx2, by2); 5539 }5540 5524 glVertex2i(bx2, by2); 5541 5525 5542 5526 texCoord(GL_TEXTURE0, tx2, ty1); 5543 if(pDst) 5544 { 5527 if (pDst) 5545 5528 pDst->texCoord(GL_TEXTURE0 + c, bx2, by1); 5546 }5547 5529 glVertex2i(bx2, by1); 5548 5530 … … 5552 5534 void VBoxVHWATextureImage::internalSetDstCKey(const VBoxVHWAColorKey * pDstCKey) 5553 5535 { 5554 if (pDstCKey)5536 if (pDstCKey) 5555 5537 { 5556 5538 mDstCKey = *pDstCKey; … … 5565 5547 void VBoxVHWATextureImage::internalSetSrcCKey(const VBoxVHWAColorKey * pSrcCKey) 5566 5548 { 5567 if (pSrcCKey)5549 if (pSrcCKey) 5568 5550 { 5569 5551 mSrcCKey = *pSrcCKey; … … 5577 5559 5578 5560 int VBoxVHWATextureImage::initDisplay(VBoxVHWATextureImage *pDst, 5579 const QRect * pDstRect, const QRect * pSrcRect, 5580 const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected) 5581 { 5582 if(!mVisibleDisplay 5583 || mpDst != pDst 5584 || *pDstRect != mDstRect 5585 || *pSrcRect != mSrcRect 5586 || !!(pDstCKey) != !!(mpDstCKey) 5587 || !!(pSrcCKey) != !!(mpSrcCKey) 5588 || mbNotIntersected != bNotIntersected 5589 || mpProgram != calcProgram(pDst, pDstCKey, pSrcCKey, bNotIntersected)) 5590 { 5591 return createSetDisplay(pDst, pDstRect, pSrcRect, 5592 pDstCKey, pSrcCKey, bNotIntersected); 5593 5594 } 5595 else if((pDstCKey && mpDstCKey && *pDstCKey != *mpDstCKey) 5596 || (pSrcCKey && mpSrcCKey && *pSrcCKey != *mpSrcCKey)) 5561 const QRect *pDstRect, const QRect *pSrcRect, 5562 const VBoxVHWAColorKey *pDstCKey, const VBoxVHWAColorKey *pSrcCKey, bool bNotIntersected) 5563 { 5564 if ( !mVisibleDisplay 5565 || mpDst != pDst 5566 || *pDstRect != mDstRect 5567 || *pSrcRect != mSrcRect 5568 || !!(pDstCKey) != !!(mpDstCKey) 5569 || !!(pSrcCKey) != !!(mpSrcCKey) 5570 || mbNotIntersected != bNotIntersected 5571 || mpProgram != calcProgram(pDst, pDstCKey, pSrcCKey, bNotIntersected)) 5572 return createSetDisplay(pDst, pDstRect, pSrcRect, pDstCKey, pSrcCKey, bNotIntersected); 5573 if ( (pDstCKey && mpDstCKey && *pDstCKey != *mpDstCKey) 5574 || (pSrcCKey && mpSrcCKey && *pSrcCKey != *mpSrcCKey)) 5597 5575 { 5598 5576 Assert(mpProgram); … … 5605 5583 void VBoxVHWATextureImage::bind(VBoxVHWATextureImage * pPrimary) 5606 5584 { 5607 for (uint32_t i = 1; i < mcTex; i++)5585 for (uint32_t i = 1; i < mcTex; i++) 5608 5586 { 5609 5587 vboxglActiveTexture(GL_TEXTURE0 + i); 5610 5588 mpTex[i]->bind(); 5611 5589 } 5612 if(pPrimary) 5613 { 5614 for(uint32_t i = 0; i < pPrimary->mcTex; i++) 5590 if (pPrimary) 5591 for (uint32_t i = 0; i < pPrimary->mcTex; i++) 5615 5592 { 5616 5593 vboxglActiveTexture(GL_TEXTURE0 + i + mcTex); 5617 5594 pPrimary->mpTex[i]->bind(); 5618 5595 } 5619 }5620 5596 5621 5597 vboxglActiveTexture(GL_TEXTURE0); … … 5623 5599 } 5624 5600 5625 uint32_t VBoxVHWATextureImage::calcProgramType(VBoxVHWATextureImage *pDst, const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected) 5601 uint32_t VBoxVHWATextureImage::calcProgramType(VBoxVHWATextureImage *pDst, const VBoxVHWAColorKey *pDstCKey, 5602 const VBoxVHWAColorKey *pSrcCKey, bool bNotIntersected) 5626 5603 { 5627 5604 uint32_t type = 0; 5628 5605 5629 if (pDstCKey != NULL)5606 if (pDstCKey != NULL) 5630 5607 type |= VBOXVHWA_PROGRAM_DSTCOLORKEY; 5631 if (pSrcCKey)5608 if (pSrcCKey) 5632 5609 type |= VBOXVHWA_PROGRAM_SRCCOLORKEY; 5633 if ((pDstCKey || pSrcCKey) && bNotIntersected)5610 if ((pDstCKey || pSrcCKey) && bNotIntersected) 5634 5611 type |= VBOXVHWA_PROGRAM_COLORKEYNODISCARD; 5635 5612 … … 5638 5615 } 5639 5616 5640 class VBoxVHWAGlProgramVHWA * VBoxVHWATextureImage::calcProgram(VBoxVHWATextureImage *pDst, const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected) 5617 class VBoxVHWAGlProgramVHWA *VBoxVHWATextureImage::calcProgram(VBoxVHWATextureImage *pDst, const VBoxVHWAColorKey *pDstCKey, 5618 const VBoxVHWAColorKey *pSrcCKey, bool bNotIntersected) 5641 5619 { 5642 5620 uint32_t type = calcProgramType(pDst, pDstCKey, pSrcCKey, bNotIntersected); … … 5645 5623 } 5646 5624 5647 int VBoxVHWATextureImage::createSetDisplay(VBoxVHWATextureImage *pDst, const QRect * pDstRect, const QRect * pSrcRect, 5648 const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected) 5625 int VBoxVHWATextureImage::createSetDisplay(VBoxVHWATextureImage *pDst, const QRect *pDstRect, const QRect *pSrcRect, 5626 const VBoxVHWAColorKey *pDstCKey, const VBoxVHWAColorKey * pSrcCKey, 5627 bool bNotIntersected) 5649 5628 { 5650 5629 deleteDisplay(); 5651 int rc = createDisplay(pDst, pDstRect, pSrcRect, 5652 pDstCKey, pSrcCKey, bNotIntersected, 5653 &mVisibleDisplay, &mpProgram); 5654 if(RT_FAILURE(rc)) 5630 int rc = createDisplay(pDst, pDstRect, pSrcRect, pDstCKey, pSrcCKey, bNotIntersected, &mVisibleDisplay, &mpProgram); 5631 if (RT_FAILURE(rc)) 5655 5632 { 5656 5633 mVisibleDisplay = 0; … … 5672 5649 5673 5650 5674 int VBoxVHWATextureImage::createDisplayList(VBoxVHWATextureImage *pDst, const QRect * pDstRect, const QRect *pSrcRect,5675 const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected,5676 GLuint *pDisplay)5651 int VBoxVHWATextureImage::createDisplayList(VBoxVHWATextureImage *pDst, const QRect *pDstRect, const QRect *pSrcRect, 5652 const VBoxVHWAColorKey *pDstCKey, const VBoxVHWAColorKey *pSrcCKey, 5653 bool bNotIntersected, GLuint *pDisplay) 5677 5654 { 5678 5655 Q_UNUSED(pDstCKey); … … 5683 5660 GLuint display = glGenLists(1); 5684 5661 GLenum err = glGetError(); 5685 if (err == GL_NO_ERROR)5662 if (err == GL_NO_ERROR) 5686 5663 { 5687 5664 Assert(display); 5688 if (!display)5665 if (!display) 5689 5666 { 5690 5667 /* well, it seems it should not return 0 on success according to the spec, … … 5692 5669 display = glGenLists(1); 5693 5670 err = glGetError(); 5694 if (err == GL_NO_ERROR)5671 if (err == GL_NO_ERROR) 5695 5672 { 5696 5673 Assert(display); … … 5704 5681 } 5705 5682 5706 if (display)5683 if (display) 5707 5684 { 5708 5685 glNewList(display, GL_COMPILE); … … 5724 5701 } 5725 5702 5726 void VBoxVHWATextureImage::updateCKeys(VBoxVHWATextureImage * pDst, class VBoxVHWAGlProgramVHWA * pProgram, const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey) 5727 { 5728 if(pProgram) 5703 void VBoxVHWATextureImage::updateCKeys(VBoxVHWATextureImage *pDst, class VBoxVHWAGlProgramVHWA *pProgram, 5704 const VBoxVHWAColorKey *pDstCKey, const VBoxVHWAColorKey *pSrcCKey) 5705 { 5706 if (pProgram) 5729 5707 { 5730 5708 pProgram->start(); 5731 if(pSrcCKey) 5732 { 5709 if (pSrcCKey) 5733 5710 VBoxVHWATextureImage::setCKey(pProgram, &pixelFormat(), pSrcCKey, false); 5734 } 5735 if(pDstCKey) 5736 { 5711 if (pDstCKey) 5737 5712 VBoxVHWATextureImage::setCKey(pProgram, &pDst->pixelFormat(), pDstCKey, true); 5738 }5739 5713 pProgram->stop(); 5740 5714 } 5741 5715 } 5742 5716 5743 void VBoxVHWATextureImage::updateSetCKeys(const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey *pSrcCKey)5717 void VBoxVHWATextureImage::updateSetCKeys(const VBoxVHWAColorKey *pDstCKey, const VBoxVHWAColorKey *pSrcCKey) 5744 5718 { 5745 5719 updateCKeys(mpDst, mpProgram, pDstCKey, pSrcCKey); … … 5748 5722 } 5749 5723 5750 int VBoxVHWATextureImage::createDisplay(VBoxVHWATextureImage *pDst, const QRect * pDstRect, const QRect *pSrcRect,5751 const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey *pSrcCKey, bool bNotIntersected,5752 GLuint *pDisplay, class VBoxVHWAGlProgramVHWA **ppProgram)5753 { 5754 VBoxVHWAGlProgramVHWA * 5724 int VBoxVHWATextureImage::createDisplay(VBoxVHWATextureImage *pDst, const QRect *pDstRect, const QRect *pSrcRect, 5725 const VBoxVHWAColorKey *pDstCKey, const VBoxVHWAColorKey *pSrcCKey, bool bNotIntersected, 5726 GLuint *pDisplay, class VBoxVHWAGlProgramVHWA **ppProgram) 5727 { 5728 VBoxVHWAGlProgramVHWA *pProgram = NULL; 5755 5729 if (!pDst) 5756 5730 { … … 5769 5743 5770 5744 GLuint displ; 5771 int rc = createDisplayList(pDst, pDstRect, pSrcRect, 5772 pDstCKey, pSrcCKey, bNotIntersected, 5773 &displ); 5774 if(RT_SUCCESS(rc)) 5745 int rc = createDisplayList(pDst, pDstRect, pSrcRect, pDstCKey, pSrcCKey, bNotIntersected, &displ); 5746 if (RT_SUCCESS(rc)) 5775 5747 { 5776 5748 *pDisplay = displ; … … 5781 5753 } 5782 5754 5783 void VBoxVHWATextureImage::display(VBoxVHWATextureImage *pDst, const QRect * pDstRect, const QRect *pSrcRect,5784 const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey *pSrcCKey, bool bNotIntersected)5785 { 5786 VBoxVHWAGlProgramVHWA * 5787 if (pProgram)5755 void VBoxVHWATextureImage::display(VBoxVHWATextureImage *pDst, const QRect *pDstRect, const QRect *pSrcRect, 5756 const VBoxVHWAColorKey *pDstCKey, const VBoxVHWAColorKey *pSrcCKey, bool bNotIntersected) 5757 { 5758 VBoxVHWAGlProgramVHWA *pProgram = calcProgram(pDst, pDstCKey, pSrcCKey, bNotIntersected); 5759 if (pProgram) 5788 5760 pProgram->start(); 5789 5761 5790 5762 runDisplay(pDst, pDstRect, pSrcRect); 5791 5763 5792 if (pProgram)5764 if (pProgram) 5793 5765 pProgram->stop(); 5794 5766 } … … 5798 5770 #ifdef DEBUG_misha 5799 5771 if (mpDst) 5800 {5801 5772 dbgDump(); 5802 }5803 5773 5804 5774 static bool bDisplayOn = true; 5805 5775 #endif 5806 5776 Assert(mVisibleDisplay); 5807 if (mVisibleDisplay5777 if ( mVisibleDisplay 5808 5778 #ifdef DEBUG_misha 5809 5810 #endif 5811 5812 { 5813 if (mpProgram)5779 && bDisplayOn 5780 #endif 5781 ) 5782 { 5783 if (mpProgram) 5814 5784 mpProgram->start(); 5815 5785 … … 5818 5788 ); 5819 5789 5820 if (mpProgram)5790 if (mpProgram) 5821 5791 mpProgram->stop(); 5822 5792 } … … 5832 5802 { 5833 5803 for (uint32_t i = 0; i < mcTex; ++i) 5834 {5835 5804 mpTex[i]->dbgDump(); 5836 5837 } 5838 #endif 5839 5840 int VBoxVHWATextureImage::setCKey (VBoxVHWAGlProgramVHWA * pProgram, const VBoxVHWAColorFormat * pFormat, const VBoxVHWAColorKey *pCKey, bool bDst)5805 } 5806 #endif 5807 5808 int VBoxVHWATextureImage::setCKey(VBoxVHWAGlProgramVHWA *pProgram, const VBoxVHWAColorFormat *pFormat, 5809 const VBoxVHWAColorKey *pCKey, bool bDst) 5841 5810 { 5842 5811 float r,g,b; 5843 pFormat->pixel2Normalized 5844 int rcL = bDst ? pProgram->setDstCKeyLowerRange (r, g, b) : pProgram->setSrcCKeyLowerRange(r, g, b);5812 pFormat->pixel2Normalized(pCKey->lower(), &r, &g, &b); 5813 int rcL = bDst ? pProgram->setDstCKeyLowerRange(r, g, b) : pProgram->setSrcCKeyLowerRange(r, g, b); 5845 5814 Assert(RT_SUCCESS(rcL)); 5846 5815 … … 5873 5842 } 5874 5843 5875 int VBoxVHWASettings::calcIntersection 5844 int VBoxVHWASettings::calcIntersection(int c1, const uint32_t *a1, int c2, const uint32_t *a2, int cOut, uint32_t *aOut) 5876 5845 { 5877 5846 /* fourcc arrays are not big, so linear search is enough, … … 5884 5853 { 5885 5854 uint32_t cur2 = a2[j]; 5886 if (cur1 == cur2)5855 if (cur1 == cur2) 5887 5856 { 5888 if (cOut > cMatch && aOut)5857 if (cOut > cMatch && aOut) 5889 5858 aOut[cMatch] = cur1; 5890 5859 ++cMatch; -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.h
r71626 r71651 1220 1220 { 1221 1221 public: 1222 void setVHWACmd(struct VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCmd )1222 void setVHWACmd(struct VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCmd, int enmCmd, bool fGuestCmd) 1223 1223 { 1224 1224 mType = VBOXVHWA_PIPECMD_VHWA; 1225 u.mpCmd = pCmd; 1225 u.s.mpCmd = pCmd; 1226 u.s.menmCmd = enmCmd; 1227 u.s.mfGuestCmd = fGuestCmd; 1226 1228 } 1227 1229 … … 1238 1240 } 1239 1241 1240 void setData(VBOXVHWA_PIPECMD_TYPE aType, void *pvData )1241 { 1242 switch (aType)1242 void setData(VBOXVHWA_PIPECMD_TYPE aType, void *pvData, int /*VBOXVHWACMD_TYPE*/ enmCmd, bool fGuestCmd = false) 1243 { 1244 switch (aType) 1243 1245 { 1244 1246 case VBOXVHWA_PIPECMD_PAINT: 1245 setPaintCmd(*((QRect *)pvData));1247 setPaintCmd(*((QRect *)pvData)); 1246 1248 break; 1247 1249 case VBOXVHWA_PIPECMD_VHWA: 1248 setVHWACmd((struct VBOXVHWACMD *)pvData );1250 setVHWACmd((struct VBOXVHWACMD *)pvData, enmCmd, fGuestCmd); 1249 1251 break; 1250 1252 case VBOXVHWA_PIPECMD_FUNC: … … 1252 1254 break; 1253 1255 default: 1254 Assert(0); 1256 AssertFailed(); 1257 mType = (VBOXVHWA_PIPECMD_TYPE)0; 1255 1258 break; 1256 1259 } … … 1259 1262 VBOXVHWA_PIPECMD_TYPE type() const {return mType;} 1260 1263 const QRect & rect() const {return mRect;} 1261 struct VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *vhwaCmd() const {return u.mpCmd;} 1264 struct VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *vhwaCmdPtr() const { return u.s.mpCmd; } 1265 int /*VBOXVHWACMD_TYPE*/ vhwaCmdType() const { return u.s.menmCmd; } 1266 bool vhwaIsGuestCmd() const { return u.s.mfGuestCmd; } 1262 1267 const VBOXVHWAFUNCCALLBACKINFO & func() const {return u.mFuncCallback; } 1263 1268 … … 1267 1272 union 1268 1273 { 1269 struct VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *mpCmd; 1274 struct 1275 { 1276 struct VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *mpCmd; 1277 int /*VBOXVHWACMD_TYPE*/ menmCmd; 1278 bool mfGuestCmd; 1279 } s; 1270 1280 VBOXVHWAFUNCCALLBACKINFO mFuncCallback; 1271 } u;1281 } u; 1272 1282 QRect mRect; 1273 1283 }; … … 1321 1331 void init(QObject *pNotifyObject); 1322 1332 ~VBoxVHWACommandElementProcessor(); 1323 void postCmd(VBOXVHWA_PIPECMD_TYPE aType, void *pvData );1333 void postCmd(VBOXVHWA_PIPECMD_TYPE aType, void *pvData, int /*VBOXVHWACMD_TYPE*/ enmCmdInt, bool fGuestCmd); 1324 1334 VBoxVHWACommandElement *getCmd(); 1325 1335 void doneCmd(); … … 1709 1719 void updateAttachment(QWidget *pViewport, QObject *pPostEventObject); 1710 1720 1711 int onVHWACommand (struct VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCommand); 1721 int onVHWACommand(struct VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCommand, 1722 int /*VBOXVHWACMD_TYPE*/ enmCmdInt, bool fGuestCmd); 1712 1723 1713 1724 void onVHWACommandEvent (QEvent * pEvent); … … 1799 1810 bool vboxGetGlOn() { return mGlOn; } 1800 1811 bool vboxSynchGl(); 1801 void vboxDoVHWACmdExec(void RT_UNTRUSTED_VOLATILE_GUEST * cmd);1812 void vboxDoVHWACmdExec(void RT_UNTRUSTED_VOLATILE_GUEST *pvCmd, int /*VBOXVHWACMD_TYPE*/ enmCmdInt, bool fGuestCmd); 1802 1813 void vboxShowOverlay (bool show); 1803 1814 void vboxDoCheckUpdateViewport(); 1804 void vboxDoVHWACmd (void RT_UNTRUSTED_VOLATILE_GUEST *cmd);1815 void vboxDoVHWACmd(void RT_UNTRUSTED_VOLATILE_GUEST *pvCmd, int /*VBOXVHWACMD_TYPE*/ enmCmd, bool fGuestCmd); 1805 1816 void addMainDirtyRect (const QRect & aRect); 1806 1817 void vboxCheckUpdateOverlay (const QRect & rect); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp
r71626 r71651 245 245 246 246 /** EMT callback which is not used in current implementation. */ 247 STDMETHOD(ProcessVHWACommand)(BYTE *pCommand );247 STDMETHOD(ProcessVHWACommand)(BYTE *pCommand, LONG enmCmd, BOOL fGuestCmd); 248 248 249 249 /** EMT callback: Notifies frame-buffer about 3D backend event. … … 420 420 } 421 421 422 STDMETHOD(ProcessVHWACommand)(BYTE *pCommand) 423 { 424 int rc; 422 STDMETHOD(ProcessVHWACommand)(BYTE *pCommand, LONG enmCmd, BOOL fGuestCmd) 423 { 425 424 UIFrameBufferPrivate::lock(); 426 425 /* Make sure frame-buffer is used: */ … … 433 432 return E_ACCESSDENIED; 434 433 } 435 rc = mOverlay.onVHWACommand((struct VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *)pCommand); 434 435 int rc = mOverlay.onVHWACommand((struct VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *)pCommand, enmCmd, fGuestCmd != FALSE); 436 436 UIFrameBufferPrivate::unlock(); 437 437 if (rc == VINF_CALLBACK_RETURN) 438 438 return S_OK; 439 elseif (RT_SUCCESS(rc))439 if (RT_SUCCESS(rc)) 440 440 return S_FALSE; 441 elseif (rc == VERR_INVALID_STATE)441 if (rc == VERR_INVALID_STATE) 442 442 return E_ACCESSDENIED; 443 443 return E_FAIL; … … 1004 1004 } 1005 1005 1006 STDMETHODIMP UIFrameBufferPrivate::ProcessVHWACommand(BYTE *pCommand )1007 { 1008 Q_UNUSED(pCommand);1006 STDMETHODIMP UIFrameBufferPrivate::ProcessVHWACommand(BYTE *pCommand, LONG enmCmd, BOOL fGuestCmd) 1007 { 1008 RT_NOREF(pCommand, enmCmd, fGuestCmd); 1009 1009 return E_NOTIMPL; 1010 1010 } -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r71349 r71651 17015 17015 <interface 17016 17016 name="IFramebuffer" extends="$unknown" 17017 uuid=" 8b82295f-415f-1aa1-17fd-9fbbac8edf44"17017 uuid="1e8d3f27-b45c-48ae-8b36-d35e83d207aa" 17018 17018 wsmap="managed" 17019 17019 > … … 17233 17233 <param name="command" type="octet" mod="ptr" dir="in"> 17234 17234 <desc>Pointer to VBOXVHWACMD containing the command to execute.</desc> 17235 </param> 17236 <param name="enmCmd" type="long" dir="in"> 17237 <desc>The validated VBOXVHWACMD::enmCmd value from the command.</desc> 17238 </param> 17239 <param name="fromGuest" type="boolean" dir="in"> 17240 <desc>Set when the command origins from the guest, clear if host.</desc> 17235 17241 </param> 17236 17242 </method> -
trunk/src/VBox/Main/src-client/DisplayImpl.cpp
r71626 r71651 3546 3546 return VERR_NOT_IMPLEMENTED; /* Implementation is not available. */ 3547 3547 3548 RT_NOREF(enmCmd, fGuestCmd); 3549 HRESULT hr = pFramebuffer->ProcessVHWACommand((BYTE *)pCommand); 3548 HRESULT hr = pFramebuffer->ProcessVHWACommand((BYTE *)pCommand, enmCmd, fGuestCmd); 3550 3549 if (hr == S_FALSE) 3551 3550 return VINF_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.