mirror of
https://github.com/reactos/reactos.git
synced 2025-06-01 15:38:37 +00:00
[WIN32K]
- Implement SURFACE_vSetPalette and use it everywhere to set the palette for a surface. Make SURFACE::ppal const, so noone accidentally modifies it without properly handling the references. svn path=/trunk/; revision=56816
This commit is contained in:
parent
7bd9006bf1
commit
0ed94ccae0
4 changed files with 41 additions and 18 deletions
|
@ -267,8 +267,7 @@ SURFACE_AllocSurface(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Assign a default palette and increment its reference count */
|
/* Assign a default palette and increment its reference count */
|
||||||
psurf->ppal = appalSurfaceDefault[iFormat];
|
SURFACE_vSetPalette(psurf, appalSurfaceDefault[iFormat]);
|
||||||
GDIOBJ_vReferenceObjectByPointer(&psurf->ppal->BaseObject);
|
|
||||||
|
|
||||||
return psurf;
|
return psurf;
|
||||||
}
|
}
|
||||||
|
@ -399,6 +398,7 @@ EngAssociateSurface(
|
||||||
SURFOBJ *pso;
|
SURFOBJ *pso;
|
||||||
PSURFACE psurf;
|
PSURFACE psurf;
|
||||||
PDEVOBJ* ppdev;
|
PDEVOBJ* ppdev;
|
||||||
|
PPALETTE ppal;
|
||||||
|
|
||||||
ppdev = (PDEVOBJ*)hdev;
|
ppdev = (PDEVOBJ*)hdev;
|
||||||
|
|
||||||
|
@ -418,8 +418,10 @@ EngAssociateSurface(
|
||||||
psurf->flags &= ~HOOK_FLAGS;
|
psurf->flags &= ~HOOK_FLAGS;
|
||||||
psurf->flags |= (flHooks & HOOK_FLAGS);
|
psurf->flags |= (flHooks & HOOK_FLAGS);
|
||||||
|
|
||||||
/* Get palette */
|
/* Assign the PDEV's palette */
|
||||||
psurf->ppal = PALETTE_ShareLockPalette(ppdev->devinfo.hpalDefault);
|
ppal = PALETTE_ShareLockPalette(ppdev->devinfo.hpalDefault);
|
||||||
|
SURFACE_vSetPalette(psurf, ppal);
|
||||||
|
PALETTE_ShareUnlockPalette(ppal);
|
||||||
|
|
||||||
SURFACE_ShareUnlockSurface(psurf);
|
SURFACE_ShareUnlockSurface(psurf);
|
||||||
|
|
||||||
|
@ -441,6 +443,7 @@ EngModifySurface(
|
||||||
SURFOBJ *pso;
|
SURFOBJ *pso;
|
||||||
PSURFACE psurf;
|
PSURFACE psurf;
|
||||||
PDEVOBJ* ppdev;
|
PDEVOBJ* ppdev;
|
||||||
|
PPALETTE ppal;
|
||||||
|
|
||||||
psurf = SURFACE_ShareLockSurface(hsurf);
|
psurf = SURFACE_ShareLockSurface(hsurf);
|
||||||
if (psurf == NULL)
|
if (psurf == NULL)
|
||||||
|
@ -462,8 +465,10 @@ EngModifySurface(
|
||||||
psurf->flags &= ~HOOK_FLAGS;
|
psurf->flags &= ~HOOK_FLAGS;
|
||||||
psurf->flags |= (flHooks & HOOK_FLAGS);
|
psurf->flags |= (flHooks & HOOK_FLAGS);
|
||||||
|
|
||||||
/* Get palette */
|
/* Assign the PDEV's palette */
|
||||||
psurf->ppal = PALETTE_ShareLockPalette(ppdev->devinfo.hpalDefault);
|
ppal = PALETTE_ShareLockPalette(ppdev->devinfo.hpalDefault);
|
||||||
|
SURFACE_vSetPalette(psurf, ppal);
|
||||||
|
PALETTE_ShareUnlockPalette(ppal);
|
||||||
|
|
||||||
SURFACE_ShareUnlockSurface(psurf);
|
SURFACE_ShareUnlockSurface(psurf);
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ typedef struct _SURFACE
|
||||||
SURFOBJ SurfObj;
|
SURFOBJ SurfObj;
|
||||||
//XDCOBJ * pdcoAA;
|
//XDCOBJ * pdcoAA;
|
||||||
FLONG flags;
|
FLONG flags;
|
||||||
struct _PALETTE *ppal;
|
struct _PALETTE * const ppal; // Use SURFACE_vSetPalette to assign a palette
|
||||||
//UINT unk_050;
|
//UINT unk_050;
|
||||||
|
|
||||||
union
|
union
|
||||||
|
@ -123,3 +123,17 @@ SURFACE_AllocSurface(
|
||||||
_In_ ULONG fjBitmap,
|
_In_ ULONG fjBitmap,
|
||||||
_In_opt_ ULONG cjWidth,
|
_In_opt_ ULONG cjWidth,
|
||||||
_In_opt_ PVOID pvBits);
|
_In_opt_ PVOID pvBits);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
FORCEINLINE
|
||||||
|
SURFACE_vSetPalette(
|
||||||
|
_Inout_ PSURFACE psurf,
|
||||||
|
_In_ PPALETTE ppal)
|
||||||
|
{
|
||||||
|
if (psurf->ppal)
|
||||||
|
GDIOBJ_vDereferenceObject((POBJ)psurf->ppal);
|
||||||
|
if (ppal)
|
||||||
|
GDIOBJ_vReferenceObjectByPointer((POBJ)ppal);
|
||||||
|
*(PVOID*)&psurf->ppal = ppal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -223,6 +223,7 @@ IntCreateCompatibleBitmap(
|
||||||
INT Height)
|
INT Height)
|
||||||
{
|
{
|
||||||
HBITMAP Bmp = NULL;
|
HBITMAP Bmp = NULL;
|
||||||
|
PPALETTE ppal;
|
||||||
|
|
||||||
/* MS doc says if width or height is 0, return 1-by-1 pixel, monochrome bitmap */
|
/* MS doc says if width or height is 0, return 1-by-1 pixel, monochrome bitmap */
|
||||||
if (0 == Width || 0 == Height)
|
if (0 == Width || 0 == Height)
|
||||||
|
@ -241,8 +242,13 @@ IntCreateCompatibleBitmap(
|
||||||
NULL);
|
NULL);
|
||||||
psurf = SURFACE_ShareLockSurface(Bmp);
|
psurf = SURFACE_ShareLockSurface(Bmp);
|
||||||
ASSERT(psurf);
|
ASSERT(psurf);
|
||||||
/* Set palette */
|
|
||||||
psurf->ppal = PALETTE_ShareLockPalette(Dc->ppdev->devinfo.hpalDefault);
|
/* Dereference old palette and set new palette */
|
||||||
|
ppal = PALETTE_ShareLockPalette(Dc->ppdev->devinfo.hpalDefault);
|
||||||
|
ASSERT(ppal);
|
||||||
|
SURFACE_vSetPalette(psurf, ppal);
|
||||||
|
PALETTE_ShareUnlockPalette(ppal);
|
||||||
|
|
||||||
/* Set flags */
|
/* Set flags */
|
||||||
psurf->flags = API_BITMAP;
|
psurf->flags = API_BITMAP;
|
||||||
psurf->hdc = NULL; // FIXME:
|
psurf->hdc = NULL; // FIXME:
|
||||||
|
@ -266,9 +272,10 @@ IntCreateCompatibleBitmap(
|
||||||
NULL);
|
NULL);
|
||||||
psurfBmp = SURFACE_ShareLockSurface(Bmp);
|
psurfBmp = SURFACE_ShareLockSurface(Bmp);
|
||||||
ASSERT(psurfBmp);
|
ASSERT(psurfBmp);
|
||||||
/* Assign palette */
|
|
||||||
psurfBmp->ppal = psurf->ppal;
|
/* Dereference old palette and set new palette */
|
||||||
GDIOBJ_vReferenceObjectByPointer((POBJ)psurf->ppal);
|
SURFACE_vSetPalette(psurfBmp, psurf->ppal);
|
||||||
|
|
||||||
/* Set flags */
|
/* Set flags */
|
||||||
psurfBmp->flags = API_BITMAP;
|
psurfBmp->flags = API_BITMAP;
|
||||||
psurfBmp->hdc = NULL; // FIXME:
|
psurfBmp->hdc = NULL; // FIXME:
|
||||||
|
@ -622,12 +629,9 @@ BITMAP_CopyBitmap(HBITMAP hBitmap)
|
||||||
psurfSrc->SurfObj.pvBits,
|
psurfSrc->SurfObj.pvBits,
|
||||||
psurfNew->SurfObj.cjBits);
|
psurfNew->SurfObj.cjBits);
|
||||||
|
|
||||||
/* Dereference the new bitmaps palette, we will use a different */
|
|
||||||
GDIOBJ_vDereferenceObject(&psurfNew->ppal->BaseObject);
|
|
||||||
|
|
||||||
/* Reference the palette of the source bitmap and use it */
|
/* Reference the palette of the source bitmap and use it */
|
||||||
GDIOBJ_vReferenceObjectByPointer(&psurfSrc->ppal->BaseObject);
|
SURFACE_vSetPalette(psurfNew, psurfSrc->ppal);
|
||||||
psurfNew->ppal = psurfSrc->ppal;
|
|
||||||
|
|
||||||
/* Unlock the new surface */
|
/* Unlock the new surface */
|
||||||
SURFACE_ShareUnlockSurface(psurfNew);
|
SURFACE_ShareUnlockSurface(psurfNew);
|
||||||
|
|
|
@ -1599,8 +1599,8 @@ DIB_CreateDIBSection(
|
||||||
ppalDIB = CreateDIBPalette(bmi, dc, usage);
|
ppalDIB = CreateDIBPalette(bmi, dc, usage);
|
||||||
if (ppalDIB)
|
if (ppalDIB)
|
||||||
{
|
{
|
||||||
if (bmp->ppal) PALETTE_ShareUnlockPalette(bmp->ppal);
|
SURFACE_vSetPalette(bmp, ppalDIB);
|
||||||
bmp->ppal = ppalDIB;
|
PALETTE_ShareUnlockPalette(ppalDIB);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean up in case of errors
|
// Clean up in case of errors
|
||||||
|
|
Loading…
Reference in a new issue