Skip to content

Commit

Permalink
removed unused DCs
Browse files Browse the repository at this point in the history
added comments for DeleteDC

git-svn-id: http://svn.code.sf.net/p/canvasdraw/cd/trunk@771 86f90930-8b5f-43f8-b0d1-9726248d827e
  • Loading branch information
scuri committed Jun 3, 2018
1 parent 3b75c29 commit 289cfaa
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 27 deletions.
2 changes: 1 addition & 1 deletion cd/src/cairo/cdcairoprn_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static void cdkillcanvas(cdCtxCanvas *ctxcanvas)
cairo_surface_finish(surface);

EndDoc(hDC);
DeleteDC(hDC);
DeleteDC(hDC); /* Use DeleteDC for printer */

if (ctxcanvas->printername)
free(ctxcanvas->printername);
Expand Down
2 changes: 1 addition & 1 deletion cd/src/gdiplus/cdwprnp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static void cdkillcanvas (cdCtxCanvas* ctxcanvas)
EndDoc(ctxcanvas->hDC);

ClosePrinter(ctxcanvas->printerHandle);
DeleteDC(ctxcanvas->hDC);
DeleteDC(ctxcanvas->hDC); /* Use DeleteDC for printer */

delete ctxcanvas;
}
Expand Down
4 changes: 2 additions & 2 deletions cd/src/win32/cdwclp.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ static void cdkillcanvas (cdCtxCanvas *ctxcanvas)
HENHMETAFILE hmf = CloseEnhMetaFile(ctxcanvas->hDC);
SetClipboardData(CF_ENHMETAFILE, hmf);
}
else
else /* CDW_BMP */
{
HANDLE hDib;

Expand All @@ -399,7 +399,7 @@ static void cdkillcanvas (cdCtxCanvas *ctxcanvas)

SelectObject(ctxcanvas->hDC, ctxcanvas->hOldBitmapClip);
DeleteObject(ctxcanvas->hBitmapClip);
DeleteDC(ctxcanvas->hDC);
DeleteDC(ctxcanvas->hDC); /* to match CreateCompatibleDC */

SetClipboardData(CF_DIB, hDib);
}
Expand Down
24 changes: 8 additions & 16 deletions cd/src/win32/cdwin.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,6 @@ void cdwKillCanvas(cdCtxCanvas* ctxcanvas)
if (ctxcanvas->clip_hrgn) DeleteObject(ctxcanvas->clip_hrgn);
if (ctxcanvas->new_rgn) DeleteObject(ctxcanvas->new_rgn);

if (ctxcanvas->hOldBitmapPat) SelectObject(ctxcanvas->hDCMemPat, ctxcanvas->hOldBitmapPat);
if (ctxcanvas->hBitmapPat) DeleteObject(ctxcanvas->hBitmapPat);
if (ctxcanvas->hDCMemPat) DeleteDC(ctxcanvas->hDCMemPat);

if (ctxcanvas->hOldBitmapStip) SelectObject(ctxcanvas->hDCMemStip, ctxcanvas->hOldBitmapStip);
if (ctxcanvas->hBitmapStip) DeleteObject(ctxcanvas->hBitmapStip);
if (ctxcanvas->hDCMemStip) DeleteDC(ctxcanvas->hDCMemStip);

if (ctxcanvas->img_mask) DeleteObject(ctxcanvas->img_mask);

SelectObject(ctxcanvas->hDC, ctxcanvas->hOldFont);
Expand Down Expand Up @@ -1385,7 +1377,7 @@ static void sTextOutBlt(cdCtxCanvas* ctxcanvas, int px, int py, const char* s, i
SelectObject(hBitmapDC, hOldBitmap);

DeleteObject(hBitmap);
DeleteDC(hBitmapDC);
DeleteDC(hBitmapDC); /* to match CreateCompatibleDC */
}

static void cdgettextsize (cdCtxCanvas* ctxcanvas, const char *s, int len, int *width, int *height)
Expand Down Expand Up @@ -1852,15 +1844,15 @@ static void cdgetimagergb(cdCtxCanvas* ctxcanvas, unsigned char *red, unsigned c
{
SelectObject(hDCMem, hOldBitmap);
DeleteObject(hBitmap);
DeleteDC(hDCMem);
DeleteDC(hDCMem); /* to match CreateCompatibleDC */
return;
}

GetDIBits(ctxcanvas->hDC, hBitmap, 0, h, dib.bits, dib.bmi, DIB_RGB_COLORS);

SelectObject(hDCMem, hOldBitmap);
DeleteObject(hBitmap);
DeleteDC(hDCMem);
DeleteDC(hDCMem); /* to match CreateCompatibleDC */

cdwDIBDecodeRGB(&dib, red, green, blue);

Expand Down Expand Up @@ -1989,7 +1981,7 @@ static void cdputimagerectrgba(cdCtxCanvas* ctxcanvas, int width, int height, co
hBitmap = cdwCreateDIBSection(&dib, hDCMem);
if (!hBitmap)
{
DeleteDC(hDCMem);
DeleteDC(hDCMem); /* to match CreateCompatibleDC */
return;
}

Expand Down Expand Up @@ -2022,7 +2014,7 @@ static void cdputimagerectrgba(cdCtxCanvas* ctxcanvas, int width, int height, co
hBitmap = CreateCompatibleBitmap(ctxcanvas->hDC, ew, eh); /* captura do tamanho do destino */
if (!hBitmap)
{
DeleteDC(hDCMem);
DeleteDC(hDCMem); /* to match CreateCompatibleDC */
return;
}

Expand All @@ -2038,7 +2030,7 @@ static void cdputimagerectrgba(cdCtxCanvas* ctxcanvas, int width, int height, co
{
SelectObject(hDCMem, hOldBitmap);
DeleteObject(hBitmap);
DeleteDC(hDCMem);
DeleteDC(hDCMem); /* to match CreateCompatibleDC */
return;
}

Expand All @@ -2054,7 +2046,7 @@ static void cdputimagerectrgba(cdCtxCanvas* ctxcanvas, int width, int height, co

SelectObject(hDCMem, hOldBitmap);
DeleteObject(hBitmap);
DeleteDC(hDCMem);
DeleteDC(hDCMem); /* to match CreateCompatibleDC */
cdwKillDIB(&dib);
}

Expand Down Expand Up @@ -2207,7 +2199,7 @@ static void cdkillimage(cdCtxImage *ctximage)
{
SelectObject(ctximage->hDC, ctximage->hOldBitmap);
DeleteObject(ctximage->hBitmap);
DeleteDC(ctximage->hDC);
DeleteDC(ctximage->hDC); /* to match CreateCompatibleDC */
free(ctximage);
}

Expand Down
6 changes: 0 additions & 6 deletions cd/src/win32/cdwin.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ struct _cdCtxCanvas
HBRUSH hOldBrush; /* brush anterior selecionado */
HBRUSH hBkBrush; /* handle para o pincel com a cor de fundo */

HDC hDCMemPat;
HBITMAP hOldBitmapPat,hBitmapPat;

HDC hDCMemStip;
HBITMAP hOldBitmapStip,hBitmapStip;

HFONT hFont; /* handle para o fonte corrente */
HFONT hOldFont;

Expand Down
2 changes: 1 addition & 1 deletion cd/src/win32/cdwprn.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static void cdkillcanvas (cdCtxCanvas *ctxcanvas)

cdwKillCanvas(ctxcanvas);

DeleteDC(ctxcanvas->hDC);
DeleteDC(ctxcanvas->hDC); /* Use DeleteDC for printer */

if (ctxcanvas->filename)
free(ctxcanvas->filename);
Expand Down

0 comments on commit 289cfaa

Please sign in to comment.