This commit is contained in:
pavlov%netscape.com 2002-06-14 18:25:33 +00:00
Родитель 2d108bf4b9
Коммит 82c9c6b6dc
2 изменённых файлов: 30 добавлений и 10 удалений

Просмотреть файл

@ -44,17 +44,16 @@ static nsresult BuildDIB(LPBITMAPINFOHEADER *aBHead,PRInt32 aWidth,PRInt32 aHei
static PRBool static PRInt32 GetPlatform()
IsWindowsNT()
{ {
OSVERSIONINFO versionInfo; OSVERSIONINFO versionInfo;
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo); versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
::GetVersionEx(&versionInfo); ::GetVersionEx(&versionInfo);
return VER_PLATFORM_WIN32_NT == versionInfo.dwPlatformId; return versionInfo.dwPlatformId;
} }
PRBool nsImageWin::gIsWinNT = IsWindowsNT(); PRInt32 nsImageWin::gPlatform = GetPlatform();
/** ---------------------------------------------------------------- /** ----------------------------------------------------------------
* Constructor for nsImageWin * Constructor for nsImageWin
@ -333,6 +332,11 @@ void nsImageWin::CreateImageWithAlphaBits(HDC TheHDC)
mHBitmap = ::CreateDIBSection(TheHDC, (LPBITMAPINFO)&bmi, DIB_RGB_COLORS, mHBitmap = ::CreateDIBSection(TheHDC, (LPBITMAPINFO)&bmi, DIB_RGB_COLORS,
(LPVOID *)&imageWithAlphaBits, NULL, 0); (LPVOID *)&imageWithAlphaBits, NULL, 0);
if (!mHBitmap) {
mIsOptimized = PR_FALSE;
return;
}
if (256 == mNumPaletteColors) { if (256 == mNumPaletteColors) {
for (int y = 0; y < mBHead->biHeight; y++) { for (int y = 0; y < mBHead->biHeight; y++) {
unsigned char *imageWithAlphaRow = imageWithAlphaBits + y * mBHead->biWidth * 4; unsigned char *imageWithAlphaRow = imageWithAlphaBits + y * mBHead->biWidth * 4;
@ -365,6 +369,7 @@ void nsImageWin::CreateImageWithAlphaBits(HDC TheHDC)
} }
} }
} }
mIsOptimized = PR_TRUE;
} }
/** --------------------------------------------------- /** ---------------------------------------------------
@ -391,10 +396,11 @@ nsImageWin :: CreateDDB(nsDrawingSurface aSurface)
} else { } else {
mHBitmap = ::CreateDIBitmap(TheHDC,mBHead,CBM_INIT,mImageBits,(LPBITMAPINFO)mBHead, mHBitmap = ::CreateDIBitmap(TheHDC,mBHead,CBM_INIT,mImageBits,(LPBITMAPINFO)mBHead,
256==mNumPaletteColors?DIB_PAL_COLORS:DIB_RGB_COLORS); 256==mNumPaletteColors?DIB_PAL_COLORS:DIB_RGB_COLORS);
mIsOptimized = (mHBitmap != 0);
} }
mIsOptimized = PR_TRUE;
//CleanUp(PR_FALSE); //CleanUp(PR_FALSE);
CleanUpDIB(); if (mIsOptimized)
CleanUpDIB();
} }
((nsDrawingSurfaceWin *)aSurface)->ReleaseDC(); ((nsDrawingSurfaceWin *)aSurface)->ReleaseDC();
} }
@ -617,6 +623,11 @@ void nsImageWin::DrawComposited(HDC TheHDC, int aDX, int aDY, int aDWidth, int a
ALPHA24BITMAPINFO bmi(aSWidth, aSHeight); ALPHA24BITMAPINFO bmi(aSWidth, aSHeight);
HBITMAP tmpBitmap = ::CreateDIBSection(memDC, (LPBITMAPINFO)&bmi, DIB_RGB_COLORS, HBITMAP tmpBitmap = ::CreateDIBSection(memDC, (LPBITMAPINFO)&bmi, DIB_RGB_COLORS,
(LPVOID *)&screenBits, NULL, 0); (LPVOID *)&screenBits, NULL, 0);
if (!tmpBitmap) {
::DeleteDC(memDC);
NS_WARNING("nsImageWin::DrawComposited failed to create tmpBitmap\n");
return;
}
HBITMAP oldBitmap = (HBITMAP)::SelectObject(memDC, tmpBitmap); HBITMAP oldBitmap = (HBITMAP)::SelectObject(memDC, tmpBitmap);
/* Copy from the HDC */ /* Copy from the HDC */
@ -979,8 +990,12 @@ nsresult
nsImageWin :: Optimize(nsIDeviceContext* aContext) nsImageWin :: Optimize(nsIDeviceContext* aContext)
{ {
// Just set the flag sinze we may not have a valid HDC, like at startup, but at drawtime we do have a valid HDC // Just set the flag sinze we may not have a valid HDC, like at startup, but at drawtime we do have a valid HDC
if ((8 != mAlphaDepth) || CanAlphaBlend())
mCanOptimize = PR_TRUE; // Windows 95/98/Me: DDB size cannot exceed 16MB in size.
if (gPlatform == VER_PLATFORM_WIN32_WINDOWS && mSizeImage >= 0xFF0000)
mCanOptimize = PR_FALSE;
else if ((8 != mAlphaDepth) || CanAlphaBlend())
mCanOptimize = PR_TRUE;
return NS_OK; return NS_OK;
} }
@ -1338,6 +1353,10 @@ NS_IMETHODIMP nsImageWin::DrawToImage(nsIImage* aDstImage, nscoord aDX, nscoord
if (imgWin->mSizeImage > 0) { if (imgWin->mSizeImage > 0) {
void* bits; void* bits;
imgWin->mHBitmap = CreateDIBSection(dstMemDC,(LPBITMAPINFO)imgWin->mBHead,DIB_RGB_COLORS,&bits,nsnull,nsnull); imgWin->mHBitmap = CreateDIBSection(dstMemDC,(LPBITMAPINFO)imgWin->mBHead,DIB_RGB_COLORS,&bits,nsnull,nsnull);
if (!imgWin->mHBitmap) {
::DeleteDC(dstMemDC);
return NS_ERROR_UNEXPECTED;
}
imgWin->mDIBSection = imgWin->mHBitmap; imgWin->mDIBSection = imgWin->mHBitmap;
oldDstBits = (HBITMAP)::SelectObject(dstMemDC, imgWin->mHBitmap); oldDstBits = (HBITMAP)::SelectObject(dstMemDC, imgWin->mHBitmap);

Просмотреть файл

@ -189,8 +189,9 @@ public:
NS_IMETHOD LockImagePixels(PRBool aMaskPixels); NS_IMETHOD LockImagePixels(PRBool aMaskPixels);
NS_IMETHOD UnlockImagePixels(PRBool aMaskPixels); NS_IMETHOD UnlockImagePixels(PRBool aMaskPixels);
// VER_PLATFORM_WIN32_WINDOWS == Win 95/98/ME
static PRBool gIsWinNT; // VER_PLATFORM_WIN32_NT == Win NT/2K/XP/.NET Server
static PRInt32 gPlatform;
private: private:
/** /**