VirtualBox

Changeset 53590 in vbox


Ignore:
Timestamp:
Dec 21, 2014 4:26:37 PM (10 years ago)
Author:
vboxsync
Message:

Some style cleanups (no actual changes).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/OpenGL/include/cr_blitter.h

    r51141 r53590  
    11/* $Id$ */
    2 
    32/** @file
    4  * Blitter API
     3 * Blitter API.
    54 */
     5
    66/*
    7  * Copyright (C) 2013 Oracle Corporation
     7 * Copyright (C) 2013-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1515 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
    1616 */
     17
    1718#ifndef ___cr_blitter_h__
    1819#define ___cr_blitter_h__
     
    2021#include <iprt/cdefs.h>
    2122#include <iprt/asm.h>
    22 #include "cr_spu.h"
     23#include <iprt/string.h>
    2324#include "cr_vreg.h"
    24 
     25#ifdef IN_VMSVGA3D
     26# include <iprt/assert.h>
     27typedef struct TODO_VMSVGA3D_DISPATCH_TABLE SPUDispatchTable;
     28# include <OpenGL/OpenGL.h>
     29#else
     30# include "cr_spu.h"
     31#endif
     32
     33/** @todo r=bird: VBOXBLITTERDECL makes no sense. */
    2534#ifndef IN_RING0
    2635# define VBOXBLITTERDECL(_type) DECLEXPORT(_type)
     
    3847    GLuint bpp;
    3948    GLuint pitch;
    40 } CR_BLITTER_IMG, *PCR_BLITTER_IMG;
    41 
    42 VBOXBLITTERDECL(void) CrMClrFillImgRect(CR_BLITTER_IMG *pDst, const RTRECT *pCopyRect, uint32_t u32Color);
    43 VBOXBLITTERDECL(void) CrMClrFillImg(CR_BLITTER_IMG *pImg, uint32_t cRects, const RTRECT *pRects, uint32_t u32Color);
    44 VBOXBLITTERDECL(void) CrMBltImgRect(const CR_BLITTER_IMG *pSrc, const RTPOINT *pSrcDataPoint, bool fSrcInvert, const RTRECT *pCopyRect, CR_BLITTER_IMG *pDst);
    45 VBOXBLITTERDECL(void) CrMBltImg(const CR_BLITTER_IMG *pSrc, const RTPOINT *pPos, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pDst);
    46 VBOXBLITTERDECL(void) CrMBltImgRectScaled(const CR_BLITTER_IMG *pSrc, const RTPOINT *pPos, bool fSrcInvert, const RTRECT *pCopyRect, float strX, float strY, CR_BLITTER_IMG *pDst);
    47 VBOXBLITTERDECL(void) CrMBltImgScaled(const CR_BLITTER_IMG *pSrc, const RTRECTSIZE *pSrcRectSize, const RTRECT *pDstRect, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pDst);
    48 
    49 /* GLSL Cache */
     49} CR_BLITTER_IMG;
     50typedef CR_BLITTER_IMG *PCR_BLITTER_IMG;
     51typedef CR_BLITTER_IMG const *PCCR_BLITTER_IMG;
     52
     53VBOXBLITTERDECL(void) CrMClrFillImgRect(PCR_BLITTER_IMG pDst, PCRTRECT pCopyRect, uint32_t u32Color);
     54VBOXBLITTERDECL(void) CrMClrFillImg(PCR_BLITTER_IMG pImg, uint32_t cRects, PCRTRECT pRects, uint32_t u32Color);
     55VBOXBLITTERDECL(void) CrMBltImgRect(PCCR_BLITTER_IMG pSrc, PCRTPOINT pSrcDataPoint, bool fSrcInvert, PCRTRECT pCopyRect,
     56                                    PCR_BLITTER_IMG pDst);
     57VBOXBLITTERDECL(void) CrMBltImg(PCCR_BLITTER_IMG pSrc, PCRTPOINT pPos, uint32_t cRects, PCRTRECT pRects, PCR_BLITTER_IMG pDst);
     58VBOXBLITTERDECL(void) CrMBltImgRectScaled(PCCR_BLITTER_IMG pSrc, PCRTPOINT pPos, bool fSrcInvert, PCRTRECT pCopyRect,
     59                                          float strX, float strY, PCR_BLITTER_IMG pDst);
     60VBOXBLITTERDECL(void) CrMBltImgScaled(PCCR_BLITTER_IMG pSrc, PCRTRECTSIZE pSrcRectSize, PCRTRECT pDstRect, uint32_t cRects,
     61                                      PCRTRECT pRects, PCR_BLITTER_IMG pDst);
     62
     63/*
     64 * GLSL Cache
     65 */
    5066typedef struct CR_GLSL_CACHE
    5167{
     
    5571    SPUDispatchTable *pDispatch;
    5672} CR_GLSL_CACHE;
    57 
    58 DECLINLINE(void) CrGlslInit(CR_GLSL_CACHE *pCache, SPUDispatchTable *pDispatch)
    59 {
    60     memset(pCache, 0, sizeof (*pCache));
     73typedef CR_GLSL_CACHE *PCR_GLSL_CACHE;
     74typedef CR_GLSL_CACHE const *PCCR_GLSL_CACHE;
     75
     76DECLINLINE(void) CrGlslInit(PCR_GLSL_CACHE pCache, SPUDispatchTable *pDispatch)
     77{
     78    RT_ZERO(*pCache);
    6179    pCache->pDispatch = pDispatch;
    6280}
    6381
    64 DECLINLINE(bool) CrGlslIsInited(const CR_GLSL_CACHE *pCache)
     82DECLINLINE(bool) CrGlslIsInited(PCCR_GLSL_CACHE pCache)
    6583{
    6684    return !!pCache->pDispatch;
     
    6886
    6987/* clients should set proper context before calling these funcs */
    70 VBOXBLITTERDECL(bool) CrGlslIsSupported(CR_GLSL_CACHE *pCache);
    71 VBOXBLITTERDECL(int) CrGlslProgGenAllNoAlpha(CR_GLSL_CACHE *pCache);
    72 VBOXBLITTERDECL(int) CrGlslProgGenNoAlpha(CR_GLSL_CACHE *pCache, GLenum enmTexTarget);
    73 VBOXBLITTERDECL(int) CrGlslProgUseGenNoAlpha(CR_GLSL_CACHE *pCache, GLenum enmTexTarget);
    74 VBOXBLITTERDECL(int) CrGlslProgUseNoAlpha(const CR_GLSL_CACHE *pCache, GLenum enmTexTarget);
    75 VBOXBLITTERDECL(void) CrGlslProgClear(const CR_GLSL_CACHE *pCache);
    76 VBOXBLITTERDECL(bool) CrGlslNeedsCleanup(const CR_GLSL_CACHE *pCache);
    77 VBOXBLITTERDECL(void) CrGlslCleanup(CR_GLSL_CACHE *pCache);
    78 VBOXBLITTERDECL(void) CrGlslTerm(CR_GLSL_CACHE *pCache);
    79 
    80 /* BLITTER */
     88VBOXBLITTERDECL(bool) CrGlslIsSupported(PCR_GLSL_CACHE pCache);
     89VBOXBLITTERDECL(int)  CrGlslProgGenAllNoAlpha(PCR_GLSL_CACHE pCache);
     90VBOXBLITTERDECL(int)  CrGlslProgGenNoAlpha(PCR_GLSL_CACHE pCache, GLenum enmTexTarget);
     91VBOXBLITTERDECL(int)  CrGlslProgUseGenNoAlpha(PCR_GLSL_CACHE pCache, GLenum enmTexTarget);
     92VBOXBLITTERDECL(int)  CrGlslProgUseNoAlpha(PCCR_GLSL_CACHE pCache, GLenum enmTexTarget);
     93VBOXBLITTERDECL(void) CrGlslProgClear(PCCR_GLSL_CACHE pCache);
     94VBOXBLITTERDECL(bool) CrGlslNeedsCleanup(PCCR_GLSL_CACHE pCache);
     95VBOXBLITTERDECL(void) CrGlslCleanup(PCR_GLSL_CACHE pCache);
     96VBOXBLITTERDECL(void) CrGlslTerm(PCR_GLSL_CACHE pCache);
     97
     98/*
     99 * BLITTER
     100 */
    81101typedef struct CR_BLITTER_BUFFER
    82102{
    83103    GLuint cbBuffer;
    84     GLvoid * pvBuffer;
    85 } CR_BLITTER_BUFFER, *PCR_BLITTER_BUFFER;
     104    GLvoid *pvBuffer;
     105} CR_BLITTER_BUFFER;
     106typedef CR_BLITTER_BUFFER *PCR_BLITTER_BUFFER;
     107typedef CR_BLITTER_BUFFER const *PCCR_BLITTER_BUFFER;
    86108
    87109typedef union CR_BLITTER_FLAGS
     
    100122    };
    101123    uint32_t Value;
    102 } CR_BLITTER_FLAGS, *PCR_BLITTER_FLAGS;
     124} CR_BLITTER_FLAGS;
    103125
    104126struct CR_BLITTER;
    105127
    106 typedef DECLCALLBACK(int) FNCRBLT_BLITTER(struct CR_BLITTER *pBlitter, const VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRect, const RTRECTSIZE *pDstSize, const RTRECT *paDstRect, uint32_t cRects, uint32_t fFlags);
     128typedef DECLCALLBACK(int) FNCRBLT_BLITTER(struct CR_BLITTER *pBlitter, PCVBOXVR_TEXTURE pSrc, PCRTRECT paSrcRect,
     129                                          PCRTRECTSIZE pDstSize, PCRTRECT paDstRect, uint32_t cRects, uint32_t fFlags);
    107130typedef FNCRBLT_BLITTER *PFNCRBLT_BLITTER;
    108131
     
    116139{
    117140    CR_BLITTER_SPUITEM Base;
    118 } CR_BLITTER_CONTEXT, *PCR_BLITTER_CONTEXT;
     141} CR_BLITTER_CONTEXT;
     142typedef CR_BLITTER_CONTEXT *PCR_BLITTER_CONTEXT;
     143typedef CR_BLITTER_CONTEXT const *PCCR_BLITTER_CONTEXT;
    119144
    120145typedef struct CR_BLITTER_WINDOW
     
    122147    CR_BLITTER_SPUITEM Base;
    123148    GLuint width, height;
    124 } CR_BLITTER_WINDOW, *PCR_BLITTER_WINDOW;
     149} CR_BLITTER_WINDOW;
     150typedef CR_BLITTER_WINDOW *PCR_BLITTER_WINDOW;
     151typedef CR_BLITTER_WINDOW const *PCCR_BLITTER_WINDOW;
    125152
    126153typedef struct CR_BLITTER
     
    137164    int32_t i32MakeCurrentUserData;
    138165    SPUDispatchTable *pDispatch;
    139     const CR_GLSL_CACHE *pGlslCache;
     166    PCCR_GLSL_CACHE pGlslCache;
    140167    CR_GLSL_CACHE LocalGlslCache;
    141 } CR_BLITTER, *PCR_BLITTER;
     168} CR_BLITTER;
     169typedef CR_BLITTER *PCR_BLITTER;
     170typedef CR_BLITTER const *PCCR_BLITTER;
    142171
    143172DECLINLINE(GLboolean) CrBltIsInitialized(PCR_BLITTER pBlitter)
     
    146175}
    147176
    148 VBOXBLITTERDECL(int) CrBltInit(PCR_BLITTER pBlitter, const CR_BLITTER_CONTEXT *pCtxBase, bool fCreateNewCtx, bool fForceDrawBlt, const CR_GLSL_CACHE *pShaders, SPUDispatchTable *pDispatch);
     177VBOXBLITTERDECL(int)  CrBltInit(PCR_BLITTER pBlitter, PCCR_BLITTER_CONTEXT pCtxBase, bool fCreateNewCtx,
     178                                bool fForceDrawBlt, PCCR_GLSL_CACHE pShaders, SPUDispatchTable *pDispatch);
    149179
    150180VBOXBLITTERDECL(void) CrBltTerm(PCR_BLITTER pBlitter);
    151181
    152 VBOXBLITTERDECL(int) CrBltCleanup(PCR_BLITTER pBlitter);
     182VBOXBLITTERDECL(int)  CrBltCleanup(PCR_BLITTER pBlitter);
    153183
    154184DECLINLINE(GLboolean) CrBltSupportsTexTex(PCR_BLITTER pBlitter)
     
    178208}
    179209
    180 VBOXBLITTERDECL(int) CrBltMuralSetCurrentInfo(PCR_BLITTER pBlitter, const CR_BLITTER_WINDOW *pMural);
    181 DECLINLINE(const CR_BLITTER_WINDOW *) CrBltMuralGetCurrentInfo(PCR_BLITTER pBlitter)
     210VBOXBLITTERDECL(int) CrBltMuralSetCurrentInfo(PCR_BLITTER pBlitter, PCCR_BLITTER_WINDOW pMural);
     211
     212DECLINLINE(PCCR_BLITTER_WINDOW) CrBltMuralGetCurrentInfo(PCR_BLITTER pBlitter)
    182213{
    183214    return &pBlitter->CurrentMural;
     
    188219VBOXBLITTERDECL(void) CrBltLeave(PCR_BLITTER pBlitter);
    189220VBOXBLITTERDECL(int) CrBltEnter(PCR_BLITTER pBlitter);
    190 VBOXBLITTERDECL(void) CrBltBlitTexMural(PCR_BLITTER pBlitter, bool fBb, const VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRects, const RTRECT *paDstRects, uint32_t cRects, uint32_t fFlags);
    191 VBOXBLITTERDECL(void) CrBltBlitTexTex(PCR_BLITTER pBlitter, const VBOXVR_TEXTURE *pSrc, const RTRECT *pSrcRect, const VBOXVR_TEXTURE *pDst, const RTRECT *pDstRect, uint32_t cRects, uint32_t fFlags);
    192 VBOXBLITTERDECL(int) CrBltImgGetTex(PCR_BLITTER pBlitter, const VBOXVR_TEXTURE *pSrc, GLenum enmFormat, CR_BLITTER_IMG *pDst);
    193 
    194 VBOXBLITTERDECL(int) CrBltImgGetMural(PCR_BLITTER pBlitter, bool fBb, CR_BLITTER_IMG *pDst);
    195 VBOXBLITTERDECL(void) CrBltImgFree(PCR_BLITTER pBlitter, CR_BLITTER_IMG *pDst);
     221VBOXBLITTERDECL(void) CrBltBlitTexMural(PCR_BLITTER pBlitter, bool fBb, PCVBOXVR_TEXTURE pSrc, PCRTRECT paSrcRects,
     222                                        PCRTRECT paDstRects, uint32_t cRects, uint32_t fFlags);
     223VBOXBLITTERDECL(void) CrBltBlitTexTex(PCR_BLITTER pBlitter, PCVBOXVR_TEXTURE pSrc, PCRTRECT pSrcRect, PCVBOXVR_TEXTURE pDst,
     224                                      PCRTRECT pDstRect, uint32_t cRects, uint32_t fFlags);
     225VBOXBLITTERDECL(int) CrBltImgGetTex(PCR_BLITTER pBlitter, PCVBOXVR_TEXTURE pSrc, GLenum enmFormat, PCR_BLITTER_IMG pDst);
     226
     227VBOXBLITTERDECL(int) CrBltImgGetMural(PCR_BLITTER pBlitter, bool fBb, PCR_BLITTER_IMG pDst);
     228VBOXBLITTERDECL(void) CrBltImgFree(PCR_BLITTER pBlitter, PCR_BLITTER_IMG pDst);
    196229VBOXBLITTERDECL(void) CrBltPresent(PCR_BLITTER pBlitter);
    197230/* */
     
    212245    };
    213246    uint32_t Value;
    214 } CR_TEXDATA_FLAGS, *PCR_TEXDATA_FLAGS;
     247} CR_TEXDATA_FLAGS;
    215248
    216249
     
    228261    PFNCRTEXDATA_RELEASED pfnTextureReleased;
    229262    struct CR_TEXDATA *pScaledCache;
    230 } CR_TEXDATA, *PCR_TEXDATA;
    231 
    232 DECLINLINE(void) CrTdInit(PCR_TEXDATA pTex, const VBOXVR_TEXTURE *pVrTex, PCR_BLITTER pBlitter, PFNCRTEXDATA_RELEASED pfnTextureReleased)
     263} CR_TEXDATA;
     264typedef CR_TEXDATA *PCR_TEXDATA;
     265typedef CR_TEXDATA const *PCCR_TEXDATA;
     266
     267DECLINLINE(void) CrTdInit(PCR_TEXDATA pTex, PCVBOXVR_TEXTURE pVrTex, PCR_BLITTER pBlitter, PFNCRTEXDATA_RELEASED pfnTextureReleased)
    233268{
    234269    memset(pTex, 0, sizeof (*pTex));
     
    239274}
    240275
    241 DECLINLINE(const VBOXVR_TEXTURE*) CrTdTexGet(const CR_TEXDATA *pTex)
     276DECLINLINE(PCVBOXVR_TEXTURE) CrTdTexGet(PCCR_TEXDATA pTex)
    242277{
    243278    return &pTex->Tex;
    244279}
    245280
    246 DECLINLINE(PCR_BLITTER) CrTdBlitterGet(CR_TEXDATA *pTex)
     281DECLINLINE(PCR_BLITTER) CrTdBlitterGet(PCR_TEXDATA pTex)
    247282{
    248283    return pTex->pBlitter;
     
    252287{
    253288    int rc;
    254         if (pTex->Flags.Entered)
    255                 return VERR_INVALID_STATE;
    256         rc = CrBltEnter(pTex->pBlitter);
     289    if (pTex->Flags.Entered)
     290        return VERR_INVALID_STATE;
     291    rc = CrBltEnter(pTex->pBlitter);
     292#ifdef IN_VMSVGA3D
     293    AssertRCReturn(rc, rc);
     294#else
    257295    if (!RT_SUCCESS(rc))
    258296    {
     
    260298        return rc;
    261299    }
    262         pTex->Flags.Entered = 1;
    263         return VINF_SUCCESS;
     300#endif
     301    pTex->Flags.Entered = 1;
     302    return VINF_SUCCESS;
    264303}
    265304
    266305DECLINLINE(bool) CrTdBltIsEntered(PCR_TEXDATA pTex)
    267306{
    268         return pTex->Flags.Entered;
     307    return pTex->Flags.Entered;
    269308}
    270309
    271310DECLINLINE(void) CrTdBltLeave(PCR_TEXDATA pTex)
    272311{
    273         if (!pTex->Flags.Entered)
    274         {
    275                 WARN(("invalid Blt Leave"));
    276                 return;
    277         }
    278 
    279         CrBltLeave(pTex->pBlitter);
    280 
    281         pTex->Flags.Entered = 0;
     312#ifdef IN_VMSVGA3D
     313    AssertReturnVoid(pTex->Flags.Entered);
     314#else
     315    if (!pTex->Flags.Entered)
     316    {
     317        WARN(("invalid Blt Leave"));
     318        return;
     319    }
     320#endif
     321
     322    CrBltLeave(pTex->pBlitter);
     323
     324    pTex->Flags.Entered = 0;
    282325}
    283326
    284327/* the CrTdBltXxx calls are done with the entered blitter */
    285 /* acquire the texture data, returns the cached data in case it is cached.
    286  * the data remains cached in the CR_TEXDATA object until it is discarded with CrTdBltDataFree or CrTdBltDataCleanup.
    287  * */
    288 VBOXBLITTERDECL(int) CrTdBltDataAcquire(PCR_TEXDATA pTex, GLenum enmFormat, bool fInverted, const CR_BLITTER_IMG**ppImg);
    289 
    290 VBOXBLITTERDECL(int) CrTdBltDataAcquireScaled(PCR_TEXDATA pTex, GLenum enmFormat, bool fInverted, uint32_t width, uint32_t height, const CR_BLITTER_IMG**ppImg);
    291 
    292 VBOXBLITTERDECL(int) CrTdBltDataReleaseScaled(PCR_TEXDATA pTex, const CR_BLITTER_IMG *pImg);
     328/** Acquire the texture data, returns the cached data in case it is cached.
     329 * The data remains cached in the CR_TEXDATA object until it is discarded with
     330 * CrTdBltDataFree or CrTdBltDataCleanup. */
     331VBOXBLITTERDECL(int) CrTdBltDataAcquire(PCR_TEXDATA pTex, GLenum enmFormat, bool fInverted, PCCR_BLITTER_IMG *ppImg);
     332
     333VBOXBLITTERDECL(int) CrTdBltDataAcquireScaled(PCR_TEXDATA pTex, GLenum enmFormat, bool fInverted,
     334                                              uint32_t width, uint32_t height, PCCR_BLITTER_IMG *ppImg);
     335
     336VBOXBLITTERDECL(int) CrTdBltDataReleaseScaled(PCR_TEXDATA pTex, PCCR_BLITTER_IMG pImg);
    293337
    294338VBOXBLITTERDECL(void) CrTdBltScaleCacheMoveTo(PCR_TEXDATA pTex, PCR_TEXDATA pDstTex);
    295339
    296 /* release the texture data, the data remains cached in the CR_TEXDATA object until it is discarded with CrTdBltDataFree or CrTdBltDataCleanup */
     340/** Release the texture data, the data remains cached in the CR_TEXDATA object
     341 * until it is discarded with CrTdBltDataFree or CrTdBltDataCleanup. */
    297342VBOXBLITTERDECL(int) CrTdBltDataRelease(PCR_TEXDATA pTex);
    298 /* discard the texture data cached with previous CrTdBltDataAcquire.
    299  * Must be called wit data released (CrTdBltDataRelease) */
     343/** Discard the texture data cached with previous CrTdBltDataAcquire.
     344 * Must be called wit data released (CrTdBltDataRelease). */
    300345VBOXBLITTERDECL(int) CrTdBltDataFree(PCR_TEXDATA pTex);
    301346VBOXBLITTERDECL(int) CrTdBltDataFreeNe(PCR_TEXDATA pTex);
    302347VBOXBLITTERDECL(void) CrTdBltDataInvalidateNe(PCR_TEXDATA pTex);
    303 /* does same as CrTdBltDataFree, and in addition cleans up.
    304  * this is kind of a texture destructor, which clients should call on texture object destruction, e.g. from the PFNCRTEXDATA_RELEASED callback */
     348/** Does same as CrTdBltDataFree, and in addition cleans up.
     349 * This is kind of a texture destructor, which clients should call on texture object destruction,
     350 * e.g. from the PFNCRTEXDATA_RELEASED callback. */
    305351VBOXBLITTERDECL(int) CrTdBltDataCleanup(PCR_TEXDATA pTex);
    306352
     
    321367        else
    322368            CrTdBltDataCleanupNe(pTex);
    323         }
     369    }
    324370
    325371    return cRefs;
     
    328374RT_C_DECLS_END
    329375
    330 #endif /* #ifndef ___cr_blitter_h__ */
     376#endif
     377
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette