Back to index

lightning-sunbird  0.9+nobinonly
Classes
Cairo Rendering Engine

Classes

class  nsISVGCairoCanvas
 'Private' rendering engine interface More...
class  nsISVGCairoRegion
 'Private' rendering engine interface More...
class  nsISVGCairoSurface
 'Private' rendering engine interface More...
class  nsSVGCairoCanvas
 Cairo canvas implementation. More...
class  nsSVGCairoGlyphGeometry
 cairo glyph geometry implementation More...
class  nsSVGCairoPathBuilder
 Libart path builder implementation. More...
class  nsSVGCairoPathGeometry
 Cairo path geometry implementation. More...
class  nsSVGCairoSurface
 Cairo surface implementation. More...
class  nsSVGRendererCairo
 Cairo renderer factory. More...
class  nsSVGGDIPlusSurface
 GDIPlus surface implementation. More...

Class Documentation

class nsISVGCairoCanvas

'Private' rendering engine interface

Definition at line 60 of file nsISVGCairoCanvas.h.

Inheritance diagram for nsISVGCairoCanvas:
Collaboration diagram for nsISVGCairoCanvas:

Public Member Functions

 NS_IMETHOD_ (cairo_t *) GetContext()=0
NS_IMETHOD AdjustMatrixForInitialTransform (cairo_matrix_t *aMatrix)=0
nsIRenderingContext lockRenderingContext ([const ] in nsRectRef rect)
 Lock a portion of the canvas and obtain a rendering context onto which Mozilla can paint non-svg content.
void unlockRenderingContext ()
 Unlock the canvas portion locked with a previous call to lockRenderingContext().
nsPresContext getPresContext ()
void clear (in nscolor color)
 Fill the canvas with the given color.
void flush ()
 Ensure that all renderings on the canvas have been flushed to the Mozilla-native rendering context.
void pushClip ()
 Push/Pop clip path.
void popClip ()
void setClipRect (in nsIDOMSVGMatrix canvasTM, in float x, in float y, in float width, in float height)
 Set rectangular clip region.
void pushSurface (in nsISVGRendererSurface surface)
 Push/Pop surface as primary drawing surface.
void popSurface ()
void compositeSurface (in nsISVGRendererSurface surface, in unsigned long x, in unsigned long y, in float opacity)
 Surface composition.
void compositeSurfaceMatrix (in nsISVGRendererSurface surface, in nsIDOMSVGMatrix canvasTM, in float opacity)

Public Attributes

const unsigned short SVG_RENDER_MODE_NORMAL = 0
 Set render mode (clipping or normal draw)
const unsigned short SVG_RENDER_MODE_CLIP = 1
attribute unsigned short renderMode

Member Function Documentation

Implemented in nsSVGCairoCanvas.

Here is the caller graph for this function:

void nsISVGRendererCanvas::clear ( in nscolor  color) [inherited]

Fill the canvas with the given color.

Parameters:
colorFill color.
void nsISVGRendererCanvas::compositeSurface ( in nsISVGRendererSurface  surface,
in unsigned long  x,
in unsigned long  y,
in float  opacity 
) [inherited]

Surface composition.

void nsISVGRendererCanvas::compositeSurfaceMatrix ( in nsISVGRendererSurface  surface,
in nsIDOMSVGMatrix  canvasTM,
in float  opacity 
) [inherited]

Ensure that all renderings on the canvas have been flushed to the Mozilla-native rendering context.

Lock a portion of the canvas and obtain a rendering context onto which Mozilla can paint non-svg content.

This is needed for (partial) foreignObject support.

lockRenderingContext() calls are paired with unlockRenderingContext() calls.

Parameters:
rectArea to be locked.
Returns:
Mozilla-native rendering context for the locked area.
nsISVGCairoCanvas::NS_IMETHOD_ ( cairo_t *  ) [pure virtual]

Implemented in nsSVGCairoCanvas.

Push/Pop clip path.

Push/Pop surface as primary drawing surface.

void nsISVGRendererCanvas::setClipRect ( in nsIDOMSVGMatrix  canvasTM,
in float  x,
in float  y,
in float  width,
in float  height 
) [inherited]

Set rectangular clip region.

Unlock the canvas portion locked with a previous call to lockRenderingContext().


Member Data Documentation

attribute unsigned short nsISVGRendererCanvas::renderMode [inherited]

Definition at line 115 of file nsISVGRendererCanvas.idl.

const unsigned short nsISVGRendererCanvas::SVG_RENDER_MODE_CLIP = 1 [inherited]

Definition at line 114 of file nsISVGRendererCanvas.idl.

const unsigned short nsISVGRendererCanvas::SVG_RENDER_MODE_NORMAL = 0 [inherited]

Set render mode (clipping or normal draw)

Definition at line 113 of file nsISVGRendererCanvas.idl.

class nsISVGCairoRegion

'Private' rendering engine interface

Definition at line 53 of file nsISVGCairoRegion.h.

Inheritance diagram for nsISVGCairoRegion:
Collaboration diagram for nsISVGCairoRegion:

Public Member Functions

 NS_IMETHOD_ (PRBool) Contains(float x
nsISVGRendererRegion combine (in nsISVGRendererRegion other)
 Return union of this region with another region.
void getRectangleScans (in nsISVGRectangleSink sink)
 Write a sequence of rectangles approximating this region to the sink object.

Public Attributes

float y = 0

Member Function Documentation

Return union of this region with another region.

Parameters:
otherRegion to combine with.
Returns:
Union region.

Write a sequence of rectangles approximating this region to the sink object.

The approximation can be crude but should fully contain the actual region area.

Parameters:
sinkRectangle sink to write to.

Member Data Documentation

Reimplemented in nsSVGCairoRectRegion.

Definition at line 58 of file nsISVGCairoRegion.h.

class nsISVGCairoSurface

'Private' rendering engine interface

Definition at line 54 of file nsISVGCairoSurface.h.

Inheritance diagram for nsISVGCairoSurface:
Collaboration diagram for nsISVGCairoSurface:

Public Member Functions

 NS_IMETHOD_ (cairo_surface_t *) GetSurface()=0
void getData ([array, size_is(length)] out PRUint8 bits, out unsigned long length, out long stride)
void lock ()
void unlock ()

Public Attributes

readonly attribute unsigned long width
readonly attribute unsigned long height

Member Function Documentation

void nsISVGRendererSurface::getData ( [array, size_is(length)] out PRUint8  bits,
out unsigned long  length,
out long  stride 
) [inherited]
nsISVGCairoSurface::NS_IMETHOD_ ( cairo_surface_t *  ) [pure virtual]

Implemented in nsSVGCairoSurface.


Member Data Documentation

readonly attribute unsigned long nsISVGRendererSurface::height [inherited]

Definition at line 56 of file nsISVGRendererSurface.idl.

readonly attribute unsigned long nsISVGRendererSurface::width [inherited]

Definition at line 55 of file nsISVGRendererSurface.idl.

class nsSVGCairoCanvas

Cairo canvas implementation.

Definition at line 103 of file nsSVGCairoCanvas.cpp.

Inheritance diagram for nsSVGCairoCanvas:
Collaboration diagram for nsSVGCairoCanvas:

Public Member Functions

 nsSVGCairoCanvas ()
 ~nsSVGCairoCanvas ()
nsresult Init (nsIRenderingContext *ctx, nsPresContext *presContext, const nsRect &dirtyRect)
NS_DECL_ISUPPORTS
NS_DECL_NSISVGRENDERERCANVAS 
NS_IMETHOD_ (cairo_t *) GetContext()
NS_IMETHOD AdjustMatrixForInitialTransform (cairo_matrix_t *aMatrix)
nsIRenderingContext lockRenderingContext ([const ] in nsRectRef rect)
 Lock a portion of the canvas and obtain a rendering context onto which Mozilla can paint non-svg content.
void unlockRenderingContext ()
 Unlock the canvas portion locked with a previous call to lockRenderingContext().
nsPresContext getPresContext ()
void clear (in nscolor color)
 Fill the canvas with the given color.
void flush ()
 Ensure that all renderings on the canvas have been flushed to the Mozilla-native rendering context.
void pushClip ()
 Push/Pop clip path.
void popClip ()
void setClipRect (in nsIDOMSVGMatrix canvasTM, in float x, in float y, in float width, in float height)
 Set rectangular clip region.
void pushSurface (in nsISVGRendererSurface surface)
 Push/Pop surface as primary drawing surface.
void popSurface ()
void compositeSurface (in nsISVGRendererSurface surface, in unsigned long x, in unsigned long y, in float opacity)
 Surface composition.
void compositeSurfaceMatrix (in nsISVGRendererSurface surface, in nsIDOMSVGMatrix canvasTM, in float opacity)

Public Attributes

const unsigned short SVG_RENDER_MODE_NORMAL = 0
 Set render mode (clipping or normal draw)
const unsigned short SVG_RENDER_MODE_CLIP = 1
attribute unsigned short renderMode

Private Attributes

nsCOMPtr< nsIRenderingContextmMozContext
nsCOMPtr< nsPresContextmPresContext
cairo_t * mCR
PRUint32 mWidth
PRUint32 mHeight
cairo_matrix_t mInitialTransform
nsVoidArray mContextStack
nsSize mSrcSizeTwips
nsRect mDestRectScaledTwips
nsCOMPtr< imgIContainermContainer
nsCOMPtr< gfxIImageFramemBuffer
PRUint8mData
PRUint16 mRenderMode
PRPackedBool mOwnsCR

Constructor & Destructor Documentation


Member Function Documentation

Implements nsISVGCairoCanvas.

Definition at line 171 of file nsSVGCairoCanvas.cpp.

{
  if (mContextStack.Count() == 0)
    cairo_matrix_multiply(aMatrix, aMatrix, &mInitialTransform);
  return NS_OK;
}
void nsISVGRendererCanvas::clear ( in nscolor  color) [inherited]

Fill the canvas with the given color.

Parameters:
colorFill color.
void nsISVGRendererCanvas::compositeSurface ( in nsISVGRendererSurface  surface,
in unsigned long  x,
in unsigned long  y,
in float  opacity 
) [inherited]

Surface composition.

void nsISVGRendererCanvas::compositeSurfaceMatrix ( in nsISVGRendererSurface  surface,
in nsIDOMSVGMatrix  canvasTM,
in float  opacity 
) [inherited]

Ensure that all renderings on the canvas have been flushed to the Mozilla-native rendering context.

nsresult nsSVGCairoCanvas::Init ( nsIRenderingContext ctx,
nsPresContext presContext,
const nsRect dirtyRect 
)

Definition at line 180 of file nsSVGCairoCanvas.cpp.

{
  mPresContext = presContext;
  mMozContext = ctx;
  NS_ASSERTION(mMozContext, "empty rendering context");

  mRenderMode = SVG_RENDER_MODE_NORMAL;

#if defined(MOZ_ENABLE_CAIRO_GFX)
  mOwnsCR = PR_FALSE;
  void* data;
  ctx->RetrieveCurrentNativeGraphicData(&data);
  mCR = (cairo_t*)data;
  cairo_get_matrix(mCR, &mInitialTranslation);
  return NS_OK;

#else // !MOZ_ENABLE_CAIRO_GFX
  cairo_surface_t* cairoSurf = nsnull;
#if defined(XP_MACOSX)
  nsIDrawingSurface *surface;
  ctx->GetDrawingSurface(&surface);
  mSurface = do_QueryInterface(surface);
  surface->GetDimensions(&mWidth, &mHeight);
  mQuartzRef = mSurface->StartQuartzDrawing();

  CGrafPtr port;
  mSurface->GetGrafPtr(&port);
  Rect portRect;
  ::GetPortBounds(port, &portRect);

#ifdef DEBUG_tor
  fprintf(stderr, "CAIRO: DS=0x%08x port x=%d y=%d w=%d h=%d\n",
          mSurface.get(), portRect.right, portRect.top,
          portRect.right - portRect.left, portRect.bottom - portRect.top);
#endif

  ::SyncCGContextOriginWithPort(mQuartzRef, port);
  cairoSurf = cairo_quartz_surface_create(mQuartzRef,
                                          portRect.right - portRect.left,
                                          portRect.bottom - portRect.top);

#elif defined(MOZ_WIDGET_XLIB)
  nsIDrawingSurfaceXlib* surface;
  ctx->GetDrawingSurface((nsIDrawingSurface**)&surface);

  surface->GetDimensions(&mWidth, &mHeight);

  XlibRgbHandle* handle;
  surface->GetXlibRgbHandle(handle);
  Drawable drawable = surface->GetDrawable();
  cairoSurf = cairo_xlib_surface_create(xxlib_rgb_get_display(handle),
                                        drawable,
                                        xxlib_rgb_get_visual(handle),
                                        mWidth, mHeight);
#elif defined(MOZ_WIDGET_QT)
  nsDrawingSurfaceQt* surface;
  ctx->GetDrawingSurface((nsIDrawingSurface**)&surface);
  surface->GetDimensions(&mWidth, &mHeight);

  QPaintDevice* dev = surface->GetPaintDevice();

  cairoSurf = cairo_xlib_surface_create(dev->x11Display(),
                                        dev->handle(),
                                        (Visual*)dev->x11Visual(),
                                        mWidth, mHeight);
#elif defined(XP_WIN)
  nsDrawingSurfaceWin *surface;
  ctx->GetDrawingSurface((nsIDrawingSurface**)&surface);

  PRInt32 canRaster;
  surface->GetTECHNOLOGY(&canRaster);
  if (canRaster != DT_RASPRINTER) {
    HDC hdc;
    surface->GetDimensions(&mWidth, &mHeight);
    surface->GetDC(&hdc);
    cairoSurf = cairo_win32_surface_create(hdc);
  }
#elif defined(XP_OS2)
  nsDrawingSurfaceOS2 *surface; /* to get a HPS from this */
  nsOffscreenSurface *surface2; /* to get a HDC from this */
  ctx->GetDrawingSurface((nsIDrawingSurface**)&surface);
  ctx->GetDrawingSurface((nsIDrawingSurface**)&surface2);

  HPS hps = surface->GetPS();
  HDC hdc = surface2->GetDC();
  LONG caps;
  if (DevQueryCaps(hdc, CAPS_TECHNOLOGY, 1L, &caps) &&
      caps == CAPS_TECH_RASTER_DISPLAY && hps) {
    /* only the display with an existing presentationn handle *
     * can handle content drawn by cairo                      */
    surface->GetDimensions(&mWidth, &mHeight);
    cairoSurf = cairo_os2_surface_create(hps, mWidth, mHeight);
    cairo_surface_mark_dirty(cairoSurf);
  }
#elif defined(MOZ_ENABLE_GTK2) || defined(MOZ_ENABLE_GTK)
  nsDrawingSurfaceGTK *surface;
  ctx->GetDrawingSurface((nsIDrawingSurface**)&surface);
  if (surface) {
    surface->GetSize(&mWidth, &mHeight);
    GdkDrawable *drawable = surface->GetDrawable();
    GdkVisual *visual = gdk_window_get_visual(drawable);
    cairoSurf = cairo_xlib_surface_create(GDK_WINDOW_XDISPLAY(drawable),
                                          GDK_WINDOW_XWINDOW(drawable),
                                          GDK_VISUAL_XVISUAL(visual),
                                          mWidth, mHeight);
  }
#endif

  // Account for the transform in the rendering context. We set dx,dy
  // to the translation required in the cairo context that will
  // ensure the cairo context's origin coincides with the top-left
  // of the area we need to draw.
  nsTransform2D* xform;
  mMozContext->GetCurrentTransform(xform);
  float dx, dy;
  xform->GetTranslation(&dx, &dy);
  
  if (!cairoSurf) {
    /* printing or some platform we don't know about yet - use an image */
    float scaledTwipsPerPx = presContext->ScaledPixelsToTwips();
    mDestRectScaledTwips = dirtyRect;
    mDestRectScaledTwips.ScaleRoundOut(scaledTwipsPerPx);
    
    float twipsPerPx = presContext->PixelsToTwips();
    nsRect r = dirtyRect;
    r.ScaleRoundOut(twipsPerPx);
    mSrcSizeTwips = r.Size();
  
    mWidth = dirtyRect.width;
    mHeight = dirtyRect.height;

    mContainer = do_CreateInstance("@mozilla.org/image/container;1");
    mContainer->Init(mWidth, mHeight, nsnull);
    
    mBuffer = do_CreateInstance("@mozilla.org/gfx/image/frame;2");
#if defined(XP_WIN) || defined(XP_OS2)
    mBuffer->Init(0, 0, mWidth, mHeight, gfxIFormats::BGR, 24);
#else
    mBuffer->Init(0, 0, mWidth, mHeight, gfxIFormats::RGB_A8, 24);
#endif
    mContainer->AppendFrame(mBuffer);

    mData = (PRUint8 *)calloc(4 * mWidth * mHeight, 1);
    if (!mData)
      return NS_ERROR_FAILURE;

    cairoSurf = cairo_image_surface_create_for_data(mData, CAIRO_FORMAT_ARGB32,
                                                    mWidth, mHeight, 4 * mWidth);
    
    // Ensure that dirtyRect.TopLeft() is translated to (0,0) in the surface                            
    dx = -dirtyRect.x;
    dy = -dirtyRect.y;
  }

  mOwnsCR = PR_TRUE;
  mCR = cairo_create(cairoSurf);
  // Destroy our reference to the surface; the cairo_t will continue to hold a reference to it
  cairo_surface_destroy(cairoSurf);

  cairo_translate(mCR, dx, dy);
  cairo_get_matrix(mCR, &mInitialTransform);

#if defined(DEBUG_tor) || defined(DEBUG_roc)
  fprintf(stderr, "cairo translate: %f %f\n", dx, dy);

  fprintf(stderr, "cairo dirty: %d %d %d %d\n",
                  dirtyRect.x, dirtyRect.y, dirtyRect.width, dirtyRect.height);
#endif

  // clip to dirtyRect
  cairo_new_path(mCR);
  cairo_rectangle(mCR,
                  dirtyRect.x, dirtyRect.y, dirtyRect.width, dirtyRect.height);
  cairo_clip(mCR);
  cairo_new_path(mCR);

  return NS_OK;
#endif // !MOZ_ENABLE_CAIRO_GFX
}

Here is the call graph for this function:

Here is the caller graph for this function:

Lock a portion of the canvas and obtain a rendering context onto which Mozilla can paint non-svg content.

This is needed for (partial) foreignObject support.

lockRenderingContext() calls are paired with unlockRenderingContext() calls.

Parameters:
rectArea to be locked.
Returns:
Mozilla-native rendering context for the locked area.
NS_DECL_ISUPPORTS NS_DECL_NSISVGRENDERERCANVAS nsSVGCairoCanvas::NS_IMETHOD_ ( cairo_t *  ) [inline, virtual]

Implements nsISVGCairoCanvas.

Definition at line 118 of file nsSVGCairoCanvas.cpp.

{ return mCR; }

Push/Pop clip path.

Push/Pop surface as primary drawing surface.

void nsISVGRendererCanvas::setClipRect ( in nsIDOMSVGMatrix  canvasTM,
in float  x,
in float  y,
in float  width,
in float  height 
) [inherited]

Set rectangular clip region.

Unlock the canvas portion locked with a previous call to lockRenderingContext().


Member Data Documentation

cairo_t* nsSVGCairoCanvas::mCR [private]

Definition at line 124 of file nsSVGCairoCanvas.cpp.

Definition at line 139 of file nsSVGCairoCanvas.cpp.

Definition at line 125 of file nsSVGCairoCanvas.cpp.

Definition at line 142 of file nsSVGCairoCanvas.cpp.

Definition at line 141 of file nsSVGCairoCanvas.cpp.

Definition at line 135 of file nsSVGCairoCanvas.cpp.

Definition at line 125 of file nsSVGCairoCanvas.cpp.

attribute unsigned short nsISVGRendererCanvas::renderMode [inherited]

Definition at line 115 of file nsISVGRendererCanvas.idl.

const unsigned short nsISVGRendererCanvas::SVG_RENDER_MODE_CLIP = 1 [inherited]

Definition at line 114 of file nsISVGRendererCanvas.idl.

const unsigned short nsISVGRendererCanvas::SVG_RENDER_MODE_NORMAL = 0 [inherited]

Set render mode (clipping or normal draw)

Definition at line 113 of file nsISVGRendererCanvas.idl.

class nsSVGCairoGlyphGeometry

cairo glyph geometry implementation

Definition at line 75 of file nsSVGCairoGlyphGeometry.cpp.

Inheritance diagram for nsSVGCairoGlyphGeometry:
Collaboration diagram for nsSVGCairoGlyphGeometry:

Public Member Functions

void render (in nsISVGRendererCanvas canvas)
 Paint this object.
nsISVGRendererRegion update (in unsigned long updatemask)
 Called by this object's corresponding nsISVGGlyphGeometrySource as a notification that some of the source's data (identified by paramter 'updatemask') has changed.
nsISVGRendererRegion getCoveredRegion ()
 Get a region object describing the area covered with paint by this glyph geometry.
boolean containsPoint (in float x, in float y)
 Hit-testing method.

Public Attributes

readonly attribute nsIDOMSVGRect boundingBox
 Transformed bounding box (does not include stroke width)

Protected Member Functions

 nsSVGCairoGlyphGeometry ()
 ~nsSVGCairoGlyphGeometry ()
nsresult Init (nsISVGGlyphGeometrySource *src)
nsresult GetGlobalTransform (cairo_t *ctx, nsISVGCairoCanvas *aCanvas)

Protected Attributes

nsCOMPtr
< nsISVGGlyphGeometrySource
mSource

Private Attributes

nsCOMPtr< nsISVGRendererRegionmCoveredRegion

Friends

nsresult NS_NewSVGCairoGlyphGeometry (nsISVGRendererGlyphGeometry **result, nsISVGGlyphGeometrySource *src)

Constructor & Destructor Documentation

Definition at line 106 of file nsSVGCairoGlyphGeometry.cpp.

{
}

Member Function Documentation

boolean nsISVGRendererGlyphGeometry::containsPoint ( in float  x,
in float  y 
) [inherited]

Hit-testing method.

Does this glyph geometry (with all relevant transformations applied) contain the point x,y? Should work on a character-cell basis, rather than the actual character outline.

Parameters:
xX-coordinate of test point.
yY-coordinate of test point.
Returns:
PR_TRUE if the glyph geometry contains the point, PR_FALSE otherwise.

Get a region object describing the area covered with paint by this glyph geometry.

Returns:
Covered region.
nsresult nsSVGCairoGlyphGeometry::GetGlobalTransform ( cairo_t *  ctx,
nsISVGCairoCanvas aCanvas 
) [protected]

Definition at line 693 of file nsSVGCairoGlyphGeometry.cpp.

{
  nsCOMPtr<nsIDOMSVGMatrix> ctm;
  mSource->GetCanvasTM(getter_AddRefs(ctm));
  NS_ASSERTION(ctm, "graphic source didn't specify a ctm");
  
  float m[6];
  float val;
  ctm->GetA(&val);
  m[0] = val;
  
  ctm->GetB(&val);
  m[1] = val;
  
  ctm->GetC(&val);  
  m[2] = val;  
  
  ctm->GetD(&val);  
  m[3] = val;  
  
  ctm->GetE(&val);
  m[4] = val;
  
  ctm->GetF(&val);
  m[5] = val;

  cairo_matrix_t matrix = {m[0], m[1], m[2], m[3], m[4], m[5]};
  if (aCanvas) {
    aCanvas->AdjustMatrixForInitialTransform(&matrix);
  }

  cairo_matrix_t inverse = matrix;
  if (cairo_matrix_invert(&inverse)) {
    cairo_identity_matrix(ctx);
    cairo_new_path(ctx);
    return NS_ERROR_FAILURE;
  }

  cairo_set_matrix(ctx, &matrix);
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 115 of file nsSVGCairoGlyphGeometry.cpp.

{
  mSource = src;
  return NS_OK;
}

Here is the caller graph for this function:

Paint this object.

Parameters:
canvasThe canvas to render to.

Here is the caller graph for this function:

nsISVGRendererRegion nsISVGRendererGlyphGeometry::update ( in unsigned long  updatemask) [inherited]

Called by this object's corresponding nsISVGGlyphGeometrySource as a notification that some of the source's data (identified by paramter 'updatemask') has changed.

Parameters:
updatemaskAn OR-ed combination of the UPDATEMASK_* constants defined in nsISVGGlyphGeometrySource.
Returns:
Region that needs to be redrawn.

Friends And Related Function Documentation

Definition at line 123 of file nsSVGCairoGlyphGeometry.cpp.

{
  *result = nsnull;
  
  nsSVGCairoGlyphGeometry* gg = new nsSVGCairoGlyphGeometry();
  if (!gg) return NS_ERROR_OUT_OF_MEMORY;

  NS_ADDREF(gg);

  nsresult rv = gg->Init(src);

  if (NS_FAILED(rv)) {
    NS_RELEASE(gg);
    return rv;
  }
  
  *result = gg;
  return rv;
}

Member Data Documentation

Transformed bounding box (does not include stroke width)

Definition at line 110 of file nsISVGRendererGlyphGeometry.idl.

class nsSVGCairoPathBuilder

Libart path builder implementation.

Definition at line 56 of file nsSVGCairoPathBuilder.cpp.

Inheritance diagram for nsSVGCairoPathBuilder:
Collaboration diagram for nsSVGCairoPathBuilder:

Public Member Functions

void moveto (in float x, in float y)
 Move current position and start new sub-path.
void lineto (in float x, in float y)
 Draw a straight line from the current position to (x,y).
void curveto (in float x, in float y, in float x1, in float y1, in float x2, in float y2)
 Draw cubic Bezier curve from the current position to (x,y) using (x1,y1) as the control point at the beginning og the curve and (x2,y2) as the control point at the end of the curve.
void arcto (in float x, in float y, in float r1, in float r2, in float angle, in boolean largeArcFlag, in boolean sweepFlag)
 Draw an elliptical arc from the current position to (x,y).
void closePath (out float newX, out float newY)
 Close the current subpath.
void endPath ()
 End the path description.

Protected Member Functions

 nsSVGCairoPathBuilder (cairo_t *ctx)

Private Attributes

cairo_t * mCR

Friends

nsresult NS_NewSVGCairoPathBuilder (nsISVGRendererPathBuilder **result, cairo_t *ctx)

Constructor & Destructor Documentation

nsSVGCairoPathBuilder::nsSVGCairoPathBuilder ( cairo_t *  ctx) [protected]

Definition at line 81 of file nsSVGCairoPathBuilder.cpp.

  : mCR(ctx)
{
}

Member Function Documentation

void nsISVGRendererPathBuilder::arcto ( in float  x,
in float  y,
in float  r1,
in float  r2,
in float  angle,
in boolean  largeArcFlag,
in boolean  sweepFlag 
) [inherited]

Draw an elliptical arc from the current position to (x,y).

Advance current position to (x,y).

Parameters:
xX-coordinate of end point (untransformed).
yY-coordinate of end point (untransformed).
r1Radius of ellipse in X direction (untransformed).
r2Radius of ellipse in Y direction (untransformed).
angleRotation of ellipse as a whole (untransformed).
largeArcFlagPR_TRUE: choose the large arc (>=180 degrees), PR_FALSE: choose the smaller arc (<=180 degrees)
sweepFlagPR_TRUE: sweep in positive angle direction, PR_FALSE: sweep in negative angle direction
void nsISVGRendererPathBuilder::closePath ( out float  newX,
out float  newY 
) [inherited]

Close the current subpath.

Move current position back to beginning of subpath.

Parameters:
newXX-coordinate of new current position (untransformed).
newYY-coordinate of new current position (untransformed).
void nsISVGRendererPathBuilder::curveto ( in float  x,
in float  y,
in float  x1,
in float  y1,
in float  x2,
in float  y2 
) [inherited]

Draw cubic Bezier curve from the current position to (x,y) using (x1,y1) as the control point at the beginning og the curve and (x2,y2) as the control point at the end of the curve.

Advance current position to (x,y).

Parameters:
xX-coordinate of end point (untransformed).
yY-coordinate of end point (untransformed).
x1X-coordinate of first control point (untransformed).
y1Y-coordinate of first control point (untransformed).
x2X-coordinate of second control point (untransformed).
y2Y-coordinate of second control point (untransformed).

End the path description.

Guaranteed to be the last function called.

void nsISVGRendererPathBuilder::lineto ( in float  x,
in float  y 
) [inherited]

Draw a straight line from the current position to (x,y).

Advance current position to (x,y).

Parameters:
xX-coordinate of end point (untransformed).
yY-coordinate of end point (untransformed).
void nsISVGRendererPathBuilder::moveto ( in float  x,
in float  y 
) [inherited]

Move current position and start new sub-path.

Parameters:
xX-coordinate (untransformed).
yY-coordinate (untransformed).

Friends And Related Function Documentation

nsresult NS_NewSVGCairoPathBuilder ( nsISVGRendererPathBuilder **  result,
cairo_t *  ctx 
) [friend]

Definition at line 87 of file nsSVGCairoPathBuilder.cpp.

{
  *result = new nsSVGCairoPathBuilder(ctx);
  if (!*result)
    return NS_ERROR_OUT_OF_MEMORY;

  NS_ADDREF(*result);
    
  return NS_OK;
}

Member Data Documentation

cairo_t* nsSVGCairoPathBuilder::mCR [private]

Definition at line 73 of file nsSVGCairoPathBuilder.cpp.

class nsSVGCairoPathGeometry

Cairo path geometry implementation.

Definition at line 75 of file nsSVGCairoPathGeometry.cpp.

Inheritance diagram for nsSVGCairoPathGeometry:
Collaboration diagram for nsSVGCairoPathGeometry:

Public Member Functions

void render (in nsISVGRendererCanvas canvas)
 Paint this object.
nsISVGRendererRegion update (in unsigned long updatemask)
 Called by this object's corresponding nsISVGPathGeometrySource as a notification that some of the source's data (identified by paramter 'updatemask') has changed.
nsISVGRendererRegion getCoveredRegion ()
 Get a region object describing the area covered with paint by this path geometry.
boolean containsPoint (in float x, in float y)
 Hit-testing method.
void flatten (out nsSVGPathData data)

Public Attributes

readonly attribute nsIDOMSVGRect boundingBox
 Bounding box (does not include stroke width)

Protected Member Functions

 nsSVGCairoPathGeometry ()
 ~nsSVGCairoPathGeometry ()
nsresult Init (nsISVGPathGeometrySource *src)

Private Member Functions

void GeneratePath (cairo_t *ctx, nsISVGCairoCanvas *aCanvas)
void SetupStrokeGeometry (cairo_t *ctx)
void SetupStrokeHitGeometry (cairo_t *ctx)

Private Attributes

nsCOMPtr
< nsISVGPathGeometrySource
mSource
nsCOMPtr< nsISVGRendererRegionmCoveredRegion

Friends

nsresult NS_NewSVGCairoPathGeometry (nsISVGRendererPathGeometry **result, nsISVGPathGeometrySource *src)

Constructor & Destructor Documentation

Definition at line 107 of file nsSVGCairoPathGeometry.cpp.

{
}

Definition at line 111 of file nsSVGCairoPathGeometry.cpp.

{
}

Member Function Documentation

boolean nsISVGRendererPathGeometry::containsPoint ( in float  x,
in float  y 
) [inherited]

Hit-testing method.

Does this path geometry (with all relevant transformations applied) contain the point x,y? Mode of operation (e.g. whether to test fill or stroke) is determined by nsISVGPathGeometrySource::hittestMask.

Parameters:
xX-coordinate of test point.
yY-coordinate of test point.
Returns:
PR_TRUE if the path geometry contains the point, PR_FALSE otherwise.

Definition at line 156 of file nsSVGCairoPathGeometry.cpp.

{
  nsCOMPtr<nsIDOMSVGMatrix> ctm;
  mSource->GetCanvasTM(getter_AddRefs(ctm));
  NS_ASSERTION(ctm, "graphic source didn't specify a ctm");

  float m[6];
  float val;
  ctm->GetA(&val);
  m[0] = val;
    
  ctm->GetB(&val);
  m[1] = val;
    
  ctm->GetC(&val);  
  m[2] = val;  
    
  ctm->GetD(&val);  
  m[3] = val;  
  
  ctm->GetE(&val);
  m[4] = val;
  
  ctm->GetF(&val);
  m[5] = val;

  cairo_matrix_t matrix = { m[0], m[1], m[2], m[3], m[4], m[5] };
  if (aCanvas) {
    aCanvas->AdjustMatrixForInitialTransform(&matrix);
  }

  cairo_matrix_t inverse = matrix;
  if (cairo_matrix_invert(&inverse)) {
    cairo_identity_matrix(ctx);
    cairo_new_path(ctx);
    return;
  }
  cairo_set_matrix(ctx, &matrix);

  nsCOMPtr<nsISVGRendererPathBuilder> builder;
  NS_NewSVGCairoPathBuilder(getter_AddRefs(builder), ctx);
  mSource->ConstructPath(builder);
  builder->EndPath();
}

Here is the call graph for this function:

Get a region object describing the area covered with paint by this path geometry.

Returns:
Covered region.

Definition at line 115 of file nsSVGCairoPathGeometry.cpp.

{
  mSource = src;
  return NS_OK;
}

Here is the caller graph for this function:

Paint this object.

Parameters:
canvasThe canvas to render to.
void nsSVGCairoPathGeometry::SetupStrokeGeometry ( cairo_t *  ctx) [private]

Definition at line 202 of file nsSVGCairoPathGeometry.cpp.

{
  float width;
  mSource->GetStrokeWidth(&width);
  cairo_set_line_width(ctx, double(width));

  PRUint16 capStyle;
  mSource->GetStrokeLinecap(&capStyle);
  switch (capStyle) {
    case nsISVGGeometrySource::STROKE_LINECAP_BUTT:
      cairo_set_line_cap(ctx, CAIRO_LINE_CAP_BUTT);
      break;
    case nsISVGGeometrySource::STROKE_LINECAP_ROUND:
      cairo_set_line_cap(ctx, CAIRO_LINE_CAP_ROUND);
      break;
    case nsISVGGeometrySource::STROKE_LINECAP_SQUARE:
      cairo_set_line_cap(ctx, CAIRO_LINE_CAP_SQUARE);
      break;
  }

  float miterlimit;
  mSource->GetStrokeMiterlimit(&miterlimit);
  cairo_set_miter_limit(ctx, double(miterlimit));

  PRUint16 joinStyle;
  mSource->GetStrokeLinejoin(&joinStyle);
  switch(joinStyle) {
    case nsISVGGeometrySource::STROKE_LINEJOIN_MITER:
      cairo_set_line_join(ctx, CAIRO_LINE_JOIN_MITER);
      break;
    case nsISVGGeometrySource::STROKE_LINEJOIN_ROUND:
      cairo_set_line_join(ctx, CAIRO_LINE_JOIN_ROUND);
      break;
    case nsISVGGeometrySource::STROKE_LINEJOIN_BEVEL:
      cairo_set_line_join(ctx, CAIRO_LINE_JOIN_BEVEL);
      break;
    }
}

Here is the caller graph for this function:

Definition at line 242 of file nsSVGCairoPathGeometry.cpp.

{
  SetupStrokeGeometry(ctx);

  float *dashArray, offset;
  PRUint32 count;
  mSource->GetStrokeDashArray(&dashArray, &count);
  if (count > 0) {
    double *dashes = new double[count];
    for (unsigned i=0; i<count; i++)
      dashes[i] = dashArray[i];
    mSource->GetStrokeDashoffset(&offset);
    cairo_set_dash(ctx, dashes, count, double(offset));
    nsMemory::Free(dashArray);
    delete [] dashes;
  }
}

Here is the call graph for this function:

nsISVGRendererRegion nsISVGRendererPathGeometry::update ( in unsigned long  updatemask) [inherited]

Called by this object's corresponding nsISVGPathGeometrySource as a notification that some of the source's data (identified by paramter 'updatemask') has changed.

Parameters:
updatemaskAn OR-ed combination of the UPDATEMASK_* constants defined in nsISVGPathGeometrySource.
Returns:
Region that needs to be redrawn.

Friends And Related Function Documentation

Definition at line 123 of file nsSVGCairoPathGeometry.cpp.

{
  nsSVGCairoPathGeometry* pg = new nsSVGCairoPathGeometry();
  if (!pg) return NS_ERROR_OUT_OF_MEMORY;

  NS_ADDREF(pg);

  nsresult rv = pg->Init(src);

  if (NS_FAILED(rv)) {
    NS_RELEASE(pg);
    return rv;
  }
  
  *result = pg;
  return rv;
}

Member Data Documentation

Bounding box (does not include stroke width)

Definition at line 111 of file nsISVGRendererPathGeometry.idl.

class nsSVGCairoSurface

Cairo surface implementation.

Definition at line 52 of file nsSVGCairoSurface.cpp.

Inheritance diagram for nsSVGCairoSurface:
Collaboration diagram for nsSVGCairoSurface:

Public Member Functions

 nsSVGCairoSurface ()
 ~nsSVGCairoSurface ()
nsresult Init (PRUint32 width, PRUint32 height)
NS_DECL_ISUPPORTS
NS_DECL_NSISVGRENDERERSURFACE 
NS_IMETHOD_ (cairo_surface_t *) GetSurface()
void getData ([array, size_is(length)] out PRUint8 bits, out unsigned long length, out long stride)
void lock ()
void unlock ()

Public Attributes

readonly attribute unsigned long width
readonly attribute unsigned long height

Private Attributes

PRUint8mData
cairo_surface_t * mSurface
PRUint32 mWidth
PRUint32 mHeight

Constructor & Destructor Documentation


Member Function Documentation

void nsISVGRendererSurface::getData ( [array, size_is(length)] out PRUint8  bits,
out unsigned long  length,
out long  stride 
) [inherited]

Definition at line 120 of file nsSVGCairoSurface.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

NS_DECL_ISUPPORTS NS_DECL_NSISVGRENDERERSURFACE nsSVGCairoSurface::NS_IMETHOD_ ( cairo_surface_t *  ) [inline, virtual]

Implements nsISVGCairoSurface.

Definition at line 66 of file nsSVGCairoSurface.cpp.

{ return mSurface; }

Member Data Documentation

readonly attribute unsigned long nsISVGRendererSurface::height [inherited]

Definition at line 56 of file nsISVGRendererSurface.idl.

Definition at line 69 of file nsSVGCairoSurface.cpp.

Definition at line 71 of file nsSVGCairoSurface.cpp.

cairo_surface_t* nsSVGCairoSurface::mSurface [private]

Definition at line 70 of file nsSVGCairoSurface.cpp.

Definition at line 71 of file nsSVGCairoSurface.cpp.

readonly attribute unsigned long nsISVGRendererSurface::width [inherited]

Definition at line 55 of file nsISVGRendererSurface.idl.

class nsSVGRendererCairo

Cairo renderer factory.

Definition at line 62 of file nsSVGRendererCairo.cpp.

Inheritance diagram for nsSVGRendererCairo:
Collaboration diagram for nsSVGRendererCairo:

Public Member Functions

 nsSVGRendererCairo ()
nsISVGRendererPathGeometry createPathGeometry (in nsISVGPathGeometrySource src)
 Create a rendering engine-native path geometry object for the source object given by 'src'.
nsISVGRendererGlyphMetrics createGlyphMetrics (in nsISVGGlyphMetricsSource src)
 Create a rendering engine-native glyph metrics object for the source object given by 'src'.
nsISVGRendererGlyphGeometry createGlyphGeometry (in nsISVGGlyphGeometrySource src)
 Create a rendering engine-native glyph geometry object for the source object given by 'src'.
nsISVGRendererCanvas createCanvas (in nsIRenderingContext ctx, in nsPresContext presContext,[const ] in nsRectRef dirtyRect)
 Create a rendering engine-native canvas object for the Mozilla-native rendering context 'ctx' and presentation context 'presContext'.
nsISVGRendererRegion createRectRegion (in float x, in float y, in float width, in float height)
 Create a rendering engine-native region object for the given axis-aligned rectangle.
nsISVGRendererSurface createSurface (in unsigned long width, in unsigned long height)
 Create a rendering engine-native surface object.

Friends

nsresult NS_NewSVGRendererCairo (nsISVGRenderer **aResult)

Constructor & Destructor Documentation


Member Function Documentation

nsISVGRendererCanvas nsISVGRenderer::createCanvas ( in nsIRenderingContext  ctx,
in nsPresContext  presContext,
[const ] in nsRectRef  dirtyRect 
) [inherited]

Create a rendering engine-native canvas object for the Mozilla-native rendering context 'ctx' and presentation context 'presContext'.

Parameters:
ctxMozilla-native rendering context.
presContextPresentation context.
dirtyRectArea that the canvas should cover.
Returns:
A rendering engine-native canvas object.

Create a rendering engine-native glyph geometry object for the source object given by 'src'.

Parameters:
srcThe source object describing the glyph for which this object is being created.
Returns:
A rendering engine-native glyph geometry object.

Create a rendering engine-native glyph metrics object for the source object given by 'src'.

Parameters:
srcThe source object describing the glyph for which this metrics object is being created.
Returns:
A rendering engine-native glyph metrics object.

Create a rendering engine-native path geometry object for the source object given by 'src'.

Parameters:
srcThe source object describing the path for which this object is being created.
Returns:
A rendering engine-native path geometry object.
nsISVGRendererRegion nsISVGRenderer::createRectRegion ( in float  x,
in float  y,
in float  width,
in float  height 
) [inherited]

Create a rendering engine-native region object for the given axis-aligned rectangle.

Parameters:
xX-coordinate of rectangle (pixels).
yY-coordinate of rectangle (pixels).
widthWidth of rectangle (pixels).
heightHeight of rectangle (pixels).
Returns:
A rendering engine-native region object.
nsISVGRendererSurface nsISVGRenderer::createSurface ( in unsigned long  width,
in unsigned long  height 
) [inherited]

Create a rendering engine-native surface object.

Parameters:
widthWidth of rectangle (pixels).
heightHeight of rectangle (pixels).
Returns:
A rendering engine-native surface object.

Friends And Related Function Documentation

Definition at line 92 of file nsSVGRendererCairo.cpp.

{
  NS_PRECONDITION(aResult != nsnull, "null ptr");
  if (! aResult)
    return NS_ERROR_NULL_POINTER;

  nsSVGRendererCairo* result = new nsSVGRendererCairo();
  if (! result)
    return NS_ERROR_OUT_OF_MEMORY;

  NS_ADDREF(result);
  *aResult = result;
  return NS_OK;
}
class nsSVGGDIPlusSurface

GDIPlus surface implementation.

Definition at line 55 of file nsSVGGDIPlusSurface.cpp.

Inheritance diagram for nsSVGGDIPlusSurface:
Collaboration diagram for nsSVGGDIPlusSurface:

Public Member Functions

 nsSVGGDIPlusSurface ()
 ~nsSVGGDIPlusSurface ()
nsresult Init (PRUint32 width, PRUint32 height)
NS_DECL_ISUPPORTS
NS_DECL_NSISVGRENDERERSURFACE 
NS_IMETHOD_ (Bitmap *) GetSurface()
 Obtain the Gdiplus::Graphics object for this canvas.
void getData ([array, size_is(length)] out PRUint8 bits, out unsigned long length, out long stride)
void lock ()
void unlock ()

Public Attributes

readonly attribute unsigned long width
readonly attribute unsigned long height

Private Attributes

Bitmap * mSurface
BitmapData mBitmapData
PRUint32 mWidth
PRUint32 mHeight

Constructor & Destructor Documentation

Definition at line 87 of file nsSVGGDIPlusSurface.cpp.

{
  if (mSurface) {
    delete mSurface;
    mSurface = nsnull;
  }
}

Member Function Documentation

void nsISVGRendererSurface::getData ( [array, size_is(length)] out PRUint8  bits,
out unsigned long  length,
out long  stride 
) [inherited]

Definition at line 96 of file nsSVGGDIPlusSurface.cpp.

{
  mWidth = width;
  mHeight = height;

  mSurface = new Bitmap(width, height, PixelFormat32bppPARGB);

  if (!mSurface)
    return NS_ERROR_FAILURE;

  return NS_OK;
}

Here is the caller graph for this function:

NS_DECL_ISUPPORTS NS_DECL_NSISVGRENDERERSURFACE nsSVGGDIPlusSurface::NS_IMETHOD_ ( Bitmap *  ) [inline, virtual]

Obtain the Gdiplus::Graphics object for this canvas.

Implements nsISVGGDIPlusSurface.

Definition at line 69 of file nsSVGGDIPlusSurface.cpp.

{ return mSurface; }

Member Data Documentation

readonly attribute unsigned long nsISVGRendererSurface::height [inherited]

Definition at line 56 of file nsISVGRendererSurface.idl.

BitmapData nsSVGGDIPlusSurface::mBitmapData [private]

Definition at line 73 of file nsSVGGDIPlusSurface.cpp.

Definition at line 74 of file nsSVGGDIPlusSurface.cpp.

Bitmap* nsSVGGDIPlusSurface::mSurface [private]

Definition at line 72 of file nsSVGGDIPlusSurface.cpp.

Definition at line 74 of file nsSVGGDIPlusSurface.cpp.

readonly attribute unsigned long nsISVGRendererSurface::width [inherited]

Definition at line 55 of file nsISVGRendererSurface.idl.