From b5444e769f9276cd1d91ed1c1e3eff724ea4e4bd Mon Sep 17 00:00:00 2001 From: "saari%netscape.com" Date: Wed, 1 May 2002 22:03:34 +0000 Subject: [PATCH] Fixing bugzilla 102321, regression in scrolling performance. Should also fix 256 color rendering regression. r=dcone, sr=jag git-svn-id: svn://10.0.0.236/trunk@120464 18797224-902f-48f8-a5cc-f745e15eee43 --- .../gfx/src/windows/nsDeviceContextWin.cpp | 1 - mozilla/gfx/src/windows/nsImageWin.cpp | 22 +++++++------------ .../gfx/src/windows/nsRenderingContextWin.cpp | 15 +++++++++---- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/mozilla/gfx/src/windows/nsDeviceContextWin.cpp b/mozilla/gfx/src/windows/nsDeviceContextWin.cpp index 0b4c05e17e0..14d7ae71255 100644 --- a/mozilla/gfx/src/windows/nsDeviceContextWin.cpp +++ b/mozilla/gfx/src/windows/nsDeviceContextWin.cpp @@ -617,7 +617,6 @@ NS_IMETHODIMP nsDeviceContextWin::GetPaletteInfo(nsPaletteInfo& aPaletteInfo) HWND hwnd = (HWND)mWidget; HDC hdc = ::GetDC(hwnd); mPaletteInfo.palette = ::CreateHalftonePalette(hdc); - ::SetStretchBltMode(hdc, HALFTONE); ::ReleaseDC(hwnd, hdc); } diff --git a/mozilla/gfx/src/windows/nsImageWin.cpp b/mozilla/gfx/src/windows/nsImageWin.cpp index 76314090847..88991355bab 100644 --- a/mozilla/gfx/src/windows/nsImageWin.cpp +++ b/mozilla/gfx/src/windows/nsImageWin.cpp @@ -379,6 +379,12 @@ nsImageWin :: CreateDDB(nsDrawingSurface aSurface) ((nsDrawingSurfaceWin *)aSurface)->GetDC(&TheHDC); if (TheHDC != NULL){ + // Temporary fix for bug 135226 until we do better decode-time + // dithering and paletized storage of images. Bail on the + // optimization to DDB if we're on a paletted device. + int rasterCaps = ::GetDeviceCaps(TheHDC, RASTERCAPS); + if (RC_PALETTE == (rasterCaps & RC_PALETTE)) return; + if (mSizeImage > 0){ if (mAlphaDepth == 8) { CreateImageWithAlphaBits(TheHDC); @@ -522,12 +528,9 @@ 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); } } } @@ -546,11 +549,8 @@ nsImageWin :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, blendFunction.SourceConstantAlpha = 255; 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); + } else { ::StretchBlt(TheHDC, aDX, aDY, aDWidth, aDHeight, srcDC, aSX, aSY,aSWidth, aSHeight, rop); - ::SetStretchBltMode(TheHDC, saveMode); } }else{ if (! didComposite) @@ -567,11 +567,8 @@ nsImageWin :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, blendFunction.SourceConstantAlpha = 255; 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); + } else { ::StretchBlt(TheHDC,aDX,aDY,aDWidth,aDHeight,srcDC,aSX,aSY,aSWidth,aSHeight,rop); - ::SetStretchBltMode(TheHDC, saveMode); } } @@ -630,11 +627,8 @@ 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/mozilla/gfx/src/windows/nsRenderingContextWin.cpp b/mozilla/gfx/src/windows/nsRenderingContextWin.cpp index 850f0b96031..c84389fb0ce 100644 --- a/mozilla/gfx/src/windows/nsRenderingContextWin.cpp +++ b/mozilla/gfx/src/windows/nsRenderingContextWin.cpp @@ -445,7 +445,15 @@ nsresult nsRenderingContextWin :: SetupDC(HDC aOldDC, HDC aNewDC) mCurrTextColor = mCurrentColor; ::SetBkMode(aNewDC, TRANSPARENT); ::SetPolyFillMode(aNewDC, WINDING); - ::SetStretchBltMode(aNewDC, HALFTONE); + // Temporary fix for bug 135226 until we do better decode-time + // dithering and paletized storage of images. + nsPaletteInfo palInfo; + mContext->GetPaletteInfo(palInfo); + if (palInfo.isPaletteDevice) + ::SetStretchBltMode(aNewDC, HALFTONE); + else + ::SetStretchBltMode(aNewDC, COLORONCOLOR); + ::SetTextAlign(aNewDC, TA_BASELINE); if (nsnull != aOldDC) @@ -482,9 +490,6 @@ nsresult nsRenderingContextWin :: SetupDC(HDC aOldDC, HDC aNewDC) #endif // If this is a palette device, then select and realize the palette - nsPaletteInfo palInfo; - mContext->GetPaletteInfo(palInfo); - if (palInfo.isPaletteDevice && palInfo.palette) { // Select the palette in the background @@ -539,6 +544,7 @@ NS_IMETHODIMP nsRenderingContextWin :: LockDrawingSurface(PRInt32 aX, PRInt32 aY if(palInfo.isPaletteDevice && palInfo.palette){ ::SelectPalette(mDC,(HPALETTE)palInfo.palette,PR_TRUE); ::RealizePalette(mDC); + ::UpdateColors(mDC); } } @@ -2636,6 +2642,7 @@ NS_IMETHODIMP nsRenderingContextWin :: CopyOffScreenBits(nsDrawingSurface aSrcSu if (palInfo.isPaletteDevice && palInfo.palette){ ::SelectPalette(destdc, (HPALETTE)palInfo.palette, PR_TRUE); ::RealizePalette(destdc); + ::UpdateColors(mDC); } if (aCopyFlags & NS_COPYBITS_XFORM_SOURCE_VALUES)