Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions | Variables | Friends
Cairo Rendering Engine

Classes

class  nsISVGCairoGlyphMetrics
 'Private' rendering engine interface More...
class  nsSVGCairoGlyphMetrics
 Cairo glyph metrics implementation. More...
class  nsISVGGDIPlusCanvas
 'Private' rendering engine interface More...
class  nsISVGGDIPlusGlyphMetrics
 'Private' rendering engine interface More...
class  nsISVGGDIPlusRegion
 'Private' rendering engine interface More...
class  nsISVGGDIPlusSurface
 'Private' rendering engine interface More...
class  nsSVGGDIPlusCanvas
 GDI+ canvas implementation. More...
class  nsSVGGDIPlusGlyphGeometry
 GDI+ glyph geometry implementation. More...
class  nsWindowsDC
 Helper class used by nsSVGGDIPlusGlyphMetrics. More...
class  nsSVGGDIPlusGlyphMetrics
 GDI+ glyph metrics implementation. More...
class  PointStack
 Helper class used by nsSVGGDIPlusPathBuilder. More...
struct  PointStack::PointData
class  nsSVGGDIPlusPathBuilder
 GDI+ path builder implementation. More...
class  nsSVGGDIPlusPathGeometry
 GDI+ path geometry implementation. More...
class  nsSVGGDIPlusRegion
 GDI+ region implementation. More...
class  nsSVGRendererGDIPlus
 GDI+ renderer factory. More...

Functions

 nsSVGCairoGlyphMetrics::nsSVGCairoGlyphMetrics (nsISVGGlyphMetricsSource *src)
 nsSVGCairoGlyphMetrics::~nsSVGCairoGlyphMetrics ()
NS_DECL_ISUPPORTS
NS_DECL_NSISVGRENDERERGLYPHMETRICS 
nsSVGCairoGlyphMetrics::NS_IMETHOD_ (void) SelectFont(cairo_t *ctx)
nsresult NS_NewSVGCairoGlyphMetrics (nsISVGRendererGlyphMetrics **result, nsISVGGlyphMetricsSource *src)

Variables

cairo_t * nsSVGCairoGlyphMetrics::mCT
cairo_text_extents_t nsSVGCairoGlyphMetrics::mExtents
nsCOMPtr
< nsISVGGlyphMetricsSource
nsSVGCairoGlyphMetrics::mSource

Friends

nsresult nsSVGCairoGlyphMetrics::NS_NewSVGCairoGlyphMetrics (nsISVGRendererGlyphMetrics **result, nsISVGGlyphMetricsSource *src)

Class Documentation

class nsISVGCairoGlyphMetrics

'Private' rendering engine interface

Definition at line 59 of file nsISVGCairoGlyphMetrics.h.

Inheritance diagram for nsISVGCairoGlyphMetrics:
Collaboration diagram for nsISVGCairoGlyphMetrics:

Public Member Functions

 NS_IMETHOD_ (void) SelectFont(cairo_t *ctx)=0
nsIDOMSVGRect getExtentOfChar (in unsigned long charnum)
 Get the untransformed bounding box of an individual glyph.
float getAdvanceOfChar (in unsigned long charnum)
 Get the advance of an individual glyph.
float getBaselineOffset (in unsigned short baselineIdentifier)
 Retrieve the (y-axis) offset of the given baseline.
boolean update (in unsigned long updatemask)
 Called by this object's corresponding nsISVGGlyphMetricsSource as a notification that some of the source's data (identified by paramter 'updatemask') has changed.

Public Attributes

readonly attribute float advance
 Untransformed width of the composite glyph in pixels.
Baseline offset constants for getBaselineOffset()
const unsigned short BASELINE_ALPHABETIC = 0
const unsigned short BASELINE_HANGING = 1
const unsigned short BASELINE_IDEOGRAPHC = 2
const unsigned short BASELINE_MATHEMATICAL = 3
const unsigned short BASELINE_CENTRAL = 4
const unsigned short BASELINE_MIDDLE = 5
const unsigned short BASELINE_TEXT_BEFORE_EDGE = 6
const unsigned short BASELINE_TEXT_AFTER_EDGE = 7

Member Function Documentation

float nsISVGRendererGlyphMetrics::getAdvanceOfChar ( in unsigned long  charnum) [inherited]

Get the advance of an individual glyph.

float nsISVGRendererGlyphMetrics::getBaselineOffset ( in unsigned short  baselineIdentifier) [inherited]

Retrieve the (y-axis) offset of the given baseline.

Parameters:
baselineIdentifierOne of the BASELINE_* constants defined in this interface.
Returns:
Y-axis offset in pixels relative to top of bounding box.

Get the untransformed bounding box of an individual glyph.

Parameters:
charnumThe index of the character in nsISVGGlyphMetricsSource::characterData whose glyph bounding box is to be determined
Returns:
The untransformed bounding box in pixel coordinates
boolean nsISVGRendererGlyphMetrics::update ( in unsigned long  updatemask) [inherited]

Called by this object's corresponding nsISVGGlyphMetricsSource 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 nsISVGGlyphMetricsSource.
Returns:
PR_TRUE if the metrics have changed as a result of the source update, PR_FALSE otherwise.

Member Data Documentation

readonly attribute float nsISVGRendererGlyphMetrics::advance [inherited]

Untransformed width of the composite glyph in pixels.

Definition at line 71 of file nsISVGRendererGlyphMetrics.idl.

Definition at line 92 of file nsISVGRendererGlyphMetrics.idl.

const unsigned short nsISVGRendererGlyphMetrics::BASELINE_CENTRAL = 4 [inherited]

Definition at line 96 of file nsISVGRendererGlyphMetrics.idl.

const unsigned short nsISVGRendererGlyphMetrics::BASELINE_HANGING = 1 [inherited]

Definition at line 93 of file nsISVGRendererGlyphMetrics.idl.

Definition at line 94 of file nsISVGRendererGlyphMetrics.idl.

Definition at line 95 of file nsISVGRendererGlyphMetrics.idl.

const unsigned short nsISVGRendererGlyphMetrics::BASELINE_MIDDLE = 5 [inherited]

Definition at line 97 of file nsISVGRendererGlyphMetrics.idl.

Definition at line 99 of file nsISVGRendererGlyphMetrics.idl.

Definition at line 98 of file nsISVGRendererGlyphMetrics.idl.

class nsSVGCairoGlyphMetrics

Cairo glyph metrics implementation.

Definition at line 70 of file nsSVGCairoGlyphMetrics.cpp.

Inheritance diagram for nsSVGCairoGlyphMetrics:
Collaboration diagram for nsSVGCairoGlyphMetrics:

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSISVGRENDERERGLYPHMETRICS 
NS_IMETHOD_ (void) SelectFont(cairo_t *ctx)
nsIDOMSVGRect getExtentOfChar (in unsigned long charnum)
 Get the untransformed bounding box of an individual glyph.
float getAdvanceOfChar (in unsigned long charnum)
 Get the advance of an individual glyph.
float getBaselineOffset (in unsigned short baselineIdentifier)
 Retrieve the (y-axis) offset of the given baseline.
boolean update (in unsigned long updatemask)
 Called by this object's corresponding nsISVGGlyphMetricsSource as a notification that some of the source's data (identified by paramter 'updatemask') has changed.

Public Attributes

readonly attribute float advance
 Untransformed width of the composite glyph in pixels.
Baseline offset constants for getBaselineOffset()
const unsigned short BASELINE_ALPHABETIC = 0
const unsigned short BASELINE_HANGING = 1
const unsigned short BASELINE_IDEOGRAPHC = 2
const unsigned short BASELINE_MATHEMATICAL = 3
const unsigned short BASELINE_CENTRAL = 4
const unsigned short BASELINE_MIDDLE = 5
const unsigned short BASELINE_TEXT_BEFORE_EDGE = 6
const unsigned short BASELINE_TEXT_AFTER_EDGE = 7

Protected Member Functions

 nsSVGCairoGlyphMetrics (nsISVGGlyphMetricsSource *src)
 ~nsSVGCairoGlyphMetrics ()

Private Attributes

cairo_t * mCT
cairo_text_extents_t mExtents
nsCOMPtr
< nsISVGGlyphMetricsSource
mSource

Friends

nsresult NS_NewSVGCairoGlyphMetrics (nsISVGRendererGlyphMetrics **result, nsISVGGlyphMetricsSource *src)

Member Function Documentation

float nsISVGRendererGlyphMetrics::getAdvanceOfChar ( in unsigned long  charnum) [inherited]

Get the advance of an individual glyph.

float nsISVGRendererGlyphMetrics::getBaselineOffset ( in unsigned short  baselineIdentifier) [inherited]

Retrieve the (y-axis) offset of the given baseline.

Parameters:
baselineIdentifierOne of the BASELINE_* constants defined in this interface.
Returns:
Y-axis offset in pixels relative to top of bounding box.

Get the untransformed bounding box of an individual glyph.

Parameters:
charnumThe index of the character in nsISVGGlyphMetricsSource::characterData whose glyph bounding box is to be determined
Returns:
The untransformed bounding box in pixel coordinates
boolean nsISVGRendererGlyphMetrics::update ( in unsigned long  updatemask) [inherited]

Called by this object's corresponding nsISVGGlyphMetricsSource 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 nsISVGGlyphMetricsSource.
Returns:
PR_TRUE if the metrics have changed as a result of the source update, PR_FALSE otherwise.

Member Data Documentation

readonly attribute float nsISVGRendererGlyphMetrics::advance [inherited]

Untransformed width of the composite glyph in pixels.

Definition at line 71 of file nsISVGRendererGlyphMetrics.idl.

Definition at line 92 of file nsISVGRendererGlyphMetrics.idl.

const unsigned short nsISVGRendererGlyphMetrics::BASELINE_CENTRAL = 4 [inherited]

Definition at line 96 of file nsISVGRendererGlyphMetrics.idl.

const unsigned short nsISVGRendererGlyphMetrics::BASELINE_HANGING = 1 [inherited]

Definition at line 93 of file nsISVGRendererGlyphMetrics.idl.

Definition at line 94 of file nsISVGRendererGlyphMetrics.idl.

Definition at line 95 of file nsISVGRendererGlyphMetrics.idl.

const unsigned short nsISVGRendererGlyphMetrics::BASELINE_MIDDLE = 5 [inherited]

Definition at line 97 of file nsISVGRendererGlyphMetrics.idl.

Definition at line 99 of file nsISVGRendererGlyphMetrics.idl.

Definition at line 98 of file nsISVGRendererGlyphMetrics.idl.

class nsISVGGDIPlusCanvas

'Private' rendering engine interface

Definition at line 64 of file nsISVGGDIPlusCanvas.h.

Inheritance diagram for nsISVGGDIPlusCanvas:
Collaboration diagram for nsISVGGDIPlusCanvas:

Public Member Functions

 NS_IMETHOD_ (Graphics *) GetGraphics()=0
 Obtain the Gdiplus::Graphics object for this canvas.
 NS_IMETHOD_ (Region *) GetClipRegion()=0
 Obtain the GdiPlus::Region clip path.
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

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.
nsISVGGDIPlusCanvas::NS_IMETHOD_ ( Graphics *  ) [pure virtual]

Obtain the Gdiplus::Graphics object for this canvas.

Implemented in nsSVGGDIPlusCanvas.

nsISVGGDIPlusCanvas::NS_IMETHOD_ ( Region *  ) [pure virtual]

Obtain the GdiPlus::Region clip path.

Implemented in nsSVGGDIPlusCanvas.

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 nsISVGGDIPlusGlyphMetrics

'Private' rendering engine interface

Definition at line 55 of file nsISVGGDIPlusGlyphMetrics.h.

Inheritance diagram for nsISVGGDIPlusGlyphMetrics:
Collaboration diagram for nsISVGGDIPlusGlyphMetrics:

Public Member Functions

 NS_IMETHOD_ (const RectF *) GetBoundingRect()=0
 Obtain the bounding rectangle of the (composite) glyph as a Gdiplus::RectF.
 NS_IMETHOD_ (void) GetSubBoundingRect(PRUint32 charoffset
 Obtain the bounding rectangle of the glyphs of part of the character string as a Gdiplus::RectF.
 NS_IMETHOD_ (const Font *) GetFont()=0
 Obtain the Gdiplus::Font object selected for this glyph metrics object.
 NS_IMETHOD_ (TextRenderingHint) GetTextRenderingHint()=0
 Obtain the Gdiplus::TextRenderingHint for this glyph metrics object.
nsIDOMSVGRect getExtentOfChar (in unsigned long charnum)
 Get the untransformed bounding box of an individual glyph.
float getAdvanceOfChar (in unsigned long charnum)
 Get the advance of an individual glyph.
float getBaselineOffset (in unsigned short baselineIdentifier)
 Retrieve the (y-axis) offset of the given baseline.
boolean update (in unsigned long updatemask)
 Called by this object's corresponding nsISVGGlyphMetricsSource as a notification that some of the source's data (identified by paramter 'updatemask') has changed.

Public Attributes

PRUint32 count
PRUint32 RectF * retval
PRUint32 RectF PRBool aLocalCoord = PR_TRUE)=0
readonly attribute float advance
 Untransformed width of the composite glyph in pixels.
Baseline offset constants for getBaselineOffset()
const unsigned short BASELINE_ALPHABETIC = 0
const unsigned short BASELINE_HANGING = 1
const unsigned short BASELINE_IDEOGRAPHC = 2
const unsigned short BASELINE_MATHEMATICAL = 3
const unsigned short BASELINE_CENTRAL = 4
const unsigned short BASELINE_MIDDLE = 5
const unsigned short BASELINE_TEXT_BEFORE_EDGE = 6
const unsigned short BASELINE_TEXT_AFTER_EDGE = 7

Member Function Documentation

float nsISVGRendererGlyphMetrics::getAdvanceOfChar ( in unsigned long  charnum) [inherited]

Get the advance of an individual glyph.

float nsISVGRendererGlyphMetrics::getBaselineOffset ( in unsigned short  baselineIdentifier) [inherited]

Retrieve the (y-axis) offset of the given baseline.

Parameters:
baselineIdentifierOne of the BASELINE_* constants defined in this interface.
Returns:
Y-axis offset in pixels relative to top of bounding box.

Get the untransformed bounding box of an individual glyph.

Parameters:
charnumThe index of the character in nsISVGGlyphMetricsSource::characterData whose glyph bounding box is to be determined
Returns:
The untransformed bounding box in pixel coordinates
nsISVGGDIPlusGlyphMetrics::NS_IMETHOD_ ( const RectF *  ) [pure virtual]

Obtain the bounding rectangle of the (composite) glyph as a Gdiplus::RectF.

Implemented in nsSVGGDIPlusGlyphMetrics.

Obtain the bounding rectangle of the glyphs of part of the character string as a Gdiplus::RectF.

Parameters:
charoffsetOffset into nsISVGGlyphMetricsSource::characterData.
countNumber of characters for which to get bounds.

Reimplemented in nsSVGGDIPlusGlyphMetrics.

nsISVGGDIPlusGlyphMetrics::NS_IMETHOD_ ( const Font *  ) [pure virtual]

Obtain the Gdiplus::Font object selected for this glyph metrics object.

Implemented in nsSVGGDIPlusGlyphMetrics.

nsISVGGDIPlusGlyphMetrics::NS_IMETHOD_ ( TextRenderingHint  ) [pure virtual]

Obtain the Gdiplus::TextRenderingHint for this glyph metrics object.

Implemented in nsSVGGDIPlusGlyphMetrics.

boolean nsISVGRendererGlyphMetrics::update ( in unsigned long  updatemask) [inherited]

Called by this object's corresponding nsISVGGlyphMetricsSource 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 nsISVGGlyphMetricsSource.
Returns:
PR_TRUE if the metrics have changed as a result of the source update, PR_FALSE otherwise.

Member Data Documentation

readonly attribute float nsISVGRendererGlyphMetrics::advance [inherited]

Untransformed width of the composite glyph in pixels.

Definition at line 71 of file nsISVGRendererGlyphMetrics.idl.

Definition at line 92 of file nsISVGRendererGlyphMetrics.idl.

const unsigned short nsISVGRendererGlyphMetrics::BASELINE_CENTRAL = 4 [inherited]

Definition at line 96 of file nsISVGRendererGlyphMetrics.idl.

const unsigned short nsISVGRendererGlyphMetrics::BASELINE_HANGING = 1 [inherited]

Definition at line 93 of file nsISVGRendererGlyphMetrics.idl.

Definition at line 94 of file nsISVGRendererGlyphMetrics.idl.

Definition at line 95 of file nsISVGRendererGlyphMetrics.idl.

const unsigned short nsISVGRendererGlyphMetrics::BASELINE_MIDDLE = 5 [inherited]

Definition at line 97 of file nsISVGRendererGlyphMetrics.idl.

Definition at line 99 of file nsISVGRendererGlyphMetrics.idl.

Definition at line 98 of file nsISVGRendererGlyphMetrics.idl.

class nsISVGGDIPlusRegion

'Private' rendering engine interface

Definition at line 70 of file nsISVGGDIPlusRegion.h.

Inheritance diagram for nsISVGGDIPlusRegion:
Collaboration diagram for nsISVGGDIPlusRegion:

Public Member Functions

 NS_IMETHOD_ (const RectF *) GetRect() const =0
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.

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.
nsISVGGDIPlusRegion::NS_IMETHOD_ ( const RectF *  ) const [pure virtual]

Implemented in nsSVGGDIPlusRegion.

class nsISVGGDIPlusSurface

'Private' rendering engine interface

Definition at line 56 of file nsISVGGDIPlusSurface.h.

Inheritance diagram for nsISVGGDIPlusSurface:
Collaboration diagram for nsISVGGDIPlusSurface:

Public Member Functions

 NS_IMETHOD_ (Bitmap *) GetSurface()=0
 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

Member Function Documentation

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

Obtain the Gdiplus::Graphics object for this canvas.

Implemented in nsSVGGDIPlusSurface.


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 nsSVGGDIPlusCanvas

GDI+ canvas implementation.

Definition at line 68 of file nsSVGGDIPlusCanvas.cpp.

Inheritance diagram for nsSVGGDIPlusCanvas:
Collaboration diagram for nsSVGGDIPlusCanvas:

Public Member Functions

 nsSVGGDIPlusCanvas ()
 ~nsSVGGDIPlusCanvas ()
nsresult Init (nsIRenderingContext *ctx, nsPresContext *presContext, const nsRect &dirtyRect)
NS_DECL_ISUPPORTS
NS_DECL_NSISVGRENDERERCANVAS 
NS_IMETHOD_ (Graphics *) GetGraphics()
 Obtain the Gdiplus::Graphics object for this canvas.
 NS_IMETHOD_ (Region *) GetClipRegion()
 Obtain the GdiPlus::Region clip path.
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
Graphics * mGraphics
nsVoidArray mClipStack
nsVoidArray mSurfaceStack
Region mClipRegion
PRUint16 mRenderMode

Constructor & Destructor Documentation

Definition at line 108 of file nsSVGGDIPlusCanvas.cpp.

    : mGraphics(nsnull)
#ifdef SVG_GDIPLUS_ENABLE_OFFSCREEN_BUFFER
      , mOffscreenBitmap(nsnull), mOffscreenGraphics(nsnull), mOffscreenHDC(nsnull)
#endif
{
}

Definition at line 116 of file nsSVGGDIPlusCanvas.cpp.

{
#ifdef SVG_GDIPLUS_ENABLE_OFFSCREEN_BUFFER
  if (mOffscreenGraphics)
    delete mOffscreenGraphics;
  if (mOffscreenBitmap)
    delete mOffscreenBitmap;
#endif
  if (mGraphics)
    delete mGraphics;
  mMozContext = nsnull;
}

Member Function Documentation

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 nsSVGGDIPlusCanvas::Init ( nsIRenderingContext ctx,
nsPresContext presContext,
const nsRect dirtyRect 
)

Definition at line 130 of file nsSVGGDIPlusCanvas.cpp.

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

  HDC hdc;
  // this ctx better be what we think it is...
  mMozContext->RetrieveCurrentNativeGraphicData((PRUint32 *)(&hdc));
    
  mGraphics = new Graphics(hdc);
  if (!mGraphics) return NS_ERROR_FAILURE;

  // Work in pixel units instead of the default DisplayUnits.
  mGraphics->SetPageUnit(UnitPixel);

  // We'll scale our logical 'pixles' to device units according to the
  // resolution of the device. For display devices, the canonical
  // pixel scale will be 1, for printers it will be some other value:
  nsCOMPtr<nsIDeviceContext>  devcontext;
  mMozContext->GetDeviceContext(*getter_AddRefs(devcontext));
  float scale;
  devcontext->GetCanonicalPixelScale(scale);

  mGraphics->SetPageScale(scale);

  
  // get the translation set on the rendering context. It will be in
  // displayunits (i.e. pixels*scale), *not* pixels:
  nsTransform2D* xform;
  mMozContext->GetCurrentTransform(xform);
  float dx, dy;
  xform->GetTranslation(&dx, &dy);

#if defined(DEBUG) && defined(SVG_DEBUG_PRINTING)
  printf("nsSVGGDIPlusCanvas(%p)::Init()[\n", this);
  printf("pagescale=%f\n", scale);
  printf("page unit=%d\n", mGraphics->GetPageUnit());
  printf("]\n");
#endif
  
#ifdef SVG_GDIPLUS_ENABLE_OFFSCREEN_BUFFER
  mGraphics->TranslateTransform(dx+dirtyRect.x, dy+dirtyRect.y);

  // GDI+ internally works on 32bpp surfaces. Writing directly to
  // Mozilla's backbuffer can be very slow if it hasn't got the right
  // format (!=32bpp).  For complex SVG docs it is advantageous to
  // render to a 32bppPARGB bitmap first:
  mOffscreenBitmap = new Bitmap(dirtyRect.width, dirtyRect.height, PixelFormat32bppPARGB);
  if (!mOffscreenBitmap) return NS_ERROR_FAILURE;
  mOffscreenGraphics = new Graphics(mOffscreenBitmap);
  if (!mOffscreenGraphics) return NS_ERROR_FAILURE;
  mOffscreenGraphics->TranslateTransform((float)-dirtyRect.x, (float)-dirtyRect.y);
#else
  mGraphics->TranslateTransform(dx/scale, dy/scale, MatrixOrderPrepend);
#endif

  mRenderMode = SVG_RENDER_MODE_NORMAL;
  
  return NS_OK;
}

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 nsSVGGDIPlusCanvas::NS_IMETHOD_ ( Graphics *  ) [virtual]

Obtain the Gdiplus::Graphics object for this canvas.

Implements nsISVGGDIPlusCanvas.

nsSVGGDIPlusCanvas::NS_IMETHOD_ ( Region *  ) [virtual]

Obtain the GdiPlus::Region clip path.

Implements nsISVGGDIPlusCanvas.

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

Definition at line 92 of file nsSVGGDIPlusCanvas.cpp.

Graphics* nsSVGGDIPlusCanvas::mGraphics [private]

Definition at line 89 of file nsSVGGDIPlusCanvas.cpp.

Definition at line 93 of file nsSVGGDIPlusCanvas.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 nsSVGGDIPlusGlyphGeometry

GDI+ glyph geometry implementation.

Definition at line 78 of file nsSVGGDIPlusGlyphGeometry.cpp.

Inheritance diagram for nsSVGGDIPlusGlyphGeometry:
Collaboration diagram for nsSVGGDIPlusGlyphGeometry:

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

 nsSVGGDIPlusGlyphGeometry ()
 ~nsSVGGDIPlusGlyphGeometry ()
nsresult Init (nsISVGGlyphGeometrySource *src)
void DrawFill (Graphics *g, Brush &b, nsISVGGradient *aGrad, const WCHAR *start, INT length, float x, float y)
void GetGlobalTransform (Matrix *matrix)
void UpdateStroke ()
void UpdateRegions ()

Protected Attributes

nsCOMPtr
< nsISVGGlyphGeometrySource
mSource
nsCOMPtr< nsISVGRendererRegionmCoveredRegion
Region * mHitTestRegion
GraphicsPath * mStroke

Friends

nsresult NS_NewSVGGDIPlusGlyphGeometry (nsISVGRendererGlyphGeometry **result, nsISVGGlyphGeometrySource *src)
void gradCBPath (Graphics *gfx, Brush *brush, void *cbStruct)

Constructor & Destructor Documentation


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.
void nsSVGGDIPlusGlyphGeometry::DrawFill ( Graphics *  g,
Brush &  b,
nsISVGGradient aGrad,
const WCHAR start,
INT  length,
float  x,
float  y 
) [protected]

Definition at line 440 of file nsSVGGDIPlusGlyphGeometry.cpp.

{
  nsCOMPtr<nsISVGGDIPlusGlyphMetrics> metrics;
  {
    nsCOMPtr<nsISVGRendererGlyphMetrics> xpmetrics;
    mSource->GetMetrics(getter_AddRefs(xpmetrics));
    metrics = do_QueryInterface(xpmetrics);
    NS_ASSERTION(metrics, "wrong metrics object!");
    if (!metrics) return;
  }

  GraphicsState state = g->Save();
  
  Matrix m;
  GetGlobalTransform(&m);
  g->MultiplyTransform(&m);
  g->SetTextRenderingHint(metrics->GetTextRenderingHint());

  StringFormat stringFormat(StringFormat::GenericTypographic());
  stringFormat.SetFormatFlags(stringFormat.GetFormatFlags() |
                              StringFormatFlagsMeasureTrailingSpaces);
  stringFormat.SetLineAlignment(StringAlignmentNear);

  nsSVGCharacterPosition *cp;
  if (NS_FAILED(mSource->GetCharacterPosition(&cp)))
    return;
  
  if (aGrad) {
    nsCOMPtr<nsISVGRendererRegion> region;
    GetCoveredRegion(getter_AddRefs(region));
    nsCOMPtr<nsISVGGDIPlusRegion> aRegion = do_QueryInterface(region);
    nsCOMPtr<nsIDOMSVGMatrix> ctm;
    mSource->GetCanvasTM(getter_AddRefs(ctm));
    
    gradCallbackStruct cb;
    cb.start = start;
    cb.length = length;
    cb.metrics = metrics;
    cb.x = x;  cb.y = y;
    cb.stringformat = &stringFormat;
    cb.cp = cp;

    GDIPlusGradient(aRegion, aGrad, ctm, g, mSource, gradCBString, &cb);
  }
  else {
    if (!cp) {
      g->DrawString(start, length, metrics->GetFont(), PointF(x,y),
                    &stringFormat, &b);
    } else {
      for (PRUint32 i=0; i<length; i++) {
        if (cp[i].draw == PR_FALSE)
          continue;
        GraphicsState state = g->Save();
        g->TranslateTransform(cp[i].x, cp[i].y);
        g->RotateTransform(cp[i].angle * 180.0 / M_PI);
        g->DrawString(start + i, 1, metrics->GetFont(), PointF(0, 0),
                      &stringFormat, &b);
        g->Restore(state);
      }
    }
  }
  
  delete [] cp;
  
  g->Restore(state);
}

Here is the call graph for this function:

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

Returns:
Covered region.
void nsSVGGDIPlusGlyphGeometry::GetGlobalTransform ( Matrix *  matrix) [protected]

Definition at line 510 of file nsSVGGDIPlusGlyphGeometry.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;

  matrix->SetElements(m[0],m[1],m[2],m[3],m[4],m[5]);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 126 of file nsSVGGDIPlusGlyphGeometry.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.

Definition at line 699 of file nsSVGGDIPlusGlyphGeometry.cpp.

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

  nsCOMPtr<nsISVGGDIPlusGlyphMetrics> metrics;
  {
    nsCOMPtr<nsISVGRendererGlyphMetrics> xpmetrics;
    mSource->GetMetrics(getter_AddRefs(xpmetrics));
    metrics = do_QueryInterface(xpmetrics);
    NS_ASSERTION(metrics, "wrong metrics object!");
    if (!metrics) return;
  }

  nsAutoString text;
  mSource->GetCharacterData(text);
  nsSVGCharacterPosition *cp;
  if (NS_FAILED(mSource->GetCharacterPosition(&cp)))
    return;

  if (!cp) {
    mHitTestRegion = new Region(*metrics->GetBoundingRect());
    if (!mHitTestRegion)
      return;
    
    float x,y;
    mSource->GetX(&x);
    mSource->GetY(&y);
    mHitTestRegion->Translate(x, y);
  } else {
    GraphicsPath string;
    for (PRUint32 i=0; i<text.Length(); i++) {
      if (cp[i].draw == PR_FALSE)
        continue;
      GraphicsPath glyph;
      Matrix matrix;

      matrix.Translate(cp[i].x, cp[i].y);
      matrix.Rotate(cp[i].angle * 180.0 / M_PI);

      RectF bounds;
      metrics->GetSubBoundingRect(i, 1, &bounds);
      bounds.X = bounds.Y = 0;
      glyph.AddRectangle(bounds);
      glyph.Transform(&matrix);
      string.AddPath(&glyph, FALSE);
    }
    mHitTestRegion = new Region(&string);
    if (!mHitTestRegion) {
      delete [] cp;
      return;
    }
  }

  delete [] cp;

  Matrix m;
  GetGlobalTransform(&m);
  mHitTestRegion->Transform(&m);

  // clone the covered region from the hit-test region:

  nsCOMPtr<nsPresContext> presContext;
  mSource->GetPresContext(getter_AddRefs(presContext));

  NS_NewSVGGDIPlusClonedRegion(getter_AddRefs(mCoveredRegion),
                               mHitTestRegion,
                               presContext);
}

Here is the call graph for this function:

Definition at line 540 of file nsSVGGDIPlusGlyphGeometry.cpp.

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

  PRUint16 type;
  mSource->GetStrokePaintType(&type);
  if (type == nsISVGGeometrySource::PAINT_TYPE_NONE)
    return;

  float width;
  mSource->GetStrokeWidth(&width);
  
  if (width==0.0f) return;

  nsCOMPtr<nsISVGGDIPlusGlyphMetrics> metrics;
  {
    nsCOMPtr<nsISVGRendererGlyphMetrics> xpmetrics;
    mSource->GetMetrics(getter_AddRefs(xpmetrics));
    metrics = do_QueryInterface(xpmetrics);
    NS_ASSERTION(metrics, "wrong metrics object!");
    if (!metrics) return;
  }

  
  mStroke = new GraphicsPath();
  if (!mStroke) {
    NS_ERROR("couldn't construct graphicspath");
    return;
  }

  FontFamily fontFamily;
  metrics->GetFont()->GetFamily(&fontFamily);
  
  nsAutoString text;
  mSource->GetCharacterData(text);

  float x,y;
  mSource->GetX(&x);
  mSource->GetY(&y);

  nsSVGCharacterPosition *cp;
  if (NS_FAILED(mSource->GetCharacterPosition(&cp)))
    return;

  if (!cp) {
    mStroke->AddString(PromiseFlatString(text).get(), -1, &fontFamily,
                       metrics->GetFont()->GetStyle(),
                       metrics->GetFont()->GetSize(),
                       PointF(x,y), StringFormat::GenericTypographic());
  } else {
    for (PRUint32 i=0; i<text.Length(); i++) {
      if (cp[i].draw == PR_FALSE)
        continue;
      GraphicsPath glyph;
      Matrix matrix;

      matrix.Translate(cp[i].x, cp[i].y);
      matrix.Rotate(cp[i].angle * 180.0 / M_PI);
      glyph.AddString(PromiseFlatString(text).get() + i, 1, &fontFamily,
                      metrics->GetFont()->GetStyle(),
                      metrics->GetFont()->GetSize(),
                      PointF(0,0), StringFormat::GenericTypographic());
      glyph.Transform(&matrix);
      mStroke->AddPath(&glyph, FALSE);
    }
  }
  
  delete [] cp;

  // gdi+ seems to widen paths to >1 width unit. If our pen width is
  // smaller, we need to widen an appropriately enlarged path and then
  // scale it down after widening:
  PRBool scaleToUnitPen = width<1.0f;
  
  Pen pen(Color(), scaleToUnitPen ? 1.0f : width);

  // set linecap style
  PRUint16 capStyle;
  LineCap lcap;
  DashCap dcap;
  mSource->GetStrokeLinecap(&capStyle);
  switch (capStyle) {
    case nsISVGGeometrySource::STROKE_LINECAP_BUTT:
      lcap = LineCapFlat;
      dcap = DashCapFlat;
      break;
    case nsISVGGeometrySource::STROKE_LINECAP_ROUND:
      lcap = LineCapRound;
      dcap = DashCapRound;
      break;
    case nsISVGGeometrySource::STROKE_LINECAP_SQUARE:
      lcap = LineCapSquare;
      dcap = DashCapFlat;
      break;
  }
  pen.SetLineCap(lcap, lcap, dcap);


  // set linejoin style:
  PRUint16 joinStyle;
  LineJoin join;
  mSource->GetStrokeLinejoin(&joinStyle);
  switch(joinStyle) {
    case nsISVGGeometrySource::STROKE_LINEJOIN_MITER:
      join = LineJoinMiterClipped;
      break;
    case nsISVGGeometrySource::STROKE_LINEJOIN_ROUND:
      join = LineJoinRound;
      break;
    case nsISVGGeometrySource::STROKE_LINEJOIN_BEVEL:
      join = LineJoinBevel;
      break;
  }
  pen.SetLineJoin(join);
  
  // set miterlimit:
  float miterlimit;
  mSource->GetStrokeMiterlimit(&miterlimit);
  pen.SetMiterLimit(miterlimit);

  // set pen dashpattern
  float *dashArray;
  PRUint32 count;
  mSource->GetStrokeDashArray(&dashArray, &count);
  if (count>0) {
    if (!scaleToUnitPen) {
      for (PRUint32 i=0; i<count; ++i)
        dashArray[i]/=width;
    }
    
    pen.SetDashPattern(dashArray, count);
    nsMemory::Free(dashArray);

    float offset;
    mSource->GetStrokeDashoffset(&offset);
    if (!scaleToUnitPen)
      offset/=width;
    pen.SetDashOffset(offset);
  }

  Matrix m;
  GetGlobalTransform(&m);

  if (scaleToUnitPen) {
    Matrix enlarge(1/width, 0, 0, 1/width, 0, 0);
    mStroke->Transform(&enlarge);
    m.Scale(width,width);
  }

  
  mStroke->Widen(&pen);
  mStroke->Transform(&m);
//  mStroke->Outline();
}

Here is the call graph for this function:


Friends And Related Function Documentation

void gradCBPath ( Graphics *  gfx,
Brush *  brush,
void cbStruct 
) [friend]

Definition at line 170 of file nsSVGGDIPlusGlyphGeometry.cpp.

{
  nsSVGGDIPlusGlyphGeometry *geom = (nsSVGGDIPlusGlyphGeometry *)cbStruct;
  gfx->FillPath(brush, geom->mStroke);
}

Definition at line 134 of file nsSVGGDIPlusGlyphGeometry.cpp.

{
  *result = nsnull;
  
  nsSVGGDIPlusGlyphGeometry* gg = new nsSVGGDIPlusGlyphGeometry();
  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.

Definition at line 105 of file nsSVGGDIPlusGlyphGeometry.cpp.

GraphicsPath* nsSVGGDIPlusGlyphGeometry::mStroke [protected]

Definition at line 106 of file nsSVGGDIPlusGlyphGeometry.cpp.

class nsWindowsDC

Helper class used by nsSVGGDIPlusGlyphMetrics.

Wraps a Windows device context handle.

Definition at line 73 of file nsSVGGDIPlusGlyphMetrics.cpp.

Public Member Functions

 nsWindowsDC (nsPresContext *presContext)
 ~nsWindowsDC ()
 operator HDC ()

Private Attributes

bool isWndDC
HWND mWND
HDC mHDC

Constructor & Destructor Documentation

Definition at line 87 of file nsSVGGDIPlusGlyphMetrics.cpp.

{
  nsIDeviceContext* devicecontext = presContext->DeviceContext();

  isWndDC=((nsDeviceContextWin *)devicecontext)->mDC==nsnull;
  if (isWndDC) {
    mWND = (HWND)((nsDeviceContextWin *)devicecontext)->mWidget;
    NS_ASSERTION(mWND, "no window and no handle in devicecontext (continuing with screen dc)");
    mHDC = ::GetDC(mWND);
  }
  else
    mHDC = ((nsDeviceContextWin *)devicecontext)->mDC;
}

Here is the call graph for this function:

Definition at line 101 of file nsSVGGDIPlusGlyphMetrics.cpp.

{
  if (isWndDC)
    ::ReleaseDC(mWND, mHDC);
}

Member Function Documentation

nsWindowsDC::operator HDC ( ) [inline]

Definition at line 77 of file nsSVGGDIPlusGlyphMetrics.cpp.

{ return mHDC; }

Member Data Documentation

Definition at line 79 of file nsSVGGDIPlusGlyphMetrics.cpp.

HDC nsWindowsDC::mHDC [private]

Definition at line 81 of file nsSVGGDIPlusGlyphMetrics.cpp.

Definition at line 80 of file nsSVGGDIPlusGlyphMetrics.cpp.

class nsSVGGDIPlusGlyphMetrics

GDI+ glyph metrics implementation.

Definition at line 115 of file nsSVGGDIPlusGlyphMetrics.cpp.

Inheritance diagram for nsSVGGDIPlusGlyphMetrics:
Collaboration diagram for nsSVGGDIPlusGlyphMetrics:

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSISVGRENDERERGLYPHMETRICS 
NS_IMETHOD_ (const RectF *) GetBoundingRect()
 Obtain the bounding rectangle of the (composite) glyph as a Gdiplus::RectF.
 NS_IMETHOD_ (void) GetSubBoundingRect(PRUint32 charoffset
 Obtain the bounding rectangle of the glyphs of part of the character string as a Gdiplus::RectF.
 NS_IMETHOD_ (const Font *) GetFont()
 Obtain the Gdiplus::Font object selected for this glyph metrics object.
 NS_IMETHOD_ (TextRenderingHint) GetTextRenderingHint()
 Obtain the Gdiplus::TextRenderingHint for this glyph metrics object.
nsIDOMSVGRect getExtentOfChar (in unsigned long charnum)
 Get the untransformed bounding box of an individual glyph.
float getAdvanceOfChar (in unsigned long charnum)
 Get the advance of an individual glyph.
float getBaselineOffset (in unsigned short baselineIdentifier)
 Retrieve the (y-axis) offset of the given baseline.
boolean update (in unsigned long updatemask)
 Called by this object's corresponding nsISVGGlyphMetricsSource as a notification that some of the source's data (identified by paramter 'updatemask') has changed.

Public Attributes

PRUint32 count
PRUint32 RectF * retval
PRUint32 RectF PRBool aLocalCoord = PR_TRUE)
readonly attribute float advance
 Untransformed width of the composite glyph in pixels.
Baseline offset constants for getBaselineOffset()
const unsigned short BASELINE_ALPHABETIC = 0
const unsigned short BASELINE_HANGING = 1
const unsigned short BASELINE_IDEOGRAPHC = 2
const unsigned short BASELINE_MATHEMATICAL = 3
const unsigned short BASELINE_CENTRAL = 4
const unsigned short BASELINE_MIDDLE = 5
const unsigned short BASELINE_TEXT_BEFORE_EDGE = 6
const unsigned short BASELINE_TEXT_AFTER_EDGE = 7

Static Public Attributes

static nsDataHashtable
< nsStringHashKey, const
nsString * > 
sFontAliases

Protected Member Functions

 nsSVGGDIPlusGlyphMetrics (nsISVGGlyphMetricsSource *src)
 ~nsSVGGDIPlusGlyphMetrics ()
void MarkRectForUpdate ()
void ClearFontInfo ()
void InitializeFontInfo ()
void GetGlobalTransform (Matrix *matrix)
void PrepareGraphics (Graphics &g)
float GetPixelScale ()

Private Attributes

PRBool mRectNeedsUpdate
RectF mRect
Font * mFont
nsCOMPtr
< nsISVGGlyphMetricsSource
mSource

Friends

nsresult NS_NewSVGGDIPlusGlyphMetrics (nsISVGRendererGlyphMetrics **result, nsISVGGlyphMetricsSource *src)
void NS_InitSVGGDIPlusGlyphMetricsGlobals ()
void NS_FreeSVGGDIPlusGlyphMetricsGlobals ()

Constructor & Destructor Documentation

Definition at line 169 of file nsSVGGDIPlusGlyphMetrics.cpp.

Here is the call graph for this function:


Member Function Documentation

Definition at line 140 of file nsSVGGDIPlusGlyphMetrics.cpp.

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

Here is the caller graph for this function:

float nsISVGRendererGlyphMetrics::getAdvanceOfChar ( in unsigned long  charnum) [inherited]

Get the advance of an individual glyph.

float nsISVGRendererGlyphMetrics::getBaselineOffset ( in unsigned short  baselineIdentifier) [inherited]

Retrieve the (y-axis) offset of the given baseline.

Parameters:
baselineIdentifierOne of the BASELINE_* constants defined in this interface.
Returns:
Y-axis offset in pixels relative to top of bounding box.

Get the untransformed bounding box of an individual glyph.

Parameters:
charnumThe index of the character in nsISVGGlyphMetricsSource::characterData whose glyph bounding box is to be determined
Returns:
The untransformed bounding box in pixel coordinates
void nsSVGGDIPlusGlyphMetrics::GetGlobalTransform ( Matrix *  matrix) [protected]

Definition at line 568 of file nsSVGGDIPlusGlyphMetrics.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;

  matrix->SetElements(m[0],m[1],m[2],m[3],m[4],m[5]);
}

Here is the call graph for this function:

Definition at line 612 of file nsSVGGDIPlusGlyphMetrics.cpp.

{
  nsCOMPtr<nsPresContext> presContext;
  mSource->GetPresContext(getter_AddRefs(presContext));
  if (!presContext) {
    NS_ERROR("null prescontext");
    return 1.0f;
  }

  float scale;
  presContext->DeviceContext()->GetCanonicalPixelScale(scale);
  return scale;
}  

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 517 of file nsSVGGDIPlusGlyphMetrics.cpp.

{
  if (mFont) return; // already initialized

  nsCOMPtr<nsPresContext> presContext;
  mSource->GetPresContext(getter_AddRefs(presContext));
  if (!presContext) {
    NS_ERROR("null prescontext");
    return;
  }

  float pxPerTwips;
  pxPerTwips = presContext->TwipsToPixels();
  pxPerTwips/=GetPixelScale();
  
  nsFont font;
  mSource->GetFont(&font);

  FontFamily *pFamily = nsnull;
  font.EnumerateFamilies(FindFontFamily, (void*)&pFamily);
  NS_ASSERTION(pFamily, "couldn't create family");

  int style = FontStyleRegular;
  if (font.style == NS_FONT_STYLE_ITALIC) style |= FontStyleItalic;
  if (font.weight % 100 == 0) { // absolute case
    if (font.weight >= 600) style |= FontStyleBold;
  }
  else if (font.weight % 100 < 50) { // relative 'bolder' case
    style |= FontStyleBold;
  }

  if (font.decorations & NS_FONT_DECORATION_UNDERLINE) style |= FontStyleUnderline;
  if (font.decorations & NS_FONT_DECORATION_LINE_THROUGH) style |= FontStyleStrikeout;
  
  mFont = new Font(pFamily, font.size*pxPerTwips, style, UnitPixel); 
  NS_ASSERTION(mFont->IsAvailable(),"font not available");
  delete pFamily;
  pFamily = nsnull;
  
#ifdef DEBUG
//   {
//     FontFamily fontFamily;
//     mFont->GetFamily(&fontFamily);
//     WCHAR familyName[100];
//     fontFamily.GetFamilyName(familyName);
//     printf("font loaded: "); printf(NS_ConvertUCS2toUTF8(familyName).get()); printf("\n");
//   }
#endif
}

Here is the call graph for this function:

NS_DECL_ISUPPORTS NS_DECL_NSISVGRENDERERGLYPHMETRICS nsSVGGDIPlusGlyphMetrics::NS_IMETHOD_ ( const RectF *  ) [virtual]

Obtain the bounding rectangle of the (composite) glyph as a Gdiplus::RectF.

Implements nsISVGGDIPlusGlyphMetrics.

Obtain the bounding rectangle of the glyphs of part of the character string as a Gdiplus::RectF.

Parameters:
charoffsetOffset into nsISVGGlyphMetricsSource::characterData.
countNumber of characters for which to get bounds.

Reimplemented from nsISVGGDIPlusGlyphMetrics.

Obtain the Gdiplus::Font object selected for this glyph metrics object.

Implements nsISVGGDIPlusGlyphMetrics.

nsSVGGDIPlusGlyphMetrics::NS_IMETHOD_ ( TextRenderingHint  ) [virtual]

Obtain the Gdiplus::TextRenderingHint for this glyph metrics object.

Implements nsISVGGDIPlusGlyphMetrics.

void nsSVGGDIPlusGlyphMetrics::PrepareGraphics ( Graphics &  g) [protected]

Definition at line 599 of file nsSVGGDIPlusGlyphMetrics.cpp.

{
  g.SetPageUnit(UnitPixel);
  // XXX for some reason the Graphics object that we derive from our
  // measurement dcs is never correctly scaled for devices like
  // printers. Hence we scale manually here:
  g.SetPageScale(GetPixelScale());
  g.SetSmoothingMode(SmoothingModeAntiAlias);
  //g.SetPixelOffsetMode(PixelOffsetModeHalf);
  g.SetTextRenderingHint(GetTextRenderingHint());
}

Here is the call graph for this function:

boolean nsISVGRendererGlyphMetrics::update ( in unsigned long  updatemask) [inherited]

Called by this object's corresponding nsISVGGlyphMetricsSource 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 nsISVGGlyphMetricsSource.
Returns:
PR_TRUE if the metrics have changed as a result of the source update, PR_FALSE otherwise.

Friends And Related Function Documentation

Definition at line 175 of file nsSVGGDIPlusGlyphMetrics.cpp.

{
  *result = new nsSVGGDIPlusGlyphMetrics(src);
  if (!*result) return NS_ERROR_OUT_OF_MEMORY;
  
  NS_ADDREF(*result);
  return NS_OK;
}

Member Data Documentation

readonly attribute float nsISVGRendererGlyphMetrics::advance [inherited]

Untransformed width of the composite glyph in pixels.

Definition at line 71 of file nsISVGRendererGlyphMetrics.idl.

Definition at line 92 of file nsISVGRendererGlyphMetrics.idl.

const unsigned short nsISVGRendererGlyphMetrics::BASELINE_CENTRAL = 4 [inherited]

Definition at line 96 of file nsISVGRendererGlyphMetrics.idl.

const unsigned short nsISVGRendererGlyphMetrics::BASELINE_HANGING = 1 [inherited]

Definition at line 93 of file nsISVGRendererGlyphMetrics.idl.

Definition at line 94 of file nsISVGRendererGlyphMetrics.idl.

Definition at line 95 of file nsISVGRendererGlyphMetrics.idl.

const unsigned short nsISVGRendererGlyphMetrics::BASELINE_MIDDLE = 5 [inherited]

Definition at line 97 of file nsISVGRendererGlyphMetrics.idl.

Definition at line 99 of file nsISVGRendererGlyphMetrics.idl.

Definition at line 98 of file nsISVGRendererGlyphMetrics.idl.

Definition at line 149 of file nsSVGGDIPlusGlyphMetrics.cpp.

Definition at line 148 of file nsSVGGDIPlusGlyphMetrics.cpp.

class PointStack

Helper class used by nsSVGGDIPlusPathBuilder.

Maintains a stack of points during the path building process.

Definition at line 62 of file nsSVGGDIPlusPathBuilder.cpp.

Collaboration diagram for PointStack:

Public Member Functions

 PointStack ()
 ~PointStack ()
void PushPoint (float x, float y)
const PointDataPopPoint ()

Private Member Functions

void Grow ()

Private Attributes

PointData mOrigin
PointDatamPoints
int mCapacity
int mSize

Constructor & Destructor Documentation

Definition at line 86 of file nsSVGGDIPlusPathBuilder.cpp.

    : mPoints(0), mCapacity(0), mSize(0)
{
  mOrigin.x = 0.0f;
  mOrigin.y = 0.0f;
}

Definition at line 93 of file nsSVGGDIPlusPathBuilder.cpp.

{
  if (mPoints) delete[] mPoints;
}

Member Function Documentation

void PointStack::Grow ( ) [private]

Definition at line 115 of file nsSVGGDIPlusPathBuilder.cpp.

{
  // nested subpaths are not very common, so we'll just grow linearly
  PointData *oldPoints = mPoints;
  mPoints = new PointData[++mCapacity];
  if (oldPoints) {
    memcpy(mPoints, oldPoints, sizeof(PointData) * mSize);
    delete[] oldPoints;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 108 of file nsSVGGDIPlusPathBuilder.cpp.

{
  if (mSize == 0) return &mOrigin;

  return &mPoints[--mSize];
}
void PointStack::PushPoint ( float  x,
float  y 
)

Definition at line 98 of file nsSVGGDIPlusPathBuilder.cpp.

{
  if (mCapacity-mSize<1)
    Grow();
  NS_ASSERTION(mCapacity-mSize>0, "no space in array");
  mPoints[mSize].x = x;
  mPoints[mSize].y = y;
  ++mSize;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 80 of file nsSVGGDIPlusPathBuilder.cpp.

Definition at line 78 of file nsSVGGDIPlusPathBuilder.cpp.

Definition at line 79 of file nsSVGGDIPlusPathBuilder.cpp.

Definition at line 81 of file nsSVGGDIPlusPathBuilder.cpp.

struct PointStack::PointData

Definition at line 68 of file nsSVGGDIPlusPathBuilder.cpp.

Class Members
float x
float y
class nsSVGGDIPlusPathBuilder

GDI+ path builder implementation.

Definition at line 134 of file nsSVGGDIPlusPathBuilder.cpp.

Inheritance diagram for nsSVGGDIPlusPathBuilder:
Collaboration diagram for nsSVGGDIPlusPathBuilder:

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

 nsSVGGDIPlusPathBuilder (nsISVGPathGeometrySource *src, GraphicsPath *dest)

Private Attributes

nsCOMPtr
< nsISVGPathGeometrySource
mSource
GraphicsPath * mPath
PointStack mSubPathStack
PointF mCurrentPoint

Friends

nsresult NS_NewSVGGDIPlusPathBuilder (nsISVGRendererPathBuilder **result, nsISVGPathGeometrySource *src, GraphicsPath *dest)

Constructor & Destructor Documentation

nsSVGGDIPlusPathBuilder::nsSVGGDIPlusPathBuilder ( nsISVGPathGeometrySource src,
GraphicsPath *  dest 
) [protected]

Definition at line 163 of file nsSVGGDIPlusPathBuilder.cpp.

    : mSource(src), mPath(dest)
{
  PRUint16 fillrule;
  mSource->GetFillRule(&fillrule);
  mPath->SetFillMode(fillrule==nsISVGGeometrySource::FILL_RULE_NONZERO ?
                     FillModeWinding : FillModeAlternate);
}

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_NewSVGGDIPlusPathBuilder ( nsISVGRendererPathBuilder **  result,
nsISVGPathGeometrySource src,
GraphicsPath *  dest 
) [friend]

Definition at line 174 of file nsSVGGDIPlusPathBuilder.cpp.

{
  *result = new nsSVGGDIPlusPathBuilder(src, dest);
  if (!result) return NS_ERROR_OUT_OF_MEMORY;

  NS_ADDREF(*result);

  return NS_OK;
}

Member Data Documentation

Definition at line 155 of file nsSVGGDIPlusPathBuilder.cpp.

GraphicsPath* nsSVGGDIPlusPathBuilder::mPath [private]

Definition at line 153 of file nsSVGGDIPlusPathBuilder.cpp.

class nsSVGGDIPlusPathGeometry

GDI+ path geometry implementation.

Definition at line 72 of file nsSVGGDIPlusPathGeometry.cpp.

Inheritance diagram for nsSVGGDIPlusPathGeometry:
Collaboration diagram for nsSVGGDIPlusPathGeometry:

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

 nsSVGGDIPlusPathGeometry ()
 ~nsSVGGDIPlusPathGeometry ()
nsresult Init (nsISVGPathGeometrySource *src)
void ClearPath ()
void ClearFill ()
void ClearStroke ()
void ClearCoveredRegion ()
void ClearHitTestRegion ()
GraphicsPath * GetPath ()
GraphicsPath * GetFill ()
GraphicsPath * GetStroke ()
Region * GetHitTestRegion ()
void GetGlobalTransform (Matrix *matrix)
void RenderPath (GraphicsPath *path, nscolor color, float opacity, nsISVGGDIPlusCanvas *canvas)

Private Attributes

nsCOMPtr
< nsISVGPathGeometrySource
mSource
GraphicsPath * mPath
GraphicsPath * mFill
GraphicsPath * mStroke
Region * mHitTestRegion
nsCOMPtr< nsISVGRendererRegionmCoveredRegion

Friends

nsresult NS_NewSVGGDIPlusPathGeometry (nsISVGRendererPathGeometry **result, nsISVGPathGeometrySource *src)
void gradCBFill (Graphics *gfx, Brush *brush, void *cbStruct)
void gradCBStroke (Graphics *gfx, Brush *brush, void *cbStruct)

Constructor & Destructor Documentation

Definition at line 125 of file nsSVGGDIPlusPathGeometry.cpp.

Here is the call graph for this function:


Member Function Documentation

Definition at line 95 of file nsSVGGDIPlusPathGeometry.cpp.

Here is the caller graph for this function:

void nsSVGGDIPlusPathGeometry::ClearFill ( ) [inline, protected]

Definition at line 93 of file nsSVGGDIPlusPathGeometry.cpp.

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

Here is the caller graph for this function:

Definition at line 96 of file nsSVGGDIPlusPathGeometry.cpp.

Here is the caller graph for this function:

void nsSVGGDIPlusPathGeometry::ClearPath ( ) [inline, protected]

Definition at line 92 of file nsSVGGDIPlusPathGeometry.cpp.

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

Here is the caller graph for this function:

Definition at line 94 of file nsSVGGDIPlusPathGeometry.cpp.

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

Here is the caller graph for this function:

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.

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

Returns:
Covered region.
GraphicsPath * nsSVGGDIPlusPathGeometry::GetFill ( ) [protected]

Definition at line 187 of file nsSVGGDIPlusPathGeometry.cpp.

{
  if (mFill) return mFill;
  GraphicsPath *path = GetPath();
  if (!path) return nsnull;

  mFill = path->Clone();
  Matrix m;
  GetGlobalTransform(&m);
  mFill->Flatten(&m);

  return mFill;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsSVGGDIPlusPathGeometry::GetGlobalTransform ( Matrix *  matrix) [protected]

Definition at line 335 of file nsSVGGDIPlusPathGeometry.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;

  matrix->SetElements(m[0],m[1],m[2],m[3],m[4],m[5]);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 305 of file nsSVGGDIPlusPathGeometry.cpp.

{
  if (mHitTestRegion) return mHitTestRegion;

  mHitTestRegion = new Region();
  if (!mHitTestRegion) {
    NS_ERROR("could not construct region");
    return nsnull;
  }

  mHitTestRegion->MakeEmpty();

  PRUint16 mask=0;
  mSource->GetHittestMask(&mask);
  if (mask & nsISVGPathGeometrySource::HITTEST_MASK_FILL) {
    GraphicsPath *fill = GetFill();
    if (fill)
      mHitTestRegion->Union(fill);
  }
  if (mask & nsISVGPathGeometrySource::HITTEST_MASK_STROKE) {
    GraphicsPath *stroke = GetStroke();
    if (stroke)
      mHitTestRegion->Union(stroke);
  }

  return mHitTestRegion;
}

Here is the call graph for this function:

Definition at line 175 of file nsSVGGDIPlusPathGeometry.cpp.

{
  if (mPath) return mPath;

  mPath = new GraphicsPath();
  nsCOMPtr<nsISVGRendererPathBuilder> builder;
  NS_NewSVGGDIPlusPathBuilder(getter_AddRefs(builder), mSource, mPath);
  mSource->ConstructPath(builder);
  return mPath;
}

Here is the call graph for this function:

Here is the caller graph for this function:

GraphicsPath * nsSVGGDIPlusPathGeometry::GetStroke ( ) [protected]

Definition at line 202 of file nsSVGGDIPlusPathGeometry.cpp.

{
  if (mStroke) return mStroke;
  GraphicsPath *path = GetPath();
  if (!path) return nsnull;

  float width;
  mSource->GetStrokeWidth(&width);
  if (width==0.0f) return nsnull;
  
  mStroke = path->Clone();

  // construct the pen:

  // gdi+ seems to widen paths to >1 width unit. If our pen width is
  // smaller, we need to widen an appropriately enlarged path and then
  // scale it down after widening:
  PRBool scaleToUnitPen = width<1.0f;
  
  Pen pen(Color(), scaleToUnitPen ? 1.0f : width);

  // set linecap style
  PRUint16 capStyle;
  LineCap lcap;
  DashCap dcap;
  mSource->GetStrokeLinecap(&capStyle);
  switch (capStyle) {
    case nsISVGGeometrySource::STROKE_LINECAP_BUTT:
      lcap = LineCapFlat;
      dcap = DashCapFlat;
      break;
    case nsISVGGeometrySource::STROKE_LINECAP_ROUND:
      lcap = LineCapRound;
      dcap = DashCapRound;
      break;
    case nsISVGGeometrySource::STROKE_LINECAP_SQUARE:
      lcap = LineCapSquare;
      dcap = DashCapFlat;
      break;
  }
  pen.SetLineCap(lcap, lcap, dcap);

  // set miterlimit:
  float miterlimit;
  mSource->GetStrokeMiterlimit(&miterlimit);
  pen.SetMiterLimit(miterlimit);

  // set linejoin style:
  PRUint16 joinStyle;
  LineJoin join;
  mSource->GetStrokeLinejoin(&joinStyle);
  switch(joinStyle) {
    case nsISVGGeometrySource::STROKE_LINEJOIN_MITER:
      join = LineJoinMiterClipped;
      break;
    case nsISVGGeometrySource::STROKE_LINEJOIN_ROUND:
      join = LineJoinRound;
      break;
    case nsISVGGeometrySource::STROKE_LINEJOIN_BEVEL:
      join = LineJoinBevel;
      break;
  }
  pen.SetLineJoin(join);
  
  // set pen dashpattern
  float *dashArray;
  PRUint32 count;
  mSource->GetStrokeDashArray(&dashArray, &count);
  if (count>0) {
    if (!scaleToUnitPen) {
      for (PRUint32 i=0; i<count; ++i)
        dashArray[i]/=width;
    }
    
    pen.SetDashPattern(dashArray, count);
    nsMemory::Free(dashArray);

    float offset;
    mSource->GetStrokeDashoffset(&offset);
    if (!scaleToUnitPen)
      offset/=width;
    pen.SetDashOffset(offset);
  }
  
  Matrix m;
  GetGlobalTransform(&m);

  if (scaleToUnitPen) {
    Matrix enlarge(1/width, 0, 0, 1/width, 0, 0);
    mStroke->Transform(&enlarge);
    m.Scale(width,width);
  }
  
  mStroke->Widen(&pen, &m);

  
//  mStroke->Outline();
//  mStroke->Transform(&m);
  
  return mStroke;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 134 of file nsSVGGDIPlusPathGeometry.cpp.

{
  mSource = src;
  return NS_OK;
}

Here is the caller graph for this function:

Paint this object.

Parameters:
canvasThe canvas to render to.
void nsSVGGDIPlusPathGeometry::RenderPath ( GraphicsPath *  path,
nscolor  color,
float  opacity,
nsISVGGDIPlusCanvas canvas 
) [protected]

Definition at line 365 of file nsSVGGDIPlusPathGeometry.cpp.

{
  SolidBrush brush(Color((BYTE)(opacity*255),NS_GET_R(color),NS_GET_G(color),NS_GET_B(color)));
  canvas->GetGraphics()->FillPath(&brush, path);
}
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

void gradCBFill ( Graphics *  gfx,
Brush *  brush,
void cbStruct 
) [friend]

Definition at line 375 of file nsSVGGDIPlusPathGeometry.cpp.

{
  nsSVGGDIPlusPathGeometry *geom = (nsSVGGDIPlusPathGeometry *)cbStruct;
  gfx->FillPath(brush, geom->GetFill());
}
void gradCBStroke ( Graphics *  gfx,
Brush *  brush,
void cbStruct 
) [friend]

Definition at line 381 of file nsSVGGDIPlusPathGeometry.cpp.

{
  nsSVGGDIPlusPathGeometry *geom = (nsSVGGDIPlusPathGeometry *)cbStruct;
  gfx->FillPath(brush, geom->GetStroke());
}

Definition at line 142 of file nsSVGGDIPlusPathGeometry.cpp.

{
  nsSVGGDIPlusPathGeometry* pg = new nsSVGGDIPlusPathGeometry();
  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.

GraphicsPath* nsSVGGDIPlusPathGeometry::mFill [private]

Definition at line 108 of file nsSVGGDIPlusPathGeometry.cpp.

Definition at line 110 of file nsSVGGDIPlusPathGeometry.cpp.

GraphicsPath* nsSVGGDIPlusPathGeometry::mPath [private]

Definition at line 107 of file nsSVGGDIPlusPathGeometry.cpp.

GraphicsPath* nsSVGGDIPlusPathGeometry::mStroke [private]

Definition at line 109 of file nsSVGGDIPlusPathGeometry.cpp.

class nsSVGGDIPlusRegion

GDI+ region implementation.

Definition at line 62 of file nsSVGGDIPlusRegion.cpp.

Inheritance diagram for nsSVGGDIPlusRegion:
Collaboration diagram for nsSVGGDIPlusRegion:

Public Member Functions

NS_DECL_ISUPPORTS NS_IMETHOD_ (const RectF *) GetRect() const
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.

Protected Member Functions

 nsSVGGDIPlusRegion (RectF &rect)
 nsSVGGDIPlusRegion (const GraphicsPath *path)
 nsSVGGDIPlusRegion (const nsSVGGDIPlusRegion &other)
 nsSVGGDIPlusRegion (const Region *other, const Graphics *graphics)
 ~nsSVGGDIPlusRegion ()

Private Attributes

RectF mRect

Friends

nsresult NS_NewSVGGDIPlusRectRegion (nsISVGRendererRegion **result, float x, float y, float width, float height)
nsresult NS_NewSVGGDIPlusPathRegion (nsISVGRendererRegion **result, const GraphicsPath *path)
nsresult NS_NewSVGGDIPlusClonedRegion (nsISVGRendererRegion **result, const Region *region, nsPresContext *presContext)

Constructor & Destructor Documentation

nsSVGGDIPlusRegion::nsSVGGDIPlusRegion ( RectF &  rect) [protected]

Definition at line 111 of file nsSVGGDIPlusRegion.cpp.

    : mRect(rect.X, rect.Y, rect.Width, rect.Height)
#else
    : mRegion(rect)
#endif
{
}
nsSVGGDIPlusRegion::nsSVGGDIPlusRegion ( const GraphicsPath *  path) [protected]

Definition at line 120 of file nsSVGGDIPlusRegion.cpp.

    : mRegion(path)
#endif
{
#ifdef NS_SVG_GDIPLUS_RENDERER_USE_RECT_REGIONS
  path->GetBounds(&mRect);
#endif
}

Definition at line 130 of file nsSVGGDIPlusRegion.cpp.

{
  
#ifdef NS_SVG_GDIPLUS_RENDERER_USE_RECT_REGIONS
  mRect.X = other.GetRect()->X;
  mRect.Y = other.GetRect()->Y;
  mRect.Width = other.GetRect()->Width;
  mRect.Height = other.GetRect()->Height;
#else
  mRegion.MakeEmpty();
  mRegion.Union(other.GetRegion());
#endif
}
nsSVGGDIPlusRegion::nsSVGGDIPlusRegion ( const Region *  other,
const Graphics *  graphics 
) [protected]

Definition at line 144 of file nsSVGGDIPlusRegion.cpp.

{
  
#ifdef NS_SVG_GDIPLUS_RENDERER_USE_RECT_REGIONS
  other->GetBounds(&mRect, graphics);
#else
  mRegion.MakeEmpty();
  mRegion.Union(other);
#endif
}

Definition at line 160 of file nsSVGGDIPlusRegion.cpp.

{
}

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.

Friends And Related Function Documentation

nsresult NS_NewSVGGDIPlusClonedRegion ( nsISVGRendererRegion **  result,
const Region *  region,
nsPresContext presContext 
) [friend]

Definition at line 187 of file nsSVGGDIPlusRegion.cpp.

{
#ifdef NS_SVG_GDIPLUS_RENDERER_USE_RECT_REGIONS
  HWND win;
  HDC devicehandle;
  {
    nsIDeviceContext* devicecontext = presContext->DeviceContext();
    // this better be what we think it is:
    win = (HWND)((nsDeviceContextWin *)devicecontext)->mWidget;
    devicehandle = ::GetDC(win);
  }

  {
    // wrap this in a block so that the Graphics-object goes out of
    // scope before we release the HDC.
    
    Graphics graphics(devicehandle);
    
    *result = new nsSVGGDIPlusRegion(region, &graphics);  
  }
  
  ::ReleaseDC(win, devicehandle);
#else
    *result = new nsSVGGDIPlusRegion(region);
#endif
  
  if (!*result) return NS_ERROR_OUT_OF_MEMORY;

  NS_ADDREF(*result);
  return NS_OK;  
}
nsresult NS_NewSVGGDIPlusPathRegion ( nsISVGRendererRegion **  result,
const GraphicsPath *  path 
) [friend]

Definition at line 177 of file nsSVGGDIPlusRegion.cpp.

{
  *result = new nsSVGGDIPlusRegion(path);
  if (!*result) return NS_ERROR_OUT_OF_MEMORY;

  NS_ADDREF(*result);
  return NS_OK;  
}
nsresult NS_NewSVGGDIPlusRectRegion ( nsISVGRendererRegion **  result,
float  x,
float  y,
float  width,
float  height 
) [friend]

Definition at line 165 of file nsSVGGDIPlusRegion.cpp.

{
  *result = new nsSVGGDIPlusRegion(RectF(x, y, width, height));
  if (!*result) return NS_ERROR_OUT_OF_MEMORY;

  NS_ADDREF(*result);
  return NS_OK;
}

Member Data Documentation

RectF nsSVGGDIPlusRegion::mRect [private]

Definition at line 100 of file nsSVGGDIPlusRegion.cpp.

class nsSVGRendererGDIPlus

GDI+ renderer factory.

Definition at line 65 of file nsSVGRendererGDIPlusShim.cpp.

Inheritance diagram for nsSVGRendererGDIPlus:
Collaboration diagram for nsSVGRendererGDIPlus:

Public Member Functions

 nsSVGRendererGDIPlus ()
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.

Static Private Attributes

static PRBool sGdiplusStarted = PR_FALSE
static ULONG_PTR sGdiplusToken
static GdiplusStartupOutput sGdiplusStartupOutput

Friends

nsresult NS_NewSVGRendererGDIPlus (nsISVGRenderer **aResult)
void NS_InitSVGRendererGDIPlusGlobals ()
void NS_FreeSVGRendererGDIPlusGlobals ()

Constructor & Destructor Documentation

Definition at line 96 of file nsSVGRendererGDIPlusShim.cpp.

{
  if (!sGdiplusStarted) {
    GdiplusStartupInput gdiplusStartupInput;
    pGdiplusStartup(&sGdiplusToken, &gdiplusStartupInput,&sGdiplusStartupOutput);
    sGdiplusStarted = PR_TRUE;
  }
}

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 162 of file nsSVGRendererGDIPlusShim.cpp.

{
  if (!TryLoadLibraries())
    return;

  rendererFunctions->NS_InitSVGGDIPlusGlyphMetricsGlobals();
  
  // initialize gdi+ lazily in nsSVGRendererGDIPlus CTOR
}

Definition at line 143 of file nsSVGRendererGDIPlusShim.cpp.

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

  if (!TryLoadLibraries())
    return NS_ERROR_FAILURE;

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

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

Member Data Documentation

Definition at line 81 of file nsSVGRendererGDIPlusShim.cpp.

GdiplusStartupOutput nsSVGRendererGDIPlus::sGdiplusStartupOutput [static, private]

Definition at line 83 of file nsSVGRendererGDIPlusShim.cpp.

ULONG_PTR nsSVGRendererGDIPlus::sGdiplusToken [static, private]

Definition at line 82 of file nsSVGRendererGDIPlusShim.cpp.


Function Documentation

NS_DECL_ISUPPORTS NS_DECL_NSISVGRENDERERGLYPHMETRICS nsSVGCairoGlyphMetrics::NS_IMETHOD_ ( void  ) [virtual]

Definition at line 110 of file nsSVGCairoGlyphMetrics.cpp.

{
  *result = new nsSVGCairoGlyphMetrics(src);
  if (!*result) return NS_ERROR_OUT_OF_MEMORY;
  
  NS_ADDREF(*result);
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 97 of file nsSVGCairoGlyphMetrics.cpp.

Here is the call graph for this function:

Definition at line 104 of file nsSVGCairoGlyphMetrics.cpp.


Variable Documentation

cairo_t* nsSVGCairoGlyphMetrics::mCT [private]

Definition at line 87 of file nsSVGCairoGlyphMetrics.cpp.

Definition at line 88 of file nsSVGCairoGlyphMetrics.cpp.

Definition at line 89 of file nsSVGCairoGlyphMetrics.cpp.


Friends

Definition at line 110 of file nsSVGCairoGlyphMetrics.cpp.

{
  *result = new nsSVGCairoGlyphMetrics(src);
  if (!*result) return NS_ERROR_OUT_OF_MEMORY;
  
  NS_ADDREF(*result);
  return NS_OK;
}