Expose Cairo path copy/append functions through Thebes - bug 445616 r=vlad

This commit is contained in:
Eric Butler 2008-07-18 11:26:02 -07:00
Родитель d7487bf8bd
Коммит 1ed317198b
4 изменённых файлов: 62 добавлений и 9 удалений

Просмотреть файл

@ -140,6 +140,16 @@ public:
*/
void ClosePath();
/**
* Copies the current path and returns the copy.
*/
already_AddRefed<gfxPath> CopyPath();
/**
* Appends the given path to the current path.
*/
void AppendPath(gfxPath* path);
/**
* Moves the pen to a new point without drawing a line.
*/

Просмотреть файл

@ -39,15 +39,41 @@
#include "gfxTypes.h"
class gfxContext;
struct gfxPoint;
typedef struct cairo_path cairo_path_t;
class THEBES_API gfxFlattenedPath {
/**
* Class representing a path. Can be created by copying the current path
* of a gfxContext.
*/
class THEBES_API gfxPath {
THEBES_INLINE_DECL_REFCOUNTING(gfxPath)
friend class gfxContext;
protected:
gfxPath(cairo_path_t* aPath);
public:
gfxFlattenedPath(cairo_path_t *aPath);
~gfxFlattenedPath();
virtual ~gfxPath();
protected:
cairo_path_t* mPath;
};
/**
* Specialization of a path that only contains linear pieces. Can be created
* from the existing path of a gfxContext.
*/
class THEBES_API gfxFlattenedPath : public gfxPath {
friend class gfxContext;
protected:
gfxFlattenedPath(cairo_path_t* aPath);
public:
virtual ~gfxFlattenedPath();
/**
* Returns calculated total length of path
@ -62,10 +88,7 @@ public:
* @param aAngle optional - output tangent
*/
gfxPoint FindPoint(gfxPoint aOffset,
gfxFloat *aAngle = nsnull);
protected:
cairo_path_t *mPath;
gfxFloat* aAngle = nsnull);
};
#endif

Просмотреть файл

@ -116,6 +116,18 @@ gfxContext::ClosePath()
cairo_close_path(mCairo);
}
already_AddRefed<gfxPath> gfxContext::CopyPath()
{
nsRefPtr<gfxPath> path = new gfxPath(cairo_copy_path(mCairo));
return path.forget();
}
void gfxContext::AppendPath(gfxPath* path)
{
if (path->mPath->status == CAIRO_STATUS_SUCCESS && path->mPath->num_data != 0)
cairo_append_path(mCairo, path->mPath);
}
gfxPoint
gfxContext::CurrentPoint() const
{

Просмотреть файл

@ -39,13 +39,21 @@
#include "cairo.h"
gfxFlattenedPath::gfxFlattenedPath(cairo_path_t *aPath) : mPath(aPath)
gfxPath::gfxPath(cairo_path_t* aPath) : mPath(aPath)
{
}
gfxPath::~gfxPath()
{
cairo_path_destroy(mPath);
}
gfxFlattenedPath::gfxFlattenedPath(cairo_path_t* aPath) : gfxPath(aPath)
{
}
gfxFlattenedPath::~gfxFlattenedPath()
{
cairo_path_destroy(mPath);
}
static gfxFloat