256 color and print cleanup
This commit is contained in:
mkaply%us.ibm.com 2001-01-24 01:49:40 +00:00
Родитель d30cb4c1a9
Коммит a466511e6b
6 изменённых файлов: 195 добавлений и 204 удалений

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

@ -35,8 +35,6 @@
#include "nsGfxDefs.h"
#define RGB_PRINTING 1 // Makes most things work
// Size of the color cube
#define COLOR_CUBE_SIZE 216
@ -65,6 +63,7 @@ nsDeviceContextOS2 :: nsDeviceContextOS2()
mSpec = nsnull;
mCachedClientRect = PR_FALSE;
mCachedFullRect = PR_FALSE;
mSupportsRasterFonts = PR_FALSE;
#ifdef XP_OS2
mPrintState = nsPrintState_ePreBeginDoc;
#endif
@ -106,13 +105,6 @@ nsDeviceContextOS2::~nsDeviceContextOS2()
PrnCloseDC(mPrintDC);
}
#ifndef RGB_PRINTING
if (!mPaletteInfo.isPaletteDevice) {
free(mPaletteInfo.palette);
mPaletteInfo.palette = nsnull;
}
#endif
NS_IF_RELEASE(mSpec);
}
@ -120,7 +112,7 @@ nsresult nsDeviceContextOS2::Init( nsNativeWidget aWidget)
{
nsresult retval = DeviceContextImpl::Init(aWidget);
CommonInit(WinOpenWindowDC((HWND)aWidget));
CommonInit(::WinOpenWindowDC((HWND)aWidget));
return retval;
}
@ -182,7 +174,7 @@ void nsDeviceContextOS2 :: CommonInit(HDC aDC)
{
LONG alArray[CAPS_DEVICE_POLYSET_POINTS];
::DevQueryCaps(aDC, CAPS_FAMILY, CAPS_DEVICE_POLYSET_POINTS, alArray);
GFX (::DevQueryCaps(aDC, CAPS_FAMILY, CAPS_DEVICE_POLYSET_POINTS, alArray), FALSE);
// This change breaks opening and closing of sidebar
// mTwipsToPixels = (float)alArray [CAPS_VERTICAL_RESOLUTION] / (float)NS_METERS_TO_TWIPS (1);
@ -217,6 +209,8 @@ void nsDeviceContextOS2 :: CommonInit(HDC aDC)
mScreenManager->GetNumberOfScreens(&sNumberOfScreens);
} // if this dc is not a print device
mSupportsRasterFonts = !!(alArray[CAPS_RASTER_CAPS] & CAPS_RASTER_FONTS);
DeviceContextImpl::CommonInit();
}
@ -656,11 +650,7 @@ NS_IMETHODIMP nsDeviceContextOS2::GetILColorSpace(IL_ColorSpace*& aColorSpace)
{
if (nsnull == mColorSpace) {
// See if we're dealing with an 8-bit palette device
#ifndef RGB_PRINTING
if (8 == mDepth) {
#else
if ((8 == mDepth) && mPaletteInfo.isPaletteDevice) {
#endif
// Create a color cube. We want to use DIB_PAL_COLORS because it's faster
// than DIB_RGB_COLORS, so make sure the indexes match that of the
// GDI physical palette
@ -718,22 +708,22 @@ typedef struct _MYRGB
MYRGB sysColors[NUM_SYS_COLORS] =
{
0xFF, 0xFF, 0xFF, // CLR_WHITE
0x00, 0x00, 0x00, // CLR_BLACK
0x00, 0x00, 0xFF, // CLR_BLUE
0xFF, 0x00, 0x00, // CLR_RED
0xFF, 0x00, 0xFF, // CLR_PINK
0x00, 0xFF, 0x00, // CLR_GREEN
0x00, 0xFF, 0xFF, // CLR_CYAN
0xFF, 0xFF, 0x00, // CLR_YELLOW
0x80, 0x80, 0x80, // CLR_DARKGRAY
0x00, 0x00, 0x80, // CLR_DARKBLUE
0x80, 0x00, 0x00, // CLR_DARKRED
0x80, 0x00, 0x80, // CLR_DARKPINK
0x00, 0x80, 0x00, // CLR_DARKGREEN
0x00, 0x80, 0x80, // CLR_DARKCYAN
0x80, 0x00, 0x00, // CLR_DARKRED
0x80, 0x00, 0x80, // CLR_DARKPINK
0x80, 0x80, 0x00, // CLR_BROWN
0x80, 0x80, 0x80, // CLR_DARKGRAY
0xCC, 0xCC, 0xCC, // CLR_PALEGRAY
0x00, 0x00, 0xFF, // CLR_BLUE
0x00, 0xFF, 0x00, // CLR_GREEN
0x00, 0xFF, 0xFF, // CLR_CYAN
0xFF, 0x00, 0x00, // CLR_RED
0xFF, 0x00, 0xFF, // CLR_PINK
0xFF, 0xFF, 0x00, // CLR_YELLOW
0xFE, 0xFE, 0xFE, // CLR_OFFWHITE - can only use white at index 255
0xC0, 0xC0, 0xC0, // Gray (Windows)
0xFF, 0xFB, 0xF0, // Pale Yellow (Windows)
@ -746,33 +736,26 @@ MYRGB sysColors[NUM_SYS_COLORS] =
NS_IMETHODIMP nsDeviceContextOS2::GetPaletteInfo(nsPaletteInfo& aPaletteInfo)
{
static PRBool fPaletteInitialized = PR_FALSE;
static ULONG aulTable[256];
aPaletteInfo.isPaletteDevice = mPaletteInfo.isPaletteDevice;
aPaletteInfo.sizePalette = mPaletteInfo.sizePalette;
aPaletteInfo.numReserved = mPaletteInfo.numReserved;
if (NULL == mPaletteInfo.palette) {
IL_ColorSpace* colorSpace;
GetILColorSpace(colorSpace);
if ((mPaletteInfo.isPaletteDevice) && (NULL == mPaletteInfo.palette)) {
if (!fPaletteInitialized) {
IL_ColorSpace* colorSpace;
GetILColorSpace(colorSpace);
if (NI_PseudoColor == colorSpace->type) {
// Create a logical palette
ULONG ulCount = COLOR_CUBE_SIZE+NUM_SYS_COLORS;
#ifndef RGB_PRINTING
PULONG aulTable;
aulTable = (PULONG)malloc(ulCount*sizeof(ULONG));
#else
ULONG aulTable[COLOR_CUBE_SIZE+NUM_SYS_COLORS];
#endif
PRInt32 i, j;
// First ten system colors
for (i = 0; i < 10; i++) {
ULONG ulCount;
PRInt32 i,j;
// system colors
for (i = 0; i < NUM_SYS_COLORS; i++) {
aulTable[i] = MK_RGB(sysColors[i].red, sysColors[i].green, sysColors[i].blue);
}
// Last six system colors + 5 Windows specific colors
for (i = 10, j = COLOR_CUBE_SIZE+10; i < NUM_SYS_COLORS; i++, j++) {
aulTable[j] = MK_RGB( sysColors[i].red, sysColors[i].green, sysColors[i].blue);
}
// Now set the color cube entries.
#ifdef XP_OS2
@ -781,29 +764,46 @@ NS_IMETHODIMP nsDeviceContextOS2::GetPaletteInfo(nsPaletteInfo& aPaletteInfo)
NI_RGB* map = colorSpace->cmap.map + 10;
#endif
for (i = 10; i < COLOR_CUBE_SIZE+10; i++, map++) {
aulTable[i] = MK_RGB( map->red, map->green, map->blue);
}
PRInt32 k = NUM_SYS_COLORS;
for (i = 0; i < COLOR_CUBE_SIZE; i++, map++) {
aulTable[k] = MK_RGB(map->red, map->green, map->blue);
for (j = 0;j < NUM_SYS_COLORS; j++) {
if (aulTable[k] == aulTable[j]) {
aulTable[k] = 0;
break;
} /* endif */
} /* endfor */
if (j == NUM_SYS_COLORS) {
k++;
} /* endif */
} /* endfor */
if (mPaletteInfo.isPaletteDevice) {
// Create a GPI palette
mPaletteInfo.palette = (void*)GFX (::GpiCreatePalette ((HAB)0, NULL,
LCOLF_CONSECRGB, ulCount, aulTable),
GPI_ERROR);
#ifndef RGB_PRINTING
free(aulTable);
} else {
mPaletteInfo.palette = (void*)aulTable;
mPaletteInfo.sizePalette = ulCount;
#endif
}
}
ulCount = (k-1);
// This overwrites the last entry in the cube (white)
for (i=ulCount;i<256 ;i++ ) {
aulTable[i] = MK_RGB(254,254,254);
} /* endfor */
aulTable[255] = MK_RGB(255, 255, 255); // Entry 255 must be white
fPaletteInitialized = PR_TRUE;
IL_ReleaseColorSpace(colorSpace);
}
IL_ReleaseColorSpace(colorSpace);
#ifdef DEBUG
for (i=0;i<256 ;i++ )
printf("Entry[%d] in table is %x\n", i, aulTable[i]);
#endif
} /* endif */
// Create a GPI palette
mPaletteInfo.palette =
(void*)GFX (::GpiCreatePalette ((HAB)0, NULL,
LCOLF_CONSECRGB, 256, aulTable),
GPI_ERROR);
} /* endif */
aPaletteInfo.palette = mPaletteInfo.palette;
aPaletteInfo.sizePalette = mPaletteInfo.sizePalette;
return NS_OK;
}
@ -968,3 +968,7 @@ BOOL nsDeviceContextOS2::isPrintDC()
else
return 1;
}
PRBool nsDeviceContextOS2::SupportsRasterFonts()
{
return mSupportsRasterFonts;
}

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

@ -97,6 +97,7 @@ protected:
PRInt32 mHeight;
nsRect mClientRect;
nsIDeviceContextSpec *mSpec;
PRBool mSupportsRasterFonts;
nsCOMPtr<nsIScreenManager> mScreenManager;
static PRUint32 sNumberOfScreens;
@ -117,6 +118,7 @@ public:
} mPrintState;
BOOL isPrintDC();
PRBool SupportsRasterFonts();
nsresult nsDeviceContextOS2::CreateFontAliasTable();
};

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

@ -181,7 +181,7 @@ InitGlobals(void)
ULONG numCP = ::WinQueryCpList((HAB)0, 0, NULL);
if (numCP > 0) {
ULONG * pCPList = (ULONG*)malloc(numCP*sizeof(ULONG));
if (WinQueryCpList( (HAB)0, numCP, pCPList)) {
if (::WinQueryCpList( (HAB)0, numCP, pCPList)) {
for (int i = 0;i<numCP ;i++ ) {
if (pCPList[i] == 1386) {
gCharSetInfo[11].mCodePage = 1386;
@ -674,17 +674,23 @@ HDC ps = NULL;
return NS_ERROR_OUT_OF_MEMORY;
// 3) Work out what our options are wrt. image/outline, prefer image.
BOOL bOutline = FALSE, bImage = FALSE;
long lFonts = 0; int i;
PFONTMETRICS pMetrics = getMetrics( lFonts, szFamily, ps);
BOOL bImage = FALSE;
for( i = 0; i < lFonts && !(bImage && bOutline); i++)
if( pMetrics[ i].fsDefn & FM_DEFN_OUTLINE) bOutline = TRUE;
else bImage = TRUE;
delete [] pMetrics;
if (mDeviceContext->SupportsRasterFonts()) {
long lFonts = 0; int i;
PFONTMETRICS pMetrics = getMetrics( lFonts, szFamily, ps);
if( !bImage) fh->fattrs.fsFontUse = FATTR_FONTUSE_OUTLINE |
FATTR_FONTUSE_TRANSFORMABLE;
for (i = 0 ; i < lFonts ; i++)
if (!(pMetrics [i].fsDefn & FM_DEFN_OUTLINE))
{
bImage = TRUE;
break;
}
delete [] pMetrics;
} /* endif */
if (!bImage)
fh->fattrs.fsFontUse = FATTR_FONTUSE_OUTLINE | FATTR_FONTUSE_TRANSFORMABLE;
// 4) Try to munge the face for italic & bold effects (could do better)
BOOL bBold = mFont->weight > NS_FONT_WEIGHT_NORMAL;
@ -695,8 +701,8 @@ HDC ps = NULL;
0,
bItalic ? FTYPE_ITALIC : 0 };
ULONG rc = GpiQueryFaceString( ps, szFamily, &fnd,
FACESIZE, fh->fattrs.szFacename);
ULONG rc = ::GpiQueryFaceString( ps, szFamily, &fnd,
FACESIZE, fh->fattrs.szFacename);
if( rc == GPI_ERROR)
{ // no real font, fake it
@ -762,8 +768,9 @@ HDC ps = NULL;
HDC hdc = GFX (::GpiQueryDevice (ps), HDC_ERROR);
long res[ 2];
::DevQueryCaps( hdc, CAPS_HORIZONTAL_FONT_RES, 2, res);
pMetrics = getMetrics( lFonts, fh->fattrs.szFacename, ps);
GFX (::DevQueryCaps( hdc, CAPS_HORIZONTAL_FONT_RES, 2, res), FALSE);
long lFonts = 0; int i;
PFONTMETRICS pMetrics = getMetrics( lFonts, fh->fattrs.szFacename, ps);
int curPoints = 0;
@ -861,6 +868,7 @@ HDC ps = NULL;
nsresult nsFontMetricsOS2::GetSpaceWidth(nscoord &aSpaceWidth)
{
aSpaceWidth = mSpaceWidth;
return NS_OK;
}
// Other metrics

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

@ -81,17 +81,9 @@ nsresult nsImageOS2::Init( PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,
// Work out size of bitmap to allocate
mRowBytes = RASWIDTH(aWidth,aDepth);
// mRowBytes = aWidth * aDepth;
// if( aDepth < 8)
// mRowBytes += 7;
// mRowBytes /= 8;
//
// // Make sure image width is 4byte aligned
// mRowBytes = (mRowBytes + 3) & ~0x3;
SetDecodedRect(0,0,0,0); //init
SetNaturalWidth(0);
SetNaturalHeight(0);
SetDecodedRect(0,0,0,0); //init
SetNaturalWidth(0);
SetNaturalHeight(0);
mImageBits = new PRUint8 [ aHeight * mRowBytes ];
@ -126,19 +118,17 @@ nsresult nsImageOS2::Init( PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,
{
if( aMaskRequirements == nsMaskRequirements_kNeeds1Bit)
{
mARowBytes = (aWidth + 7) / 8;
mAlphaDepth = 1;
}
else
{
NS_ASSERTION( nsMaskRequirements_kNeeds8Bit == aMaskRequirements,
"unexpected mask depth");
mARowBytes = aWidth;
mAlphaDepth = 8;
}
// 32-bit align each row
mARowBytes = (mARowBytes + 3) & ~0x3;
mARowBytes = RASWIDTH (aWidth, mAlphaDepth);
mAlphaBits = new PRUint8 [ aHeight * mARowBytes];
}
@ -261,7 +251,7 @@ nsresult nsImageOS2::Draw( nsIRenderingContext &aContext,
if( mAlphaDepth == 0)
{
// no transparency, just blit it
DrawBitmap( surf->mPS, 4, aptl, ROP_SRCCOPY, PR_FALSE);
DrawBitmap( surf->mPS, aptl, ROP_SRCCOPY, PR_FALSE);
}
else
{
@ -273,20 +263,14 @@ nsresult nsImageOS2::Draw( nsIRenderingContext &aContext,
// > out pels that are not transparent, and then OR the image onto
// > the target.
// >
// > Note that GPI *ignores* the colour in monochrome bitmaps when
// > blitting, but uses the actual pel values (indices into cmap)
// > to do things with. For 8bpp palette surface, the XP mask is
// > backwards, so we need a custom ROP.
// >
// > There's probably a really good reason why ROP_SRCAND does the
// > right thing in true colour...
long lRop = (mDeviceDepth <= 8) ? ROP_NOTSRCAND : ROP_SRCAND;
// > For monochrome bitmaps GPI replaces 1 with IMAGEBUNDLE foreground
// > color and 0 with background color.
// Apply mask to target, clear pels we will fill in from the image
DrawBitmap( surf->mPS, 4, aptl, lRop, PR_TRUE);
DrawBitmap( surf->mPS, aptl, ROP_NOTSRCAND, PR_TRUE);
// DrawBitmap( surf->mPS, aptl, ROP_SRCAND, PR_TRUE);
// Now combine image with target
DrawBitmap( surf->mPS, 4, aptl, ROP_SRCPAINT, PR_FALSE);
DrawBitmap( surf->mPS, aptl, ROP_SRCPAINT, PR_FALSE);
}
return NS_OK;
@ -342,34 +326,16 @@ void nsImageOS2::CreateBitmaps( nsDrawingSurfaceOS2 *surf)
}
}
void nsImageOS2::DrawBitmap( HPS hps, LONG lCount, PPOINTL pPoints,
LONG lRop, PRBool bIsMask)
void nsImageOS2::DrawBitmap (HPS hps, PPOINTL pPoints, LONG lRop, PRBool bIsMask)
{
HBITMAP hBmp = bIsMask ? mABitmap : mBitmap;
#if 0
if( hBmp)
if (bIsMask)
{
if( GPI_ERROR == GpiWCBitBlt( hps, hBmp, lCount, pPoints, lRop, BBO_OR))
PMERROR( "GpiWCBitBlt");
}
else
#endif
MASKBMPINFO MaskBitmapInfo (mInfo);
GFX (::GpiDrawBits (hps, mAlphaBits, MaskBitmapInfo, 4, pPoints, lRop, BBO_OR), GPI_ERROR);
} else
{
MASKBMPINFO *pMaskInfo = 0;
PBITMAPINFO2 pBmp2 = mInfo;
if( PR_TRUE == bIsMask)
{
pMaskInfo = new MASKBMPINFO( pBmp2);
pBmp2 = *pMaskInfo;
}
void *pBits = bIsMask ? mAlphaBits : mImageBits;
GFX (::GpiDrawBits (hps, pBits, pBmp2, lCount, pPoints, lRop, BBO_OR), GPI_ERROR);
delete pMaskInfo;
GFX (::GpiDrawBits (hps, mImageBits, mInfo, 4, pPoints, lRop, BBO_OR), GPI_ERROR);
}
}
@ -416,29 +382,37 @@ nsImageOS2::DrawTile(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
if( (aWidth <= tileWidth/2) || (aHeight <= tileHeight/2))
{
nsDrawingSurfaceOS2 *surf = (nsDrawingSurfaceOS2*) aSurface;
// Find the compatible device context and create a memory one
HDC hdcCompat = GFX (::GpiQueryDevice (surf->mPS), HDC_ERROR);
DEVOPENSTRUC dop = { 0, 0, 0, 0, 0 };
HDC mDC = ::DevOpenDC( (HAB)0, OD_MEMORY, "*", 5,
(PDEVOPENDATA) &dop, hdcCompat);
if( DEV_ERROR != mDC)
HDC MemDC = ::DevOpenDC( (HAB)0, OD_MEMORY, "*", 5,
(PDEVOPENDATA) &dop, hdcCompat);
if( DEV_ERROR != MemDC)
{
// create the PS
SIZEL sizel = { 0, 0 };
HPS mPS = GFX (::GpiCreatePS (0, mDC, &sizel,
PU_PELS | GPIT_MICRO | GPIA_ASSOC),
GPI_ERROR);
HPS MemPS = GFX (::GpiCreatePS (0, MemDC, &sizel,
PU_PELS | GPIT_MICRO | GPIA_ASSOC),
GPI_ERROR);
if( GPI_ERROR != mPS)
// Set image foreground and background colors. These are used in transparent images for blitting 1-bit masks.
IMAGEBUNDLE ib;
ib.lColor = GFX (::GpiQueryColorIndex (MemPS, 0, MK_RGB (255, 255, 255)), GPI_ALTERROR); // 1 in monochrome image maps to white
ib.lBackColor = GFX (::GpiQueryColorIndex (MemPS, 0, MK_RGB (0, 0, 0)), GPI_ALTERROR); // 0 in monochrome image maps to black
ib.usMixMode = FM_OVERPAINT;
ib.usBackMixMode = BM_OVERPAINT;
GFX (::GpiSetAttrs (MemPS, PRIM_IMAGE, IBB_COLOR | IBB_BACK_COLOR | IBB_MIX_MODE | IBB_BACK_MIX_MODE, 0, (PBUNDLE)&ib), FALSE);
if( GPI_ERROR != MemPS)
{
// now create a bitmap of the right size
HBITMAP hBmp;
HBITMAP hBmpMask = 0;
BITMAPINFOHEADER2 hdr = { 0 };
hdr.cbFix = sizeof( BITMAPINFOHEADER2);
// Maximum size of tiled area (could do this better)
LONG endWidth = aWidth * 2;
@ -454,33 +428,33 @@ nsImageOS2::DrawTile(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
hdr.cx = endWidth;
hdr.cy = endHeight;
hdr.cPlanes = 1;
// find bitdepth
LONG lBitCount = 0;
::DevQueryCaps( hdcCompat, CAPS_COLOR_BITCOUNT, 1, &lBitCount);
GFX (::DevQueryCaps( hdcCompat, CAPS_COLOR_BITCOUNT, 1, &lBitCount), FALSE);
hdr.cBitCount = (USHORT) lBitCount;
hBmp = GFX (::GpiCreateBitmap (mPS, &hdr, 0, 0, 0), GPI_ERROR);
hBmp = GFX (::GpiCreateBitmap (MemPS, &hdr, 0, 0, 0), GPI_ERROR);
if( GPI_ERROR != hBmp)
{
if( mAlphaDepth != 0)
if (mAlphaDepth != 0)
{
hBmpMask = GFX (::GpiCreateBitmap (mPS, &hdr, 0, 0, 0), GPI_ERROR);
hBmpMask = GFX (::GpiCreateBitmap (MemPS, &hdr, 0, 0, 0), GPI_ERROR);
}
nsRect trect( aX0, aY0, tileWidth, tileHeight);
RECTL rcl;
((nsRenderingContextOS2 &)aContext).NS2PM_ININ( trect, rcl); // !! !! !!
GFX (::GpiSetBitmap (mPS, hBmp), HBM_ERROR);
GFX (::GpiSetBitmap (MemPS, hBmp), HBM_ERROR);
PRInt32 notLoadedDY = 0;
if( mDecodedY2 < mInfo->cy)
{
// If bitmap not fully loaded, fill unloaded area
notLoadedDY = mInfo->cy - mDecodedY2;
RECTL rect = { 0, 0, aWidth, notLoadedDY };
::WinFillRect( mPS, &rect, CLR_BACKGROUND);
::WinFillRect( MemPS, &rect, CLR_BACKGROUND);
}
// Set up blit coord array
@ -488,16 +462,16 @@ nsImageOS2::DrawTile(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
{ aWidth - 1, aHeight - 1 },
{ 0, notLoadedDY },
{ mInfo->cx, mInfo->cy } };
// Draw bitmap once into temporary PS
DrawBitmap( mPS, 4, aptl, ROP_SRCCOPY, PR_FALSE);
DrawBitmap( MemPS, aptl, ROP_SRCCOPY, PR_FALSE);
if( hBmpMask)
{
GFX (::GpiSetBitmap (mPS, hBmpMask), HBM_ERROR);
DrawBitmap (mPS, 4, aptl, ROP_SRCCOPY, PR_TRUE);
GFX (::GpiSetBitmap (mPS, hBmp), HBM_ERROR);
}
GFX (::GpiSetBitmap (MemPS, hBmpMask), HBM_ERROR);
DrawBitmap (MemPS, aptl, ROP_SRCCOPY, PR_TRUE);
GFX (::GpiSetBitmap (MemPS, hBmp), HBM_ERROR);
}
// Copy bitmap horizontally, doubling each time
while( aWidth < tileWidth)
@ -506,14 +480,15 @@ nsImageOS2::DrawTile(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
{ 2*aWidth, aHeight },
{ 0, 0 },
{ aWidth, aHeight } };
GFX (::GpiBitBlt (MemPS, MemPS, 4, aptlCopy, ROP_SRCCOPY, 0L), GPI_ERROR);
GFX (::GpiBitBlt (mPS, mPS, 4, aptlCopy, ROP_SRCCOPY, 0L), GPI_ERROR);
if (hBmpMask)
if ( hBmpMask)
{
GFX (::GpiSetBitmap (mPS, hBmpMask), HBM_ERROR);
GFX (::GpiBitBlt (mPS, mPS, 4, aptlCopy, ROP_SRCCOPY, 0L), GPI_ERROR);
GFX (::GpiSetBitmap (mPS, hBmp), HBM_ERROR);
GFX (::GpiSetBitmap (MemPS, hBmpMask), HBM_ERROR);
GFX (::GpiBitBlt (MemPS, MemPS, 4, aptlCopy, ROP_SRCCOPY, 0L), GPI_ERROR);
GFX (::GpiSetBitmap (MemPS, hBmp), HBM_ERROR);
}
aWidth *= 2;
}
@ -524,57 +499,54 @@ nsImageOS2::DrawTile(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
{ aWidth, 2*aHeight },
{ 0, 0 },
{ aWidth, aHeight } };
GFX (::GpiBitBlt (MemPS, MemPS, 4, aptlCopy, ROP_SRCCOPY, 0L), GPI_ERROR);
GFX (::GpiBitBlt (mPS, mPS, 4, aptlCopy, ROP_SRCCOPY, 0L), GPI_ERROR);
if (hBmpMask)
if ( hBmpMask)
{
GFX (::GpiSetBitmap (mPS, hBmpMask), HBM_ERROR);
GFX (::GpiBitBlt (mPS, mPS, 4, aptlCopy, ROP_SRCCOPY, 0L), GPI_ERROR);
GFX (::GpiSetBitmap (mPS, hBmp), HBM_ERROR);
GFX (::GpiSetBitmap (MemPS, hBmpMask), HBM_ERROR);
GFX (::GpiBitBlt (MemPS, MemPS, 4, aptlCopy, ROP_SRCCOPY, 0L), GPI_ERROR);
GFX (::GpiSetBitmap (MemPS, hBmp), HBM_ERROR);
}
aHeight *= 2;
}
POINTL aptlTile[ 4] = { { rcl.xLeft, rcl.yBottom },
{ rcl.xRight + 1, rcl.yTop + 1 },
{ 0, aHeight - tileHeight },
{ tileWidth, aHeight } };
// Copy tiled bitmap into destination PS
if( mAlphaDepth == 0)
{
// no transparency, just blit it
GFX (::GpiBitBlt (surf->mPS, mPS, 4, aptlTile, ROP_SRCCOPY, 0L), GPI_ERROR);
GFX (::GpiBitBlt (surf->mPS, MemPS, 4, aptlTile, ROP_SRCCOPY, 0L), GPI_ERROR);
}
else
{
// For some reason, only ROP_NOTSRCAND seems to work here....
long lRop = (mDeviceDepth <= 8) ? ROP_NOTSRCAND : ROP_SRCAND;
// Apply mask to target, clear pels we will fill in from the image
GFX (::GpiSetBitmap (mPS, hBmpMask), HBM_ERROR);
GFX (::GpiBitBlt (surf->mPS, mPS, 4, aptlTile, lRop, 0L), GPI_ERROR);
GFX (::GpiSetBitmap (MemPS, hBmpMask), HBM_ERROR);
GFX (::GpiBitBlt (surf->mPS, MemPS, 4, aptlTile, ROP_NOTSRCAND, 0L), GPI_ERROR);
// Now combine image with target
GFX (::GpiSetBitmap (mPS, hBmp), HBM_ERROR);
GFX (::GpiBitBlt (surf->mPS, mPS, 4, aptlTile, ROP_SRCPAINT, 0L), GPI_ERROR);
GFX (::GpiSetBitmap (MemPS, hBmp), HBM_ERROR);
GFX (::GpiBitBlt (surf->mPS, MemPS, 4, aptlTile, ROP_SRCPAINT, 0L), GPI_ERROR);
}
// Tiling successful
didTile = PR_TRUE;
// Must deselect bitmap from PS before freeing bitmap and PS.
GFX (::GpiSetBitmap (mPS, NULLHANDLE), HBM_ERROR);
GFX (::GpiSetBitmap (MemPS, NULLHANDLE), HBM_ERROR);
GFX (::GpiDeleteBitmap (hBmp), FALSE);
if( hBmpMask)
if ( hBmpMask)
{
GFX (::GpiDeleteBitmap (hBmpMask), FALSE);
}
}
GFX (::GpiDestroyPS (mPS), FALSE);
GFX (::GpiDestroyPS (MemPS), FALSE);
}
DevCloseDC( mDC);
::DevCloseDC (MemDC);
}
}

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

@ -208,7 +208,7 @@ public:
PRInt16 mAlphaLevel; // an alpha level every pixel uses
void CreateBitmaps( nsDrawingSurfaceOS2 *surf);
void DrawBitmap( HPS hps, LONG cPts, PPOINTL pPts, LONG lRop, PRBool bMsk);
void DrawBitmap( HPS hps, PPOINTL pPts, LONG lRop, PRBool bMsk);
};
#endif

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

@ -53,8 +53,6 @@
#include "libimg.h"
#include "prprf.h"
#define RGB_PRINTING 1 // Makes most things work
// helper clip region functions - defined at the bottom of this file.
LONG OS2_CombineClipRegion( HPS hps, HRGN hrgnCombine, LONG lMode);
HRGN OS2_CopyClipRegion( HPS hps);
@ -321,19 +319,23 @@ nsresult nsRenderingContextOS2::CommonInit()
// Select the palette in the background
GFX (::GpiSelectPalette (mSurface->mPS, (HPAL)palInfo.palette), PAL_ERROR);
::WinRealizePalette((HWND)mDCOwner->GetNativeData(NS_NATIVE_WINDOW),mSurface->mPS, &cclr);
if (mDCOwner) {
::WinRealizePalette((HWND)mDCOwner->GetNativeData(NS_NATIVE_WINDOW),mSurface->mPS, &cclr);
} /* endif */
}
#ifndef RGB_PRINTING
else if (!palInfo.isPaletteDevice && palInfo.palette) {
GFX (::GpiCreateLogColorTable (mSurface->mPS, LCOL_RESET, LCOLF_CONSECRGB,
0, palInfo.sizePalette, (PLONG)palInfo.palette),
FALSE);
}
#endif
else
{
GFX (::GpiCreateLogColorTable (mSurface->mPS, 0, LCOLF_RGB, 0, 0, 0), FALSE);
}
// Set image foreground and background colors. These are used in transparent images for blitting 1-bit masks.
IMAGEBUNDLE ib;
ib.lColor = GFX (::GpiQueryColorIndex (mSurface->mPS, 0, MK_RGB (0, 0, 0)), GPI_ALTERROR); // 1 in monochrome image maps to white
ib.lBackColor = GFX (::GpiQueryColorIndex (mSurface->mPS, 0, MK_RGB (255, 255, 255)), GPI_ALTERROR); // 0 in monochrome image maps to black
ib.usMixMode = FM_OVERPAINT;
ib.usBackMixMode = BM_OVERPAINT;
GFX (::GpiSetAttrs (mSurface->mPS, PRIM_IMAGE, IBB_COLOR | IBB_BACK_COLOR | IBB_MIX_MODE | IBB_BACK_MIX_MODE, 0, (PBUNDLE)&ib), FALSE);
return NS_OK;
}
@ -356,15 +358,10 @@ nsresult nsRenderingContextOS2::SelectOffScreenDrawingSurface( nsDrawingSurface
ULONG cclr;
// Select the palette in the background
GFX (::GpiSelectPalette (mSurface->mPS, (HPAL)palInfo.palette), PAL_ERROR);
::WinRealizePalette((HWND)mDCOwner->GetNativeData(NS_NATIVE_WINDOW),mSurface->mPS, &cclr);
if (mDCOwner) {
::WinRealizePalette((HWND)mDCOwner->GetNativeData(NS_NATIVE_WINDOW),mSurface->mPS, &cclr);
} /* endif */
}
#ifndef RGB_PRINTING
else if (!palInfo.isPaletteDevice && palInfo.palette) {
GFX (::GpiCreateLogColorTable (mSurface->mPS, LCOL_RESET, LCOLF_CONSECRGB,
0, palInfo.sizePalette, (PLONG)palInfo.palette),
FALSE);
}
#endif
else
{
GFX (::GpiCreateLogColorTable (mSurface->mPS, 0, LCOLF_RGB, 0, 0, 0), FALSE);
@ -377,6 +374,14 @@ nsresult nsRenderingContextOS2::SelectOffScreenDrawingSurface( nsDrawingSurface
rc = NS_OK;
}
// Set image foreground and background colors. These are used in transparent images for blitting 1-bit masks.
IMAGEBUNDLE ib;
ib.lColor = GFX (::GpiQueryColorIndex (mSurface->mPS, 0, MK_RGB (255, 255, 255)), GPI_ALTERROR); // 1 in monochrome image maps to white
ib.lBackColor = GFX (::GpiQueryColorIndex (mSurface->mPS, 0, MK_RGB (0, 0, 0)), GPI_ALTERROR); // 0 in monochrome image maps to black
ib.usMixMode = FM_OVERPAINT;
ib.usBackMixMode = BM_OVERPAINT;
GFX (::GpiSetAttrs (mSurface->mPS, PRIM_IMAGE, IBB_COLOR | IBB_BACK_COLOR | IBB_MIX_MODE | IBB_BACK_MIX_MODE, 0, (PBUNDLE)&ib), FALSE);
// need to force a state refresh because the offscreen is something of
// an unknown quantity.
SetupDrawingColor( TRUE);
@ -906,8 +911,8 @@ void nsRenderingContextOS2::SetupDrawingColor( BOOL bForce)
if (((nsDeviceContextOS2 *) mContext)->mPrintDC )
{
areaBundle.lBackColor = CLR_BACKGROUND;
lineBundle.lBackColor = CLR_BACKGROUND;
areaBundle.lBackColor = GFX (::GpiQueryColorIndex (mSurface->mPS, 0, CLR_BACKGROUND), GPI_ALTERROR);
lineBundle.lBackColor = GFX (::GpiQueryColorIndex (mSurface->mPS, 0, CLR_BACKGROUND), GPI_ALTERROR);
areaBundle.usMixMode = FM_OVERPAINT;
areaBundle.usBackMixMode = BM_OVERPAINT;