mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-30 05:08:30 +00:00
gdiplus: Do not store HDC on HWND Graphics objects.
This commit is contained in:
parent
8c04e7c0cc
commit
f20a1bb94f
|
@ -665,7 +665,7 @@ static inline void image_unlock(GpImage *image)
|
|||
|
||||
static inline BOOL has_gdi_dc(GpGraphics *graphics)
|
||||
{
|
||||
return graphics->hdc != NULL;
|
||||
return graphics->hdc != NULL || graphics->owndc;
|
||||
}
|
||||
|
||||
static inline void set_rect(GpRectF *rect, REAL x, REAL y, REAL width, REAL height)
|
||||
|
|
|
@ -55,6 +55,14 @@ GpStatus gdi_dc_acquire(GpGraphics *graphics, HDC *hdc)
|
|||
graphics->hdc_refs++;
|
||||
return Ok;
|
||||
}
|
||||
else if (graphics->owndc)
|
||||
{
|
||||
*hdc = graphics->hdc = GetDC(graphics->hwnd);
|
||||
if (!graphics->hdc)
|
||||
return OutOfMemory;
|
||||
graphics->hdc_refs++;
|
||||
return Ok;
|
||||
}
|
||||
|
||||
*hdc = NULL;
|
||||
return InvalidParameter;
|
||||
|
@ -64,6 +72,13 @@ void gdi_dc_release(GpGraphics *graphics, HDC hdc)
|
|||
{
|
||||
assert(graphics->hdc_refs > 0);
|
||||
graphics->hdc_refs--;
|
||||
|
||||
if (graphics->owndc && !graphics->hdc_refs)
|
||||
{
|
||||
assert(graphics->hdc == hdc);
|
||||
graphics->hdc = NULL;
|
||||
ReleaseDC(graphics->hwnd, hdc);
|
||||
}
|
||||
}
|
||||
|
||||
static GpStatus draw_driver_string(GpGraphics *graphics, GDIPCONST UINT16 *text, INT length,
|
||||
|
@ -2556,6 +2571,9 @@ GpStatus WINGDIPAPI GdipCreateFromHWND(HWND hwnd, GpGraphics **graphics)
|
|||
(*graphics)->hwnd = hwnd;
|
||||
(*graphics)->owndc = TRUE;
|
||||
|
||||
ReleaseDC(hwnd, hdc);
|
||||
(*graphics)->hdc = NULL;
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
|
@ -2610,13 +2628,13 @@ GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
|
|||
|
||||
if (graphics->temp_hdc)
|
||||
{
|
||||
DeleteDC(graphics->temp_hdc);
|
||||
if (graphics->owndc)
|
||||
ReleaseDC(graphics->hwnd, graphics->temp_hdc);
|
||||
else
|
||||
DeleteDC(graphics->temp_hdc);
|
||||
graphics->temp_hdc = NULL;
|
||||
}
|
||||
|
||||
if(graphics->owndc)
|
||||
ReleaseDC(graphics->hwnd, graphics->hdc);
|
||||
|
||||
LIST_FOR_EACH_ENTRY_SAFE(cont, next, &graphics->containers, GraphicsContainerItem, entry){
|
||||
list_remove(&cont->entry);
|
||||
delete_container(cont);
|
||||
|
@ -7002,6 +7020,13 @@ GpStatus WINGDIPAPI GdipGetDC(GpGraphics *graphics, HDC *hdc)
|
|||
{
|
||||
stat = METAFILE_GetDC((GpMetafile*)graphics->image, hdc);
|
||||
}
|
||||
else if (graphics->owndc)
|
||||
{
|
||||
graphics->temp_hdc = GetDC(graphics->hwnd);
|
||||
if (!graphics->temp_hdc)
|
||||
return OutOfMemory;
|
||||
*hdc = graphics->temp_hdc;
|
||||
}
|
||||
else if (!graphics->hdc ||
|
||||
(graphics->image && graphics->image->type == ImageTypeBitmap))
|
||||
{
|
||||
|
@ -7083,6 +7108,11 @@ GpStatus WINGDIPAPI GdipReleaseDC(GpGraphics *graphics, HDC hdc)
|
|||
{
|
||||
stat = METAFILE_ReleaseDC((GpMetafile*)graphics->image, hdc);
|
||||
}
|
||||
else if (graphics->owndc)
|
||||
{
|
||||
ReleaseDC(graphics->hwnd, graphics->temp_hdc);
|
||||
graphics->temp_hdc = NULL;
|
||||
}
|
||||
else if (graphics->temp_hdc == hdc)
|
||||
{
|
||||
DWORD* pos;
|
||||
|
|
Loading…
Reference in a new issue