diff --git a/gfx/src/os2/nsImageOS2.cpp b/gfx/src/os2/nsImageOS2.cpp index 73715ccb758..4063d0fde86 100644 --- a/gfx/src/os2/nsImageOS2.cpp +++ b/gfx/src/os2/nsImageOS2.cpp @@ -452,8 +452,14 @@ nsImageOS2::DrawTile(nsIRenderingContext &aContext, nsDrawingSurface aSurface, // Set image foreground and background colors. These are used in transparent images for blitting 1-bit masks. // To invert colors on ROP_SRCAND we map 1 to black and 0 to white IMAGEBUNDLE ib; - ib.lColor = GFX (::GpiQueryColorIndex (MemPS, 0, MK_RGB (0, 0, 0)), GPI_ALTERROR); // map 1 in mask to 0x000000 (black) in destination - ib.lBackColor = GFX (::GpiQueryColorIndex (MemPS, 0, MK_RGB (255, 255, 255)), GPI_ALTERROR); // map 0 in mask to 0xFFFFFF (white) in destination + ib.lColor = GFX (::GpiQueryColorIndex (MemPS, 0, MK_RGB (0x00, 0x00, 0x00)), GPI_ALTERROR); // CLR_BLACK + if (ib.lColor == -1) { + ib.lColor = MK_RGB (0x00, 0x00, 0x00); + } + ib.lBackColor = GFX (::GpiQueryColorIndex (MemPS, 0, MK_RGB (0xFF, 0xFF, 0xFF)), GPI_ALTERROR); // CLR_WHITE + if (ib.lBackColor == -1) { + ib.lBackColor = MK_RGB (0xFF, 0xFF, 0xFF); + } 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); diff --git a/gfx/src/os2/nsRenderingContextOS2.cpp b/gfx/src/os2/nsRenderingContextOS2.cpp index 09b7234be8d..5c8fc34db49 100644 --- a/gfx/src/os2/nsRenderingContextOS2.cpp +++ b/gfx/src/os2/nsRenderingContextOS2.cpp @@ -314,6 +314,12 @@ nsresult nsRenderingContextOS2::CommonInit() nsPaletteInfo palInfo; mContext->GetPaletteInfo(palInfo); + // Set image foreground and background colors. These are used in transparent images for blitting 1-bit masks. + // To invert colors on ROP_SRCAND we map 1 to black and 0 to white + // map 1 in mask to 0x000000 (black) in destination + // map 0 in mask to 0xFFFFFF (white) in destination + IMAGEBUNDLE ib; + if (palInfo.isPaletteDevice && palInfo.palette) { ULONG cclr; @@ -323,17 +329,16 @@ nsresult nsRenderingContextOS2::CommonInit() if (mDCOwner) { ::WinRealizePalette((HWND)mDCOwner->GetNativeData(NS_NATIVE_WINDOW),mSurface->mPS, &cclr); } /* endif */ + ib.lColor = GFX (::GpiQueryColorIndex (mSurface->mPS, 0, MK_RGB (0x00, 0x00, 0x00)), GPI_ALTERROR); // CLR_BLACK + ib.lBackColor = GFX (::GpiQueryColorIndex (mSurface->mPS, 0, MK_RGB (0xFF, 0xFF, 0xFF)), GPI_ALTERROR); // CLR_WHITE } else { GFX (::GpiCreateLogColorTable (mSurface->mPS, 0, LCOLF_RGB, 0, 0, 0), FALSE); + ib.lColor = MK_RGB (0x00, 0x00, 0x00); // CLR_BLACK + ib.lBackColor = MK_RGB (0xFF, 0xFF, 0xFF); // CLR_WHITE } - // Set image foreground and background colors. These are used in transparent images for blitting 1-bit masks. - // To invert colors on ROP_SRCAND we map 1 to black and 0 to white - IMAGEBUNDLE ib; - ib.lColor = GFX (::GpiQueryColorIndex (mSurface->mPS, 0, MK_RGB (0, 0, 0)), GPI_ALTERROR); // map 1 in mask to 0x000000 (black) in destination - ib.lBackColor = GFX (::GpiQueryColorIndex (mSurface->mPS, 0, MK_RGB (255, 255, 255)), GPI_ALTERROR); // map 0 in mask to 0xFFFFFF (white) in destination 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);