r=mkaply, a=blizzard
Code from Javier - get images working again, cleanup nsRenderingContext
This commit is contained in:
mkaply%us.ibm.com 2001-04-19 22:00:56 +00:00
Родитель f8defeec04
Коммит 84b46ca0d7
4 изменённых файлов: 550 добавлений и 414 удалений

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

@ -475,7 +475,7 @@ nsresult nsImageOS2::Optimize( nsIDeviceContext* aContext)
void nsImageOS2::CreateBitmaps( nsDrawingSurfaceOS2 *surf)
{
mBitmap = GFX (::GpiCreateBitmap (surf->GetPS (), (PBITMAPINFOHEADER2)mInfo,
mBitmap = GFX (::GpiCreateBitmap (surf->GetPS(), (PBITMAPINFOHEADER2)mInfo,
CBM_INIT, (PBYTE)mImageBits, mInfo),
GPI_ERROR);
@ -484,7 +484,7 @@ void nsImageOS2::CreateBitmaps( nsDrawingSurfaceOS2 *surf)
if( mAlphaDepth == 1)
{
MONOBITMAPINFO maskInfo( mInfo);
mABitmap = GFX (::GpiCreateBitmap (surf->GetPS (), maskInfo, CBM_INIT,
mABitmap = GFX (::GpiCreateBitmap (surf->GetPS(), maskInfo, CBM_INIT,
(PBYTE)mAlphaBits, maskInfo),
GPI_ERROR);
}
@ -710,10 +710,114 @@ PRBool nsImageOS2::SlowTile (nsIRenderingContext& aContext, nsDrawingSurface aSu
}
#ifdef USE_IMG2
void nsImageOS2::NS2PM_ININ( const nsRect &in, RECTL &rcl)
{
PRUint32 ulHeight = GetHeight ();
rcl.xLeft = in.x;
rcl.xRight = in.x + in.width - 1;
rcl.yTop = ulHeight - in.y - 1;
rcl.yBottom = rcl.yTop - in.height + 1;
}
// ---------------------------------------------------
// Update mImageBits with content of new mBitmap
//
NS_IMETHODIMP nsImageOS2::UpdateImageBits( HPS mPS )
{
BITMAPINFOHEADER2 rawInfo = { 0 };
rawInfo.cbFix = sizeof (BITMAPINFOHEADER2);
rawInfo.cPlanes = 1;
rawInfo.cBitCount = mInfo->cBitCount;
int RawDataSize = mInfo->cy * RASWIDTH (mInfo->cx, mInfo->cBitCount);
PRUint8* pRawBitData = (PRUint8*)malloc (RawDataSize);
if (pRawBitData)
{
GFX (::GpiQueryBitmapBits (mPS, 0, mInfo->cy, (PBYTE)pRawBitData, (PBITMAPINFO2)&rawInfo), GPI_ALTERROR);
free (mImageBits);
mImageBits = pRawBitData;
return NS_OK;
}
else
return NS_ERROR_OUT_OF_MEMORY;
}
NS_IMETHODIMP nsImageOS2::DrawToImage(nsIImage* aDstImage,
nscoord aDX, nscoord aDY,
nscoord aDWidth, nscoord aDHeight)
{
return NS_ERROR_FAILURE;
HBITMAP oldBitmap;
int rc = NS_OK;
DEVOPENSTRUC dop = { 0, 0, 0, 0, 0 };
SIZEL sizel = { 0, 0 };
if (mInfo == nsnull || aDWidth < 0 || aDHeight < 0)
return NS_ERROR_FAILURE;
if (0 == aDWidth || 0 == aDHeight)
return NS_OK;
// Create a memory DC that is compatible with the screen
HDC destDC = GFX (::DevOpenDC( 0/*hab*/, OD_MEMORY, "*", 5,
(PDEVOPENDATA) &dop, (HDC)0), DEV_ERROR);
// create the PS
HPS destPS = GFX (::GpiCreatePS (0/*hab*/, destDC, &sizel,
PU_PELS | GPIT_MICRO | GPIA_ASSOC), GPI_ERROR);
nsImageOS2* destImg = NS_STATIC_CAST(nsImageOS2*, aDstImage);
if(!destImg->mBitmap)
{
destImg->mBitmap = GFX (::GpiCreateBitmap (destPS,
(PBITMAPINFOHEADER2)destImg->mInfo,
CBM_INIT, (PBYTE)destImg->mImageBits,
destImg->mInfo),
GPI_ERROR);
destImg->mIsOptimized = PR_TRUE;
}
oldBitmap = GFX (::GpiSetBitmap (destPS, destImg->mBitmap), HBM_ERROR);
nsRect trect( aDX, aDY, aDWidth, aDHeight);
RECTL rcl;
destImg->NS2PM_ININ (trect, rcl);
// Set up blit coord array
POINTL aptl[ 4] = { { rcl.xLeft, rcl.yBottom },
{ rcl.xRight, rcl.yTop },
{ 0, mInfo->cy - mNaturalHeight },
{ mNaturalWidth, mInfo->cy } };
if( 1==mAlphaDepth && mAlphaBits){
// Apply mask to target, clear pels we will fill in from the image
MONOBITMAPINFO MaskBitmapInfo (mInfo);
GFX (::GpiDrawBits (destPS, mAlphaBits, MaskBitmapInfo, 4, aptl, ROP_SRCAND,
BBO_IGNORE), GPI_ERROR);
// Now combine image with target
GFX (::GpiDrawBits (destPS, mImageBits, mInfo, 4, aptl, ROP_SRCPAINT,
BBO_IGNORE), GPI_ERROR);
} else {
// alpha depth of 8 not used (yet?)
NS_ASSERTION( mAlphaDepth != 8, "Alpha depth of 8 not implemented in DrawToImage" );
// no transparency, just blit it
GFX (::GpiDrawBits (destPS, mImageBits, mInfo, 4, aptl, ROP_SRCCOPY,
BBO_IGNORE), GPI_ERROR);
}
rc = destImg->UpdateImageBits (destPS);
GFX (::GpiSetBitmap (destPS, oldBitmap), HBM_ERROR);
GFX (::GpiDestroyPS (destPS), FALSE);
GFX (::DevCloseDC (destDC), DEV_ERROR);
return rc;
}
#endif

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

@ -218,6 +218,8 @@ public:
static PRUint8 FAST_BLEND (PRUint8 Source, PRUint8 Dest, PRUint8 Alpha) { return gBlenderLookup [(Alpha << 8) + Source] +
gBlenderLookup [((255 - Alpha) << 8) + Dest]; }
NS_IMETHODIMP UpdateImageBits( HPS mPS );
void NS2PM_ININ( const nsRect &in, RECTL &rcl);
void CreateBitmaps( nsDrawingSurfaceOS2 *surf);
PRBool SlowTile(nsIRenderingContext &aContext, nsDrawingSurface aSurface,nscoord aX0,nscoord aY0,nscoord aX1,nscoord aY1,nscoord aWidth,nscoord aHeight);

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -214,6 +214,7 @@ private:
nsresult CommonInit (void);
nsresult SetupPS (void);
LONG GetGPIColor (void);
void PushClipState(void);
// Colour/font setting; call before drawing things.