Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Private Attributes
gfxContext Class Reference

#include <gfxContext.h>

Collaboration diagram for gfxContext:
Collaboration graph
[legend]

List of all members.

Public Types

enum  gfxLineType { gfxLineSolid, gfxLineDashed, gfxLineDotted }
 Line Properties. More...
enum  GraphicsLineCap { LINE_CAP_BUTT, LINE_CAP_ROUND, LINE_CAP_SQUARE }
enum  GraphicsLineJoin { LINE_JOIN_MITER, LINE_JOIN_ROUND, LINE_JOIN_BEVEL }
enum  GraphicsOperator {
  OPERATOR_CLEAR, OPERATOR_SRC, OPERATOR_DST, OPERATOR_OVER,
  OPERATOR_OVER_REVERSE, OPERATOR_IN, OPERATOR_IN_REVERSE, OPERATOR_OUT,
  OPERATOR_OUT_REVERSE, OPERATOR_ATOP, OPERATOR_ATOP_REVERSE, OPERATOR_XOR,
  OPERATOR_ADD, OPERATOR_SATURATE
}
 Operators and Rendering control. More...
enum  AntialiasMode { MODE_ALIASED, MODE_COVERAGE }
 MODE_ALIASED means that only pixels whose centers are in the drawn area should be modified, and they should be modified to take the value drawn at the pixel center. More...
enum  FilterHints { FILTER_OPAQUE_DRAW }
 Filters/Group Rendering XXX these aren't really "filters" and should be renamed properly. More...

Public Member Functions

 gfxContext (gfxASurface *surface)
 ~gfxContext ()
gfxASurfaceCurrentSurface ()
cairo_t * GetCairo ()
void Save ()
 State.
void Restore ()
void Stroke ()
 Paths & Drawing.
void Fill ()
void NewPath ()
void ClosePath ()
void MoveTo (gfxPoint pt)
void LineTo (gfxPoint pt)
void CurveTo (gfxPoint pt1, gfxPoint pt2, gfxPoint pt3)
void Arc (gfxPoint center, gfxFloat radius, gfxFloat angle1, gfxFloat angle2)
void NegativeArc (gfxPoint center, gfxFloat radius, gfxFloat angle1, gfxFloat angle2)
void Line (gfxPoint start, gfxPoint end)
void Rectangle (gfxRect rect, PRBool snapToPixels=PR_FALSE)
void Ellipse (gfxPoint center, gfxSize dimensions)
void Polygon (const gfxPoint *points, PRUint32 numPoints)
void AddStringToPath (gfxTextRun &text, int pos, int len)
 Text.
void DrawString (gfxTextRun &text, int pos, int len)
void Translate (gfxPoint pt)
 Transformation Matrix manipulation.
void Scale (gfxFloat x, gfxFloat y)
void Rotate (gfxFloat angle)
void Multiply (const gfxMatrix &other)
void SetMatrix (const gfxMatrix &matrix)
void IdentityMatrix ()
gfxMatrix CurrentMatrix () const
gfxPoint DeviceToUser (gfxPoint point) const
gfxSize DeviceToUser (gfxSize size) const
gfxRect DeviceToUser (gfxRect rect) const
gfxPoint UserToDevice (gfxPoint point) const
gfxSize UserToDevice (gfxSize size) const
gfxRect UserToDevice (gfxRect rect) const
void SetColor (const gfxRGBA &c)
 Painting sources.
void SetPattern (gfxPattern *pattern)
void SetSource (gfxASurface *surface)
void SetSource (gfxASurface *surface, gfxPoint offset)
void Paint (gfxFloat alpha=1.0)
 Painting.
void DrawSurface (gfxASurface *surface, gfxSize size)
 Shortcuts.
void SetDash (gfxLineType ltype)
void SetDash (gfxFloat *dashes, int ndash, gfxFloat offset)
void SetLineWidth (gfxFloat width)
gfxFloat CurrentLineWidth () const
void SetLineCap (GraphicsLineCap cap)
GraphicsLineCap CurrentLineCap () const
void SetLineJoin (GraphicsLineJoin join)
GraphicsLineJoin CurrentLineJoin () const
void SetMiterLimit (gfxFloat limit)
gfxFloat CurrentMiterLimit () const
void SetOperator (GraphicsOperator op)
GraphicsOperator CurrentOperator () const
void SetAntialiasMode (AntialiasMode mode)
AntialiasMode CurrentAntialiasMode ()
void Clip ()
 Clipping.
void ResetClip ()
void Clip (gfxRect rect)
void Clip (const gfxRegion &region)
void PushFilter (gfxFilter &filter, FilterHints hints, gfxRect &maxArea)
void PopFilter ()

Private Attributes

cairo_t * mCairo
nsRefPtr< gfxASurfacemSurface

Detailed Description

Definition at line 56 of file gfxContext.h.


Member Enumeration Documentation

MODE_ALIASED means that only pixels whose centers are in the drawn area should be modified, and they should be modified to take the value drawn at the pixel center.

Enumerator:
MODE_ALIASED 
MODE_COVERAGE 

Definition at line 224 of file gfxContext.h.

Filters/Group Rendering XXX these aren't really "filters" and should be renamed properly.

Enumerator:
FILTER_OPAQUE_DRAW 

Definition at line 247 of file gfxContext.h.

                     {
        // Future drawing will completely cover the specified maxArea
        FILTER_OPAQUE_DRAW
    };

Line Properties.

Enumerator:
gfxLineSolid 
gfxLineDashed 
gfxLineDotted 

Definition at line 163 of file gfxContext.h.

Enumerator:
LINE_CAP_BUTT 
LINE_CAP_ROUND 
LINE_CAP_SQUARE 

Definition at line 176 of file gfxContext.h.

Enumerator:
LINE_JOIN_MITER 
LINE_JOIN_ROUND 
LINE_JOIN_BEVEL 

Definition at line 184 of file gfxContext.h.

Operators and Rendering control.

Enumerator:
OPERATOR_CLEAR 
OPERATOR_SRC 
OPERATOR_DST 
OPERATOR_OVER 
OPERATOR_OVER_REVERSE 
OPERATOR_IN 
OPERATOR_IN_REVERSE 
OPERATOR_OUT 
OPERATOR_OUT_REVERSE 
OPERATOR_ATOP 
OPERATOR_ATOP_REVERSE 
OPERATOR_XOR 
OPERATOR_ADD 
OPERATOR_SATURATE 

Definition at line 200 of file gfxContext.h.


Constructor & Destructor Documentation

Definition at line 53 of file gfxContext.cpp.

                                           :
    mSurface(surface)
{
    mCairo = cairo_create(surface->CairoSurface());
}

Definition at line 58 of file gfxContext.cpp.


Member Function Documentation

void gfxContext::AddStringToPath ( gfxTextRun text,
int  pos,
int  len 
)

Text.

void gfxContext::Arc ( gfxPoint  center,
gfxFloat  radius,
gfxFloat  angle1,
gfxFloat  angle2 
)

Definition at line 111 of file gfxContext.cpp.

{
    cairo_arc(mCairo, center.x, center.y, radius, angle1, angle2);
}

Clipping.

Definition at line 393 of file gfxContext.cpp.

Definition at line 383 of file gfxContext.cpp.

Definition at line 389 of file gfxContext.cpp.

{
}

Definition at line 83 of file gfxContext.cpp.

Definition at line 305 of file gfxContext.cpp.

{
    return MODE_COVERAGE;
}

Definition at line 357 of file gfxContext.cpp.

Definition at line 366 of file gfxContext.cpp.

Definition at line 339 of file gfxContext.cpp.

Definition at line 249 of file gfxContext.cpp.

{
    cairo_matrix_t mat;
    cairo_get_matrix(mCairo, &mat);
    return gfxMatrix(mat);
}

Definition at line 376 of file gfxContext.cpp.

Definition at line 348 of file gfxContext.cpp.

Definition at line 63 of file gfxContext.cpp.

{
    return mSurface;
}
void gfxContext::CurveTo ( gfxPoint  pt1,
gfxPoint  pt2,
gfxPoint  pt3 
)

Definition at line 106 of file gfxContext.cpp.

{
    cairo_curve_to(mCairo, pt1.x, pt1.y, pt2.x, pt2.y, pt3.x, pt3.y);
}

Definition at line 256 of file gfxContext.cpp.

{
    gfxPoint ret = point;
    cairo_device_to_user(mCairo, &ret.x, &ret.y);
    return ret;
}

Definition at line 263 of file gfxContext.cpp.

Definition at line 270 of file gfxContext.cpp.

void gfxContext::DrawString ( gfxTextRun text,
int  pos,
int  len 
)

Definition at line 422 of file gfxContext.cpp.

{

}
void gfxContext::DrawSurface ( gfxASurface surface,
gfxSize  size 
)

Shortcuts.

Definition at line 206 of file gfxContext.cpp.

Here is the call graph for this function:

void gfxContext::Ellipse ( gfxPoint  center,
gfxSize  dimensions 
)

Definition at line 160 of file gfxContext.cpp.

{
    // circle?
    if (dimensions.width == dimensions.height) {
        double radius = dimensions.width / 2.0;

        cairo_arc(mCairo, center.x, center.y, radius, 0, 2.0 * M_PI);
    } else {
        double x = center.x;
        double y = center.y;
        double w = dimensions.width;
        double h = dimensions.height;

        cairo_new_path(mCairo);
        cairo_move_to(mCairo, x + w/2.0, y);

        cairo_rel_curve_to(mCairo,
                           0, 0,
                           w / 2.0, 0,
                           w / 2.0, h / 2.0);
        cairo_rel_curve_to(mCairo,
                           0, 0,
                           0, h / 2.0,
                           - w / 2.0, h / 2.0);
        cairo_rel_curve_to(mCairo,
                           0, 0,
                           - w / 2.0, 0,
                           - w / 2.0, - h / 2.0);
        cairo_rel_curve_to(mCairo,
                           0, 0,
                           0, - h / 2.0,
                           w / 2.0, - h / 2.0);
    }
}

Definition at line 92 of file gfxContext.cpp.

Here is the caller graph for this function:

cairo_t* gfxContext::GetCairo ( ) [inline]

Definition at line 65 of file gfxContext.h.

{ return mCairo; }

Definition at line 244 of file gfxContext.cpp.

void gfxContext::Line ( gfxPoint  start,
gfxPoint  end 
)

Definition at line 117 of file gfxContext.cpp.

{
    MoveTo(start);
    LineTo(end);
}

Here is the call graph for this function:

Definition at line 101 of file gfxContext.cpp.

{
    cairo_line_to(mCairo, pt.x, pt.y);
}

Here is the caller graph for this function:

Definition at line 97 of file gfxContext.cpp.

{
    cairo_move_to(mCairo, pt.x, pt.y);
}

Here is the caller graph for this function:

Definition at line 232 of file gfxContext.cpp.

{
    cairo_matrix_t mat = matrix.ToCairoMatrix();
    cairo_transform(mCairo, &mat);
}

Here is the call graph for this function:

void gfxContext::NegativeArc ( gfxPoint  center,
gfxFloat  radius,
gfxFloat  angle1,
gfxFloat  angle2 
)

Definition at line 79 of file gfxContext.cpp.

Here is the caller graph for this function:

void gfxContext::Paint ( gfxFloat  alpha = 1.0)

Painting.

Definition at line 427 of file gfxContext.cpp.

void gfxContext::Polygon ( const gfxPoint points,
PRUint32  numPoints 
)

Definition at line 195 of file gfxContext.cpp.

{
    if (numPoints == 0)
        return;

    cairo_move_to(mCairo, points[0].x, points[0].y);
    for (PRUint32 i = 1; i < numPoints; ++i) {
        cairo_line_to(mCairo, points[i].x, points[i].y);
    }
}

Definition at line 438 of file gfxContext.cpp.

{

}
void gfxContext::PushFilter ( gfxFilter filter,
FilterHints  hints,
gfxRect maxArea 
)

Definition at line 433 of file gfxContext.cpp.

{

}
void gfxContext::Rectangle ( gfxRect  rect,
PRBool  snapToPixels = PR_FALSE 
)

Definition at line 123 of file gfxContext.cpp.

{
    if (snapToPixels) {
        gfxPoint p1 = UserToDevice(rect.pos);
        gfxPoint p2 = UserToDevice(rect.pos + rect.size);

        gfxPoint p3 = UserToDevice(rect.pos + gfxSize(rect.size.width, 0.0));
        gfxPoint p4 = UserToDevice(rect.pos + gfxSize(0.0, rect.size.height));

        if (p1.x != p4.x ||
            p2.x != p3.x ||
            p1.y != p3.y ||
            p2.y != p4.y)
            // rectangle is no longer axis-aligned after transforming, so don't snap
            goto dontsnap;

        cairo_matrix_t mat;
        cairo_get_matrix(mCairo, &mat);

        if (mat.xx != 1.0 ||
            mat.yy != 1.0)
            // if we're not at 1.0 scale, don't snap
            goto dontsnap;

        p1.round();
        p2.round();

        cairo_identity_matrix(mCairo);
        cairo_rectangle(mCairo, p1.x, p1.y, p2.x - p1.x, p2.y - p1.y);
        cairo_set_matrix(mCairo, &mat);
        return;
    }

dontsnap:
    cairo_rectangle(mCairo, rect.pos.x, rect.pos.y, rect.size.width, rect.size.height);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 398 of file gfxContext.cpp.

Definition at line 73 of file gfxContext.cpp.

Definition at line 228 of file gfxContext.cpp.

{
    cairo_rotate(mCairo, angle);
}

State.

Definition at line 68 of file gfxContext.cpp.

Definition at line 224 of file gfxContext.cpp.

Definition at line 300 of file gfxContext.cpp.

{
    // XXX implement me
}

Painting sources.

Definition at line 406 of file gfxContext.cpp.

{
    cairo_set_source_rgba(mCairo, c.r, c.g, c.b, c.a);
}

Definition at line 310 of file gfxContext.cpp.

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

    switch (ltype) {
        case gfxLineDashed:
            SetDash(dash, 2, 0.0);
            break;
        case gfxLineDotted:
            SetDash(dot, 2, 0.0);
            break;
        case gfxLineSolid:
        default:
            SetDash(nsnull, 0, 0.0);
            break;
    }
}
void gfxContext::SetDash ( gfxFloat dashes,
int  ndash,
gfxFloat  offset 
)

Definition at line 329 of file gfxContext.cpp.

Definition at line 353 of file gfxContext.cpp.

Definition at line 362 of file gfxContext.cpp.

Definition at line 335 of file gfxContext.cpp.

Definition at line 238 of file gfxContext.cpp.

Here is the call graph for this function:

Definition at line 372 of file gfxContext.cpp.

Definition at line 344 of file gfxContext.cpp.

Definition at line 411 of file gfxContext.cpp.

Here is the call graph for this function:

void gfxContext::SetSource ( gfxASurface surface) [inline]

Definition at line 141 of file gfxContext.h.

                                         {
        SetSource(surface, gfxPoint(0, 0));
    }
void gfxContext::SetSource ( gfxASurface surface,
gfxPoint  offset 
)

Definition at line 416 of file gfxContext.cpp.

{
    cairo_set_source_surface(mCairo, surface->CairoSurface(), offset.x, offset.y);
}

Here is the call graph for this function:

Paths & Drawing.

Definition at line 88 of file gfxContext.cpp.

Transformation Matrix manipulation.

Definition at line 220 of file gfxContext.cpp.

{
    cairo_translate(mCairo, pt.x, pt.y);
}

Definition at line 278 of file gfxContext.cpp.

{
    gfxPoint ret = point;
    cairo_user_to_device(mCairo, &ret.x, &ret.y);
    return ret;
}

Here is the caller graph for this function:

Definition at line 285 of file gfxContext.cpp.

Definition at line 292 of file gfxContext.cpp.


Member Data Documentation

cairo_t* gfxContext::mCairo [private]

Definition at line 260 of file gfxContext.h.

Definition at line 261 of file gfxContext.h.


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