#include <grndwing.h>
Inheritance diagram for GRenderWinG:
Public Types | |
typedef HDC(PASCAL * | WING_CREATEDC )(void) |
typedef BOOL(PASCAL * | WING_RECOMMENDED )(BITMAPINFO FAR *pFormat) |
typedef HBITMAP(PASCAL * | WING_CREATEBITMAP )(HDC WinGDC, BITMAPINFO const FAR *pHeader, void FAR *FAR *ppBits) |
typedef BOOL(PASCAL * | WING_BITBLT )(HDC hdcDest, INT32 nXOriginDest, INT32 nYOriginDest, INT32 nWidthDest, INT32 nHeightDest, HDC hdcSrc, INT32 nXOriginSrc, INT32 nYOriginSrc) |
Public Member Functions | |
GRenderWinG (DocRect ClipRegion, Matrix ConvertMatrix, FIXED16 ViewScale, UINT32 Depth, double dpi) | |
GRenderWinG constructor. Doesn't do anything actually, just calls base class. INT32 dpi changed to FIXED16 dpi (12/12/95) to improve the range of values allowed at the < 1000dpi settings that we will be using. | |
~GRenderWinG () | |
GRenderWinG destructor. Frees up the bitmap. | |
Static Public Member Functions | |
static BOOL | Init (BOOL) |
Determines whether WinG is available on this platform. | |
static void | Deinit () |
Tidies up WinG before exit. Frees up necessary resources etc. | |
static BOOL | CanWinG (UINT32 Depth) |
Use before creating GRenderWinGs inc case they are not supported. Currently only uses WinG if depth matches the recommended format. | |
Static Public Attributes | |
static HINSTANCE | WinGDLL |
static WING_CREATEDC | pWinGCreateDC |
static WING_RECOMMENDED | pWinGRecommendedDIBFormat |
static WING_CREATEBITMAP | pWinGCreateBitmap |
static WING_BITBLT | pWinGBitBlt |
Private Member Functions | |
LPBITMAPINFO | GetLPBits (INT32 Width, INT32 Height, INT32 Depth, LPBYTE *) |
Allocates a bitmap header and the bitmap bytes. | |
void | FreeLPBits (LPBITMAPINFO, LPBYTE) |
Frees up a bitmap allocated with GetLPBits. | |
BOOL | DisplayBits (LPBITMAPINFO lpDisplayBitmapInfo=NULL, LPBYTE lpDisplayBits=NULL) |
Plots the DIB onto the owner device. | |
BOOL | StartRenderAfter (GMATRIX *GMat) |
Updates the Gavin matrix to cope with the upside-down nature of DIBs if that is the recommended format. | |
Private Attributes | |
HBITMAP | WinGBitmap |
BOOL | Inverted |
Static Private Attributes | |
static HDC | OffScreenDC |
Definition at line 111 of file grndwing.h.
|
Definition at line 133 of file grndwing.h. |
|
Definition at line 131 of file grndwing.h. |
|
Definition at line 129 of file grndwing.h. |
|
Definition at line 130 of file grndwing.h. |
|
GRenderWinG constructor. Doesn't do anything actually, just calls base class. INT32 dpi changed to FIXED16 dpi (12/12/95) to improve the range of values allowed at the < 1000dpi settings that we will be using.
Definition at line 309 of file grndwing.cpp. 00310 : GRenderRegion( ClipRegion, ConvertMatrix, ViewScale, Depth, dpi) 00311 { 00312 WinGBitmap = NULL; 00313 Inverted = FALSE; 00314 }
|
|
GRenderWinG destructor. Frees up the bitmap.
Definition at line 437 of file grndwing.cpp. 00438 { 00439 if (LocalBitmap) 00440 { 00441 if (HaveRenderedSomething) 00442 // We're not clean - flush bitmap to screen 00443 DisplayBits(); 00444 00445 // FreeLPBits( lpBitmapInfo, lpBits ); 00446 FreeOffscreenState(); 00447 lpBitmapInfo = NULL; 00448 lpBits = NULL; 00449 } 00450 // will call GRenderRegions destructor here 00451 }
|
|
Use before creating GRenderWinGs inc case they are not supported. Currently only uses WinG if depth matches the recommended format.
Definition at line 279 of file grndwing.cpp. 00280 { 00281 if ( 00282 WinGDLL && // must have DLL 00283 OffScreenDC && // and screen DC 00284 (RecommendedDIB.biPlanes == 1) && // mono planar 00285 (Depth == RecommendedDIB.biBitCount) // and correct depth 00286 ) 00287 return TRUE; 00288 00289 return FALSE; 00290 }
|
|
Tidies up WinG before exit. Frees up necessary resources etc.
Definition at line 255 of file grndwing.cpp. 00256 { 00257 if (OffScreenDC) 00258 { 00259 DeleteDC(OffScreenDC); 00260 OffScreenDC = NULL; 00261 } 00262 }
|
|
Plots the DIB onto the owner device.
Implements GRenderRegion. Definition at line 504 of file grndwing.cpp. 00505 { 00506 BOOL ok = FALSE; 00507 00508 if (lpBitmapInfo && lpBits && RenderDC) 00509 { 00510 HBITMAP hOldBitmap; 00511 00512 hOldBitmap = SelectBitmap( OffScreenDC, WinGBitmap ); 00513 if (hOldBitmap) 00514 { 00515 ok = pWinGBitBlt( RenderDC->m_hDC, // dest 00516 WRect.left, WRect.top, // dest XY 00517 WRect.right-WRect.left, 00518 WRect.bottom-WRect.top, 00519 OffScreenDC, // source 00520 0,0 // source XY 00521 ); 00522 SelectBitmap( OffScreenDC, hOldBitmap ); 00523 } 00524 } 00525 return ok; 00526 }
|
|
Frees up a bitmap allocated with GetLPBits.
Implements GRenderRegion. Definition at line 413 of file grndwing.cpp. 00414 { 00415 if (WinGBitmap) 00416 { 00417 DeleteObject( WinGBitmap ); 00418 WinGBitmap = NULL; 00419 } 00420 FreeDIB( lpBMI, NULL ); 00421 }
|
|
Allocates a bitmap header and the bitmap bytes.
Implements GRenderRegion. Definition at line 331 of file grndwing.cpp. 00332 { 00333 // get a bitmap header with no bits 00334 const LPBITMAPINFO bmInfo = AllocDIB( Width, Height, Depth, NULL ); 00335 if (!bmInfo) 00336 return NULL; 00337 00338 // tell it the sort of palette we want - we want Gavin's 00339 if (Depth==8) 00340 { 00341 #if 0 00342 RGBQUAD *rgb = bmInfo->bmiColors; 00343 LPPALETTEENTRY lpPal = GetRecommendedPalette()->palPalEntry; 00344 00345 size_t i ; 00346 for ( i=0 ; i<256 ; i++ ) 00347 { 00348 rgb->rgbRed = lpPal->peRed; 00349 rgb->rgbGreen = lpPal->peGreen; 00350 rgb->rgbBlue = lpPal->peBlue; 00351 rgb->rgbReserved = 0; 00352 rgb ++; 00353 lpPal++; 00354 } 00355 #else 00356 00357 GetSystemPaletteEntries ( 00358 RenderDC->m_hDC, 0, 256, (LPPALETTEENTRY) bmInfo->bmiColors 00359 ) ; 00360 RGBQUAD *rgb = bmInfo->bmiColors ; // Swap R and B. 00361 size_t i ; 00362 for ( i=0 ; i<256 ; i++ ) 00363 { 00364 BYTE t = rgb->rgbRed ; 00365 rgb->rgbRed = rgb->rgbBlue ; 00366 rgb->rgbBlue = t ; 00367 rgb ++ ; 00368 } 00369 #endif 00370 } 00371 00372 // if WinG wants it upside-down then go for it 00373 if (RecommendedDIB.biHeight == -1) 00374 { 00375 Inverted = TRUE; 00376 bmInfo->bmiHeader.biHeight = -bmInfo->bmiHeader.biHeight; 00377 } 00378 else 00379 Inverted = FALSE; 00380 00381 // now get a lovely WinG bitmap 00382 WinGBitmap = pWinGCreateBitmap( OffScreenDC, bmInfo, (void FAR* FAR *)lplpBits ); 00383 if (WinGBitmap==NULL) 00384 { 00385 TRACE( _T("WinGCreateBitmap failed\n")); 00386 FreeDIB( bmInfo, NULL ); 00387 return NULL; 00388 } 00389 00390 // turn it back the other way else Gavin is likely to get confused 00391 if (Inverted) 00392 bmInfo->bmiHeader.biHeight = -bmInfo->bmiHeader.biHeight; 00393 00394 //TRACE( _T("WinG Alloc %lx=%lx:%lx\n"), this, bmInfo, *lplpBits); 00395 return bmInfo; 00396 }
|
|
Determines whether WinG is available on this platform.
Reimplemented from GRenderRegion. Definition at line 144 of file grndwing.cpp. 00145 { 00146 if (!FirstTime) 00147 { 00148 // only a screen mode change so don't redo DLL etc, just get new DC 00149 if (WinGDLL) 00150 { 00151 // kill old one 00152 if (OffScreenDC) 00153 DeleteDC( OffScreenDC ); 00154 00155 // go get new one 00156 OffScreenDC = pWinGCreateDC(); 00157 if (OffScreenDC) 00158 return TRUE; 00159 } 00160 return FALSE; 00161 } 00162 00163 #if WIN32 00164 // lets see if the DLL is there 00165 00166 // on NT 3.1 the DLL init code fails the load and produces an ugly dialog, so we don't 00167 // bother 00168 if (IsWin32NT()) 00169 { 00170 const WORD Ver = LOWORD( GetVersion() ); 00171 if ( 00172 (LOBYTE(Ver) == 3) && // NT 3.5 is minimum requirement 00173 (HIBYTE(Ver) < 50) 00174 ) 00175 return FALSE; 00176 } 00177 00178 // try the DLL now 00179 WinGDLL = LoadLibrary("WING32.DLL"); 00180 if (WinGDLL) 00181 { 00182 // (ordinal values extracted from DLL using DUMPBIN -export) 00183 00184 pWinGCreateDC = (WING_CREATEDC) GetProcAddress( WinGDLL, MAKEINTRESOURCE(0x3e9) ); 00185 pWinGCreateBitmap = (WING_CREATEBITMAP) GetProcAddress( WinGDLL, MAKEINTRESOURCE(0x3eb) ); 00186 pWinGBitBlt = (WING_BITBLT) GetProcAddress( WinGDLL, MAKEINTRESOURCE(0x3f2) ); 00187 pWinGRecommendedDIBFormat = 00188 (WING_RECOMMENDED) GetProcAddress( WinGDLL, MAKEINTRESOURCE( 0x3ea ) ); 00189 00190 if ( 00191 (pWinGCreateDC == NULL) || 00192 (pWinGCreateBitmap == NULL) || 00193 (pWinGBitBlt == NULL) || 00194 (pWinGRecommendedDIBFormat==NULL) 00195 ) 00196 { 00197 TRACE( _T("WinG32 DLL entrypoints missing!\n")); 00198 FreeLibrary( WinGDLL ); 00199 WinGDLL = NULL; 00200 return FALSE; 00201 } 00202 } 00203 else 00204 { 00205 TRACE( _T("WinG DLL not found (error %d)\n"), GetLastError() ); 00206 return FALSE; 00207 } 00208 00209 // remember the DLL handle so it gets cleaned up for us always on exit 00210 ExtraDLLs[ WinG_DLL ] = WinGDLL; 00211 00212 RecommendedDIB.biSize = sizeof(BITMAPINFOHEADER); 00213 00214 // excuse the seemingly rampant cast but I think the official prototype is wrong 00215 const BOOL ok = pWinGRecommendedDIBFormat( (LPBITMAPINFO)&RecommendedDIB ); 00216 00217 if (IsUserName("Andy")) 00218 { 00219 TRACE( _T("Recommended bitmap:\n")); 00220 if (ok) 00221 { 00222 TRACE( _T("%dx%d height=%d comp=%d\n"), 00223 (INT32)RecommendedDIB.biPlanes, 00224 (INT32)RecommendedDIB.biBitCount, 00225 (INT32)RecommendedDIB.biHeight, 00226 (INT32)RecommendedDIB.biCompression 00227 ); 00228 } 00229 else 00230 TRACE( _T("ERROR - isnt one\n")); 00231 } 00232 00233 OffScreenDC = pWinGCreateDC(); 00234 if (OffScreenDC) 00235 return TRUE; 00236 00237 #endif 00238 00239 // if we get here it means we failed 00240 return FALSE; 00241 }
|
|
Updates the Gavin matrix to cope with the upside-down nature of DIBs if that is the recommended format.
Reimplemented from GRenderRegion. Definition at line 470 of file grndwing.cpp. 00471 { 00472 if (Inverted) 00473 { 00474 // flip up other way 00475 GMat->BY = -GMat->BY; 00476 00477 // calculate the new offset 00478 //XLONG ydisp = (XLONG)( (WRect.bottom - WRect.top ) * 72000 ) / (XLONG)(PixelsPerInch.MakeXlong() * ScaleFactor); 00479 FIXED16 ScaledDpi = FIXED16(PixelsPerInch) * ScaleFactor; 00480 XLONG Size = (WRect.bottom - WRect.top ) * 72000; 00481 XLONG ydisp = Size / ScaledDpi.MakeXlong(); 00482 00483 GMat->CY = -GMat->CY + Mul(-GMat->BY, ydisp); 00484 } 00485 00486 // we cannot fail 00487 return TRUE; 00488 }
|
|
Definition at line 157 of file grndwing.h. |
|
Definition at line 161 of file grndwing.h. |
|
Definition at line 146 of file grndwing.h. |
|
Definition at line 145 of file grndwing.h. |
|
Definition at line 143 of file grndwing.h. |
|
Definition at line 144 of file grndwing.h. |
|
Definition at line 156 of file grndwing.h. |
|
Definition at line 141 of file grndwing.h. |