Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Protected Attributes
nsRenderingContextXp Class Reference

#include <nsRenderingContextXp.h>

Inheritance diagram for nsRenderingContextXp:
Inheritance graph
[legend]
Collaboration diagram for nsRenderingContextXp:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsRenderingContextXp ()
virtual ~nsRenderingContextXp ()
NS_IMETHOD Init (nsIDeviceContext *aContext)
NS_IMETHOD Init (nsIDeviceContext *aContext, nsIWidget *aWindow)
 Initialize the RenderingContext.
NS_IMETHOD Init (nsIDeviceContext *aContext, nsIDrawingSurface *aSurface)
 Initialize the RenderingContext.
NS_IMETHOD LockDrawingSurface (PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight, void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes, PRUint32 aFlags)
 Lock a rect of the drawing surface associated with the rendering context.
NS_IMETHOD UnlockDrawingSurface (void)
 Unlock a rect of the drawing surface associated with the rendering context.
NS_IMETHOD DrawImage (imgIContainer *aImage, const nsRect &aSrcRect, const nsRect &aDestRect)
 Draw a portion of an image, scaling it to fit within a specified rect.
NS_IMETHOD DrawTile (imgIContainer *aImage, nscoord aXImageStart, nscoord aYImageStart, const nsRect *aTargetRect)
NS_IMETHOD RenderEPS (const nsRect &aRect, FILE *aDataFile)
 Render an encapsulated postscript object onto the current rendering surface.
NS_IMETHOD Reset (void)
 Reset the rendering context.
NS_IMETHOD GetDeviceContext (nsIDeviceContext *&aContext)
 Get the DeviceContext that this RenderingContext was initialized with.
NS_IMETHOD SelectOffScreenDrawingSurface (nsIDrawingSurface *aSurface)
 Selects an offscreen drawing surface into the RenderingContext to draw to.
NS_IMETHOD GetDrawingSurface (nsIDrawingSurface **aSurface)
 Get the currently selected drawing surface.
NS_IMETHOD GetHints (PRUint32 &aResult)
 Returns in aResult any rendering hints that the context has.
NS_IMETHOD PushState (void)
 Save a graphical state onto a stack.
NS_IMETHOD PopState (void)
 Get and and set RenderingContext to this graphical state.
NS_IMETHOD IsVisibleRect (const nsRect &aRect, PRBool &aVisible)
 Tells if a given rectangle is visible within the rendering context.
NS_IMETHOD SetClipRect (const nsRect &aRect, nsClipCombine aCombine)
 Sets the clipping for the RenderingContext to the passed in rectangle.
NS_IMETHOD GetClipRect (nsRect &aRect, PRBool &aClipValid)
 Gets the bounds of the clip region of the RenderingContext.
NS_IMETHOD SetClipRegion (const nsIRegion &aRegion, nsClipCombine aCombine)
 Sets the clipping for the RenderingContext to the passed in region.
NS_IMETHOD CopyClipRegion (nsIRegion &aRegion)
 Gets a copy of the current clipping region for the RenderingContext The region is in device coordinates!
NS_IMETHOD GetClipRegion (nsIRegion **aRegion)
 Gets the current clipping region for the RenderingContext The region is in device coordinates!
NS_IMETHOD SetLineStyle (nsLineStyle aLineStyle)
 Sets the line style for the RenderingContext.
NS_IMETHOD GetLineStyle (nsLineStyle &aLineStyle)
 Gets the line style for the RenderingContext.
NS_IMETHOD SetColor (nscolor aColor)
 Sets the forground color for the RenderingContext.
NS_IMETHOD GetColor (nscolor &aColor) const
 Get the forground color for the RenderingContext.
NS_IMETHOD SetFont (const nsFont &aFont, nsIAtom *aLangGroup)
 Sets the font for the RenderingContext.
NS_IMETHOD SetFont (nsIFontMetrics *aFontMetrics)
 Sets the font for the RenderingContext.
NS_IMETHOD GetFontMetrics (nsIFontMetrics *&aFontMetrics)
 Get the current fontmetrics for the RenderingContext.
NS_IMETHOD Translate (nscoord aX, nscoord aY)
 Add in a translate to the RenderingContext's transformation matrix.
NS_IMETHOD Scale (float aSx, float aSy)
 Add in a scale to the RenderingContext's transformation matrix.
NS_IMETHOD GetCurrentTransform (nsTransform2D *&aTransform)
 Get the current transformation matrix for the RenderingContext.
NS_IMETHOD CreateDrawingSurface (const nsRect &aBounds, PRUint32 aSurfFlags, nsIDrawingSurface *&aSurface)
 Create an offscreen drawing surface compatible with this RenderingContext.
NS_IMETHOD DestroyDrawingSurface (nsIDrawingSurface *aDS)
 Destroy a drawing surface created by CreateDrawingSurface()
NS_IMETHOD DrawLine (nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1)
 Draw a line.
NS_IMETHOD DrawPolyline (const nsPoint aPoints[], PRInt32 aNumPoints)
 Draw a polyline.
NS_IMETHOD DrawRect (const nsRect &aRect)
 Draw a rectangle.
NS_IMETHOD DrawRect (nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
 Draw a rectangle.
NS_IMETHOD FillRect (const nsRect &aRect)
 Fill a rectangle in the current foreground color.
NS_IMETHOD FillRect (nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
 Fill a rectangle in the current foreground color.
NS_IMETHOD InvertRect (const nsRect &aRect)
 XOR Invert a rectangle in the current foreground color.
NS_IMETHOD InvertRect (nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
 XOR Invert a rectangle in the current foreground color.
NS_IMETHOD DrawPolygon (const nsPoint aPoints[], PRInt32 aNumPoints)
 Draw a poly in the current foreground color.
NS_IMETHOD FillPolygon (const nsPoint aPoints[], PRInt32 aNumPoints)
 Fill a poly in the current foreground color.
NS_IMETHOD DrawEllipse (const nsRect &aRect)
 Draw an ellipse in the current foreground color.
NS_IMETHOD DrawEllipse (nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
 Draw an ellipse in the current foreground color.
NS_IMETHOD FillEllipse (const nsRect &aRect)
 Fill an ellipse in the current foreground color.
NS_IMETHOD FillEllipse (nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
 Fill an ellipse in the current foreground color.
NS_IMETHOD DrawArc (const nsRect &aRect, float aStartAngle, float aEndAngle)
 Draw an arc in the current forground color.
NS_IMETHOD DrawArc (nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, float aStartAngle, float aEndAngle)
 Draw an arc in the current forground color.
NS_IMETHOD FillArc (const nsRect &aRect, float aStartAngle, float aEndAngle)
 Fill an arc in the current forground color.
NS_IMETHOD FillArc (nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, float aStartAngle, float aEndAngle)
 Fill an arc in the current forground color.
NS_IMETHOD GetWidth (char aC, nscoord &aWidth)
 Returns the width (in app units) of an 8-bit character If no font has been Set, the results are undefined.
NS_IMETHOD GetWidth (PRUnichar aC, nscoord &aWidth, PRInt32 *aFontID)
 Returns the width (in app units) of a unicode character If no font has been Set, the results are undefined.
NS_IMETHOD GetWidth (const nsString &aString, nscoord &aWidth, PRInt32 *aFontID)
 Returns the width (in app units) of an nsString If no font has been Set, the results are undefined.
NS_IMETHOD GetWidth (const char *aString, nscoord &aWidth)
 Returns the width (in app units) of an 8-bit character string If no font has been Set, the results are undefined.
NS_IMETHOD GetWidth (const char *aString, PRUint32 aLength, nscoord &aWidth)
 Returns the width (in app units) of an 8-bit character string If no font has been Set, the results are undefined.
NS_IMETHOD GetWidth (const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth, PRInt32 *aFontID)
 Returns the width (in app units) of a Unicode character string If no font has been Set, the results are undefined.
NS_IMETHOD DrawString (const char *aString, PRUint32 aLength, nscoord aX, nscoord aY, const nscoord *aSpacing)
 Draw a string in the RenderingContext.
NS_IMETHOD DrawString (const PRUnichar *aString, PRUint32 aLength, nscoord aX, nscoord aY, PRInt32 aFontID, const nscoord *aSpacing)
 Draw a string in the RenderingContext.
NS_IMETHOD DrawString (const nsString &aString, nscoord aX, nscoord aY, PRInt32 aFontID, const nscoord *aSpacing)
 Draw a string in the RenderingContext.
NS_IMETHOD GetTextDimensions (const char *aString, PRUint32 aLength, nsTextDimensions &aDimensions)
 Returns the dimensions of a string, i.e., the overall extent of a string whose rendering may involve switching between different fonts that have different metrics.
NS_IMETHOD GetTextDimensions (const PRUnichar *aString, PRUint32 aLength, nsTextDimensions &aDimensions, PRInt32 *aFontID)
NS_IMETHOD GetTextDimensions (const char *aString, PRInt32 aLength, PRInt32 aAvailWidth, PRInt32 *aBreaks, PRInt32 aNumBreaks, nsTextDimensions &aDimensions, PRInt32 &aNumCharsFit, nsTextDimensions &aLastWordDimensions, PRInt32 *aFontID=nsnull)
NS_IMETHOD GetTextDimensions (const PRUnichar *aString, PRInt32 aLength, PRInt32 aAvailWidth, PRInt32 *aBreaks, PRInt32 aNumBreaks, nsTextDimensions &aDimensions, PRInt32 &aNumCharsFit, nsTextDimensions &aLastWordDimensions, PRInt32 *aFontID=nsnull)
NS_IMETHOD CopyOffScreenBits (nsIDrawingSurface *aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY, const nsRect &aDestBounds, PRUint32 aCopyFlags)
 Copy offscreen pixelmap to this RenderingContext.
NS_IMETHOD RetrieveCurrentNativeGraphicData (void **ngd)
NS_IMETHOD GetBackbuffer (const nsRect &aRequestedSize, const nsRect &aMaxSize, PRBool aForBlending, nsIDrawingSurface *&aBackbuffer)
 Get a drawing surface used as a backbuffer.
NS_IMETHOD ReleaseBackbuffer (void)
 Release a drawing surface used as the backbuffer If the platform caches the backbuffer this call will destroy it.
void SetClipRectInPixels (const nsRect &aRect, nsClipCombine aCombine)
xGCGetGC ()
void UpdateGC ()
void SetCurrentFont (nsFontXlib *cf)
nsFontXlibGetCurrentFont ()
NS_IMETHOD FlushRect (const nsRect &aRect)
 For platforms (e.g., Cocoa) that implicitly double buffer, this call can be used to force a buffer flush following the painting of a rectangle.
NS_IMETHOD FlushRect (nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
NS_IMETHOD GetPenMode (nsPenMode &aPenMode)
 Gets the Pen Mode for the RenderingContext.
NS_IMETHOD SetPenMode (nsPenMode aPenMode)
 Sets the Pen Mode for the RenderingContext.
NS_IMETHOD DestroyCachedBackbuffer (void)
 Destroy the drawing surface used as the backbuffer.
NS_IMETHOD UseBackbuffer (PRBool *aUseBackbuffer)
 Some platforms may not want a backbuffer at all.
NS_IMETHOD PushTranslation (PushedTranslation *aState)
NS_IMETHOD PopTranslation (PushedTranslation *aState)
virtual PRInt32 GetMaxStringLength ()
 Return the maximum length of a string that can be handled by the platform using the current font metrics.
NS_IMETHOD SetRightToLeftText (PRBool aIsRTL)
 Let the device context know whether we want text reordered with right-to-left base direction.
NS_IMETHOD GetRightToLeftText (PRBool *aIsRTL)
NS_IMETHOD GetClusterInfo (const PRUnichar *aText, PRUint32 aLength, PRUint8 *aClusterStarts)
 Get cluster details for a chunk of text.
virtual PRInt32 GetPosition (const PRUnichar *aText, PRUint32 aLength, nsPoint aPt)
 Find the closest cursor position for a given x coordinate.
NS_IMETHOD GetRangeWidth (const PRUnichar *aText, PRUint32 aLength, PRUint32 aStart, PRUint32 aEnd, PRUint32 &aWidth)
 Get the width for the specific range of a given string.
NS_IMETHOD GetRangeWidth (const char *aText, PRUint32 aLength, PRUint32 aStart, PRUint32 aEnd, PRUint32 &aWidth)
 Get the width for the specific range of a given string.
NS_IMETHOD GetWidthInternal (const char *aString, PRUint32 aLength, nscoord &aWidth)
NS_IMETHOD GetWidthInternal (const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth, PRInt32 *aFontID=nsnull)
NS_IMETHOD GetTextDimensionsInternal (const char *aString, PRUint32 aLength, nsTextDimensions &aDimensions)
NS_IMETHOD GetTextDimensionsInternal (const PRUnichar *aString, PRUint32 aLength, nsTextDimensions &aDimensions, PRInt32 *aFontID=nsnull)
NS_IMETHOD DrawStringInternal (const char *aString, PRUint32 aLength, nscoord aX, nscoord aY, const nscoord *aSpacing=nsnull)
NS_IMETHOD DrawStringInternal (const PRUnichar *aString, PRUint32 aLength, nscoord aX, nscoord aY, PRInt32 aFontID=-1, const nscoord *aSpacing=nsnull)

Protected Member Functions

nsresult CommonInit (void)
void ConditionRect (nscoord &x, nscoord &y, nscoord &w, nscoord &h)
PRBool RectFitsInside (const nsRect &aRect, PRInt32 aWidth, PRInt32 aHeight) const
 Determine if a rect's width and height will fit within a specified width and height.
PRBool BothRectsFitInside (const nsRect &aRect1, const nsRect &aRect2, PRInt32 aWidth, PRInt32 aHeight, nsRect &aNewSize) const
 Determine if two rectangles width and height will fit within a specified width and height.
void CalculateDiscreteSurfaceSize (const nsRect &aMaxBackbufferSize, const nsRect &aRequestedSize, nsRect &aSize)
 Return an offscreen surface size from a set of discrete surface sizes.
void GetDrawingSurfaceSize (const nsRect &aMaxBackbufferSize, const nsRect &aRequestedSize, nsRect &aSurfaceSize)
 Get the size of the offscreen drawing surface.
nsresult AllocateBackbuffer (const nsRect &aRequestedSize, const nsRect &aMaxSize, nsIDrawingSurface *&aBackbuffer, PRBool aCacheBackbuffer, PRUint32 aSurfFlags)
 Utility method used to implement NS_IMETHOD GetBackbuffer.

Protected Attributes

nsXPrintContextmPrintContext
nsCOMPtr< nsIDeviceContextmContext
nsCOMPtr< nsIDrawingSurfaceXlibmOffscreenSurface
nsCOMPtr< nsIDrawingSurfaceXlibmSurface
nsCOMPtr< nsIFontMetricsmFontMetrics
nsCOMPtr< nsIRegionmClipRegion
float mP2T
nsAutoVoidArray mStateCache
xGCmGC
int mFunction
int mLineStyle
char * mDashList
int mDashes
nscolor mCurrentColor
XlibRgbHandle * mXlibRgbHandle
DisplaymDisplay
nsFontXlibmCurrentFont
nsLineStyle mCurrentLineStyle
nsTransform2D * mTranMatrix
int mAct
EdgemActive
nsPenMode mPenMode

Detailed Description

Definition at line 51 of file nsRenderingContextXp.h.


Constructor & Destructor Documentation

Definition at line 67 of file nsRenderingContextXp.cpp.

{
}

Member Function Documentation

nsresult nsRenderingContextImpl::AllocateBackbuffer ( const nsRect aRequestedSize,
const nsRect aMaxSize,
nsIDrawingSurface *&  aBackbuffer,
PRBool  aCacheBackbuffer,
PRUint32  aSurfFlags 
) [protected, inherited]

Utility method used to implement NS_IMETHOD GetBackbuffer.

Parameters:
aRequestedSizesize of the backbuffer area requested
aMaxSizemaximum size that may be requested for the backbuffer
aBackbufferdrawing surface used as the backbuffer
aCacheBackbufferPR_TRUE then the backbuffer will be cached, if PR_FALSE it is created each time
aSurfFlagsflags passed to CreateDrawingSurface()

Definition at line 86 of file nsRenderingContextImpl.cpp.

{
  nsRect newBounds;
  nsresult rv = NS_OK;

   if (! aCacheBackbuffer) {
    newBounds = aRequestedSize;
  } else {
    GetDrawingSurfaceSize(aMaxSize, aRequestedSize, newBounds);
  }

  if ((nsnull == gBackbuffer)
      || (gBackbufferBounds.width != newBounds.width)
      || (gBackbufferBounds.height != newBounds.height))
    {
      if (gBackbuffer) {
        //destroy existing DS
        DestroyDrawingSurface(gBackbuffer);
        gBackbuffer = nsnull;
      }

      rv = CreateDrawingSurface(newBounds, aSurfFlags, gBackbuffer);
      //   printf("Allocating a new drawing surface %d %d\n", newBounds.width, newBounds.height);
      if (NS_SUCCEEDED(rv)) {
        gBackbufferBounds = newBounds;
        SelectOffScreenDrawingSurface(gBackbuffer);
      } else {
        gBackbufferBounds.SetRect(0,0,0,0);
        gBackbuffer = nsnull;
      }
    } else {
      SelectOffScreenDrawingSurface(gBackbuffer);

      float p2t;
      nsCOMPtr<nsIDeviceContext>  dx;
      GetDeviceContext(*getter_AddRefs(dx));
      p2t = dx->DevUnitsToAppUnits();
      nsRect bounds = aRequestedSize;
      bounds *= p2t;

      SetClipRect(bounds, nsClipCombine_kReplace);
    }

  aBackbuffer = gBackbuffer;
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsRenderingContextImpl::BothRectsFitInside ( const nsRect aRect1,
const nsRect aRect2,
PRInt32  aWidth,
PRInt32  aHeight,
nsRect aNewSize 
) const [protected, inherited]

Determine if two rectangles width and height will fit within a specified width and height.

Parameters:
aRect1first rectangle to test
aRect1second rectangle to test
aWidthwidth to determine if both rectangle's width will fit within
aHeightheight to determine if both rectangles height will fit within
Returns:
PR_TRUE if the rect1's and rect2's width and height fits with aWidth, aHeight, PR_FALSE otherwise.

Definition at line 199 of file nsRenderingContextImpl.cpp.

{
  if (PR_FALSE == RectFitsInside(aRect1, aWidth, aHeight)) {
    return PR_FALSE;
  }

  if (PR_FALSE == RectFitsInside(aRect2, aWidth, aHeight)) {
    return PR_FALSE;
  }

  aNewSize.width = aWidth;
  aNewSize.height = aHeight;

  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsRenderingContextImpl::CalculateDiscreteSurfaceSize ( const nsRect aMaxBackbufferSize,
const nsRect aRequestedSize,
nsRect aSize 
) [protected, inherited]

Return an offscreen surface size from a set of discrete surface sizes.

The smallest discrete surface size that can enclose both the Maximum widget size (

See also:
GetMaxWidgetBounds) and the requested size is returned.
Parameters:
aMaxBackbufferSizeMaximum size that may be requested for the backbuffer
aRequestedSizeRequested size for the offscreen.
aSurfaceSizecontains the surface size

Definition at line 221 of file nsRenderingContextImpl.cpp.

{
  // Get the height and width of the screen
  PRInt32 height;
  PRInt32 width;

  nsCOMPtr<nsIDeviceContext>  dx;
  GetDeviceContext(*getter_AddRefs(dx));
  dx->GetDeviceSurfaceDimensions(width, height);

  float devUnits;
  devUnits = dx->DevUnitsToAppUnits();
  PRInt32 screenHeight = NSToIntRound(float( height) / devUnits );
  PRInt32 screenWidth = NSToIntRound(float( width) / devUnits );

  // These tests must go from smallest rectangle to largest rectangle.

  // 1/8 screen
  if (BothRectsFitInside(aRequestedSize, aMaxBackbufferSize, screenWidth / 8, screenHeight / 8, aSurfaceSize)) {
    return;
  }

  // 1/4 screen
  if (BothRectsFitInside(aRequestedSize, aMaxBackbufferSize, screenWidth / 4, screenHeight / 4, aSurfaceSize)) {
    return;
  }

  // 1/2 screen
  if (BothRectsFitInside(aRequestedSize, aMaxBackbufferSize, screenWidth / 2, screenHeight / 2, aSurfaceSize)) {
    return;
  }

  // 3/4 screen
  if (BothRectsFitInside(aRequestedSize, aMaxBackbufferSize, (screenWidth * 3) / 4, (screenHeight * 3) / 4, aSurfaceSize)) {
    return;
  }

  // 3/4 screen width full screen height
  if (BothRectsFitInside(aRequestedSize, aMaxBackbufferSize, (screenWidth * 3) / 4, screenHeight, aSurfaceSize)) {
    return;
  }

  // Full screen
  if (BothRectsFitInside(aRequestedSize, aMaxBackbufferSize, screenWidth, screenHeight, aSurfaceSize)) {
    return;
  }

  // Bigger than Full Screen use the largest request every made.
  if (BothRectsFitInside(aRequestedSize, aMaxBackbufferSize, gLargestRequestedSize.width, gLargestRequestedSize.height, aSurfaceSize)) {
    return;
  } else {
    gLargestRequestedSize.width = PR_MAX(aRequestedSize.width, aMaxBackbufferSize.width);
    gLargestRequestedSize.height = PR_MAX(aRequestedSize.height, aMaxBackbufferSize.height);
    aSurfaceSize.width = gLargestRequestedSize.width;
    aSurfaceSize.height = gLargestRequestedSize.height;
    //   printf("Expanding the largested requested size to %d %d\n", gLargestRequestedSize.width, gLargestRequestedSize.height);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsRenderingContextXlib::CommonInit ( void  ) [protected, inherited]

Definition at line 213 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContxtXlib::CommonInit()\n"));
  // put common stuff in here.
  int x, y;
  unsigned int width, height, border, depth;
  Window root_win;

  Drawable drawable; mSurface->GetDrawable(drawable);

  ::XGetGeometry(mDisplay, 
                 drawable, 
                 &root_win,
                 &x, 
                 &y, 
                 &width, 
                 &height, 
                 &border, 
                 &depth);

  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, 
         ("XGetGeometry(display=%lx,drawable=%lx) ="
         " {root_win=%lx, x=%d, y=%d, width=%d, height=%d. border=%d, depth=%d}\n",
         (long)mDisplay, (long)drawable,
         (long)root_win, (int)x, (int)y, (int)width, (int)height, (int)border, (int)depth));

  mClipRegion = new nsRegionXlib();
  if (!mClipRegion)
    return NS_ERROR_OUT_OF_MEMORY;
  mClipRegion->Init();
  mClipRegion->SetTo(0, 0, width, height);

  mP2T = mContext->DevUnitsToAppUnits();
  float app2dev;
  app2dev = mContext->AppUnitsToDevUnits();
  mTranMatrix->AddScale(app2dev, app2dev);
  return NS_OK;
}

Here is the caller graph for this function:

void nsRenderingContextXlib::ConditionRect ( nscoord x,
nscoord y,
nscoord w,
nscoord h 
) [inline, protected, inherited]

Definition at line 262 of file nsRenderingContextXlib.h.

                                                                     {
    if ( y < -32766 ) {
      y = -32766;
    }

    if ( y + h > 32766 ) {
      h  = 32766 - y;
    }

    if ( x < -32766 ) {
      x = -32766;
    }

    if ( x + w > 32766 ) {
      w  = 32766 - x;
    }
  }

Here is the caller graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::CopyClipRegion ( nsIRegion aRegion) [virtual, inherited]

Gets a copy of the current clipping region for the RenderingContext The region is in device coordinates!

Parameters:
aRegioninout parameter representing the clip region. if SetClipRegion() is called, do not assume that GetClipRegion() will return the same object.

Implements nsIRenderingContext.

Definition at line 559 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::CopyClipRegion()\n"));
  aRegion.SetTo(*mClipRegion);
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::CopyOffScreenBits ( nsIDrawingSurface aSrcSurf,
PRInt32  aSrcX,
PRInt32  aSrcY,
const nsRect aDestBounds,
PRUint32  aCopyFlags 
) [virtual, inherited]

Copy offscreen pixelmap to this RenderingContext.

Parameters:
aSrcSurfdrawing surface to copy bits from
aSrcXx offset into source pixelmap to copy from
aSrcYy offset into source pixelmap to copy from
aDestBoundsDestination rectangle to copy to
aCopyFlagssee below

Implements nsIRenderingContext.

Definition at line 2286 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::CopyOffScreenBits()\n"));

  PRInt32                 srcX = aSrcX;
  PRInt32                 srcY = aSrcY;
  nsRect                  drect = aDestBounds;
  nsIDrawingSurfaceXlib  *destsurf;

  NS_ENSURE_TRUE(mTranMatrix != nsnull, NS_ERROR_FAILURE);
  NS_ENSURE_TRUE(mSurface    != nsnull, NS_ERROR_FAILURE);
  NS_ENSURE_TRUE(aSrcSurf    != nsnull, NS_ERROR_FAILURE);
    
  if (aCopyFlags & NS_COPYBITS_TO_BACK_BUFFER) {
    destsurf = mSurface;
  }
  else
  {
    NS_ENSURE_TRUE(mOffscreenSurface != nsnull, NS_ERROR_FAILURE);
    destsurf = mOffscreenSurface;
  }
  
  if (aCopyFlags & NS_COPYBITS_XFORM_SOURCE_VALUES)
    mTranMatrix->TransformCoord(&srcX, &srcY);
  
  if (aCopyFlags & NS_COPYBITS_XFORM_DEST_VALUES)
    mTranMatrix->TransformCoord(&drect.x, &drect.y, &drect.width, &drect.height);
  
  //XXX flags are unused. that would seem to mean that there is
  //inefficiency somewhere... MMP

  UpdateGC();
  Drawable destdrawable; destsurf->GetDrawable(destdrawable);
  Drawable srcdrawable; ((nsIDrawingSurfaceXlib *)aSrcSurf)->GetDrawable(srcdrawable);

  ::XCopyArea(mDisplay,
              srcdrawable,
              destdrawable,
              *mGC,
              srcX, srcY,
              drect.width, drect.height,
              drect.x, drect.y);

  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::CreateDrawingSurface ( const nsRect aBounds,
PRUint32  aSurfFlags,
nsIDrawingSurface *&  aSurface 
) [virtual, inherited]

Create an offscreen drawing surface compatible with this RenderingContext.

The rect passed in is not affected by any transforms in the rendering context and the values are in device units.

Parameters:
aBoundsA rectangle representing the size for the drawing surface. if nsnull then a bitmap will not be created and associated with the new drawing surface
aSurfFlagssee bottom of nsIRenderingContext.h
Returns:
A nsIDrawingSurface*

Implements nsIRenderingContext.

Definition at line 753 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::CreateDrawingSurface()\n"));

  if (nsnull == mSurface) {
    aSurface = nsnull;
    return NS_ERROR_FAILURE;
  }

  NS_ENSURE_TRUE((aBounds.width > 0) && (aBounds.height > 0), NS_ERROR_FAILURE);
 
  nsresult rv = NS_ERROR_FAILURE;
  nsDrawingSurfaceXlibImpl *surf = new nsDrawingSurfaceXlibImpl();

  if (surf)
  {
    NS_ADDREF(surf);
    UpdateGC();
    rv = surf->Init(mXlibRgbHandle, mGC, aBounds.width, aBounds.height, aSurfFlags);    
  }

  aSurface = surf;

  return rv;
}

Here is the call graph for this function:

Destroy the drawing surface used as the backbuffer.

If the platform does not maintain a cached backbuffer this call will do nothing.

Implements nsIRenderingContext.

Definition at line 140 of file nsRenderingContextImpl.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Destroy a drawing surface created by CreateDrawingSurface()

Parameters:
aDSA drawing surface to destroy

Implements nsIRenderingContext.

Definition at line 782 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DestroyDrawingSurface()\n"));
  nsIDrawingSurfaceXlib *surf = NS_STATIC_CAST(nsIDrawingSurfaceXlib *, aDS);;

  NS_ENSURE_TRUE(surf != nsnull, NS_ERROR_FAILURE);

  NS_IF_RELEASE(surf);

  return NS_OK;
}
NS_IMETHODIMP nsRenderingContextXlib::DrawArc ( const nsRect aRect,
float  aStartAngle,
float  aEndAngle 
) [virtual, inherited]

Draw an arc in the current forground color.

Parameters:
aRectThe rectangle define bounds of ellipse to use
aStartAnglethe starting angle of the arc, in degrees
aEndAngleThe ending angle of the arc, in degrees

Implements nsIRenderingContext.

Definition at line 1146 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawArc()\n"));
  return DrawArc(aRect.x,aRect.y,aRect.width,aRect.height,aStartAngle,aEndAngle); 
}
NS_IMETHODIMP nsRenderingContextXlib::DrawArc ( nscoord  aX,
nscoord  aY,
nscoord  aWidth,
nscoord  aHeight,
float  aStartAngle,
float  aEndAngle 
) [virtual, inherited]

Draw an arc in the current forground color.

Parameters:
aXHorizontal left Coordinate in twips
aYVertical top Coordinate in twips
aWidthWidth of horizontal axis in twips
aHeightHeight of vertical axis in twips
aStartAnglethe starting angle of the arc, in degrees
aEndAngleThe ending angle of the arc, in degrees

Implements nsIRenderingContext.

Definition at line 1154 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawArc()\n"));

  NS_ENSURE_TRUE(mTranMatrix != nsnull, NS_ERROR_FAILURE);
  NS_ENSURE_TRUE(mSurface    != nsnull, NS_ERROR_FAILURE);

  nscoord x, y, w, h;
   
  x = aX; 
  y = aY;
  w = aWidth; 
  h = aHeight;
    
  mTranMatrix->TransformCoord(&x,&y,&w,&h);
    
  UpdateGC();
  Drawable drawable; mSurface->GetDrawable(drawable);
  ::XDrawArc(mDisplay,
             drawable,
             *mGC,
             x,y,w,h, NSToIntRound(aStartAngle * 64.0f),
             NSToIntRound(aEndAngle * 64.0f));
  
  return NS_OK;  
}

Here is the call graph for this function:

Draw an ellipse in the current foreground color.

Parameters:
aRectThe rectangle define bounds of ellipse to draw

Implements nsIRenderingContext.

Definition at line 1068 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawEllipse(const nsRect& aRect)\n"));
  return DrawEllipse(aRect.x, aRect.y, aRect.width, aRect.height);
}
NS_IMETHODIMP nsRenderingContextXlib::DrawEllipse ( nscoord  aX,
nscoord  aY,
nscoord  aWidth,
nscoord  aHeight 
) [virtual, inherited]

Draw an ellipse in the current foreground color.

Parameters:
aXHorizontal left Coordinate in twips
aYVertical top Coordinate in twips
aWidthWidth of horizontal axis in twips
aHeightHeight of vertical axis in twips

Implements nsIRenderingContext.

Definition at line 1075 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawEllipse(aX, aY, aWidth, aHeight)\n"));

  NS_ENSURE_TRUE(mTranMatrix != nsnull, NS_ERROR_FAILURE);
  NS_ENSURE_TRUE(mSurface    != nsnull, NS_ERROR_FAILURE);

  nscoord x, y, w, h;
   
  x = aX; 
  y = aY;
  w = aWidth; 
  h = aHeight;
    
  mTranMatrix->TransformCoord(&x,&y,&w,&h);
    
  UpdateGC();
  Drawable drawable; mSurface->GetDrawable(drawable);
  ::XDrawArc(mDisplay,
             drawable,
             *mGC,
             x, y, w, h, 0, 360*64);
  
  return NS_OK;  
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextXp::DrawImage ( imgIContainer aImage,
const nsRect aSrcRect,
const nsRect aDestRect 
) [virtual]

Draw a portion of an image, scaling it to fit within a specified rect.

Parameters:
aImageThe image to draw
aSrcRectThe rect (in twips) of the image to draw. [x,y] denotes the top left corner of the region.
aDestRectThe device context rect (in twips) that the image portion should occupy. [x,y] denotes the top left corner. [height,width] denotes the desired image size.

Reimplemented from nsRenderingContextXlib.

Definition at line 132 of file nsRenderingContextXp.cpp.

{
  PR_LOG(RenderingContextXpLM, PR_LOG_DEBUG, ("nsRenderingContextXp::DrawImage()\n"));

  nsRect 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 = 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(mSurface->GetDrawable(),
                                  mGC, img,
                                  sr.x, sr.y,
                                  sr.width, sr.height,
                                  dr.x, dr.y,
                                  dr.width, dr.height);
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::DrawLine ( nscoord  aX0,
nscoord  aY0,
nscoord  aX1,
nscoord  aY1 
) [virtual, inherited]

Draw a line.

Parameters:
aXOstarting horiztonal coord in twips
aY0starting vertical coord in twips
aX1end horiztonal coord in twips
aY1end vertical coord in twips

Implements nsIRenderingContext.

Definition at line 795 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawLine()\n"));

  nscoord diffX, diffY;

  NS_ENSURE_TRUE(mTranMatrix != nsnull, NS_ERROR_FAILURE);
  NS_ENSURE_TRUE(mSurface    != nsnull, NS_ERROR_FAILURE);

  mTranMatrix->TransformCoord(&aX0,&aY0);
  mTranMatrix->TransformCoord(&aX1,&aY1);
  
  diffX = aX1-aX0;
  diffY = aY1-aY0;

  if (0!=diffX) {
    diffX = (diffX>0?1:-1);
  }
  if (0!=diffY) {
    diffY = (diffY>0?1:-1);
  }

  UpdateGC();
  Drawable drawable; mSurface->GetDrawable(drawable);
  ::XDrawLine(mDisplay, drawable,
              *mGC, aX0, aY0, aX1 - diffX, aY1 - diffY);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::DrawPolygon ( const nsPoint  aPoints[],
PRInt32  aNumPoints 
) [virtual, inherited]

Draw a poly in the current foreground color.

Parameters:
aPointspoints to use for the drawing, last must equal first
aNumPontsnumber of points in the polygon

Implements nsIRenderingContext.

Definition at line 1001 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawPolygon()\n"));

  NS_ENSURE_TRUE(mTranMatrix != nsnull, NS_ERROR_FAILURE);
  NS_ENSURE_TRUE(mSurface    != nsnull, NS_ERROR_FAILURE);

  PRInt32 i ;
  XPoint * xpoints;
  XPoint * thispoint;
  
  xpoints = (XPoint *) malloc(sizeof(XPoint) * aNumPoints);
  NS_ENSURE_TRUE(xpoints != nsnull, NS_ERROR_OUT_OF_MEMORY);
  
  for (i = 0; i < aNumPoints; i++){
    thispoint = (xpoints+i);
    thispoint->x = aPoints[i].x;
    thispoint->y = aPoints[i].y;
    mTranMatrix->TransformCoord((PRInt32*)&thispoint->x,(PRInt32*)&thispoint->y);
  }
  
  UpdateGC();
  Drawable drawable; mSurface->GetDrawable(drawable);
  ::XDrawLines(mDisplay,
               drawable,
               *mGC,
               xpoints, aNumPoints, CoordModeOrigin);

  free((void *)xpoints);
  
  return NS_OK;    
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::DrawPolyline ( const nsPoint  aPoints[],
PRInt32  aNumPoints 
) [virtual, inherited]

Draw a polyline.

Parameters:
aPointsarray of endpoints
aNumPontsnumber of points

Implements nsIRenderingContext.

Definition at line 826 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawPolyLine()\n"));

  NS_ENSURE_TRUE(mTranMatrix != nsnull, NS_ERROR_FAILURE);
  NS_ENSURE_TRUE(mSurface    != nsnull, NS_ERROR_FAILURE);

  PRInt32  i;
  XPoint * xpoints;
  XPoint * thispoint;

  xpoints = (XPoint *) malloc(sizeof(XPoint) * aNumPoints);
  NS_ENSURE_TRUE(xpoints != nsnull, NS_ERROR_OUT_OF_MEMORY);

  for (i = 0; i < aNumPoints; i++){
    thispoint = (xpoints+i);
    thispoint->x = aPoints[i].x;
    thispoint->y = aPoints[i].y;
    mTranMatrix->TransformCoord((PRInt32*)&thispoint->x,(PRInt32*)&thispoint->y);
  }

  UpdateGC();
  Drawable drawable; mSurface->GetDrawable(drawable);
  ::XDrawLines(mDisplay,
               drawable,
               *mGC,
               xpoints, aNumPoints, CoordModeOrigin);

  free((void *)xpoints);

  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::DrawRect ( const nsRect aRect) [virtual, inherited]

Draw a rectangle.

Parameters:
aRectThe rectangle to draw

Implements nsIRenderingContext.

Definition at line 860 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawRext(const nsRect& aRect)\n"));
  return DrawRect(aRect.x, aRect.y, aRect.width, aRect.height);
}
NS_IMETHODIMP nsRenderingContextXlib::DrawRect ( nscoord  aX,
nscoord  aY,
nscoord  aWidth,
nscoord  aHeight 
) [virtual, inherited]

Draw a rectangle.

Parameters:
aXHorizontal left Coordinate in twips
aYVertical top Coordinate in twips
aWidthWidth of rectangle in twips
aHeightHeight of rectangle in twips

Implements nsIRenderingContext.

Definition at line 867 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawRect(aX, aY, aWidth, aHeight)\n"));

  NS_ENSURE_TRUE(mTranMatrix != nsnull, NS_ERROR_FAILURE);
  NS_ENSURE_TRUE(mSurface    != nsnull, NS_ERROR_FAILURE);

  nscoord x, y, w, h; 
  
  x = aX;
  y = aY; 
  w = aWidth;
  h = aHeight;
    
  mTranMatrix->TransformCoord(&x,&y,&w,&h);
    
  // After the transform, if the numbers are huge, chop them, because
  // they're going to be converted from 32 bit to 16 bit.
  // It's all way off the screen anyway.
  ConditionRect(x,y,w,h);
   
  // Don't draw empty rectangles; also, w/h are adjusted down by one
  // so that the right number of pixels are drawn.
  if (w && h) 
  {
    UpdateGC();
    Drawable drawable; mSurface->GetDrawable(drawable);
    ::XDrawRectangle(mDisplay,
                     drawable,
                     *mGC,
                     x,
                     y,
                     w-1,
                     h-1);
  }

  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::DrawString ( const char *  aString,
PRUint32  aLength,
nscoord  aX,
nscoord  aY,
const nscoord aSpacing 
) [virtual, inherited]

Draw a string in the RenderingContext.

Parameters:
aStringThe string to draw
aLengthThe length of the aString
aXHorizontal starting point of baseline
aYVertical starting point of baseline.
aSpacinginter-character spacing to apply

Reimplemented from nsRenderingContextImpl.

Definition at line 2064 of file nsRenderingContextXlib.cpp.

{
  nsresult res = NS_OK;

  if (aLength) {
    NS_ENSURE_TRUE(mTranMatrix  != nsnull, NS_ERROR_FAILURE);
    NS_ENSURE_TRUE(mSurface     != nsnull, NS_ERROR_FAILURE);
    NS_ENSURE_TRUE(aString      != nsnull, NS_ERROR_FAILURE);
    NS_ENSURE_TRUE(mCurrentFont != nsnull, NS_ERROR_FAILURE);

    nscoord x = aX;
    nscoord y = aY;

    UpdateGC();

    nsXFont *xFont = mCurrentFont->GetXFont();
    if (nsnull != aSpacing) {
      // Render the string, one character at a time...
      const char* end = aString + aLength;
      while (aString < end) {
        char ch = *aString++;
        nscoord xx = x;
        nscoord yy = y;
        mTranMatrix->TransformCoord(&xx, &yy);
#ifdef USE_FREETYPE
        if (mCurrentFont->IsFreeTypeFont()) {
          // this function is only supposed to be called for ascii data
          res = mCurrentFont->DrawString(this, mSurface, xx, yy, 
                            NS_ConvertASCIItoUTF16(aString, aLength).get(),
                            aLength);
        }
        else
#endif /* USE_FREETYPE */
        if (!mCurrentFont->GetXFontIs10646()) {
          // 8 bit data with an 8 bit font
          NS_ASSERTION(xFont->IsSingleByte(),"wrong string/font size");
          xFont->DrawText8(mSurface->GetDrawable(), *mGC, xx, yy, &ch, 1);
        }
        else {
          // we have 8 bit data but a 16 bit font
          NS_ASSERTION(!xFont->IsSingleByte(),"wrong string/font size");
          Widen8To16AndDraw(mSurface->GetDrawable(), xFont, *mGC,
                                                xx, yy, &ch, 1);
        }
        x += *aSpacing++;
      }
    }
    else {
      mTranMatrix->TransformCoord(&x, &y);
#ifdef USE_FREETYPE
      if (mCurrentFont->IsFreeTypeFont()) {
        // this function is only supposed to be called for ascii data
        res = mCurrentFont->DrawString(this, mSurface, x, y, 
                          NS_ConvertASCIItoUTF16(aString, aLength).get(),
                          aLength);
      }
      else
#endif /* USE_FREETYPE */
      if (!mCurrentFont->GetXFontIs10646()) { // keep 8 bit path fast
        // 8 bit data with an 8 bit font
        NS_ASSERTION(xFont->IsSingleByte(),"wrong string/font size");
        xFont->DrawText8(mSurface->GetDrawable(), *mGC, x, y, aString, aLength);
      }
      else {
        // we have 8 bit data but a 16 bit font
        NS_ASSERTION(!xFont->IsSingleByte(),"wrong string/font size");
        Widen8To16AndDraw(mSurface->GetDrawable(), xFont, *mGC,
                                             x, y, aString, aLength);
      }
    }
  }

#ifdef DISABLED_FOR_NOW
  //this is no longer to be done by this API, but another
  //will take it's place that will need this code again. MMP
  if (mFontMetrics)
  {
    PRUint8 deco = mFontMetrics->Font().decorations;

    if (deco & NS_FONT_DECORATION_OVERLINE)
      DrawLine(aX, aY, aX + aWidth, aY);

    if (deco & NS_FONT_DECORATION_UNDERLINE)
    {
      nscoord ascent,descent;

      mFontMetrics->GetMaxAscent(ascent);
      mFontMetrics->GetMaxDescent(descent);

      DrawLine(aX, aY + ascent + (descent >> 1),
               aX + aWidth, aY + ascent + (descent >> 1));
    }

    if (deco & NS_FONT_DECORATION_LINE_THROUGH)
    {
      nscoord height;

      mFontMetrics->GetHeight(height);

      DrawLine(aX, aY + (height >> 1), aX + aWidth, aY + (height >> 1));
    }
  }
#endif /* DISABLED_FOR_NOW */

  return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::DrawString ( const PRUnichar aString,
PRUint32  aLength,
nscoord  aX,
nscoord  aY,
PRInt32  aFontID,
const nscoord aSpacing 
) [virtual, inherited]

Draw a string in the RenderingContext.

Parameters:
aStringA PRUnichar of the string
aLengthThe length of the aString
aXHorizontal starting point of baseline
aYVertical starting point of baseline.
aFontIDan optional parameter used to speed font selection for complex unicode strings. the value passed is returned by the DrawString() methods.
aSpacinginter-character spacing to apply

Reimplemented from nsRenderingContextImpl.

Definition at line 2174 of file nsRenderingContextXlib.cpp.

{
  if (aLength && mFontMetrics) {
    NS_ENSURE_TRUE(mTranMatrix != nsnull, NS_ERROR_FAILURE);
    NS_ENSURE_TRUE(mSurface    != nsnull, NS_ERROR_FAILURE);
    NS_ENSURE_TRUE(aString     != nsnull, NS_ERROR_FAILURE);

    nscoord x = aX;
    nscoord y = aY;

    mTranMatrix->TransformCoord(&x, &y);

    nsFontMetricsXlib *metrics = NS_REINTERPRET_CAST(nsFontMetricsXlib *, mFontMetrics.get());
    nsFontXlib *prevFont = nsnull;
    PRUint32 start = 0;
    PRUint32 i;
    for (i = 0; i < aLength; i++) {
      PRUnichar c = aString[i];
      nsFontXlib* currFont = nsnull;
      nsFontXlib** font = metrics->mLoadedFonts;
      nsFontXlib** lastFont = &metrics->mLoadedFonts[metrics->mLoadedFontsCount];
      while (font < lastFont) {
        if (CCMAP_HAS_CHAR((*font)->mCCMap, c)) {
          currFont = *font;
          goto FoundFont; // for speed -- avoid "if" statement
        }
        font++;
      }
      currFont = metrics->FindFont(c);
FoundFont:
      // XXX avoid this test by duplicating code -- erik
      if (prevFont) {
        if (currFont != prevFont) {
          if (aSpacing) {
            const PRUnichar* str = &aString[start];
            const PRUnichar* end = &aString[i];

            // save off mCurrentFont and set it so that we cache the GC's font correctly
            nsFontXlib *oldFont = mCurrentFont;
            mCurrentFont = prevFont;
            UpdateGC();

            while (str < end) {
              x = aX;
              y = aY;
              mTranMatrix->TransformCoord(&x, &y);
              prevFont->DrawString(this, mSurface, x, y, str, 1);
              aX += *aSpacing++;
              str++;
            }
            mCurrentFont = oldFont;
          }
          else {
            nsFontXlib *oldFont = mCurrentFont;
            mCurrentFont = prevFont;
            UpdateGC();
            x += prevFont->DrawString(this, mSurface, x, y, &aString[start],
                                      i - start);
            mCurrentFont = oldFont;
          }
          prevFont = currFont;
          start = i;
        }
      }
      else {
        prevFont = currFont;
        start = i;
      }
    }

    if (prevFont) {
      nsFontXlib *oldFont = mCurrentFont;
      mCurrentFont = prevFont;
      UpdateGC();
    
      if (aSpacing) {
        const PRUnichar* str = &aString[start];
        const PRUnichar* end = &aString[i];
        while (str < end) {
          x = aX;
          y = aY;
          mTranMatrix->TransformCoord(&x, &y);
          prevFont->DrawString(this, mSurface, x, y, str, 1);
          aX += *aSpacing++;
          str++;
        }
      }
      else {
        prevFont->DrawString(this, mSurface, x, y, &aString[start], i - start);
      }

      mCurrentFont = oldFont;
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::DrawString ( const nsString aString,
nscoord  aX,
nscoord  aY,
PRInt32  aFontID,
const nscoord aSpacing 
) [virtual, inherited]

Draw a string in the RenderingContext.

Parameters:
aStringA nsString of the string
aXHorizontal starting point of baseline
aYVertical starting point of baseline.
aFontIDan optional parameter used to speed font selection for complex unicode strings. the value passed is returned by the DrawString() methods.
aSpacinginter-character spacing to apply

Reimplemented from nsRenderingContextImpl.

Definition at line 2276 of file nsRenderingContextXlib.cpp.

{
  return DrawString(aString.get(), aString.Length(),
                    aX, aY, aFontID, aSpacing);
}

Here is the call graph for this function:

NS_IMETHOD nsRenderingContextImpl::DrawStringInternal ( const char *  aString,
PRUint32  aLength,
nscoord  aX,
nscoord  aY,
const nscoord aSpacing = nsnull 
) [inline, inherited]

Reimplemented in nsRenderingContextWin, nsRenderingContextGTK, and nsRenderingContextMac.

Definition at line 250 of file nsRenderingContextImpl.h.

Here is the caller graph for this function:

NS_IMETHOD nsRenderingContextImpl::DrawStringInternal ( const PRUnichar aString,
PRUint32  aLength,
nscoord  aX,
nscoord  aY,
PRInt32  aFontID = -1,
const nscoord aSpacing = nsnull 
) [inline, inherited]
NS_IMETHODIMP nsRenderingContextXp::DrawTile ( imgIContainer aImage,
nscoord  aXImageStart,
nscoord  aYImageStart,
const nsRect aTargetRect 
) [virtual]

Reimplemented from nsRenderingContextImpl.

Definition at line 200 of file nsRenderingContextXp.cpp.

{
  PR_LOG(RenderingContextXpLM, PR_LOG_DEBUG,
         ("nsRenderingContextXp::DrawTile(imgIContainer *aImage, nscoord aXImageStart, nscoord aYImageStart, const nsRect *aTargetRect)\n"));

/* xxx_julien: Either this code or the PDF DDX needs a fix */
#ifdef JULIEN_NOTNOW    
  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;

  PushState();

  nscoord imgwidth, imgheight;
  aImage->GetWidth(&imgwidth);
  aImage->GetHeight(&imgheight);

  imgwidth  = NSToCoordRound(imgwidth*mP2T);
  imgheight = NSToCoordRound(imgheight*mP2T);
  
  Drawable srcdrawable;
  Drawable destdrawable;
  mSurface->GetDrawable(destdrawable);

  UpdateGC(); 
  srcdrawable = XCreatePixmap(mDisplay, destdrawable,
                              imgwidth, imgheight,
                              xxlib_rgb_get_depth(mXlibRgbHandle));

  XGCValues     values;
  unsigned long valuesMask = 0;
  nsRenderingContextXlibContext *rcContext;
  nsIDeviceContext *dc = mContext;
  NS_STATIC_CAST(nsDeviceContextX *, dc)->GetRCContext(rcContext);
  xGC *xgc = rcContext->mGcCache.GetGC(mDisplay, srcdrawable, valuesMask, &values, NULL);

  mPrintContext->DrawImage(srcdrawable,
                           xgc, img,
                           0, 0,
                           img->GetWidth(), img->GetHeight(),
                           0, 0,
                           imgwidth, imgheight);

  /* Xlib API can tile for us */
  nsRect clipRect;
  PRBool isValid;

  GetClipRect(clipRect, isValid);
  TilePixmap(mDisplay, srcdrawable, destdrawable, aSXOffset, aSYOffset,
             *aTileRect, clipRect, PR_FALSE);

  xgc->Release();
  XFreePixmap(mDisplay, srcdrawable);
  
  PopState();
#endif /* JULIEN_NOTNOW */
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::FillArc ( const nsRect aRect,
float  aStartAngle,
float  aEndAngle 
) [virtual, inherited]

Fill an arc in the current forground color.

Parameters:
aRectThe rectangle define bounds of ellipse to use
aStartAnglethe starting angle of the arc, in degrees
aEndAngleThe ending angle of the arc, in degrees

Implements nsIRenderingContext.

Definition at line 1183 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::FillArc()\n"));
  return FillArc(aRect.x, aRect.y, aRect.width, aRect.height, aStartAngle, aEndAngle);
}
NS_IMETHODIMP nsRenderingContextXlib::FillArc ( nscoord  aX,
nscoord  aY,
nscoord  aWidth,
nscoord  aHeight,
float  aStartAngle,
float  aEndAngle 
) [virtual, inherited]

Fill an arc in the current forground color.

Parameters:
aXHorizontal left Coordinate in twips
aYVertical top Coordinate in twips
aWidthWidth of horizontal axis in twips
aHeightHeight of vertical axis in twips
aStartAnglethe starting angle of the arc, in degrees
aEndAngleThe ending angle of the arc, in degrees

Implements nsIRenderingContext.

Definition at line 1191 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::FillArc()\n"));

  NS_ENSURE_TRUE(mTranMatrix != nsnull, NS_ERROR_FAILURE);
  NS_ENSURE_TRUE(mSurface    != nsnull, NS_ERROR_FAILURE);

  nscoord x,y,w,h;
   
  x = aX; 
  y = aY;
  w = aWidth; 
  h = aHeight;
    
  mTranMatrix->TransformCoord(&x,&y,&w,&h);
    
  UpdateGC();
  Drawable drawable; mSurface->GetDrawable(drawable);
  ::XFillArc(mDisplay,
             drawable,
             *mGC,
             x,y,w,h, NSToIntRound(aStartAngle * 64.0f),
             NSToIntRound(aEndAngle * 64.0f));
  
  return NS_OK;  
}

Here is the call graph for this function:

Fill an ellipse in the current foreground color.

Parameters:
aRectThe rectangle define bounds of ellipse to draw

Implements nsIRenderingContext.

Definition at line 1102 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::FillEllipse()\n"));
  return FillEllipse(aRect.x, aRect.y, aRect.width, aRect.height);
}
NS_IMETHODIMP nsRenderingContextXlib::FillEllipse ( nscoord  aX,
nscoord  aY,
nscoord  aWidth,
nscoord  aHeight 
) [virtual, inherited]

Fill an ellipse in the current foreground color.

Parameters:
aXHorizontal left Coordinate in twips
aYVertical top Coordinate in twips
aWidthWidth of horizontal axis in twips
aHeightHeight of vertical axis in twips

Implements nsIRenderingContext.

Definition at line 1109 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::FillEllipse()\n"));

  NS_ENSURE_TRUE(mTranMatrix != nsnull, NS_ERROR_FAILURE);
  NS_ENSURE_TRUE(mSurface    != nsnull, NS_ERROR_FAILURE);

  nscoord x,y,w,h;
   
  x = aX; 
  y = aY;
  w = aWidth; 
  h = aHeight;
    
  mTranMatrix->TransformCoord(&x,&y,&w,&h);
    
  UpdateGC();
  Drawable drawable; mSurface->GetDrawable(drawable);
  if (w < 16 || h < 16) {
    /* Fix for bug 91816 ("bullets are not displayed correctly on certain text zooms")
     * De-uglify bullets on some X servers:
     * 1st: Draw... */
    ::XDrawArc(mDisplay,
               drawable,
               *mGC,
               x, y, w, h, 0, 360*64);
    /*  ...then fill. */
  }
  ::XFillArc(mDisplay,
             drawable,
             *mGC,
             x, y, w, h, 0, 360*64);
  
  return NS_OK;  
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::FillPolygon ( const nsPoint  aPoints[],
PRInt32  aNumPoints 
) [virtual, inherited]

Fill a poly in the current foreground color.

Parameters:
aPointspoints to use for the drawing, last must equal first
aNumPontsnumber of points in the polygon

Implements nsIRenderingContext.

Definition at line 1035 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::FillPolygon()\n"));

  NS_ENSURE_TRUE(mTranMatrix != nsnull, NS_ERROR_FAILURE);
  NS_ENSURE_TRUE(mSurface    != nsnull, NS_ERROR_FAILURE);

  PRInt32 i ;
  XPoint * xpoints;
   
  xpoints = (XPoint *) malloc(sizeof(XPoint) * aNumPoints);
  NS_ENSURE_TRUE(xpoints != nsnull, NS_ERROR_OUT_OF_MEMORY);
  
  for (i = 0; i < aNumPoints; ++i) {
    nsPoint p = aPoints[i];
    mTranMatrix->TransformCoord(&p.x, &p.y);
    xpoints[i].x = p.x;
    xpoints[i].y = p.y;
  } 
    
  UpdateGC();
  Drawable drawable; mSurface->GetDrawable(drawable);
  ::XFillPolygon(mDisplay,
                 drawable,
                 *mGC,
                 xpoints, aNumPoints, Complex, CoordModeOrigin);
               
  free((void *)xpoints);

  return NS_OK; 
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::FillRect ( const nsRect aRect) [virtual, inherited]

Fill a rectangle in the current foreground color.

Parameters:
aRectThe rectangle to draw

Implements nsIRenderingContext.

Definition at line 908 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::FillRect()\n"));
  return FillRect(aRect.x, aRect.y, aRect.width, aRect.height);
}
NS_IMETHODIMP nsRenderingContextXlib::FillRect ( nscoord  aX,
nscoord  aY,
nscoord  aWidth,
nscoord  aHeight 
) [virtual, inherited]

Fill a rectangle in the current foreground color.

Parameters:
aXHorizontal left Coordinate in twips
aYVertical top Coordinate in twips
aWidthWidth of rectangle in twips
aHeightHeight of rectangle in twips

Implements nsIRenderingContext.

Definition at line 915 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::FillRect()\n"));

  NS_ENSURE_TRUE(mTranMatrix != nsnull, NS_ERROR_FAILURE);
  NS_ENSURE_TRUE(mSurface    != nsnull, NS_ERROR_FAILURE);

  nscoord x,y,w,h;
  x = aX;
  y = aY;
  w = aWidth;
  h = aHeight;

  mTranMatrix->TransformCoord(&x,&y,&w,&h);

  // After the transform, if the numbers are huge, chop them, because
  // they're going to be converted from 32 bit to 16 bit.
  // It's all way off the screen anyway.
  ConditionRect(x,y,w,h);

  Drawable drawable; mSurface->GetDrawable(drawable);
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("About to fill window 0x%lxd with rect %d %d %d %d\n",
                                                drawable, x, y, w, h));
  UpdateGC();
  ::XFillRectangle(mDisplay,
                   drawable,
                   *mGC,
                   x,y,w,h);
  
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextImpl::FlushRect ( const nsRect aRect) [virtual, inherited]

For platforms (e.g., Cocoa) that implicitly double buffer, this call can be used to force a buffer flush following the painting of a rectangle.

This call needs to be used any time drawing of rects is being done "on the fly", outside of the normal painting process. Examples include the blinking caret and tabbing through subimages in an image map.

Implements nsIRenderingContext.

Reimplemented in nsRenderingContextMac.

Definition at line 436 of file nsRenderingContextImpl.cpp.

{
  return NS_OK;
}
NS_IMETHODIMP nsRenderingContextImpl::FlushRect ( nscoord  aX,
nscoord  aY,
nscoord  aWidth,
nscoord  aHeight 
) [virtual, inherited]

Implements nsIRenderingContext.

Reimplemented in nsRenderingContextMac.

Definition at line 442 of file nsRenderingContextImpl.cpp.

{
    return NS_OK;
}
NS_IMETHODIMP nsRenderingContextXlib::GetBackbuffer ( const nsRect aRequestedSize,
const nsRect aMaxSize,
PRBool  aForBlending,
nsIDrawingSurface *&  aBackbuffer 
) [virtual, inherited]

Get a drawing surface used as a backbuffer.

Depending on the platform this will either cause a backbuffer surface to be allocated or an existing cached backbuffer will be returned. If the backbuffer is being cached asking for aMaxSize which is different from a previous request may cause the platform to dump it's cached backbuffer and reallocate a backbuffer of a size which will allow aMaxSize buffer to be allocated.

Parameters:
aRequestedSizesize of the backbuffer area requested
aMaxSizemaximum size that may be requested for the backbuffer
aForBlendingparameter telling if the buffer will be used for blending
aBackbufferdrawing surface used as the backbuffer

Reimplemented from nsRenderingContextImpl.

Definition at line 2518 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::GetBackbuffer()\n"));
  /* Do not cache the backbuffer. On X11 it is more efficient to allocate
   * the backbuffer as needed and it doesn't cause a performance hit. @see bug 95952 */
  return AllocateBackbuffer(aRequestedSize, aMaxSize, aBackbuffer, PR_FALSE, 0);
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::GetClipRect ( nsRect aRect,
PRBool aHasLocalClip 
) [virtual, inherited]

Gets the bounds of the clip region of the RenderingContext.

The bounds are returned in device units!

Parameters:
aRectout parameter to contain the clip region bounds for the RenderingContext
Returns:
PR_TRUE if the rendering context has a local cliprect set else aRect is undefined

Implements nsIRenderingContext.

Definition at line 520 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::GetClipRext()\n"));
  PRInt32 x, y, w, h;
  if (!mClipRegion->IsEmpty()) {
    mClipRegion->GetBoundingBox(&x,&y,&w,&h);
    aRect.SetRect(x,y,w,h);
    aClipState = PR_TRUE;
  } else {
    aRect.SetRect(0,0,0,0);
    aClipState = PR_FALSE;
  }
  return NS_OK;
}

Here is the caller graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::GetClipRegion ( nsIRegion **  aRegion) [virtual, inherited]

Gets the current clipping region for the RenderingContext The region is in device coordinates!

Parameters:
aRegionout parameter representing the clip region. if SetClipRegion() is called, do not assume that GetClipRegion() will return the same object.

Implements nsIRenderingContext.

Definition at line 567 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::GetClipRegion()\n"));
  nsresult  rv = NS_OK;
  
  NS_ASSERTION(!(nsnull == aRegion), "no region ptr");
  
  if (*aRegion) {
    (*aRegion)->SetTo(*mClipRegion);
  }
  return rv;
}
NS_IMETHODIMP nsRenderingContextImpl::GetClusterInfo ( const PRUnichar aText,
PRUint32  aLength,
PRUint8 aClusterStarts 
) [virtual, inherited]

Get cluster details for a chunk of text.

This will fill in the aClusterStarts array with information about what characters are the start of clusters for display. The information is just a bitfield that is set to 1 if the character is the start of a cluster. aClusterStarts must already be allocated to at least aLength items in length. Array index zero being set to one indicates that the first character is the beginning of a cluster.

Parameters:
aTextText on which to get details.
aLengthLength of the text.
aClusterStartsArray of ints that will be populated with information about which characters are the starts of clusters.

Implements nsIRenderingContext.

Reimplemented in nsRenderingContextGTK.

Definition at line 448 of file nsRenderingContextImpl.cpp.

Here is the caller graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::GetColor ( nscolor aColor) const [virtual, inherited]

Get the forground color for the RenderingContext.

Returns:
The current forground color of the RenderingContext

Implements nsIRenderingContext.

Definition at line 638 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::GetColor()\n"));

  aColor = mCurrentColor;
  return NS_OK;
}

Definition at line 232 of file nsRenderingContextXlib.h.

{ return mCurrentFont; };
NS_IMETHODIMP nsRenderingContextXlib::GetCurrentTransform ( nsTransform2D *&  aTransform) [virtual, inherited]

Get the current transformation matrix for the RenderingContext.

Returns:
The transformation matrix for the RenderingContext

Implements nsIRenderingContext.

Definition at line 745 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::GetCurrentTransform()\n"));
  aTransform = mTranMatrix;
  return NS_OK;
}
NS_IMETHODIMP nsRenderingContextXlib::GetDeviceContext ( nsIDeviceContext *&  aDeviceContext) [virtual, inherited]

Get the DeviceContext that this RenderingContext was initialized with.

Returns:
the device context

Implements nsIRenderingContext.

Definition at line 365 of file nsRenderingContextXlib.cpp.

Get the currently selected drawing surface.

Parameters:
aSurfaceout parameter for the current drawing surface

Implements nsIRenderingContext.

Definition at line 351 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::GetDrawingSurface()\n"));
  *aSurface = mSurface;
  return NS_OK;
}
void nsRenderingContextImpl::GetDrawingSurfaceSize ( const nsRect aMaxBackbufferSize,
const nsRect aRequestedSize,
nsRect aSurfaceSize 
) [protected, inherited]

Get the size of the offscreen drawing surface.

Parameters:
aMaxBackbufferSizeMaximum size that may be requested for the backbuffer
aRequestedSizeDesired size for the offscreen.
aSurfaceSizeOffscreen adjusted to a discrete size which encloses aRequestedSize.

Definition at line 215 of file nsRenderingContextImpl.cpp.

{ 
  CalculateDiscreteSurfaceSize(aMaxBackbufferSize, aRequestedSize, aNewSize);
  aNewSize.MoveTo(aRequestedSize.x, aRequestedSize.y);
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::GetFontMetrics ( nsIFontMetrics *&  aFontMetrics) [virtual, inherited]

Get the current fontmetrics for the RenderingContext.

Returns:
The current font of the RenderingContext

Implements nsIRenderingContext.

Definition at line 717 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::GetFontMetrics()\n"));

  aFontMetrics = mFontMetrics;
  NS_IF_ADDREF(aFontMetrics);
  return NS_OK;
}
xGC* nsRenderingContextXlib::GetGC ( void  ) [inline, inherited]

Definition at line 227 of file nsRenderingContextXlib.h.

{ mGC->AddRef(); return mGC; }

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::GetHints ( PRUint32 aResult) [virtual, inherited]

Returns in aResult any rendering hints that the context has.

See below for the hints bits. Always returns NS_OK.

Implements nsIRenderingContext.

Definition at line 254 of file nsRenderingContextXlib.cpp.

{
  PRUint32 result = 0;

  // Most X servers implement 8 bit text rendering alot faster than
  // XChar2b rendering. In addition, we can avoid the PRUnichar to
  // XChar2b conversion. So we set this bit...
  result |= NS_RENDERING_HINT_FAST_8BIT_TEXT;
  
/* We can't enable fast text measuring (yet) on platforms
 * which force natural alignment of datatypes (see 
 * http://bugzilla.mozilla.org/show_bug.cgi?id=36146#c46) ... ;-(
 */
#ifndef CPU_DOES_NOT_REQUIRE_NATURAL_ALIGNMENT
#if defined(__i386)
#define CPU_DOES_NOT_REQUIRE_NATURAL_ALIGNMENT 1
#endif /* __i386 */
#endif /* !CPU_DOES_NOT_REQUIRE_NATURAL_ALIGNMENT */

  static PRBool enable_fast_measure;
  static PRBool getenv_done = PR_FALSE;

  /* Check for the env vars "MOZILLA_GFX_ENABLE_FAST_MEASURE" and
   * "MOZILLA_GFX_DISABLE_FAST_MEASURE" to enable/disable fast text
   * measuring (for debugging the feature and doing regression tests).
   * This code will be removed one all issues around this new feature have
   * been fixed. */
  if (!getenv_done)
  {
#ifdef CPU_DOES_NOT_REQUIRE_NATURAL_ALIGNMENT
    enable_fast_measure = PR_TRUE;
#else
    enable_fast_measure = PR_FALSE;
#endif /* CPU_DOES_NOT_REQUIRE_NATURAL_ALIGNMENT */

    if (PR_GetEnv("MOZILLA_GFX_ENABLE_FAST_MEASURE"))
    {
      enable_fast_measure = PR_TRUE;
    }

    if (PR_GetEnv("MOZILLA_GFX_DISABLE_FAST_MEASURE"))
    {
      enable_fast_measure = PR_FALSE;
    }
        
    getenv_done = PR_TRUE;
  } 

  if (enable_fast_measure) {
    // We have GetTextDimensions()
    result |= NS_RENDERING_HINT_FAST_MEASURE;
  }

  // XXX see if we are rendering to the local display or to a remote
  // dispaly and set the NS_RENDERING_HINT_REMOTE_RENDERING accordingly

  aResult = result;
  return NS_OK;
}
NS_IMETHODIMP nsRenderingContextXlib::GetLineStyle ( nsLineStyle aLineStyle) [virtual, inherited]

Gets the line style for the RenderingContext.

Parameters:
aLineStyleThe line style to be retrieved
Returns:
NS_OK if the line style is correctly retrieved

Implements nsIRenderingContext.

Definition at line 709 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::GetLineStyle()\n"));
  aLineStyle = mCurrentLineStyle;
  return NS_OK;
}
virtual PRInt32 nsRenderingContextImpl::GetMaxStringLength ( ) [inline, virtual, inherited]

Return the maximum length of a string that can be handled by the platform using the current font metrics.

The implementation here is just a stub; classes that don't override the safe string methods need to implement this.

Reimplemented in nsRenderingContextWin, nsRenderingContextGTK, and nsRenderingContextMac.

Definition at line 106 of file nsRenderingContextImpl.h.

{ return 1; }

Here is the caller graph for this function:

NS_IMETHOD nsRenderingContextImpl::GetPenMode ( nsPenMode aPenMode) [inline, virtual, inherited]

Gets the Pen Mode for the RenderingContext.

Parameters:
aPenModeThe Pen Mode to be retrieved
Returns:
NS_OK if the Pen Mode is correctly retrieved

Implements nsIRenderingContext.

Reimplemented in nsRenderingContextWin.

Definition at line 83 of file nsRenderingContextImpl.h.

{ return NS_ERROR_FAILURE;}
PRInt32 nsRenderingContextImpl::GetPosition ( const PRUnichar aText,
PRUint32  aLength,
nsPoint  aPt 
) [virtual, inherited]

Find the closest cursor position for a given x coordinate.

This will find the closest byte index for a given x coordinate. This takes into account grapheme clusters and bidi text.

Parameters:
aTextText on which to operate.
aLengthLength of the text.
aPtthe x/y position in the string to check.
Returns:
Index where the cursor falls. If the return is zero, it's before the first character, if it falls off the end of the string it's the length of the string + 1.

Implements nsIRenderingContext.

Reimplemented in nsRenderingContextGTK.

Definition at line 456 of file nsRenderingContextImpl.cpp.

{
  return -1;
}
NS_IMETHODIMP nsRenderingContextImpl::GetRangeWidth ( const PRUnichar aText,
PRUint32  aLength,
PRUint32  aStart,
PRUint32  aEnd,
PRUint32 aWidth 
) [virtual, inherited]

Get the width for the specific range of a given string.

This function is similar to other GetWidth functions, except that it gets the width for a part of the string instead of the entire string. This is useful when you're interested in finding out the length of a chunk in the middle of the string. Lots of languages require you to include surrounding information to accurately determine the length of a substring.

Parameters:
aTextText on which to operate
aLengthLength of the text
aStartStart index into the string
aEndEnd index into the string (inclusive)
aWidthReturned with in app coordinates

Implements nsIRenderingContext.

Reimplemented in nsRenderingContextGTK.

Definition at line 464 of file nsRenderingContextImpl.cpp.

NS_IMETHODIMP nsRenderingContextImpl::GetRangeWidth ( const char *  aText,
PRUint32  aLength,
PRUint32  aStart,
PRUint32  aEnd,
PRUint32 aWidth 
) [virtual, inherited]

Get the width for the specific range of a given string.

Same as GetRangeWidth for PRUnichar, but takes a char * as the text argument.

Implements nsIRenderingContext.

Reimplemented in nsRenderingContextGTK.

Definition at line 474 of file nsRenderingContextImpl.cpp.

Reimplemented in nsRenderingContextWin, nsRenderingContextGTK, and nsRenderingContextMac.

Definition at line 293 of file nsRenderingContextImpl.cpp.

{
  *aIsRTL = PR_FALSE;
  return NS_OK;
}

Here is the caller graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::GetTextDimensions ( const char *  aString,
PRUint32  aLength,
nsTextDimensions aDimensions 
) [virtual, inherited]

Returns the dimensions of a string, i.e., the overall extent of a string whose rendering may involve switching between different fonts that have different metrics.

Parameters:
aStringstring to measure
aLengthnumber of characters in string
aFontIDan optional out parameter used to store a font identifier that can be passed into the DrawString() methods to speed measurements
Returns:
aDimensions struct that contains the extent of the string (see below)

Reimplemented from nsRenderingContextImpl.

Definition at line 1989 of file nsRenderingContextXlib.cpp.

{
  mFontMetrics->GetMaxAscent(aDimensions.ascent);
  mFontMetrics->GetMaxDescent(aDimensions.descent);
  return GetWidth(aString, aLength, aDimensions.width);
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::GetTextDimensions ( const PRUnichar aString,
PRUint32  aLength,
nsTextDimensions aDimensions,
PRInt32 aFontID 
) [virtual, inherited]

Reimplemented from nsRenderingContextImpl.

Definition at line 1998 of file nsRenderingContextXlib.cpp.

{
  aDimensions.Clear();
  if (0 < aLength) {
    NS_ENSURE_TRUE(aString != nsnull, NS_ERROR_FAILURE);

    nsFontMetricsXlib *metrics = NS_REINTERPRET_CAST(nsFontMetricsXlib *, mFontMetrics.get());

    NS_ENSURE_TRUE(metrics != nsnull, NS_ERROR_FAILURE);

    nsFontXlib* prevFont = nsnull;
    int rawWidth = 0, rawAscent = 0, rawDescent = 0;
    PRUint32 start = 0;
    PRUint32 i;
    for (i = 0; i < aLength; i++) {
      PRUnichar c = aString[i];
      nsFontXlib  *currFont = nsnull;
      nsFontXlib **font = metrics->mLoadedFonts;
      nsFontXlib **end = &metrics->mLoadedFonts[metrics->mLoadedFontsCount];
      while (font < end) {
        if (CCMAP_HAS_CHAR((*font)->mCCMap, c)) {
          currFont = *font;
          goto FoundFont; // for speed -- avoid "if" statement
        }
        font++;
      }
      currFont = metrics->FindFont(c);
FoundFont:
      // XXX avoid this test by duplicating code -- erik
      if (prevFont) {
        if (currFont != prevFont) {
          rawWidth += prevFont->GetWidth(&aString[start], i - start);
          if (rawAscent < prevFont->mMaxAscent)
            rawAscent = prevFont->mMaxAscent;
          if (rawDescent < prevFont->mMaxDescent)
            rawDescent = prevFont->mMaxDescent;
          prevFont = currFont;
          start = i;
        }
      }
      else {
        prevFont = currFont;
        start = i;
      }
    }

    if (prevFont) {
      rawWidth += prevFont->GetWidth(&aString[start], i - start);
      if (rawAscent < prevFont->mMaxAscent)
        rawAscent = prevFont->mMaxAscent;
      if (rawDescent < prevFont->mMaxDescent)
        rawDescent = prevFont->mMaxDescent;
    }

    aDimensions.width = NSToCoordRound(rawWidth * mP2T);
    aDimensions.ascent = NSToCoordRound(rawAscent * mP2T);
    aDimensions.descent = NSToCoordRound(rawDescent * mP2T);
  }
  if (nsnull != aFontID)
    *aFontID = 0;

  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::GetTextDimensions ( const char *  aString,
PRInt32  aLength,
PRInt32  aAvailWidth,
PRInt32 aBreaks,
PRInt32  aNumBreaks,
nsTextDimensions aDimensions,
PRInt32 aNumCharsFit,
nsTextDimensions aLastWordDimensions,
PRInt32 aFontID = nsnull 
) [inherited]

Definition at line 1417 of file nsRenderingContextXlib.cpp.

{
  NS_PRECONDITION(aBreaks[aNumBreaks - 1] == aLength, "invalid break array");

  if (nsnull != mFontMetrics) {
    // If we need to back up this state represents the last place we could
    // break. We can use this to avoid remeasuring text
    PRInt32 prevBreakState_BreakIndex = -1; // not known (hasn't been computed)
    nscoord prevBreakState_Width = 0; // accumulated width to this point

    // Initialize OUT parameters
    mFontMetrics->GetMaxAscent(aLastWordDimensions.ascent);
    mFontMetrics->GetMaxDescent(aLastWordDimensions.descent);
    aLastWordDimensions.width = -1;
    aNumCharsFit = 0;

    // Iterate each character in the string and determine which font to use
    nscoord width = 0;
    PRInt32 start = 0;
    nscoord aveCharWidth;
    mFontMetrics->GetAveCharWidth(aveCharWidth);

    while (start < aLength) {
      // Estimate how many characters will fit. Do that by diving the available
      // space by the average character width. Make sure the estimated number
      // of characters is at least 1
      PRInt32 estimatedNumChars = 0;
      if (aveCharWidth > 0) {
        estimatedNumChars = (aAvailWidth - width) / aveCharWidth;
      }
      if (estimatedNumChars < 1) {
        estimatedNumChars = 1;
      }

      // Find the nearest break offset
      PRInt32 estimatedBreakOffset = start + estimatedNumChars;
      PRInt32 breakIndex;
      nscoord numChars;

      // Find the nearest place to break that is less than or equal to
      // the estimated break offset
      if (aLength <= estimatedBreakOffset) {
        // All the characters should fit
        numChars = aLength - start;
        breakIndex = aNumBreaks - 1;
      } 
      else {
        breakIndex = prevBreakState_BreakIndex;
        while (((breakIndex + 1) < aNumBreaks) &&
               (aBreaks[breakIndex + 1] <= estimatedBreakOffset)) {
          ++breakIndex;
        }
        if (breakIndex == prevBreakState_BreakIndex) {
          ++breakIndex; // make sure we advanced past the previous break index
        }
        numChars = aBreaks[breakIndex] - start;
      }

      // Measure the text
      nscoord twWidth = 0;
      if ((1 == numChars) && (aString[start] == ' ')) {
        mFontMetrics->GetSpaceWidth(twWidth);
      } 
      else if (numChars > 0)
        GetWidth( &aString[start], numChars, twWidth);

      // See if the text fits
      PRBool  textFits = (twWidth + width) <= aAvailWidth;

      // If the text fits then update the width and the number of
      // characters that fit
      if (textFits) {
        aNumCharsFit += numChars;
        width += twWidth;
        start += numChars;

        // This is a good spot to back up to if we need to so remember
        // this state
        prevBreakState_BreakIndex = breakIndex;
        prevBreakState_Width = width;
      }
      else {
        // See if we can just back up to the previous saved state and not
        // have to measure any text
        if (prevBreakState_BreakIndex > 0) {
          // If the previous break index is just before the current break index
          // then we can use it
          if (prevBreakState_BreakIndex == (breakIndex - 1)) {
            aNumCharsFit = aBreaks[prevBreakState_BreakIndex];
            width = prevBreakState_Width;
            break;
          }
        }

        // We can't just revert to the previous break state
        if (0 == breakIndex) {
          // There's no place to back up to, so even though the text doesn't fit
          // return it anyway
          aNumCharsFit += numChars;
          width += twWidth;
          break;
        }

        // Repeatedly back up until we get to where the text fits or we're all
        // the way back to the first word
        width += twWidth;
        while ((breakIndex >= 1) && (width > aAvailWidth)) {
          twWidth = 0;
          start = aBreaks[breakIndex - 1];
          numChars = aBreaks[breakIndex] - start;
          
          if ((1 == numChars) && (aString[start] == ' ')) {
            mFontMetrics->GetSpaceWidth(twWidth);
          } 
          else if (numChars > 0)
            GetWidth( &aString[start], numChars, twWidth);

          width -= twWidth;
          aNumCharsFit = start;
          breakIndex--;
        }
        break;
      }
    }

    aDimensions.width = width;
    mFontMetrics->GetMaxAscent(aDimensions.ascent);
    mFontMetrics->GetMaxDescent(aDimensions.descent);

    return NS_OK;
  }

  return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::GetTextDimensions ( const PRUnichar aString,
PRInt32  aLength,
PRInt32  aAvailWidth,
PRInt32 aBreaks,
PRInt32  aNumBreaks,
nsTextDimensions aDimensions,
PRInt32 aNumCharsFit,
nsTextDimensions aLastWordDimensions,
PRInt32 aFontID = nsnull 
) [inherited]

Definition at line 1834 of file nsRenderingContextXlib.cpp.

{
  if (!mFontMetrics)
    return NS_ERROR_FAILURE;

  nsFontMetricsXlib *metrics = NS_REINTERPRET_CAST(nsFontMetricsXlib *, mFontMetrics.get());

  nscoord spaceWidth, aveCharWidth;
  metrics->GetSpaceWidth(spaceWidth);
  metrics->GetAveCharWidth(aveCharWidth);

  // Note: aBreaks[] is supplied to us so that the first word is located
  // at aString[0 .. aBreaks[0]-1] and more generally, the k-th word is
  // located at aString[aBreaks[k-1] .. aBreaks[k]-1]. Whitespace can
  // be included and each of them counts as a word in its own right.

  // Upon completion of glyph resolution, characters that can be
  // represented with fonts[i] are at offsets[i] .. offsets[i+1]-1

  nsAutoVoidArray fonts, offsets;
  offsets.AppendElement((void*)aString);

  BreakGetTextDimensionsData data = { mP2T, aAvailWidth, aBreaks, aNumBreaks,
    spaceWidth, aveCharWidth, 0, 0, 0, -1, 0, &fonts, &offsets 
  };

  metrics->ResolveForwards(aString, aLength, do_BreakGetTextDimensions, &data);

  if (aFontID) *aFontID = 0;

  aNumCharsFit = data.mNumCharsFit;
  aDimensions.width = data.mWidth;

  // Post-processing for the ascent and descent:
  //
  // The width of the last word is included in the final width, but its
  // ascent and descent are kept aside for the moment. The problem is that
  // line-breaking may occur _before_ the last word, and we don't want its
  // ascent and descent to interfere. We can re-measure the last word and
  // substract its width later. However, we need a special care for the ascent
  // and descent at the break-point. The idea is to keep the ascent and descent
  // of the last word separate, and let layout consider them later when it has
  // determined that line-breaking doesn't occur before the last word.
  //
  // Therefore, there are two things to do:
  // 1. Determine the ascent and descent up to where line-breaking may occur.
  // 2. Determine the ascent and descent of the remainder.
  //    For efficiency however, it is okay to bail out early if there is only
  //    one font (in this case, the height of the last word has no special
  //    effect on the total height).

  // aLastWordDimensions.width should be set to -1 to reply that we don't
  // know the width of the last word since we measure multiple words
  aLastWordDimensions.Clear();
  aLastWordDimensions.width = -1;

  PRInt32 count = fonts.Count();
  if (!count)
    return NS_OK;
  nsFontXlib *fontXlib = (nsFontXlib *)fonts[0];
  NS_ASSERTION(fontXlib, "internal error in do_BreakGetTextDimensions");
  aDimensions.ascent = fontXlib->mMaxAscent;
  aDimensions.descent = fontXlib->mMaxDescent;

  // fast path - normal case, quick return if there is only one font
  if (count == 1)
    return NS_OK;

  // get the last break index.
  // If there is only one word, we end up with lastBreakIndex = 0. We don't
  // need to worry about aLastWordDimensions in this case too. But if we didn't
  // return earlier, it would mean that the unique word needs several fonts
  // and we will still have to loop over the fonts to return the final height
  PRInt32 lastBreakIndex = 0;
  while (aBreaks[lastBreakIndex] < aNumCharsFit)
    ++lastBreakIndex;

  const PRUnichar* lastWord = (lastBreakIndex > 0) 
    ? aString + aBreaks[lastBreakIndex-1]
    : aString + aNumCharsFit; // let it point outside to play nice with the loop

  // now get the desired ascent and descent information... this is however
  // a very fast loop of the order of the number of additional fonts

  PRInt32 currFont = 0;
  const PRUnichar* pstr = aString;
  const PRUnichar* last = aString + aNumCharsFit;

  while (pstr < last) {
    fontXlib = (nsFontXlib*)fonts[currFont];
    PRUnichar* nextOffset = (PRUnichar*)offsets[++currFont]; 

    // For consistent word-wrapping, we are going to handle the whitespace
    // character with special care because a whitespace character can come
    // from a font different from that of the previous word. If 'x', 'y', 'z',
    // are Unicode points that require different fonts, we want 'xyz <br>'
    // and 'xyz<br>' to have the same height because it gives a more stable
    // rendering, especially when the window is resized at the edge of the word.
    // If we don't do this, a 'tall' trailing whitespace, i.e., if the whitespace
    // happens to come from a font with a bigger ascent and/or descent than all
    // current fonts on the line, this can cause the next lines to be shifted
    // down when the window is slowly resized to fit that whitespace.
    if (*pstr == ' ') {
      // skip pass the whitespace to ignore the height that it may contribute
      ++pstr;
      // get out if we reached the end
      if (pstr == last) {
        break;
      }
      // switch to the next font if we just passed the current font 
      if (pstr == nextOffset) {
        fontXlib = (nsFontXlib*)fonts[currFont];
        nextOffset = (PRUnichar*)offsets[++currFont];
      } 
    }

    // see if the last word intersects with the current font
    // (we are testing for 'nextOffset-1 >= lastWord' since the
    // current font ends at nextOffset-1)
    if (nextOffset > lastWord) {
      if (aLastWordDimensions.ascent < fontXlib->mMaxAscent) {
        aLastWordDimensions.ascent = fontXlib->mMaxAscent;
      }
      if (aLastWordDimensions.descent < fontXlib->mMaxDescent) {
        aLastWordDimensions.descent = fontXlib->mMaxDescent;
      }
    }

    // see if we have not reached the last word yet
    if (pstr < lastWord) {
      if (aDimensions.ascent < fontXlib->mMaxAscent) {
        aDimensions.ascent = fontXlib->mMaxAscent;
      }
      if (aDimensions.descent < fontXlib->mMaxDescent) {
        aDimensions.descent = fontXlib->mMaxDescent;
      }
    }

    // advance to where the next font starts
    pstr = nextOffset;
  }

  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHOD nsRenderingContextImpl::GetTextDimensionsInternal ( const char *  aString,
PRUint32  aLength,
nsTextDimensions aDimensions 
) [inline, inherited]

Reimplemented in nsRenderingContextWin, nsRenderingContextGTK, and nsRenderingContextMac.

Definition at line 207 of file nsRenderingContextImpl.h.

Here is the caller graph for this function:

NS_IMETHOD nsRenderingContextImpl::GetTextDimensionsInternal ( const PRUnichar aString,
PRUint32  aLength,
nsTextDimensions aDimensions,
PRInt32 aFontID = nsnull 
) [inline, inherited]
NS_IMETHODIMP nsRenderingContextXlib::GetWidth ( char  aC,
nscoord aWidth 
) [virtual, inherited]

Returns the width (in app units) of an 8-bit character If no font has been Set, the results are undefined.

Parameters:
aCcharacter to measure
aWidthout parameter for width
Returns:
error status

Implements nsRenderingContextImpl.

Definition at line 1293 of file nsRenderingContextXlib.cpp.

{
  // Check for the very common case of trying to get the width of a single
  // space.
  if ((aC == ' ') && (nsnull != mFontMetrics)) {
    return mFontMetrics->GetSpaceWidth(aWidth);
  }
  return GetWidth(&aC, 1, aWidth);
}

Here is the caller graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::GetWidth ( PRUnichar  aC,
nscoord aWidth,
PRInt32 aFontID 
) [virtual, inherited]

Returns the width (in app units) of a unicode character If no font has been Set, the results are undefined.

Parameters:
aCcharacter to measure
aWidthout parameter for width
aFontIDan optional out parameter used to store a font identifier that can be passed into the DrawString() methods to speed rendering
Returns:
error status

Implements nsRenderingContextImpl.

Definition at line 1304 of file nsRenderingContextXlib.cpp.

{
  return GetWidth(&aC, 1, aWidth, aFontID);
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::GetWidth ( const nsString aString,
nscoord aWidth,
PRInt32 aFontID 
) [virtual, inherited]

Returns the width (in app units) of an nsString If no font has been Set, the results are undefined.

Parameters:
aStringstring to measure
aWidthout parameter for width
aFontIDan optional out parameter used to store a font identifier that can be passed into the DrawString() methods to speed rendering
Returns:
error status

Reimplemented from nsRenderingContextImpl.

Definition at line 1311 of file nsRenderingContextXlib.cpp.

{
  return GetWidth(aString.get(), aString.Length(), aWidth, aFontID);
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::GetWidth ( const char *  aString,
nscoord aWidth 
) [virtual, inherited]

Returns the width (in app units) of an 8-bit character string If no font has been Set, the results are undefined.

Parameters:
aStringstring to measure
aWidthout parameter for width
Returns:
error status

Reimplemented from nsRenderingContextImpl.

Definition at line 1318 of file nsRenderingContextXlib.cpp.

{
  return GetWidth(aString, strlen(aString), aWidth);
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::GetWidth ( const char *  aString,
PRUint32  aLength,
nscoord aWidth 
) [virtual, inherited]

Returns the width (in app units) of an 8-bit character string If no font has been Set, the results are undefined.

Parameters:
aStringstring to measure
aLengthnumber of characters in string
aWidthout parameter for width
Returns:
error status

Reimplemented from nsRenderingContextImpl.

Definition at line 1324 of file nsRenderingContextXlib.cpp.

{
  if (0 == aLength) {
    aWidth = 0;
  }
  else {
    NS_ENSURE_TRUE(aString      != nsnull, NS_ERROR_FAILURE);
    NS_ENSURE_TRUE(mCurrentFont != nsnull, NS_ERROR_FAILURE);
    int rawWidth;
    nsXFont *xFont = mCurrentFont->GetXFont();
#ifdef USE_FREETYPE
    if (mCurrentFont->IsFreeTypeFont()) {
      // this function is only supposed to be called for ascii data
      rawWidth = mCurrentFont->
        GetWidth(NS_ConvertASCIItoUTF16(aString, aLength).get(), aLength);
    }
    else
#endif /* USE_FREETYPE */
    if (!mCurrentFont->GetXFontIs10646()) {
      NS_ASSERTION(xFont->IsSingleByte(), "wrong string/font size");
      // 8 bit data with an 8 bit font
      rawWidth = xFont->TextWidth8(aString, aLength);
    }
    else {
      NS_ASSERTION(!xFont->IsSingleByte(), "wrong string/font size");
      // we have 8 bit data but a 16 bit font
      rawWidth = Widen8To16AndGetWidth (mCurrentFont->GetXFont(), aString, aLength);
    }
    aWidth = NSToCoordRound(rawWidth * mP2T);
  }
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::GetWidth ( const PRUnichar aString,
PRUint32  aLength,
nscoord aWidth,
PRInt32 aFontID 
) [virtual, inherited]

Returns the width (in app units) of a Unicode character string If no font has been Set, the results are undefined.

Parameters:
aStringstring to measure
aLengthnumber of characters in string
aWidthout parameter for width
aFontIDan optional out parameter used to store a font identifier that can be passed into the DrawString() methods to speed rendering
Returns:
error status

Reimplemented from nsRenderingContextImpl.

Definition at line 1359 of file nsRenderingContextXlib.cpp.

{
  if (0 == aLength) {
    aWidth = 0;
  }
  else {
    NS_ENSURE_TRUE(aString != nsnull, NS_ERROR_FAILURE);

    nsFontMetricsXlib *metrics = NS_REINTERPRET_CAST(nsFontMetricsXlib *, mFontMetrics.get());

    NS_ENSURE_TRUE(metrics != nsnull, NS_ERROR_FAILURE);

    nsFontXlib *prevFont = nsnull;
    int rawWidth = 0;
    PRUint32 start = 0;
    PRUint32 i;
    for (i = 0; i < aLength; i++) {
      PRUnichar c = aString[i];
      nsFontXlib  *currFont = nsnull;
      nsFontXlib **font = metrics->mLoadedFonts;
      nsFontXlib **end = &metrics->mLoadedFonts[metrics->mLoadedFontsCount];
      while (font < end) {
        if (CCMAP_HAS_CHAR((*font)->mCCMap, c)) {
          currFont = *font;
          goto FoundFont; // for speed -- avoid "if" statement
        }
        font++;
      }
      currFont = metrics->FindFont(c);
FoundFont:
      // XXX avoid this test by duplicating code -- erik
      if (prevFont) {
        if (currFont != prevFont) {
          rawWidth += prevFont->GetWidth(&aString[start], i - start);
          prevFont = currFont;
          start = i;
        }
      }
      else {
        prevFont = currFont;
        start = i;
      }
    }

    if (prevFont) {
      rawWidth += prevFont->GetWidth(&aString[start], i - start);
    }

    aWidth = NSToCoordRound(rawWidth * mP2T);
  }
  if (nsnull != aFontID)
    *aFontID = 0;

  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHOD nsRenderingContextImpl::GetWidthInternal ( const char *  aString,
PRUint32  aLength,
nscoord aWidth 
) [inline, inherited]

Reimplemented in nsRenderingContextWin, nsRenderingContextGTK, and nsRenderingContextMac.

Definition at line 201 of file nsRenderingContextImpl.h.

Here is the caller graph for this function:

NS_IMETHOD nsRenderingContextImpl::GetWidthInternal ( const PRUnichar aString,
PRUint32  aLength,
nscoord aWidth,
PRInt32 aFontID = nsnull 
) [inline, inherited]

Definition at line 72 of file nsRenderingContextXp.cpp.

{
  PR_LOG(RenderingContextXpLM, PR_LOG_DEBUG, ("nsRenderingContextXp::Init(nsIDeviceContext *)\n"));

  NS_ENSURE_TRUE(nsnull != aContext, NS_ERROR_NULL_POINTER);
  mContext = aContext;
  if (mContext) {
     nsIDeviceContext *dc = mContext;     
     NS_STATIC_CAST(nsDeviceContextXp *,dc)->GetPrintContext(mPrintContext);
  }
  NS_ENSURE_TRUE(nsnull != mPrintContext, NS_ERROR_NULL_POINTER);

  mPrintContext->GetXlibRgbHandle(mXlibRgbHandle);
  mDisplay = xxlib_rgb_get_display(mXlibRgbHandle);

  /* A printer usually does not support things like multiple drawing surfaces
   * (nor "offscreen" drawing surfaces... would be quite difficult to 
   * implement) - however the Xprint API supports offscreen surfaces for
   * all DDX implementations.
   */
  mOffscreenSurface = mSurface = mPrintContext; 
  UpdateGC(); /* Fill |mGC| */
  mPrintContext->SetGC(mGC);

  return CommonInit();
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextXp::Init ( nsIDeviceContext aContext,
nsIWidget aWidget 
) [virtual]

Initialize the RenderingContext.

Parameters:
aContextthe device context to use.
aWidgetthe widget to hook up to
Returns:
The result of the initialization, NS_Ok if no errors

Reimplemented from nsRenderingContextXlib.

Definition at line 99 of file nsRenderingContextXp.cpp.

{ 
  PR_LOG(RenderingContextXpLM, PR_LOG_DEBUG, ("nsRenderingContextXp::Init(nsIDeviceContext* aContext, nsIWidget *aWidget)\n"));
  return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsRenderingContextXp::Init ( nsIDeviceContext aContext,
nsIDrawingSurface aSurface 
) [virtual]

Initialize the RenderingContext.

Parameters:
aContextthe device context to use for the drawing.
aSurfacethe surface to draw into
Returns:
The result of the initialization, NS_Ok if no errors

Reimplemented from nsRenderingContextXlib.

Definition at line 105 of file nsRenderingContextXp.cpp.

{
  PR_LOG(RenderingContextXpLM, PR_LOG_DEBUG, ("nsRenderingContextXp::Init(nsIDeviceContext* aContext, nsIDrawingSurface* aSurface)\n"));
  return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsRenderingContextXlib::InvertRect ( const nsRect aRect) [virtual, inherited]

XOR Invert a rectangle in the current foreground color.

Parameters:
aRectThe rectangle to draw

Implements nsIRenderingContext.

Definition at line 948 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::InvertRect()\n"));
  return InvertRect(aRect.x, aRect.y, aRect.width, aRect.height);
}
NS_IMETHODIMP nsRenderingContextXlib::InvertRect ( nscoord  aX,
nscoord  aY,
nscoord  aWidth,
nscoord  aHeight 
) [virtual, inherited]

XOR Invert a rectangle in the current foreground color.

Parameters:
aXHorizontal left Coordinate in twips
aYVertical top Coordinate in twips
aWidthWidth of rectangle in twips
aHeightHeight of rectangle in twips

Implements nsIRenderingContext.

Definition at line 955 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::InvertRect()\n"));

  NS_ENSURE_TRUE(mTranMatrix != nsnull, NS_ERROR_FAILURE);
  NS_ENSURE_TRUE(mSurface    != nsnull, NS_ERROR_FAILURE);
  
  // Back up the current color, and use GXxor against white to get a
  // visible result.
  nscolor backupColor = mCurrentColor;
  mCurrentColor = NS_RGB(255, 255, 255);
  nscoord x,y,w,h;

  x = aX;
  y = aY;
  w = aWidth;
  h = aHeight;

  mTranMatrix->TransformCoord(&x,&y,&w,&h);

  // After the transform, if the numbers are huge, chop them, because
  // they're going to be converted from 32 bit to 16 bit.
  // It's all way off the screen anyway.
  ConditionRect(x,y,w,h);

  mFunction = GXxor;
  
  UpdateGC();
  Drawable drawable; mSurface->GetDrawable(drawable);
  ::XFillRectangle(mDisplay,
                   drawable,
                   *mGC,
                   x,
                   y,
                   w,
                   h);
  
  mFunction = GXcopy;

  // Restore current color
  mCurrentColor = backupColor;

  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::IsVisibleRect ( const nsRect aRect,
PRBool aIsVisible 
) [virtual, inherited]

Tells if a given rectangle is visible within the rendering context.

Parameters:
aRectis the rectangle that will be checked for visiblity
Returns:
If true, that rectanglular area is visable.

Implements nsIRenderingContext.

Definition at line 478 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::IsVisibleRect()\n"));
  aVisible = PR_TRUE;
  return NS_OK;
}
NS_IMETHODIMP nsRenderingContextXp::LockDrawingSurface ( PRInt32  aX,
PRInt32  aY,
PRUint32  aWidth,
PRUint32  aHeight,
void **  aBits,
PRInt32 aStride,
PRInt32 aWidthBytes,
PRUint32  aFlags 
) [virtual]

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

Returns:
error status

Reimplemented from nsRenderingContextXlib.

Definition at line 112 of file nsRenderingContextXp.cpp.

{
  PR_LOG(RenderingContextXpLM, PR_LOG_DEBUG, ("nsRenderingContextXp::LockDrawingSurface()\n"));
  PushState();
  return NS_OK;
}

Here is the call graph for this function:

Get and and set RenderingContext to this graphical state.

Implements nsIRenderingContext.

Definition at line 407 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::PopState()\n"));

  PRUint32 cnt = mStateCache.Count();
  GraphicsState *state;
  
  if (cnt > 0) {
    state = (GraphicsState *)mStateCache.ElementAt(cnt - 1);
    mStateCache.RemoveElementAt(cnt - 1);
    
    if (mTranMatrix)
      delete mTranMatrix;
    mTranMatrix = state->mMatrix;
    
    mClipRegion = state->mClipRegion;
    if (mFontMetrics != state->mFontMetrics)
      SetFont(state->mFontMetrics);

    if (state->mColor != mCurrentColor)
      SetColor(state->mColor);
    if (state->mLineStyle != mCurrentLineStyle)
      SetLineStyle(state->mLineStyle);

    delete state;
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Implements nsIRenderingContext.

Definition at line 178 of file nsRenderingContextImpl.cpp.

{
  nsTransform2D *theTransform; 
  GetCurrentTransform(theTransform);
  NS_ASSERTION(theTransform != nsnull, "The rendering context transform is null");
  theTransform->SetTranslation(aState->mSavedX, aState->mSavedY);

  return NS_OK;
}

Here is the call graph for this function:

Save a graphical state onto a stack.

Implements nsIRenderingContext.

Definition at line 373 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::PushState()\n"));
  GraphicsState *state = new GraphicsState();

  if (!state)
    return NS_ERROR_OUT_OF_MEMORY;

  state->mMatrix = mTranMatrix;
  
  mStateCache.AppendElement(state);
  
  if (nsnull == mTranMatrix)
    mTranMatrix = new nsTransform2D();
  else
    mTranMatrix = new nsTransform2D(mTranMatrix);
  
  if (mClipRegion) {
    state->mClipRegion = mClipRegion;
    mClipRegion = new nsRegionXlib();
    if (!mClipRegion)
      return NS_ERROR_OUT_OF_MEMORY;
    mClipRegion->Init();
    mClipRegion->SetTo(*state->mClipRegion);
  }
  
  state->mFontMetrics = mFontMetrics;
  state->mColor       = mCurrentColor;
  state->mLineStyle   = mCurrentLineStyle;
  
  return NS_OK;
}

Here is the caller graph for this function:

Implements nsIRenderingContext.

Definition at line 155 of file nsRenderingContextImpl.cpp.

{
  // The transform components are saved and restored instead 
  // of using PushState and PopState because they are too slow
  // because they also save and restore the clip state.
  // Note: Setting a negative translation to restore the 
  // state does not work because the floating point errors can accumulate
  // causing the display of some frames to be off by one pixel. 
  // This happens frequently when running in 120DPI mode where frames are
  // often positioned at 1/2 pixel locations and small floating point errors
  // will cause the frames to vary their pixel x location during scrolling
  // operations causes a single scan line of pixels to be shifted left relative
  // to the other scan lines for the same text. 
  
  // Save the transformation matrix's translation components.
  nsTransform2D *theTransform; 
  GetCurrentTransform(theTransform);
  NS_ASSERTION(theTransform != nsnull, "The rendering context transform is null");
  theTransform->GetTranslation(&aState->mSavedX, &aState->mSavedY);
  
  return NS_OK;
}

Here is the call graph for this function:

PRBool nsRenderingContextImpl::RectFitsInside ( const nsRect aRect,
PRInt32  aWidth,
PRInt32  aHeight 
) const [protected, inherited]

Determine if a rect's width and height will fit within a specified width and height.

Parameters:
aRectrectangle to test
aWidthwidth to determine if the rectangle's width will fit within
aHeightheight to determine if the rectangles height will fit within
Returns:
PR_TRUE if the rect width and height fits with aWidth, aHeight, PR_FALSE otherwise.

Definition at line 188 of file nsRenderingContextImpl.cpp.

{
  if (aRect.width > aWidth)
    return (PR_FALSE);

  if (aRect.height > aHeight)
    return (PR_FALSE);

  return PR_TRUE;
}

Here is the caller graph for this function:

Release a drawing surface used as the backbuffer If the platform caches the backbuffer this call will destroy it.

Reimplemented from nsRenderingContextImpl.

Definition at line 2530 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::ReleaseBackbuffer()\n"));
  /* Do not cache the backbuffer. On X11 it is more efficient to allocate
   * the backbuffer as needed and it doesn't cause a performance hit. @see bug 95952 */
  return DestroyCachedBackbuffer();
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextXp::RenderEPS ( const nsRect aRect,
FILE aDataFile 
) [virtual]

Render an encapsulated postscript object onto the current rendering surface.

The EPS object must conform to the EPSF standard. See Adobe specification #5002, "Encapsulated PostScript File Format Specification" at http://partners.adobe.com/asn/developer/pdfs/tn/5002.EPSF_Spec.pdf. In particular, the EPS object must contain a BoundingBox comment.

Parameters:
aRectRectangle in which to render the EPSF.
aDataFile- plugin data stored in a file
Returns:
NS_OK for success, or a suitable error value. NS_ERROR_NOT_IMPLEMENTED is returned if the rendering context doesn't support rendering EPSF,

Reimplemented from nsRenderingContextImpl.

Definition at line 268 of file nsRenderingContextXp.cpp.

{
  nsresult             rv;
  int                  fd;
  const unsigned char *data;
  size_t               datalen;

  PR_LOG(RenderingContextXpLM, PR_LOG_DEBUG, ("nsRenderingContextXp::RenderPostScriptDataFragment()\n"));

  /* Get file size */
  fseek(aDataFile, 0, SEEK_END);
  datalen = ftell(aDataFile);

  PR_LOG(RenderingContextXpLM, PR_LOG_DEBUG, ("file size=%ld\n", (long)datalen));  

  /* Safeguard against bogus values
   * (make sure we clamp the size to a reasonable value (say... 128 MB)) */
  if (datalen <= 0 || datalen > (128 * 1024 * 1024)) {
    PR_LOG(RenderingContextXpLM, PR_LOG_DEBUG, ("error: file size %ld too large\n", (long)datalen));
    return NS_ERROR_FAILURE;
  }
  
  fflush(aDataFile);
  fd = fileno(aDataFile);
  PR_LOG(RenderingContextXpLM, PR_LOG_DEBUG, ("fileno=%d\n", fd));  
  data = (const unsigned char *)mmap(0, datalen, PROT_READ, MAP_SHARED, fd, 0); 
  if (MAP_FAILED == data) {
    int saved_errno = errno;
    PR_LOG(RenderingContextXpLM, PR_LOG_DEBUG, ("mmap() failure, errno=%s/%d\n",
           strerror(saved_errno), saved_errno));  
    return nsresultForErrno(saved_errno);
  }

  PushState();

  nsRect trect = aRect;
  mTranMatrix->TransformCoord(&trect.x, &trect.y, &trect.width, &trect.height);
  UpdateGC();
  rv = mPrintContext->RenderEPS(mSurface->GetDrawable(), trect, data, datalen);

  PopState();
  
  munmap((char *)data, datalen);

  return rv;
}

Here is the call graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::Reset ( void  ) [virtual, inherited]

Reset the rendering context.

Implements nsIRenderingContext.

Definition at line 359 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::Reset()\n"));
  return NS_OK;
}

Implements nsIRenderingContext.

Definition at line 2334 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::RetrieveCurrentNativeGraphicData()\n"));
  *ngd = nsnull;
  return NS_OK;
}
NS_IMETHODIMP nsRenderingContextXlib::Scale ( float  aSx,
float  aSy 
) [virtual, inherited]

Add in a scale to the RenderingContext's transformation matrix.

Parameters:
aXThe horizontal scale
aYThe vertical scale

Implements nsIRenderingContext.

Definition at line 737 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::Scale()\n"));
  mTranMatrix->AddScale(aSx, aSy);
  return NS_OK;
}

Selects an offscreen drawing surface into the RenderingContext to draw to.

Parameters:
aSurfaceis the offscreen surface we are going to draw to. if nsnull, the original drawing surface obtained at initialization should be selected.

Implements nsIRenderingContext.

Definition at line 339 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::SelectOffScreenDrawingSurface()\n"));
  if (nsnull == aSurface)
    mSurface = mOffscreenSurface;
  else
    mSurface = (nsIDrawingSurfaceXlib *)aSurface;

  return NS_OK;
}
NS_IMETHODIMP nsRenderingContextXlib::SetClipRect ( const nsRect aRect,
nsClipCombine  aCombine 
) [virtual, inherited]

Sets the clipping for the RenderingContext to the passed in rectangle.

The rectangle is in app units!

Parameters:
aRectThe rectangle to set the clipping rectangle to
aCombinehow to combine this rect with the current clip region. see the bottom of nsIRenderingContext.h

Implements nsIRenderingContext.

Definition at line 486 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::SetClipRect()\n"));
  nsRect trect = aRect;
  mTranMatrix->TransformCoord(&trect.x, &trect.y,
                              &trect.width, &trect.height);
  SetClipRectInPixels(trect, aCombine);
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 497 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::SetClipRectInPixels()\n"));

  switch(aCombine)
  {
    case nsClipCombine_kIntersect:
      mClipRegion->Intersect(aRect.x,aRect.y,aRect.width,aRect.height);
      break;
    case nsClipCombine_kUnion:
      mClipRegion->Union(aRect.x,aRect.y,aRect.width,aRect.height);
      break;
    case nsClipCombine_kSubtract:
      mClipRegion->Subtract(aRect.x,aRect.y,aRect.width,aRect.height);
      break;
    case nsClipCombine_kReplace:
      mClipRegion->SetTo(aRect.x,aRect.y,aRect.width,aRect.height);
      break;
  }
}

Here is the caller graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::SetClipRegion ( const nsIRegion aRegion,
nsClipCombine  aCombine 
) [virtual, inherited]

Sets the clipping for the RenderingContext to the passed in region.

The region is in device coordinates!

Parameters:
aRegionThe region to set the clipping area to, IN DEVICE COORDINATES
aCombinehow to combine this region with the current clip region. see the bottom of nsIRenderingContext.h

Implements nsIRenderingContext.

Definition at line 536 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::SetClipRegion()\n"));
  switch(aCombine)
  {
    case nsClipCombine_kIntersect:
      mClipRegion->Intersect(aRegion);
      break;
    case nsClipCombine_kUnion:
      mClipRegion->Union(aRegion);
      break;
    case nsClipCombine_kSubtract:
      mClipRegion->Subtract(aRegion);
      break;
    case nsClipCombine_kReplace:
      mClipRegion->SetTo(aRegion);
      break;
  }

  return NS_OK;
}
NS_IMETHODIMP nsRenderingContextXlib::SetColor ( nscolor  aColor) [virtual, inherited]

Sets the forground color for the RenderingContext.

Parameters:
aColorThe color to set the RenderingContext to

Implements nsIRenderingContext.

Definition at line 626 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::SetColor(nscolor)\n"));
  NS_ENSURE_TRUE(mContext != nsnull, NS_ERROR_FAILURE);

  mCurrentColor = aColor;

  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("Setting color to %d %d %d\n", NS_GET_R(aColor), NS_GET_G(aColor), NS_GET_B(aColor)));
  return NS_OK;
}

Here is the caller graph for this function:

Definition at line 231 of file nsRenderingContextXlib.h.

{ mCurrentFont = cf; };
NS_IMETHODIMP nsRenderingContextXlib::SetFont ( const nsFont aFont,
nsIAtom aLangGroup 
) [virtual, inherited]

Sets the font for the RenderingContext.

Parameters:
aFontThe font to use in the RenderingContext

Implements nsIRenderingContext.

Definition at line 647 of file nsRenderingContextXlib.cpp.

{
  nsCOMPtr<nsIFontMetrics> newMetrics;
  nsresult rv = mContext->GetMetricsFor( aFont, aLangGroup, *getter_AddRefs(newMetrics) );

  if (NS_SUCCEEDED(rv)) {
    rv = SetFont(newMetrics);
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsRenderingContextXlib::SetFont ( nsIFontMetrics aFontMetrics) [virtual, inherited]

Sets the font for the RenderingContext.

Parameters:
aFontMetricThe font metrics representing the font to use in the RenderingContext

Implements nsIRenderingContext.

Definition at line 659 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::SetFont()\n"));

  mFontMetrics = aFontMetrics;

  if (mFontMetrics)
  {
    nsFontHandle  fontHandle;
    mFontMetrics->GetFontHandle(fontHandle);
    mCurrentFont = (nsFontXlib *)fontHandle;
  }

  return NS_OK;
}
NS_IMETHODIMP nsRenderingContextXlib::SetLineStyle ( nsLineStyle  aLineStyle) [virtual, inherited]

Sets the line style for the RenderingContext.

Parameters:
aLineStyleThe line style
Returns:
NS_OK if the line style is correctly set

Implements nsIRenderingContext.

Definition at line 676 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::SetLineStyle()\n"));

  if (aLineStyle != mCurrentLineStyle) {
    /* XXX this isnt done in gtk, copy from there when ready
    switch(aLineStyle)
      { 
      case nsLineStyle_kSolid:
        mLineStyle = LineSolid;
        mDashes = 0;
        break;
      case nsLineStyle_kDashed:
          static char dashed[2] = {4,4};
        mDashList = dashed;
        mDashes = 2;
        break;
      case nsLineStyle_kDotted:
          static char dotted[2] = {3,1};
        mDashList = dotted;
        mDashes = 2;
        break;
    default:
        break;

    }
    */
    mCurrentLineStyle = aLineStyle ;
  }
  return NS_OK;
}

Here is the caller graph for this function:

NS_IMETHOD nsRenderingContextImpl::SetPenMode ( nsPenMode  aPenMode) [inline, virtual, inherited]

Sets the Pen Mode for the RenderingContext.

Parameters:
aPenModeThe Pen Mode
Returns:
NS_OK if the Pen Mode is correctly set

Implements nsIRenderingContext.

Reimplemented in nsRenderingContextWin.

Definition at line 90 of file nsRenderingContextImpl.h.

{ return NS_ERROR_FAILURE;};

Let the device context know whether we want text reordered with right-to-left base direction.

Implements nsIRenderingContext.

Reimplemented in nsRenderingContextWin, nsRenderingContextGTK, and nsRenderingContextMac.

Definition at line 287 of file nsRenderingContextImpl.cpp.

{
  return NS_OK;
}
NS_IMETHODIMP nsRenderingContextXlib::Translate ( nscoord  aX,
nscoord  aY 
) [virtual, inherited]

Add in a translate to the RenderingContext's transformation matrix.

Parameters:
aXThe horizontal translation
aYThe vertical translation

Implements nsIRenderingContext.

Definition at line 728 of file nsRenderingContextXlib.cpp.

{
  PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::Translate()\n"));
  mTranMatrix->AddTranslation((float)aX,(float)aY);
  return NS_OK;
}

Unlock a rect of the drawing surface associated with the rendering context.

see nsIDrawingSurface.h for more information.

Returns:
error status

Reimplemented from nsRenderingContextXlib.

Definition at line 125 of file nsRenderingContextXp.cpp.

{
  PR_LOG(RenderingContextXpLM, PR_LOG_DEBUG, ("nsRenderingContextXp::UnlockDrawingSurface()\n"));
  PopState();
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 580 of file nsRenderingContextXlib.cpp.

{
   PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::UpdateGC()\n"));
   XGCValues     values;
   unsigned long valuesMask = 0;

   Drawable drawable; mOffscreenSurface->GetDrawable(drawable);
 
   if (mGC)
     mGC->Release();
 
   memset(&values, 0, sizeof(XGCValues));
 
   unsigned long color;
   color = xxlib_rgb_xpixel_from_rgb (mXlibRgbHandle,
                                      NS_RGB(NS_GET_B(mCurrentColor),
                                             NS_GET_G(mCurrentColor),
                                             NS_GET_R(mCurrentColor)));
   values.foreground = color;
   valuesMask |= GCForeground;

   if (mCurrentFont && mCurrentFont->GetXFontStruct()) {
     valuesMask |= GCFont;
     values.font = mCurrentFont->GetXFontStruct()->fid;
   }
 
   values.line_style = mLineStyle;
   valuesMask |= GCLineStyle;
 
   values.function = mFunction;
   valuesMask |= GCFunction;

   Region rgn = nsnull;
   if (mClipRegion) { 
     mClipRegion->GetNativeRegion((void*&)rgn);
   }

   nsRenderingContextXlibContext *rcContext;
   nsIDeviceContext *dc = mContext;
   NS_STATIC_CAST(nsDeviceContextX *, dc)->GetRCContext(rcContext);
   
   mGC = rcContext->mGcCache.GetGC(mDisplay, drawable,
                                  valuesMask, &values, rgn);
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsRenderingContextImpl::UseBackbuffer ( PRBool aUseBackbuffer) [virtual, inherited]

Some platforms may not want a backbuffer at all.

Returning false here allows them to achieve that

Parameters:
aUseBackbufferPR_TRUE if we should use a backbuffer, PR_FALSE if not

Implements nsIRenderingContext.

Reimplemented in nsRenderingContextMac.

Definition at line 149 of file nsRenderingContextImpl.cpp.

{
  *aUseBackbuffer = PR_TRUE;
  return NS_OK;
}

Member Data Documentation

int nsRenderingContextImpl::mAct [protected, inherited]

Definition at line 65 of file nsRenderingContextImpl.h.

Edge* nsRenderingContextImpl::mActive [protected, inherited]

Definition at line 66 of file nsRenderingContextImpl.h.

Definition at line 242 of file nsRenderingContextXlib.h.

Definition at line 238 of file nsRenderingContextXlib.h.

Definition at line 253 of file nsRenderingContextXlib.h.

Definition at line 257 of file nsRenderingContextXlib.h.

Definition at line 258 of file nsRenderingContextXlib.h.

int nsRenderingContextXlib::mDashes [protected, inherited]

Definition at line 252 of file nsRenderingContextXlib.h.

char* nsRenderingContextXlib::mDashList [protected, inherited]

Definition at line 251 of file nsRenderingContextXlib.h.

Display* nsRenderingContextXlib::mDisplay [protected, inherited]

Definition at line 255 of file nsRenderingContextXlib.h.

Definition at line 241 of file nsRenderingContextXlib.h.

int nsRenderingContextXlib::mFunction [protected, inherited]

Definition at line 249 of file nsRenderingContextXlib.h.

xGC* nsRenderingContextXlib::mGC [protected, inherited]

Definition at line 248 of file nsRenderingContextXlib.h.

int nsRenderingContextXlib::mLineStyle [protected, inherited]

Definition at line 250 of file nsRenderingContextXlib.h.

Definition at line 239 of file nsRenderingContextXlib.h.

float nsRenderingContextXlib::mP2T [protected, inherited]

Definition at line 243 of file nsRenderingContextXlib.h.

Definition at line 321 of file nsRenderingContextImpl.h.

Definition at line 73 of file nsRenderingContextXp.h.

nsAutoVoidArray nsRenderingContextXlib::mStateCache [protected, inherited]

Definition at line 246 of file nsRenderingContextXlib.h.

Definition at line 240 of file nsRenderingContextXlib.h.

nsTransform2D* nsRenderingContextImpl::mTranMatrix [protected, inherited]

Definition at line 64 of file nsRenderingContextImpl.h.

XlibRgbHandle* nsRenderingContextXlib::mXlibRgbHandle [protected, inherited]

Definition at line 254 of file nsRenderingContextXlib.h.


The documentation for this class was generated from the following files: