cr_vreg.h revision b554f49f62cfc1184e3b4b49ec337eceffafbb71
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync/* $Id$ */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync/** @file
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * Visible Regions processing API
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync/*
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * Copyright (C) 2012 Oracle Corporation
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync *
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.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#ifndef ___cr_vreg_h_
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#define ___cr_vreg_h_
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#include <iprt/list.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#include <iprt/types.h>
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync#include <iprt/mem.h>
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync#include <iprt/string.h>
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync#include <iprt/assert.h>
8be5264d31d6a6ec949ff2285764c9af57298b52vboxsync#include <iprt/critsect.h>
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync#include <iprt/asm.h>
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync#ifndef IN_RING0
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync# define VBOXVREGDECL(_type) DECLEXPORT(_type)
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync#else
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync# define VBOXVREGDECL(_type) RTDECL(_type)
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync#endif
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsyncRT_C_DECLS_BEGIN
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsynctypedef struct VBOXVR_LIST
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync{
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync RTLISTNODE ListHead;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync uint32_t cEntries;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync} VBOXVR_LIST, *PVBOXVR_LIST;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsyncDECLINLINE(int) VBoxRectCmp(const RTRECT * pRect1, const RTRECT * pRect2)
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync{
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync return memcmp(pRect1, pRect2, sizeof (*pRect1));
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync}
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync
8d1da51eb6665874aa82bf03668e03d1a0d63223vboxsync#ifndef IN_RING0
8d1da51eb6665874aa82bf03668e03d1a0d63223vboxsyncDECLINLINE(void) VBoxRectStretch(PRTRECT pRect, float xStretch, float yStretch)
8d1da51eb6665874aa82bf03668e03d1a0d63223vboxsync{
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync pRect->xLeft = (int32_t)(pRect->xLeft * xStretch);
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync pRect->yTop = (int32_t)(pRect->yTop * yStretch);
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync pRect->xRight = (int32_t)(pRect->xRight * xStretch);
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync pRect->yBottom = (int32_t)(pRect->yBottom * yStretch);
8d1da51eb6665874aa82bf03668e03d1a0d63223vboxsync}
8d1da51eb6665874aa82bf03668e03d1a0d63223vboxsync
8d1da51eb6665874aa82bf03668e03d1a0d63223vboxsyncDECLINLINE(void) VBoxRectStretched(const RTRECT *pRect, float xStretch, float yStretch, PRTRECT pResult)
8d1da51eb6665874aa82bf03668e03d1a0d63223vboxsync{
8d1da51eb6665874aa82bf03668e03d1a0d63223vboxsync *pResult = *pRect;
8d1da51eb6665874aa82bf03668e03d1a0d63223vboxsync VBoxRectStretch(pResult, xStretch, yStretch);
8d1da51eb6665874aa82bf03668e03d1a0d63223vboxsync}
8d1da51eb6665874aa82bf03668e03d1a0d63223vboxsync#endif
8d1da51eb6665874aa82bf03668e03d1a0d63223vboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsyncDECLINLINE(void) VBoxRectIntersect(PRTRECT pRect1, const RTRECT * pRect2)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync{
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync Assert(pRect1);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync Assert(pRect2);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync pRect1->xLeft = RT_MAX(pRect1->xLeft, pRect2->xLeft);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync pRect1->yTop = RT_MAX(pRect1->yTop, pRect2->yTop);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync pRect1->xRight = RT_MIN(pRect1->xRight, pRect2->xRight);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync pRect1->yBottom = RT_MIN(pRect1->yBottom, pRect2->yBottom);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync}
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsyncDECLINLINE(void) VBoxRectIntersected(const RTRECT *pRect1, const RTRECT * pRect2, RTRECT *pResult)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync{
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync *pResult = *pRect1;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync VBoxRectIntersect(pResult, pRect2);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync}
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsyncDECLINLINE(void) VBoxRectTranslate(RTRECT * pRect, int32_t x, int32_t y)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync{
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync pRect->xLeft += x;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync pRect->yTop += y;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync pRect->xRight += x;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync pRect->yBottom += y;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync}
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
7b6926b2bf44f326f40e1d9d1ce33a4dff0a2c67vboxsyncDECLINLINE(void) VBoxRectTranslated(const RTRECT * pRect, int32_t x, int32_t y, RTRECT *pResult)
7b6926b2bf44f326f40e1d9d1ce33a4dff0a2c67vboxsync{
7b6926b2bf44f326f40e1d9d1ce33a4dff0a2c67vboxsync *pResult = *pRect;
7b6926b2bf44f326f40e1d9d1ce33a4dff0a2c67vboxsync VBoxRectTranslate(pResult, x, y);
7b6926b2bf44f326f40e1d9d1ce33a4dff0a2c67vboxsync}
7b6926b2bf44f326f40e1d9d1ce33a4dff0a2c67vboxsync
24e27201b1438d88569467f104a0e3cb1df190edvboxsyncDECLINLINE(void) VBoxRectInvertY(RTRECT * pRect)
24e27201b1438d88569467f104a0e3cb1df190edvboxsync{
24e27201b1438d88569467f104a0e3cb1df190edvboxsync int32_t y = pRect->yTop;
24e27201b1438d88569467f104a0e3cb1df190edvboxsync pRect->yTop = pRect->yBottom;
24e27201b1438d88569467f104a0e3cb1df190edvboxsync pRect->yBottom = y;
24e27201b1438d88569467f104a0e3cb1df190edvboxsync}
24e27201b1438d88569467f104a0e3cb1df190edvboxsync
24e27201b1438d88569467f104a0e3cb1df190edvboxsyncDECLINLINE(void) VBoxRectInvertedY(const RTRECT * pRect, RTRECT * pResult)
24e27201b1438d88569467f104a0e3cb1df190edvboxsync{
24e27201b1438d88569467f104a0e3cb1df190edvboxsync *pResult = *pRect;
24e27201b1438d88569467f104a0e3cb1df190edvboxsync VBoxRectInvertY(pResult);
24e27201b1438d88569467f104a0e3cb1df190edvboxsync}
24e27201b1438d88569467f104a0e3cb1df190edvboxsync
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsyncDECLINLINE(void) VBoxRectMove(RTRECT * pRect, int32_t x, int32_t y)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync{
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync int32_t w = pRect->xRight - pRect->xLeft;
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync int32_t h = pRect->yBottom - pRect->yTop;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync pRect->xLeft = x;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync pRect->yTop = y;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync pRect->xRight = w + x;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync pRect->yBottom = h + y;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync}
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
7b6926b2bf44f326f40e1d9d1ce33a4dff0a2c67vboxsyncDECLINLINE(void) VBoxRectMoved(const RTRECT * pRect, int32_t x, int32_t y, RTRECT *pResult)
7b6926b2bf44f326f40e1d9d1ce33a4dff0a2c67vboxsync{
7b6926b2bf44f326f40e1d9d1ce33a4dff0a2c67vboxsync *pResult = *pRect;
7b6926b2bf44f326f40e1d9d1ce33a4dff0a2c67vboxsync VBoxRectMove(pResult, x, y);
7b6926b2bf44f326f40e1d9d1ce33a4dff0a2c67vboxsync}
7b6926b2bf44f326f40e1d9d1ce33a4dff0a2c67vboxsync
878e6d9047ecb951fb66b8923976ae616d994f61vboxsyncDECLINLINE(bool) VBoxRectCovers(const RTRECT *pRect, const RTRECT *pCovered)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync{
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync Assert(pRect);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync Assert(pCovered);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync if (pRect->xLeft > pCovered->xLeft)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return false;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync if (pRect->yTop > pCovered->yTop)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return false;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync if (pRect->xRight < pCovered->xRight)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return false;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync if (pRect->yBottom < pCovered->yBottom)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return false;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return true;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync}
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
66a94fee6b0acc21c078369f49d97020cc03ab11vboxsyncDECLINLINE(bool) VBoxRectIsZero(const RTRECT *pRect)
66a94fee6b0acc21c078369f49d97020cc03ab11vboxsync{
66a94fee6b0acc21c078369f49d97020cc03ab11vboxsync return pRect->xLeft == pRect->xRight || pRect->yTop == pRect->yBottom;
66a94fee6b0acc21c078369f49d97020cc03ab11vboxsync}
66a94fee6b0acc21c078369f49d97020cc03ab11vboxsync
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsyncDECLINLINE(bool) VBoxRectIsIntersect(const RTRECT * pRect1, const RTRECT * pRect2)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync{
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));
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync}
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsyncDECLINLINE(uint32_t) VBoxVrListRectsCount(const VBOXVR_LIST *pList)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync{
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return pList->cEntries;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync}
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsyncDECLINLINE(bool) VBoxVrListIsEmpty(const VBOXVR_LIST *pList)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync{
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return !VBoxVrListRectsCount(pList);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync}
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsyncDECLINLINE(void) VBoxVrListInit(PVBOXVR_LIST pList)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync{
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync RTListInit(&pList->ListHead);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync pList->cEntries = 0;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync}
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsyncVBOXVREGDECL(void) VBoxVrListClear(PVBOXVR_LIST pList);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
d331ca5667e19a46f1e967617184483bec985e86vboxsync/* moves list data to pDstList and empties the pList */
d331ca5667e19a46f1e967617184483bec985e86vboxsyncVBOXVREGDECL(void) VBoxVrListMoveTo(PVBOXVR_LIST pList, PVBOXVR_LIST pDstList);
d331ca5667e19a46f1e967617184483bec985e86vboxsync
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsyncVBOXVREGDECL(void) VBoxVrListTranslate(PVBOXVR_LIST pList, int32_t x, int32_t y);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
8cfe2efff2058bd07777056112155ea5353dcfbavboxsyncVBOXVREGDECL(int) VBoxVrListCmp(const VBOXVR_LIST *pList1, const VBOXVR_LIST *pList2);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
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);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync
8cfe2efff2058bd07777056112155ea5353dcfbavboxsyncVBOXVREGDECL(int) VBoxVrListClone(const VBOXVR_LIST *pList, VBOXVR_LIST *pDstList);
8cfe2efff2058bd07777056112155ea5353dcfbavboxsync
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);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
b554f49f62cfc1184e3b4b49ec337eceffafbb71vboxsyncVBOXVREGDECL(int) VBoxVrInit(void);
b554f49f62cfc1184e3b4b49ec337eceffafbb71vboxsyncVBOXVREGDECL(void) VBoxVrTerm(void);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsynctypedef struct VBOXVR_LIST_ITERATOR
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync{
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync PVBOXVR_LIST pList;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync PRTLISTNODE pNextEntry;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync} VBOXVR_LIST_ITERATOR, *PVBOXVR_LIST_ITERATOR;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsyncDECLINLINE(void) VBoxVrListIterInit(PVBOXVR_LIST pList, PVBOXVR_LIST_ITERATOR pIter)
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync{
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync pIter->pList = pList;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync pIter->pNextEntry = pList->ListHead.pNext;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync}
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsynctypedef struct VBOXVR_REG
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync{
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync RTLISTNODE ListEntry;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync RTRECT Rect;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync} VBOXVR_REG, *PVBOXVR_REG;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync#define PVBOXVR_REG_FROM_ENTRY(_pEntry) ((PVBOXVR_REG)(((uint8_t*)(_pEntry)) - RT_OFFSETOF(VBOXVR_REG, ListEntry)))
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
6715b8ee12df87a566f92449a44e907ec10aef91vboxsyncDECLINLINE(PCRTRECT) VBoxVrListIterNext(PVBOXVR_LIST_ITERATOR pIter)
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync{
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync PRTLISTNODE pNextEntry = pIter->pNextEntry;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync if (pNextEntry != &pIter->pList->ListHead)
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync {
6715b8ee12df87a566f92449a44e907ec10aef91vboxsync PCRTRECT pRect = &(PVBOXVR_REG_FROM_ENTRY(pNextEntry)->Rect);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync pIter->pNextEntry = pNextEntry->pNext;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync return pRect;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync }
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync return NULL;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync}
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsynctypedef struct VBOXVR_COMPOSITOR_ENTRY
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync{
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync RTLISTNODE Node;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync VBOXVR_LIST Vr;
ea1cc8df95dba6fca9c36c94f565ef95c7802a36vboxsync uint32_t cRefs;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync} VBOXVR_COMPOSITOR_ENTRY, *PVBOXVR_COMPOSITOR_ENTRY;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsyncstruct VBOXVR_COMPOSITOR;
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync
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;
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsynctypedef struct VBOXVR_COMPOSITOR
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync{
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync RTLISTNODE List;
ea1cc8df95dba6fca9c36c94f565ef95c7802a36vboxsync PFNVBOXVRCOMPOSITOR_ENTRY_RELEASED pfnEntryReleased;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync} VBOXVR_COMPOSITOR, *PVBOXVR_COMPOSITOR;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsynctypedef DECLCALLBACK(bool) FNVBOXVRCOMPOSITOR_VISITOR(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, void *pvVisitor);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsynctypedef FNVBOXVRCOMPOSITOR_VISITOR *PFNVBOXVRCOMPOSITOR_VISITOR;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
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)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync{
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return !VBoxVrListIsEmpty(&pEntry->Vr);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync}
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync
8cfe2efff2058bd07777056112155ea5353dcfbavboxsync#define CRBLT_F_LINEAR 0x00000001
8cfe2efff2058bd07777056112155ea5353dcfbavboxsync#define CRBLT_F_INVERT_SRC_YCOORDS 0x00000002
8cfe2efff2058bd07777056112155ea5353dcfbavboxsync#define CRBLT_F_INVERT_DST_YCOORDS 0x00000004
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 */
d7bd3e8bc4c337f385a92e0e5528525abba906c2vboxsync#define CRBLT_F_NOALPHA 0x00000010
8cfe2efff2058bd07777056112155ea5353dcfbavboxsync
8cfe2efff2058bd07777056112155ea5353dcfbavboxsync#define CRBLT_FTYPE_XOR CRBLT_F_INVERT_YCOORDS
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
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
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
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync
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);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsyncDECLINLINE(bool) VBoxVrCompositorIsEmpty(const VBOXVR_COMPOSITOR *pCompositor)
6ee161d72f994dd23bce113a7b1aef8fe60c1766vboxsync{
6ee161d72f994dd23bce113a7b1aef8fe60c1766vboxsync return RTListIsEmpty(&pCompositor->List);
6ee161d72f994dd23bce113a7b1aef8fe60c1766vboxsync}
6ee161d72f994dd23bce113a7b1aef8fe60c1766vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsynctypedef struct VBOXVR_COMPOSITOR_ITERATOR
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync{
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync PVBOXVR_COMPOSITOR pCompositor;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync PRTLISTNODE pNextEntry;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync} VBOXVR_COMPOSITOR_ITERATOR ,*PVBOXVR_COMPOSITOR_ITERATOR;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
01df41f7a4e5f7de195a059541d1c89676da9673vboxsynctypedef struct VBOXVR_COMPOSITOR_CONST_ITERATOR
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync{
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync const VBOXVR_COMPOSITOR *pCompositor;
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync const RTLISTNODE *pNextEntry;
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync} VBOXVR_COMPOSITOR_CONST_ITERATOR ,*PVBOXVR_COMPOSITOR_CONST_ITERATOR;
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsyncDECLINLINE(void) VBoxVrCompositorIterInit(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ITERATOR pIter)
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync{
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync pIter->pCompositor = pCompositor;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync pIter->pNextEntry = pCompositor->List.pNext;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync}
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
01df41f7a4e5f7de195a059541d1c89676da9673vboxsyncDECLINLINE(void) VBoxVrCompositorConstIterInit(const VBOXVR_COMPOSITOR *pCompositor, PVBOXVR_COMPOSITOR_CONST_ITERATOR pIter)
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync{
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync pIter->pCompositor = pCompositor;
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync pIter->pNextEntry = pCompositor->List.pNext;
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync}
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync
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)))
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsyncDECLINLINE(PVBOXVR_COMPOSITOR_ENTRY) VBoxVrCompositorIterNext(PVBOXVR_COMPOSITOR_ITERATOR pIter)
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync{
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync PRTLISTNODE pNextEntry = pIter->pNextEntry;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync if (pNextEntry != &pIter->pCompositor->List)
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync {
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync PVBOXVR_COMPOSITOR_ENTRY pEntry = VBOXVR_COMPOSITOR_ENTRY_FROM_NODE(pNextEntry);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync pIter->pNextEntry = pNextEntry->pNext;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync return pEntry;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync }
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync return NULL;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync}
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
01df41f7a4e5f7de195a059541d1c89676da9673vboxsyncDECLINLINE(const VBOXVR_COMPOSITOR_ENTRY*) VBoxVrCompositorConstIterNext(PVBOXVR_COMPOSITOR_CONST_ITERATOR pIter)
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync{
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync const RTLISTNODE *pNextEntry = pIter->pNextEntry;
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync if (pNextEntry != &pIter->pCompositor->List)
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync {
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync const VBOXVR_COMPOSITOR_ENTRY *pEntry = VBOXVR_COMPOSITOR_CONST_ENTRY_FROM_NODE(pNextEntry);
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync pIter->pNextEntry = pNextEntry->pNext;
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync return pEntry;
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync }
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync return NULL;
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync}
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsynctypedef struct VBOXVR_TEXTURE
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync{
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync int32_t width;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync int32_t height;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync uint32_t target;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync uint32_t hwid;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync} VBOXVR_TEXTURE, *PVBOXVR_TEXTURE;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsyncRT_C_DECLS_END
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#endif /* #ifndef ___cr_vreg_h_ */