Bug 107341: xlib/xprint xcleanup. Checking in for gisburn.

r=biesi, r=pocemit, sr=blizzard
This commit is contained in:
rjesup%wgate.com 2001-11-03 01:39:11 +00:00
parent a83ac5dc9c
commit 72854e9840
8 changed files with 14 additions and 308 deletions

View File

@ -41,9 +41,8 @@
#ifndef nsDeviceContextXlib_h__
#define nsDeviceContextXlib_h__
#include "nsDeviceContext.h"
#include "nsDeviceContextX.h"
#include "nsRenderingContextXlib.h"
#include "xlibrgb.h"
class nsDeviceContextXlib : public nsDeviceContextX
{

View File

@ -59,9 +59,11 @@
#include "nsReadableUtils.h"
#include "nsAWritableString.h"
#include "nsXPIDLString.h"
#include <stdlib.h>
#include <X11/Xatom.h>
#ifdef USE_XPRINT
#include <X11/extensions/Print.h>
#endif /* USE_XPRINT */
#include "xlibrgb.h"
/* #define NOISY_FONTS 1 */
@ -614,14 +616,11 @@ FreeStretch(nsFontStretchXlib* aStretch)
{
PR_smprintf_free(aStretch->mScalable);
PRInt32 count;
while ((count = aStretch->mScaledFonts.Count())) {
// go backwards to keep nsVoidArray from memmoving everything each time
count--; // nsVoidArray is zero based
for (PRInt32 count = aStretch->mScaledFonts.Count()-1; count >= 0; --count) {
nsFontXlib *font = (nsFontXlib*)aStretch->mScaledFonts.ElementAt(count);
aStretch->mScaledFonts.RemoveElementAt(count);
if (font) delete font;
}
// aStretch->mScaledFonts.Clear(); handled by delete of aStretch
for (int i = 0; i < aStretch->mSizesCount; i++) {
delete aStretch->mSizes[i];

View File

@ -44,21 +44,15 @@
#include "nsICharRepresentable.h"
#include "nsCompressedCharMap.h"
#include "nsIDeviceContext.h"
#include "nsDeviceContextX.h"
#include "nsIFontMetrics.h"
#include "nsIFontEnumerator.h"
#include "nsCRT.h"
#include "nsCOMPtr.h"
#include "nsDrawingSurfaceXlib.h"
#ifdef USE_XPRINT
#include "nsDeviceContextXP.h"
#endif /* USE_XPRINT */
#include "nsFont.h"
#include "nsRenderingContextXlib.h"
#include "nsString.h"
#include "nsUnitConversion.h"
#include "xlibrgb.h"
#undef FONT_HAS_GLYPH
#define FONT_HAS_GLYPH(map, char) IS_REPRESENTABLE(map, char)

View File

@ -93,17 +93,7 @@ GraphicsState::~GraphicsState()
NS_IF_RELEASE(mFontMetrics);
}
#ifdef USE_XPRINT
nsRenderingContextXp::nsRenderingContextXp()
: nsRenderingContextXlib(),
mPrintContext(nsnull)
{
}
nsRenderingContextXp::~nsRenderingContextXp()
{
}
#endif /* USE_XPRINT */
nsRenderingContextXlib::nsRenderingContextXlib()
{
@ -164,50 +154,6 @@ nsRenderingContextXlib::Shutdown()
return NS_OK;
}
#ifdef USE_XPRINT
NS_IMETHODIMP
nsRenderingContextXp::Init(nsIDeviceContext* aContext)
{
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::Init(nsIDeviceContext *)\n"));
mContext = do_QueryInterface(aContext);
NS_ASSERTION(nsnull != mContext, "Device context is null.");
if (mContext) {
nsIDeviceContext *dc = mContext;
NS_STATIC_CAST(nsDeviceContextXp *,dc)->GetPrintContext(mPrintContext);
}
NS_ASSERTION(nsnull != mPrintContext, "mPrintContext is null.");
mPrintContext->GetXlibRgbHandle(mXlibRgbHandle);
mDisplay = xxlib_rgb_get_display(mXlibRgbHandle);
mScreen = xxlib_rgb_get_screen(mXlibRgbHandle);
mVisual = xxlib_rgb_get_visual(mXlibRgbHandle);
mDepth = xxlib_rgb_get_depth(mXlibRgbHandle);
/* A printer usually does not support things like multiple drawing surfaces
* (nor "offscreen" drawing surfaces... would be quite difficult to
* implement =:-) ...
* We just feed the nsXPContext object here directly - this is the only
* "surface" the printer can "draw" on ...
*/
Drawable drawable; mPrintContext->GetDrawable(drawable);
UpdateGC(drawable); // fill mGC
mPrintContext->SetGC(mGC);
mRenderingSurface = mPrintContext;
return CommonInit();
}
NS_IMETHODIMP nsRenderingContextXp::Init(nsIDeviceContext* aContext, nsIWidget *aWidget)
{
return NS_OK;
}
NS_IMETHODIMP nsRenderingContextXp::Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface)
{
return NS_OK;
}
#endif /* USE_XPRINT */
NS_IMETHODIMP
nsRenderingContextXlib::Init(nsIDeviceContext* aContext, nsIWidget *aWindow)
@ -317,29 +263,6 @@ nsRenderingContextXlib::GetDeviceContext(nsIDeviceContext *&aContext)
return NS_OK;
}
#ifdef USE_XPRINT
NS_IMETHODIMP
nsRenderingContextXp::LockDrawingSurface(PRInt32 aX, PRInt32 aY,
PRUint32 aWidth, PRUint32 aHeight,
void **aBits,
PRInt32 *aStride,
PRInt32 *aWidthBytes,
PRUint32 aFlags)
{
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::LockDrawingSurface()\n"));
PushState();
return NS_OK;
}
NS_IMETHODIMP
nsRenderingContextXp::UnlockDrawingSurface(void)
{
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::UnlockDrawingSurface()\n"));
PRBool clipstate;
PopState(clipstate);
return NS_OK;
}
#endif /* USE_XPRINT */
NS_IMETHODIMP
nsRenderingContextXlib::LockDrawingSurface(PRInt32 aX, PRInt32 aY,
@ -365,23 +288,6 @@ nsRenderingContextXlib::UnlockDrawingSurface(void)
return NS_OK;
}
#ifdef USE_XPRINT
NS_IMETHODIMP
nsRenderingContextXp::SelectOffScreenDrawingSurface(nsDrawingSurface aSurface)
{
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::SelectOffScreenDrawingSurface()\n"));
return NS_OK;
}
NS_IMETHODIMP
nsRenderingContextXp::GetDrawingSurface(nsDrawingSurface *aSurface)
{
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::GetDrawingSurface()\n"));
*aSurface = nsnull;
return NS_OK;
}
#endif /* USE_XPRINT */
NS_IMETHODIMP
nsRenderingContextXlib::SelectOffScreenDrawingSurface(nsDrawingSurface aSurface)
{
@ -760,16 +666,6 @@ nsRenderingContextXlib::GetCurrentTransform(nsTransform2D *&aTransform)
return NS_OK;
}
#ifdef USE_XPRINT
NS_IMETHODIMP
nsRenderingContextXp::CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface)
{
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::CreateDrawingSurface()\n"));
aSurface = nsnull;
return NS_OK;
}
#endif /* USE_XPRINT */
NS_IMETHODIMP
nsRenderingContextXlib::CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface)
{
@ -1658,20 +1554,6 @@ nsRenderingContextXlib::DrawImage(nsIImage *aImage, nscoord aX, nscoord aY,
return DrawImage(aImage, tr);
}
#ifdef USE_XPRINT
NS_IMETHODIMP
nsRenderingContextXp::DrawImage(nsIImage *aImage, const nsRect& aRect)
{
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawImage()\n"));
nsRect tr;
tr = aRect;
mTranMatrix->TransformCoord(&tr.x, &tr.y, &tr.width, &tr.height);
UpdateGC();
return mPrintContext->DrawImage(mGC, aImage, tr.x, tr.y, tr.width, tr.height);
}
#endif /* USE_XPRINT */
NS_IMETHODIMP
nsRenderingContextXlib::DrawImage(nsIImage *aImage, const nsRect& aRect)
{
@ -1684,32 +1566,6 @@ nsRenderingContextXlib::DrawImage(nsIImage *aImage, const nsRect& aRect)
return aImage->Draw(*this, mRenderingSurface, tr.x, tr.y, tr.width, tr.height);
}
#ifdef USE_XPRINT
NS_IMETHODIMP
nsRenderingContextXp::DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect)
{
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawImage()\n"));
nsRect sr,dr;
sr = aSRect;
mTranMatrix->TransformCoord(&sr.x, &sr.y,
&sr.width, &sr.height);
sr.x = aSRect.x;
sr.y = aSRect.y;
mTranMatrix->TransformNoXLateCoord(&sr.x, &sr.y);
dr = aDRect;
mTranMatrix->TransformCoord(&dr.x, &dr.y,
&dr.width, &dr.height);
UpdateGC();
return mPrintContext->DrawImage(mGC, aImage,
sr.x, sr.y,
sr.width, sr.height,
dr.x, dr.y,
dr.width, dr.height);
}
#endif /* USE_XPRINT */
NS_IMETHODIMP
nsRenderingContextXlib::DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect)
{
@ -1748,86 +1604,6 @@ nsRenderingContextXlib::DrawTile(nsIImage *aImage,nscoord aX0,nscoord aY0,nscoor
}
#endif
#ifdef USE_XPRINT
/* [noscript] void drawImage (in imgIContainer aImage, [const] in nsRect aSrcRect, [const] in nsPoint aDestPoint); */
NS_IMETHODIMP nsRenderingContextXp::DrawImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint)
{
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawImage()\n"));
nsPoint pt;
nsRect sr;
pt = *aDestPoint;
mTranMatrix->TransformCoord(&pt.x, &pt.y);
sr = *aSrcRect;
mTranMatrix->TransformNoXLateCoord(&sr.x, &sr.y);
nsCOMPtr<gfxIImageFrame> iframe;
aImage->GetCurrentFrame(getter_AddRefs(iframe));
if (!iframe)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIImage> img(do_GetInterface(iframe));
if (!img)
return NS_ERROR_FAILURE;
UpdateGC();
// doesn't it seem like we should use more of the params here?
// img->Draw(*this, surface, sr.x, sr.y, sr.width, sr.height,
// pt.x + sr.x, pt.y + sr.y, sr.width, sr.height);
return mPrintContext->DrawImage(mGC, img, pt.x, pt.y, sr.width, sr.height);
}
/* [noscript] void drawScaledImage (in imgIContainer aImage, [const] in nsRect aSrcRect, [const] in nsRect aDestRect); */
NS_IMETHODIMP nsRenderingContextXp::DrawScaledImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect)
{
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawScaledImage()\n"));
nsRect dr;
dr = *aDestRect;
mTranMatrix->TransformCoord(&dr.x, &dr.y, &dr.width, &dr.height);
nsCOMPtr<gfxIImageFrame> iframe;
aImage->GetCurrentFrame(getter_AddRefs(iframe));
if (!iframe)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIImage> img(do_GetInterface(iframe));
if (!img)
return NS_ERROR_FAILURE;
// doesn't it seem like we should use more of the params here?
// img->Draw(*this, surface, sr.x, sr.y, sr.width, sr.height, dr.x, dr.y, dr.width, dr.height);
nsRect sr;
sr = *aSrcRect;
mTranMatrix->TransformCoord(&sr.x, &sr.y, &sr.width, &sr.height);
sr.x = aSrcRect->x;
sr.y = aSrcRect->y;
mTranMatrix->TransformNoXLateCoord(&sr.x, &sr.y);
UpdateGC();
return mPrintContext->DrawImage(mGC, img,
sr.x, sr.y,
sr.width, sr.height,
dr.x, dr.y,
dr.width, dr.height);
}
#endif /* USE_XPRINT */
#ifdef USE_XPRINT
NS_IMETHODIMP
nsRenderingContextXp::CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
const nsRect &aDestBounds, PRUint32 aCopyFlags)
{
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::CopyOffScreenBits()\n"));
NS_NOTREACHED("nsRenderingContextXlib::CopyOffScreenBits() not yet implemented");
return NS_OK;
}
#endif /* USE_XPRINT */
NS_IMETHODIMP
nsRenderingContextXlib::CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
const nsRect &aDestBounds, PRUint32 aCopyFlags)

View File

@ -53,10 +53,7 @@
#include "nsIViewManager.h"
#include "nsIWidget.h"
#include "nsRect.h"
#ifdef USE_XPRINT
#include "nsXPrintContext.h"
#endif /* USE_XPRINT */
#include "nsDeviceContext.h"
#include "nsDeviceContextX.h"
#include "nsImageXlib.h"
#include "nsVoidArray.h"
#include "nsDrawingSurfaceXlib.h"
@ -69,20 +66,7 @@
class GraphicsState;
class nsFontXlib;
class nsDeviceContextX : public DeviceContextImpl
{
public:
nsDeviceContextX()
: DeviceContextImpl()
{
}
virtual ~nsDeviceContextX() {}
NS_IMETHOD GetXlibRgbHandle(XlibRgbHandle *&aHandle) = 0;
};
/* Note |nsRenderingContextXp| may override some of these methods here */
class nsRenderingContextXlib : public nsRenderingContextImpl
{
public:
@ -292,47 +276,6 @@ protected:
static nsGCCacheXlib *gcCache;
};
#ifdef USE_XPRINT
/* Rendering context class to match the special needs of Xprint (X11 print
* system). Nearly identical to nsRenderingContextXlib - except two details:
* - "offscreen" drawing surfaces are not supported by printers, therefore
* we "disable" those functions here by overriding them with empty versions.
* - images are handeled by nsXPrintContext class instead of nsImageXlib
*/
class nsRenderingContextXp : public nsRenderingContextXlib
{
public:
nsRenderingContextXp();
virtual ~nsRenderingContextXp();
NS_IMETHOD Init(nsIDeviceContext* aContext);
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIWidget *aWindow);
NS_IMETHOD Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface);
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 CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface);
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aRect);
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect);
NS_IMETHOD DrawImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint);
NS_IMETHOD DrawScaledImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect);
NS_IMETHOD CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
const nsRect &aDestBounds, PRUint32 aCopyFlags);
protected:
nsXPrintContext *mPrintContext; /* identical to |mRenderingSurface|
* (except the different type)
*/
};
#endif /* USE_XPRINT */
#endif /* !nsRenderingContextXlib_h___ */

View File

@ -52,6 +52,7 @@ CSRCS = \
xprintutil_printtofile.c \
$(NULL)
# nsDrawingSurfaceXlib only required for staticbuild
XLIB_LCPPSRCS = \
nsDrawingSurfaceXlib.cpp \
nsFontMetricsXlib.cpp \
@ -60,12 +61,12 @@ XLIB_LCPPSRCS = \
nsGCCache.cpp \
$(NULL)
# nsDrawingSurfaceXlib only required for staticbuild
CPPSRCS = \
$(XLIB_LCPPSRCS) \
nsDeviceContextXP.cpp \
nsGfxFactoryXP.cpp \
nsXPrintContext.cpp \
nsRenderingContextXp.cpp \
$(NULL)
EXPORTS = \

View File

@ -39,7 +39,7 @@
* ***** END LICENSE BLOCK ***** */
#include "nsDeviceContextXP.h"
#include "nsRenderingContextXlib.h"
#include "nsRenderingContextXp.h"
#include "nsFontMetricsXlib.h"
#include "nsIDeviceContext.h"
#include "nsIDeviceContextSpecXPrint.h"

View File

@ -40,16 +40,10 @@
#ifndef nsDeviceContextXp_h___
#define nsDeviceContextXp_h___
#include <X11/Xlib.h>
#include "nsDeviceContext.h"
#include "nsUnitConversion.h"
#include "nsIWidget.h"
#include "nsIView.h"
#include "nsRenderingContextXlib.h"
#include "nsVoidArray.h"
#include "nsDeviceContextX.h"
#include "nsRenderingContextXp.h"
#include "nsIDeviceContextXPrint.h"
#include "nsXPrintContext.h"
#include "nsISupportsArray.h"
class nsDeviceContextXp : public nsDeviceContextX,
public nsIDeviceContextXp