moving headers from src to public. added support for dib sections to windows

drawing surface. WIP on making blender work with arbitrary pixel organizations.
This commit is contained in:
michaelp%netscape.com 1999-01-25 22:16:47 +00:00
Родитель 4f72556760
Коммит c8e0ba6a08
40 изменённых файлов: 562 добавлений и 83 удалений

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

@ -2,4 +2,27 @@
# This is a list of local files which get copied to the mozilla:dist:widget directory
#
nsIDOMRenderingContext.h
nsIDOMRenderingContext.h
nsColor.h
nsColorNames.h
nsCoord.h
nsFont.h
nsRect.h
nsPoint.h
nsSize.h
nsMargin.h
nsTransform2D.h
nsIRenderingContext.h
nsIFontMetrics.h
nsIImageManager.h
nsIImageGroup.h
nsIImageRequest.h
nsIImageObserver.h
nsIDeviceContext.h
nsIImage.h
nsIBlender.h
nsGfxCIID.h
nsIRegion.h
nsDeviceContext.h
nsIDeviceContextSpec.h
nsIDeviceContextSpecFactory.h

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

@ -24,6 +24,29 @@ include $(DEPTH)/config/autoconf.mk
EXPORTS = \
nsIDOMRenderingContext.h \
nsColor.h \
nsColorNames.h \
nsCoord.h \
nsFont.h \
nsRect.h \
nsPoint.h \
nsSize.h \
nsMargin.h \
nsTransform2D.h \
nsIRenderingContext.h \
nsIFontMetrics.h \
nsIImageManager.h \
nsIImageGroup.h \
nsIImageRequest.h \
nsIImageObserver.h \
nsIDeviceContext.h \
nsIImage.h \
nsIBlender.h \
nsGfxCIID.h \
nsIRegion.h \
nsDeviceContext.h \
nsIDeviceContextSpec.h \
nsIDeviceContextSpecFactory.h \
$(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))

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

@ -20,6 +20,29 @@ IGNORE_MANIFEST=1
EXPORTS = \
nsIDOMRenderingContext.h \
nsColor.h \
nsColorNames.h \
nsCoord.h \
nsFont.h \
nsRect.h \
nsPoint.h \
nsSize.h \
nsMargin.h \
nsTransform2D.h \
nsIRenderingContext.h \
nsIFontMetrics.h \
nsIImageManager.h \
nsIImageGroup.h \
nsIImageRequest.h \
nsIImageObserver.h \
nsIDeviceContext.h \
nsIImage.h \
nsIBlender.h \
nsGfxCIID.h \
nsIRegion.h \
nsDeviceContext.h \
nsIDeviceContextSpec.h \
nsIDeviceContextSpecFactory.h \
$(NULL)
MODULE=raptor

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -1,27 +0,0 @@
#
# This is a list of local files which get copied to the mozilla:dist:gfx directory
#
nsColor.h
nsColorNames.h
nsCoord.h
nsFont.h
nsRect.h
nsPoint.h
nsSize.h
nsMargin.h
nsTransform2D.h
nsIRenderingContext.h
nsIFontMetrics.h
nsIImageManager.h
nsIImageGroup.h
nsIImageRequest.h
nsIImageObserver.h
nsIDeviceContext.h
nsIImage.h
nsIBlender.h
nsGfxCIID.h
nsIRegion.h
nsDeviceContext.h
nsIDeviceContextSpec.h
nsIDeviceContextSpecFactory.h

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

@ -41,13 +41,4 @@ CPPSRCS=nsColor.cpp nsColorNames.cpp nsColorNamesRGB.cpp nsFont.cpp \
nsDeviceContext.cpp nsImageNetContextSync.cpp \
nsJSRenderingContext.cpp
EXPORTS=nsColor.h nsColorNames.h nsCoord.h nsFont.h nsRect.h nsPoint.h \
nsSize.h nsMargin.h nsTransform2D.h nsIRenderingContext.h \
nsIFontMetrics.h nsIImageManager.h nsIImageGroup.h nsIImageRequest.h \
nsIImageObserver.h nsIDeviceContext.h nsIImage.h nsIBlender.h \
nsGfxCIID.h nsIRegion.h nsDeviceContext.h nsIDeviceContextSpec.h \
nsIDeviceContextSpecFactory.h
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
include $(topsrcdir)/config/rules.mk

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

@ -21,7 +21,7 @@
#include "nscore.h"
#include "nsIFactory.h"
#include "nsISupports.h"
#include "../nsGfxCIID.h"
#include "nsGfxCIID.h"
#include "nsFontMetricsGTK.h"
#include "nsRenderingContextGTK.h"
#include "nsImageGTK.h"

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

@ -32,13 +32,6 @@ CPPSRCS=nsColor.cpp nsColorNames.cpp nsColorNamesRGB.cpp nsFont.cpp \
nsImageURL.cpp nsRect.cpp nsTransform2D.cpp nsBlender.cpp \
nsDeviceContext.cpp nsImageNetContextSync.cpp
EXPORTS=nsColor.h nsColorNames.h nsCoord.h nsFont.h nsRect.h nsPoint.h \
nsSize.h nsMargin.h nsTransform2D.h nsIRenderingContext.h \
nsIFontMetrics.h nsIImageManager.h nsIImageGroup.h nsIImageRequest.h \
nsIImageObserver.h nsIDeviceContext.h nsIImage.h nsIBlender.h \
nsGfxCIID.h nsIRegion.h nsDeviceContext.h nsIDeviceContextSpec.h \
nsIDeviceContextSpecFactory.h
CPP_OBJS=.\$(OBJDIR)\nsColor.obj .\$(OBJDIR)\nsColorNames.obj \
.\$(OBJDIR)\nsColorNamesRGB.obj .\$(OBJDIR)\nsFont.obj \
.\$(OBJDIR)\nsImageGroup.obj .\$(OBJDIR)\nsImageManager.obj \

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

@ -20,7 +20,7 @@
#include "nscore.h"
#include "nsIFactory.h"
#include "nsISupports.h"
#include "../nsGfxCIID.h"
#include "nsGfxCIID.h"
#include "nsFontMetricsMotif.h"
#include "nsRenderingContextMotif.h"
#include "nsImageMotif.h"

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

@ -80,7 +80,7 @@ nsBlender :: CalcBytesSpan(PRUint32 aWidth, PRUint32 aBitsPixel)
* @param aBlendQuality The quality of this blend, this is for tweening if neccesary
*/
void
nsBlender::Do32Blend(PRUint8 aBlendVal,PRInt32 aNumlines,PRInt32 aNumbytes,PRUint8 *aSImage,PRUint8 *aDImage,PRUint8 *aSecondSImage,PRInt32 aSLSpan,PRInt32 aDLSpan,nsBlendQuality aBlendQuality,nscolor aSrcBackColor, nscolor aSecondSrcBackColor)
nsBlender::Do32Blend(PRUint8 aBlendVal,PRInt32 aNumlines,PRInt32 aNumbytes,PRUint8 *aSImage,PRUint8 *aDImage,PRUint8 *aSecondSImage,PRInt32 aSLSpan,PRInt32 aDLSpan,nsBlendQuality aBlendQuality,nscolor aSrcBackColor, nscolor aSecondSrcBackColor, nsPixelFormat &aPixFormat)
{
PRUint8 *d1,*d2,*s1,*s2;
PRUint32 val1,val2;
@ -205,11 +205,12 @@ PRInt32 sspan,dspan,mspan;
* @param aBlendQuality The quality of this blend, this is for tweening if neccesary
*/
void
nsBlender::Do24Blend(PRUint8 aBlendVal,PRInt32 aNumlines,PRInt32 aNumbytes,PRUint8 *aSImage,PRUint8 *aDImage,PRUint8 *aSecondSImage,PRInt32 aSLSpan,PRInt32 aDLSpan,nsBlendQuality aBlendQuality,nscolor aSrcBackColor, nscolor aSecondSrcBackColor)
nsBlender::Do24Blend(PRUint8 aBlendVal,PRInt32 aNumlines,PRInt32 aNumbytes,PRUint8 *aSImage,PRUint8 *aDImage,PRUint8 *aSecondSImage,PRInt32 aSLSpan,PRInt32 aDLSpan,nsBlendQuality aBlendQuality,nscolor aSrcBackColor, nscolor aSecondSrcBackColor, nsPixelFormat &aPixFormat)
{
PRUint8 *d1,*d2,*s1,*s2;
PRUint8 *d1,*d2,*s1,*s2,*ss1,*ss2;
PRUint32 val1,val2;
PRInt32 x,y,temp1,numlines,xinc,yinc;
PRUint16 srccolor,secsrccolor;
aBlendVal = (aBlendVal*255)/100;
val2 = aBlendVal;
@ -223,6 +224,19 @@ PRInt32 x,y,temp1,numlines,xinc,yinc;
xinc = 1;
yinc = 1;
if (nsnull != aSecondSImage)
{
ss1 = (PRUint8 *)aSecondSImage;
srccolor = ((NS_GET_R(aSrcBackColor) & 0xf8) << 8) |
((NS_GET_G(aSrcBackColor) & 0xfc) << 3) |
((NS_GET_B(aSrcBackColor) & 0xf8) >> 3);
secsrccolor = ((NS_GET_R(aSecondSrcBackColor) & 0xf8) << 8) |
((NS_GET_G(aSecondSrcBackColor) & 0xfc) << 3) |
((NS_GET_B(aSecondSrcBackColor) & 0xf8) >> 3);
}
else
ss1 = nsnull;
for(y = 0; y < aNumlines; y++){
s2 = s1;
d2 = d1;
@ -262,7 +276,7 @@ PRInt32 x,y,temp1,numlines,xinc,yinc;
* @param aBlendQuality The quality of this blend, this is for tweening if neccesary
*/
void
nsBlender::Do16Blend(PRUint8 aBlendVal,PRInt32 aNumlines,PRInt32 aNumbytes,PRUint8 *aSImage,PRUint8 *aDImage,PRUint8 *aSecondSImage,PRInt32 aSLSpan,PRInt32 aDLSpan,nsBlendQuality aBlendQuality,nscolor aSrcBackColor, nscolor aSecondSrcBackColor)
nsBlender::Do16Blend(PRUint8 aBlendVal,PRInt32 aNumlines,PRInt32 aNumbytes,PRUint8 *aSImage,PRUint8 *aDImage,PRUint8 *aSecondSImage,PRInt32 aSLSpan,PRInt32 aDLSpan,nsBlendQuality aBlendQuality,nscolor aSrcBackColor, nscolor aSecondSrcBackColor, nsPixelFormat &aPixFormat)
{
PRUint16 *d1,*d2,*s1,*s2,*ss1,*ss2;
PRUint32 val1,val2,red,green,blue,stemp,dtemp,sstemp;
@ -287,7 +301,7 @@ PRInt16 dspan,sspan,span;
if (nsnull != aSecondSImage)
{
ss1 = (PRUint16*)aSecondSImage;
ss1 = (PRUint16 *)aSecondSImage;
srccolor = ((NS_GET_R(aSrcBackColor) & 0xf8) << 8) |
((NS_GET_G(aSrcBackColor) & 0xfc) << 3) |
((NS_GET_B(aSrcBackColor) & 0xf8) >> 3);

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

@ -37,6 +37,25 @@
#include "nsIImage.h"
#include "libimg.h"
typedef struct
{
PRUint32 mRedZeroMask; //red color mask in zero position
PRUint32 mGreenZeroMask; //green color mask in zero position
PRUint32 mBlueZeroMask; //blue color mask in zero position
PRUint32 mAlphaZeroMask; //alpha data mask in zero position
PRUint32 mRedMask; //red color mask
PRUint32 mGreenMask; //green color mask
PRUint32 mBlueMask; //blue color mask
PRUint32 mAlphaMask; //alpha data mask
PRUint8 mRedCount; //number of red color bits
PRUint8 mGreenCount; //number of green color bits
PRUint8 mBlueCount; //number of blue color bits
PRUint8 mAlphaCount; //number of alpha data bits
PRUint8 mRedShift; //number to shift value into red position
PRUint8 mGreenShift; //number to shift value into green position
PRUint8 mBlueShift; //number to shift value into blue position
PRUint8 mAlphaShift; //number to shift value into alpha position
} nsPixelFormat;
//----------------------------------------------------------------------
@ -83,10 +102,11 @@ public:
* @param aDLSpan number of bytes per line for the destination bytes
* @param aMLSpan number of bytes per line for the Mask bytes
* @param aBlendQuality The quality of this blend, this is for tweening if neccesary
* @param aPixelFormat nsPixelFormat struct filled out to describe data format
*/
void Do32Blend(PRUint8 aBlendVal,PRInt32 aNumlines,PRInt32 aNumbytes,PRUint8 *aSImage,PRUint8 *aDImage,
PRUint8 *aSecondSImage,PRInt32 aSLSpan,PRInt32 aDLSpan,nsBlendQuality aBlendQuality,
nscolor aSrcBackColor, nscolor aSecondSrcBackColor);
nscolor aSrcBackColor, nscolor aSecondSrcBackColor, nsPixelFormat &aPixelFormat);
/** --------------------------------------------------------------------------
* Blend two 24 bit image arrays using an 8 bit alpha mask
@ -117,7 +137,7 @@ public:
*/
void Do24Blend(PRUint8 aBlendVal,PRInt32 aNumlines,PRInt32 aNumbytes,PRUint8 *aSImage,PRUint8 *aDImage,
PRUint8 *aSecondSImage,PRInt32 aSLSpan,PRInt32 aDLSpan,nsBlendQuality aBlendQuality,
nscolor aSrcBackColor, nscolor aSecondSrcBackColor);
nscolor aSrcBackColor, nscolor aSecondSrcBackColor, nsPixelFormat &aPixelFormat);
/** --------------------------------------------------------------------------
@ -134,7 +154,7 @@ public:
*/
void Do16Blend(PRUint8 aBlendVal,PRInt32 aNumlines,PRInt32 aNumbytes,PRUint8 *aSImage,PRUint8 *aDImage,
PRUint8 *aSecondSImage,PRInt32 aSLSpan,PRInt32 aDLSpan,nsBlendQuality aBlendQuality,
nscolor aSrcBackColor, nscolor aSecondSrcBackColor);
nscolor aSrcBackColor, nscolor aSecondSrcBackColor, nsPixelFormat &aPixelFormat);
/** --------------------------------------------------------------------------
* Blend two 8 bit image arrays using an 8 bit alpha mask

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

@ -59,8 +59,6 @@ nsBlenderWin :: ~nsBlenderWin()
if (nsnull != mSecondSrcbinfo)
DeleteDIB(&mSecondSrcbinfo, &mSecondSrcBytes);
mDstBytes = nsnull;
}
/** --------------------------------------------------------------------------
@ -104,6 +102,7 @@ HDC srcdc, dstdc, secondsrcdc;
PRBool srcissurf = PR_FALSE;
PRBool secondsrcissurf = PR_FALSE;
PRBool dstissurf = PR_FALSE;
nsPixelFormat pixformat;
// This is a temporary solution, nsDrawingSurface is a void*, but on windows it is really a
// nsDrawingSurfaceWin, which is an XPCom object. I am going to cast it here just temporarily
@ -125,7 +124,7 @@ PRBool dstissurf = PR_FALSE;
srect.right = aSX + aWidth;
srect.bottom = aSY + aHeight;
if (PR_TRUE == LockSurface(SrcWinSurf->mSurface, &mSrcSurf, &mSrcInfo, &srect, DDLOCK_READONLY)){
if (PR_TRUE == LockSurface(SrcWinSurf->mSurface, &mSrcSurf, &mSrcInfo, &srect, DDLOCK_READONLY, &pixformat)){
srcissurf = PR_TRUE;
mSRowBytes = mSrcInfo.bmWidthBytes;
}else
@ -146,7 +145,7 @@ PRBool dstissurf = PR_FALSE;
srcbits = SrcWinSurf->mSelectedBitmap;
}
BuildDIB(&mSrcbinfo, &mSrcBytes, mSrcInfo.bmWidth, mSrcInfo.bmHeight, mSrcInfo.bmBitsPixel);
BuildDIB(&mSrcbinfo, &mSrcBytes, mSrcInfo.bmWidth, mSrcInfo.bmHeight, mSrcInfo.bmBitsPixel, &pixformat);
numbytes = ::GetDIBits(srcdc, srcbits, 0, mSrcInfo.bmHeight, mSrcBytes, (LPBITMAPINFO)mSrcbinfo, DIB_RGB_COLORS);
mSRowBytes = CalcBytesSpan(mSrcInfo.bmWidth, mSrcInfo.bmBitsPixel);
@ -165,7 +164,7 @@ PRBool dstissurf = PR_FALSE;
drect.right = aDX + aWidth;
drect.bottom = aDY + aHeight;
if (PR_TRUE == LockSurface(DstWinSurf->mSurface, &mDstSurf, &mDstInfo, &drect, 0)){
if (PR_TRUE == LockSurface(DstWinSurf->mSurface, &mDstSurf, &mDstInfo, &drect, 0, nsnull)){
dstissurf = PR_TRUE;
mDRowBytes = mDstInfo.bmWidthBytes;
}
@ -187,7 +186,7 @@ PRBool dstissurf = PR_FALSE;
dstbits = DstWinSurf->mSelectedBitmap;
}
BuildDIB(&mDstbinfo, &mDstBytes, mDstInfo.bmWidth, mDstInfo.bmHeight, mDstInfo.bmBitsPixel);
BuildDIB(&mDstbinfo, &mDstBytes, mDstInfo.bmWidth, mDstInfo.bmHeight, mDstInfo.bmBitsPixel, nsnull);
numbytes = ::GetDIBits(dstdc, dstbits, 0, mDstInfo.bmHeight, mDstBytes, (LPBITMAPINFO)mDstbinfo, DIB_RGB_COLORS);
mDRowBytes = CalcBytesSpan(mDstInfo.bmWidth, mDstInfo.bmBitsPixel);
@ -208,7 +207,7 @@ PRBool dstissurf = PR_FALSE;
srect.right = aSX + aWidth;
srect.bottom = aSY + aHeight;
if (PR_TRUE == LockSurface(SecondSrcWinSurf->mSurface, &mSecondSrcSurf, &mSecondSrcInfo, &srect, DDLOCK_READONLY)){
if (PR_TRUE == LockSurface(SecondSrcWinSurf->mSurface, &mSecondSrcSurf, &mSecondSrcInfo, &srect, DDLOCK_READONLY, nsnull)){
secondsrcissurf = PR_TRUE;
}else
#endif
@ -228,7 +227,7 @@ PRBool dstissurf = PR_FALSE;
srcbits = SecondSrcWinSurf->mSelectedBitmap;
}
BuildDIB(&mSecondSrcbinfo, &mSecondSrcBytes, mSecondSrcInfo.bmWidth, mSecondSrcInfo.bmHeight, mSecondSrcInfo.bmBitsPixel);
BuildDIB(&mSecondSrcbinfo, &mSecondSrcBytes, mSecondSrcInfo.bmWidth, mSecondSrcInfo.bmHeight, mSecondSrcInfo.bmBitsPixel, nsnull);
numbytes = ::GetDIBits(secondsrcdc, srcbits, 0, mSecondSrcInfo.bmHeight, mSecondSrcBytes, (LPBITMAPINFO)mSecondSrcbinfo, DIB_RGB_COLORS);
}
@ -252,7 +251,7 @@ PRBool dstissurf = PR_FALSE;
case 32:
if (!mask){
level = (PRInt32)(aSrcOpacity*100);
Do32Blend(level,numlines,numbytes,s1,d1,ssl,slinespan,dlinespan,nsHighQual,aSrcBackColor,aSecondSrcBackColor);
Do32Blend(level,numlines,numbytes,s1,d1,ssl,slinespan,dlinespan,nsHighQual,aSrcBackColor,aSecondSrcBackColor,pixformat);
result = NS_OK;
}else
result = NS_ERROR_FAILURE;
@ -264,7 +263,7 @@ PRBool dstissurf = PR_FALSE;
result = NS_OK;
}else{
level = (PRInt32)(aSrcOpacity*100);
Do24Blend(level,numlines,numbytes,s1,d1,ssl,slinespan,dlinespan,nsHighQual,aSrcBackColor,aSecondSrcBackColor);
Do24Blend(level,numlines,numbytes,s1,d1,ssl,slinespan,dlinespan,nsHighQual,aSrcBackColor,aSecondSrcBackColor,pixformat);
result = NS_OK;
}
break;
@ -272,7 +271,7 @@ PRBool dstissurf = PR_FALSE;
case 16:
if (!mask){
level = (PRInt32)(aSrcOpacity*100);
Do16Blend(level,numlines,numbytes,s1,d1,ssl,slinespan,dlinespan,nsHighQual,aSrcBackColor,aSecondSrcBackColor);
Do16Blend(level,numlines,numbytes,s1,d1,ssl,slinespan,dlinespan,nsHighQual,aSrcBackColor,aSecondSrcBackColor,pixformat);
result = NS_OK;
}
else
@ -302,7 +301,7 @@ PRBool dstissurf = PR_FALSE;
::DeleteObject(tb1);
}
} else
result = NS_ERROR_FAILURE;
result = NS_ERROR_FAILURE;
}
#ifdef NGLAYOUT_DDRAW
@ -316,6 +315,16 @@ PRBool dstissurf = PR_FALSE;
SecondSrcWinSurf->mSurface->Unlock(mSecondSrcSurf.lpSurface);
#endif
// get rid of the DIB's
if (nsnull != mSrcbinfo)
DeleteDIB(&mSrcbinfo, &mSrcBytes);
if (nsnull != mDstbinfo)
DeleteDIB(&mDstbinfo, &mDstBytes);
if (nsnull != mSecondSrcbinfo)
DeleteDIB(&mSecondSrcbinfo, &mSecondSrcBytes);
return result;
}
@ -331,7 +340,7 @@ PRBool dstissurf = PR_FALSE;
* @param DWORD --
* @result PR_TRUE lock was succesful
*/
PRBool nsBlenderWin :: LockSurface(IDirectDrawSurface *aSurface, DDSURFACEDESC *aDesc, BITMAP *aBitmap, RECT *aRect, DWORD aLockFlags)
PRBool nsBlenderWin :: LockSurface(IDirectDrawSurface *aSurface, DDSURFACEDESC *aDesc, BITMAP *aBitmap, RECT *aRect, DWORD aLockFlags, nsPixelFormat *aPixFormat)
{
if (nsnull != aSurface){
aDesc->dwSize = sizeof(DDSURFACEDESC);
@ -356,6 +365,149 @@ PRBool nsBlenderWin :: LockSurface(IDirectDrawSurface *aSurface, DDSURFACEDESC *
aBitmap->bmBitsPixel = (PRUint16)aDesc->ddpfPixelFormat.dwRGBBitCount;
aBitmap->bmBits = aDesc->lpSurface;
if ((nsnull != aPixFormat) && (aBitmap->bmBitsPixel > 8)) {
DWORD btemp, shiftcnt;
btemp = aDesc->ddpfPixelFormat.dwRBitMask;
aPixFormat->mRedMask = btemp;
shiftcnt = 32;
if (!(btemp & 0xffff)) {
aPixFormat->mRedShift = 16;
btemp >>= 16;
shiftcnt = 16;
}
else if (!(btemp & 0xff)) {
aPixFormat->mRedShift = 8;
btemp >>= 8;
shiftcnt = 24;
}
else {
aPixFormat->mRedShift = 0;
shiftcnt = 32;
}
while (!(btemp & 1) && shiftcnt--) {
btemp >>= 1;
aPixFormat->mRedShift++;
}
aPixFormat->mRedZeroMask = btemp;
aPixFormat->mRedCount = 0;
while ((btemp & 1) && shiftcnt--) {
btemp >>= 1;
aPixFormat->mRedCount++;
}
btemp = aDesc->ddpfPixelFormat.dwGBitMask;
aPixFormat->mGreenMask = btemp;
shiftcnt = 32;
if (!(btemp & 0xffff)) {
aPixFormat->mGreenShift = 16;
btemp >>= 16;
shiftcnt = 16;
}
else if (!(btemp & 0xff)) {
aPixFormat->mGreenShift = 8;
btemp >>= 8;
shiftcnt = 24;
}
else {
aPixFormat->mGreenShift = 0;
shiftcnt = 32;
}
while (!(btemp & 1) && shiftcnt--) {
btemp >>= 1;
aPixFormat->mGreenShift++;
}
aPixFormat->mGreenZeroMask = btemp;
aPixFormat->mGreenCount = 0;
while ((btemp & 1) && shiftcnt--) {
btemp >>= 1;
aPixFormat->mGreenCount++;
}
btemp = aDesc->ddpfPixelFormat.dwBBitMask;
aPixFormat->mBlueMask = btemp;
shiftcnt = 32;
if (!(btemp & 0xffff)) {
aPixFormat->mBlueShift = 16;
btemp >>= 16;
shiftcnt = 16;
}
else if (!(btemp & 0xff)) {
aPixFormat->mBlueShift = 8;
btemp >>= 8;
shiftcnt = 24;
}
else {
aPixFormat->mBlueShift = 0;
shiftcnt = 32;
}
while (!(btemp & 1) && shiftcnt--) {
btemp >>= 1;
aPixFormat->mBlueShift++;
}
aPixFormat->mBlueZeroMask = btemp;
aPixFormat->mBlueCount = 0;
while ((btemp & 1) && shiftcnt--) {
btemp >>= 1;
aPixFormat->mBlueCount++;
}
aPixFormat->mAlphaCount = aDesc->ddpfPixelFormat.dwAlphaBitDepth;
if (aPixFormat->mAlphaCount > 0) {
btemp = aDesc->ddpfPixelFormat.dwRGBAlphaBitMask;
aPixFormat->mAlphaMask = btemp;
shiftcnt = 32;
if (!(btemp & 0xffff)) {
aPixFormat->mAlphaShift = 16;
btemp >>= 16;
shiftcnt = 16;
}
else if (!(btemp & 0xff)) {
aPixFormat->mAlphaShift = 8;
btemp >>= 8;
shiftcnt = 24;
}
else {
aPixFormat->mAlphaShift = 0;
shiftcnt = 32;
}
while (!(btemp & 1) && shiftcnt--) {
btemp >>= 1;
aPixFormat->mAlphaShift++;
}
aPixFormat->mAlphaZeroMask = btemp;
}
else {
aPixFormat->mAlphaMask = 0;
aPixFormat->mAlphaShift = 0;
aPixFormat->mAlphaZeroMask = 0;
}
}
return PR_TRUE;
}else
return PR_FALSE;
@ -464,7 +616,7 @@ PRInt32 startx,starty;
* @result NS_OK if the build was succesful
*/
nsresult
nsBlenderWin :: BuildDIB(LPBITMAPINFOHEADER *aBHead,unsigned char **aBits,PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth)
nsBlenderWin :: BuildDIB(LPBITMAPINFOHEADER *aBHead,unsigned char **aBits,PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth, nsPixelFormat *aPixFormat)
{
PRInt32 palsize, imagesize, spanbytes, allocsize;
PRUint8 *colortable;
@ -484,12 +636,52 @@ nsBlenderWin :: BuildDIB(LPBITMAPINFOHEADER *aBHead,unsigned char **aBits,PRInt
masks[0] = 0xf800;
masks[1] = 0x07e0;
masks[2] = 0x001f;
if (nsnull != aPixFormat) {
aPixFormat->mRedZeroMask = 0x1f;
aPixFormat->mGreenZeroMask = 0x3f;
aPixFormat->mBlueZeroMask = 0x1f;
aPixFormat->mAlphaZeroMask = 0;
aPixFormat->mRedMask = masks[0];
aPixFormat->mGreenMask = masks[1];
aPixFormat->mBlueMask = masks[2];
aPixFormat->mAlphaMask = 0;
aPixFormat->mRedCount = 5;
aPixFormat->mGreenCount = 6;
aPixFormat->mBlueCount = 5;
aPixFormat->mAlphaCount = 0;
aPixFormat->mRedShift = 11;
aPixFormat->mGreenShift = 5;
aPixFormat->mBlueShift = 0;
aPixFormat->mAlphaShift = 0;
}
break;
case 24:
palsize = 0;
allocsize = 0;
bicomp = BI_RGB;
if (nsnull != aPixFormat) {
aPixFormat->mRedZeroMask = 0xff;
aPixFormat->mGreenZeroMask = 0xff;
aPixFormat->mBlueZeroMask = 0xff;
aPixFormat->mAlphaZeroMask = 0;
aPixFormat->mRedMask = 0xff;
aPixFormat->mGreenMask = 0xff00;
aPixFormat->mBlueMask = 0xff0000;
aPixFormat->mAlphaMask = 0;
aPixFormat->mRedCount = 8;
aPixFormat->mGreenCount = 8;
aPixFormat->mBlueCount = 8;
aPixFormat->mAlphaCount = 0;
aPixFormat->mRedShift = 0;
aPixFormat->mGreenShift = 8;
aPixFormat->mBlueShift = 16;
aPixFormat->mAlphaShift = 0;
}
break;
case 32:
@ -499,6 +691,26 @@ nsBlenderWin :: BuildDIB(LPBITMAPINFOHEADER *aBHead,unsigned char **aBits,PRInt
masks[0] = 0xff0000;
masks[1] = 0x00ff00;
masks[2] = 0x0000ff;
if (nsnull != aPixFormat) {
aPixFormat->mRedZeroMask = 0xff;
aPixFormat->mGreenZeroMask = 0xff;
aPixFormat->mBlueZeroMask = 0xff;
aPixFormat->mAlphaZeroMask = 0xff;
aPixFormat->mRedMask = masks[0];
aPixFormat->mGreenMask = masks[1];
aPixFormat->mBlueMask = masks[2];
aPixFormat->mAlphaMask = 0xff000000;
aPixFormat->mRedCount = 8;
aPixFormat->mGreenCount = 8;
aPixFormat->mBlueCount = 8;
aPixFormat->mAlphaCount = 8;
aPixFormat->mRedShift = 16;
aPixFormat->mGreenShift = 8;
aPixFormat->mBlueShift = 0;
aPixFormat->mAlphaShift = 24;
}
break;
default:

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

@ -94,7 +94,7 @@ public:
* @param aHeight Height of the bitmap to create
* @param aDepth Bits per pixel of the bitmap to create
*/
nsresult BuildDIB(LPBITMAPINFOHEADER *aBHead,unsigned char **aBits,PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth);
nsresult BuildDIB(LPBITMAPINFOHEADER *aBHead,unsigned char **aBits,PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth, nsPixelFormat *aPixFormat);
/**
* Delete the DIB header and bits created from BuildDIB
@ -115,7 +115,7 @@ public:
* @param DWORD --
* @result PR_TRUE lock was succesful
*/
PRBool LockSurface(IDirectDrawSurface *aSurface, DDSURFACEDESC *aDesc, BITMAP *aBitmap, RECT *aRect, DWORD aLockFlags);
PRBool LockSurface(IDirectDrawSurface *aSurface, DDSURFACEDESC *aDesc, BITMAP *aBitmap, RECT *aRect, DWORD aLockFlags, nsPixelFormat *aPixFormat);
#endif
private:

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

@ -19,7 +19,7 @@
#include "nscore.h"
#include "nsIFactory.h"
#include "nsISupports.h"
#include "../nsGfxCIID.h"
#include "nsGfxCIID.h"
#include "nsFontMetricsWin.h"
#include "nsRenderingContextWin.h"
#include "nsImageWin.h"

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

@ -85,18 +85,10 @@ void CALLBACK LineDDAFunc(int x,int y,LONG lData)
{
lineddastruct * dda_struct = (lineddastruct *) lData;
if (dda_struct->nDottedPixel == 1)
{
dda_struct->nDottedPixel = 0;
dda_struct->nDottedPixel ^= 1;
SetPixel(dda_struct->dc,
x,y,
dda_struct->crColor);
}
else
{
dda_struct->nDottedPixel = 1;
}
if (dda_struct->nDottedPixel)
SetPixel(dda_struct->dc, x, y, dda_struct->crColor);
}
@ -190,6 +182,8 @@ nsDrawingSurfaceWin :: nsDrawingSurfaceWin()
mOrigBitmap = nsnull;
mSelectedBitmap = nsnull;
mKillDC = PR_TRUE;
mBitmapInfo = nsnull;
mDIBits = nsnull;
#ifdef NGLAYOUT_DDRAW
mSurface = NULL;
@ -210,6 +204,14 @@ nsDrawingSurfaceWin :: ~nsDrawingSurfaceWin()
mSelectedBitmap = nsnull;
if (nsnull != mBitmapInfo)
{
delete mBitmapInfo;
mBitmapInfo = nsnull;
}
mDIBits = nsnull;
#ifdef NGLAYOUT_DDRAW
if (NULL != mSurface)
{
@ -1106,7 +1108,31 @@ NS_IMETHODIMP nsRenderingContextWin :: CreateDrawingSurface(nsRect *aBounds, PRU
#endif
{
if (nsnull != aBounds)
surf->mSelectedBitmap = ::CreateCompatibleBitmap(mMainDC, aBounds->width, aBounds->height);
{
if (aSurfFlags & NS_CREATEDRAWINGSURFACE_FOR_PIXEL_ACCESS)
{
void *bits;
PRUint32 depth;
BITMAPINFO *binfo;
mContext->GetDepth(depth);
binfo = CreateBitmapInfo(aBounds->width, aBounds->height, depth);
if (nsnull != binfo)
surf->mSelectedBitmap = ::CreateDIBSection(mMainDC, binfo, DIB_RGB_COLORS, &bits, NULL, 0);
if (NULL == surf->mSelectedBitmap)
surf->mSelectedBitmap = ::CreateCompatibleBitmap(mMainDC, aBounds->width, aBounds->height);
else
{
surf->mBitmapInfo = binfo;
surf->mDIBits = (PRUint8 *)bits;
}
}
else
surf->mSelectedBitmap = ::CreateCompatibleBitmap(mMainDC, aBounds->width, aBounds->height);
}
else
{
//we do this to make sure that the memory DC knows what the
@ -2026,6 +2052,86 @@ nsresult nsRenderingContextWin :: GetDDraw(IDirectDraw2 **aDDraw)
#endif
#define RASWIDTH(width, bpp) ((((width) * (bpp) + 31) >> 5) << 2)
BITMAPINFO * nsRenderingContextWin :: CreateBitmapInfo(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth)
{
PRInt32 palsize, imagesize, spanbytes, allocsize;
PRUint8 *colortable;
DWORD bicomp, masks[3];
BITMAPINFO *rv = nsnull;
switch (aDepth)
{
case 8:
palsize = 256;
allocsize = 256;
bicomp = BI_RGB;
break;
case 16:
palsize = 0;
allocsize = 3;
bicomp = BI_BITFIELDS;
masks[0] = 0xf800;
masks[1] = 0x07e0;
masks[2] = 0x001f;
break;
case 24:
palsize = 0;
allocsize = 0;
bicomp = BI_RGB;
break;
case 32:
palsize = 0;
allocsize = 3;
bicomp = BI_BITFIELDS;
masks[0] = 0xff0000;
masks[1] = 0x00ff00;
masks[2] = 0x0000ff;
break;
default:
palsize = -1;
break;
}
if (palsize >= 0)
{
spanbytes = RASWIDTH(aWidth, aDepth);
imagesize = spanbytes * aHeight;
rv = (BITMAPINFO *)new char[sizeof(BITMAPINFOHEADER) + (sizeof(RGBQUAD) * allocsize)];
if (nsnull != rv)
{
rv->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
rv->bmiHeader.biWidth = aWidth;
rv->bmiHeader.biHeight = aHeight;
rv->bmiHeader.biPlanes = 1;
rv->bmiHeader.biBitCount = (unsigned short)aDepth;
rv->bmiHeader.biCompression = bicomp;
rv->bmiHeader.biSizeImage = imagesize;
rv->bmiHeader.biXPelsPerMeter = 0;
rv->bmiHeader.biYPelsPerMeter = 0;
rv->bmiHeader.biClrUsed = palsize;
rv->bmiHeader.biClrImportant = palsize;
// set the color table in the info header
colortable = (PRUint8 *)rv + sizeof(BITMAPINFOHEADER);
if ((aDepth == 16) || (aDepth == 32))
nsCRT::memcpy(colortable, masks, sizeof(DWORD) * allocsize);
else
nsCRT::zero(colortable, sizeof(RGBQUAD) * palsize);
}
}
return rv;
}
NS_IMETHODIMP
nsRenderingContextWin::GetScriptObject(nsIScriptContext* aContext,
void** aScriptObject)

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

@ -181,6 +181,7 @@ private:
#ifdef NGLAYOUT_DDRAW
nsresult CreateDDraw(void);
#endif
BITMAPINFO *CreateBitmapInfo(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth);
protected:
nscolor mCurrentColor;
@ -253,6 +254,8 @@ public:
HBITMAP mOrigBitmap;
HBITMAP mSelectedBitmap;
PRBool mKillDC;
BITMAPINFO *mBitmapInfo;
PRUint8 *mDIBits;
#ifdef NGLAYOUT_DDRAW
IDirectDrawSurface *mSurface;

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

@ -0,0 +1,33 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsIDeviceContextSpec_h___
#define nsIDeviceContextSpec_h___
#include "nsIDeviceContext.h"
#define NS_IDEVICE_CONTEXT_SPEC_IID \
{ 0x9951f910, 0x78d7, 0x11d2, \
{ 0xa8, 0x46, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
class nsIDeviceContextSpec : public nsISupports
{
public:
};
#endif

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

@ -0,0 +1,65 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsIDeviceContextSpecFactory_h___
#define nsIDeviceContextSpecFactory_h___
#include "nsISupports.h"
class nsIDeviceContextSpec;
#define NS_IDEVICE_CONTEXT_SPEC_FACTORY_IID \
{ 0xf6669570, 0x7b3d, 0x11d2, \
{ 0xa8, 0x48, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
class nsIDeviceContextSpecFactory : public nsISupports
{
public:
/**
* Initialize the device context spec factory
* @return error status
*/
NS_IMETHOD Init(void) = 0;
/**
* Get a device context specification. Typically, this
* means getting information about a printer. A previously
* returned device context spec can be passed in and used as
* a starting point for getting a new spec (or simply returning
* the old spec again). Additionally, if it is desirable to
* get the device context spec without user intervention, any
* dialog boxes can be supressed by passing in PR_TRUE for the
* aQuiet parameter.
* @param aOldSpec a previously obtained devince context spec which
* can be used to initialize parameters of the new context to
* be returned.
* @param aNewSpec out parameter for device context spec returned. the
* aOldSpec may be returned if the object is recyclable.
* @param aQuiet if PR_TRUE, prevent the need for user intervention
* in obtaining device context spec. if nsnull is passed in for
* the aOldSpec, this will typically result in getting a device
* context spec for the default output device (i.e. default
* printer).
* @return error status
*/
NS_IMETHOD CreateDeviceContextSpec(nsIDeviceContextSpec *aOldSpec,
nsIDeviceContextSpec *&aNewSpec,
PRBool aQuiet) = 0;
};
#endif