зеркало из https://github.com/mozilla/pjs.git
Expose Cairo path copy/append functions through Thebes - bug 445616 r=vlad
This commit is contained in:
Родитель
9c29e506e3
Коммит
20e06052e3
|
@ -140,6 +140,16 @@ public:
|
||||||
*/
|
*/
|
||||||
void ClosePath();
|
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.
|
* Moves the pen to a new point without drawing a line.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -39,15 +39,41 @@
|
||||||
|
|
||||||
#include "gfxTypes.h"
|
#include "gfxTypes.h"
|
||||||
|
|
||||||
|
class gfxContext;
|
||||||
struct gfxPoint;
|
struct gfxPoint;
|
||||||
typedef struct cairo_path cairo_path_t;
|
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)
|
THEBES_INLINE_DECL_REFCOUNTING(gfxPath)
|
||||||
|
|
||||||
|
friend class gfxContext;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
gfxPath(cairo_path_t* aPath);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
gfxFlattenedPath(cairo_path_t *aPath);
|
virtual ~gfxPath();
|
||||||
~gfxFlattenedPath();
|
|
||||||
|
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
|
* Returns calculated total length of path
|
||||||
|
@ -62,10 +88,7 @@ public:
|
||||||
* @param aAngle optional - output tangent
|
* @param aAngle optional - output tangent
|
||||||
*/
|
*/
|
||||||
gfxPoint FindPoint(gfxPoint aOffset,
|
gfxPoint FindPoint(gfxPoint aOffset,
|
||||||
gfxFloat *aAngle = nsnull);
|
gfxFloat* aAngle = nsnull);
|
||||||
|
|
||||||
protected:
|
|
||||||
cairo_path_t *mPath;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -116,6 +116,18 @@ gfxContext::ClosePath()
|
||||||
cairo_close_path(mCairo);
|
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
|
gfxPoint
|
||||||
gfxContext::CurrentPoint() const
|
gfxContext::CurrentPoint() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,13 +39,21 @@
|
||||||
|
|
||||||
#include "cairo.h"
|
#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()
|
gfxFlattenedPath::~gfxFlattenedPath()
|
||||||
{
|
{
|
||||||
cairo_path_destroy(mPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gfxFloat
|
static gfxFloat
|
||||||
|
|
Загрузка…
Ссылка в новой задаче