Use the passed in values of aHeight & aWidth rather than the size of aView to determine the size of offscreen bitmap.

Thanks to Makoto Hamanaka <VYA04230@nifty.com> for the patch.
Bug #68072 r=cls a=asa
This commit is contained in:
cls%seawood.org 2001-06-17 00:06:15 +00:00
Родитель f3de1c990d
Коммит b9389f0571
1 изменённых файлов: 44 добавлений и 45 удалений

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

@ -106,7 +106,7 @@ NS_IMETHODIMP nsDrawingSurfaceBeOS :: Lock(PRInt32 aX, PRInt32 aY,
printf("Time taken to lock: %d\n", PR_Now() - mLockTime); printf("Time taken to lock: %d\n", PR_Now() - mLockTime);
#endif #endif
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDrawingSurfaceBeOS :: Unlock(void) NS_IMETHODIMP nsDrawingSurfaceBeOS :: Unlock(void)
@ -153,20 +153,20 @@ NS_IMETHODIMP nsDrawingSurfaceBeOS :: GetDimensions(PRUint32 *aWidth, PRUint32 *
NS_IMETHODIMP nsDrawingSurfaceBeOS :: IsOffscreen(PRBool *aOffScreen) NS_IMETHODIMP nsDrawingSurfaceBeOS :: IsOffscreen(PRBool *aOffScreen)
{ {
*aOffScreen = mIsOffscreen;//mBitmap ? PR_TRUE : PR_FALSE; *aOffScreen = mIsOffscreen;//mBitmap ? PR_TRUE : PR_FALSE;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDrawingSurfaceBeOS :: IsPixelAddressable(PRBool *aAddressable) NS_IMETHODIMP nsDrawingSurfaceBeOS :: IsPixelAddressable(PRBool *aAddressable)
{ {
*aAddressable = PR_FALSE; *aAddressable = PR_FALSE;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDrawingSurfaceBeOS :: GetPixelFormat(nsPixelFormat *aFormat) NS_IMETHODIMP nsDrawingSurfaceBeOS :: GetPixelFormat(nsPixelFormat *aFormat)
{ {
*aFormat = mPixFormat; *aFormat = mPixFormat;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDrawingSurfaceBeOS :: Init(BView *aView) NS_IMETHODIMP nsDrawingSurfaceBeOS :: Init(BView *aView)
@ -177,7 +177,7 @@ NS_IMETHODIMP nsDrawingSurfaceBeOS :: Init(BView *aView)
mWidth=nscoord(aView->Bounds().Width()); mWidth=nscoord(aView->Bounds().Width());
mHeight=nscoord(aView->Bounds().Height()); mHeight=nscoord(aView->Bounds().Height());
mView = aView; mView = aView;
aView->UnlockLooper(); aView->UnlockLooper();
} }
@ -187,75 +187,74 @@ NS_IMETHODIMP nsDrawingSurfaceBeOS :: Init(BView *aView)
// widget or something. // widget or something.
mIsOffscreen = PR_FALSE; mIsOffscreen = PR_FALSE;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDrawingSurfaceBeOS :: Init(BView *aView, PRUint32 aWidth, NS_IMETHODIMP nsDrawingSurfaceBeOS :: Init(BView *aView, PRUint32 aWidth,
PRUint32 aHeight, PRUint32 aFlags) PRUint32 aHeight, PRUint32 aFlags)
{ {
NS_ASSERTION(!(aView == nsnull), "null BView"); NS_ASSERTION(!(aView == nsnull), "null BView");
//remember dimensions //remember dimensions
mWidth=aWidth; mWidth=aWidth;
mHeight=aHeight; mHeight=aHeight;
mFlags = aFlags; mFlags = aFlags;
// we can draw on this offscreen because it has no parent // we can draw on this offscreen because it has no parent
mIsOffscreen = PR_TRUE; mIsOffscreen = PR_TRUE;
BRect r = aView->Bounds(); BRect r(0,0, mWidth-1, mHeight-1);
mView = new BView(r, "", 0, 0); mView = new BView(r, "", 0, 0);
if (mView==NULL) if (!mView)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
// if((aFlags & NS_CREATEDRAWINGSURFACE_FOR_PIXEL_ACCESS) && //if((aFlags & NS_CREATEDRAWINGSURFACE_FOR_PIXEL_ACCESS) &&
// (aWidth > 0) && (aHeight > 0)) // (aWidth > 0) && (aHeight > 0))
if(aWidth > 0 && aHeight > 0) if(aWidth > 0 && aHeight > 0)
{ {
mBitmap = new BBitmap(r, B_RGBA32, true); mBitmap = new BBitmap(r, B_RGBA32, true);
if (mBitmap==NULL) if (!mBitmap)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
if (mBitmap->InitCheck()!=B_OK) { if (mBitmap->InitCheck()!=B_OK) {
//for some reason, the bitmap isn't valid - delete the //for some reason, the bitmap isn't valid - delete the
//bitmap object, then indicate failure //bitmap object, then indicate failure
delete mBitmap; delete mBitmap;
mBitmap=NULL; mBitmap=NULL;
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
mBitmap->AddChild(mView); mBitmap->AddChild(mView);
} }
return NS_OK;
return NS_OK;
} }
NS_IMETHODIMP nsDrawingSurfaceBeOS :: AcquireView(BView **aView) NS_IMETHODIMP nsDrawingSurfaceBeOS :: AcquireView(BView **aView)
{ {
*aView = mView; *aView = mView;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDrawingSurfaceBeOS :: AcquireBitmap(BBitmap **aBitmap) NS_IMETHODIMP nsDrawingSurfaceBeOS :: AcquireBitmap(BBitmap **aBitmap)
{ {
if(mBitmap && mBitmap->Lock()) if(mBitmap && mBitmap->Lock())
{ {
mView->Sync(); mView->Sync();
mBitmap->Unlock(); mBitmap->Unlock();
} }
*aBitmap = mBitmap; *aBitmap = mBitmap;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDrawingSurfaceBeOS :: ReleaseView(void) NS_IMETHODIMP nsDrawingSurfaceBeOS :: ReleaseView(void)
{ {
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDrawingSurfaceBeOS :: ReleaseBitmap(void) NS_IMETHODIMP nsDrawingSurfaceBeOS :: ReleaseBitmap(void)
{ {
return NS_OK; return NS_OK;
} }