r=mkaply, sr=blizzard (OS/2 specific), a=mkaply
OS/2 only - bad handling of presentation spaces
This commit is contained in:
mkaply%us.ibm.com 2003-06-02 20:37:00 +00:00
Родитель 4983ab23c5
Коммит 19acabcc8e
2 изменённых файлов: 20 добавлений и 9 удалений

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

@ -36,7 +36,7 @@ NS_IMPL_ISUPPORTS1(nsDrawingSurfaceOS2, nsIDrawingSurface)
// do testing with, and 0 is, of course, LCID_DEFAULT. // do testing with, and 0 is, of course, LCID_DEFAULT.
nsDrawingSurfaceOS2::nsDrawingSurfaceOS2() nsDrawingSurfaceOS2::nsDrawingSurfaceOS2()
: mNextID(2), mTopID(1), mPS(0), : mNextID(2), mTopID(1), mPS(0), mOwnPS(PR_FALSE),
mWidth (0), mHeight (0) mWidth (0), mHeight (0)
{ {
mHTFonts = new nsHashtable; mHTFonts = new nsHashtable;
@ -189,6 +189,8 @@ nsresult nsOffscreenSurface::Init( HPS aCompatiblePS,
if( GPI_ERROR != mPS) if( GPI_ERROR != mPS)
{ {
mOwnPS = PR_TRUE;
nsPaletteOS2::SelectGlobalPalette(mPS); nsPaletteOS2::SelectGlobalPalette(mPS);
// now create a bitmap of the right size // now create a bitmap of the right size
@ -222,14 +224,19 @@ nsresult nsOffscreenSurface::Init( HPS aCompatiblePS,
nsOffscreenSurface::~nsOffscreenSurface() nsOffscreenSurface::~nsOffscreenSurface()
{ {
if( mPS) DisposeFonts();
{
DisposeFonts(); if (mBitmap) {
GFX (::GpiSetBitmap (mPS, 0), HBM_ERROR); GFX (::GpiSetBitmap (mPS, 0), HBM_ERROR);
GFX (::GpiDeleteBitmap (mBitmap), FALSE); GFX (::GpiDeleteBitmap (mBitmap), FALSE);
GFX (::GpiDestroyPS (mPS), FALSE);
::DevCloseDC( mDC);
} }
if (mOwnPS) {
GFX (::GpiDestroyPS (mPS), FALSE);
}
if (mDC) {
::DevCloseDC(mDC);
}
if( mInfoHeader) if( mInfoHeader)
free( mInfoHeader); free( mInfoHeader);
delete [] mBits; delete [] mBits;
@ -517,9 +524,11 @@ nsWindowSurface::~nsWindowSurface()
// need to do this now because hps is invalid after subsequent free // need to do this now because hps is invalid after subsequent free
DisposeFonts(); DisposeFonts();
// release hps
mWidget->FreeNativeData( (void*) mPS, NS_NATIVE_GRAPHIC); // release hps if we had instantiated it
mPS = 0; // just for safety if (mOwnPS) {
mWidget->FreeNativeData( (void*) mPS, NS_NATIVE_GRAPHIC);
}
} }
NS_IMETHODIMP nsWindowSurface::Init(HPS aPS, nsIWidget *aWidget) NS_IMETHODIMP nsWindowSurface::Init(HPS aPS, nsIWidget *aWidget)
@ -534,6 +543,7 @@ nsresult nsWindowSurface::Init( nsIWidget *aOwner)
{ {
mWidget = aOwner; mWidget = aOwner;
mPS = (HPS) mWidget->GetNativeData( NS_NATIVE_GRAPHIC); mPS = (HPS) mWidget->GetNativeData( NS_NATIVE_GRAPHIC);
mOwnPS = PR_TRUE;
return NS_OK; return NS_OK;
} }

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

@ -58,6 +58,7 @@ class nsDrawingSurfaceOS2 : public nsIDrawingSurface
protected: protected:
HPS mPS; // presentation space for this surface HPS mPS; // presentation space for this surface
PRBool mOwnPS; // did we instantiate PS or was it passed in?
PRInt32 mWidth; // dimensions of drawing surface PRInt32 mWidth; // dimensions of drawing surface
PRInt32 mHeight; PRInt32 mHeight;