diff --git a/gfx/src/windows/nsDeviceContextWin.cpp b/gfx/src/windows/nsDeviceContextWin.cpp index bf9ffc75cce..24f34cd9dfe 100644 --- a/gfx/src/windows/nsDeviceContextWin.cpp +++ b/gfx/src/windows/nsDeviceContextWin.cpp @@ -52,8 +52,6 @@ #include "nsString.h" static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID); -// Size of the color cube -#define COLOR_CUBE_SIZE 216 #define DOC_TITLE_LENGTH 64 static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); @@ -604,225 +602,6 @@ NS_IMETHODIMP nsDeviceContextWin::GetDepth(PRUint32& aDepth) return NS_OK; } -#define COLOR_CUBE_SIZE 216 - -nscolor map[COLOR_CUBE_SIZE] = { -NS_RGB(0x0, 0x0, 0x0 ), -NS_RGB(0x0, 0x0, 0x33), -NS_RGB(0x0, 0x0, 0x66), -NS_RGB(0x0, 0x0, 0x99), -NS_RGB(0x0, 0x0, 0xcc), -NS_RGB(0x0, 0x0, 0xff), -NS_RGB(0x0, 0x33, 0x0 ), -NS_RGB(0x0, 0x33, 0x33), -NS_RGB(0x0, 0x33, 0x66), -NS_RGB(0x0, 0x33, 0x99), -NS_RGB(0x0, 0x33, 0xcc), -NS_RGB(0x0, 0x33, 0xff), -NS_RGB(0x0, 0x66, 0x0 ), -NS_RGB(0x0, 0x66, 0x33), -NS_RGB(0x0, 0x66, 0x66), -NS_RGB(0x0, 0x66, 0x99), -NS_RGB(0x0, 0x66, 0xcc), -NS_RGB(0x0, 0x66, 0xff), -NS_RGB(0x0, 0x99, 0x0 ), -NS_RGB(0x0, 0x99, 0x33), -NS_RGB(0x0, 0x99, 0x66), -NS_RGB(0x0, 0x99, 0x99), -NS_RGB(0x0, 0x99, 0xcc), -NS_RGB(0x0, 0x99, 0xff), -NS_RGB(0x0, 0xcc, 0x0 ), -NS_RGB(0x0, 0xcc, 0x33), -NS_RGB(0x0, 0xcc, 0x66), -NS_RGB(0x0, 0xcc, 0x99), -NS_RGB(0x0, 0xcc, 0xcc), -NS_RGB(0x0, 0xcc, 0xff), -NS_RGB(0x0, 0xff, 0x0 ), -NS_RGB(0x0, 0xff, 0x33), -NS_RGB(0x0, 0xff, 0x66), -NS_RGB(0x0, 0xff, 0x99), -NS_RGB(0x0, 0xff, 0xcc), -NS_RGB(0x0, 0xff, 0xff), -NS_RGB(0x33, 0x0, 0x0 ), -NS_RGB(0x33, 0x0, 0x33), -NS_RGB(0x33, 0x0, 0x66), -NS_RGB(0x33, 0x0, 0x99), -NS_RGB(0x33, 0x0, 0xcc), -NS_RGB(0x33, 0x0, 0xff), -NS_RGB(0x33, 0x33, 0x0 ), -NS_RGB(0x33, 0x33, 0x33), -NS_RGB(0x33, 0x33, 0x66), -NS_RGB(0x33, 0x33, 0x99), -NS_RGB(0x33, 0x33, 0xcc), -NS_RGB(0x33, 0x33, 0xff), -NS_RGB(0x33, 0x66, 0x0 ), -NS_RGB(0x33, 0x66, 0x33), -NS_RGB(0x33, 0x66, 0x66), -NS_RGB(0x33, 0x66, 0x99), -NS_RGB(0x33, 0x66, 0xcc), -NS_RGB(0x33, 0x66, 0xff), -NS_RGB(0x33, 0x99, 0x0 ), -NS_RGB(0x33, 0x99, 0x33), -NS_RGB(0x33, 0x99, 0x66), -NS_RGB(0x33, 0x99, 0x99), -NS_RGB(0x33, 0x99, 0xcc), -NS_RGB(0x33, 0x99, 0xff), -NS_RGB(0x33, 0xcc, 0x0 ), -NS_RGB(0x33, 0xcc, 0x33), -NS_RGB(0x33, 0xcc, 0x66), -NS_RGB(0x33, 0xcc, 0x99), -NS_RGB(0x33, 0xcc, 0xcc), -NS_RGB(0x33, 0xcc, 0xff), -NS_RGB(0x33, 0xff, 0x0 ), -NS_RGB(0x33, 0xff, 0x33), -NS_RGB(0x33, 0xff, 0x66), -NS_RGB(0x33, 0xff, 0x99), -NS_RGB(0x33, 0xff, 0xcc), -NS_RGB(0x33, 0xff, 0xff), -NS_RGB(0x66, 0x0, 0x0 ), -NS_RGB(0x66, 0x0, 0x33), -NS_RGB(0x66, 0x0, 0x66), -NS_RGB(0x66, 0x0, 0x99), -NS_RGB(0x66, 0x0, 0xcc), -NS_RGB(0x66, 0x0, 0xff), -NS_RGB(0x66, 0x33, 0x0 ), -NS_RGB(0x66, 0x33, 0x33), -NS_RGB(0x66, 0x33, 0x66), -NS_RGB(0x66, 0x33, 0x99), -NS_RGB(0x66, 0x33, 0xcc), -NS_RGB(0x66, 0x33, 0xff), -NS_RGB(0x66, 0x66, 0x0 ), -NS_RGB(0x66, 0x66, 0x33), -NS_RGB(0x66, 0x66, 0x66), -NS_RGB(0x66, 0x66, 0x99), -NS_RGB(0x66, 0x66, 0xcc), -NS_RGB(0x66, 0x66, 0xff), -NS_RGB(0x66, 0x99, 0x0 ), -NS_RGB(0x66, 0x99, 0x33), -NS_RGB(0x66, 0x99, 0x66), -NS_RGB(0x66, 0x99, 0x99), -NS_RGB(0x66, 0x99, 0xcc), -NS_RGB(0x66, 0x99, 0xff), -NS_RGB(0x66, 0xcc, 0x0 ), -NS_RGB(0x66, 0xcc, 0x33), -NS_RGB(0x66, 0xcc, 0x66), -NS_RGB(0x66, 0xcc, 0x99), -NS_RGB(0x66, 0xcc, 0xcc), -NS_RGB(0x66, 0xcc, 0xff), -NS_RGB(0x66, 0xff, 0x0 ), -NS_RGB(0x66, 0xff, 0x33), -NS_RGB(0x66, 0xff, 0x66), -NS_RGB(0x66, 0xff, 0x99), -NS_RGB(0x66, 0xff, 0xcc), -NS_RGB(0x66, 0xff, 0xff), -NS_RGB(0x99, 0x0, 0x0 ), -NS_RGB(0x99, 0x0, 0x33), -NS_RGB(0x99, 0x0, 0x66), -NS_RGB(0x99, 0x0, 0x99), -NS_RGB(0x99, 0x0, 0xcc), -NS_RGB(0x99, 0x0, 0xff), -NS_RGB(0x99, 0x33, 0x0 ), -NS_RGB(0x99, 0x33, 0x33), -NS_RGB(0x99, 0x33, 0x66), -NS_RGB(0x99, 0x33, 0x99), -NS_RGB(0x99, 0x33, 0xcc), -NS_RGB(0x99, 0x33, 0xff), -NS_RGB(0x99, 0x66, 0x0 ), -NS_RGB(0x99, 0x66, 0x33), -NS_RGB(0x99, 0x66, 0x66), -NS_RGB(0x99, 0x66, 0x99), -NS_RGB(0x99, 0x66, 0xcc), -NS_RGB(0x99, 0x66, 0xff), -NS_RGB(0x99, 0x99, 0x0 ), -NS_RGB(0x99, 0x99, 0x33), -NS_RGB(0x99, 0x99, 0x66), -NS_RGB(0x99, 0x99, 0x99), -NS_RGB(0x99, 0x99, 0xcc), -NS_RGB(0x99, 0x99, 0xff), -NS_RGB(0x99, 0xcc, 0x0 ), -NS_RGB(0x99, 0xcc, 0x33), -NS_RGB(0x99, 0xcc, 0x66), -NS_RGB(0x99, 0xcc, 0x99), -NS_RGB(0x99, 0xcc, 0xcc), -NS_RGB(0x99, 0xcc, 0xff), -NS_RGB(0x99, 0xff, 0x0 ), -NS_RGB(0x99, 0xff, 0x33), -NS_RGB(0x99, 0xff, 0x66), -NS_RGB(0x99, 0xff, 0x99), -NS_RGB(0x99, 0xff, 0xcc), -NS_RGB(0x99, 0xff, 0xff), -NS_RGB(0xcc, 0x0, 0x0 ), -NS_RGB(0xcc, 0x0, 0x33), -NS_RGB(0xcc, 0x0, 0x66), -NS_RGB(0xcc, 0x0, 0x99), -NS_RGB(0xcc, 0x0, 0xcc), -NS_RGB(0xcc, 0x0, 0xff), -NS_RGB(0xcc, 0x33, 0x0 ), -NS_RGB(0xcc, 0x33, 0x33), -NS_RGB(0xcc, 0x33, 0x66), -NS_RGB(0xcc, 0x33, 0x99), -NS_RGB(0xcc, 0x33, 0xcc), -NS_RGB(0xcc, 0x33, 0xff), -NS_RGB(0xcc, 0x66, 0x0 ), -NS_RGB(0xcc, 0x66, 0x33), -NS_RGB(0xcc, 0x66, 0x66), -NS_RGB(0xcc, 0x66, 0x99), -NS_RGB(0xcc, 0x66, 0xcc), -NS_RGB(0xcc, 0x66, 0xff), -NS_RGB(0xcc, 0x99, 0x0 ), -NS_RGB(0xcc, 0x99, 0x33), -NS_RGB(0xcc, 0x99, 0x66), -NS_RGB(0xcc, 0x99, 0x99), -NS_RGB(0xcc, 0x99, 0xcc), -NS_RGB(0xcc, 0x99, 0xff), -NS_RGB(0xcc, 0xcc, 0x0 ), -NS_RGB(0xcc, 0xcc, 0x33), -NS_RGB(0xcc, 0xcc, 0x66), -NS_RGB(0xcc, 0xcc, 0x99), -NS_RGB(0xcc, 0xcc, 0xcc), -NS_RGB(0xcc, 0xcc, 0xff), -NS_RGB(0xcc, 0xff, 0x0 ), -NS_RGB(0xcc, 0xff, 0x33), -NS_RGB(0xcc, 0xff, 0x66), -NS_RGB(0xcc, 0xff, 0x99), -NS_RGB(0xcc, 0xff, 0xcc), -NS_RGB(0xcc, 0xff, 0xff), -NS_RGB(0xff, 0x0, 0x0 ), -NS_RGB(0xff, 0x0, 0x33), -NS_RGB(0xff, 0x0, 0x66), -NS_RGB(0xff, 0x0, 0x99), -NS_RGB(0xff, 0x0, 0xcc), -NS_RGB(0xff, 0x0, 0xff), -NS_RGB(0xff, 0x33, 0x0 ), -NS_RGB(0xff, 0x33, 0x33), -NS_RGB(0xff, 0x33, 0x66), -NS_RGB(0xff, 0x33, 0x99), -NS_RGB(0xff, 0x33, 0xcc), -NS_RGB(0xff, 0x33, 0xff), -NS_RGB(0xff, 0x66, 0x0 ), -NS_RGB(0xff, 0x66, 0x33), -NS_RGB(0xff, 0x66, 0x66), -NS_RGB(0xff, 0x66, 0x99), -NS_RGB(0xff, 0x66, 0xcc), -NS_RGB(0xff, 0x66, 0xff), -NS_RGB(0xff, 0x99, 0x0 ), -NS_RGB(0xff, 0x99, 0x33), -NS_RGB(0xff, 0x99, 0x66), -NS_RGB(0xff, 0x99, 0x99), -NS_RGB(0xff, 0x99, 0xcc), -NS_RGB(0xff, 0x99, 0xff), -NS_RGB(0xff, 0xcc, 0x0 ), -NS_RGB(0xff, 0xcc, 0x33), -NS_RGB(0xff, 0xcc, 0x66), -NS_RGB(0xff, 0xcc, 0x99), -NS_RGB(0xff, 0xcc, 0xcc), -NS_RGB(0xff, 0xcc, 0xff), -NS_RGB(0xff, 0xff, 0x0 ), -NS_RGB(0xff, 0xff, 0x33), -NS_RGB(0xff, 0xff, 0x66), -NS_RGB(0xff, 0xff, 0x99), -NS_RGB(0xff, 0xff, 0xcc), -NS_RGB(0xff, 0xff, 0xff)}; NS_IMETHODIMP nsDeviceContextWin::GetPaletteInfo(nsPaletteInfo& aPaletteInfo) { @@ -831,38 +610,15 @@ NS_IMETHODIMP nsDeviceContextWin::GetPaletteInfo(nsPaletteInfo& aPaletteInfo) aPaletteInfo.numReserved = mPaletteInfo.numReserved; if (NULL == mPaletteInfo.palette) { - // Create a logical palette - BYTE tmp[sizeof(LOGPALETTE) + ((COLOR_CUBE_SIZE + 20) * sizeof(PALETTEENTRY))]; - LPLOGPALETTE logPal = (LPLOGPALETTE)tmp; - - logPal->palVersion = 0x300; - logPal->palNumEntries = COLOR_CUBE_SIZE + 20; - - // Initialize it from the default Windows palette - HPALETTE hDefaultPalette = (HPALETTE)::GetStockObject(DEFAULT_PALETTE); - - // First ten system colors - ::GetPaletteEntries(hDefaultPalette, 0, 10, logPal->palPalEntry); - - // Last ten system colors - ::GetPaletteEntries(hDefaultPalette, 10, 10, &logPal->palPalEntry[COLOR_CUBE_SIZE + 10]); - - // Now set the color cube entries. - PALETTEENTRY* entry = &logPal->palPalEntry[10]; - for (PRInt32 i = 0; i < COLOR_CUBE_SIZE; i++) { - entry->peRed = NS_GET_R(map[i]); - entry->peGreen = NS_GET_G(map[i]); - entry->peBlue = NS_GET_B(map[i]); - entry->peFlags = 0; - - entry++; - } - - // Create a GDI palette - mPaletteInfo.palette = ::CreatePalette(logPal); + HWND hwnd = (HWND)mWidget; + HDC hdc = ::GetDC(hwnd); + mPaletteInfo.palette = ::CreateHalftonePalette(hdc); + ::SetStretchBltMode(hdc, HALFTONE); + ::ReleaseDC(hwnd, hdc); } aPaletteInfo.palette = mPaletteInfo.palette; + return NS_OK; } diff --git a/gfx/src/windows/nsImageWin.cpp b/gfx/src/windows/nsImageWin.cpp index 617055c4bb0..b1cda706828 100644 --- a/gfx/src/windows/nsImageWin.cpp +++ b/gfx/src/windows/nsImageWin.cpp @@ -525,9 +525,12 @@ nsImageWin :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, } } } else { + int saveMode = ::GetStretchBltMode(TheHDC); + ::SetStretchBltMode(TheHDC, HALFTONE); ::StretchDIBits(TheHDC, aDX, aDY, aDWidth, aDHeight,aSX, srcy, aSWidth, aSHeight, mAlphaBits, (LPBITMAPINFO)&bmi, DIB_RGB_COLORS, SRCAND); rop = SRCPAINT; + ::SetStretchBltMode(TheHDC, saveMode); } } } @@ -547,7 +550,10 @@ nsImageWin :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, blendFunction.AlphaFormat = 1 /*AC_SRC_ALPHA*/; gAlphaBlend(TheHDC, aDX, aDY, aDWidth, aDHeight, srcDC, aSX, aSY, aSWidth, aSHeight, blendFunction); } else { + int saveMode = ::GetStretchBltMode(TheHDC); + ::SetStretchBltMode(TheHDC, HALFTONE); ::StretchBlt(TheHDC, aDX, aDY, aDWidth, aDHeight, srcDC, aSX, aSY,aSWidth, aSHeight, rop); + ::SetStretchBltMode(TheHDC, saveMode); } }else{ if (! didComposite) @@ -565,7 +571,10 @@ nsImageWin :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, blendFunction.AlphaFormat = 1 /*AC_SRC_ALPHA*/; gAlphaBlend(TheHDC, aDX, aDY, aDWidth, aDHeight, srcDC, aSX, aSY, aSWidth, aSHeight, blendFunction); } else { + int saveMode = ::GetStretchBltMode(TheHDC); + ::SetStretchBltMode(TheHDC, HALFTONE); ::StretchBlt(TheHDC,aDX,aDY,aDWidth,aDHeight,srcDC,aSX,aSY,aSWidth,aSHeight,rop); + ::SetStretchBltMode(TheHDC, saveMode); } } @@ -624,8 +633,11 @@ void nsImageWin::DrawComposited(HDC TheHDC, int aDX, int aDY, int aDWidth, int a DrawComposited24(screenBits, aSX, aSY, aSWidth, aSHeight); /* Copy back to the HDC */ + int saveMode = ::GetStretchBltMode(TheHDC); + ::SetStretchBltMode(TheHDC, HALFTONE); ::StretchBlt(TheHDC, aDX, aDY, aDWidth, aDHeight, memDC, 0, 0, aSWidth, aSHeight, SRCCOPY); + ::SetStretchBltMode(TheHDC, saveMode); ::SelectObject(memDC, oldBitmap); ::DeleteObject(tmpBitmap); diff --git a/gfx/src/windows/nsRenderingContextWin.cpp b/gfx/src/windows/nsRenderingContextWin.cpp index 7fe3a316add..078d498fee8 100644 --- a/gfx/src/windows/nsRenderingContextWin.cpp +++ b/gfx/src/windows/nsRenderingContextWin.cpp @@ -445,7 +445,7 @@ nsresult nsRenderingContextWin :: SetupDC(HDC aOldDC, HDC aNewDC) mCurrTextColor = mCurrentColor; ::SetBkMode(aNewDC, TRANSPARENT); ::SetPolyFillMode(aNewDC, WINDING); - ::SetStretchBltMode(aNewDC, COLORONCOLOR); + ::SetStretchBltMode(aNewDC, HALFTONE); ::SetTextAlign(aNewDC, TA_BASELINE); if (nsnull != aOldDC) @@ -488,7 +488,7 @@ nsresult nsRenderingContextWin :: SetupDC(HDC aOldDC, HDC aNewDC) if (palInfo.isPaletteDevice && palInfo.palette) { // Select the palette in the background - ::SelectPalette(aNewDC, (HPALETTE)palInfo.palette, PR_FALSE); + ::SelectPalette(aNewDC, (HPALETTE)palInfo.palette, PR_TRUE); ::RealizePalette(aNewDC); } @@ -537,9 +537,8 @@ NS_IMETHODIMP nsRenderingContextWin :: LockDrawingSurface(PRInt32 aX, PRInt32 aY mContext->GetPaletteInfo(palInfo); if(palInfo.isPaletteDevice && palInfo.palette){ - ::SelectPalette(mDC,(HPALETTE)palInfo.palette,PR_FALSE); + ::SelectPalette(mDC,(HPALETTE)palInfo.palette,PR_TRUE); ::RealizePalette(mDC); - ::UpdateColors(mDC); } } @@ -2635,9 +2634,8 @@ NS_IMETHODIMP nsRenderingContextWin :: CopyOffScreenBits(nsDrawingSurface aSrcSu mContext->GetPaletteInfo(palInfo); if (palInfo.isPaletteDevice && palInfo.palette){ - ::SelectPalette(destdc, (HPALETTE)palInfo.palette, PR_FALSE); + ::SelectPalette(destdc, (HPALETTE)palInfo.palette, PR_TRUE); ::RealizePalette(destdc); - ::UpdateColors(destdc); } if (aCopyFlags & NS_COPYBITS_XFORM_SOURCE_VALUES) diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index 6b3561e254d..97c75da75d2 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -3866,7 +3866,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT mContext->GetPaletteInfo(palInfo); if (palInfo.isPaletteDevice && palInfo.palette) { HDC hDC = ::GetDC(mWnd); - HPALETTE hOldPal = ::SelectPalette(hDC, (HPALETTE)palInfo.palette, FALSE); + HPALETTE hOldPal = ::SelectPalette(hDC, (HPALETTE)palInfo.palette, TRUE); // Realize the drawing palette int i = ::RealizePalette(hDC);