[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] master cafbc46: [graph] Clean up win32 driver.
From: |
Alexei Podtelezhnikov |
Subject: |
[freetype2-demos] master cafbc46: [graph] Clean up win32 driver. |
Date: |
Thu, 21 May 2020 23:38:37 -0400 (EDT) |
branch: master
commit cafbc46d98e5c5900468972aeb9e688ed6b99bff
Author: Alexei Podtelezhnikov <address@hidden>
Commit: Alexei Podtelezhnikov <address@hidden>
[graph] Clean up win32 driver.
This removes `BitBlt' and a related bitmap copy. Instead the driver
now uses direct `SetDIBitsToDevice' which is similar to `XPutImage'.
* graph/win32/grwin32.c (grWin32Surface): Remove `hbn'.
(gr_win32_surface_refresh_rectangle): Do not call `SetDIBits'.
(Message_Process): Use `SetDIBitsToDevice' in WM_PAINT and do not
handle WM_CREATE and simplify WM_DESTROY.
(gr_win32_surface_init): Remove unnecessary code.
(gr_win32_surface_listen_event): Minor.
* graph/grobjs.c (grNewBitmap): Add padding to rgb24 required by GDI.
---
ChangeLog | 16 +++++++++++++++
graph/grobjs.c | 2 +-
graph/win32/grwin32.c | 57 +++++++++++++--------------------------------------
3 files changed, 31 insertions(+), 44 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index fe56eb8..261790d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2020-05-21 Alexei Podtelezhnikov <address@hidden>
+
+ [graph] Clean up win32 driver.
+
+ This removes `BitBlt' and a related bitmap copy. Instead the driver
+ now uses direct `SetDIBitsToDevice' which is similar to `XPutImage'.
+
+ * graph/win32/grwin32.c (grWin32Surface): Remove `hbn'.
+ (gr_win32_surface_refresh_rectangle): Do not call `SetDIBits'.
+ (Message_Process): Use `SetDIBitsToDevice' in WM_PAINT and do not
+ handle WM_CREATE and simplify WM_DESTROY.
+ (gr_win32_surface_init): Remove unnecessary code.
+ (gr_win32_surface_listen_event): Minor.
+
+ * graph/grobjs.c (grNewBitmap): Add padding to rgb24 required by GDI.
+
2020-05-19 Alexei Podtelezhnikov <address@hidden>
[graph]: Implement resizable X11 windows.
diff --git a/graph/grobjs.c b/graph/grobjs.c
index 514cc91..e747df4 100644
--- a/graph/grobjs.c
+++ b/graph/grobjs.c
@@ -187,7 +187,7 @@
case gr_pixel_mode_rgb555:
case gr_pixel_mode_rgb565: pitch = width*2; break;
- case gr_pixel_mode_rgb24 : pitch = width*3; break;
+ case gr_pixel_mode_rgb24 : pitch = ( width*3 + 3 ) & ~3; break;
case gr_pixel_mode_rgb32 : pitch = width*4; break;
diff --git a/graph/win32/grwin32.c b/graph/win32/grwin32.c
index e7bf2d1..95eeffc 100644
--- a/graph/win32/grwin32.c
+++ b/graph/win32/grwin32.c
@@ -119,7 +119,6 @@
const char* the_title;
LPBITMAPINFO pbmi;
char bmi[ sizeof(BITMAPINFO) + 256*sizeof(RGBQUAD) ];
- HBITMAP hbm;
grEvent ourevent;
int eventToProcess;
grBitmap bgrBitmap; /* windows wants data in BGR format !! */
@@ -262,16 +261,6 @@ gr_win32_surface_refresh_rectangle(
}
}
- hDC = GetDC ( window );
- SetDIBits ( hDC, surface->hbm,
- 0,
- bitmap->rows,
- surface->bgrBitmap.buffer,
- pbmi,
- DIB_RGB_COLORS );
-
- ReleaseDC ( window, hDC );
-
ShowWindow( window, SW_SHOW );
InvalidateRect ( window, NULL, FALSE );
UpdateWindow ( window );
@@ -305,7 +294,7 @@ gr_win32_surface_listen_event( grWin32Surface* surface,
}
surface->eventToProcess = 0;
- while (GetMessage( &msg, 0, 0, 0 ))
+ while (GetMessage( &msg, 0, 0, 0 ) > 0)
{
TranslateMessage( &msg );
DispatchMessage( &msg );
@@ -351,7 +340,6 @@ gr_win32_surface_init( grWin32Surface* surface,
return 0;
/* allocate the BGR shadow bitmap */
- surface->bgrBitmap.buffer = NULL;
if ( grNewBitmap( bitmap->mode,
bitmap->grays,
bitmap->width,
@@ -362,7 +350,6 @@ gr_win32_surface_init( grWin32Surface* surface,
surface->bgrBitmap.pitch = -surface->bgrBitmap.pitch;
#ifdef SWIZZLE
- surface->swizzle_bitmap.buffer = NULL;
if ( bitmap->mode == gr_pixel_mode_rgb24 )
{
if ( grNewBitmap( bitmap->mode,
@@ -504,42 +491,26 @@ LRESULT CALLBACK Message_Process( HWND handle, UINT mess,
surface->eventToProcess = 1;
surface->window = 0;
PostQuitMessage ( 0 );
- DeleteObject ( surface->hbm );
return 0;
- case WM_CREATE:
- {
- HDC hDC;
- LPBITMAPINFO pbmi = surface->pbmi;
-
- hDC = GetDC ( handle );
- surface->hbm = CreateDIBitmap (
- /* HDC hdc; handle of device context */ hDC,
- /* BITMAPINFOHEADER FAR* lpbmih; addr.of header*/ &pbmi->bmiHeader,
- /* DWORD dwInit; CBM_INIT to initialize bitmap */ 0,
- /* const void FAR* lpvBits; address of values */ NULL,
- /* BITMAPINFO FAR* lpbmi; addr.of bitmap data */ pbmi,
- /* UINT fnColorUse; RGB or palette indices */ DIB_RGB_COLORS);
- ReleaseDC ( handle, hDC );
- break;
- }
-
case WM_PAINT:
{
- HDC hDC, memDC;
- HANDLE oldbm;
+ HDC hDC;
PAINTSTRUCT ps;
+ LPBITMAPINFO pbmi = surface->pbmi;
hDC = BeginPaint ( handle, &ps );
- memDC = CreateCompatibleDC( hDC );
- oldbm = SelectObject( memDC, surface->hbm );
-
- BitBlt ( hDC, 0, 0, surface->window_width, surface->window_height,
- memDC, 0, 0, SRCCOPY);
-
- ReleaseDC ( handle, hDC );
- SelectObject ( memDC, oldbm );
- DeleteObject ( memDC );
+ if ( pbmi )
+ {
+ SetDIBitsToDevice( hDC, 0, 0,
+ pbmi->bmiHeader.biWidth,
+ pbmi->bmiHeader.biHeight,
+ 0, 0, 0,
+ pbmi->bmiHeader.biHeight,
+ surface->bgrBitmap.buffer,
+ pbmi,
+ DIB_RGB_COLORS );
+ }
EndPaint ( handle, &ps );
return 0;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] master cafbc46: [graph] Clean up win32 driver.,
Alexei Podtelezhnikov <=