Back to index

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

#include <nsCairoRenderingContext.h>

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

List of all members.

Public Member Functions

 nsCairoRenderingContext ()
virtual ~nsCairoRenderingContext ()
NS_DECL_ISUPPORTS NS_IMETHOD Init (nsIDeviceContext *aContext, nsIWidget *aWidget)
 Initialize the RenderingContext.
NS_IMETHOD Init (nsIDeviceContext *aContext, nsIDrawingSurface *aSurface)
 Initialize the RenderingContext.
NS_IMETHOD CommonInit (void)
NS_IMETHOD Reset (void)
 Reset the rendering context.
NS_IMETHOD GetDeviceContext (nsIDeviceContext *&aDeviceContext)
 Get the DeviceContext that this RenderingContext was initialized with.
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 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 &aIsVisible)
 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 &aHasLocalClip)
 Gets the bounds of the clip region of the RenderingContext.
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 GetPenMode (nsPenMode &aPenMode)
 Gets the Pen Mode for the RenderingContext.
NS_IMETHOD SetPenMode (nsPenMode aPenMode)
 Sets the Pen Mode for 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 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 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 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=nsnull)
 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=nsnull)
 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=nsnull)
 Returns the width (in app units) of a Unicode character string If no font has been Set, the results are undefined.
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=nsnull)
NS_IMETHOD DrawString (const char *aString, PRUint32 aLength, nscoord aX, nscoord aY, const nscoord *aSpacing=nsnull)
 Draw a string in the RenderingContext.
NS_IMETHOD DrawString (const PRUnichar *aString, PRUint32 aLength, nscoord aX, nscoord aY, PRInt32 aFontID=-1, const nscoord *aSpacing=nsnull)
 Draw a string in the RenderingContext.
NS_IMETHOD DrawString (const nsString &aString, nscoord aX, nscoord aY, PRInt32 aFontID=-1, const nscoord *aSpacing=nsnull)
 Draw a string in the RenderingContext.
NS_IMETHOD CopyOffScreenBits (nsIDrawingSurface *aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY, const nsRect &aDestBounds, PRUint32 aCopyFlags)
 Copy offscreen pixelmap to this RenderingContext.
NS_IMETHOD RetrieveCurrentNativeGraphicData (PRUint32 *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.
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)
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 aXOffset, nscoord aYOffset, const nsRect *aTargetRect)
NS_IMETHOD SetRightToLeftText (PRBool aIsRTL)
 Let the device context know whether we want text reordered with right-to-left base direction.
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 RenderEPS (const nsRect &aRect, FILE *aDataFile)
 Render an encapsulated postscript object onto the current rendering surface.
cairo_t * GetCairo ()
nsTransform2D & CurrentTransform ()
void TransformCoord (nscoord *aX, nscoord *aY)
NS_IMETHOD RetrieveCurrentNativeGraphicData (void **ngd)=0

Protected Member Functions

PRBool DoCairoDrawPolygon (const nsPoint aPoints[], PRInt32 aNumPoints)
void DoCairoDrawEllipse (double aX, double aY, double aWidth, double aHeight)
void DoCairoDrawArc (double aX, double aY, double aWidth, double aHeight, double aStartAngle, double aEndAngle)
void DoCairoClip ()
void UpdateTempTransformMatrix ()

Protected Attributes

nsCOMPtr< nsIDeviceContextmDeviceContext
nsCOMPtr< nsIWidgetmWidget
nsCOMPtr< nsIRegionmClipRegion
nsCOMPtr< nsICairoFontMetricsmFontMetrics
nsLineStyle mLineStyle
nscolor mColor
cairo_t * mCairo
nsCOMPtr< nsCairoDrawingSurfacemDrawingSurface
nsCOMPtr< nsCairoDrawingSurfacemOffscreenSurface
nsCOMPtr< nsCairoDrawingSurfacemBackBufferSurface
nsTransform2D mTempTransform

Detailed Description

Definition at line 63 of file nsCairoRenderingContext.h.


Constructor & Destructor Documentation

Definition at line 77 of file nsCairoRenderingContext.cpp.


Member Function Documentation

Definition at line 121 of file nsCairoRenderingContext.cpp.

{
    mClipRegion = new nsCairoRegion();

    float app2dev;
    app2dev = mDeviceContext->AppUnitsToDevUnits();
    Scale(app2dev, app2dev);

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

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 337 of file nsCairoRenderingContext.cpp.

{
    aRegion.SetTo(*mClipRegion);
    return NS_OK;
}

Here is the call graph for this function:

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

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 737 of file nsCairoRenderingContext.cpp.

{
    nsCairoDrawingSurface *cds = (nsCairoDrawingSurface *) aSrcSurf;

    fprintf (stderr, "***** nsCairoRenderingContext::CopyOffScreenBits: [%p] %d,%d -> %d,%d %dx%d\n",
             aSrcSurf, aSrcX, aSrcY, aDestBounds.x, aDestBounds.y, aDestBounds.width, aDestBounds.height);

    PRUint32 srcWidth, srcHeight;
    cds->GetDimensions (&srcWidth, &srcHeight);

    double sx, sy, dx, dy, dw, dh;
    // figure out pixel positions
    sx = double(aSrcX);
    sy = double(aSrcY);
    dx = double(aDestBounds.x);
    dy = double(aDestBounds.y);
    dw = double(aDestBounds.width);
    dh = double(aDestBounds.height);

    if (aCopyFlags & NS_COPYBITS_XFORM_SOURCE_VALUES) {
        cairo_transform_point (mCairo, &sx, &sy);
    }

    if (aCopyFlags & NS_COPYBITS_XFORM_DEST_VALUES) {
        cairo_transform_point (mCairo, &dx, &dy);
        cairo_transform_distance (mCairo, &dw, &dh);
    }

    fprintf (stderr, "***** --> %g,%g [%d,%d] -> %g,%g %gx%g\n", sx, sy, srcWidth, srcHeight, dx, dy, dw, dh);
    cairo_save (mCairo);
    cairo_init_clip (mCairo);

    cairo_set_rgb_color (mCairo, 0.0, 0.0, 1.0);
    cairo_set_alpha (mCairo, 0.5);

    cairo_rectangle(mCairo, dx, dy, dw, dh);
    cairo_fill(mCairo);

    // args are in pixels!!
    cairo_identity_matrix (mCairo);

    // clip to target
    cairo_rectangle(mCairo, dx, dy, dw, dh);
    cairo_clip(mCairo);

    cairo_scale(mCairo, dw / double(srcWidth), dh / double(srcHeight));
    cairo_translate(mCairo, dx - sx, dy - sy);

//    cairo_show_surface(mCairo, src, srcWidth, srcHeight);

    cairo_restore (mCairo);

    return NS_OK;
}

Here is the call graph for this function:

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

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 509 of file nsCairoRenderingContext.cpp.

{
    nsCairoDrawingSurface *cds = new nsCairoDrawingSurface();
    nsIDeviceContext *dc = mDeviceContext.get();
    cds->Init (NS_STATIC_CAST(nsCairoDeviceContext *, dc),
               aBounds.width, aBounds.height,
               PR_FALSE);
    aSurface = (nsIDrawingSurface*) cds;
    NS_ADDREF(aSurface);

    return NS_OK;
}

Here is the call graph for this function:

Definition at line 484 of file nsCairoRenderingContext.cpp.

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 842 of file nsCairoRenderingContext.cpp.

{
    mBackBufferSurface = NULL;
    return NS_OK;
//    NS_WARNING("DestroyCachedBackbuffer: not implemented");
//    return NS_ERROR_NOT_IMPLEMENTED;
}

Destroy a drawing surface created by CreateDrawingSurface()

Parameters:
aDSA drawing surface to destroy

Implements nsIRenderingContext.

Definition at line 525 of file nsCairoRenderingContext.cpp.

{
    NS_RELEASE(aDS);

    return NS_OK;
}

Definition at line 261 of file nsCairoRenderingContext.cpp.

{
    nsRegionComplexity cplx;
    mClipRegion->GetRegionComplexity(cplx);

    cairo_init_clip (mCairo);

    float pixToTwip = mDeviceContext->DevUnitsToAppUnits();

    if (cplx == eRegionComplexity_rect) {
        PRInt32 x, y, w, h;
        mClipRegion->GetBoundingBox(&x, &y, &w, &h);
        cairo_new_path (mCairo);
        cairo_rectangle (mCairo,
                         double(x * pixToTwip),
                         double(y * pixToTwip),
                         double(w * pixToTwip),
                         double(h * pixToTwip));
        cairo_clip (mCairo);
    } else if (cplx == eRegionComplexity_complex) {
        nsRegionRectSet *rects = nsnull;
        nsresult rv = mClipRegion->GetRects (&rects);
        if (NS_FAILED(rv) || !rects)
            return;

        cairo_new_path (mCairo);
        for (PRUint32 i = 0; i < rects->mRectsLen; i++) {
            cairo_rectangle (mCairo,
                             double (rects->mRects[i].x * pixToTwip),
                             double (rects->mRects[i].y * pixToTwip),
                             double (rects->mRects[i].width * pixToTwip),
                             double (rects->mRects[i].height * pixToTwip));
        }

        cairo_clip (mCairo);

        mClipRegion->FreeRects (rects);
    }
}

Here is the caller graph for this function:

void nsCairoRenderingContext::DoCairoDrawArc ( double  aX,
double  aY,
double  aWidth,
double  aHeight,
double  aStartAngle,
double  aEndAngle 
) [protected]

Definition at line 697 of file nsCairoRenderingContext.cpp.

{
    cairo_new_path (mCairo);

    // XXX - cairo can't do arcs with differing start and end radii.
    // I guess it's good that no code ever draws arcs.
}
void nsCairoRenderingContext::DoCairoDrawEllipse ( double  aX,
double  aY,
double  aWidth,
double  aHeight 
) [protected]

Definition at line 644 of file nsCairoRenderingContext.cpp.

{
    cairo_new_path (mCairo);
    cairo_move_to (mCairo, aX + aWidth/2.0, aY);
    cairo_curve_to (mCairo,
                    aX + aWidth, aY,
                    aX + aWidth, aY,
                    aX + aWidth, aY + aHeight/2.0);
    cairo_curve_to (mCairo,
                    aX + aWidth, aY + aHeight,
                    aX + aWidth, aY + aHeight,
                    aX + aWidth/2.0, aY);
    cairo_curve_to (mCairo,
                    aX, aY + aHeight,
                    aX, aY + aHeight,
                    aX, aY + aHeight/2.0);
    cairo_curve_to (mCairo,
                    aX, aY,
                    aX, aY,
                    aX + aWidth/2.0, aY);
}

Here is the caller graph for this function:

PRBool nsCairoRenderingContext::DoCairoDrawPolygon ( const nsPoint  aPoints[],
PRInt32  aNumPoints 
) [protected]

Definition at line 591 of file nsCairoRenderingContext.cpp.

{
    if (aNumPoints < 2)
        return PR_FALSE;

    cairo_new_path (mCairo);
    cairo_move_to (mCairo, (double) aPoints[0].x, (double) aPoints[0].y);
    for (PRInt32 i = 1; i < aNumPoints; ++i) {
        cairo_line_to (mCairo, (double) aPoints[i].x, (double) aPoints[i].y);
    }
    return PR_TRUE;
}

Here is the caller graph for this function:

NS_IMETHODIMP nsCairoRenderingContext::DrawArc ( const nsRect aRect,
float  aStartAngle,
float  aEndAngle 
) [virtual]

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 707 of file nsCairoRenderingContext.cpp.

{
    return DrawArc(aRect.x, aRect.y, aRect.width, aRect.height, aStartAngle, aEndAngle);
}
NS_IMETHODIMP nsCairoRenderingContext::DrawArc ( nscoord  aX,
nscoord  aY,
nscoord  aWidth,
nscoord  aHeight,
float  aStartAngle,
float  aEndAngle 
) [virtual]

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 714 of file nsCairoRenderingContext.cpp.

{
    NS_ERROR("not used");
    return NS_OK;
}

Draw an ellipse in the current foreground color.

Parameters:
aRectThe rectangle define bounds of ellipse to draw

Implements nsIRenderingContext.

Definition at line 667 of file nsCairoRenderingContext.cpp.

{
    return DrawEllipse(aRect.x, aRect.y, aRect.width, aRect.height);
}
NS_IMETHODIMP nsCairoRenderingContext::DrawEllipse ( nscoord  aX,
nscoord  aY,
nscoord  aWidth,
nscoord  aHeight 
) [virtual]

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 673 of file nsCairoRenderingContext.cpp.

{
    DoCairoDrawEllipse ((double) aX, (double) aY, (double) aWidth, (double) aHeight);
    cairo_stroke (mCairo);

    return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsCairoRenderingContext::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.

Implements nsIRenderingContext.

Definition at line 851 of file nsCairoRenderingContext.cpp.

{
    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;

    // For Bug 87819
    // iframe may want image to start at different position, so adjust
    nsRect iframeRect;
    iframe->GetRect(iframeRect);
  
    // aSrcRect is always in appunits, it has
    // nothing to do with the current transform
    float app2dev;
    app2dev = mDeviceContext->AppUnitsToDevUnits();
    nsRect sr;
    sr.x = NSToIntRound(app2dev*aSrcRect.x);
    sr.y = NSToIntRound(app2dev*aSrcRect.y);
    sr.width = NSToIntRound(app2dev*aSrcRect.XMost()) - sr.x;
    sr.height = NSToIntRound(app2dev*aSrcRect.YMost()) - sr.y;
    
    nsRect dr = aDestRect;
    if (iframeRect != sr) {
        double xscale = double(aDestRect.width)/sr.width;
        double yscale = double(aDestRect.height)/sr.height;
        nsRect scaledUpIRect;
        scaledUpIRect.x = NSToCoordRound(iframeRect.x*xscale);
        scaledUpIRect.y = NSToCoordRound(iframeRect.y*yscale);
        scaledUpIRect.width = NSToCoordRound(iframeRect.XMost()*xscale) - scaledUpIRect.x;
        scaledUpIRect.height = NSToCoordRound(iframeRect.YMost()*yscale) - scaledUpIRect.y;

        sr.IntersectRect(sr, iframeRect);
        dr.IntersectRect(dr, scaledUpIRect);
    }

    return img->Draw(*this, mDrawingSurface, sr.x - iframeRect.x, sr.y - iframeRect.y,
                     sr.width, sr.height,
                     dr.x, dr.y, dr.width, dr.height);
}

Here is the call graph for this function:

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

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 533 of file nsCairoRenderingContext.cpp.

{
    // XXX are these twips?
    cairo_new_path (mCairo);
    cairo_move_to (mCairo, (double) aX0, (double) aY0);
    cairo_line_to (mCairo, (double) aX1, (double) aY1);
    cairo_stroke (mCairo);

    return NS_OK;
}
NS_IMETHODIMP nsCairoRenderingContext::DrawPolygon ( const nsPoint  aPoints[],
PRInt32  aNumPoints 
) [virtual]

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 618 of file nsCairoRenderingContext.cpp.

{
    // I'm assuming the difference between a polygon and a polyline is that this one
    // implicitly closes

    if (!DoCairoDrawPolygon(aPoints, aNumPoints))
        return NS_OK;

    cairo_close_path(mCairo);
    cairo_stroke(mCairo);
    return NS_OK;
}

Here is the call graph for this function:

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

Draw a polyline.

Parameters:
aPointsarray of endpoints
aNumPontsnumber of points

Implements nsIRenderingContext.

Definition at line 607 of file nsCairoRenderingContext.cpp.

{
    if (!DoCairoDrawPolygon(aPoints, aNumPoints))
        return NS_OK;

    cairo_stroke (mCairo);
    return NS_OK;
}

Here is the call graph for this function:

Draw a rectangle.

Parameters:
aRectThe rectangle to draw

Implements nsIRenderingContext.

Definition at line 545 of file nsCairoRenderingContext.cpp.

{
    return DrawRect(aRect.x, aRect.y, aRect.width, aRect.height);
}
NS_IMETHODIMP nsCairoRenderingContext::DrawRect ( nscoord  aX,
nscoord  aY,
nscoord  aWidth,
nscoord  aHeight 
) [virtual]

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 551 of file nsCairoRenderingContext.cpp.

{
    cairo_new_path (mCairo);
    cairo_rectangle (mCairo, (double) aX, (double) aY, (double) aWidth, (double) aHeight);
    cairo_stroke (mCairo);
    return NS_OK;
}
NS_IMETHODIMP nsCairoRenderingContext::DrawString ( const char *  aString,
PRUint32  aLength,
nscoord  aX,
nscoord  aY,
const nscoord aSpacing = nsnull 
) [virtual]

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

Implements nsIRenderingContext.

Definition at line 1086 of file nsCairoRenderingContext.cpp.

{
    return mFontMetrics->DrawString(aString, aLength, aX, aY, aSpacing,
                                    this, mDrawingSurface);

#if 0
    NS_WARNING("DrawString 1");
    cairo_move_to(mCairo, double(aX), double(aY));
    cairo_new_path (mCairo);
    cairo_text_path (mCairo, (const unsigned char *) aString);
    cairo_fill (mCairo);
    cairo_move_to(mCairo, -double(aX), -double(aY));
#endif
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsCairoRenderingContext::DrawString ( const PRUnichar aString,
PRUint32  aLength,
nscoord  aX,
nscoord  aY,
PRInt32  aFontID = -1,
const nscoord aSpacing = nsnull 
) [virtual]

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

Implements nsIRenderingContext.

Definition at line 1105 of file nsCairoRenderingContext.cpp.

{
    return mFontMetrics->DrawString(aString, aLength, aX, aY, aFontID,
                                    aSpacing, this, mDrawingSurface);
}
NS_IMETHODIMP nsCairoRenderingContext::DrawString ( const nsString aString,
nscoord  aX,
nscoord  aY,
PRInt32  aFontID = -1,
const nscoord aSpacing = nsnull 
) [virtual]

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

Implements nsIRenderingContext.

Definition at line 1115 of file nsCairoRenderingContext.cpp.

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

Here is the call graph for this function:

NS_IMETHODIMP nsCairoRenderingContext::DrawTile ( imgIContainer aImage,
nscoord  aXOffset,
nscoord  aYOffset,
const nsRect aTargetRect 
) [virtual]

Implements nsIRenderingContext.

Definition at line 897 of file nsCairoRenderingContext.cpp.

{
    nscoord width, height;
    aImage->GetWidth(&width);
    aImage->GetHeight(&height);

    if (width == 0 || height == 0)
        return PR_FALSE;

    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;

    // For Bug 87819
    // iframe may want image to start at different position, so adjust
    nsRect iframeRect;
    iframe->GetRect(iframeRect);
  
    // offsets are always in appunits, they have
    // nothing to do with the current transform
    float app2dev;
    app2dev = mDeviceContext->AppUnitsToDevUnits();
    nsPoint s;
    s.x = NSToIntRound(app2dev*aXOffset);
    s.y = NSToIntRound(app2dev*aYOffset);
    
    PRInt32 padx = width - iframeRect.width;
    PRInt32 pady = height - iframeRect.height;

    return img->DrawTile(*this, mDrawingSurface, s.x - iframeRect.x, s.y - iframeRect.y,
                         padx, pady, *aTargetRect);
}

Here is the call graph for this function:

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

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 722 of file nsCairoRenderingContext.cpp.

{
    return FillArc(aRect.x, aRect.y, aRect.width, aRect.height, aStartAngle, aEndAngle);
}
NS_IMETHODIMP nsCairoRenderingContext::FillArc ( nscoord  aX,
nscoord  aY,
nscoord  aWidth,
nscoord  aHeight,
float  aStartAngle,
float  aEndAngle 
) [virtual]

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 729 of file nsCairoRenderingContext.cpp.

{
    NS_ERROR("not used");
    return NS_OK;
}

Fill an ellipse in the current foreground color.

Parameters:
aRectThe rectangle define bounds of ellipse to draw

Implements nsIRenderingContext.

Definition at line 682 of file nsCairoRenderingContext.cpp.

{
    return FillEllipse(aRect.x, aRect.y, aRect.width, aRect.height);
}
NS_IMETHODIMP nsCairoRenderingContext::FillEllipse ( nscoord  aX,
nscoord  aY,
nscoord  aWidth,
nscoord  aHeight 
) [virtual]

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 688 of file nsCairoRenderingContext.cpp.

{
    DoCairoDrawEllipse ((double) aX, (double) aY, (double) aWidth, (double) aHeight);
    cairo_fill (mCairo);

    return NS_OK;
}

Here is the call graph for this function:

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

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 632 of file nsCairoRenderingContext.cpp.

{
    if (!DoCairoDrawPolygon(aPoints, aNumPoints))
        return NS_OK;

    cairo_close_path(mCairo);
    cairo_fill(mCairo);

    return NS_OK;
}

Here is the call graph for this function:

Fill a rectangle in the current foreground color.

Parameters:
aRectThe rectangle to draw

Implements nsIRenderingContext.

Definition at line 560 of file nsCairoRenderingContext.cpp.

{
    return FillRect(aRect.x, aRect.y, aRect.width, aRect.height);
}

Here is the caller graph for this function:

NS_IMETHODIMP nsCairoRenderingContext::FillRect ( nscoord  aX,
nscoord  aY,
nscoord  aWidth,
nscoord  aHeight 
) [virtual]

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 566 of file nsCairoRenderingContext.cpp.

{
    cairo_new_path (mCairo);
    cairo_rectangle (mCairo, (double) aX, (double) aY, (double) aWidth, (double) aHeight);
    cairo_fill (mCairo);
    return NS_OK;
}

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.

Definition at line 354 of file nsCairoRenderingContext.cpp.

{
    return FlushRect(aRect.x, aRect.y, aRect.width, aRect.height);
}
NS_IMETHODIMP nsCairoRenderingContext::FlushRect ( nscoord  aX,
nscoord  aY,
nscoord  aWidth,
nscoord  aHeight 
) [virtual]

Implements nsIRenderingContext.

Definition at line 360 of file nsCairoRenderingContext.cpp.

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

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

Implements nsIRenderingContext.

Definition at line 811 of file nsCairoRenderingContext.cpp.

{
    if (!mBackBufferSurface) {
#if 1
        nsIDeviceContext *dc = mDeviceContext.get();
        mBackBufferSurface = new nsCairoDrawingSurface ();
        mBackBufferSurface->Init (NS_STATIC_CAST(nsCairoDeviceContext*, dc),
                                  aMaxSize.width, aMaxSize.height,
                                  PR_FALSE);
#else
        mBackBufferSurface = mDrawingSurface;
#endif
    }

    aBackbuffer = mBackBufferSurface;
    return NS_OK;
}

Here is the call graph for this function:

cairo_t* nsCairoRenderingContext::GetCairo ( ) [inline]

Definition at line 232 of file nsCairoRenderingContext.h.

{ return mCairo; }

Here is the caller graph for this function:

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

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 254 of file nsCairoRenderingContext.cpp.

{
    NS_ERROR("not used anywhere");
    return NS_OK;
}

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 344 of file nsCairoRenderingContext.cpp.

{
    *aRegion = new nsCairoRegion();
    (*aRegion)->SetTo(*mClipRegion);
    NS_ADDREF(*aRegion);
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsCairoRenderingContext::GetClusterInfo ( const PRUnichar aText,
PRUint32  aLength,
PRUint8 aClusterStarts 
) [virtual]

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.

Definition at line 1125 of file nsCairoRenderingContext.cpp.

Get the forground color for the RenderingContext.

Returns:
The current forground color of the RenderingContext

Implements nsIRenderingContext.

Definition at line 440 of file nsCairoRenderingContext.cpp.

{
    aColor = mColor;
    return NS_OK;
}

Here is the caller graph for this function:

NS_IMETHODIMP nsCairoRenderingContext::GetCurrentTransform ( nsTransform2D *&  aTransform) [virtual]

Get the current transformation matrix for the RenderingContext.

Returns:
The transformation matrix for the RenderingContext

Implements nsIRenderingContext.

Definition at line 491 of file nsCairoRenderingContext.cpp.

{
    UpdateTempTransformMatrix();
    aTransform = &mTempTransform;
    return NS_OK;
}

Here is the call graph for this function:

Get the DeviceContext that this RenderingContext was initialized with.

Returns:
the device context

Implements nsIRenderingContext.

Definition at line 147 of file nsCairoRenderingContext.cpp.

{
    aDeviceContext = mDeviceContext;
    NS_IF_ADDREF(aDeviceContext);
    return NS_OK;
}

Get the currently selected drawing surface.

Parameters:
aSurfaceout parameter for the current drawing surface

Implements nsIRenderingContext.

Definition at line 191 of file nsCairoRenderingContext.cpp.

{
    if (mOffscreenSurface)
        *aSurface = mOffscreenSurface;
    else if (mDrawingSurface)
        *aSurface = mDrawingSurface;

    NS_IF_ADDREF (*aSurface);
    
    return NS_OK;
}

Get the current fontmetrics for the RenderingContext.

Returns:
The current font of the RenderingContext

Implements nsIRenderingContext.

Definition at line 956 of file nsCairoRenderingContext.cpp.

{
    aFontMetrics = mFontMetrics;
    NS_IF_ADDREF(aFontMetrics);
    return NS_OK;
}

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 220 of file nsCairoRenderingContext.cpp.

{
    aResult = 0;

    return NS_OK;
}

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 398 of file nsCairoRenderingContext.cpp.

{
    NS_ERROR("not used anywhere");
    aLineStyle = mLineStyle;
    return NS_OK;
}

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.

Definition at line 414 of file nsCairoRenderingContext.cpp.

{
    //NS_ERROR("not used anywhere, but used in a debug thing");
    return NS_ERROR_NOT_IMPLEMENTED;
}
PRInt32 nsCairoRenderingContext::GetPosition ( const PRUnichar aText,
PRUint32  aLength,
nsPoint  aPt 
) [virtual]

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.

Definition at line 1133 of file nsCairoRenderingContext.cpp.

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

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.

Definition at line 1141 of file nsCairoRenderingContext.cpp.

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

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.

Definition at line 1151 of file nsCairoRenderingContext.cpp.

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

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)

Implements nsIRenderingContext.

Definition at line 1017 of file nsCairoRenderingContext.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 nsCairoRenderingContext::GetTextDimensions ( const PRUnichar aString,
PRUint32  aLength,
nsTextDimensions aDimensions,
PRInt32 aFontID = nsnull 
) [virtual]

Implements nsIRenderingContext.

Definition at line 1026 of file nsCairoRenderingContext.cpp.

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

Here is the call graph for this function:

NS_IMETHODIMP nsCairoRenderingContext::GetWidth ( char  aC,
nscoord aWidth 
) [virtual]

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 nsIRenderingContext.

Definition at line 964 of file nsCairoRenderingContext.cpp.

{
    if (aC == ' ' && mFontMetrics)
        return mFontMetrics->GetSpaceWidth(aWidth);

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

Here is the caller graph for this function:

NS_IMETHODIMP nsCairoRenderingContext::GetWidth ( PRUnichar  aC,
nscoord aWidth,
PRInt32 aFontID = nsnull 
) [virtual]

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 nsIRenderingContext.

Definition at line 973 of file nsCairoRenderingContext.cpp.

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

Here is the call graph for this function:

NS_IMETHODIMP nsCairoRenderingContext::GetWidth ( const nsString aString,
nscoord aWidth,
PRInt32 aFontID = nsnull 
) [virtual]

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

Implements nsIRenderingContext.

Definition at line 980 of file nsCairoRenderingContext.cpp.

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

Here is the call graph for this function:

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

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

Implements nsIRenderingContext.

Definition at line 987 of file nsCairoRenderingContext.cpp.

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

Here is the call graph for this function:

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

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

Implements nsIRenderingContext.

Definition at line 993 of file nsCairoRenderingContext.cpp.

{
    if (aLength == 0) {
        aWidth = 0;
        return NS_OK;
    }

    return mFontMetrics->GetWidth(aString, aLength, aWidth);
}
NS_IMETHODIMP nsCairoRenderingContext::GetWidth ( const PRUnichar aString,
PRUint32  aLength,
nscoord aWidth,
PRInt32 aFontID = nsnull 
) [virtual]

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

Implements nsIRenderingContext.

Definition at line 1005 of file nsCairoRenderingContext.cpp.

{
    if (aLength == 0) {
        aWidth = 0;
        return NS_OK;
    }

    return mFontMetrics->GetWidth(aString, aLength, aWidth, aFontID);
}
NS_IMETHODIMP nsCairoRenderingContext::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

Implements nsIRenderingContext.

Definition at line 87 of file nsCairoRenderingContext.cpp.

{
    nsCairoDeviceContext *cairoDC = NS_STATIC_CAST(nsCairoDeviceContext*, aContext);

    mDeviceContext = aContext;
    mWidget = aWidget;

    mDrawingSurface = new nsCairoDrawingSurface();
    nsNativeWidget nativeWidget = aWidget->GetNativeData(NS_NATIVE_WIDGET);
    mDrawingSurface->Init (cairoDC, nativeWidget);

    mCairo = cairo_create ();
    cairo_set_target_surface (mCairo, mDrawingSurface->GetCairoSurface());

    return (CommonInit());
}

Here is the call graph for this function:

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

Implements nsIRenderingContext.

Definition at line 105 of file nsCairoRenderingContext.cpp.

Here is the call graph for this function:

XOR Invert a rectangle in the current foreground color.

Parameters:
aRectThe rectangle to draw

Implements nsIRenderingContext.

Definition at line 575 of file nsCairoRenderingContext.cpp.

{
    return InvertRect(aRect.x, aRect.y, aRect.width, aRect.height);
}
NS_IMETHODIMP nsCairoRenderingContext::InvertRect ( nscoord  aX,
nscoord  aY,
nscoord  aWidth,
nscoord  aHeight 
) [virtual]

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 581 of file nsCairoRenderingContext.cpp.

Here is the call graph for this function:

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

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 246 of file nsCairoRenderingContext.cpp.

{
    // XXX
    aIsVisible = PR_TRUE;
    return NS_OK;
}
NS_IMETHODIMP nsCairoRenderingContext::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

Implements nsIRenderingContext.

Definition at line 155 of file nsCairoRenderingContext.cpp.

{
    if (mOffscreenSurface)
        return mOffscreenSurface->Lock(aX, aY, aWidth, aHeight, aBits, aStride, aWidthBytes, aFlags);
    else
        return mDrawingSurface->Lock(aX, aY, aWidth, aHeight, aBits, aStride, aWidthBytes, aFlags);

    return NS_OK;
}

Get and and set RenderingContext to this graphical state.

Implements nsIRenderingContext.

Definition at line 235 of file nsCairoRenderingContext.cpp.

{
    cairo_restore (mCairo);
    return NS_OK;
}

Here is the caller graph for this function:

Implements nsIRenderingContext.

Definition at line 212 of file nsCairoRenderingContext.cpp.

{
    // XXX this is slow!
    PopState();
    return NS_OK;
}

Here is the call graph for this function:

Save a graphical state onto a stack.

Implements nsIRenderingContext.

Definition at line 228 of file nsCairoRenderingContext.cpp.

{
    cairo_save (mCairo);
    return NS_OK;
}

Here is the caller graph for this function:

Implements nsIRenderingContext.

Definition at line 204 of file nsCairoRenderingContext.cpp.

{
    // XXX this is slow!
    PushState();
    return NS_OK;
}

Here is the call graph for this function:

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

Implements nsIRenderingContext.

Definition at line 833 of file nsCairoRenderingContext.cpp.

{
    mBackBufferSurface = NULL;
    return NS_OK;
//    NS_WARNING("ReleaseBackbuffer: not implemented");
//    return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsCairoRenderingContext::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,

Implements nsIRenderingContext.

Definition at line 1161 of file nsCairoRenderingContext.cpp.

Reset the rendering context.

Implements nsIRenderingContext.

Definition at line 133 of file nsCairoRenderingContext.cpp.

{
    cairo_surface_t *surf = cairo_current_target_surface (mCairo);
    cairo_t *cairo = cairo_create ();
    cairo_set_target_surface (cairo, surf);
    cairo_destroy (mCairo);
    mCairo = cairo;

    mClipRegion = new nsCairoRegion();

    return (CommonInit());
}

Here is the call graph for this function:

Definition at line 796 of file nsCairoRenderingContext.cpp.

{
    NS_WARNING ("not implemented");
    return NS_OK;
}
NS_IMETHODIMP nsCairoRenderingContext::Scale ( float  aSx,
float  aSy 
) [virtual]

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

Parameters:
aXThe horizontal scale
aYThe vertical scale

Implements nsIRenderingContext.

Definition at line 455 of file nsCairoRenderingContext.cpp.

{
//    fprintf (stderr, "++ Scale: %g %g\n", (double)aSx, (double)aSy);
    cairo_scale (mCairo, (double) aSx, (double) aSy);
    return NS_OK;
}

Here is the caller graph for this function:

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 181 of file nsCairoRenderingContext.cpp.

{
    NS_WARNING("not implemented, because I don't know how to unselect the offscreen surface");
    return NS_ERROR_FAILURE;

    mOffscreenSurface = NS_STATIC_CAST(nsCairoDrawingSurface *, aSurface);
    return NS_OK;
}

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 302 of file nsCairoRenderingContext.cpp.

{
    // transform rect by current transform matrix and clip
    return NS_OK;
}

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 309 of file nsCairoRenderingContext.cpp.

{
    // region is in device coords, no transformation!
    // how do we do that with cairo?

    switch(aCombine)
    {
    case nsClipCombine_kIntersect:
        mClipRegion->Intersect (aRegion);
        break;
    case nsClipCombine_kReplace:
        mClipRegion->SetTo (aRegion);
        break;
    case nsClipCombine_kUnion:
    case nsClipCombine_kSubtract:
        // these two are never used in mozilla
    default:
        NS_WARNING("aCombine type passed that should never be used\n");
        break;
    }

    DoCairoClip();

    return NS_OK;
}

Here is the call graph for this function:

Sets the forground color for the RenderingContext.

Parameters:
aColorThe color to set the RenderingContext to

Implements nsIRenderingContext.

Definition at line 421 of file nsCairoRenderingContext.cpp.

{
    mColor = aColor;

    PRUint8 r = NS_GET_R(aColor);
    PRUint8 g = NS_GET_G(aColor);
    PRUint8 b = NS_GET_B(aColor);
    PRUint8 a = NS_GET_A(aColor);

    cairo_set_rgb_color (mCairo,
                         (double) r / 255.0,
                         (double) g / 255.0,
                         (double) b / 255.0);
    cairo_set_alpha (mCairo, (double) a / 255.0);

    return NS_OK;
}
NS_IMETHODIMP nsCairoRenderingContext::SetFont ( const nsFont aFont,
nsIAtom aLangGroup 
) [virtual]

Sets the font for the RenderingContext.

Parameters:
aFontThe font to use in the RenderingContext

Implements nsIRenderingContext.

Definition at line 940 of file nsCairoRenderingContext.cpp.

{
    nsCOMPtr<nsIFontMetrics> newMetrics;
    nsresult rv = mDeviceContext->GetMetricsFor(aFont, aLangGroup, *getter_AddRefs(newMetrics));
    mFontMetrics = NS_REINTERPRET_CAST(nsICairoFontMetrics*, newMetrics.get());
    return NS_OK;
}

Here is the call graph for this function:

Sets the font for the RenderingContext.

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

Implements nsIRenderingContext.

Definition at line 949 of file nsCairoRenderingContext.cpp.

{
    mFontMetrics = NS_STATIC_CAST(nsICairoFontMetrics*, aFontMetrics);
    return NS_OK;
}

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 370 of file nsCairoRenderingContext.cpp.

{
    static double dash[] = {5.0, 5.0};
    static double dot[] = {1.0, 1.0};

    switch (aLineStyle) {
        case nsLineStyle_kNone:
            // XX what is this supposed to be? invisible line?
            break;
        case nsLineStyle_kSolid:
            cairo_set_dash (mCairo, nsnull, 0, 0);
            break;
        case nsLineStyle_kDashed:
            cairo_set_dash (mCairo, dash, 2, 0);
            break;
        case nsLineStyle_kDotted:
            cairo_set_dash (mCairo, dot, 2, 0);
            break;
        default:
            NS_ERROR("SetLineStyle: Invalid line style");
            break;
    }

    mLineStyle = aLineStyle;
    return NS_OK;
}

Sets the Pen Mode for the RenderingContext.

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

Implements nsIRenderingContext.

Definition at line 406 of file nsCairoRenderingContext.cpp.

{
    // aPenMode == nsPenMode_kNone, nsPenMode_kInverted.
    NS_ERROR("not used anywhere");
    return NS_ERROR_NOT_IMPLEMENTED;
}

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

Implements nsIRenderingContext.

Definition at line 209 of file nsCairoRenderingContext.h.

{ return NS_OK; }

Definition at line 499 of file nsCairoRenderingContext.cpp.

{
    double x = double(*aX);
    double y = double(*aY);
    cairo_transform_point (mCairo, &x, &y);
    *aX = nscoord(x);
    *aY = nscoord(y);
}

Here is the caller graph for this function:

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

Parameters:
aXThe horizontal translation
aYThe vertical translation

Implements nsIRenderingContext.

Definition at line 447 of file nsCairoRenderingContext.cpp.

{
//    fprintf (stderr, "++ Xlate: %g %g\n", (double)aX, (double)aY);
    cairo_translate (mCairo, (double) aX, (double) 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

Implements nsIRenderingContext.

Definition at line 170 of file nsCairoRenderingContext.cpp.

{
    if (mOffscreenSurface)
        return mOffscreenSurface->Unlock();
    else
        return mDrawingSurface->Unlock();

    return NS_OK;
}

Definition at line 463 of file nsCairoRenderingContext.cpp.

{
    double a, b, c, d, tx, ty;
    cairo_matrix_t *mat = cairo_matrix_create();
    cairo_current_matrix (mCairo, mat);
    cairo_matrix_get_affine (mat, &a, &b, &c, &d, &tx, &ty);
    /*****
     * Cairo matrix layout:   gfx matrix layout:
     * | a  b  0 |            | m00 m01  0 |
     * | c  d  0 |            | m10 m11  0 |
     * | tx ty 1 |            | m20 m21  1 |
     *****/

    cairo_matrix_destroy (mat);

    NS_ASSERTION(b == 0 && c == 0, "Can't represent Cairo matrix to Gfx");
    mTempTransform.SetToTranslate(tx, ty);
    mTempTransform.AddScale(a, d);
}

Here is the caller graph for this function:

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.

Definition at line 803 of file nsCairoRenderingContext.cpp.

{
    *aUseBackbuffer = PR_FALSE;
    // *aUseBackbuffer = PR_TRUE;
    return NS_OK;
}

Member Data Documentation

Definition at line 260 of file nsCairoRenderingContext.h.

cairo_t* nsCairoRenderingContext::mCairo [protected]

Definition at line 256 of file nsCairoRenderingContext.h.

Definition at line 250 of file nsCairoRenderingContext.h.

Definition at line 254 of file nsCairoRenderingContext.h.

Definition at line 245 of file nsCairoRenderingContext.h.

Definition at line 258 of file nsCairoRenderingContext.h.

Definition at line 251 of file nsCairoRenderingContext.h.

Definition at line 253 of file nsCairoRenderingContext.h.

Definition at line 259 of file nsCairoRenderingContext.h.

nsTransform2D nsCairoRenderingContext::mTempTransform [protected]

Definition at line 264 of file nsCairoRenderingContext.h.

Definition at line 246 of file nsCairoRenderingContext.h.


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