2005-04-06 05:54:26 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is Oracle Corporation code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Oracle Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2005
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Stuart Parmenter <pavlov@pavlov.net>
|
2005-06-28 13:18:55 +04:00
|
|
|
* Vladimir Vukicevic <vladimir@pobox.com>
|
2005-04-06 05:54:26 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
2005-04-11 08:36:18 +04:00
|
|
|
#ifndef GFX_CONTEXT_H
|
|
|
|
#define GFX_CONTEXT_H
|
2005-04-06 05:54:26 +04:00
|
|
|
|
|
|
|
#include <cairo.h>
|
|
|
|
|
2005-06-28 13:27:02 +04:00
|
|
|
#include "gfxASurface.h"
|
2005-04-06 05:54:26 +04:00
|
|
|
#include "gfxColor.h"
|
|
|
|
#include "gfxPoint.h"
|
2005-04-06 11:36:31 +04:00
|
|
|
#include "gfxRect.h"
|
2005-04-08 09:44:32 +04:00
|
|
|
#include "gfxTypes.h"
|
2005-06-30 08:58:27 +04:00
|
|
|
#include "gfxMatrix.h"
|
|
|
|
#include "gfxPattern.h"
|
2005-10-08 09:09:42 +04:00
|
|
|
#include "gfxFont.h"
|
2005-04-06 05:54:26 +04:00
|
|
|
|
|
|
|
class gfxRegion;
|
|
|
|
class gfxFilter;
|
|
|
|
class gfxTextRun;
|
|
|
|
|
2005-08-20 09:36:47 +04:00
|
|
|
/**
|
|
|
|
* This is the main class for doing actual drawing. It is initialized using
|
|
|
|
* a surface and can be drawn on. It manages various state information like
|
|
|
|
* a current transformation matrix (CTM), a current path, current color,
|
|
|
|
* etc.
|
|
|
|
*
|
|
|
|
* All drawing happens by creating a path and then stroking or filling it.
|
|
|
|
* The functions like Rectangle and Arc do not do any drawing themselves.
|
|
|
|
* When a path is drawn (stroked or filled), it is filled/stroked with a
|
|
|
|
* pattern set by SetPattern, SetColor or SetSource.
|
|
|
|
*/
|
2005-10-06 08:02:10 +04:00
|
|
|
class NS_EXPORT gfxContext {
|
2005-06-28 13:18:55 +04:00
|
|
|
THEBES_DECL_REFCOUNTING
|
|
|
|
|
2005-04-06 05:54:26 +04:00
|
|
|
public:
|
2005-08-20 09:36:47 +04:00
|
|
|
/**
|
|
|
|
* Initialize this context from a surface.
|
|
|
|
*/
|
2005-06-30 08:58:27 +04:00
|
|
|
gfxContext(gfxASurface *surface);
|
2005-04-06 05:54:26 +04:00
|
|
|
~gfxContext();
|
|
|
|
|
2005-10-06 08:02:10 +04:00
|
|
|
/**
|
|
|
|
* Return the current target surface
|
|
|
|
*/
|
2005-04-06 05:54:26 +04:00
|
|
|
gfxASurface* CurrentSurface();
|
2005-10-06 08:02:10 +04:00
|
|
|
|
2006-02-09 04:24:30 +03:00
|
|
|
/**
|
|
|
|
* Return the current transparency group target, if any
|
|
|
|
*/
|
|
|
|
gfxASurface* CurrentGroupSurface();
|
|
|
|
|
2005-10-06 08:02:10 +04:00
|
|
|
/**
|
|
|
|
* Return the raw cairo_t object.
|
|
|
|
* XXX this should go away at some point.
|
|
|
|
*/
|
2005-06-30 08:58:27 +04:00
|
|
|
cairo_t* GetCairo() { return mCairo; }
|
2005-04-06 05:54:26 +04:00
|
|
|
|
2005-06-28 13:18:55 +04:00
|
|
|
/**
|
|
|
|
** State
|
|
|
|
**/
|
|
|
|
// XXX document exactly what bits are saved
|
2005-04-06 05:54:26 +04:00
|
|
|
void Save();
|
|
|
|
void Restore();
|
|
|
|
|
2005-06-28 13:18:55 +04:00
|
|
|
/**
|
|
|
|
** Paths & Drawing
|
|
|
|
**/
|
2005-04-06 05:54:26 +04:00
|
|
|
|
2005-08-20 09:36:47 +04:00
|
|
|
/**
|
|
|
|
* Stroke the current path using the current settings (such as line
|
|
|
|
* width and color).
|
|
|
|
* A path is set up using functions such as Line, Rectangle and Arc.
|
|
|
|
*
|
|
|
|
* Does not consume the current path.
|
|
|
|
*/
|
2005-04-06 05:54:26 +04:00
|
|
|
void Stroke();
|
2005-08-20 09:36:47 +04:00
|
|
|
/**
|
|
|
|
* Fill the current path according to the current settings.
|
|
|
|
*
|
|
|
|
* Does not consume the current path.
|
|
|
|
*/
|
2005-04-06 05:54:26 +04:00
|
|
|
void Fill();
|
2005-06-28 13:18:55 +04:00
|
|
|
|
2005-08-20 09:36:47 +04:00
|
|
|
/**
|
|
|
|
* Forgets the current path.
|
|
|
|
*/
|
2005-06-28 13:18:55 +04:00
|
|
|
void NewPath();
|
2005-08-20 09:36:47 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Closes the path, i.e. connects the last drawn point to the first one.
|
|
|
|
*
|
|
|
|
* Filling a path will implicitly close it.
|
|
|
|
*/
|
2005-06-28 13:18:55 +04:00
|
|
|
void ClosePath();
|
|
|
|
|
2005-08-20 09:36:47 +04:00
|
|
|
/**
|
|
|
|
* Moves the pen to a new point without drawing a line.
|
|
|
|
*/
|
2005-04-08 09:44:32 +04:00
|
|
|
void MoveTo(gfxPoint pt);
|
2005-08-20 09:36:47 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Draws a line from the current point to pt.
|
|
|
|
*
|
|
|
|
* @see MoveTo
|
|
|
|
*/
|
2005-04-08 09:44:32 +04:00
|
|
|
void LineTo(gfxPoint pt);
|
2005-08-20 09:36:47 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Draws a quadratic Bézier curve with control points pt1, pt2 and pt3.
|
|
|
|
*/
|
2005-04-08 09:44:32 +04:00
|
|
|
void CurveTo(gfxPoint pt1, gfxPoint pt2, gfxPoint pt3);
|
2005-04-06 05:54:26 +04:00
|
|
|
|
2005-08-20 09:36:47 +04:00
|
|
|
/**
|
|
|
|
* Draws a clockwise arc (i.e. a circle segment).
|
|
|
|
* @param center The center of the circle
|
|
|
|
* @param radius The radius of the circle
|
|
|
|
* @param angle1 Starting angle for the segment
|
|
|
|
* @param angle2 Ending angle
|
|
|
|
*/
|
2005-04-08 09:44:32 +04:00
|
|
|
void Arc(gfxPoint center, gfxFloat radius,
|
|
|
|
gfxFloat angle1, gfxFloat angle2);
|
2005-04-06 05:54:26 +04:00
|
|
|
|
2005-08-20 09:36:47 +04:00
|
|
|
/**
|
|
|
|
* Draws a counter-clockwise arc (i.e. a circle segment).
|
|
|
|
* @param center The center of the circle
|
|
|
|
* @param radius The radius of the circle
|
|
|
|
* @param angle1 Starting angle for the segment
|
|
|
|
* @param angle2 Ending angle
|
|
|
|
*/
|
|
|
|
|
2005-06-28 13:18:55 +04:00
|
|
|
void NegativeArc(gfxPoint center, gfxFloat radius,
|
|
|
|
gfxFloat angle1, gfxFloat angle2);
|
|
|
|
|
2005-06-30 08:58:27 +04:00
|
|
|
// path helpers
|
2005-08-20 09:36:47 +04:00
|
|
|
/**
|
|
|
|
* Draws a line from start to end.
|
|
|
|
*/
|
2005-06-30 08:58:27 +04:00
|
|
|
void Line(gfxPoint start, gfxPoint end); // XXX snapToPixels option?
|
2005-08-20 09:36:47 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Draws the rectangle given by rect.
|
|
|
|
* @param snapToPixels ?
|
|
|
|
*/
|
2005-06-28 13:18:55 +04:00
|
|
|
void Rectangle(gfxRect rect, PRBool snapToPixels = PR_FALSE);
|
2005-06-30 08:58:27 +04:00
|
|
|
void Ellipse(gfxPoint center, gfxSize dimensions);
|
2005-06-28 13:27:02 +04:00
|
|
|
void Polygon(const gfxPoint *points, PRUint32 numPoints);
|
2005-06-28 13:18:55 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
** Text
|
|
|
|
**/
|
2005-04-06 05:54:26 +04:00
|
|
|
|
2005-08-20 09:36:47 +04:00
|
|
|
/**
|
|
|
|
* Add the text outline to the current path.
|
|
|
|
*/
|
2005-11-29 23:12:29 +03:00
|
|
|
// specify this in a sane way.
|
|
|
|
//void AddStringToPath(gfxTextRun& text);
|
2005-04-12 02:22:10 +04:00
|
|
|
|
2005-08-20 09:36:47 +04:00
|
|
|
/**
|
2005-11-29 23:12:29 +03:00
|
|
|
* Draw the text run at the current point.
|
|
|
|
* XXX support drawing subsections of the text run
|
2005-08-20 09:36:47 +04:00
|
|
|
*/
|
2005-11-29 23:12:29 +03:00
|
|
|
void DrawText(gfxTextRun& text);
|
2005-04-06 05:54:26 +04:00
|
|
|
|
2005-06-28 13:18:55 +04:00
|
|
|
/**
|
|
|
|
** Transformation Matrix manipulation
|
|
|
|
**/
|
|
|
|
|
2005-08-20 09:36:47 +04:00
|
|
|
/**
|
|
|
|
* Adds a translation to the current matrix. This translation takes place
|
|
|
|
* before the previously set transformations.
|
|
|
|
*/
|
2005-04-08 09:44:32 +04:00
|
|
|
void Translate(gfxPoint pt);
|
2005-08-20 09:36:47 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a scale to the current matrix. This scaling takes place before the
|
|
|
|
* previously set transformations.
|
|
|
|
*/
|
2005-04-08 09:44:32 +04:00
|
|
|
void Scale(gfxFloat x, gfxFloat y);
|
2005-06-28 13:18:55 +04:00
|
|
|
|
2005-08-20 09:36:47 +04:00
|
|
|
/**
|
|
|
|
* Adds a rotation around the origin to the current matrix. This rotation
|
|
|
|
* takes place before the previously set transformations.
|
|
|
|
*
|
|
|
|
* @param angle The angle in radians.
|
|
|
|
*/
|
|
|
|
void Rotate(gfxFloat angle);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Post-multiplies 'other' onto the current CTM, i.e. this
|
|
|
|
* matrix's transformation will take place before the previously set
|
|
|
|
* transformations.
|
|
|
|
*/
|
2005-06-28 13:18:55 +04:00
|
|
|
void Multiply(const gfxMatrix& other);
|
2005-04-06 05:54:26 +04:00
|
|
|
|
2005-08-20 09:36:47 +04:00
|
|
|
/**
|
|
|
|
* Replaces the current transformation matrix with matrix.
|
|
|
|
*/
|
2005-04-06 05:54:26 +04:00
|
|
|
void SetMatrix(const gfxMatrix& matrix);
|
2005-08-20 09:36:47 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the transformation matrix to the identity matrix.
|
|
|
|
*/
|
2005-06-30 08:58:27 +04:00
|
|
|
void IdentityMatrix();
|
2005-08-20 09:36:47 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the current transformation matrix.
|
|
|
|
*/
|
2005-04-06 05:54:26 +04:00
|
|
|
gfxMatrix CurrentMatrix() const;
|
|
|
|
|
2005-08-20 09:36:47 +04:00
|
|
|
/**
|
|
|
|
* Converts a point from device to user coordinates using the inverse
|
|
|
|
* transformation matrix.
|
|
|
|
*/
|
2005-06-28 13:18:55 +04:00
|
|
|
gfxPoint DeviceToUser(gfxPoint point) const;
|
2005-08-20 09:36:47 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts a size from device to user coordinates. This does not apply
|
|
|
|
* translation components of the matrix.
|
|
|
|
*/
|
2005-06-28 13:18:55 +04:00
|
|
|
gfxSize DeviceToUser(gfxSize size) const;
|
2005-08-20 09:36:47 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts a rectangle from device to user coordinates; this has the
|
|
|
|
* same effect as using DeviceToUser on both the rectangle's point and
|
|
|
|
* size.
|
|
|
|
*/
|
2005-07-02 05:05:26 +04:00
|
|
|
gfxRect DeviceToUser(gfxRect rect) const;
|
2005-08-20 09:36:47 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts a point from user to device coordinates using the inverse
|
|
|
|
* transformation matrix.
|
|
|
|
*/
|
2005-06-28 13:18:55 +04:00
|
|
|
gfxPoint UserToDevice(gfxPoint point) const;
|
2005-08-20 09:36:47 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts a size from user to device coordinates. This does not apply
|
|
|
|
* translation components of the matrix.
|
|
|
|
*/
|
2005-06-28 13:18:55 +04:00
|
|
|
gfxSize UserToDevice(gfxSize size) const;
|
2005-08-20 09:36:47 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts a rectangle from user to device coordinates; this has the
|
|
|
|
* same effect as using DeviceToUser on both the rectangle's point and
|
|
|
|
* size.
|
|
|
|
*/
|
2005-07-02 05:05:26 +04:00
|
|
|
gfxRect UserToDevice(gfxRect rect) const;
|
2005-06-28 13:18:55 +04:00
|
|
|
|
2005-08-20 09:36:47 +04:00
|
|
|
/**
|
|
|
|
* Takes the given rect and tries to align it to device pixels. If
|
|
|
|
* this succeeds, the method will return PR_TRUE, and the rect will
|
|
|
|
* be in device coordinates (already transformed by the CTM). If it
|
|
|
|
* fails, the method will return PR_FALSE, and the rect will not be
|
|
|
|
* changed.
|
|
|
|
*/
|
|
|
|
PRBool UserToDevicePixelSnapped(gfxRect& rect) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempts to pixel snap the rectangle, add it to the current
|
|
|
|
* path, and to set pattern as the current painting source. This
|
|
|
|
* should be used for drawing filled pixel-snapped rectangles (like
|
|
|
|
* images), because the CTM at the time of the SetPattern call needs
|
|
|
|
* to have a snapped translation, or you get smeared images.
|
|
|
|
*/
|
|
|
|
void PixelSnappedRectangleAndSetPattern(const gfxRect& rect, gfxPattern *pattern);
|
|
|
|
|
2005-06-28 13:18:55 +04:00
|
|
|
/**
|
|
|
|
** Painting sources
|
|
|
|
**/
|
|
|
|
|
2005-08-20 09:36:47 +04:00
|
|
|
/**
|
|
|
|
* Uses a solid color for drawing.
|
|
|
|
*/
|
2005-04-06 05:54:26 +04:00
|
|
|
void SetColor(const gfxRGBA& c);
|
2005-08-20 09:36:47 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Uses a pattern for drawing.
|
|
|
|
*/
|
2005-06-30 08:58:27 +04:00
|
|
|
void SetPattern(gfxPattern *pattern);
|
2005-08-20 09:36:47 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Uses a surface for drawing. This is a shorthand for creating a
|
|
|
|
* pattern and setting it.
|
|
|
|
*
|
|
|
|
* @param offset ?
|
|
|
|
*/
|
|
|
|
void SetSource(gfxASurface* surface, gfxPoint offset = gfxPoint(0.0, 0.0));
|
2005-06-28 13:18:55 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
** Painting
|
|
|
|
**/
|
2005-08-20 09:36:47 +04:00
|
|
|
/**
|
|
|
|
* Paints the current source surface/pattern everywhere in the current
|
|
|
|
* clip region.
|
|
|
|
*/
|
2005-06-28 13:18:55 +04:00
|
|
|
void Paint(gfxFloat alpha = 1.0);
|
|
|
|
|
2005-08-20 09:36:47 +04:00
|
|
|
/**
|
|
|
|
** Painting with a Mask
|
|
|
|
**/
|
|
|
|
/**
|
|
|
|
* Like Paint, except that it only draws the source where pattern is
|
|
|
|
* non-transparent.
|
|
|
|
*/
|
|
|
|
void Mask(gfxPattern *pattern);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shorthand for creating a pattern and calling the pattern-taking
|
|
|
|
* variant of Mask.
|
|
|
|
*/
|
|
|
|
void Mask(gfxASurface *surface, gfxPoint offset = gfxPoint(0.0, 0.0));
|
|
|
|
|
2005-06-28 13:18:55 +04:00
|
|
|
/**
|
|
|
|
** Shortcuts
|
|
|
|
**/
|
|
|
|
|
2005-08-20 09:36:47 +04:00
|
|
|
/**
|
|
|
|
* Creates a new path with a rectangle from 0,0 to size.w,size.h
|
|
|
|
* and calls cairo_fill.
|
|
|
|
*/
|
2005-06-30 08:58:27 +04:00
|
|
|
void DrawSurface(gfxASurface *surface, gfxSize size);
|
2005-06-28 13:18:55 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
** Line Properties
|
|
|
|
**/
|
2005-04-06 05:54:26 +04:00
|
|
|
|
2005-06-30 08:58:27 +04:00
|
|
|
typedef enum {
|
|
|
|
gfxLineSolid,
|
|
|
|
gfxLineDashed,
|
|
|
|
gfxLineDotted
|
|
|
|
} gfxLineType;
|
|
|
|
|
|
|
|
void SetDash(gfxLineType ltype);
|
|
|
|
void SetDash(gfxFloat *dashes, int ndash, gfxFloat offset);
|
2005-04-06 05:54:26 +04:00
|
|
|
//void getDash() const;
|
|
|
|
|
2005-08-20 09:36:47 +04:00
|
|
|
/**
|
|
|
|
* Sets the line width that's used for line drawing.
|
|
|
|
*/
|
2005-04-08 09:44:32 +04:00
|
|
|
void SetLineWidth(gfxFloat width);
|
2005-08-20 09:36:47 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the currently set line width.
|
|
|
|
*
|
|
|
|
* @see SetLineWidth
|
|
|
|
*/
|
2005-04-08 09:44:32 +04:00
|
|
|
gfxFloat CurrentLineWidth() const;
|
2005-04-06 05:54:26 +04:00
|
|
|
|
2005-06-28 13:18:55 +04:00
|
|
|
enum GraphicsLineCap {
|
|
|
|
LINE_CAP_BUTT,
|
|
|
|
LINE_CAP_ROUND,
|
|
|
|
LINE_CAP_SQUARE
|
|
|
|
};
|
2005-08-20 09:36:47 +04:00
|
|
|
/**
|
|
|
|
* Sets the line caps, i.e. how line endings are drawn.
|
|
|
|
*/
|
2005-06-28 13:18:55 +04:00
|
|
|
void SetLineCap(GraphicsLineCap cap);
|
|
|
|
GraphicsLineCap CurrentLineCap() const;
|
|
|
|
|
|
|
|
enum GraphicsLineJoin {
|
|
|
|
LINE_JOIN_MITER,
|
|
|
|
LINE_JOIN_ROUND,
|
|
|
|
LINE_JOIN_BEVEL
|
|
|
|
};
|
2005-08-20 09:36:47 +04:00
|
|
|
/**
|
|
|
|
* Sets the line join, i.e. how the connection between two lines is
|
|
|
|
* drawn.
|
|
|
|
*/
|
2005-06-28 13:18:55 +04:00
|
|
|
void SetLineJoin(GraphicsLineJoin join);
|
|
|
|
GraphicsLineJoin CurrentLineJoin() const;
|
|
|
|
|
|
|
|
void SetMiterLimit(gfxFloat limit);
|
|
|
|
gfxFloat CurrentMiterLimit() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
** Operators and Rendering control
|
|
|
|
**/
|
|
|
|
|
2005-04-06 05:54:26 +04:00
|
|
|
// define enum for operators (clear, src, dst, etc)
|
|
|
|
enum GraphicsOperator {
|
2005-08-20 09:36:47 +04:00
|
|
|
OPERATOR_CLEAR = CAIRO_OPERATOR_CLEAR,
|
|
|
|
OPERATOR_SOURCE = CAIRO_OPERATOR_SOURCE,
|
|
|
|
|
|
|
|
OPERATOR_OVER = CAIRO_OPERATOR_OVER,
|
|
|
|
OPERATOR_IN = CAIRO_OPERATOR_IN,
|
|
|
|
OPERATOR_OUT = CAIRO_OPERATOR_OUT,
|
|
|
|
OPERATOR_ATOP = CAIRO_OPERATOR_ATOP,
|
|
|
|
|
|
|
|
OPERATOR_DEST = CAIRO_OPERATOR_DEST,
|
|
|
|
OPERATOR_DEST_OVER = CAIRO_OPERATOR_DEST_OVER,
|
|
|
|
OPERATOR_DEST_IN = CAIRO_OPERATOR_DEST_IN,
|
|
|
|
OPERATOR_DEST_OUT = CAIRO_OPERATOR_DEST_OUT,
|
|
|
|
OPERATOR_DEST_ATOP = CAIRO_OPERATOR_DEST_ATOP,
|
|
|
|
|
|
|
|
OPERATOR_XOR = CAIRO_OPERATOR_XOR,
|
|
|
|
OPERATOR_ADD = CAIRO_OPERATOR_ADD,
|
|
|
|
OPERATOR_SATURATE = CAIRO_OPERATOR_SATURATE
|
2005-04-06 05:54:26 +04:00
|
|
|
};
|
2005-08-20 09:36:47 +04:00
|
|
|
/**
|
|
|
|
* Sets the operator used for all further drawing. The operator affects
|
|
|
|
* how drawing something will modify the destination. For example, the
|
|
|
|
* OVER operator will do alpha blending of source and destination, while
|
|
|
|
* SOURCE will replace the destination with the source.
|
|
|
|
*/
|
2005-04-06 05:54:26 +04:00
|
|
|
void SetOperator(GraphicsOperator op);
|
|
|
|
GraphicsOperator CurrentOperator() const;
|
|
|
|
|
2005-04-12 02:22:10 +04:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
enum AntialiasMode {
|
|
|
|
MODE_ALIASED,
|
|
|
|
MODE_COVERAGE
|
|
|
|
};
|
|
|
|
void SetAntialiasMode(AntialiasMode mode);
|
|
|
|
AntialiasMode CurrentAntialiasMode();
|
2005-04-06 05:54:26 +04:00
|
|
|
|
2005-06-28 13:18:55 +04:00
|
|
|
/**
|
|
|
|
** Clipping
|
|
|
|
**/
|
2005-04-06 05:54:26 +04:00
|
|
|
|
2005-08-20 09:36:47 +04:00
|
|
|
/**
|
|
|
|
* Clips all further drawing to the current path.
|
|
|
|
* This does not consume the current path.
|
|
|
|
*/
|
|
|
|
void Clip();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Undoes any clipping. Further drawings will only be restricted by the
|
|
|
|
* surface dimensions.
|
|
|
|
*/
|
|
|
|
void ResetClip();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper functions that will create a rect path and call Clip().
|
|
|
|
* Any current path will be destroyed by these functions!
|
|
|
|
*/
|
2005-06-28 13:18:55 +04:00
|
|
|
void Clip(gfxRect rect); // will clip to a rect
|
|
|
|
void Clip(const gfxRegion& region); // will clip to a region
|
2005-04-06 05:54:26 +04:00
|
|
|
|
2006-02-23 23:55:42 +03:00
|
|
|
/**
|
|
|
|
* This will ensure that the surface actually has its clip set.
|
|
|
|
* Useful if you are doing native drawing.
|
|
|
|
*/
|
|
|
|
void UpdateSurfaceClip();
|
|
|
|
|
2006-01-19 01:43:42 +03:00
|
|
|
/**
|
|
|
|
* Groups
|
|
|
|
*/
|
2006-02-10 05:20:35 +03:00
|
|
|
enum SurfaceContent {
|
|
|
|
CONTENT_COLOR = CAIRO_CONTENT_COLOR,
|
|
|
|
CONTENT_ALPHA = CAIRO_CONTENT_ALPHA,
|
|
|
|
CONTENT_COLOR_ALPHA = CAIRO_CONTENT_COLOR_ALPHA
|
|
|
|
};
|
|
|
|
|
|
|
|
void PushGroup(SurfaceContent content = CONTENT_COLOR_ALPHA);
|
2006-01-19 01:43:42 +03:00
|
|
|
gfxPattern *PopGroup();
|
|
|
|
void PopGroupToSource();
|
|
|
|
|
2006-01-13 18:06:22 +03:00
|
|
|
/**
|
2006-02-01 08:21:59 +03:00
|
|
|
* Printing functions
|
2006-01-13 18:06:22 +03:00
|
|
|
*/
|
2006-02-01 08:21:59 +03:00
|
|
|
// XXX look and see if the arguments here should be a seperate object
|
|
|
|
void BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName);
|
|
|
|
void EndPrinting();
|
|
|
|
void AbortPrinting();
|
|
|
|
void BeginPage();
|
|
|
|
void EndPage();
|
2006-01-13 18:06:22 +03:00
|
|
|
|
2005-04-06 05:54:26 +04:00
|
|
|
private:
|
|
|
|
cairo_t *mCairo;
|
2005-06-28 13:27:02 +04:00
|
|
|
nsRefPtr<gfxASurface> mSurface;
|
2005-04-06 05:54:26 +04:00
|
|
|
};
|
|
|
|
|
2005-04-11 08:36:18 +04:00
|
|
|
#endif /* GFX_CONTEXT_H */
|