cr_vreg.h revision b554f49f62cfc1184e3b4b49ec337eceffafbb71
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * Visible Regions processing API
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * Copyright (C) 2012 Oracle Corporation
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * available from http://www.virtualbox.org. This file is free software;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * you can redistribute it and/or modify it under the terms of the GNU
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * General Public License (GPL) as published by the Free Software
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsynctypedef struct VBOXVR_LIST
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsyncDECLINLINE(int) VBoxRectCmp(const RTRECT * pRect1, const RTRECT * pRect2)
8d1da51eb6665874aa82bf03668e03d1a0d63223vboxsyncDECLINLINE(void) VBoxRectStretch(PRTRECT pRect, float xStretch, float yStretch)
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync pRect->xRight = (int32_t)(pRect->xRight * xStretch);
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync pRect->yBottom = (int32_t)(pRect->yBottom * yStretch);
8d1da51eb6665874aa82bf03668e03d1a0d63223vboxsyncDECLINLINE(void) VBoxRectStretched(const RTRECT *pRect, float xStretch, float yStretch, PRTRECT pResult)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsyncDECLINLINE(void) VBoxRectIntersect(PRTRECT pRect1, const RTRECT * pRect2)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync pRect1->xLeft = RT_MAX(pRect1->xLeft, pRect2->xLeft);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync pRect1->xRight = RT_MIN(pRect1->xRight, pRect2->xRight);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync pRect1->yBottom = RT_MIN(pRect1->yBottom, pRect2->yBottom);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsyncDECLINLINE(void) VBoxRectIntersected(const RTRECT *pRect1, const RTRECT * pRect2, RTRECT *pResult)
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsyncDECLINLINE(void) VBoxRectTranslate(RTRECT * pRect, int32_t x, int32_t y)
7b6926b2bf44f326f40e1d9d1ce33a4dff0a2c67vboxsyncDECLINLINE(void) VBoxRectTranslated(const RTRECT * pRect, int32_t x, int32_t y, RTRECT *pResult)
24e27201b1438d88569467f104a0e3cb1df190edvboxsyncDECLINLINE(void) VBoxRectInvertedY(const RTRECT * pRect, RTRECT * pResult)
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsyncDECLINLINE(void) VBoxRectMove(RTRECT * pRect, int32_t x, int32_t y)
7b6926b2bf44f326f40e1d9d1ce33a4dff0a2c67vboxsyncDECLINLINE(void) VBoxRectMoved(const RTRECT * pRect, int32_t x, int32_t y, RTRECT *pResult)
878e6d9047ecb951fb66b8923976ae616d994f61vboxsyncDECLINLINE(bool) VBoxRectCovers(const RTRECT *pRect, const RTRECT *pCovered)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return false;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return false;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return false;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return false;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return true;
66a94fee6b0acc21c078369f49d97020cc03ab11vboxsyncDECLINLINE(bool) VBoxRectIsZero(const RTRECT *pRect)
66a94fee6b0acc21c078369f49d97020cc03ab11vboxsync return pRect->xLeft == pRect->xRight || pRect->yTop == pRect->yBottom;
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsyncDECLINLINE(bool) VBoxRectIsIntersect(const RTRECT * pRect1, const RTRECT * pRect2)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return !((pRect1->xLeft < pRect2->xLeft && pRect1->xRight <= pRect2->xLeft)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync || (pRect2->xLeft < pRect1->xLeft && pRect2->xRight <= pRect1->xLeft)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync || (pRect1->yTop < pRect2->yTop && pRect1->yBottom <= pRect2->yTop)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync || (pRect2->yTop < pRect1->yTop && pRect2->yBottom <= pRect1->yTop));
6902a98267d5180fb081cb5273751d0a628bf04dvboxsyncDECLINLINE(uint32_t) VBoxVrListRectsCount(const VBOXVR_LIST *pList)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsyncDECLINLINE(bool) VBoxVrListIsEmpty(const VBOXVR_LIST *pList)
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsyncVBOXVREGDECL(void) VBoxVrListClear(PVBOXVR_LIST pList);
d331ca5667e19a46f1e967617184483bec985e86vboxsync/* moves list data to pDstList and empties the pList */
d331ca5667e19a46f1e967617184483bec985e86vboxsyncVBOXVREGDECL(void) VBoxVrListMoveTo(PVBOXVR_LIST pList, PVBOXVR_LIST pDstList);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsyncVBOXVREGDECL(void) VBoxVrListTranslate(PVBOXVR_LIST pList, int32_t x, int32_t y);
8cfe2efff2058bd07777056112155ea5353dcfbavboxsyncVBOXVREGDECL(int) VBoxVrListCmp(const VBOXVR_LIST *pList1, const VBOXVR_LIST *pList2);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsyncVBOXVREGDECL(int) VBoxVrListRectsSet(PVBOXVR_LIST pList, uint32_t cRects, const RTRECT * aRects, bool *pfChanged);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsyncVBOXVREGDECL(int) VBoxVrListRectsAdd(PVBOXVR_LIST pList, uint32_t cRects, const RTRECT * aRects, bool *pfChanged);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsyncVBOXVREGDECL(int) VBoxVrListRectsSubst(PVBOXVR_LIST pList, uint32_t cRects, const RTRECT * aRects, bool *pfChanged);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsyncVBOXVREGDECL(int) VBoxVrListRectsGet(PVBOXVR_LIST pList, uint32_t cRects, RTRECT * aRects);
8cfe2efff2058bd07777056112155ea5353dcfbavboxsyncVBOXVREGDECL(int) VBoxVrListClone(const VBOXVR_LIST *pList, VBOXVR_LIST *pDstList);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync/* NOTE: with the current implementation the VBoxVrListIntersect is faster than VBoxVrListRectsIntersect,
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * i.e. VBoxVrListRectsIntersect is actually a convenience function that create a temporary list and calls VBoxVrListIntersect internally */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsyncVBOXVREGDECL(int) VBoxVrListRectsIntersect(PVBOXVR_LIST pList, uint32_t cRects, const RTRECT * aRects, bool *pfChanged);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsyncVBOXVREGDECL(int) VBoxVrListIntersect(PVBOXVR_LIST pList, const VBOXVR_LIST *pList2, bool *pfChanged);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsyncDECLINLINE(void) VBoxVrListIterInit(PVBOXVR_LIST pList, PVBOXVR_LIST_ITERATOR pIter)
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsynctypedef struct VBOXVR_REG
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync#define PVBOXVR_REG_FROM_ENTRY(_pEntry) ((PVBOXVR_REG)(((uint8_t*)(_pEntry)) - RT_OFFSETOF(VBOXVR_REG, ListEntry)))
6715b8ee12df87a566f92449a44e907ec10aef91vboxsyncDECLINLINE(PCRTRECT) VBoxVrListIterNext(PVBOXVR_LIST_ITERATOR pIter)
6715b8ee12df87a566f92449a44e907ec10aef91vboxsync PCRTRECT pRect = &(PVBOXVR_REG_FROM_ENTRY(pNextEntry)->Rect);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync} VBOXVR_COMPOSITOR_ENTRY, *PVBOXVR_COMPOSITOR_ENTRY;
ea1cc8df95dba6fca9c36c94f565ef95c7802a36vboxsynctypedef DECLCALLBACK(void) FNVBOXVRCOMPOSITOR_ENTRY_RELEASED(const struct VBOXVR_COMPOSITOR *pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, PVBOXVR_COMPOSITOR_ENTRY pReplacingEntry);
ea1cc8df95dba6fca9c36c94f565ef95c7802a36vboxsynctypedef FNVBOXVRCOMPOSITOR_ENTRY_RELEASED *PFNVBOXVRCOMPOSITOR_ENTRY_RELEASED;
ea1cc8df95dba6fca9c36c94f565ef95c7802a36vboxsync PFNVBOXVRCOMPOSITOR_ENTRY_RELEASED pfnEntryReleased;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsynctypedef DECLCALLBACK(bool) FNVBOXVRCOMPOSITOR_VISITOR(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, void *pvVisitor);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsynctypedef FNVBOXVRCOMPOSITOR_VISITOR *PFNVBOXVRCOMPOSITOR_VISITOR;
ea1cc8df95dba6fca9c36c94f565ef95c7802a36vboxsyncVBOXVREGDECL(void) VBoxVrCompositorInit(PVBOXVR_COMPOSITOR pCompositor, PFNVBOXVRCOMPOSITOR_ENTRY_RELEASED pfnEntryReleased);
8cfe2efff2058bd07777056112155ea5353dcfbavboxsyncVBOXVREGDECL(void) VBoxVrCompositorClear(PVBOXVR_COMPOSITOR pCompositor);
8cfe2efff2058bd07777056112155ea5353dcfbavboxsyncVBOXVREGDECL(void) VBoxVrCompositorRegionsClear(PVBOXVR_COMPOSITOR pCompositor, bool *pfChanged);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsyncVBOXVREGDECL(void) VBoxVrCompositorEntryInit(PVBOXVR_COMPOSITOR_ENTRY pEntry);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsyncDECLINLINE(bool) VBoxVrCompositorEntryIsInList(const VBOXVR_COMPOSITOR_ENTRY *pEntry)
8cfe2efff2058bd07777056112155ea5353dcfbavboxsync#define CRBLT_F_INVERT_YCOORDS (CRBLT_F_INVERT_SRC_YCOORDS | CRBLT_F_INVERT_DST_YCOORDS)
d7bd3e8bc4c337f385a92e0e5528525abba906c2vboxsync/* the blit operation with discard the source alpha channel values and set the destination alpha values to 1.0 */
8d1da51eb6665874aa82bf03668e03d1a0d63223vboxsync#define CRBLT_FTYPE_OR (CRBLT_F_LINEAR | CRBLT_F_NOALPHA)
8cfe2efff2058bd07777056112155ea5353dcfbavboxsync#define CRBLT_FOP_COMBINE(_f1, _f2) ((((_f1) ^ (_f2)) & CRBLT_FTYPE_XOR) | (((_f1) | (_f2)) & CRBLT_FTYPE_OR))
8cfe2efff2058bd07777056112155ea5353dcfbavboxsync#define CRBLT_FLAGS_FROM_FILTER(_f) ( ((_f) & GL_LINEAR) ? CRBLT_F_LINEAR : 0)
8cfe2efff2058bd07777056112155ea5353dcfbavboxsync#define CRBLT_FILTER_FROM_FLAGS(_f) (((_f) & CRBLT_F_LINEAR) ? GL_LINEAR : GL_NEAREST)
8cfe2efff2058bd07777056112155ea5353dcfbavboxsync/* compositor regions changed */
8cfe2efff2058bd07777056112155ea5353dcfbavboxsync#define VBOXVR_COMPOSITOR_CF_REGIONS_CHANGED 0x00000001
8cfe2efff2058bd07777056112155ea5353dcfbavboxsync/* other entries changed along while doing current entry modification
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * always comes with VBOXVR_COMPOSITOR_CF_ENTRY_REGIONS_CHANGED */
8cfe2efff2058bd07777056112155ea5353dcfbavboxsync#define VBOXVR_COMPOSITOR_CF_OTHER_ENTRIES_REGIONS_CHANGED 0x00000002
8cfe2efff2058bd07777056112155ea5353dcfbavboxsync/* only current entry regions changed
8cfe2efff2058bd07777056112155ea5353dcfbavboxsync * can come wither with VBOXVR_COMPOSITOR_CF_REGIONS_CHANGED or with VBOXVR_COMPOSITOR_CF_ENTRY_REPLACED */
8cfe2efff2058bd07777056112155ea5353dcfbavboxsync#define VBOXVR_COMPOSITOR_CF_ENTRY_REGIONS_CHANGED 0x00000004
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync/* the given entry has replaced some other entry, while overal regions did NOT change.
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * always comes with VBOXVR_COMPOSITOR_CF_ENTRY_REGIONS_CHANGED */
8cfe2efff2058bd07777056112155ea5353dcfbavboxsync#define VBOXVR_COMPOSITOR_CF_ENTRY_REPLACED 0x00000008
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsyncVBOXVREGDECL(bool) VBoxVrCompositorEntryRemove(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry);
d331ca5667e19a46f1e967617184483bec985e86vboxsyncVBOXVREGDECL(bool) VBoxVrCompositorEntryReplace(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, PVBOXVR_COMPOSITOR_ENTRY pNewEntry);
8cfe2efff2058bd07777056112155ea5353dcfbavboxsyncVBOXVREGDECL(int) VBoxVrCompositorEntryRegionsAdd(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, uint32_t cRegions, const RTRECT *paRegions, PVBOXVR_COMPOSITOR_ENTRY *ppReplacedEntry, uint32_t *pfChangeFlags);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsyncVBOXVREGDECL(int) VBoxVrCompositorEntryRegionsSubst(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, uint32_t cRegions, const RTRECT *paRegions, bool *pfChanged);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsyncVBOXVREGDECL(int) VBoxVrCompositorEntryRegionsSet(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, uint32_t cRegions, const RTRECT *paRegions, bool *pfChanged);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsyncVBOXVREGDECL(int) VBoxVrCompositorEntryRegionsIntersect(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, uint32_t cRegions, const RTRECT *paRegions, bool *pfChanged);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsyncVBOXVREGDECL(int) VBoxVrCompositorEntryListIntersect(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, const VBOXVR_LIST *pList2, bool *pfChanged);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsyncVBOXVREGDECL(int) VBoxVrCompositorEntryRegionsIntersectAll(PVBOXVR_COMPOSITOR pCompositor, uint32_t cRegions, const RTRECT *paRegions, bool *pfChanged);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsyncVBOXVREGDECL(int) VBoxVrCompositorEntryListIntersectAll(PVBOXVR_COMPOSITOR pCompositor, const VBOXVR_LIST *pList2, bool *pfChanged);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsyncVBOXVREGDECL(int) VBoxVrCompositorEntryRegionsTranslate(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, int32_t x, int32_t y, bool *pfChanged);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsyncVBOXVREGDECL(void) VBoxVrCompositorVisit(PVBOXVR_COMPOSITOR pCompositor, PFNVBOXVRCOMPOSITOR_VISITOR pfnVisitor, void *pvVisitor);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsyncDECLINLINE(bool) VBoxVrCompositorIsEmpty(const VBOXVR_COMPOSITOR *pCompositor)
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync} VBOXVR_COMPOSITOR_ITERATOR ,*PVBOXVR_COMPOSITOR_ITERATOR;
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync} VBOXVR_COMPOSITOR_CONST_ITERATOR ,*PVBOXVR_COMPOSITOR_CONST_ITERATOR;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsyncDECLINLINE(void) VBoxVrCompositorIterInit(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ITERATOR pIter)
01df41f7a4e5f7de195a059541d1c89676da9673vboxsyncDECLINLINE(void) VBoxVrCompositorConstIterInit(const VBOXVR_COMPOSITOR *pCompositor, PVBOXVR_COMPOSITOR_CONST_ITERATOR pIter)
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync#define VBOXVR_COMPOSITOR_ENTRY_FROM_NODE(_p) ((PVBOXVR_COMPOSITOR_ENTRY)(((uint8_t*)(_p)) - RT_OFFSETOF(VBOXVR_COMPOSITOR_ENTRY, Node)))
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync#define VBOXVR_COMPOSITOR_CONST_ENTRY_FROM_NODE(_p) ((const VBOXVR_COMPOSITOR_ENTRY*)(((uint8_t*)(_p)) - RT_OFFSETOF(VBOXVR_COMPOSITOR_ENTRY, Node)))
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsyncDECLINLINE(PVBOXVR_COMPOSITOR_ENTRY) VBoxVrCompositorIterNext(PVBOXVR_COMPOSITOR_ITERATOR pIter)
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync PVBOXVR_COMPOSITOR_ENTRY pEntry = VBOXVR_COMPOSITOR_ENTRY_FROM_NODE(pNextEntry);
01df41f7a4e5f7de195a059541d1c89676da9673vboxsyncDECLINLINE(const VBOXVR_COMPOSITOR_ENTRY*) VBoxVrCompositorConstIterNext(PVBOXVR_COMPOSITOR_CONST_ITERATOR pIter)
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync const VBOXVR_COMPOSITOR_ENTRY *pEntry = VBOXVR_COMPOSITOR_CONST_ENTRY_FROM_NODE(pNextEntry);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#endif /* #ifndef ___cr_vreg_h_ */