diff options
Diffstat (limited to 'vcl/win/gdi/salgdi.cxx')
-rw-r--r-- | vcl/win/gdi/salgdi.cxx | 323 |
1 files changed, 0 insertions, 323 deletions
diff --git a/vcl/win/gdi/salgdi.cxx b/vcl/win/gdi/salgdi.cxx index 978f4cf95309..0e6e033d0c4d 100644 --- a/vcl/win/gdi/salgdi.cxx +++ b/vcl/win/gdi/salgdi.cxx @@ -43,65 +43,6 @@ #endif -#define DITHER_PAL_DELTA 51 -#define DITHER_PAL_STEPS 6 -#define DITHER_PAL_COUNT (DITHER_PAL_STEPS*DITHER_PAL_STEPS*DITHER_PAL_STEPS) -#define DITHER_MAX_SYSCOLOR 16 -#define DITHER_EXTRA_COLORS 1 - -namespace -{ - -struct SysColorEntry -{ - DWORD nRGB; - SysColorEntry* pNext; -}; - -SysColorEntry* pFirstSysColor = nullptr; -SysColorEntry* pActSysColor = nullptr; - -void DeleteSysColorList() -{ - SysColorEntry* pEntry = pFirstSysColor; - pActSysColor = pFirstSysColor = nullptr; - - while( pEntry ) - { - SysColorEntry* pTmp = pEntry->pNext; - delete pEntry; - pEntry = pTmp; - } -} - -} // namespace - -// Blue7 -static PALETTEENTRY aImplExtraColor1 = -{ - 0, 184, 255, 0 -}; - -static PALETTEENTRY aImplSalSysPalEntryAry[ DITHER_MAX_SYSCOLOR ] = -{ -{ 0, 0, 0, 0 }, -{ 0, 0, 0x80, 0 }, -{ 0, 0x80, 0, 0 }, -{ 0, 0x80, 0x80, 0 }, -{ 0x80, 0, 0, 0 }, -{ 0x80, 0, 0x80, 0 }, -{ 0x80, 0x80, 0, 0 }, -{ 0x80, 0x80, 0x80, 0 }, -{ 0xC0, 0xC0, 0xC0, 0 }, -{ 0, 0, 0xFF, 0 }, -{ 0, 0xFF, 0, 0 }, -{ 0, 0xFF, 0xFF, 0 }, -{ 0xFF, 0, 0, 0 }, -{ 0xFF, 0, 0xFF, 0 }, -{ 0xFF, 0xFF, 0, 0 }, -{ 0xFF, 0xFF, 0xFF, 0 } -}; - // we must create pens with 1-pixel width; otherwise the S3-graphics card // map has many paint problems when drawing polygons/polyLines and a // complex is set @@ -137,152 +78,6 @@ void ImplInitSalGDI() // initialize temporary font lists pSalData->mpSharedTempFontItem = nullptr; pSalData->mpOtherTempFontItem = nullptr; - - // support palettes for 256 color displays - HDC hDC = GetDC( nullptr ); - int nBitsPixel = GetDeviceCaps( hDC, BITSPIXEL ); - int nPlanes = GetDeviceCaps( hDC, PLANES ); - int nRasterCaps = GetDeviceCaps( hDC, RASTERCAPS ); - int nBitCount = nBitsPixel * nPlanes; - - if ( (nBitCount > 8) && (nBitCount < 24) ) - { - // test if we have to dither - HDC hMemDC = ::CreateCompatibleDC( hDC ); - HBITMAP hMemBmp = ::CreateCompatibleBitmap( hDC, 8, 8 ); - HBITMAP hBmpOld = static_cast<HBITMAP>(::SelectObject( hMemDC, hMemBmp )); - HBRUSH hMemBrush = ::CreateSolidBrush( PALETTERGB( 175, 171, 169 ) ); - HBRUSH hBrushOld = static_cast<HBRUSH>(::SelectObject( hMemDC, hMemBrush )); - bool bDither16 = true; - - ::PatBlt( hMemDC, 0, 0, 8, 8, PATCOPY ); - const COLORREF aCol( ::GetPixel( hMemDC, 0, 0 ) ); - - for( int nY = 0; ( nY < 8 ) && bDither16; nY++ ) - for( int nX = 0; ( nX < 8 ) && bDither16; nX++ ) - if( ::GetPixel( hMemDC, nX, nY ) != aCol ) - bDither16 = false; - - ::SelectObject( hMemDC, hBrushOld ); - ::DeleteObject( hMemBrush ); - ::SelectObject( hMemDC, hBmpOld ); - ::DeleteObject( hMemBmp ); - ::DeleteDC( hMemDC ); - - if( bDither16 ) - { - // create DIBPattern for 16Bit dithering - tools::Long n; - - pSalData->mhDitherDIB = GlobalAlloc( GMEM_FIXED, sizeof( BITMAPINFOHEADER ) + 192 ); - pSalData->mpDitherDIB = static_cast<BYTE*>(GlobalLock( pSalData->mhDitherDIB )); - pSalData->mpDitherDiff.reset(new tools::Long[ 256 ]); - pSalData->mpDitherLow.reset(new BYTE[ 256 ]); - pSalData->mpDitherHigh.reset(new BYTE[ 256 ]); - pSalData->mpDitherDIBData = pSalData->mpDitherDIB + sizeof( BITMAPINFOHEADER ); - memset( pSalData->mpDitherDIB, 0, sizeof( BITMAPINFOHEADER ) ); - - BITMAPINFOHEADER* pBIH = reinterpret_cast<BITMAPINFOHEADER*>(pSalData->mpDitherDIB); - - pBIH->biSize = sizeof( BITMAPINFOHEADER ); - pBIH->biWidth = 8; - pBIH->biHeight = 8; - pBIH->biPlanes = 1; - pBIH->biBitCount = 24; - - for( n = 0; n < 256; n++ ) - pSalData->mpDitherDiff[ n ] = n - ( n & 248L ); - - for( n = 0; n < 256; n++ ) - pSalData->mpDitherLow[ n ] = static_cast<BYTE>( n & 248 ); - - for( n = 0; n < 256; n++ ) - pSalData->mpDitherHigh[ n ] = static_cast<BYTE>(std::min( pSalData->mpDitherLow[ n ] + 8, 255 )); - } - } - else if ( (nRasterCaps & RC_PALETTE) && (nBitCount == 8) ) - { - BYTE nRed, nGreen, nBlue; - BYTE nR, nG, nB; - PALETTEENTRY* pPalEntry; - LOGPALETTE* pLogPal; - const sal_uInt16 nDitherPalCount = DITHER_PAL_COUNT; - sal_uLong nTotalCount = DITHER_MAX_SYSCOLOR + nDitherPalCount + DITHER_EXTRA_COLORS; - - // create logical palette - pLogPal = reinterpret_cast<LOGPALETTE*>(new char[ sizeof( LOGPALETTE ) + ( nTotalCount * sizeof( PALETTEENTRY ) ) ]); - pLogPal->palVersion = 0x0300; - pLogPal->palNumEntries = static_cast<sal_uInt16>(nTotalCount); - pPalEntry = pLogPal->palPalEntry; - - // Standard colors - memcpy( pPalEntry, aImplSalSysPalEntryAry, DITHER_MAX_SYSCOLOR * sizeof( PALETTEENTRY ) ); - pPalEntry += DITHER_MAX_SYSCOLOR; - - // own palette (6/6/6) - for( nB=0, nBlue=0; nB < DITHER_PAL_STEPS; nB++, nBlue += DITHER_PAL_DELTA ) - { - for( nG=0, nGreen=0; nG < DITHER_PAL_STEPS; nG++, nGreen += DITHER_PAL_DELTA ) - { - for( nR=0, nRed=0; nR < DITHER_PAL_STEPS; nR++, nRed += DITHER_PAL_DELTA ) - { - pPalEntry->peRed = nRed; - pPalEntry->peGreen = nGreen; - pPalEntry->peBlue = nBlue; - pPalEntry->peFlags = 0; - pPalEntry++; - } - } - } - - // insert special 'Blue' as standard drawing color - *pPalEntry++ = aImplExtraColor1; - - // create palette - pSalData->mhDitherPal = CreatePalette( pLogPal ); - delete[] reinterpret_cast<char*>(pLogPal); - - if( pSalData->mhDitherPal ) - { - // create DIBPattern for 8Bit dithering - tools::Long const nSize = sizeof( BITMAPINFOHEADER ) + ( 256 * sizeof( short ) ) + 64; - tools::Long n; - - pSalData->mhDitherDIB = GlobalAlloc( GMEM_FIXED, nSize ); - pSalData->mpDitherDIB = static_cast<BYTE*>(GlobalLock( pSalData->mhDitherDIB )); - pSalData->mpDitherDiff.reset(new tools::Long[ 256 ]); - pSalData->mpDitherLow.reset(new BYTE[ 256 ]); - pSalData->mpDitherHigh.reset(new BYTE[ 256 ]); - pSalData->mpDitherDIBData = pSalData->mpDitherDIB + sizeof( BITMAPINFOHEADER ) + ( 256 * sizeof( short ) ); - memset( pSalData->mpDitherDIB, 0, sizeof( BITMAPINFOHEADER ) ); - - BITMAPINFOHEADER* pBIH = reinterpret_cast<BITMAPINFOHEADER*>(pSalData->mpDitherDIB); - short* pColors = reinterpret_cast<short*>( pSalData->mpDitherDIB + sizeof( BITMAPINFOHEADER ) ); - - pBIH->biSize = sizeof( BITMAPINFOHEADER ); - pBIH->biWidth = 8; - pBIH->biHeight = 8; - pBIH->biPlanes = 1; - pBIH->biBitCount = 8; - - for( n = 0; n < nDitherPalCount; n++ ) - pColors[ n ] = static_cast<short>( n + DITHER_MAX_SYSCOLOR ); - - for( n = 0; n < 256; n++ ) - pSalData->mpDitherDiff[ n ] = n % 51; - - for( n = 0; n < 256; n++ ) - pSalData->mpDitherLow[ n ] = static_cast<BYTE>( n / 51 ); - - for( n = 0; n < 256; n++ ) - pSalData->mpDitherHigh[ n ] = static_cast<BYTE>(std::min( pSalData->mpDitherLow[ n ] + 1, 5 )); - } - - // get system color entries - ImplUpdateSysColorEntries(); - } - - ReleaseDC( nullptr, hDC ); } void ImplFreeSalGDI() @@ -315,26 +110,6 @@ void ImplFreeSalGDI() ImplClearHDCCache( pSalData ); - // delete Ditherpalette, if existing - if ( pSalData->mhDitherPal ) - { - DeleteObject( pSalData->mhDitherPal ); - pSalData->mhDitherPal = nullptr; - } - - // delete buffers for dithering DIB patterns, if necessary - if ( pSalData->mhDitherDIB ) - { - GlobalUnlock( pSalData->mhDitherDIB ); - GlobalFree( pSalData->mhDitherDIB ); - pSalData->mhDitherDIB = nullptr; - pSalData->mpDitherDiff.reset(); - pSalData->mpDitherLow.reset(); - pSalData->mpDitherHigh.reset(); - } - - DeleteSysColorList(); - // delete icon cache SalIcon* pIcon = pSalData->mpFirstIcon; pSalData->mpFirstIcon = nullptr; @@ -353,98 +128,6 @@ void ImplFreeSalGDI() pSalData->mbResourcesAlreadyFreed = true; } -int ImplIsSysColorEntry( Color nColor ) -{ - SysColorEntry* pEntry = pFirstSysColor; - const DWORD nTestRGB = static_cast<DWORD>(RGB( nColor.GetRed(), - nColor.GetGreen(), - nColor.GetBlue() )); - - while ( pEntry ) - { - if ( pEntry->nRGB == nTestRGB ) - return TRUE; - pEntry = pEntry->pNext; - } - - return FALSE; -} - -static int ImplIsPaletteEntry( BYTE nRed, BYTE nGreen, BYTE nBlue ) -{ - // dither color? - if ( !(nRed % DITHER_PAL_DELTA) && !(nGreen % DITHER_PAL_DELTA) && !(nBlue % DITHER_PAL_DELTA) ) - return TRUE; - - PALETTEENTRY* pPalEntry = aImplSalSysPalEntryAry; - - // standard palette color? - for ( sal_uInt16 i = 0; i < DITHER_MAX_SYSCOLOR; i++, pPalEntry++ ) - { - if( pPalEntry->peRed == nRed && pPalEntry->peGreen == nGreen && pPalEntry->peBlue == nBlue ) - return TRUE; - } - - // extra color? - if ( aImplExtraColor1.peRed == nRed && - aImplExtraColor1.peGreen == nGreen && - aImplExtraColor1.peBlue == nBlue ) - { - return TRUE; - } - - return FALSE; -} - -static void ImplInsertSysColorEntry( int nSysIndex ) -{ - const DWORD nRGB = GetSysColor( nSysIndex ); - - if ( ImplIsPaletteEntry( GetRValue( nRGB ), GetGValue( nRGB ), GetBValue( nRGB ) ) ) - return; - - if ( !pFirstSysColor ) - { - pActSysColor = pFirstSysColor = new SysColorEntry; - pFirstSysColor->nRGB = nRGB; - pFirstSysColor->pNext = nullptr; - } - else - { - pActSysColor = pActSysColor->pNext = new SysColorEntry; - pActSysColor->nRGB = nRGB; - pActSysColor->pNext = nullptr; - } -} - -void ImplUpdateSysColorEntries() -{ - DeleteSysColorList(); - - // create new sys color list - ImplInsertSysColorEntry( COLOR_ACTIVEBORDER ); - ImplInsertSysColorEntry( COLOR_INACTIVEBORDER ); - ImplInsertSysColorEntry( COLOR_GRADIENTACTIVECAPTION ); - ImplInsertSysColorEntry( COLOR_GRADIENTINACTIVECAPTION ); - ImplInsertSysColorEntry( COLOR_3DFACE ); - ImplInsertSysColorEntry( COLOR_3DHILIGHT ); - ImplInsertSysColorEntry( COLOR_3DLIGHT ); - ImplInsertSysColorEntry( COLOR_3DSHADOW ); - ImplInsertSysColorEntry( COLOR_3DDKSHADOW ); - ImplInsertSysColorEntry( COLOR_INFOBK ); - ImplInsertSysColorEntry( COLOR_INFOTEXT ); - ImplInsertSysColorEntry( COLOR_BTNTEXT ); - ImplInsertSysColorEntry( COLOR_WINDOW ); - ImplInsertSysColorEntry( COLOR_WINDOWTEXT ); - ImplInsertSysColorEntry( COLOR_HIGHLIGHT ); - ImplInsertSysColorEntry( COLOR_HIGHLIGHTTEXT ); - ImplInsertSysColorEntry( COLOR_MENU ); - ImplInsertSysColorEntry( COLOR_MENUTEXT ); - ImplInsertSysColorEntry( COLOR_ACTIVECAPTION ); - ImplInsertSysColorEntry( COLOR_CAPTIONTEXT ); - ImplInsertSysColorEntry( COLOR_INACTIVECAPTION ); - ImplInsertSysColorEntry( COLOR_INACTIVECAPTIONTEXT ); -} void WinSalGraphics::InitGraphics() { @@ -513,12 +196,6 @@ HDC ImplGetCachedDC( sal_uLong nID, HBITMAP hBmp ) // create new DC with DefaultBitmap pC->mhDC = CreateCompatibleDC( hDC ); - if( pSalData->mhDitherPal ) - { - pC->mhDefPal = SelectPalette( pC->mhDC, pSalData->mhDitherPal, TRUE ); - RealizePalette( pC->mhDC ); - } - pC->mhSelBmp = CreateCompatibleBitmap( hDC, CACHED_HDC_DEFEXT, CACHED_HDC_DEFEXT ); pC->mhDefBmp = static_cast<HBITMAP>(SelectObject( pC->mhDC, pC->mhSelBmp )); |