зеркало из https://github.com/mozilla/pjs.git
stop exporting cairo headers from thebes headers. bug 368377. r=vlad
This commit is contained in:
Родитель
c9ef4deaae
Коммит
b23f38fda6
|
@ -352,8 +352,8 @@ nsThebesImage::Draw(nsIRenderingContext &aContext, nsIDrawingSurface *aSurface,
|
|||
// See comment inside ThebesDrawTile
|
||||
if (doSnap) {
|
||||
gfxMatrix roundedCTM(savedCTM);
|
||||
roundedCTM.x0() = ::floor(roundedCTM.x0() + 0.5);
|
||||
roundedCTM.y0() = ::floor(roundedCTM.y0() + 0.5);
|
||||
roundedCTM.x0 = ::floor(roundedCTM.x0 + 0.5);
|
||||
roundedCTM.y0 = ::floor(roundedCTM.y0 + 0.5);
|
||||
ctx->SetMatrix(roundedCTM);
|
||||
}
|
||||
|
||||
|
@ -431,8 +431,8 @@ nsThebesImage::ThebesDrawTile(gfxContext *thebesContext,
|
|||
// is what's used at the time of a SetPattern call).
|
||||
if (doSnap) {
|
||||
gfxMatrix roundedCTM(savedCTM);
|
||||
roundedCTM.x0() = ::floor(roundedCTM.x0() + 0.5);
|
||||
roundedCTM.y0() = ::floor(roundedCTM.y0() + 0.5);
|
||||
roundedCTM.x0 = ::floor(roundedCTM.x0 + 0.5);
|
||||
roundedCTM.y0 = ::floor(roundedCTM.y0 + 0.5);
|
||||
thebesContext->SetMatrix(roundedCTM);
|
||||
}
|
||||
|
||||
|
@ -487,7 +487,7 @@ nsThebesImage::ThebesDrawTile(gfxContext *thebesContext,
|
|||
patMat.Translate(p0);
|
||||
|
||||
pat = new gfxPattern(surface);
|
||||
pat->SetExtend(CAIRO_EXTEND_REPEAT);
|
||||
pat->SetExtend(gfxPattern::EXTEND_REPEAT);
|
||||
pat->SetMatrix(patMat);
|
||||
|
||||
thebesContext->SetPattern(pat);
|
||||
|
|
|
@ -231,10 +231,9 @@ nsThebesRenderingContext::PopTranslation(PushedTranslation* aState)
|
|||
NS_IMETHODIMP
|
||||
nsThebesRenderingContext::SetTranslation(nscoord aX, nscoord aY)
|
||||
{
|
||||
gfxMatrix mat = mThebes->CurrentMatrix();
|
||||
gfxFloat a, b, c, d, tx, ty;
|
||||
mat.ToValues(&a, &b, &c, &d, &tx, &ty);
|
||||
gfxMatrix newMat(a, b, c, d, aX, aY);
|
||||
gfxMatrix newMat(mThebes->CurrentMatrix());
|
||||
newMat.x0 = aX;
|
||||
newMat.y0 = aY;
|
||||
mThebes->SetMatrix(newMat);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -452,13 +451,10 @@ nsThebesRenderingContext::UpdateTempTransformMatrix()
|
|||
* | x0 y0 1 | | m20 m21 1 |
|
||||
*****/
|
||||
|
||||
// this sort of sucks
|
||||
gfxFloat xx, yx, xy, yy, x0, y0;
|
||||
mThebes->CurrentMatrix().ToValues(&xx, &yx, &xy, &yy, &x0, &y0);
|
||||
|
||||
NS_ASSERTION(yx == 0 && xy == 0, "Can't represent Thebes matrix to Gfx");
|
||||
mTempTransform.SetToTranslate(TO_TWIPS(x0), TO_TWIPS(y0));
|
||||
mTempTransform.AddScale(xx, yy);
|
||||
const gfxMatrix& ctm = mThebes->CurrentMatrix();
|
||||
NS_ASSERTION(ctm.yx == 0 && ctm.xy == 0, "Can't represent Thebes matrix to Gfx");
|
||||
mTempTransform.SetToTranslate(TO_TWIPS(ctm.x0), TO_TWIPS(ctm.y0));
|
||||
mTempTransform.AddScale(ctm.xx, ctm.yy);
|
||||
}
|
||||
|
||||
nsTransform2D&
|
||||
|
|
|
@ -38,46 +38,23 @@
|
|||
#ifndef GFX_ASURFACE_H
|
||||
#define GFX_ASURFACE_H
|
||||
|
||||
#include <cairo.h>
|
||||
|
||||
#include "gfxTypes.h"
|
||||
#include "gfxRect.h"
|
||||
#include "nsStringFwd.h"
|
||||
|
||||
typedef struct _cairo_surface cairo_surface_t;
|
||||
typedef struct _cairo_user_data_key cairo_user_data_key_t;
|
||||
|
||||
typedef void (*thebes_destroy_func_t) (void *data);
|
||||
|
||||
/**
|
||||
* A surface is something you can draw on. Instantiate a subclass of this
|
||||
* abstract class, and use gfxContext to draw on this surface.
|
||||
*/
|
||||
class THEBES_API gfxASurface {
|
||||
public:
|
||||
// Surfaces use refcounting that's tied to the cairo surface refcnt, to avoid
|
||||
// refcount mismatch issues.
|
||||
nsrefcnt AddRef(void) {
|
||||
NS_PRECONDITION(mSurface != nsnull, "gfxASurface::AddRef without mSurface");
|
||||
|
||||
if (mHasFloatingRef) {
|
||||
// eat the floating ref
|
||||
mHasFloatingRef = PR_FALSE;
|
||||
} else {
|
||||
cairo_surface_reference(mSurface);
|
||||
}
|
||||
|
||||
return (nsrefcnt) cairo_surface_get_reference_count(mSurface);
|
||||
}
|
||||
|
||||
nsrefcnt Release(void) {
|
||||
NS_PRECONDITION(!mHasFloatingRef, "gfxASurface::Release while floating ref still outstanding!");
|
||||
NS_PRECONDITION(mSurface != nsnull, "gfxASurface::Release without mSurface");
|
||||
// Note that there is a destructor set on user data for mSurface,
|
||||
// which will delete this gfxASurface wrapper when the surface's refcount goes
|
||||
// out of scope.
|
||||
nsrefcnt refcnt = (nsrefcnt) cairo_surface_get_reference_count(mSurface);
|
||||
cairo_surface_destroy(mSurface);
|
||||
|
||||
// |this| may not be valid any more, don't use it!
|
||||
|
||||
return --refcnt;
|
||||
}
|
||||
nsrefcnt AddRef(void);
|
||||
nsrefcnt Release(void);
|
||||
|
||||
public:
|
||||
/**
|
||||
|
@ -108,9 +85,9 @@ public:
|
|||
} gfxSurfaceType;
|
||||
|
||||
typedef enum {
|
||||
CONTENT_COLOR = CAIRO_CONTENT_COLOR,
|
||||
CONTENT_ALPHA = CAIRO_CONTENT_ALPHA,
|
||||
CONTENT_COLOR_ALPHA = CAIRO_CONTENT_COLOR_ALPHA
|
||||
CONTENT_COLOR = 0x1000,
|
||||
CONTENT_ALPHA = 0x2000,
|
||||
CONTENT_COLOR_ALPHA = 0x3000
|
||||
} gfxContentType;
|
||||
|
||||
/* Wrap the given cairo surface and return a gfxASurface for it */
|
||||
|
@ -119,26 +96,27 @@ public:
|
|||
/*** this DOES NOT addref the surface */
|
||||
cairo_surface_t *CairoSurface() { return mSurface; }
|
||||
|
||||
gfxSurfaceType GetType() const { return (gfxSurfaceType)cairo_surface_get_type(mSurface); }
|
||||
gfxSurfaceType GetType() const;
|
||||
|
||||
gfxContentType GetContentType() const { return (gfxContentType)cairo_surface_get_content(mSurface); }
|
||||
gfxContentType GetContentType() const;
|
||||
|
||||
void SetDeviceOffset (gfxFloat xOff, gfxFloat yOff) {
|
||||
cairo_surface_set_device_offset(mSurface,
|
||||
xOff, yOff);
|
||||
void SetDeviceOffset(gfxPoint offset);
|
||||
gfxPoint GetDeviceOffset() const;
|
||||
|
||||
// XXX deprecated remove this
|
||||
void SetDeviceOffset(gfxFloat xOff, gfxFloat yOff) {
|
||||
SetDeviceOffset(gfxPoint(xOff, yOff));
|
||||
}
|
||||
// XXX deprecated remove this
|
||||
void GetDeviceOffset(gfxFloat *xOff, gfxFloat *yOff) const {
|
||||
gfxPoint pt = GetDeviceOffset();
|
||||
*xOff = pt.x;
|
||||
*yOff = pt.y;
|
||||
}
|
||||
|
||||
void GetDeviceOffset (gfxFloat *xOff, gfxFloat *yOff) {
|
||||
cairo_surface_get_device_offset(mSurface, xOff, yOff);
|
||||
}
|
||||
|
||||
void Flush() { cairo_surface_flush(mSurface); }
|
||||
void MarkDirty() { cairo_surface_mark_dirty(mSurface); }
|
||||
void MarkDirty(const gfxRect& r) {
|
||||
cairo_surface_mark_dirty_rectangle(mSurface,
|
||||
(int) r.pos.x, (int) r.pos.y,
|
||||
(int) r.size.width, (int) r.size.height);
|
||||
}
|
||||
void Flush();
|
||||
void MarkDirty();
|
||||
void MarkDirty(const gfxRect& r);
|
||||
|
||||
/* Printing backend functions */
|
||||
virtual nsresult BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
|
@ -149,15 +127,8 @@ public:
|
|||
|
||||
void SetData(const cairo_user_data_key_t *key,
|
||||
void *user_data,
|
||||
cairo_destroy_func_t destroy)
|
||||
{
|
||||
cairo_surface_set_user_data (mSurface, key, user_data, destroy);
|
||||
}
|
||||
|
||||
void *GetData(const cairo_user_data_key_t *key)
|
||||
{
|
||||
return cairo_surface_get_user_data (mSurface, key);
|
||||
}
|
||||
thebes_destroy_func_t destroy);
|
||||
void *GetData(const cairo_user_data_key_t *key);
|
||||
|
||||
protected:
|
||||
static gfxASurface* GetSurfaceWrapper(cairo_surface_t *csurf);
|
||||
|
|
|
@ -35,8 +35,8 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _GFX_COLOR_H
|
||||
#define _GFX_COLOR_H
|
||||
#ifndef GFX_COLOR_H
|
||||
#define GFX_COLOR_H
|
||||
|
||||
#include "nsPrintfCString.h"
|
||||
|
||||
|
|
|
@ -39,18 +39,16 @@
|
|||
#ifndef GFX_CONTEXT_H
|
||||
#define GFX_CONTEXT_H
|
||||
|
||||
#include <cairo.h>
|
||||
#include "gfxTypes.h"
|
||||
|
||||
#include "gfxASurface.h"
|
||||
#include "gfxColor.h"
|
||||
#include "gfxPoint.h"
|
||||
#include "gfxRect.h"
|
||||
#include "gfxTypes.h"
|
||||
#include "gfxMatrix.h"
|
||||
#include "gfxPattern.h"
|
||||
#include "gfxFont.h"
|
||||
|
||||
class gfxRegion;
|
||||
typedef struct _cairo cairo_t;
|
||||
|
||||
/**
|
||||
* This is the main class for doing actual drawing. It is initialized using
|
||||
|
@ -429,23 +427,23 @@ public:
|
|||
|
||||
// define enum for operators (clear, src, dst, etc)
|
||||
enum GraphicsOperator {
|
||||
OPERATOR_CLEAR = CAIRO_OPERATOR_CLEAR,
|
||||
OPERATOR_SOURCE = CAIRO_OPERATOR_SOURCE,
|
||||
OPERATOR_CLEAR,
|
||||
OPERATOR_SOURCE,
|
||||
|
||||
OPERATOR_OVER = CAIRO_OPERATOR_OVER,
|
||||
OPERATOR_IN = CAIRO_OPERATOR_IN,
|
||||
OPERATOR_OUT = CAIRO_OPERATOR_OUT,
|
||||
OPERATOR_ATOP = CAIRO_OPERATOR_ATOP,
|
||||
OPERATOR_OVER,
|
||||
OPERATOR_IN,
|
||||
OPERATOR_OUT,
|
||||
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_DEST,
|
||||
OPERATOR_DEST_OVER,
|
||||
OPERATOR_DEST_IN,
|
||||
OPERATOR_DEST_OUT,
|
||||
OPERATOR_DEST_ATOP,
|
||||
|
||||
OPERATOR_XOR = CAIRO_OPERATOR_XOR,
|
||||
OPERATOR_ADD = CAIRO_OPERATOR_ADD,
|
||||
OPERATOR_SATURATE = CAIRO_OPERATOR_SATURATE
|
||||
OPERATOR_XOR,
|
||||
OPERATOR_ADD,
|
||||
OPERATOR_SATURATE
|
||||
};
|
||||
/**
|
||||
* Sets the operator used for all further drawing. The operator affects
|
||||
|
@ -489,7 +487,6 @@ public:
|
|||
* Any current path will be destroyed by these functions!
|
||||
*/
|
||||
void Clip(gfxRect rect); // will clip to a rect
|
||||
void Clip(const gfxRegion& region); // will clip to a region
|
||||
|
||||
/**
|
||||
* This will ensure that the surface actually has its clip set.
|
||||
|
|
|
@ -38,8 +38,6 @@
|
|||
#ifndef GFX_MATRIX_H
|
||||
#define GFX_MATRIX_H
|
||||
|
||||
#include <cairo.h>
|
||||
|
||||
#include "gfxPoint.h"
|
||||
#include "gfxTypes.h"
|
||||
#include "gfxRect.h"
|
||||
|
@ -64,46 +62,25 @@
|
|||
* \ tx ty 1 / \ 1 /
|
||||
*
|
||||
*/
|
||||
class THEBES_API gfxMatrix {
|
||||
protected:
|
||||
cairo_matrix_t mat;
|
||||
struct THEBES_API gfxMatrix {
|
||||
double xx; double yx;
|
||||
double xy; double yy;
|
||||
double x0; double y0;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Initializes this matrix as the identity matrix.
|
||||
*/
|
||||
gfxMatrix() { Reset(); }
|
||||
gfxMatrix(const gfxMatrix& m) : mat(m.mat) {}
|
||||
|
||||
/**
|
||||
* Initializes the matrix from individual components. See the class
|
||||
* description for the layout of the matrix.
|
||||
*/
|
||||
gfxMatrix(gfxFloat a, gfxFloat b, gfxFloat c, gfxFloat d, gfxFloat tx, gfxFloat ty) {
|
||||
// XXX cairo_matrix_init?
|
||||
mat.xx = a; mat.yx = b; mat.xy = c; mat.yy = d; mat.x0 = tx; mat.y0 = ty;
|
||||
}
|
||||
|
||||
gfxMatrix(const cairo_matrix_t& m) {
|
||||
mat = m;
|
||||
}
|
||||
|
||||
bool operator==(const gfxMatrix& m) const {
|
||||
return ((mat.xx == m.mat.xx) &&
|
||||
(mat.yx == m.mat.yx) &&
|
||||
(mat.xy == m.mat.xy) &&
|
||||
(mat.yy == m.mat.yy) &&
|
||||
(mat.x0 == m.mat.x0) &&
|
||||
(mat.y0 == m.mat.y0));
|
||||
}
|
||||
|
||||
bool operator!=(const gfxMatrix& m) const {
|
||||
return !(*this == m);
|
||||
}
|
||||
|
||||
gfxMatrix& operator=(const cairo_matrix_t& m) {
|
||||
mat = m;
|
||||
return *this;
|
||||
}
|
||||
gfxMatrix(gfxFloat a, gfxFloat b, gfxFloat c, gfxFloat d, gfxFloat tx, gfxFloat ty) :
|
||||
xx(a), yx(b),
|
||||
xy(c), yy(d),
|
||||
x0(tx), y0(ty) { }
|
||||
|
||||
/**
|
||||
* Post-multiplies m onto the matrix.
|
||||
|
@ -119,45 +96,11 @@ public:
|
|||
return gfxMatrix(*this).Multiply(m);
|
||||
}
|
||||
|
||||
// conversion to other types
|
||||
const cairo_matrix_t& ToCairoMatrix() const {
|
||||
return mat;
|
||||
}
|
||||
|
||||
void ToValues(gfxFloat *xx, gfxFloat *yx,
|
||||
gfxFloat *xy, gfxFloat *yy,
|
||||
gfxFloat *x0, gfxFloat *y0) const
|
||||
{
|
||||
*xx = mat.xx;
|
||||
*yx = mat.yx;
|
||||
*xy = mat.xy;
|
||||
*yy = mat.yy;
|
||||
*x0 = mat.x0;
|
||||
*y0 = mat.y0;
|
||||
}
|
||||
|
||||
gfxFloat& xx() { return mat.xx; }
|
||||
gfxFloat& xy() { return mat.xy; }
|
||||
gfxFloat& yx() { return mat.yx; }
|
||||
gfxFloat& yy() { return mat.yy; }
|
||||
gfxFloat& x0() { return mat.x0; }
|
||||
gfxFloat& y0() { return mat.y0; }
|
||||
|
||||
const gfxFloat& xx() const { return mat.xx; }
|
||||
const gfxFloat& xy() const { return mat.xy; }
|
||||
const gfxFloat& yx() const { return mat.yx; }
|
||||
const gfxFloat& yy() const { return mat.yy; }
|
||||
const gfxFloat& x0() const { return mat.x0; }
|
||||
const gfxFloat& y0() const { return mat.y0; }
|
||||
|
||||
// matrix operations
|
||||
/**
|
||||
* Resets this matrix to the identity matrix.
|
||||
*/
|
||||
const gfxMatrix& Reset() {
|
||||
cairo_matrix_init_identity(&mat);
|
||||
return *this;
|
||||
}
|
||||
const gfxMatrix& Reset();
|
||||
|
||||
/**
|
||||
* Inverts this matrix, if possible. Otherwise, the matrix is left
|
||||
|
@ -166,36 +109,27 @@ public:
|
|||
* XXX should this do something with the return value of
|
||||
* cairo_matrix_invert?
|
||||
*/
|
||||
const gfxMatrix& Invert() {
|
||||
cairo_matrix_invert(&mat);
|
||||
return *this;
|
||||
}
|
||||
const gfxMatrix& Invert();
|
||||
|
||||
/**
|
||||
* Check if matrix is singular (no inverse exists).
|
||||
*/
|
||||
PRBool IsSingular() {
|
||||
// if the determinant (ad - bc) is zero it's singular
|
||||
return (mat.xx * mat.yy) == (mat.yx * mat.xy);
|
||||
return (xx * yy) == (yx * xy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scales this matrix. The scale is pre-multiplied onto this matrix,
|
||||
* i.e. the scaling takes place before the other transformations.
|
||||
*/
|
||||
const gfxMatrix& Scale(gfxFloat x, gfxFloat y) {
|
||||
cairo_matrix_scale(&mat, x, y);
|
||||
return *this;
|
||||
}
|
||||
const gfxMatrix& Scale(gfxFloat x, gfxFloat y);
|
||||
|
||||
/**
|
||||
* Translates this matrix. The translation is pre-multiplied onto this matrix,
|
||||
* i.e. the translation takes place before the other transformations.
|
||||
*/
|
||||
const gfxMatrix& Translate(const gfxPoint& pt) {
|
||||
cairo_matrix_translate(&mat, pt.x, pt.y);
|
||||
return *this;
|
||||
}
|
||||
const gfxMatrix& Translate(const gfxPoint& pt);
|
||||
|
||||
/**
|
||||
* Rotates this matrix. The rotation is pre-multiplied onto this matrix,
|
||||
|
@ -203,15 +137,7 @@ public:
|
|||
*
|
||||
* @param radians Angle in radians.
|
||||
*/
|
||||
const gfxMatrix& Rotate(gfxFloat radians) {
|
||||
// cairo_matrix_rotate?
|
||||
gfxFloat s = sin(radians);
|
||||
gfxFloat c = cos(radians);
|
||||
gfxMatrix t( c, s,
|
||||
-s, c,
|
||||
0, 0);
|
||||
return *this = t.Multiply(*this);
|
||||
}
|
||||
const gfxMatrix& Rotate(gfxFloat radians);
|
||||
|
||||
/**
|
||||
* Multiplies the current matrix with m.
|
||||
|
@ -220,54 +146,32 @@ public:
|
|||
*
|
||||
* XXX is that difference (compared to Rotate etc) a good thing?
|
||||
*/
|
||||
const gfxMatrix& Multiply(const gfxMatrix& m) {
|
||||
cairo_matrix_multiply(&mat, &mat, &m.mat);
|
||||
return *this;
|
||||
}
|
||||
const gfxMatrix& Multiply(const gfxMatrix& m);
|
||||
|
||||
/**
|
||||
* Transforms a point according to this matrix.
|
||||
*/
|
||||
gfxPoint Transform(const gfxPoint& point) const {
|
||||
gfxPoint ret = point;
|
||||
cairo_matrix_transform_point(&mat, &ret.x, &ret.y);
|
||||
return ret;
|
||||
}
|
||||
gfxPoint Transform(const gfxPoint& point) const;
|
||||
|
||||
|
||||
/**
|
||||
* Transform a distance according to this matrix. This does not apply
|
||||
* any translation components.
|
||||
*/
|
||||
gfxSize Transform(const gfxSize& size) const {
|
||||
gfxSize ret = size;
|
||||
cairo_matrix_transform_distance(&mat, &ret.width, &ret.height);
|
||||
return ret;
|
||||
}
|
||||
gfxSize Transform(const gfxSize& size) const;
|
||||
|
||||
/**
|
||||
* Transforms both the point and distance according to this matrix.
|
||||
*/
|
||||
gfxRect Transform(const gfxRect& rect) const {
|
||||
gfxRect ret(Transform(rect.pos), Transform(rect.size));
|
||||
return ret;
|
||||
}
|
||||
gfxRect Transform(const gfxRect& rect) const;
|
||||
|
||||
gfxRect TransformBounds(const gfxRect& rect) const {
|
||||
double x0 = rect.pos.x;
|
||||
double y0 = rect.pos.y;
|
||||
double x1 = rect.pos.x + rect.size.width;
|
||||
double y1 = rect.pos.y + rect.size.height;
|
||||
|
||||
cairo_matrix_transform_bounding_box (&mat, &x0, &y0, &x1, &y1, NULL);
|
||||
|
||||
return gfxRect(x0, y0, x1 - x0, y1 - y0);
|
||||
}
|
||||
gfxRect TransformBounds(const gfxRect& rect) const;
|
||||
|
||||
/**
|
||||
* Returns the translation component of this matrix.
|
||||
*/
|
||||
gfxPoint GetTranslation() const {
|
||||
return gfxPoint(mat.x0, mat.y0);
|
||||
return gfxPoint(x0, y0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -275,13 +179,13 @@ public:
|
|||
* than a straight translation
|
||||
*/
|
||||
bool HasNonTranslation() const {
|
||||
return ((mat.xx != 1.0) || (mat.yy != 1.0) ||
|
||||
(mat.xy != 0.0) || (mat.yx != 0.0));
|
||||
return ((xx != 1.0) || (yy != 1.0) ||
|
||||
(xy != 0.0) || (yx != 0.0));
|
||||
}
|
||||
|
||||
bool HasNonTranslationOrFlip() const {
|
||||
return ((mat.xx != 1.0) || ((mat.yy != 1.0) && (mat.yy != -1.0)) ||
|
||||
(mat.xy != 0.0) || (mat.yx != 0.0));
|
||||
return ((xx != 1.0) || ((yy != 1.0) && (yy != -1.0)) ||
|
||||
(xy != 0.0) || (yx != 0.0));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@pavlov.net>
|
||||
* Stuart Parmenter <stuart@mozilla.com>
|
||||
*
|
||||
* 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
|
||||
|
@ -38,95 +38,50 @@
|
|||
#ifndef GFX_PATTERN_H
|
||||
#define GFX_PATTERN_H
|
||||
|
||||
#include <cairo.h>
|
||||
|
||||
#include "gfxColor.h"
|
||||
#include "gfxASurface.h"
|
||||
#include "gfxMatrix.h"
|
||||
#include "gfxTypes.h"
|
||||
|
||||
#include "gfxColor.h"
|
||||
#include "gfxMatrix.h"
|
||||
|
||||
class gfxContext;
|
||||
class gfxASurface;
|
||||
typedef struct _cairo_pattern cairo_pattern_t;
|
||||
|
||||
|
||||
class THEBES_API gfxPattern {
|
||||
friend class gfxContext;
|
||||
|
||||
THEBES_INLINE_DECL_REFCOUNTING(gfxPattern)
|
||||
|
||||
public:
|
||||
gfxPattern(cairo_pattern_t *aPattern) {
|
||||
mPattern = cairo_pattern_reference(aPattern);
|
||||
}
|
||||
|
||||
gfxPattern(gfxRGBA aColor) {
|
||||
mPattern = cairo_pattern_create_rgba(aColor.r, aColor.g, aColor.b, aColor.a);
|
||||
}
|
||||
|
||||
// from another surface
|
||||
gfxPattern(gfxASurface* surface) {
|
||||
mPattern = cairo_pattern_create_for_surface(surface->CairoSurface());
|
||||
}
|
||||
|
||||
gfxPattern(cairo_pattern_t *aPattern);
|
||||
gfxPattern(gfxRGBA aColor);
|
||||
gfxPattern(gfxASurface *surface); // from another surface
|
||||
// linear
|
||||
gfxPattern(gfxFloat x0, gfxFloat y0, gfxFloat x1, gfxFloat y1) {
|
||||
mPattern = cairo_pattern_create_linear(x0, y0, x1, y1);
|
||||
}
|
||||
|
||||
// radial
|
||||
gfxPattern(gfxFloat x0, gfxFloat y0, gfxFloat x1, gfxFloat y1); // linear
|
||||
gfxPattern(gfxFloat cx0, gfxFloat cy0, gfxFloat radius0,
|
||||
gfxFloat cx1, gfxFloat cy1, gfxFloat radius1) {
|
||||
mPattern = cairo_pattern_create_radial(cx0, cy0, radius0,
|
||||
cx1, cy1, radius1);
|
||||
}
|
||||
gfxFloat cx1, gfxFloat cy1, gfxFloat radius1); // radial
|
||||
virtual ~gfxPattern();
|
||||
|
||||
virtual ~gfxPattern() {
|
||||
cairo_pattern_destroy(mPattern);
|
||||
}
|
||||
cairo_pattern_t *CairoPattern();
|
||||
void AddColorStop(gfxFloat offset, const gfxRGBA& c);
|
||||
void SetMatrix(const gfxMatrix& matrix);
|
||||
gfxMatrix CurrentMatrix() const;
|
||||
|
||||
cairo_pattern_t *CairoPattern() {
|
||||
return mPattern;
|
||||
}
|
||||
|
||||
void AddColorStop(gfxFloat offset, const gfxRGBA& c) {
|
||||
cairo_pattern_add_color_stop_rgba(mPattern, offset, c.r, c.g, c.b, c.a);
|
||||
}
|
||||
|
||||
void SetMatrix(const gfxMatrix& matrix) {
|
||||
cairo_matrix_t mat = matrix.ToCairoMatrix();
|
||||
cairo_pattern_set_matrix(mPattern, &mat);
|
||||
}
|
||||
|
||||
gfxMatrix CurrentMatrix() const {
|
||||
cairo_matrix_t mat;
|
||||
cairo_pattern_get_matrix(mPattern, &mat);
|
||||
return gfxMatrix(mat);
|
||||
}
|
||||
enum GraphicsExtend {
|
||||
EXTEND_NONE,
|
||||
EXTEND_REPEAT,
|
||||
EXTEND_REFLECT,
|
||||
EXTEND_PAD
|
||||
};
|
||||
|
||||
// none, repeat, reflect
|
||||
void SetExtend(int extend) {
|
||||
cairo_pattern_set_extend(mPattern, (cairo_extend_t)extend);
|
||||
}
|
||||
|
||||
int Extend() const {
|
||||
return (int)cairo_pattern_get_extend(mPattern);
|
||||
}
|
||||
|
||||
void SetFilter(int filter) {
|
||||
cairo_pattern_set_filter(mPattern, (cairo_filter_t)filter);
|
||||
}
|
||||
|
||||
int Filter() const {
|
||||
return (int)cairo_pattern_get_filter(mPattern);
|
||||
}
|
||||
void SetExtend(GraphicsExtend extend);
|
||||
GraphicsExtend Extend() const;
|
||||
|
||||
void SetFilter(int filter);
|
||||
int Filter() const;
|
||||
|
||||
/* returns TRUE if it succeeded */
|
||||
PRBool GetSolidColor(gfxRGBA& aColor) {
|
||||
return cairo_pattern_get_rgba(mPattern,
|
||||
&aColor.r,
|
||||
&aColor.g,
|
||||
&aColor.b,
|
||||
&aColor.a) == CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
PRBool GetSolidColor(gfxRGBA& aColor);
|
||||
|
||||
protected:
|
||||
cairo_pattern_t *mPattern;
|
||||
|
|
|
@ -41,8 +41,8 @@
|
|||
|
||||
#include "gfxASurface.h"
|
||||
|
||||
#include <cairo-xlib.h>
|
||||
#include <cairo-xlib-xrender.h>
|
||||
#include <X11/extensions/Xrender.h>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
class THEBES_API gfxXlibSurface : public gfxASurface {
|
||||
public:
|
||||
|
|
|
@ -26,11 +26,13 @@ CPPSRCS = \
|
|||
gfxContext.cpp \
|
||||
gfxImageSurface.cpp \
|
||||
gfxFont.cpp \
|
||||
gfxFontTest.cpp \
|
||||
gfxMatrix.cpp \
|
||||
gfxPattern.cpp \
|
||||
gfxPlatform.cpp \
|
||||
gfxRect.cpp \
|
||||
gfxSkipChars.cpp \
|
||||
gfxTextRunCache.cpp \
|
||||
gfxPlatform.cpp \
|
||||
gfxFontTest.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_TREE_CAIRO
|
||||
|
|
|
@ -36,12 +36,12 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gfxASurface.h"
|
||||
|
||||
#include "gfxImageSurface.h"
|
||||
|
||||
#include "cairo.h"
|
||||
|
||||
#ifdef CAIRO_HAS_WIN32_SURFACE
|
||||
#include "gfxWindowsSurface.h"
|
||||
#endif
|
||||
|
@ -54,8 +54,43 @@
|
|||
#include "gfxQuartzSurface.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static cairo_user_data_key_t gfxasurface_pointer_key;
|
||||
|
||||
// Surfaces use refcounting that's tied to the cairo surface refcnt, to avoid
|
||||
// refcount mismatch issues.
|
||||
nsrefcnt
|
||||
gfxASurface::AddRef(void)
|
||||
{
|
||||
NS_PRECONDITION(mSurface != nsnull, "gfxASurface::AddRef without mSurface");
|
||||
|
||||
if (mHasFloatingRef) {
|
||||
// eat the floating ref
|
||||
mHasFloatingRef = PR_FALSE;
|
||||
} else {
|
||||
cairo_surface_reference(mSurface);
|
||||
}
|
||||
|
||||
return (nsrefcnt) cairo_surface_get_reference_count(mSurface);
|
||||
}
|
||||
|
||||
nsrefcnt
|
||||
gfxASurface::Release(void)
|
||||
{
|
||||
NS_PRECONDITION(!mHasFloatingRef, "gfxASurface::Release while floating ref still outstanding!");
|
||||
NS_PRECONDITION(mSurface != nsnull, "gfxASurface::Release without mSurface");
|
||||
// Note that there is a destructor set on user data for mSurface,
|
||||
// which will delete this gfxASurface wrapper when the surface's refcount goes
|
||||
// out of scope.
|
||||
nsrefcnt refcnt = (nsrefcnt) cairo_surface_get_reference_count(mSurface);
|
||||
cairo_surface_destroy(mSurface);
|
||||
|
||||
// |this| may not be valid any more, don't use it!
|
||||
|
||||
return --refcnt;
|
||||
}
|
||||
|
||||
void
|
||||
gfxASurface::SurfaceDestroyFunc(void *data) {
|
||||
gfxASurface *surf = (gfxASurface*) data;
|
||||
|
@ -132,3 +167,65 @@ gfxASurface::Init(cairo_surface_t* surface, PRBool existingSurface)
|
|||
mHasFloatingRef = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
gfxASurface::gfxSurfaceType
|
||||
gfxASurface::GetType() const
|
||||
{
|
||||
return (gfxSurfaceType)cairo_surface_get_type(mSurface);
|
||||
}
|
||||
|
||||
gfxASurface::gfxContentType
|
||||
gfxASurface::GetContentType() const
|
||||
{
|
||||
return (gfxContentType)cairo_surface_get_content(mSurface);
|
||||
}
|
||||
|
||||
void
|
||||
gfxASurface::SetDeviceOffset(gfxPoint offset)
|
||||
{
|
||||
cairo_surface_set_device_offset(mSurface,
|
||||
offset.x, offset.y);
|
||||
}
|
||||
|
||||
gfxPoint
|
||||
gfxASurface::GetDeviceOffset() const
|
||||
{
|
||||
gfxPoint pt;
|
||||
cairo_surface_get_device_offset(mSurface, &pt.x, &pt.y);
|
||||
return pt;
|
||||
}
|
||||
|
||||
void
|
||||
gfxASurface::Flush()
|
||||
{
|
||||
cairo_surface_flush(mSurface);
|
||||
}
|
||||
|
||||
void
|
||||
gfxASurface::MarkDirty()
|
||||
{
|
||||
cairo_surface_mark_dirty(mSurface);
|
||||
}
|
||||
|
||||
void
|
||||
gfxASurface::MarkDirty(const gfxRect& r)
|
||||
{
|
||||
cairo_surface_mark_dirty_rectangle(mSurface,
|
||||
(int) r.pos.x, (int) r.pos.y,
|
||||
(int) r.size.width, (int) r.size.height);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gfxASurface::SetData(const cairo_user_data_key_t *key,
|
||||
void *user_data,
|
||||
cairo_destroy_func_t destroy)
|
||||
{
|
||||
cairo_surface_set_user_data(mSurface, key, user_data, destroy);
|
||||
}
|
||||
|
||||
void *
|
||||
gfxASurface::GetData(const cairo_user_data_key_t *key)
|
||||
{
|
||||
return cairo_surface_get_user_data(mSurface, key);
|
||||
}
|
||||
|
|
|
@ -45,6 +45,8 @@
|
|||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
#include "cairo.h"
|
||||
|
||||
#include "gfxContext.h"
|
||||
|
||||
#include "gfxColor.h"
|
||||
|
@ -52,6 +54,8 @@
|
|||
#include "gfxASurface.h"
|
||||
#include "gfxPattern.h"
|
||||
|
||||
|
||||
|
||||
gfxContext::gfxContext(gfxASurface *surface) :
|
||||
mSurface(surface)
|
||||
{
|
||||
|
@ -277,14 +281,14 @@ gfxContext::Rotate(gfxFloat angle)
|
|||
void
|
||||
gfxContext::Multiply(const gfxMatrix& matrix)
|
||||
{
|
||||
const cairo_matrix_t& mat = matrix.ToCairoMatrix();
|
||||
const cairo_matrix_t& mat = reinterpret_cast<const cairo_matrix_t&>(matrix);
|
||||
cairo_transform(mCairo, &mat);
|
||||
}
|
||||
|
||||
void
|
||||
gfxContext::SetMatrix(const gfxMatrix& matrix)
|
||||
{
|
||||
const cairo_matrix_t& mat = matrix.ToCairoMatrix();
|
||||
const cairo_matrix_t& mat = reinterpret_cast<const cairo_matrix_t&>(matrix);
|
||||
cairo_set_matrix(mCairo, &mat);
|
||||
}
|
||||
|
||||
|
@ -299,7 +303,7 @@ gfxContext::CurrentMatrix() const
|
|||
{
|
||||
cairo_matrix_t mat;
|
||||
cairo_get_matrix(mCairo, &mat);
|
||||
return gfxMatrix(mat);
|
||||
return gfxMatrix(*reinterpret_cast<gfxMatrix*>(&mat));
|
||||
}
|
||||
|
||||
gfxPoint
|
||||
|
@ -563,11 +567,6 @@ gfxContext::Clip(gfxRect rect)
|
|||
cairo_clip(mCairo);
|
||||
}
|
||||
|
||||
void
|
||||
gfxContext::Clip(const gfxRegion& region)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
gfxContext::Clip()
|
||||
{
|
||||
|
|
|
@ -35,10 +35,10 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gfxImageSurface.h"
|
||||
|
||||
#include "cairo.h"
|
||||
|
||||
gfxImageSurface::gfxImageSurface(gfxImageFormat format, long width, long height) :
|
||||
mFormat(format), mWidth(width), mHeight(height)
|
||||
{
|
||||
|
@ -46,8 +46,6 @@ gfxImageSurface::gfxImageSurface(gfxImageFormat format, long width, long height)
|
|||
mData = new unsigned char[height * stride];
|
||||
mOwnsData = PR_TRUE;
|
||||
|
||||
//memset(mData, 0xff, height*stride);
|
||||
|
||||
cairo_surface_t *surface =
|
||||
cairo_image_surface_create_for_data((unsigned char*)mData,
|
||||
(cairo_format_t)format,
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
/* -*- 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>
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
#include "gfxMatrix.h"
|
||||
#include "cairo.h"
|
||||
|
||||
#define CAIRO_MATRIX(x) reinterpret_cast<cairo_matrix_t*>((x))
|
||||
#define CONST_CAIRO_MATRIX(x) reinterpret_cast<const cairo_matrix_t*>((x))
|
||||
|
||||
const gfxMatrix&
|
||||
gfxMatrix::Reset()
|
||||
{
|
||||
cairo_matrix_init_identity(CAIRO_MATRIX(this));
|
||||
return *this;
|
||||
}
|
||||
|
||||
const gfxMatrix&
|
||||
gfxMatrix::Invert()
|
||||
{
|
||||
cairo_matrix_invert(CAIRO_MATRIX(this));
|
||||
return *this;
|
||||
}
|
||||
|
||||
const gfxMatrix&
|
||||
gfxMatrix::Scale(gfxFloat x, gfxFloat y)
|
||||
{
|
||||
cairo_matrix_scale(CAIRO_MATRIX(this), x, y);
|
||||
return *this;
|
||||
}
|
||||
|
||||
const gfxMatrix&
|
||||
gfxMatrix::Translate(const gfxPoint& pt)
|
||||
{
|
||||
cairo_matrix_translate(CAIRO_MATRIX(this), pt.x, pt.y);
|
||||
return *this;
|
||||
}
|
||||
|
||||
const gfxMatrix&
|
||||
gfxMatrix::Rotate(gfxFloat radians)
|
||||
{
|
||||
cairo_matrix_rotate(CAIRO_MATRIX(this), radians);
|
||||
return *this;
|
||||
}
|
||||
|
||||
const gfxMatrix&
|
||||
gfxMatrix::Multiply(const gfxMatrix& m)
|
||||
{
|
||||
cairo_matrix_multiply(CAIRO_MATRIX(this), CAIRO_MATRIX(this), CONST_CAIRO_MATRIX(&m));
|
||||
return *this;
|
||||
}
|
||||
|
||||
gfxPoint
|
||||
gfxMatrix::Transform(const gfxPoint& point) const
|
||||
{
|
||||
gfxPoint ret = point;
|
||||
cairo_matrix_transform_point(CONST_CAIRO_MATRIX(this), &ret.x, &ret.y);
|
||||
return ret;
|
||||
}
|
||||
|
||||
gfxSize
|
||||
gfxMatrix::Transform(const gfxSize& size) const
|
||||
{
|
||||
gfxSize ret = size;
|
||||
cairo_matrix_transform_distance(CONST_CAIRO_MATRIX(this), &ret.width, &ret.height);
|
||||
return ret;
|
||||
}
|
||||
|
||||
gfxRect
|
||||
gfxMatrix::Transform(const gfxRect& rect) const
|
||||
{
|
||||
return gfxRect(Transform(rect.pos), Transform(rect.size));
|
||||
}
|
||||
|
||||
gfxRect
|
||||
gfxMatrix::TransformBounds(const gfxRect& rect) const
|
||||
{
|
||||
double x0 = rect.pos.x;
|
||||
double y0 = rect.pos.y;
|
||||
double x1 = rect.pos.x + rect.size.width;
|
||||
double y1 = rect.pos.y + rect.size.height;
|
||||
|
||||
cairo_matrix_transform_bounding_box(CONST_CAIRO_MATRIX(this), &x0, &y0, &x1, &y1, NULL);
|
||||
|
||||
return gfxRect(x0, y0, x1 - x0, y1 - y0);
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
/* -*- 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 Mozilla Corporation code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2007
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <stuart@mozilla.com>
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
#include "gfxTypes.h"
|
||||
#include "gfxPattern.h"
|
||||
#include "gfxASurface.h"
|
||||
|
||||
#include "cairo.h"
|
||||
|
||||
gfxPattern::gfxPattern(cairo_pattern_t *aPattern)
|
||||
{
|
||||
mPattern = cairo_pattern_reference(aPattern);
|
||||
}
|
||||
|
||||
gfxPattern::gfxPattern(gfxRGBA aColor)
|
||||
{
|
||||
mPattern = cairo_pattern_create_rgba(aColor.r, aColor.g, aColor.b, aColor.a);
|
||||
}
|
||||
|
||||
// from another surface
|
||||
gfxPattern::gfxPattern(gfxASurface *surface)
|
||||
{
|
||||
mPattern = cairo_pattern_create_for_surface(surface->CairoSurface());
|
||||
}
|
||||
|
||||
// linear
|
||||
gfxPattern::gfxPattern(gfxFloat x0, gfxFloat y0, gfxFloat x1, gfxFloat y1)
|
||||
{
|
||||
mPattern = cairo_pattern_create_linear(x0, y0, x1, y1);
|
||||
}
|
||||
|
||||
// radial
|
||||
gfxPattern::gfxPattern(gfxFloat cx0, gfxFloat cy0, gfxFloat radius0,
|
||||
gfxFloat cx1, gfxFloat cy1, gfxFloat radius1)
|
||||
{
|
||||
mPattern = cairo_pattern_create_radial(cx0, cy0, radius0,
|
||||
cx1, cy1, radius1);
|
||||
}
|
||||
|
||||
gfxPattern::~gfxPattern()
|
||||
{
|
||||
cairo_pattern_destroy(mPattern);
|
||||
}
|
||||
|
||||
cairo_pattern_t *
|
||||
gfxPattern::CairoPattern()
|
||||
{
|
||||
return mPattern;
|
||||
}
|
||||
|
||||
void
|
||||
gfxPattern::AddColorStop(gfxFloat offset, const gfxRGBA& c)
|
||||
{
|
||||
cairo_pattern_add_color_stop_rgba(mPattern, offset, c.r, c.g, c.b, c.a);
|
||||
}
|
||||
|
||||
void
|
||||
gfxPattern::SetMatrix(const gfxMatrix& matrix)
|
||||
{
|
||||
cairo_matrix_t mat = *reinterpret_cast<const cairo_matrix_t*>(&matrix);
|
||||
cairo_pattern_set_matrix(mPattern, &mat);
|
||||
}
|
||||
|
||||
gfxMatrix
|
||||
gfxPattern::CurrentMatrix() const
|
||||
{
|
||||
cairo_matrix_t mat;
|
||||
cairo_pattern_get_matrix(mPattern, &mat);
|
||||
return gfxMatrix(*reinterpret_cast<gfxMatrix*>(&mat));
|
||||
}
|
||||
|
||||
void
|
||||
gfxPattern::SetExtend(GraphicsExtend extend)
|
||||
{
|
||||
cairo_pattern_set_extend(mPattern, (cairo_extend_t)extend);
|
||||
}
|
||||
|
||||
gfxPattern::GraphicsExtend
|
||||
gfxPattern::Extend() const
|
||||
{
|
||||
return (GraphicsExtend)cairo_pattern_get_extend(mPattern);
|
||||
}
|
||||
|
||||
void
|
||||
gfxPattern::SetFilter(int filter)
|
||||
{
|
||||
cairo_pattern_set_filter(mPattern, (cairo_filter_t)filter);
|
||||
}
|
||||
|
||||
int
|
||||
gfxPattern::Filter() const
|
||||
{
|
||||
return (int)cairo_pattern_get_filter(mPattern);
|
||||
}
|
||||
|
||||
PRBool
|
||||
gfxPattern::GetSolidColor(gfxRGBA& aColor)
|
||||
{
|
||||
return cairo_pattern_get_rgba(mPattern,
|
||||
&aColor.r,
|
||||
&aColor.g,
|
||||
&aColor.b,
|
||||
&aColor.a) == CAIRO_STATUS_SUCCESS;
|
||||
}
|
|
@ -55,6 +55,11 @@
|
|||
|
||||
#include "gfxFontTest.h"
|
||||
|
||||
#include "cairo.h"
|
||||
#include "cairo-win32.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "nsUnicodeRange.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
|
||||
|
@ -166,10 +171,10 @@ gfxWindowsFont::CairoScaledFont()
|
|||
void
|
||||
gfxWindowsFont::UpdateCTM(const gfxMatrix& aMatrix)
|
||||
{
|
||||
if (aMatrix.yy() == mCTM.yy() &&
|
||||
aMatrix.xx() == mCTM.xx() &&
|
||||
aMatrix.xy() == mCTM.xy() &&
|
||||
aMatrix.yx() == mCTM.yx())
|
||||
if (aMatrix.yy == mCTM.yy &&
|
||||
aMatrix.xx == mCTM.xx &&
|
||||
aMatrix.xy == mCTM.xy &&
|
||||
aMatrix.yx == mCTM.yx)
|
||||
return;
|
||||
|
||||
Destroy();
|
||||
|
@ -302,7 +307,9 @@ gfxWindowsFont::MakeCairoScaledFont()
|
|||
cairo_matrix_init_scale(&sizeMatrix, mAdjustedSize, mAdjustedSize);
|
||||
|
||||
cairo_font_options_t *fontOptions = cairo_font_options_create();
|
||||
font = cairo_scaled_font_create(CairoFontFace(), &sizeMatrix, &mCTM.ToCairoMatrix(), fontOptions);
|
||||
font = cairo_scaled_font_create(CairoFontFace(), &sizeMatrix,
|
||||
reinterpret_cast<cairo_matrix_t*>(&mCTM),
|
||||
fontOptions);
|
||||
cairo_font_options_destroy(fontOptions);
|
||||
|
||||
return font;
|
||||
|
@ -395,7 +402,7 @@ gfxWindowsFont::FillLogFont(gfxFloat aSize, PRInt16 aWeight)
|
|||
{
|
||||
#define CLIP_TURNOFF_FONTASSOCIATION 0x40
|
||||
|
||||
const double yScale = mCTM.ToCairoMatrix().yy;
|
||||
const double yScale = mCTM.yy;
|
||||
|
||||
mLogFont.lfHeight = (LONG)-ROUND(aSize * yScale);
|
||||
|
||||
|
|
|
@ -36,12 +36,13 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "gfxWindowsSurface.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include "gfxContext.h"
|
||||
#include "gfxPlatform.h"
|
||||
|
||||
#include <cairo-win32.h>
|
||||
#include "cairo.h"
|
||||
#include "cairo-win32.h"
|
||||
|
||||
#include "nsString.h"
|
||||
|
||||
gfxWindowsSurface::gfxWindowsSurface(HWND wnd) :
|
||||
mOwnsDC(PR_TRUE), mWnd(wnd)
|
||||
|
|
|
@ -36,9 +36,12 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "gfxXlibSurface.h"
|
||||
|
||||
#include "cairo.h"
|
||||
#include "cairo-xlib.h"
|
||||
#include "cairo-xlib-xrender.h"
|
||||
|
||||
static cairo_user_data_key_t pixmap_free_key;
|
||||
|
||||
typedef struct {
|
||||
|
@ -48,7 +51,7 @@ typedef struct {
|
|||
|
||||
static void pixmap_free_func (void *);
|
||||
|
||||
gfxXlibSurface::gfxXlibSurface(Display* dpy, Drawable drawable, Visual* visual)
|
||||
gfxXlibSurface::gfxXlibSurface(Display *dpy, Drawable drawable, Visual *visual)
|
||||
: mPixmapTaken(PR_FALSE), mDisplay(dpy), mDrawable(drawable)
|
||||
{
|
||||
DoSizeQuery();
|
||||
|
@ -56,7 +59,7 @@ gfxXlibSurface::gfxXlibSurface(Display* dpy, Drawable drawable, Visual* visual)
|
|||
Init(surf);
|
||||
}
|
||||
|
||||
gfxXlibSurface::gfxXlibSurface(Display* dpy, Drawable drawable, Visual* visual,
|
||||
gfxXlibSurface::gfxXlibSurface(Display *dpy, Drawable drawable, Visual *visual,
|
||||
unsigned long width, unsigned long height)
|
||||
: mPixmapTaken(PR_FALSE), mDisplay(dpy), mDrawable(drawable), mWidth(width), mHeight(height)
|
||||
{
|
||||
|
@ -64,7 +67,7 @@ gfxXlibSurface::gfxXlibSurface(Display* dpy, Drawable drawable, Visual* visual,
|
|||
Init(surf);
|
||||
}
|
||||
|
||||
gfxXlibSurface::gfxXlibSurface(Display* dpy, Visual* visual, unsigned long width, unsigned long height)
|
||||
gfxXlibSurface::gfxXlibSurface(Display *dpy, Visual *visual, unsigned long width, unsigned long height)
|
||||
: mPixmapTaken(PR_FALSE), mDisplay(dpy), mWidth(width), mHeight(height)
|
||||
|
||||
{
|
||||
|
@ -79,7 +82,7 @@ gfxXlibSurface::gfxXlibSurface(Display* dpy, Visual* visual, unsigned long width
|
|||
TakePixmap();
|
||||
}
|
||||
|
||||
gfxXlibSurface::gfxXlibSurface(Display* dpy, Drawable drawable, XRenderPictFormat *format,
|
||||
gfxXlibSurface::gfxXlibSurface(Display *dpy, Drawable drawable, XRenderPictFormat *format,
|
||||
unsigned long width, unsigned long height)
|
||||
: mPixmapTaken(PR_FALSE), mDisplay(dpy), mDrawable(drawable),
|
||||
mWidth(width), mHeight(height)
|
||||
|
@ -90,7 +93,7 @@ gfxXlibSurface::gfxXlibSurface(Display* dpy, Drawable drawable, XRenderPictForma
|
|||
Init(surf);
|
||||
}
|
||||
|
||||
gfxXlibSurface::gfxXlibSurface(Display* dpy, XRenderPictFormat *format,
|
||||
gfxXlibSurface::gfxXlibSurface(Display *dpy, XRenderPictFormat *format,
|
||||
unsigned long width, unsigned long height)
|
||||
: mPixmapTaken(PR_FALSE), mDisplay(dpy), mWidth(width), mHeight(height)
|
||||
{
|
||||
|
@ -183,7 +186,6 @@ pixmap_free_func (void *data)
|
|||
{
|
||||
pixmap_free_struct *pfs = (pixmap_free_struct*) data;
|
||||
|
||||
//fprintf (stderr, "freeing pixmap %d\n", pfs->pixmap);
|
||||
XFreePixmap (pfs->dpy, pfs->pixmap);
|
||||
|
||||
delete pfs;
|
||||
|
|
|
@ -262,7 +262,7 @@ nsSVGForeignObjectFrame::PaintSVG(nsSVGRenderState *aContext,
|
|||
gfxContext *gfx = aContext->GetGfxContext();
|
||||
|
||||
gfx->Save();
|
||||
gfx->Multiply(gfxMatrix(matrix));
|
||||
gfx->Multiply(gfxMatrix(*reinterpret_cast<gfxMatrix*>(&matrix)));
|
||||
|
||||
nsresult rv = nsLayoutUtils::PaintFrame(ctx, kid, nsRegion(kid->GetRect()),
|
||||
NS_RGBA(0,0,0,0));
|
||||
|
|
|
@ -1433,7 +1433,7 @@ nsSVGGlyphFrame::GetGlobalTransform(gfxContext *aContext)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
aContext->Multiply(gfxMatrix(matrix));
|
||||
aContext->Multiply(gfxMatrix(*reinterpret_cast<gfxMatrix*>(&matrix)));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -653,7 +653,7 @@ nsSVGPathGeometryFrame::GeneratePath(gfxContext* aContext)
|
|||
return;
|
||||
}
|
||||
|
||||
aContext->Multiply(gfxMatrix(matrix));
|
||||
aContext->Multiply(gfxMatrix(*reinterpret_cast<gfxMatrix*>(&matrix)));
|
||||
|
||||
cairo_new_path(ctx);
|
||||
NS_STATIC_CAST(nsSVGPathGeometryElement*, mContent)->ConstructPath(ctx);
|
||||
|
|
|
@ -1021,7 +1021,7 @@ nsSVGUtils::CompositeSurfaceMatrix(gfxContext *aContext,
|
|||
|
||||
aContext->Save();
|
||||
|
||||
aContext->Multiply(gfxMatrix(matrix));
|
||||
aContext->Multiply(gfxMatrix(*reinterpret_cast<gfxMatrix*>(&matrix)));
|
||||
|
||||
aContext->SetSource(aSurface);
|
||||
aContext->Paint(aOpacity);
|
||||
|
@ -1039,7 +1039,7 @@ nsSVGUtils::SetClipRect(gfxContext *aContext,
|
|||
return;
|
||||
|
||||
gfxMatrix oldMatrix = aContext->CurrentMatrix();
|
||||
aContext->Multiply(gfxMatrix(matrix));
|
||||
aContext->Multiply(gfxMatrix(*reinterpret_cast<gfxMatrix*>(&matrix)));
|
||||
aContext->Clip(gfxRect(aX, aY, aWidth, aHeight));
|
||||
aContext->SetMatrix(oldMatrix);
|
||||
}
|
||||
|
|
|
@ -853,15 +853,12 @@ nsNativeThemeWin::DrawWidgetBackground(nsIRenderingContext* aContext,
|
|||
|
||||
SetGraphicsMode(hdc, GM_ADVANCED);
|
||||
XFORM xform;
|
||||
double dm[6];
|
||||
m.ToValues(&dm[0], &dm[1], &dm[2], &dm[3], &dm[4], &dm[5]);
|
||||
|
||||
xform.eM11 = (FLOAT) dm[0];
|
||||
xform.eM12 = (FLOAT) dm[1];
|
||||
xform.eM21 = (FLOAT) dm[2];
|
||||
xform.eM22 = (FLOAT) dm[3];
|
||||
xform.eDx = (FLOAT) dm[4];
|
||||
xform.eDy = (FLOAT) dm[5];
|
||||
xform.eM11 = (FLOAT) m.xx;
|
||||
xform.eM12 = (FLOAT) m.yx;
|
||||
xform.eM21 = (FLOAT) m.xy;
|
||||
xform.eM22 = (FLOAT) m.yy;
|
||||
xform.eDx = (FLOAT) m.x0;
|
||||
xform.eDy = (FLOAT) m.y0;
|
||||
SetWorldTransform (hdc, &xform);
|
||||
} else {
|
||||
gfxPoint pos(m.GetTranslation());
|
||||
|
@ -2035,14 +2032,12 @@ nsresult nsNativeThemeWin::ClassicDrawWidgetBackground(nsIRenderingContext* aCon
|
|||
|
||||
SetGraphicsMode(hdc, GM_ADVANCED);
|
||||
XFORM xform;
|
||||
double dm[6];
|
||||
m.ToValues(&dm[0], &dm[1], &dm[2], &dm[3], &dm[4], &dm[5]);
|
||||
xform.eM11 = (FLOAT) dm[0];
|
||||
xform.eM12 = (FLOAT) dm[1];
|
||||
xform.eM21 = (FLOAT) dm[2];
|
||||
xform.eM22 = (FLOAT) dm[3];
|
||||
xform.eDx = (FLOAT) dm[4];
|
||||
xform.eDy = (FLOAT) dm[5];
|
||||
xform.eM11 = (FLOAT) m.xx;
|
||||
xform.eM12 = (FLOAT) m.yx;
|
||||
xform.eM21 = (FLOAT) m.xy;
|
||||
xform.eM22 = (FLOAT) m.yy;
|
||||
xform.eDx = (FLOAT) m.x0;
|
||||
xform.eDy = (FLOAT) m.y0;
|
||||
SetWorldTransform (hdc, &xform);
|
||||
} else {
|
||||
gfxPoint pos(m.GetTranslation());
|
||||
|
|
Загрузка…
Ссылка в новой задаче