Changeset 53593 in vbox for trunk/src/VBox/GuestHost/OpenGL
- Timestamp:
- Dec 21, 2014 4:58:42 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/util/vreg.cpp
r50246 r53593 1 1 /* $Id$ */ 2 3 2 /** @file 4 3 * Visible Regions processing API implementation … … 6 5 7 6 /* 8 * Copyright (C) 2012 Oracle Corporation7 * Copyright (C) 2012-2014 Oracle Corporation 9 8 * 10 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 16 15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 17 16 */ 18 #include <cr_vreg.h> 17 18 /******************************************************************************* 19 * Header Files * 20 *******************************************************************************/ 21 #ifdef IN_VMSVGA3D 22 # include "../include/cr_vreg.h" 23 # define WARN AssertMsgFailed 24 #else 25 # include <cr_vreg.h> 26 # include <cr_error.h> 27 #endif 28 19 29 #include <iprt/err.h> 20 30 #include <iprt/assert.h> 21 31 #include <iprt/asm.h> 22 32 23 #include <cr_error.h>24 25 33 #ifdef DEBUG_misha 26 34 # define VBOXVDBG_VR_LAL_DISABLE … … 28 36 29 37 #ifndef IN_RING0 30 # include <iprt/memcache.h>31 # ifndef VBOXVDBG_VR_LAL_DISABLE38 # include <iprt/memcache.h> 39 # ifndef VBOXVDBG_VR_LAL_DISABLE 32 40 static RTMEMCACHE g_VBoxVrLookasideList; 33 #define vboxVrRegLaAlloc(_c) RTMemCacheAlloc((_c)) 34 #define vboxVrRegLaFree(_c, _e) RTMemCacheFree((_c), (_e)) 35 DECLINLINE(int) vboxVrLaCreate(RTMEMCACHE *pCache, size_t cbElement) 36 { 37 int rc = RTMemCacheCreate(pCache, cbElement, 38 0, /* size_t cbAlignment */ 39 UINT32_MAX, /* uint32_t cMaxObjects */ 40 NULL, /* PFNMEMCACHECTOR pfnCtor*/ 41 NULL, /* PFNMEMCACHEDTOR pfnDtor*/ 42 NULL, /* void *pvUser*/ 43 0 /* uint32_t fFlags*/ 44 ); 41 # define vboxVrRegLaAlloc(_c) RTMemCacheAlloc((_c)) 42 # define vboxVrRegLaFree(_c, _e) RTMemCacheFree((_c), (_e)) 43 44 DECLINLINE(int) vboxVrLaCreate(PRTMEMCACHE phCache, size_t cbElement) 45 { 46 int rc = RTMemCacheCreate(phCache, 47 cbElement, 48 0 /* cbAlignment */, 49 UINT32_MAX /* cMaxObjects */, 50 NULL /* pfnCtor*/, 51 NULL /* pfnDtor*/, 52 NULL /* pvUser*/, 53 0 /* fFlags*/); 45 54 if (!RT_SUCCESS(rc)) 46 55 { … … 50 59 return VINF_SUCCESS; 51 60 } 52 #define vboxVrLaDestroy(_c) RTMemCacheDestroy((_c)) 53 #endif 54 #else 61 # define vboxVrLaDestroy(_c) RTMemCacheDestroy((_c)) 62 # endif /* !VBOXVDBG_VR_LAL_DISABLE */ 63 64 #else /* IN_RING0 */ 55 65 # ifdef RT_OS_WINDOWS 56 # ifdef PAGE_SIZE 57 # undef PAGE_SIZE 58 # endif 59 # ifdef PAGE_SHIFT 60 # undef PAGE_SHIFT 61 # endif 66 # undef PAGE_SIZE 67 # undef PAGE_SHIFT 62 68 # define VBOX_WITH_WORKAROUND_MISSING_PACK 63 69 # if (_MSC_VER >= 1400) && !defined(VBOX_WITH_PATCHED_DDK) … … 72 78 # pragma warning(disable : 4163) 73 79 # ifdef VBOX_WITH_WORKAROUND_MISSING_PACK 74 # 80 # pragma warning(disable : 4103) 75 81 # endif 76 82 # include <ntddk.h> 77 83 # pragma warning(default : 4163) 78 84 # ifdef VBOX_WITH_WORKAROUND_MISSING_PACK 79 # 80 # 85 # pragma pack() 86 # pragma warning(default : 4103) 81 87 # endif 82 88 # undef _InterlockedExchange … … 91 97 # include <ntddk.h> 92 98 # endif 93 # ifndef VBOXVDBG_VR_LAL_DISABLE99 # ifndef VBOXVDBG_VR_LAL_DISABLE 94 100 static LOOKASIDE_LIST_EX g_VBoxVrLookasideList; 95 # define vboxVrRegLaAlloc(_c) ExAllocateFromLookasideListEx(&(_c))96 # define vboxVrRegLaFree(_c, _e) ExFreeToLookasideListEx(&(_c), (_e))97 # define VBOXWDDMVR_MEMTAG 'vDBV'101 # define vboxVrRegLaAlloc(_c) ExAllocateFromLookasideListEx(&(_c)) 102 # define vboxVrRegLaFree(_c, _e) ExFreeToLookasideListEx(&(_c), (_e)) 103 # define VBOXWDDMVR_MEMTAG 'vDBV' 98 104 DECLINLINE(int) vboxVrLaCreate(LOOKASIDE_LIST_EX *pCache, size_t cbElement) 99 105 { 100 106 NTSTATUS Status = ExInitializeLookasideListEx(pCache, 101 NULL, /* PALLOCATE_FUNCTION_EX Allocate */102 NULL, /* PFREE_FUNCTION_EX Free */103 NonPagedPool,104 0, /* ULONG Flags */105 cbElement,106 VBOXWDDMVR_MEMTAG,107 0 /* USHORT Depth - reserved, must be null */108 );107 NULL, /* PALLOCATE_FUNCTION_EX Allocate */ 108 NULL, /* PFREE_FUNCTION_EX Free */ 109 NonPagedPool, 110 0, /* ULONG Flags */ 111 cbElement, 112 VBOXWDDMVR_MEMTAG, 113 0 /* USHORT Depth - reserved, must be null */ 114 ); 109 115 if (!NT_SUCCESS(Status)) 110 116 { … … 115 121 return VINF_SUCCESS; 116 122 } 117 # define vboxVrLaDestroy(_c) ExDeleteLookasideListEx(&(_c))118 # endif119 # else 123 # define vboxVrLaDestroy(_c) ExDeleteLookasideListEx(&(_c)) 124 # endif 125 # else /* !RT_OS_WINDOWS */ 120 126 # error "port me!" 121 # endif 122 #endif 123 127 # endif /* !RT_OS_WINDOWS */ 128 #endif /* IN_RING0 */ 129 130 131 /******************************************************************************* 132 * Defined Constants And Macros * 133 *******************************************************************************/ 134 #define VBOXVR_INVALID_COORD (~0U) 135 136 137 /******************************************************************************* 138 * Global Variables * 139 *******************************************************************************/ 124 140 static volatile int32_t g_cVBoxVrInits = 0; 125 141 126 static PVBOXVR_REG vboxVrRegCreate() 142 143 static PVBOXVR_REG vboxVrRegCreate(void) 127 144 { 128 145 #ifndef VBOXVDBG_VR_LAL_DISABLE … … 134 151 return pReg; 135 152 #else 136 return (PVBOXVR_REG)RTMemAlloc(sizeof 153 return (PVBOXVR_REG)RTMemAlloc(sizeof(VBOXVR_REG)); 137 154 #endif 138 155 } … … 167 184 } 168 185 169 #define VBOXVR_MEMTAG 'vDBV' 170 171 VBOXVREGDECL(int) VBoxVrInit() 186 VBOXVREGDECL(int) VBoxVrInit(void) 172 187 { 173 188 int32_t cNewRefs = ASMAtomicIncS32(&g_cVBoxVrInits); … … 178 193 179 194 #ifndef VBOXVDBG_VR_LAL_DISABLE 180 int rc = vboxVrLaCreate(&g_VBoxVrLookasideList, sizeof 195 int rc = vboxVrLaCreate(&g_VBoxVrLookasideList, sizeof(VBOXVR_REG)); 181 196 if (!RT_SUCCESS(rc)) 182 197 { … … 189 204 } 190 205 191 VBOXVREGDECL(void) VBoxVrTerm( )206 VBOXVREGDECL(void) VBoxVrTerm(void) 192 207 { 193 208 int32_t cNewRefs = ASMAtomicDecS32(&g_cVBoxVrInits); … … 201 216 } 202 217 203 typedef DECLCALLBACK(int) FNVBOXVR_CB_COMPARATOR( const VBOXVR_REG *pReg1, const VBOXVR_REG *pReg2);218 typedef DECLCALLBACK(int) FNVBOXVR_CB_COMPARATOR(PCVBOXVR_REG pReg1, PCVBOXVR_REG pReg2); 204 219 typedef FNVBOXVR_CB_COMPARATOR *PFNVBOXVR_CB_COMPARATOR; 205 220 206 static DECLCALLBACK(int) vboxVrRegNonintersectedComparator( const RTRECT* pRect1, const RTRECT*pRect2)221 static DECLCALLBACK(int) vboxVrRegNonintersectedComparator(PCRTRECT pRect1, PCRTRECT pRect2) 207 222 { 208 223 Assert(!VBoxRectIsIntersect(pRect1, pRect2)); … … 226 241 } 227 242 } 228 229 #define vboxVrDbgListVerify vboxVrDbgListDoVerify 243 # define vboxVrDbgListVerify(_p) vboxVrDbgListDoVerify(_p) 230 244 #else 231 # define vboxVrDbgListVerify(_p) do {} while (0)245 # define vboxVrDbgListVerify(_p) do {} while (0) 232 246 #endif 233 247 234 static int vboxVrListUniteIntersection(PVBOXVR_LIST pList, PVBOXVR_LIST pIntersection);235 236 #define VBOXVR_INVALID_COORD (~0U)237 248 238 249 DECLINLINE(void) vboxVrListRegAdd(PVBOXVR_LIST pList, PVBOXVR_REG pReg, PRTLISTNODE pPlace, bool fAfter) … … 255 266 static void vboxVrListRegAddOrder(PVBOXVR_LIST pList, PRTLISTNODE pMemberEntry, PVBOXVR_REG pReg) 256 267 { 257 do268 for (;;) 258 269 { 259 270 if (pMemberEntry != &pList->ListHead) … … 268 279 vboxVrListRegAdd(pList, pReg, pMemberEntry, false); 269 280 break; 270 } while (1);281 } 271 282 } 272 283 … … 278 289 { 279 290 PVBOXVR_REG pReg2 = PVBOXVR_REG_FROM_ENTRY(pEntry2); 280 do { 291 for (;;) 292 { 281 293 if (pEntry1 != &pList1->ListHead) 282 294 { … … 291 303 vboxVrListRegAdd(pList1, pReg2, pEntry1, false); 292 304 break; 293 } while (1);305 } 294 306 } 295 307 … … 297 309 } 298 310 299 static int vboxVrListRegIntersectSubstNoJoin(PVBOXVR_LIST pList1, PVBOXVR_REG pReg1, const RTRECT *pRect2)311 static int vboxVrListRegIntersectSubstNoJoin(PVBOXVR_LIST pList1, PVBOXVR_REG pReg1, PCRTRECT pRect2) 300 312 { 301 313 uint32_t topLim = VBOXVR_INVALID_COORD; … … 369 381 return VINF_SUCCESS; /* the region is covered by the pRect2 */ 370 382 371 PRTLISTNODE pEntry = List.pNext, pNext; 383 PRTLISTNODE pNext; 384 PRTLISTNODE pEntry = List.pNext; 372 385 for (; pEntry != &List; pEntry = pNext) 373 386 { … … 381 394 } 382 395 383 /* @returns Entry to be used for continuing the rectangles iterations being made currently on the callback call. 396 /** 397 * @returns Entry to be used for continuing the rectangles iterations being made currently on the callback call. 384 398 * ListHead is returned to break the current iteration 385 * @param ppNext specifies next reg entry to be used for iteration. the default is pReg1->ListEntry.pNext */ 386 typedef DECLCALLBACK(PRTLISTNODE) FNVBOXVR_CB_INTERSECTED_VISITOR(PVBOXVR_LIST pList1, PVBOXVR_REG pReg1, const RTRECT * pRect2, void *pvContext, PRTLISTNODE *ppNext); 399 * @param ppNext specifies next reg entry to be used for iteration. the default is pReg1->ListEntry.pNext */ 400 typedef DECLCALLBACK(PRTLISTNODE) FNVBOXVR_CB_INTERSECTED_VISITOR(PVBOXVR_LIST pList1, PVBOXVR_REG pReg1, 401 PCRTRECT pRect2, void *pvContext, PRTLISTNODE *ppNext); 387 402 typedef FNVBOXVR_CB_INTERSECTED_VISITOR *PFNVBOXVR_CB_INTERSECTED_VISITOR; 388 403 389 static void vboxVrListVisitIntersected(PVBOXVR_LIST pList1, uint32_t cRects, const RTRECT *aRects, PFNVBOXVR_CB_INTERSECTED_VISITOR pfnVisitor, void* pvVisitor) 404 static void vboxVrListVisitIntersected(PVBOXVR_LIST pList1, uint32_t cRects, PCRTRECT aRects, 405 PFNVBOXVR_CB_INTERSECTED_VISITOR pfnVisitor, void* pvVisitor) 390 406 { 391 407 PRTLISTNODE pEntry1 = pList1->ListHead.pNext; … … 399 415 for (uint32_t i = iFirst2; i < cRects; ++i) 400 416 { 401 const RTRECT *pRect2 = &aRects[i];417 PCRTRECT pRect2 = &aRects[i]; 402 418 if (VBoxRectIsZero(pRect2)) 403 419 continue; … … 410 426 if (pEntry1 == &pList1->ListHead) 411 427 break; 412 else413 pReg1 = PVBOXVR_REG_FROM_ENTRY(pEntry1);414 415 416 } 417 418 /* @returns Entry to be iterated next. ListHead is returned to break the iteration 419 * 428 pReg1 = PVBOXVR_REG_FROM_ENTRY(pEntry1); 429 } 430 } 431 } 432 433 /** 434 * @returns Entry to be iterated next. ListHead is returned to break the 435 * iteration 420 436 */ 421 437 typedef DECLCALLBACK(PRTLISTNODE) FNVBOXVR_CB_NONINTERSECTED_VISITOR(PVBOXVR_LIST pList1, PVBOXVR_REG pReg1, void *pvContext); 422 438 typedef FNVBOXVR_CB_NONINTERSECTED_VISITOR *PFNVBOXVR_CB_NONINTERSECTED_VISITOR; 423 439 424 static void vboxVrListVisitNonintersected(PVBOXVR_LIST pList1, uint32_t cRects, const RTRECT *aRects, PFNVBOXVR_CB_NONINTERSECTED_VISITOR pfnVisitor, void* pvVisitor) 440 static void vboxVrListVisitNonintersected(PVBOXVR_LIST pList1, uint32_t cRects, PCRTRECT aRects, 441 PFNVBOXVR_CB_NONINTERSECTED_VISITOR pfnVisitor, void* pvVisitor) 425 442 { 426 443 PRTLISTNODE pEntry1 = pList1->ListHead.pNext; … … 434 451 for (; i < cRects; ++i) 435 452 { 436 const RTRECT *pRect2 = &aRects[i];453 PCRTRECT pRect2 = &aRects[i]; 437 454 if (VBoxRectIsZero(pRect2)) 438 455 continue; … … 488 505 break; 489 506 } 490 else if (pReg1->Rect.yBottom < pReg2->Rect.yBottom) 507 508 if (pReg1->Rect.yBottom < pReg2->Rect.yBottom) 491 509 { 492 510 pReg1->Rect.xRight = pReg2->Rect.xRight; … … 499 517 break; 500 518 } 501 else 502 { 503 pReg1->Rect.xRight = pReg2->Rect.xRight; 504 vboxVrDbgListVerify(pList); 505 /* reset the pNext1 since it could be the pReg2 being destroyed */ 506 pNext1 = pEntry1->pNext; 507 /* pNext2 stays the same since it is pReg2->ListEntry.pNext, which is kept intact */ 508 vboxVrRegTerm(pReg2); 509 } 519 520 pReg1->Rect.xRight = pReg2->Rect.xRight; 521 vboxVrDbgListVerify(pList); 522 /* reset the pNext1 since it could be the pReg2 being destroyed */ 523 pNext1 = pEntry1->pNext; 524 /* pNext2 stays the same since it is pReg2->ListEntry.pNext, which is kept intact */ 525 vboxVrRegTerm(pReg2); 510 526 } 511 527 continue; … … 530 546 break; 531 547 } 532 else if (pReg1->Rect.xLeft == pReg2->Rect.xRight) 548 549 if (pReg1->Rect.xLeft == pReg2->Rect.xRight) 533 550 { 534 551 /* join rectangles */ … … 572 589 break; 573 590 } 574 else if (pReg1->Rect.xRight > pReg2->Rect.xLeft) 591 592 if (pReg1->Rect.xRight > pReg2->Rect.xLeft) 575 593 { 576 594 /* no more to be done for for pReg1 */ … … 580 598 continue; 581 599 } 582 else if (pReg1->Rect.yBottom < pReg2->Rect.yTop) 600 601 if (pReg1->Rect.yBottom < pReg2->Rect.yTop) 583 602 { 584 603 /* no more to be done for for pReg1 */ … … 600 619 int rc; 601 620 bool fChanged; 602 } VBOXVR_CBDATA_SUBST, *PVBOXVR_CBDATA_SUBST; 603 604 static DECLCALLBACK(PRTLISTNODE) vboxVrListSubstNoJoinCb(PVBOXVR_LIST pList, PVBOXVR_REG pReg1, const RTRECT *pRect2, void *pvContext, PRTLISTNODE *ppNext) 621 } VBOXVR_CBDATA_SUBST; 622 typedef VBOXVR_CBDATA_SUBST *PVBOXVR_CBDATA_SUBST; 623 624 static DECLCALLBACK(PRTLISTNODE) vboxVrListSubstNoJoinCb(PVBOXVR_LIST pList, PVBOXVR_REG pReg1, PCRTRECT pRect2, 625 void *pvContext, PRTLISTNODE *ppNext) 605 626 { 606 627 PVBOXVR_CBDATA_SUBST pData = (PVBOXVR_CBDATA_SUBST)pvContext; … … 625 646 } 626 647 627 static int vboxVrListSubstNoJoin(PVBOXVR_LIST pList, uint32_t cRects, const RTRECT *aRects, bool *pfChanged)648 static int vboxVrListSubstNoJoin(PVBOXVR_LIST pList, uint32_t cRects, PCRTRECT aRects, bool *pfChanged) 628 649 { 629 650 if (pfChanged) … … 651 672 652 673 #if 0 653 static const RTRECT * vboxVrRectsOrder(uint32_t cRects, const RTRECT * aRects) 654 { 655 #ifdef DEBUG 656 { 657 for (uint32_t i = 0; i < cRects; ++i) 658 { 659 RTRECT *pRectI = &aRects[i]; 660 for (uint32_t j = i + 1; j < cRects; ++j) 661 { 662 RTRECT *pRectJ = &aRects[j]; 663 Assert(!VBoxRectIsIntersect(pRectI, pRectJ)); 664 } 674 static PCRTRECT vboxVrRectsOrder(uint32_t cRects, PCRTRECT aRects) 675 { 676 #ifdef VBOX_STRICT 677 for (uint32_t i = 0; i < cRects; ++i) 678 { 679 PRTRECT pRectI = &aRects[i]; 680 for (uint32_t j = i + 1; j < cRects; ++j) 681 { 682 PRTRECT pRectJ = &aRects[j]; 683 Assert(!VBoxRectIsIntersect(pRectI, pRectJ)); 665 684 } 666 685 } 667 686 #endif 668 687 669 RTRECT * pRects = (RTRECT *)aRects;688 PRTRECT pRects = (PRTRECT)aRects; 670 689 /* check if rects are ordered already */ 671 690 for (uint32_t i = 0; i < cRects - 1; ++i) 672 691 { 673 RTRECT *pRect1 = &pRects[i];674 RTRECT *pRect2 = &pRects[i+1];692 PRTRECT pRect1 = &pRects[i]; 693 PRTRECT pRect2 = &pRects[i+1]; 675 694 if (vboxVrRegNonintersectedComparator(pRect1, pRect2) < 0) 676 695 continue; … … 680 699 if (pRects == aRects) 681 700 { 682 pRects = ( RTRECT *)RTMemAlloc(sizeof(RTRECT) * cRects);701 pRects = (PRTRECT)RTMemAlloc(sizeof(RTRECT) * cRects); 683 702 if (!pRects) 684 703 { … … 687 706 } 688 707 689 memcpy(pRects, aRects, sizeof 708 memcpy(pRects, aRects, sizeof(RTRECT) * cRects); 690 709 } 691 710 … … 693 712 694 713 int j = (int)i - 1; 695 do { 714 for (;;) 715 { 696 716 RTRECT Tmp = *pRect1; 697 717 *pRect1 = *pRect2; … … 706 726 pRect2 = pRect1--; 707 727 --j; 708 } while (1);728 } 709 729 } 710 730 … … 740 760 } 741 761 742 static DECLCALLBACK(PRTLISTNODE) vboxVrListIntersectNoJoinIntersectedCb(PVBOXVR_LIST pList1, PVBOXVR_REG pReg1, const RTRECT *pRect2, void *pvContext, PRTLISTNODE *ppNext) 762 static DECLCALLBACK(PRTLISTNODE) vboxVrListIntersectNoJoinIntersectedCb(PVBOXVR_LIST pList1, PVBOXVR_REG pReg1, PCRTRECT pRect2, 763 void *pvContext, PPRTLISTNODE ppNext) 743 764 { 744 765 PVBOXVR_CBDATA_SUBST pData = (PVBOXVR_CBDATA_SUBST)pvContext; … … 763 784 } 764 785 765 static int vboxVrListIntersectNoJoin(PVBOXVR_LIST pList, const VBOXVR_LIST *pList2, bool *pfChanged)786 static int vboxVrListIntersectNoJoin(PVBOXVR_LIST pList, PCVBOXVR_LIST pList2, bool *pfChanged) 766 787 { 767 788 bool fChanged = false; … … 791 812 for (const RTLISTNODE *pEntry2 = pList2->ListHead.pNext; pEntry2 != &pList2->ListHead; pEntry2 = pEntry2->pNext) 792 813 { 793 const VBOXVR_REG *pReg2 = PVBOXVR_REG_FROM_ENTRY(pEntry2);794 const RTRECT *pRect2 = &pReg2->Rect;814 PCVBOXVR_REG pReg2 = PVBOXVR_REG_FROM_ENTRY(pEntry2); 815 PCRTRECT pRect2 = &pReg2->Rect; 795 816 796 817 if (!VBoxRectIsIntersect(&RegRect1, pRect2)) … … 855 876 } 856 877 857 VBOXVREGDECL(int) VBoxVrListIntersect(PVBOXVR_LIST pList, const VBOXVR_LIST *pList2, bool *pfChanged)878 VBOXVREGDECL(int) VBoxVrListIntersect(PVBOXVR_LIST pList, PCVBOXVR_LIST pList2, bool *pfChanged) 858 879 { 859 880 if (pfChanged) … … 875 896 } 876 897 877 VBOXVREGDECL(int) VBoxVrListRectsIntersect(PVBOXVR_LIST pList, uint32_t cRects, const RTRECT *aRects, bool *pfChanged)898 VBOXVREGDECL(int) VBoxVrListRectsIntersect(PVBOXVR_LIST pList, uint32_t cRects, PCRTRECT aRects, bool *pfChanged) 878 899 { 879 900 if (pfChanged) … … 916 937 } 917 938 918 VBOXVREGDECL(int) VBoxVrListRectsSubst(PVBOXVR_LIST pList, uint32_t cRects, const RTRECT *aRects, bool *pfChanged)939 VBOXVREGDECL(int) VBoxVrListRectsSubst(PVBOXVR_LIST pList, uint32_t cRects, PCRTRECT aRects, bool *pfChanged) 919 940 { 920 941 #if 0 921 const RTRECT *pRects = vboxVrRectsOrder(cRects, aRects);942 PCRTRECT pRects = vboxVrRectsOrder(cRects, aRects); 922 943 if (!pRects) 923 944 { … … 953 974 } 954 975 955 VBOXVREGDECL(int) VBoxVrListRectsSet(PVBOXVR_LIST pList, uint32_t cRects, const RTRECT *aRects, bool *pfChanged)976 VBOXVREGDECL(int) VBoxVrListRectsSet(PVBOXVR_LIST pList, uint32_t cRects, PCRTRECT aRects, bool *pfChanged) 956 977 { 957 978 if (pfChanged) … … 959 980 960 981 if (!cRects && VBoxVrListIsEmpty(pList)) 961 {962 982 return VINF_SUCCESS; 963 }964 983 965 984 /* @todo: fChanged will have false alarming here, fix if needed */ … … 979 998 } 980 999 981 VBOXVREGDECL(int) VBoxVrListRectsAdd(PVBOXVR_LIST pList, uint32_t cRects, const RTRECT *aRects, bool *pfChanged)1000 VBOXVREGDECL(int) VBoxVrListRectsAdd(PVBOXVR_LIST pList, uint32_t cRects, PCRTRECT aRects, bool *pfChanged) 982 1001 { 983 1002 uint32_t cCovered = 0; … … 987 1006 988 1007 #if 0 989 #ifdef DEBUG 990 { 1008 #ifdef VBOX_STRICT 991 1009 for (uint32_t i = 0; i < cRects; ++i) 992 1010 { 993 RTRECT *pRectI = &aRects[i];1011 PRTRECT pRectI = &aRects[i]; 994 1012 for (uint32_t j = i + 1; j < cRects; ++j) 995 1013 { 996 RTRECT *pRectJ = &aRects[j];1014 PRTRECT pRectJ = &aRects[j]; 997 1015 Assert(!VBoxRectIsIntersect(pRectI, pRectJ)); 998 1016 } 999 1017 } 1000 }1001 1018 #endif 1002 1019 #endif … … 1030 1047 VBOXVR_LIST DiffList; 1031 1048 VBoxVrListInit(&DiffList); 1032 RTRECT *pListRects = NULL;1049 PRTRECT pListRects = NULL; 1033 1050 uint32_t cAllocatedRects = 0; 1034 1051 bool fNeedRectreate = true; … … 1057 1074 continue; 1058 1075 } 1059 else 1060 { 1061 Assert(VBoxVrListIsEmpty(&DiffList)); 1062 vboxVrListRegAdd(&DiffList, pReg, &DiffList.ListHead, false); 1063 } 1076 Assert(VBoxVrListIsEmpty(&DiffList)); 1077 vboxVrListRegAdd(&DiffList, pReg, &DiffList.ListHead, false); 1064 1078 1065 1079 if (cAllocatedRects < cListRects) … … 1069 1083 if (pListRects) 1070 1084 RTMemFree(pListRects); 1071 pListRects = (RTRECT *)RTMemAlloc(sizeof 1085 pListRects = (RTRECT *)RTMemAlloc(sizeof(RTRECT) * cAllocatedRects); 1072 1086 if (!pListRects) 1073 1087 { … … 1143 1157 1144 1158 for (pReg1 = RTListNodeGetNext(&pList1->ListHead, VBOXVR_REG, ListEntry), 1145 pReg2 = RTListNodeGetNext(&pList2->ListHead, VBOXVR_REG, ListEntry); 1146 !RTListNodeIsDummy(&pList1->ListHead, pReg1, VBOXVR_REG, ListEntry); 1147 pReg1 = RT_FROM_MEMBER(pReg1->ListEntry.pNext, VBOXVR_REG, ListEntry), 1148 pReg2 = RT_FROM_MEMBER(pReg2->ListEntry.pNext, VBOXVR_REG, ListEntry)) 1159 pReg2 = RTListNodeGetNext(&pList2->ListHead, VBOXVR_REG, ListEntry); 1160 1161 !RTListNodeIsDummy(&pList1->ListHead, pReg1, VBOXVR_REG, ListEntry); 1162 1163 pReg1 = RT_FROM_MEMBER(pReg1->ListEntry.pNext, VBOXVR_REG, ListEntry), 1164 pReg2 = RT_FROM_MEMBER(pReg2->ListEntry.pNext, VBOXVR_REG, ListEntry) ) 1149 1165 { 1150 1166 Assert(!RTListNodeIsDummy(&pList2->ListHead, pReg2, VBOXVR_REG, ListEntry)); … … 1157 1173 } 1158 1174 1159 VBOXVREGDECL(int) VBoxVrListClone( const VBOXVR_LIST *pList, VBOXVR_LIST *pDstList)1175 VBOXVREGDECL(int) VBoxVrListClone(PCVBOXVR_LIST pList, PVBOXVR_LIST pDstList) 1160 1176 { 1161 1177 VBoxVrListInit(pDstList); 1162 const VBOXVR_REG *pReg;1178 PCVBOXVR_REG pReg; 1163 1179 RTListForEach(&pList->ListHead, pReg, const VBOXVR_REG, ListEntry) 1164 1180 { … … 1204 1220 } 1205 1221 1206 DECLINLINE(void) vboxVrCompositorEntryRelease(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, PVBOXVR_COMPOSITOR_ENTRY pReplacingEntry) 1222 DECLINLINE(void) vboxVrCompositorEntryRelease(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, 1223 PVBOXVR_COMPOSITOR_ENTRY pReplacingEntry) 1207 1224 { 1208 1225 if (--pEntry->cRefs) … … 1229 1246 } 1230 1247 1231 DECLINLINE(void) vboxVrCompositorEntryRemove(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, PVBOXVR_COMPOSITOR_ENTRY pReplacingEntry) 1248 DECLINLINE(void) vboxVrCompositorEntryRemove(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, 1249 PVBOXVR_COMPOSITOR_ENTRY pReplacingEntry) 1232 1250 { 1233 1251 RTListNodeRemove(&pEntry->Node); … … 1235 1253 } 1236 1254 1237 static void vboxVrCompositorEntryReplace(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, PVBOXVR_COMPOSITOR_ENTRY pReplacingEntry) 1255 static void vboxVrCompositorEntryReplace(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, 1256 PVBOXVR_COMPOSITOR_ENTRY pReplacingEntry) 1238 1257 { 1239 1258 VBoxVrListMoveTo(&pEntry->Vr, &pReplacingEntry->Vr); … … 1270 1289 } 1271 1290 1272 VBOXVREGDECL(bool) VBoxVrCompositorEntryReplace(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, PVBOXVR_COMPOSITOR_ENTRY pNewEntry) 1291 VBOXVREGDECL(bool) VBoxVrCompositorEntryReplace(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, 1292 PVBOXVR_COMPOSITOR_ENTRY pNewEntry) 1273 1293 { 1274 1294 if (!VBoxVrCompositorEntryIsInList(pEntry)) … … 1280 1300 } 1281 1301 1282 static int vboxVrCompositorEntryRegionsSubst(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, uint32_t cRects, const RTRECT * paRects, bool *pfChanged) 1302 static int vboxVrCompositorEntryRegionsSubst(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, 1303 uint32_t cRects, PCRTRECT paRects, bool *pfChanged) 1283 1304 { 1284 1305 bool fChanged; … … 1303 1324 } 1304 1325 1305 VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsAdd(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, uint32_t cRects, const RTRECT *paRects, PVBOXVR_COMPOSITOR_ENTRY *ppReplacedEntry, uint32_t *pfChangeFlags) 1306 { 1307 bool fOthersChanged = false, fCurChanged = false, fEntryChanged = false, fEntryWasInList = false; 1308 PVBOXVR_COMPOSITOR_ENTRY pCur, pNext, pReplacedEntry = NULL; 1326 VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsAdd(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, 1327 uint32_t cRects, PCRTRECT paRects, PVBOXVR_COMPOSITOR_ENTRY *ppReplacedEntry, 1328 uint32_t *pfChangeFlags) 1329 { 1330 bool fOthersChanged = false; 1331 bool fCurChanged = false; 1332 bool fEntryChanged = false; 1333 bool fEntryWasInList = false; 1334 PVBOXVR_COMPOSITOR_ENTRY pCur; 1335 PVBOXVR_COMPOSITOR_ENTRY pNext; 1336 PVBOXVR_COMPOSITOR_ENTRY pReplacedEntry = NULL; 1309 1337 int rc = VINF_SUCCESS; 1310 1338 … … 1365 1393 break; 1366 1394 } 1395 1396 rc = vboxVrCompositorEntryRegionsSubst(pCompositor, pCur, cRects, paRects, &fCurChanged); 1397 if (RT_SUCCESS(rc)) 1398 fOthersChanged |= fCurChanged; 1367 1399 else 1368 1400 { 1369 rc = vboxVrCompositorEntryRegionsSubst(pCompositor, pCur, cRects, paRects, &fCurChanged); 1370 if (RT_SUCCESS(rc)) 1371 fOthersChanged |= fCurChanged; 1372 else 1373 { 1374 WARN(("vboxVrCompositorEntryRegionsSubst failed, rc %d", rc)); 1375 return rc; 1376 } 1401 WARN(("vboxVrCompositorEntryRegionsSubst failed, rc %d", rc)); 1402 return rc; 1377 1403 } 1378 1404 } … … 1395 1421 { 1396 1422 Assert(!pReplacedEntry); 1397 fFlags = VBOXVR_COMPOSITOR_CF_ENTRY_REGIONS_CHANGED | VBOXVR_COMPOSITOR_CF_REGIONS_CHANGED | VBOXVR_COMPOSITOR_CF_OTHER_ENTRIES_REGIONS_CHANGED; 1423 fFlags = VBOXVR_COMPOSITOR_CF_ENTRY_REGIONS_CHANGED | VBOXVR_COMPOSITOR_CF_REGIONS_CHANGED 1424 | VBOXVR_COMPOSITOR_CF_OTHER_ENTRIES_REGIONS_CHANGED; 1398 1425 } 1399 1426 else if (pReplacedEntry) … … 1422 1449 } 1423 1450 1424 VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsSubst(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, uint32_t cRects, const RTRECT * paRects, bool *pfChanged) 1451 VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsSubst(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, 1452 uint32_t cRects, PCRTRECT paRects, bool *pfChanged) 1425 1453 { 1426 1454 if (!pEntry) … … 1451 1479 } 1452 1480 1453 VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsSet(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, uint32_t cRects, const RTRECT *paRects, bool *pfChanged) 1481 VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsSet(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, 1482 uint32_t cRects, PCRTRECT paRects, bool *pfChanged) 1454 1483 { 1455 1484 if (!pEntry) … … 1484 1513 } 1485 1514 1486 VBOXVREGDECL(int) VBoxVrCompositorEntryListIntersect(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, const VBOXVR_LIST *pList2, bool *pfChanged) 1515 VBOXVREGDECL(int) VBoxVrCompositorEntryListIntersect(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, 1516 PCVBOXVR_LIST pList2, bool *pfChanged) 1487 1517 { 1488 1518 int rc = VINF_SUCCESS; … … 1516 1546 } 1517 1547 1518 VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsIntersect(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, uint32_t cRects, const RTRECT *paRects, bool *pfChanged) 1548 VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsIntersect(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, 1549 uint32_t cRects, PCRTRECT paRects, bool *pfChanged) 1519 1550 { 1520 1551 int rc = VINF_SUCCESS; … … 1548 1579 } 1549 1580 1550 VBOXVREGDECL(int) VBoxVrCompositorEntryListIntersectAll(PVBOXVR_COMPOSITOR pCompositor, const VBOXVR_LIST *pList2, bool *pfChanged)1581 VBOXVREGDECL(int) VBoxVrCompositorEntryListIntersectAll(PVBOXVR_COMPOSITOR pCompositor, PCVBOXVR_LIST pList2, bool *pfChanged) 1551 1582 { 1552 1583 VBOXVR_COMPOSITOR_ITERATOR Iter; … … 1577 1608 } 1578 1609 1579 VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsIntersectAll(PVBOXVR_COMPOSITOR pCompositor, uint32_t cRegions, const RTRECT *paRegions, bool *pfChanged) 1610 VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsIntersectAll(PVBOXVR_COMPOSITOR pCompositor, uint32_t cRegions, PCRTRECT paRegions, 1611 bool *pfChanged) 1580 1612 { 1581 1613 VBOXVR_COMPOSITOR_ITERATOR Iter; … … 1606 1638 } 1607 1639 1608 VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsTranslate(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, int32_t x, int32_t y, bool *pfChanged) 1640 VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsTranslate(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, 1641 int32_t x, int32_t y, bool *pfChanged) 1609 1642 { 1610 1643 if (!pEntry) … … 1618 1651 vboxVrCompositorEntryAddRef(pEntry); 1619 1652 1620 if ( (!x && !y)1621 1653 if ( (!x && !y) 1654 || !VBoxVrCompositorEntryIsInList(pEntry)) 1622 1655 { 1623 1656 if (pfChanged) … … 1634 1667 PVBOXVR_COMPOSITOR_ENTRY pCur; 1635 1668 uint32_t cRects = 0; 1636 RTRECT *paRects = NULL;1669 PRTRECT paRects = NULL; 1637 1670 int rc = VINF_SUCCESS; 1638 1671 RTListForEach(&pCompositor->List, pCur, VBOXVR_COMPOSITOR_ENTRY, Node) … … 1647 1680 cRects = VBoxVrListRectsCount(&pEntry->Vr); 1648 1681 Assert(cRects); 1649 paRects = (RTRECT*)RTMemAlloc(cRects * sizeof 1682 paRects = (RTRECT*)RTMemAlloc(cRects * sizeof(RTRECT)); 1650 1683 if (!paRects) 1651 1684 { … … 1691 1724 } 1692 1725 } 1726
Note:
See TracChangeset
for help on using the changeset viewer.