зеркало из https://github.com/mozilla/pjs.git
added blender method that takes rendering contexts.
added LockDrawingSurface() and UnlockDrawingSurface() to rendering context. fixed state maintenance errors in rendering context win. added IsReleaseDCDestructive() to drawingsurfacewin.
This commit is contained in:
Родитель
6687febd3d
Коммит
6aa94d777d
|
@ -69,6 +69,11 @@ public:
|
|||
nsDrawingSurface aDest, PRInt32 aDX, PRInt32 aDY, float aSrcOpacity,
|
||||
nsDrawingSurface aSecondSrc = nsnull, nscolor aSrcBackColor = NS_RGB(0, 0, 0),
|
||||
nscolor aSecondSrcBackColor = NS_RGB(0, 0, 0)) = 0;
|
||||
|
||||
NS_IMETHOD Blend(PRInt32 aSX, PRInt32 aSY, PRInt32 aWidth, PRInt32 aHeight, nsIRenderingContext *aSrc,
|
||||
nsIRenderingContext *aDest, PRInt32 aDX, PRInt32 aDY, float aSrcOpacity,
|
||||
nsIRenderingContext *aSecondSrc = nsnull, nscolor aSrcBackColor = NS_RGB(0, 0, 0),
|
||||
nscolor aSecondSrcBackColor = NS_RGB(0, 0, 0)) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -101,6 +101,27 @@ public:
|
|||
*/
|
||||
NS_IMETHOD GetDeviceContext(nsIDeviceContext *& aDeviceContext) = 0;
|
||||
|
||||
/**
|
||||
* Lock a rect of the drawing surface associated with the
|
||||
* rendering context. do not attempt to use any of the Rendering Context
|
||||
* rendering or state management methods until the drawing surface has
|
||||
* been Unlock()ed. if a drawing surface is Lock()ed with this method,
|
||||
* it must be Unlock()ed by calling UnlockDrawingSurface() rather than
|
||||
* just calling the Unlock() method on the drawing surface directly.
|
||||
* see nsIDrawingSurface.h for more information
|
||||
* @return error status
|
||||
**/
|
||||
NS_IMETHOD LockDrawingSurface(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
|
||||
void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
|
||||
PRUint32 aFlags) = 0;
|
||||
|
||||
/**
|
||||
* Unlock a rect of the drawing surface associated with the rendering
|
||||
* context. see nsIDrawingSurface.h for more information.
|
||||
* @return error status
|
||||
**/
|
||||
NS_IMETHOD UnlockDrawingSurface(void) = 0;
|
||||
|
||||
/**
|
||||
* Selects an offscreen drawing surface into the RenderingContext to draw to.
|
||||
* @param aSurface is the offscreen surface we are going to draw to.
|
||||
|
|
|
@ -181,6 +181,19 @@ NS_IMETHODIMP nsRenderingContextGTK::GetHints(PRUint32& aResult)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextGTK::LockDrawingSurface(PRInt32 aX, PRInt32 aY,
|
||||
PRUint32 aWidth, PRUint32 aHeight,
|
||||
void **aBits, PRInt32 *aStride,
|
||||
PRInt32 *aWidthBytes, PRUint32 aFlags)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextGTK::UnlockDrawingSurface(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextGTK::SelectOffScreenDrawingSurface(nsDrawingSurface aSurface)
|
||||
{
|
||||
if (nsnull == aSurface)
|
||||
|
|
|
@ -56,6 +56,11 @@ public:
|
|||
|
||||
NS_IMETHOD GetDeviceContext(nsIDeviceContext *&aContext);
|
||||
|
||||
NS_IMETHOD LockDrawingSurface(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
|
||||
void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
|
||||
PRUint32 aFlags);
|
||||
NS_IMETHOD UnlockDrawingSurface(void);
|
||||
|
||||
NS_IMETHOD SelectOffScreenDrawingSurface(nsDrawingSurface aSurface);
|
||||
NS_IMETHOD GetDrawingSurface(nsDrawingSurface *aSurface);
|
||||
NS_IMETHOD GetHints(PRUint32& aResult);
|
||||
|
|
|
@ -601,6 +601,24 @@ NS_IMETHODIMP nsRenderingContextMac :: PopState(PRBool &aClipEmpty)
|
|||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextMac::LockDrawingSurface(PRInt32 aX, PRInt32 aY,
|
||||
PRUint32 aWidth, PRUint32 aHeight,
|
||||
void **aBits, PRInt32 *aStride,
|
||||
PRInt32 *aWidthBytes, PRUint32 aFlags)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextMac::UnlockDrawingSurface(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
|
|
@ -51,6 +51,10 @@ public:
|
|||
|
||||
NS_IMETHOD Reset(void);
|
||||
NS_IMETHOD GetDeviceContext(nsIDeviceContext *&aContext);
|
||||
NS_IMETHOD LockDrawingSurface(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
|
||||
void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
|
||||
PRUint32 aFlags);
|
||||
NS_IMETHOD UnlockDrawingSurface(void);
|
||||
NS_IMETHOD SelectOffScreenDrawingSurface(nsDrawingSurface aSurface);
|
||||
NS_IMETHOD GetDrawingSurface(nsDrawingSurface *aSurface);
|
||||
NS_IMETHOD GetHints(PRUint32& aResult);
|
||||
|
|
|
@ -234,6 +234,19 @@ NS_IMETHODIMP nsRenderingContextMotif :: CommonInit()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextMotif :: LockDrawingSurface(PRInt32 aX, PRInt32 aY,
|
||||
PRUint32 aWidth, PRUint32 aHeight,
|
||||
void **aBits, PRInt32 *aStride,
|
||||
PRInt32 *aWidthBytes, PRUint32 aFlags)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextMotif :: UnlockDrawingSurface(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextMotif :: SelectOffScreenDrawingSurface(nsDrawingSurface aSurface)
|
||||
{
|
||||
|
|
|
@ -64,6 +64,11 @@ public:
|
|||
|
||||
NS_IMETHOD GetDeviceContext(nsIDeviceContext *&aContext);
|
||||
|
||||
NS_IMETHOD LockDrawingSurface(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
|
||||
void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
|
||||
PRUint32 aFlags);
|
||||
NS_IMETHOD UnlockDrawingSurface(void);
|
||||
|
||||
NS_IMETHOD SelectOffScreenDrawingSurface(nsDrawingSurface aSurface);
|
||||
NS_IMETHOD GetDrawingSurface(nsDrawingSurface *aSurface);
|
||||
NS_IMETHOD GetHints(PRUint32& aResult);
|
||||
|
|
|
@ -205,6 +205,27 @@ float app2dev;
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIRenderingContext.h
|
||||
* @update 12/21/98 dwc
|
||||
*/
|
||||
NS_IMETHODIMP nsRenderingContextPS :: LockDrawingSurface(PRInt32 aX, PRInt32 aY,
|
||||
PRUint32 aWidth, PRUint32 aHeight,
|
||||
void **aBits, PRInt32 *aStride,
|
||||
PRInt32 *aWidthBytes, PRUint32 aFlags)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIRenderingContext.h
|
||||
* @update 12/21/98 dwc
|
||||
*/
|
||||
NS_IMETHODIMP nsRenderingContextPS :: UnlockDrawingSurface(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIRenderingContext.h
|
||||
* @update 12/21/98 dwc
|
||||
|
|
|
@ -62,6 +62,11 @@ public:
|
|||
|
||||
NS_IMETHOD GetDeviceContext(nsIDeviceContext *&aContext);
|
||||
|
||||
NS_IMETHOD LockDrawingSurface(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
|
||||
void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
|
||||
PRUint32 aFlags);
|
||||
NS_IMETHOD UnlockDrawingSurface(void);
|
||||
|
||||
NS_IMETHOD SelectOffScreenDrawingSurface(nsDrawingSurface aSurface);
|
||||
NS_IMETHOD GetDrawingSurface(nsDrawingSurface *aSurface);
|
||||
NS_IMETHOD GetHints(PRUint32& aResult);
|
||||
|
|
|
@ -188,6 +188,122 @@ if (1)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBlenderWin :: Blend(PRInt32 aSX, PRInt32 aSY, PRInt32 aWidth, PRInt32 aHeight, nsIRenderingContext *aSrc,
|
||||
nsIRenderingContext *aDest, PRInt32 aDX, PRInt32 aDY, float aSrcOpacity,
|
||||
nsIRenderingContext *aSecondSrc, nscolor aSrcBackColor,
|
||||
nscolor aSecondSrcBackColor)
|
||||
{
|
||||
nsresult result = NS_ERROR_FAILURE;
|
||||
HBITMAP dstbits, tb1;
|
||||
nsPoint srcloc, maskloc;
|
||||
PRInt32 dlinespan, slinespan, mlinespan, numbytes, numlines, level;
|
||||
PRUint8 *s1, *d1, *m1, *mask = NULL, *ssl = NULL;
|
||||
IL_ColorSpace *thespace=nsnull;
|
||||
HDC srcdc, dstdc, secondsrcdc;
|
||||
PRBool srcissurf = PR_FALSE;
|
||||
PRBool secondsrcissurf = PR_FALSE;
|
||||
PRBool dstissurf = PR_FALSE;
|
||||
nsPixelFormat pixformat;
|
||||
nsDrawingSurface srcsurf;
|
||||
|
||||
mSrcBytes = mSecondSrcBytes = mDestBytes = nsnull;
|
||||
|
||||
aSrc->LockDrawingSurface(aSX, aSY, aWidth, aHeight, (void **)&mSrcBytes, &mSrcRowBytes, &mSrcSpan, NS_LOCK_SURFACE_READ_ONLY);
|
||||
aDest->LockDrawingSurface(aSX, aSY, aWidth, aHeight, (void **)&mDestBytes, &mDestRowBytes, &mDestSpan, 0);
|
||||
|
||||
if (nsnull != aSecondSrc)
|
||||
aSecondSrc->LockDrawingSurface(aSX, aSY, aWidth, aHeight, (void **)&mSecondSrcBytes, &mSecondSrcRowBytes, &mSecondSrcSpan, NS_LOCK_SURFACE_READ_ONLY);
|
||||
|
||||
srcloc.x = 0;
|
||||
srcloc.y = 0;
|
||||
|
||||
maskloc.x = 0;
|
||||
maskloc.y = 0;
|
||||
|
||||
// if (CalcAlphaMetrics(&mSrcInfo, &mDstInfo,
|
||||
// ((nsnull != mSecondSrcbinfo) || (PR_TRUE == secondsrcissurf)) ? &mSecondSrcInfo : nsnull,
|
||||
// &srcloc, NULL, &maskloc, aWidth, aHeight, &numlines, &numbytes,
|
||||
// &s1, &d1, &ssl, &m1, &slinespan, &dlinespan, &mlinespan))
|
||||
if (1)
|
||||
{
|
||||
// if (mSrcInfo.bmBitsPixel == mDstInfo.bmBitsPixel)
|
||||
if (1)
|
||||
{
|
||||
PRUint32 depth;
|
||||
mContext->GetDepth(depth);
|
||||
aSrc->GetDrawingSurface(&srcsurf);
|
||||
((nsIDrawingSurface *)srcsurf)->GetPixelFormat(&pixformat);
|
||||
// now do the blend
|
||||
switch (depth)
|
||||
{
|
||||
case 32:
|
||||
if (!mask){
|
||||
level = (PRInt32)(aSrcOpacity * 100);
|
||||
Do32Blend(level, aHeight, mSrcSpan, mSrcBytes, mDestBytes,
|
||||
mSecondSrcBytes, mSrcRowBytes, mDestRowBytes, nsHighQual,
|
||||
aSrcBackColor, aSecondSrcBackColor, pixformat);
|
||||
result = NS_OK;
|
||||
}else
|
||||
result = NS_ERROR_FAILURE;
|
||||
break;
|
||||
|
||||
case 24:
|
||||
if (mask){
|
||||
Do24BlendWithMask(aHeight, mSrcSpan, mSrcBytes, mDestBytes,
|
||||
NULL, mSrcRowBytes, mDestRowBytes, 0, nsHighQual);
|
||||
result = NS_OK;
|
||||
}else{
|
||||
level = (PRInt32)(aSrcOpacity*100);
|
||||
Do24Blend(level, aHeight, mSrcSpan, mSrcBytes, mDestBytes,
|
||||
mSecondSrcBytes, mSrcRowBytes, mDestRowBytes, nsHighQual,
|
||||
aSrcBackColor, aSecondSrcBackColor, pixformat);
|
||||
result = NS_OK;
|
||||
}
|
||||
break;
|
||||
|
||||
case 16:
|
||||
if (!mask){
|
||||
level = (PRInt32)(aSrcOpacity*100);
|
||||
Do16Blend(level, aHeight, mSrcSpan, mSrcBytes, mDestBytes,
|
||||
mSecondSrcBytes, mSrcRowBytes, mDestRowBytes, nsHighQual,
|
||||
aSrcBackColor, aSecondSrcBackColor, pixformat);
|
||||
result = NS_OK;
|
||||
}
|
||||
else
|
||||
result = NS_ERROR_FAILURE;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
if (mask){
|
||||
Do8BlendWithMask(aHeight, mSrcSpan, mSrcBytes, mDestBytes,
|
||||
NULL, mSrcRowBytes, mDestRowBytes, 0, nsHighQual);
|
||||
result = NS_OK;
|
||||
}else{
|
||||
if (mContext->GetILColorSpace(thespace) == NS_OK){
|
||||
level = (PRInt32)(aSrcOpacity*100);
|
||||
Do8Blend(level, aHeight, mSrcSpan, mSrcBytes, mDestBytes,
|
||||
mSecondSrcBytes, mSrcRowBytes, mDestRowBytes, thespace,
|
||||
nsHighQual, aSrcBackColor, aSecondSrcBackColor);
|
||||
result = NS_OK;
|
||||
IL_ReleaseColorSpace(thespace);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
result = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
aSrc->UnlockDrawingSurface();
|
||||
aDest->UnlockDrawingSurface();
|
||||
|
||||
if (nsnull != aSecondSrc)
|
||||
aSecondSrc->UnlockDrawingSurface();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** --------------------------------------------------------------------------
|
||||
* Calculate the metrics for the alpha layer before the blend
|
||||
* @update mp - 10/01/98
|
||||
|
|
|
@ -47,6 +47,11 @@ public:
|
|||
nsDrawingSurface aSecondSrc = nsnull, nscolor aSrcBackColor = NS_RGB(0, 0, 0),
|
||||
nscolor aSecondSrcBackColor = NS_RGB(0, 0, 0));
|
||||
|
||||
NS_IMETHOD Blend(PRInt32 aSX, PRInt32 aSY, PRInt32 aWidth, PRInt32 aHeight, nsIRenderingContext *aSrc,
|
||||
nsIRenderingContext *aDest, PRInt32 aDX, PRInt32 aDY, float aSrcOpacity,
|
||||
nsIRenderingContext *aSecondSrc = nsnull, nscolor aSrcBackColor = NS_RGB(0, 0, 0),
|
||||
nscolor aSecondSrcBackColor = NS_RGB(0, 0, 0));
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Release and cleanup all the windows specific information for this blender
|
||||
|
|
|
@ -292,11 +292,23 @@ NS_IMETHODIMP nsDrawingSurfaceWin :: GetDimensions(PRUint32 *aWidth, PRUint32 *a
|
|||
|
||||
NS_IMETHODIMP nsDrawingSurfaceWin :: IsOffscreen(PRBool *aOffScreen)
|
||||
{
|
||||
*aOffScreen = mKillDC;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfaceWin :: IsPixelAddressable(PRBool *aAddressable)
|
||||
{
|
||||
#ifdef NGLAYOUT_DDRAW
|
||||
if (nsnull != mSurface)
|
||||
*aAddressable = PR_TRUE;
|
||||
else
|
||||
#endif
|
||||
if (nsnull != mSelectedBitmap)
|
||||
*aAddressable = PR_TRUE;
|
||||
else
|
||||
*aAddressable = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -442,6 +454,18 @@ NS_IMETHODIMP nsDrawingSurfaceWin :: ReleaseDC(void)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfaceWin :: IsReleaseDCDestructive(PRBool *aDestructive)
|
||||
{
|
||||
#ifdef NGLAYOUT_DDRAW
|
||||
if (nsnull != mSurface)
|
||||
*aDestructive = PR_TRUE;
|
||||
else
|
||||
#endif
|
||||
*aDestructive = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
BITMAPINFO * nsDrawingSurfaceWin :: CreateBitmapInfo(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,
|
||||
void **aBits, nsPixelFormat *aPixFormat)
|
||||
{
|
||||
|
|
|
@ -52,6 +52,7 @@ public:
|
|||
PRUint32 aFlags);
|
||||
NS_IMETHOD GetDC(HDC *aDC);
|
||||
NS_IMETHOD ReleaseDC(void);
|
||||
NS_IMETHOD IsReleaseDCDestructive(PRBool *aDestructive);
|
||||
|
||||
// locals
|
||||
#ifdef NGLAYOUT_DDRAW
|
||||
|
|
|
@ -71,6 +71,14 @@ public:
|
|||
* @return error status
|
||||
**/
|
||||
NS_IMETHOD ReleaseDC(void) = 0;
|
||||
|
||||
/**
|
||||
* If ReleaseDC() truly destroys the state in the DC
|
||||
* this will return PR_TRUE.
|
||||
* @param aDestructive out parameter for destructiveness
|
||||
* @return error status
|
||||
**/
|
||||
NS_IMETHOD IsReleaseDCDestructive(PRBool *aDestructive) = 0;
|
||||
};
|
||||
|
||||
#endif // nsIDrawingSurfaceWin_h___
|
||||
|
|
|
@ -129,20 +129,20 @@ nsresult nsImageWin :: Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,nsMa
|
|||
// Initialize the array of indexes into the logical palette
|
||||
WORD* palIndx = (WORD*)(((LPBYTE)mBHead) + mBHead->biSize);
|
||||
for (WORD index = 0; index < 256; index++) {
|
||||
*palIndx++ = index;
|
||||
*palIndx++ = index;
|
||||
}
|
||||
}
|
||||
|
||||
// Allocate mask image bits if requested
|
||||
if (aMaskRequirements != nsMaskRequirements_kNoMask){
|
||||
if (nsMaskRequirements_kNeeds1Bit == aMaskRequirements){
|
||||
mARowBytes = (aWidth + 7) / 8;
|
||||
mAlphaDepth = 1;
|
||||
mARowBytes = (aWidth + 7) / 8;
|
||||
mAlphaDepth = 1;
|
||||
}else{
|
||||
NS_ASSERTION(nsMaskRequirements_kNeeds8Bit == aMaskRequirements,
|
||||
"unexpected mask depth");
|
||||
mARowBytes = aWidth;
|
||||
mAlphaDepth = 8;
|
||||
NS_ASSERTION(nsMaskRequirements_kNeeds8Bit == aMaskRequirements,
|
||||
"unexpected mask depth");
|
||||
mARowBytes = aWidth;
|
||||
mAlphaDepth = 8;
|
||||
}
|
||||
|
||||
// 32-bit align each row
|
||||
|
@ -164,12 +164,12 @@ nsresult nsImageWin :: Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,nsMa
|
|||
mColorMap->NumColors = mNumPaletteColors;
|
||||
mColorMap->Index = nsnull;
|
||||
if (mColorMap->NumColors > 0) {
|
||||
mColorMap->Index = new PRUint8[3 * mColorMap->NumColors];
|
||||
mColorMap->Index = new PRUint8[3 * mColorMap->NumColors];
|
||||
|
||||
// XXX Note: I added this because purify claims that we make a
|
||||
// copy of the memory (which we do!). I'm not sure if this
|
||||
// matters or not, but this shutup purify.
|
||||
memset(mColorMap->Index, 0, sizeof(PRUint8) * (3 * mColorMap->NumColors));
|
||||
// XXX Note: I added this because purify claims that we make a
|
||||
// copy of the memory (which we do!). I'm not sure if this
|
||||
// matters or not, but this shutup purify.
|
||||
memset(mColorMap->Index, 0, sizeof(PRUint8) * (3 * mColorMap->NumColors));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -209,8 +209,8 @@ void nsImageWin :: ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsRe
|
|||
if (0 == mNumPaletteColors){
|
||||
PRInt32 x, y, span = CalcBytesSpan(mBHead->biWidth), idx;
|
||||
PRUint8 *pixels = mImageBits +
|
||||
(mBHead->biHeight - aUpdateRect->y - aUpdateRect->height) * span +
|
||||
aUpdateRect->x * 3;
|
||||
(mBHead->biHeight - aUpdateRect->y - aUpdateRect->height) * span +
|
||||
aUpdateRect->x * 3;
|
||||
PRUint8 *gamma;
|
||||
float gammaValue;
|
||||
aContext->GetGammaTable(gamma);
|
||||
|
@ -218,17 +218,17 @@ void nsImageWin :: ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsRe
|
|||
|
||||
// Gamma correct the image
|
||||
if (1.0 != gammaValue){
|
||||
for (y = 0; y < aUpdateRect->height; y++){
|
||||
for (x = 0, idx = 0; x < aUpdateRect->width; x++){
|
||||
pixels[idx] = gamma[pixels[idx]];
|
||||
idx++;
|
||||
pixels[idx] = gamma[pixels[idx]];
|
||||
idx++;
|
||||
pixels[idx] = gamma[pixels[idx]];
|
||||
idx++;
|
||||
}
|
||||
pixels += span;
|
||||
}
|
||||
for (y = 0; y < aUpdateRect->height; y++){
|
||||
for (x = 0, idx = 0; x < aUpdateRect->width; x++){
|
||||
pixels[idx] = gamma[pixels[idx]];
|
||||
idx++;
|
||||
pixels[idx] = gamma[pixels[idx]];
|
||||
idx++;
|
||||
pixels[idx] = gamma[pixels[idx]];
|
||||
idx++;
|
||||
}
|
||||
pixels += span;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -289,18 +289,18 @@ void nsImageWin :: CreateDDB(nsDrawingSurface aSurface)
|
|||
if (mSizeImage > 0)
|
||||
{
|
||||
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);
|
||||
|
||||
if (nsnull != mAlphaBits)
|
||||
{
|
||||
// Create a monochrome bitmap
|
||||
// XXX Handle the case of 8-bit alpha...
|
||||
NS_ASSERTION(1 == mAlphaDepth, "unexpected alpha depth");
|
||||
mAlphaHBitmap = ::CreateBitmap(mAlphaWidth, mAlphaHeight, 1, 1, NULL);
|
||||
// Create a monochrome bitmap
|
||||
// XXX Handle the case of 8-bit alpha...
|
||||
NS_ASSERTION(1 == mAlphaDepth, "unexpected alpha depth");
|
||||
mAlphaHBitmap = ::CreateBitmap(mAlphaWidth, mAlphaHeight, 1, 1, NULL);
|
||||
|
||||
MONOBITMAPINFO bmi(mAlphaWidth, mAlphaHeight);
|
||||
::SetDIBits(TheHDC, mAlphaHBitmap, 0, mAlphaHeight, mAlphaBits,
|
||||
(LPBITMAPINFO)&bmi, DIB_RGB_COLORS);
|
||||
MONOBITMAPINFO bmi(mAlphaWidth, mAlphaHeight);
|
||||
::SetDIBits(TheHDC, mAlphaHBitmap, 0, mAlphaHeight, mAlphaBits,
|
||||
(LPBITMAPINFO)&bmi, DIB_RGB_COLORS);
|
||||
}
|
||||
|
||||
CleanUp(PR_FALSE);
|
||||
|
@ -326,8 +326,8 @@ void nsImageWin :: CreateDDB(nsDrawingSurface aSurface)
|
|||
* @result NS_OK if the draw worked
|
||||
*/
|
||||
NS_IMETHODIMP nsImageWin :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
|
||||
PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
|
||||
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight)
|
||||
PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
|
||||
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight)
|
||||
{
|
||||
HDC TheHDC;
|
||||
|
||||
|
@ -348,18 +348,18 @@ NS_IMETHODIMP nsImageWin :: Draw(nsIRenderingContext &aContext, nsDrawingSurface
|
|||
|
||||
if (nsnull != mAlphaBits)
|
||||
{
|
||||
MONOBITMAPINFO bmi(mAlphaWidth, mAlphaHeight);
|
||||
MONOBITMAPINFO bmi(mAlphaWidth, mAlphaHeight);
|
||||
|
||||
::StretchDIBits(TheHDC, aDX, aDY, aDWidth, aDHeight,
|
||||
aSX, aSY, aSWidth, aSHeight, mAlphaBits,
|
||||
(LPBITMAPINFO)&bmi, DIB_RGB_COLORS, SRCAND);
|
||||
rop = SRCPAINT;
|
||||
::StretchDIBits(TheHDC, aDX, aDY, aDWidth, aDHeight,
|
||||
aSX, aSY, aSWidth, aSHeight, mAlphaBits,
|
||||
(LPBITMAPINFO)&bmi, DIB_RGB_COLORS, SRCAND);
|
||||
rop = SRCPAINT;
|
||||
}
|
||||
|
||||
::StretchDIBits(TheHDC, aDX, aDY, aDWidth, aDHeight,
|
||||
aSX, aSY, aSWidth, aSHeight, mImageBits,
|
||||
(LPBITMAPINFO)mBHead, 256 == mNumPaletteColors ? DIB_PAL_COLORS :
|
||||
DIB_RGB_COLORS, rop);
|
||||
aSX, aSY, aSWidth, aSHeight, mImageBits,
|
||||
(LPBITMAPINFO)mBHead, 256 == mNumPaletteColors ? DIB_PAL_COLORS :
|
||||
DIB_RGB_COLORS, rop);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -372,42 +372,42 @@ NS_IMETHODIMP nsImageWin :: Draw(nsIRenderingContext &aContext, nsDrawingSurface
|
|||
|
||||
if (nsnull != srcDS)
|
||||
{
|
||||
srcDS->GetDC(&srcDC);
|
||||
srcDS->GetDC(&srcDC);
|
||||
|
||||
if (NULL != srcDC)
|
||||
{
|
||||
HBITMAP oldbits;
|
||||
if (NULL != srcDC)
|
||||
{
|
||||
HBITMAP oldbits;
|
||||
|
||||
if (nsnull == mAlphaHBitmap)
|
||||
{
|
||||
oldbits = (HBITMAP)::SelectObject(srcDC, mHBitmap);
|
||||
::StretchBlt(TheHDC, aDX, aDY, aDWidth, aDHeight, srcDC, aSX, aSY,
|
||||
aSWidth, aSHeight, SRCCOPY);
|
||||
}
|
||||
else if (gIsWinNT && (aDWidth == aSWidth) && (aDHeight == aSHeight)){
|
||||
oldbits = (HBITMAP)::SelectObject(srcDC, mHBitmap);
|
||||
::MaskBlt(TheHDC, aDX, aDY, aDWidth, aDHeight,
|
||||
srcDC, aSX, aSY, mAlphaHBitmap, aSX, aSY, MASKBLT_ROP);
|
||||
}
|
||||
else
|
||||
{
|
||||
COLORREF oldTextColor = ::SetTextColor(TheHDC, RGB(0, 0, 0));
|
||||
COLORREF oldBkColor = ::SetBkColor(TheHDC, RGB(255, 255, 255));
|
||||
oldbits = (HBITMAP)::SelectObject(srcDC, mAlphaHBitmap);
|
||||
::StretchBlt(TheHDC, aDX, aDY, aDWidth, aDHeight, srcDC, aSX, aSY,
|
||||
aSWidth, aSHeight, SRCAND);
|
||||
::SetTextColor(TheHDC, oldTextColor);
|
||||
::SetBkColor(TheHDC, oldBkColor);
|
||||
if (nsnull == mAlphaHBitmap)
|
||||
{
|
||||
oldbits = (HBITMAP)::SelectObject(srcDC, mHBitmap);
|
||||
::StretchBlt(TheHDC, aDX, aDY, aDWidth, aDHeight, srcDC, aSX, aSY,
|
||||
aSWidth, aSHeight, SRCCOPY);
|
||||
}
|
||||
else if (gIsWinNT && (aDWidth == aSWidth) && (aDHeight == aSHeight)){
|
||||
oldbits = (HBITMAP)::SelectObject(srcDC, mHBitmap);
|
||||
::MaskBlt(TheHDC, aDX, aDY, aDWidth, aDHeight,
|
||||
srcDC, aSX, aSY, mAlphaHBitmap, aSX, aSY, MASKBLT_ROP);
|
||||
}
|
||||
else
|
||||
{
|
||||
COLORREF oldTextColor = ::SetTextColor(TheHDC, RGB(0, 0, 0));
|
||||
COLORREF oldBkColor = ::SetBkColor(TheHDC, RGB(255, 255, 255));
|
||||
oldbits = (HBITMAP)::SelectObject(srcDC, mAlphaHBitmap);
|
||||
::StretchBlt(TheHDC, aDX, aDY, aDWidth, aDHeight, srcDC, aSX, aSY,
|
||||
aSWidth, aSHeight, SRCAND);
|
||||
::SetTextColor(TheHDC, oldTextColor);
|
||||
::SetBkColor(TheHDC, oldBkColor);
|
||||
|
||||
::SelectObject(srcDC, mHBitmap);
|
||||
::StretchBlt(TheHDC, aDX, aDY, aDWidth, aDHeight, srcDC, aSX, aSY,
|
||||
aSWidth, aSHeight, SRCPAINT);
|
||||
}
|
||||
::SelectObject(srcDC, mHBitmap);
|
||||
::StretchBlt(TheHDC, aDX, aDY, aDWidth, aDHeight, srcDC, aSX, aSY,
|
||||
aSWidth, aSHeight, SRCPAINT);
|
||||
}
|
||||
|
||||
::SelectObject(srcDC, oldbits);
|
||||
::SelectObject(srcDC, oldbits);
|
||||
|
||||
srcDS->ReleaseDC();
|
||||
}
|
||||
srcDS->ReleaseDC();
|
||||
}
|
||||
}
|
||||
|
||||
NS_RELEASE(dx);
|
||||
|
@ -432,7 +432,7 @@ NS_IMETHODIMP nsImageWin :: Draw(nsIRenderingContext &aContext, nsDrawingSurface
|
|||
* @result NS_OK if the draw worked
|
||||
*/
|
||||
NS_IMETHODIMP nsImageWin :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
|
||||
PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
|
||||
PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
|
||||
{
|
||||
HDC TheHDC;
|
||||
|
||||
|
@ -453,18 +453,18 @@ NS_IMETHODIMP nsImageWin :: Draw(nsIRenderingContext &aContext, nsDrawingSurface
|
|||
|
||||
if (nsnull != mAlphaBits)
|
||||
{
|
||||
MONOBITMAPINFO bmi(mAlphaWidth, mAlphaHeight);
|
||||
MONOBITMAPINFO bmi(mAlphaWidth, mAlphaHeight);
|
||||
|
||||
::StretchDIBits(TheHDC, aX, aY, aWidth, aHeight,
|
||||
0, 0, mAlphaWidth, mAlphaHeight, mAlphaBits,
|
||||
(LPBITMAPINFO)&bmi, DIB_RGB_COLORS, SRCAND);
|
||||
rop = SRCPAINT;
|
||||
::StretchDIBits(TheHDC, aX, aY, aWidth, aHeight,
|
||||
0, 0, mAlphaWidth, mAlphaHeight, mAlphaBits,
|
||||
(LPBITMAPINFO)&bmi, DIB_RGB_COLORS, SRCAND);
|
||||
rop = SRCPAINT;
|
||||
}
|
||||
|
||||
::StretchDIBits(TheHDC, aX, aY, aWidth, aHeight,
|
||||
0, 0, mBHead->biWidth, mBHead->biHeight, mImageBits,
|
||||
(LPBITMAPINFO)mBHead, 256 == mNumPaletteColors ? DIB_PAL_COLORS :
|
||||
DIB_RGB_COLORS, rop);
|
||||
0, 0, mBHead->biWidth, mBHead->biHeight, mImageBits,
|
||||
(LPBITMAPINFO)mBHead, 256 == mNumPaletteColors ? DIB_PAL_COLORS :
|
||||
DIB_RGB_COLORS, rop);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -477,43 +477,43 @@ NS_IMETHODIMP nsImageWin :: Draw(nsIRenderingContext &aContext, nsDrawingSurface
|
|||
|
||||
if (nsnull != srcDS)
|
||||
{
|
||||
srcDS->GetDC(&srcDC);
|
||||
srcDS->GetDC(&srcDC);
|
||||
|
||||
if (NULL != srcDC)
|
||||
{
|
||||
HBITMAP oldBits;
|
||||
if (NULL != srcDC)
|
||||
{
|
||||
HBITMAP oldBits;
|
||||
|
||||
if (nsnull == mAlphaHBitmap)
|
||||
{
|
||||
oldBits = (HBITMAP)::SelectObject(srcDC, mHBitmap);
|
||||
::StretchBlt(TheHDC, aX, aY, aWidth, aHeight, srcDC, 0, 0,
|
||||
mBHead->biWidth, mBHead->biHeight, SRCCOPY);
|
||||
if (nsnull == mAlphaHBitmap)
|
||||
{
|
||||
oldBits = (HBITMAP)::SelectObject(srcDC, mHBitmap);
|
||||
::StretchBlt(TheHDC, aX, aY, aWidth, aHeight, srcDC, 0, 0,
|
||||
mBHead->biWidth, mBHead->biHeight, SRCCOPY);
|
||||
|
||||
}
|
||||
else if (gIsWinNT && (aWidth == mBHead->biWidth) && (aHeight == mBHead->biHeight)){
|
||||
oldBits = (HBITMAP)::SelectObject(srcDC, mHBitmap);
|
||||
::MaskBlt(TheHDC, aX, aY, aWidth, aHeight,
|
||||
srcDC, 0, 0, mAlphaHBitmap, 0, 0, MASKBLT_ROP);
|
||||
}
|
||||
else
|
||||
{
|
||||
COLORREF oldTextColor = ::SetTextColor(TheHDC, RGB(0, 0, 0));
|
||||
COLORREF oldBkColor = ::SetBkColor(TheHDC, RGB(255, 255, 255));
|
||||
oldBits = (HBITMAP)::SelectObject(srcDC, mAlphaHBitmap);
|
||||
::StretchBlt(TheHDC, aX, aY, aWidth, aHeight, srcDC, 0, 0,
|
||||
mAlphaWidth, mAlphaHeight, SRCAND);
|
||||
::SetTextColor(TheHDC, oldTextColor);
|
||||
::SetBkColor(TheHDC, oldBkColor);
|
||||
}
|
||||
else if (gIsWinNT && (aWidth == mBHead->biWidth) && (aHeight == mBHead->biHeight)){
|
||||
oldBits = (HBITMAP)::SelectObject(srcDC, mHBitmap);
|
||||
::MaskBlt(TheHDC, aX, aY, aWidth, aHeight,
|
||||
srcDC, 0, 0, mAlphaHBitmap, 0, 0, MASKBLT_ROP);
|
||||
}
|
||||
else
|
||||
{
|
||||
COLORREF oldTextColor = ::SetTextColor(TheHDC, RGB(0, 0, 0));
|
||||
COLORREF oldBkColor = ::SetBkColor(TheHDC, RGB(255, 255, 255));
|
||||
oldBits = (HBITMAP)::SelectObject(srcDC, mAlphaHBitmap);
|
||||
::StretchBlt(TheHDC, aX, aY, aWidth, aHeight, srcDC, 0, 0,
|
||||
mAlphaWidth, mAlphaHeight, SRCAND);
|
||||
::SetTextColor(TheHDC, oldTextColor);
|
||||
::SetBkColor(TheHDC, oldBkColor);
|
||||
|
||||
::SelectObject(srcDC, mHBitmap);
|
||||
::StretchBlt(TheHDC, aX, aY, aWidth, aHeight, srcDC, 0, 0,
|
||||
mBHead->biWidth, mBHead->biHeight, SRCPAINT);
|
||||
}
|
||||
::SelectObject(srcDC, mHBitmap);
|
||||
::StretchBlt(TheHDC, aX, aY, aWidth, aHeight, srcDC, 0, 0,
|
||||
mBHead->biWidth, mBHead->biHeight, SRCPAINT);
|
||||
}
|
||||
|
||||
::SelectObject(srcDC, oldBits);
|
||||
::SelectObject(srcDC, oldBits);
|
||||
|
||||
srcDS->ReleaseDC();
|
||||
}
|
||||
srcDS->ReleaseDC();
|
||||
}
|
||||
}
|
||||
|
||||
NS_RELEASE(dx);
|
||||
|
|
|
@ -100,16 +100,13 @@ public:
|
|||
nsTransform2D mMatrix;
|
||||
nsRect mLocalClip;
|
||||
HRGN mClipRegion;
|
||||
nscolor mBrushColor;
|
||||
HBRUSH mSolidBrush;
|
||||
nscolor mColor;
|
||||
COLORREF mColorREF;
|
||||
nsIFontMetrics *mFontMetrics;
|
||||
HFONT mFont;
|
||||
nscolor mPenColor;
|
||||
HPEN mSolidPen;
|
||||
HPEN mDashedPen;
|
||||
HPEN mDottedPen;
|
||||
PRInt32 mFlags;
|
||||
nscolor mTextColor;
|
||||
nsLineStyle mLineStyle;
|
||||
};
|
||||
|
||||
|
@ -119,16 +116,13 @@ GraphicsState :: GraphicsState()
|
|||
mMatrix.SetToIdentity();
|
||||
mLocalClip.x = mLocalClip.y = mLocalClip.width = mLocalClip.height = 0;
|
||||
mClipRegion = NULL;
|
||||
mBrushColor = NS_RGB(0, 0, 0);
|
||||
mSolidBrush = NULL;
|
||||
mColor = NS_RGB(0, 0, 0);
|
||||
mColorREF = RGB(0, 0, 0);
|
||||
mFontMetrics = nsnull;
|
||||
mFont = NULL;
|
||||
mPenColor = NS_RGB(0, 0, 0);
|
||||
mSolidPen = NULL;
|
||||
mDashedPen = NULL;
|
||||
mDottedPen = NULL;
|
||||
mFlags = ~FLAGS_ALL;
|
||||
mTextColor = RGB(0, 0, 0);
|
||||
mLineStyle = nsLineStyle_kSolid;
|
||||
}
|
||||
|
||||
|
@ -138,16 +132,13 @@ GraphicsState :: GraphicsState(GraphicsState &aState) :
|
|||
{
|
||||
mNext = &aState;
|
||||
mClipRegion = NULL;
|
||||
mBrushColor = aState.mBrushColor;
|
||||
mSolidBrush = NULL;
|
||||
mColor = NS_RGB(0, 0, 0);
|
||||
mColorREF = RGB(0, 0, 0);
|
||||
mFontMetrics = nsnull;
|
||||
mFont = NULL;
|
||||
mPenColor = aState.mPenColor;
|
||||
mSolidPen = NULL;
|
||||
mDashedPen = NULL;
|
||||
mDottedPen = NULL;
|
||||
mFlags = ~FLAGS_ALL;
|
||||
mTextColor = aState.mTextColor;
|
||||
mLineStyle = aState.mLineStyle;
|
||||
}
|
||||
|
||||
|
@ -160,13 +151,9 @@ GraphicsState :: ~GraphicsState()
|
|||
}
|
||||
|
||||
//these are killed by the rendering context...
|
||||
mSolidBrush = NULL;
|
||||
mSolidPen = NULL;
|
||||
mDashedPen = NULL;
|
||||
mDottedPen = NULL;
|
||||
|
||||
//don't delete this because it lives in the font metrics
|
||||
mFont = NULL;
|
||||
}
|
||||
|
||||
#define NOT_SETUP 0x33
|
||||
|
@ -206,14 +193,13 @@ nsRenderingContextWin :: nsRenderingContextWin()
|
|||
mCurrPenColor = NULL;
|
||||
mCurrPen = NULL;
|
||||
mNullPen = NULL;
|
||||
mCurrTextColor = RGB(0, 0, 0);
|
||||
mCurrTextColor = NS_RGB(0, 0, 0);
|
||||
mCurrLineStyle = nsLineStyle_kSolid;
|
||||
#ifdef NS_DEBUG
|
||||
mInitialized = PR_FALSE;
|
||||
#endif
|
||||
mSurface = nsnull;
|
||||
mMainSurface = nsnull;
|
||||
mGetNearestColor = PR_FALSE;
|
||||
|
||||
mStateCache = new nsVoidArray();
|
||||
|
||||
|
@ -448,7 +434,8 @@ nsresult nsRenderingContextWin :: SetupDC(HDC aOldDC, HDC aNewDC)
|
|||
HFONT prevfont;
|
||||
HPEN prevpen;
|
||||
|
||||
::SetTextColor(aNewDC, mCurrTextColor);
|
||||
::SetTextColor(aNewDC, PALETTERGB_COLORREF(mColor));
|
||||
mCurrTextColor = mCurrentColor;
|
||||
::SetBkMode(aNewDC, TRANSPARENT);
|
||||
::SetPolyFillMode(aNewDC, WINDING);
|
||||
::SetStretchBltMode(aNewDC, COLORONCOLOR);
|
||||
|
@ -510,17 +497,11 @@ nsresult nsRenderingContextWin :: SetupDC(HDC aOldDC, HDC aNewDC)
|
|||
nsresult nsRenderingContextWin :: CommonInit(void)
|
||||
{
|
||||
float app2dev;
|
||||
|
||||
mContext->GetAppUnitsToDevUnits(app2dev);
|
||||
mTMatrix->AddScale(app2dev, app2dev);
|
||||
mContext->GetDevUnitsToAppUnits(mP2T);
|
||||
|
||||
PRUint32 depth;
|
||||
|
||||
mContext->GetDepth(depth);
|
||||
|
||||
if (16 == depth)
|
||||
mGetNearestColor = PR_TRUE;
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
mInitialized = PR_TRUE;
|
||||
#endif
|
||||
|
@ -536,6 +517,88 @@ nsresult nsRenderingContextWin :: CommonInit(void)
|
|||
return SetupDC(nsnull, mDC);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextWin :: LockDrawingSurface(PRInt32 aX, PRInt32 aY,
|
||||
PRUint32 aWidth, PRUint32 aHeight,
|
||||
void **aBits, PRInt32 *aStride,
|
||||
PRInt32 *aWidthBytes, PRUint32 aFlags)
|
||||
{
|
||||
PRBool destructive;
|
||||
|
||||
PushState();
|
||||
|
||||
mSurface->IsReleaseDCDestructive(&destructive);
|
||||
|
||||
if (destructive)
|
||||
{
|
||||
PushClipState();
|
||||
|
||||
if (nsnull != mOrigSolidBrush)
|
||||
mCurrBrush = (HBRUSH)::SelectObject(mDC, mOrigSolidBrush);
|
||||
|
||||
if (nsnull != mOrigFont)
|
||||
mCurrFont = (HFONT)::SelectObject(mDC, mOrigFont);
|
||||
|
||||
if (nsnull != mOrigSolidPen)
|
||||
mCurrPen = (HPEN)::SelectObject(mDC, mOrigSolidPen);
|
||||
|
||||
if (nsnull != mOrigPalette)
|
||||
::SelectPalette(mDC, mOrigPalette, TRUE);
|
||||
}
|
||||
|
||||
mSurface->ReleaseDC();
|
||||
|
||||
return mSurface->Lock(aX, aY, aWidth, aHeight, aBits, aStride, aWidthBytes, aFlags);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextWin :: UnlockDrawingSurface(void)
|
||||
{
|
||||
PRBool clipstate;
|
||||
|
||||
mSurface->Unlock();
|
||||
mSurface->GetDC(&mDC);
|
||||
|
||||
PopState(clipstate);
|
||||
|
||||
mSurface->IsReleaseDCDestructive(&clipstate);
|
||||
|
||||
if (clipstate)
|
||||
{
|
||||
::SetTextColor(mDC, PALETTERGB_COLORREF(mColor));
|
||||
mCurrTextColor = mCurrentColor;
|
||||
|
||||
::SetBkMode(mDC, TRANSPARENT);
|
||||
::SetPolyFillMode(mDC, WINDING);
|
||||
::SetStretchBltMode(mDC, COLORONCOLOR);
|
||||
|
||||
mOrigSolidBrush = (HBRUSH)::SelectObject(mDC, mCurrBrush);
|
||||
mOrigFont = (HFONT)::SelectObject(mDC, mCurrFont);
|
||||
mOrigSolidPen = (HPEN)::SelectObject(mDC, mCurrPen);
|
||||
|
||||
// If this is a palette device, then select and realize the palette
|
||||
nsPaletteInfo palInfo;
|
||||
mContext->GetPaletteInfo(palInfo);
|
||||
|
||||
if (palInfo.isPaletteDevice && palInfo.palette)
|
||||
{
|
||||
PRBool offscr;
|
||||
// Select the palette in the background
|
||||
mOrigPalette = ::SelectPalette(mDC, (HPALETTE)palInfo.palette, TRUE);
|
||||
|
||||
mSurface->IsOffscreen(&offscr);
|
||||
|
||||
// Don't do the realization for an off-screen memory DC
|
||||
|
||||
if (PR_FALSE == offscr)
|
||||
::RealizePalette(mDC);
|
||||
}
|
||||
|
||||
if (GetDeviceCaps(mDC, RASTERCAPS) & (RC_BITBLT))
|
||||
gFastDDASupport = PR_TRUE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextWin :: SelectOffScreenDrawingSurface(nsDrawingSurface aSurface)
|
||||
{
|
||||
|
@ -641,21 +704,23 @@ NS_IMETHODIMP nsRenderingContextWin :: PushState(void)
|
|||
// from state to state. if we NULL it, we need to also delete it,
|
||||
// which means we'll just re-create it when we push the clip state. MMP
|
||||
// state->mClipRegion = NULL;
|
||||
state->mBrushColor = mStates->mBrushColor;
|
||||
state->mSolidBrush = NULL;
|
||||
state->mFontMetrics = mStates->mFontMetrics;
|
||||
state->mFont = NULL;
|
||||
state->mPenColor = mStates->mPenColor;
|
||||
state->mSolidPen = NULL;
|
||||
state->mDashedPen = NULL;
|
||||
state->mDottedPen = NULL;
|
||||
state->mFlags = ~FLAGS_ALL;
|
||||
state->mTextColor = mStates->mTextColor;
|
||||
state->mLineStyle = mStates->mLineStyle;
|
||||
|
||||
mStates = state;
|
||||
}
|
||||
|
||||
if (nsnull != mStates->mNext)
|
||||
{
|
||||
mStates->mNext->mColor = mCurrentColor;
|
||||
mStates->mNext->mColorREF = mColor;
|
||||
mStates->mNext->mFontMetrics = mFontMetrics;
|
||||
NS_IF_ADDREF(mStates->mNext->mFontMetrics);
|
||||
}
|
||||
|
||||
mTMatrix = &mStates->mMatrix;
|
||||
|
||||
return NS_OK;
|
||||
|
@ -703,12 +768,16 @@ NS_IMETHODIMP nsRenderingContextWin :: PopState(PRBool &aClipEmpty)
|
|||
}
|
||||
|
||||
oldstate->mFlags &= ~FLAGS_ALL;
|
||||
oldstate->mSolidBrush = NULL;
|
||||
oldstate->mFont = NULL;
|
||||
oldstate->mSolidPen = NULL;
|
||||
oldstate->mDashedPen = NULL;
|
||||
oldstate->mDottedPen = NULL;
|
||||
|
||||
NS_IF_RELEASE(mFontMetrics);
|
||||
mFontMetrics = mStates->mFontMetrics;
|
||||
|
||||
mCurrentColor = mStates->mColor;
|
||||
mColor = mStates->mColorREF;
|
||||
|
||||
SetLineStyle(mStates->mLineStyle);
|
||||
}
|
||||
else
|
||||
|
@ -922,6 +991,7 @@ NS_IMETHODIMP nsRenderingContextWin :: SetFont(const nsFont& aFont)
|
|||
{
|
||||
NS_IF_RELEASE(mFontMetrics);
|
||||
mContext->GetMetricsFor(aFont, mFontMetrics);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -938,6 +1008,7 @@ NS_IMETHODIMP nsRenderingContextWin :: GetFontMetrics(nsIFontMetrics *&aFontMetr
|
|||
{
|
||||
NS_IF_ADDREF(mFontMetrics);
|
||||
aFontMetrics = mFontMetrics;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1022,7 +1093,6 @@ NS_IMETHODIMP nsRenderingContextWin :: DrawLine(nscoord aX0, nscoord aY0, nscoor
|
|||
dda_struct.crColor = mColor;
|
||||
|
||||
LineDDA((int)(aX0),(int)(aY0),(int)(aX1),(int)(aY1),(LINEDDAPROC) LineDDAFunc,(long)&dda_struct);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1623,20 +1693,15 @@ HBRUSH nsRenderingContextWin :: SetupSolidBrush(void)
|
|||
{
|
||||
if ((mCurrentColor != mCurrBrushColor) || (NULL == mCurrBrush))
|
||||
{
|
||||
HBRUSH tbrush;
|
||||
|
||||
if (PR_TRUE == mGetNearestColor)
|
||||
tbrush = ::CreateSolidBrush(PALETTERGB_COLORREF(::GetNearestColor(mDC, mColor)));
|
||||
else
|
||||
tbrush = ::CreateSolidBrush(PALETTERGB_COLORREF(mColor));
|
||||
HBRUSH tbrush = ::CreateSolidBrush(PALETTERGB_COLORREF(mColor));
|
||||
|
||||
::SelectObject(mDC, tbrush);
|
||||
|
||||
if (NULL != mCurrBrush)
|
||||
VERIFY(::DeleteObject(mCurrBrush));
|
||||
|
||||
mStates->mSolidBrush = mCurrBrush = tbrush;
|
||||
mStates->mBrushColor = mCurrBrushColor = mCurrentColor;
|
||||
mCurrBrush = tbrush;
|
||||
mCurrBrushColor = mCurrentColor;
|
||||
//printf("brushes: %d\n", ++numbrush);
|
||||
}
|
||||
|
||||
|
@ -1654,15 +1719,15 @@ void nsRenderingContextWin :: SetupFontAndColor(void)
|
|||
|
||||
::SelectObject(mDC, tfont);
|
||||
|
||||
mStates->mFont = mCurrFont = tfont;
|
||||
mStates->mFontMetrics = mCurrFontMetrics = mFontMetrics;
|
||||
mCurrFont = tfont;
|
||||
mCurrFontMetrics = mFontMetrics;
|
||||
//printf("fonts: %d\n", ++numfont);
|
||||
}
|
||||
|
||||
if (mCurrentColor != mCurrTextColor)
|
||||
{
|
||||
::SetTextColor(mDC, PALETTERGB_COLORREF(mColor));
|
||||
mStates->mTextColor = mCurrTextColor = mCurrentColor;
|
||||
mCurrTextColor = mCurrentColor;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1701,12 +1766,7 @@ HPEN nsRenderingContextWin :: SetupSolidPen(void)
|
|||
{
|
||||
if ((mCurrentColor != mCurrPenColor) || (NULL == mCurrPen) || (mCurrPen != mStates->mSolidPen))
|
||||
{
|
||||
HPEN tpen;
|
||||
|
||||
if (PR_TRUE == mGetNearestColor)
|
||||
tpen = ::CreatePen(PS_SOLID, 0, PALETTERGB_COLORREF(::GetNearestColor(mDC, mColor)));
|
||||
else
|
||||
tpen = ::CreatePen(PS_SOLID, 0, PALETTERGB_COLORREF(mColor));
|
||||
HPEN tpen = ::CreatePen(PS_SOLID, 0, PALETTERGB_COLORREF(mColor));
|
||||
|
||||
::SelectObject(mDC, tpen);
|
||||
|
||||
|
@ -1714,7 +1774,7 @@ HPEN nsRenderingContextWin :: SetupSolidPen(void)
|
|||
VERIFY(::DeleteObject(mCurrPen));
|
||||
|
||||
mStates->mSolidPen = mCurrPen = tpen;
|
||||
mStates->mPenColor = mCurrPenColor = mCurrentColor;
|
||||
mCurrPenColor = mCurrentColor;
|
||||
//printf("pens: %d\n", ++numpen);
|
||||
}
|
||||
|
||||
|
@ -1725,12 +1785,7 @@ HPEN nsRenderingContextWin :: SetupDashedPen(void)
|
|||
{
|
||||
if ((mCurrentColor != mCurrPenColor) || (NULL == mCurrPen) || (mCurrPen != mStates->mDashedPen))
|
||||
{
|
||||
HPEN tpen;
|
||||
|
||||
if (PR_TRUE == mGetNearestColor)
|
||||
tpen = ::CreatePen(PS_DASH, 0, PALETTERGB_COLORREF(::GetNearestColor(mDC, mColor)));
|
||||
else
|
||||
tpen = ::CreatePen(PS_DASH, 0, PALETTERGB_COLORREF(mColor));
|
||||
HPEN tpen = ::CreatePen(PS_DASH, 0, PALETTERGB_COLORREF(mColor));
|
||||
|
||||
::SelectObject(mDC, tpen);
|
||||
|
||||
|
@ -1738,7 +1793,7 @@ HPEN nsRenderingContextWin :: SetupDashedPen(void)
|
|||
VERIFY(::DeleteObject(mCurrPen));
|
||||
|
||||
mStates->mDashedPen = mCurrPen = tpen;
|
||||
mStates->mPenColor = mCurrPenColor = mCurrentColor;
|
||||
mCurrPenColor = mCurrentColor;
|
||||
//printf("pens: %d\n", ++numpen);
|
||||
}
|
||||
|
||||
|
@ -1749,12 +1804,7 @@ HPEN nsRenderingContextWin :: SetupDottedPen(void)
|
|||
{
|
||||
if ((mCurrentColor != mCurrPenColor) || (NULL == mCurrPen) || (mCurrPen != mStates->mDottedPen))
|
||||
{
|
||||
HPEN tpen;
|
||||
|
||||
if (PR_TRUE == mGetNearestColor)
|
||||
tpen = ::CreatePen(PS_DOT, 0, PALETTERGB_COLORREF(::GetNearestColor(mDC, mColor)));
|
||||
else
|
||||
tpen = ::CreatePen(PS_DOT, 0, PALETTERGB_COLORREF(mColor));
|
||||
HPEN tpen = ::CreatePen(PS_DOT, 0, PALETTERGB_COLORREF(mColor));
|
||||
|
||||
::SelectObject(mDC, tpen);
|
||||
|
||||
|
@ -1762,8 +1812,7 @@ HPEN nsRenderingContextWin :: SetupDottedPen(void)
|
|||
VERIFY(::DeleteObject(mCurrPen));
|
||||
|
||||
mStates->mDottedPen = mCurrPen = tpen;
|
||||
mStates->mPenColor = mCurrPenColor = mCurrentColor;
|
||||
|
||||
mCurrPenColor = mCurrentColor;
|
||||
//printf("pens: %d\n", ++numpen);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,11 @@ public:
|
|||
|
||||
NS_IMETHOD GetDeviceContext(nsIDeviceContext *&aContext);
|
||||
|
||||
NS_IMETHOD LockDrawingSurface(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
|
||||
void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
|
||||
PRUint32 aFlags);
|
||||
NS_IMETHOD UnlockDrawingSurface(void);
|
||||
|
||||
NS_IMETHOD SelectOffScreenDrawingSurface(nsDrawingSurface aSurface);
|
||||
NS_IMETHOD GetDrawingSurface(nsDrawingSurface *aSurface);
|
||||
NS_IMETHOD GetHints(PRUint32& aResult);
|
||||
|
@ -203,9 +208,8 @@ protected:
|
|||
HPEN mCurrPen;
|
||||
HPEN mNullPen;
|
||||
PRUint8 *mGammaTable;
|
||||
COLORREF mCurrTextColor;
|
||||
nscolor mCurrTextColor;
|
||||
nsLineStyle mCurrLineStyle;
|
||||
PRBool mGetNearestColor;
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
PRBool mInitialized;
|
||||
|
|
Загрузка…
Ссылка в новой задаче