зеркало из https://github.com/mozilla/pjs.git
thebes API cleanup. bug 368910. r/sr=vlad
This commit is contained in:
Родитель
6572b7168d
Коммит
95e12e6c06
|
@ -799,7 +799,7 @@ nsCanvasRenderingContext2D::SetDimensions(PRInt32 width, PRInt32 height)
|
|||
mHeight = height;
|
||||
|
||||
#ifdef MOZ_CAIRO_GFX
|
||||
mThebesSurface = gfxPlatform::GetPlatform()->CreateOffscreenSurface(width, height, gfxASurface::ImageFormatARGB32);
|
||||
mThebesSurface = gfxPlatform::GetPlatform()->CreateOffscreenSurface(gfxIntSize(width, height), gfxASurface::ImageFormatARGB32);
|
||||
mThebesContext = new gfxContext(mThebesSurface);
|
||||
|
||||
mSurface = mThebesSurface->CairoSurface();
|
||||
|
|
|
@ -84,6 +84,7 @@ static nsSystemFontsBeOS *gSystemFonts = nsnull;
|
|||
#elif XP_MACOSX
|
||||
#include "nsSystemFontsMac.h"
|
||||
#include "gfxQuartzSurface.h"
|
||||
#include "gfxImageSurface.h"
|
||||
static nsSystemFontsMac *gSystemFonts = nsnull;
|
||||
#else
|
||||
#error Need to declare gSystemFonts!
|
||||
|
@ -524,9 +525,9 @@ nsThebesDeviceContext::BeginDocument(PRUnichar* aTitle,
|
|||
PRInt32 aEndPage)
|
||||
{
|
||||
static const PRUnichar kEmpty[] = { '\0' };
|
||||
nsRefPtr<gfxContext> thebes = new gfxContext(mPrintingSurface);
|
||||
thebes->BeginPrinting(nsDependentString(aTitle ? aTitle : kEmpty),
|
||||
nsDependentString(aPrintToFileName ? aPrintToFileName : kEmpty));
|
||||
|
||||
mPrintingSurface->BeginPrinting(nsDependentString(aTitle ? aTitle : kEmpty),
|
||||
nsDependentString(aPrintToFileName ? aPrintToFileName : kEmpty));
|
||||
if (mDeviceContextSpec)
|
||||
mDeviceContextSpec->BeginDocument(aTitle, aPrintToFileName, aStartPage, aEndPage);
|
||||
return NS_OK;
|
||||
|
@ -536,12 +537,8 @@ nsThebesDeviceContext::BeginDocument(PRUnichar* aTitle,
|
|||
NS_IMETHODIMP
|
||||
nsThebesDeviceContext::EndDocument(void)
|
||||
{
|
||||
if (mPrintingSurface) {
|
||||
nsRefPtr<gfxContext> thebes = new gfxContext(mPrintingSurface);
|
||||
thebes->EndPrinting();
|
||||
|
||||
mPrintingSurface->Finish();
|
||||
}
|
||||
mPrintingSurface->EndPrinting();
|
||||
mPrintingSurface->Finish();
|
||||
|
||||
if (mDeviceContextSpec)
|
||||
mDeviceContextSpec->EndDocument();
|
||||
|
@ -552,8 +549,7 @@ nsThebesDeviceContext::EndDocument(void)
|
|||
NS_IMETHODIMP
|
||||
nsThebesDeviceContext::AbortDocument(void)
|
||||
{
|
||||
nsRefPtr<gfxContext> thebes = new gfxContext(mPrintingSurface);
|
||||
thebes->AbortPrinting();
|
||||
mPrintingSurface->AbortPrinting();
|
||||
|
||||
if (mDeviceContextSpec)
|
||||
mDeviceContextSpec->EndDocument();
|
||||
|
@ -564,10 +560,7 @@ nsThebesDeviceContext::AbortDocument(void)
|
|||
NS_IMETHODIMP
|
||||
nsThebesDeviceContext::BeginPage(void)
|
||||
{
|
||||
if (mPrintingSurface) {
|
||||
nsRefPtr<gfxContext> thebes = new gfxContext(mPrintingSurface);
|
||||
thebes->BeginPage();
|
||||
}
|
||||
mPrintingSurface->BeginPage();
|
||||
|
||||
if (mDeviceContextSpec)
|
||||
mDeviceContextSpec->BeginPage();
|
||||
|
@ -577,8 +570,7 @@ nsThebesDeviceContext::BeginPage(void)
|
|||
NS_IMETHODIMP
|
||||
nsThebesDeviceContext::EndPage(void)
|
||||
{
|
||||
nsRefPtr<gfxContext> thebes = new gfxContext(mPrintingSurface);
|
||||
thebes->EndPage();
|
||||
mPrintingSurface->EndPage();
|
||||
|
||||
/* uhh. yeah, don't ask.
|
||||
* We need to release this before we call end page for mac.. */
|
||||
|
@ -755,3 +747,4 @@ nsThebesDeviceContext::CalcPrintingSize()
|
|||
mHeight = NSToIntRound(size.height);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ nsThebesDrawingSurface::Init(nsThebesDeviceContext *aDC, PRUint32 aWidth, PRUint
|
|||
// XXX Performance Problem
|
||||
// because we don't pass aDC->GetWidget() (a HWND on Windows) to this function,
|
||||
// we get DIBs instead of DDBs.
|
||||
mSurface = gfxPlatform::GetPlatform()->CreateOffscreenSurface(aWidth, aHeight, gfxImageSurface::ImageFormatARGB32);
|
||||
mSurface = gfxPlatform::GetPlatform()->CreateOffscreenSurface(gfxIntSize(aWidth, aHeight), gfxImageSurface::ImageFormatARGB32);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -98,15 +98,15 @@ nsThebesImage::Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth, nsMaskRequi
|
|||
mFormat = format;
|
||||
|
||||
#ifdef XP_WIN
|
||||
mWinSurface = new gfxWindowsSurface(mWidth, mHeight, format);
|
||||
mWinSurface = new gfxWindowsSurface(gfxIntSize(mWidth, mHeight), format);
|
||||
mImageSurface = mWinSurface->GetImageSurface();
|
||||
|
||||
if (!mImageSurface) {
|
||||
mWinSurface = nsnull;
|
||||
mImageSurface = new gfxImageSurface(format, mWidth, mHeight);
|
||||
mImageSurface = new gfxImageSurface(gfxIntSize(mWidth, mHeight), format);
|
||||
}
|
||||
#else
|
||||
mImageSurface = new gfxImageSurface(format, mWidth, mHeight);
|
||||
mImageSurface = new gfxImageSurface(gfxIntSize(mWidth, mHeight), format);
|
||||
#endif
|
||||
mStride = mImageSurface->Stride();
|
||||
|
||||
|
@ -228,7 +228,7 @@ nsThebesImage::Optimize(nsIDeviceContext* aContext)
|
|||
// will be to make sure we don't ever make a DDB that's bigger
|
||||
// than the primary screen size (rule of thumb).
|
||||
if (mWidth <= 1024 && mHeight <= 1024) {
|
||||
nsRefPtr<gfxWindowsSurface> wsurf = mWinSurface->OptimizeToDDB(nsnull, mFormat, mWidth, mHeight);
|
||||
nsRefPtr<gfxWindowsSurface> wsurf = mWinSurface->OptimizeToDDB(nsnull, gfxIntSize(mWidth, mHeight), mFormat);
|
||||
if (wsurf) {
|
||||
mOptSurface = wsurf;
|
||||
}
|
||||
|
@ -277,8 +277,8 @@ nsThebesImage::LockImagePixels(PRBool aMaskPixels)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
if ((mOptSurface || mSinglePixel) && !mImageSurface) {
|
||||
// Recover the pixels
|
||||
mImageSurface = new gfxImageSurface(gfxImageSurface::ImageFormatARGB32,
|
||||
mWidth, mHeight);
|
||||
mImageSurface = new gfxImageSurface(gfxIntSize(mWidth, mHeight),
|
||||
gfxImageSurface::ImageFormatARGB32);
|
||||
if (!mImageSurface)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
nsRefPtr<gfxContext> context = new gfxContext(mImageSurface);
|
||||
|
@ -466,8 +466,8 @@ nsThebesImage::ThebesDrawTile(gfxContext *thebesContext,
|
|||
if (!AllowedImageSize(width, height))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
surface = new gfxImageSurface(gfxASurface::ImageFormatARGB32,
|
||||
width, height);
|
||||
surface = new gfxImageSurface(gfxIntSize(width, height),
|
||||
gfxASurface::ImageFormatARGB32);
|
||||
tmpSurfaceGrip = surface;
|
||||
|
||||
nsRefPtr<gfxContext> tmpContext = new gfxContext(surface);
|
||||
|
|
|
@ -101,20 +101,9 @@ public:
|
|||
|
||||
gfxContentType GetContentType() const;
|
||||
|
||||
void SetDeviceOffset(gfxPoint offset);
|
||||
void SetDeviceOffset(const 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 Flush();
|
||||
void MarkDirty();
|
||||
void MarkDirty(const gfxRect& r);
|
||||
|
|
|
@ -137,7 +137,7 @@ public:
|
|||
/**
|
||||
* Moves the pen to a new point without drawing a line.
|
||||
*/
|
||||
void MoveTo(gfxPoint pt);
|
||||
void MoveTo(const gfxPoint& pt);
|
||||
|
||||
/**
|
||||
* Returns the current point in the current path.
|
||||
|
@ -149,12 +149,12 @@ public:
|
|||
*
|
||||
* @see MoveTo
|
||||
*/
|
||||
void LineTo(gfxPoint pt);
|
||||
void LineTo(const gfxPoint& pt);
|
||||
|
||||
/**
|
||||
* Draws a quadratic Bézier curve with control points pt1, pt2 and pt3.
|
||||
*/
|
||||
void CurveTo(gfxPoint pt1, gfxPoint pt2, gfxPoint pt3);
|
||||
void CurveTo(const gfxPoint& pt1, const gfxPoint& pt2, const gfxPoint& pt3);
|
||||
|
||||
/**
|
||||
* Draws a clockwise arc (i.e. a circle segment).
|
||||
|
@ -163,7 +163,7 @@ public:
|
|||
* @param angle1 Starting angle for the segment
|
||||
* @param angle2 Ending angle
|
||||
*/
|
||||
void Arc(gfxPoint center, gfxFloat radius,
|
||||
void Arc(const gfxPoint& center, gfxFloat radius,
|
||||
gfxFloat angle1, gfxFloat angle2);
|
||||
|
||||
/**
|
||||
|
@ -174,21 +174,21 @@ public:
|
|||
* @param angle2 Ending angle
|
||||
*/
|
||||
|
||||
void NegativeArc(gfxPoint center, gfxFloat radius,
|
||||
void NegativeArc(const gfxPoint& center, gfxFloat radius,
|
||||
gfxFloat angle1, gfxFloat angle2);
|
||||
|
||||
// path helpers
|
||||
/**
|
||||
* Draws a line from start to end.
|
||||
*/
|
||||
void Line(gfxPoint start, gfxPoint end); // XXX snapToPixels option?
|
||||
void Line(const gfxPoint& start, const gfxPoint& end); // XXX snapToPixels option?
|
||||
|
||||
/**
|
||||
* Draws the rectangle given by rect.
|
||||
* @param snapToPixels ?
|
||||
*/
|
||||
void Rectangle(gfxRect rect, PRBool snapToPixels = PR_FALSE);
|
||||
void Ellipse(gfxPoint center, gfxSize dimensions);
|
||||
void Rectangle(const gfxRect& rect, PRBool snapToPixels = PR_FALSE);
|
||||
void Ellipse(const gfxPoint& center, const gfxSize& dimensions);
|
||||
void Polygon(const gfxPoint *points, PRUint32 numPoints);
|
||||
|
||||
/**
|
||||
|
@ -199,7 +199,7 @@ public:
|
|||
* Adds a translation to the current matrix. This translation takes place
|
||||
* before the previously set transformations.
|
||||
*/
|
||||
void Translate(gfxPoint pt);
|
||||
void Translate(const gfxPoint& pt);
|
||||
|
||||
/**
|
||||
* Adds a scale to the current matrix. This scaling takes place before the
|
||||
|
@ -315,7 +315,7 @@ public:
|
|||
*
|
||||
* @param offset ?
|
||||
*/
|
||||
void SetSource(gfxASurface *surface, gfxPoint offset = gfxPoint(0.0, 0.0));
|
||||
void SetSource(gfxASurface *surface, const gfxPoint& offset = gfxPoint(0.0, 0.0));
|
||||
|
||||
/**
|
||||
* Uses a pattern for drawing.
|
||||
|
@ -349,7 +349,7 @@ public:
|
|||
* Shorthand for creating a pattern and calling the pattern-taking
|
||||
* variant of Mask.
|
||||
*/
|
||||
void Mask(gfxASurface *surface, gfxPoint offset = gfxPoint(0.0, 0.0));
|
||||
void Mask(gfxASurface *surface, const gfxPoint& offset = gfxPoint(0.0, 0.0));
|
||||
|
||||
/**
|
||||
** Shortcuts
|
||||
|
@ -359,7 +359,7 @@ public:
|
|||
* Creates a new path with a rectangle from 0,0 to size.w,size.h
|
||||
* and calls cairo_fill.
|
||||
*/
|
||||
void DrawSurface(gfxASurface *surface, gfxSize size);
|
||||
void DrawSurface(gfxASurface *surface, const gfxSize& size);
|
||||
|
||||
/**
|
||||
** Line Properties
|
||||
|
@ -489,7 +489,7 @@ public:
|
|||
* Helper functions that will create a rect path and call Clip().
|
||||
* Any current path will be destroyed by these functions!
|
||||
*/
|
||||
void Clip(gfxRect rect); // will clip to a rect
|
||||
void Clip(const gfxRect& rect); // will clip to a rect
|
||||
|
||||
/**
|
||||
* This will ensure that the surface actually has its clip set.
|
||||
|
@ -504,21 +504,11 @@ public:
|
|||
already_AddRefed<gfxPattern> PopGroup();
|
||||
void PopGroupToSource();
|
||||
|
||||
/**
|
||||
* Printing functions
|
||||
*/
|
||||
// XXX look and see if the arguments here should be a separate object
|
||||
void BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName);
|
||||
void EndPrinting();
|
||||
void AbortPrinting();
|
||||
void BeginPage();
|
||||
void EndPage();
|
||||
|
||||
/**
|
||||
** Hit Testing - check if given point is in the current path
|
||||
**/
|
||||
PRBool PointInFill(gfxPoint pt);
|
||||
PRBool PointInStroke(gfxPoint pt);
|
||||
PRBool PointInFill(const gfxPoint& pt);
|
||||
PRBool PointInStroke(const gfxPoint& pt);
|
||||
|
||||
/**
|
||||
** Extents - returns user space extent of current path
|
||||
|
|
|
@ -60,8 +60,7 @@ public:
|
|||
*
|
||||
* XXX why not unsigned long for the dimensions? And, why not gfxSize?
|
||||
*/
|
||||
gfxImageSurface(gfxImageFormat format, long width, long height);
|
||||
|
||||
gfxImageSurface(const gfxIntSize& size, gfxImageFormat format);
|
||||
gfxImageSurface(cairo_surface_t *csurf);
|
||||
|
||||
virtual ~gfxImageSurface();
|
||||
|
@ -69,7 +68,7 @@ public:
|
|||
// ImageSurface methods
|
||||
gfxImageFormat Format() const { return mFormat; }
|
||||
|
||||
gfxSize GetSize() const { return gfxSize(mWidth, mHeight); }
|
||||
const gfxIntSize& GetSize() const { return mSize; }
|
||||
|
||||
/**
|
||||
* Distance in bytes between the start of a line and the start of the
|
||||
|
@ -83,14 +82,12 @@ public:
|
|||
unsigned char* Data() { return mData; } // delete this data under us and die.
|
||||
|
||||
private:
|
||||
|
||||
long ComputeStride() const;
|
||||
|
||||
gfxIntSize mSize;
|
||||
PRBool mOwnsData;
|
||||
unsigned char *mData;
|
||||
gfxImageFormat mFormat;
|
||||
long mWidth;
|
||||
long mHeight;
|
||||
long mStride;
|
||||
};
|
||||
|
||||
|
|
|
@ -43,14 +43,20 @@
|
|||
class THEBES_API gfxPDFSurface : public gfxASurface {
|
||||
public:
|
||||
/* size is in points */
|
||||
gfxPDFSurface(const char *filename, gfxSize aSizeInPonits);
|
||||
gfxPDFSurface(const char *filename, const gfxSize& aSizeInPonits);
|
||||
virtual ~gfxPDFSurface();
|
||||
|
||||
nsresult BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName);
|
||||
nsresult EndPrinting();
|
||||
nsresult AbortPrinting();
|
||||
nsresult BeginPage();
|
||||
nsresult EndPage();
|
||||
|
||||
void SetDPI(double x, double y);
|
||||
void GetDPI(double *xDPI, double *yDPI);
|
||||
|
||||
// this is in points!
|
||||
gfxSize GetSize() const { return mSize; }
|
||||
const gfxSize& GetSize() const { return mSize; }
|
||||
|
||||
private:
|
||||
double mXDPI;
|
||||
|
|
|
@ -46,14 +46,20 @@ public:
|
|||
#ifdef UNTESTED_CODE
|
||||
gfxPSSurface(FILE *file, gfxSize aSizeInPonits); /* does not close the file */
|
||||
#endif
|
||||
gfxPSSurface(const char *filename, gfxSize aSizeInPonits);
|
||||
gfxPSSurface(const char *filename, const gfxSize& aSizeInPonits);
|
||||
virtual ~gfxPSSurface();
|
||||
|
||||
nsresult BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName);
|
||||
nsresult EndPrinting();
|
||||
nsresult AbortPrinting();
|
||||
nsresult BeginPage();
|
||||
nsresult EndPage();
|
||||
|
||||
void SetDPI(double x, double y);
|
||||
void GetDPI(double *xDPI, double *yDPI);
|
||||
|
||||
// this is in points!
|
||||
gfxSize GetSize() const { return mSize; }
|
||||
const gfxSize& GetSize() const { return mSize; }
|
||||
|
||||
private:
|
||||
double mXDPI;
|
||||
|
|
|
@ -53,7 +53,7 @@ class THEBES_API gfxPattern {
|
|||
|
||||
public:
|
||||
gfxPattern(cairo_pattern_t *aPattern);
|
||||
gfxPattern(gfxRGBA aColor);
|
||||
gfxPattern(const gfxRGBA& aColor);
|
||||
gfxPattern(gfxASurface *surface); // from another surface
|
||||
// linear
|
||||
gfxPattern(gfxFloat x0, gfxFloat y0, gfxFloat x1, gfxFloat y1); // linear
|
||||
|
|
|
@ -72,8 +72,7 @@ public:
|
|||
* create a surface that is optimized for rapid pixel
|
||||
* changing.
|
||||
*/
|
||||
virtual already_AddRefed<gfxASurface> CreateOffscreenSurface(PRUint32 width,
|
||||
PRUint32 height,
|
||||
virtual already_AddRefed<gfxASurface> CreateOffscreenSurface(const gfxIntSize& size,
|
||||
gfxASurface::gfxImageFormat imageFormat) = 0;
|
||||
|
||||
|
||||
|
|
|
@ -53,8 +53,7 @@ public:
|
|||
return (gfxPlatformGtk*) gfxPlatform::GetPlatform();
|
||||
}
|
||||
|
||||
already_AddRefed<gfxASurface> CreateOffscreenSurface(PRUint32 width,
|
||||
PRUint32 height,
|
||||
already_AddRefed<gfxASurface> CreateOffscreenSurface(const gfxIntSize& size,
|
||||
gfxASurface::gfxImageFormat imageFormat);
|
||||
|
||||
GdkDrawable *GetSurfaceGdkDrawable(gfxASurface *aSurf);
|
||||
|
|
|
@ -49,8 +49,7 @@ public:
|
|||
return (gfxPlatformMac*) gfxPlatform::GetPlatform();
|
||||
}
|
||||
|
||||
already_AddRefed<gfxASurface> CreateOffscreenSurface(PRUint32 width,
|
||||
PRUint32 height,
|
||||
already_AddRefed<gfxASurface> CreateOffscreenSurface(const gfxIntSize& size,
|
||||
gfxASurface::gfxImageFormat imageFormat);
|
||||
|
||||
nsresult ResolveFontName(const nsAString& aFontName,
|
||||
|
|
|
@ -42,12 +42,44 @@
|
|||
|
||||
#include "gfxTypes.h"
|
||||
|
||||
/*
|
||||
* gfxSize and gfxIntSize -- please keep their member functions in sync.
|
||||
* also note: gfxIntSize may be replaced by nsIntSize at some point...
|
||||
*/
|
||||
struct THEBES_API gfxIntSize {
|
||||
PRInt32 width, height;
|
||||
|
||||
gfxIntSize() {}
|
||||
gfxIntSize(PRInt32 _width, PRInt32 _height) : width(_width), height(_height) {}
|
||||
|
||||
void SizeTo(PRInt32 _width, PRInt32 _height) {width = _width; height = _height;}
|
||||
|
||||
int operator==(const gfxIntSize& s) const {
|
||||
return ((width == s.width) && (height == s.height));
|
||||
}
|
||||
int operator!=(const gfxIntSize& s) const {
|
||||
return ((width != s.width) || (height != s.height));
|
||||
}
|
||||
gfxIntSize operator+(const gfxIntSize& s) const {
|
||||
return gfxIntSize(width + s.width, height + s.height);
|
||||
}
|
||||
gfxIntSize operator-() const {
|
||||
return gfxIntSize(- width, - height);
|
||||
}
|
||||
gfxIntSize operator*(const PRInt32 v) const {
|
||||
return gfxIntSize(width * v, height * v);
|
||||
}
|
||||
gfxIntSize operator/(const PRInt32 v) const {
|
||||
return gfxIntSize(width / v, height / v);
|
||||
}
|
||||
};
|
||||
|
||||
struct THEBES_API gfxSize {
|
||||
gfxFloat width, height;
|
||||
|
||||
gfxSize() {}
|
||||
gfxSize(const gfxSize& s) : width(s.width), height(s.height) {}
|
||||
gfxSize(gfxFloat _width, gfxFloat _height) : width(_width), height(_height) {}
|
||||
gfxSize(const gfxIntSize& size) : width(size.width), height(size.height) {}
|
||||
|
||||
void SizeTo(gfxFloat _width, gfxFloat _height) {width = _width; height = _height;}
|
||||
|
||||
|
@ -71,6 +103,8 @@ struct THEBES_API gfxSize {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct THEBES_API gfxPoint {
|
||||
gfxFloat x, y;
|
||||
|
||||
|
|
|
@ -45,21 +45,19 @@
|
|||
|
||||
class THEBES_API gfxQuartzSurface : public gfxASurface {
|
||||
public:
|
||||
gfxQuartzSurface(gfxImageFormat format,
|
||||
int width, int height);
|
||||
gfxQuartzSurface(CGContextRef context,
|
||||
int width, int height,
|
||||
PRBool y_grows_down);
|
||||
gfxQuartzSurface(const gfxSize& size, gfxImageFormat format);
|
||||
gfxQuartzSurface(CGContextRef context, const gfxSize& size, PRBool y_grows_down);
|
||||
gfxQuartzSurface(cairo_surface_t *csurf);
|
||||
|
||||
virtual ~gfxQuartzSurface();
|
||||
|
||||
gfxSize GetSize() const { return gfxSize(mWidth, mHeight); }
|
||||
const gfxSize& GetSize() const { return mSize; }
|
||||
|
||||
CGContextRef GetCGContext() { return mCGContext; }
|
||||
|
||||
protected:
|
||||
CGContextRef mCGContext;
|
||||
unsigned long mWidth, mHeight;
|
||||
gfxSize mSize;
|
||||
};
|
||||
|
||||
#endif /* GFX_QUARTZSURFACE_H */
|
||||
|
|
|
@ -56,8 +56,7 @@ public:
|
|||
return (gfxWindowsPlatform*) gfxPlatform::GetPlatform();
|
||||
}
|
||||
|
||||
already_AddRefed<gfxASurface> CreateOffscreenSurface(PRUint32 width,
|
||||
PRUint32 height,
|
||||
already_AddRefed<gfxASurface> CreateOffscreenSurface(const gfxIntSize& size,
|
||||
gfxASurface::gfxImageFormat imageFormat);
|
||||
|
||||
nsresult GetFontList(const nsACString& aLangGroup,
|
||||
|
|
|
@ -49,12 +49,12 @@ public:
|
|||
gfxWindowsSurface(HDC dc, PRBool deleteDC = PR_FALSE);
|
||||
|
||||
// Create a DIB surface
|
||||
gfxWindowsSurface(unsigned long width, unsigned long height,
|
||||
gfxWindowsSurface(const gfxIntSize& size,
|
||||
gfxImageFormat imageFormat = ImageFormatRGB24);
|
||||
|
||||
// Create a DDB surface; dc may be NULL to use the screen DC
|
||||
gfxWindowsSurface(HDC dc,
|
||||
unsigned long width, unsigned long height,
|
||||
const gfxIntSize& size,
|
||||
gfxImageFormat imageFormat = ImageFormatRGB24);
|
||||
|
||||
gfxWindowsSurface(cairo_surface_t *csurf);
|
||||
|
@ -65,7 +65,9 @@ public:
|
|||
|
||||
already_AddRefed<gfxImageSurface> GetImageSurface();
|
||||
|
||||
already_AddRefed<gfxWindowsSurface> OptimizeToDDB(HDC dc, gfxImageFormat format, PRUint32 width, PRUint32 height);
|
||||
already_AddRefed<gfxWindowsSurface> OptimizeToDDB(HDC dc,
|
||||
const gfxIntSize& size,
|
||||
gfxImageFormat format);
|
||||
|
||||
nsresult BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName);
|
||||
nsresult EndPrinting();
|
||||
|
|
|
@ -52,27 +52,28 @@ public:
|
|||
|
||||
// create a surface for the specified dpy/drawable/visual,
|
||||
// with explicitly provided width/height.
|
||||
gfxXlibSurface(Display *dpy, Drawable drawable, Visual *visual, unsigned long width, unsigned long height);
|
||||
gfxXlibSurface(Display *dpy, Drawable drawable, Visual *visual, const gfxIntSize& size);
|
||||
|
||||
// create a new Pixmap on the display dpy, with
|
||||
// the root window as the parent and the default depth
|
||||
// for the default screen, and attach the given visual
|
||||
gfxXlibSurface(Display *dpy, Visual *visual, unsigned long width, unsigned long height);
|
||||
gfxXlibSurface(Display *dpy, Visual *visual, const gfxIntSize& size);
|
||||
|
||||
gfxXlibSurface(Display* dpy, Drawable drawable, XRenderPictFormat *format,
|
||||
unsigned long width, unsigned long height);
|
||||
const gfxIntSize& size);
|
||||
|
||||
gfxXlibSurface(Display* dpy, XRenderPictFormat *format,
|
||||
unsigned long width, unsigned long height);
|
||||
const gfxIntSize& size);
|
||||
|
||||
gfxXlibSurface(cairo_surface_t *csurf);
|
||||
|
||||
virtual ~gfxXlibSurface();
|
||||
|
||||
gfxSize GetSize() {
|
||||
if (mWidth == -1 || mHeight == -1)
|
||||
const gfxIntSize& GetSize() {
|
||||
if (mSize.width == -1 || mSize.height == -1)
|
||||
DoSizeQuery();
|
||||
return gfxSize(mWidth, mHeight);
|
||||
|
||||
return mSize;
|
||||
}
|
||||
|
||||
Display* XDisplay() { return mDisplay; }
|
||||
|
@ -93,8 +94,7 @@ protected:
|
|||
|
||||
void DoSizeQuery();
|
||||
|
||||
long mWidth;
|
||||
long mHeight;
|
||||
gfxIntSize mSize;
|
||||
};
|
||||
|
||||
#endif /* GFX_XLIBSURFACE_H */
|
||||
|
|
|
@ -181,7 +181,7 @@ gfxASurface::GetContentType() const
|
|||
}
|
||||
|
||||
void
|
||||
gfxASurface::SetDeviceOffset(gfxPoint offset)
|
||||
gfxASurface::SetDeviceOffset(const gfxPoint& offset)
|
||||
{
|
||||
cairo_surface_set_device_offset(mSurface,
|
||||
offset.x, offset.y);
|
||||
|
|
|
@ -135,39 +135,39 @@ gfxContext::Fill()
|
|||
}
|
||||
|
||||
void
|
||||
gfxContext::MoveTo(gfxPoint pt)
|
||||
gfxContext::MoveTo(const gfxPoint& pt)
|
||||
{
|
||||
cairo_move_to(mCairo, pt.x, pt.y);
|
||||
}
|
||||
|
||||
void
|
||||
gfxContext::LineTo(gfxPoint pt)
|
||||
gfxContext::LineTo(const gfxPoint& pt)
|
||||
{
|
||||
cairo_line_to(mCairo, pt.x, pt.y);
|
||||
}
|
||||
|
||||
void
|
||||
gfxContext::CurveTo(gfxPoint pt1, gfxPoint pt2, gfxPoint pt3)
|
||||
gfxContext::CurveTo(const gfxPoint& pt1, const gfxPoint& pt2, const gfxPoint& pt3)
|
||||
{
|
||||
cairo_curve_to(mCairo, pt1.x, pt1.y, pt2.x, pt2.y, pt3.x, pt3.y);
|
||||
}
|
||||
|
||||
void
|
||||
gfxContext::Arc(gfxPoint center, gfxFloat radius,
|
||||
gfxFloat angle1, gfxFloat angle2)
|
||||
gfxContext::Arc(const gfxPoint& center, gfxFloat radius,
|
||||
gfxFloat angle1, gfxFloat angle2)
|
||||
{
|
||||
cairo_arc(mCairo, center.x, center.y, radius, angle1, angle2);
|
||||
}
|
||||
|
||||
void
|
||||
gfxContext::NegativeArc(gfxPoint center, gfxFloat radius,
|
||||
gfxFloat angle1, gfxFloat angle2)
|
||||
gfxContext::NegativeArc(const gfxPoint& center, gfxFloat radius,
|
||||
gfxFloat angle1, gfxFloat angle2)
|
||||
{
|
||||
cairo_arc_negative(mCairo, center.x, center.y, radius, angle1, angle2);
|
||||
}
|
||||
|
||||
void
|
||||
gfxContext::Line(gfxPoint start, gfxPoint end)
|
||||
gfxContext::Line(const gfxPoint& start, const gfxPoint& end)
|
||||
{
|
||||
MoveTo(start);
|
||||
LineTo(end);
|
||||
|
@ -178,7 +178,7 @@ gfxContext::Line(gfxPoint start, gfxPoint end)
|
|||
// For odd-width stroked rectangles, we need to offset x/y by
|
||||
// 0.5...
|
||||
void
|
||||
gfxContext::Rectangle(gfxRect rect, PRBool snapToPixels)
|
||||
gfxContext::Rectangle(const gfxRect& rect, PRBool snapToPixels)
|
||||
{
|
||||
if (snapToPixels) {
|
||||
gfxRect snappedRect(rect);
|
||||
|
@ -198,7 +198,7 @@ gfxContext::Rectangle(gfxRect rect, PRBool snapToPixels)
|
|||
}
|
||||
|
||||
void
|
||||
gfxContext::Ellipse(gfxPoint center, gfxSize dimensions)
|
||||
gfxContext::Ellipse(const gfxPoint& center, const gfxSize& dimensions)
|
||||
{
|
||||
// circle?
|
||||
if (dimensions.width == dimensions.height) {
|
||||
|
@ -246,7 +246,7 @@ gfxContext::Polygon(const gfxPoint *points, PRUint32 numPoints)
|
|||
}
|
||||
|
||||
void
|
||||
gfxContext::DrawSurface(gfxASurface *surface, gfxSize size)
|
||||
gfxContext::DrawSurface(gfxASurface *surface, const gfxSize& size)
|
||||
{
|
||||
cairo_save(mCairo);
|
||||
cairo_set_source_surface(mCairo, surface->CairoSurface(), 0, 0);
|
||||
|
@ -261,7 +261,7 @@ gfxContext::DrawSurface(gfxASurface *surface, gfxSize size)
|
|||
|
||||
// transform stuff
|
||||
void
|
||||
gfxContext::Translate(gfxPoint pt)
|
||||
gfxContext::Translate(const gfxPoint& pt)
|
||||
{
|
||||
cairo_translate(mCairo, pt.x, pt.y);
|
||||
}
|
||||
|
@ -560,7 +560,7 @@ gfxContext::CurrentFillRule() const
|
|||
|
||||
// clipping
|
||||
void
|
||||
gfxContext::Clip(gfxRect rect)
|
||||
gfxContext::Clip(const gfxRect& rect)
|
||||
{
|
||||
cairo_new_path(mCairo);
|
||||
cairo_rectangle(mCairo, rect.pos.x, rect.pos.y, rect.size.width, rect.size.height);
|
||||
|
@ -606,7 +606,7 @@ gfxContext::GetColor(gfxRGBA& c)
|
|||
}
|
||||
|
||||
void
|
||||
gfxContext::SetSource(gfxASurface *surface, gfxPoint offset)
|
||||
gfxContext::SetSource(gfxASurface *surface, const gfxPoint& offset)
|
||||
{
|
||||
cairo_set_source_surface(mCairo, surface->CairoSurface(), offset.x, offset.y);
|
||||
}
|
||||
|
@ -643,7 +643,7 @@ gfxContext::Mask(gfxPattern *pattern)
|
|||
}
|
||||
|
||||
void
|
||||
gfxContext::Mask(gfxASurface *surface, gfxPoint offset)
|
||||
gfxContext::Mask(gfxASurface *surface, const gfxPoint& offset)
|
||||
{
|
||||
cairo_mask_surface(mCairo, surface->CairoSurface(), offset.x, offset.y);
|
||||
}
|
||||
|
@ -677,45 +677,14 @@ gfxContext::PopGroupToSource()
|
|||
cairo_pop_group_to_source(mCairo);
|
||||
}
|
||||
|
||||
void
|
||||
gfxContext::BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName)
|
||||
{
|
||||
mSurface->BeginPrinting(aTitle, aPrintToFileName);
|
||||
}
|
||||
|
||||
void
|
||||
gfxContext::EndPrinting()
|
||||
{
|
||||
mSurface->EndPrinting();
|
||||
}
|
||||
|
||||
void
|
||||
gfxContext::AbortPrinting()
|
||||
{
|
||||
mSurface->AbortPrinting();
|
||||
}
|
||||
|
||||
void
|
||||
gfxContext::BeginPage()
|
||||
{
|
||||
mSurface->BeginPage();
|
||||
}
|
||||
|
||||
void
|
||||
gfxContext::EndPage()
|
||||
{
|
||||
if (NS_FAILED(mSurface->EndPage()))
|
||||
cairo_show_page(mCairo);
|
||||
}
|
||||
|
||||
PRBool
|
||||
gfxContext::PointInFill(gfxPoint pt)
|
||||
gfxContext::PointInFill(const gfxPoint& pt)
|
||||
{
|
||||
return cairo_in_fill(mCairo, pt.x, pt.y);
|
||||
}
|
||||
|
||||
PRBool
|
||||
gfxContext::PointInStroke(gfxPoint pt)
|
||||
gfxContext::PointInStroke(const gfxPoint& pt)
|
||||
{
|
||||
return cairo_in_stroke(mCairo, pt.x, pt.y);
|
||||
}
|
||||
|
|
|
@ -39,18 +39,18 @@
|
|||
|
||||
#include "cairo.h"
|
||||
|
||||
gfxImageSurface::gfxImageSurface(gfxImageFormat format, long width, long height) :
|
||||
mFormat(format), mWidth(width), mHeight(height)
|
||||
gfxImageSurface::gfxImageSurface(const gfxIntSize& size, gfxImageFormat format) :
|
||||
mSize(size), mFormat(format)
|
||||
{
|
||||
long stride = ComputeStride();
|
||||
mData = new unsigned char[height * stride];
|
||||
mData = new unsigned char[mSize.height * stride];
|
||||
mOwnsData = PR_TRUE;
|
||||
|
||||
cairo_surface_t *surface =
|
||||
cairo_image_surface_create_for_data((unsigned char*)mData,
|
||||
(cairo_format_t)format,
|
||||
width,
|
||||
height,
|
||||
mSize.width,
|
||||
mSize.height,
|
||||
stride);
|
||||
mStride = stride;
|
||||
|
||||
|
@ -59,8 +59,8 @@ gfxImageSurface::gfxImageSurface(gfxImageFormat format, long width, long height)
|
|||
|
||||
gfxImageSurface::gfxImageSurface(cairo_surface_t *csurf)
|
||||
{
|
||||
mWidth = cairo_image_surface_get_width(csurf);
|
||||
mHeight = cairo_image_surface_get_height(csurf);
|
||||
mSize.width = cairo_image_surface_get_width(csurf);
|
||||
mSize.height = cairo_image_surface_get_height(csurf);
|
||||
mData = cairo_image_surface_get_data(csurf);
|
||||
mFormat = (gfxImageFormat) cairo_image_surface_get_format(csurf);
|
||||
mOwnsData = PR_FALSE;
|
||||
|
@ -81,16 +81,16 @@ gfxImageSurface::ComputeStride() const
|
|||
long stride;
|
||||
|
||||
if (mFormat == ImageFormatARGB32)
|
||||
stride = mWidth * 4;
|
||||
stride = mSize.width * 4;
|
||||
else if (mFormat == ImageFormatRGB24)
|
||||
stride = mWidth * 4;
|
||||
stride = mSize.width * 4;
|
||||
else if (mFormat == ImageFormatA8)
|
||||
stride = mWidth;
|
||||
stride = mSize.width;
|
||||
else if (mFormat == ImageFormatA1) {
|
||||
stride = (mWidth + 7) / 8;
|
||||
stride = (mSize.width + 7) / 8;
|
||||
} else {
|
||||
NS_WARNING("Unknown format specified to gfxImageSurface!");
|
||||
stride = mWidth * 4;
|
||||
stride = mSize.width * 4;
|
||||
}
|
||||
|
||||
stride = ((stride + 3) / 4) * 4;
|
||||
|
|
|
@ -37,9 +37,10 @@
|
|||
|
||||
#include "gfxPDFSurface.h"
|
||||
|
||||
#include <cairo-pdf.h>
|
||||
#include "cairo.h"
|
||||
#include "cairo-pdf.h"
|
||||
|
||||
gfxPDFSurface::gfxPDFSurface(const char *filename, gfxSize aSizeInPoints)
|
||||
gfxPDFSurface::gfxPDFSurface(const char *filename, const gfxSize& aSizeInPoints)
|
||||
: mXDPI(-1), mYDPI(-1), mSize(aSizeInPoints)
|
||||
{
|
||||
Init(cairo_pdf_surface_create(filename, mSize.width, mSize.height));
|
||||
|
@ -49,6 +50,39 @@ gfxPDFSurface::~gfxPDFSurface()
|
|||
{
|
||||
}
|
||||
|
||||
nsresult
|
||||
gfxPDFSurface::BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
gfxPDFSurface::EndPrinting()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
gfxPDFSurface::AbortPrinting()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
gfxPDFSurface::BeginPage()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
gfxPDFSurface::EndPage()
|
||||
{
|
||||
cairo_t *cx = cairo_create(CairoSurface());
|
||||
cairo_show_page(cx);
|
||||
cairo_destroy(cx);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
gfxPDFSurface::SetDPI(double xDPI, double yDPI)
|
||||
{
|
||||
|
|
|
@ -49,7 +49,7 @@ write_func(void *closure,
|
|||
}
|
||||
#endif
|
||||
|
||||
gfxPSSurface::gfxPSSurface(const char *filename, gfxSize aSizeInPoints)
|
||||
gfxPSSurface::gfxPSSurface(const char *filename, const gfxSize& aSizeInPoints)
|
||||
: mXDPI(-1), mYDPI(-1), mSize(aSizeInPoints)
|
||||
{
|
||||
Init(cairo_ps_surface_create(filename, mSize.width, mSize.height));
|
||||
|
@ -67,6 +67,39 @@ gfxPSSurface::~gfxPSSurface()
|
|||
{
|
||||
}
|
||||
|
||||
nsresult
|
||||
gfxPSSurface::BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
gfxPSSurface::EndPrinting()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
gfxPSSurface::AbortPrinting()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
gfxPSSurface::BeginPage()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
gfxPSSurface::EndPage()
|
||||
{
|
||||
cairo_t *cx = cairo_create(CairoSurface());
|
||||
cairo_show_page(cx);
|
||||
cairo_destroy(cx);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
gfxPSSurface::SetDPI(double xDPI, double yDPI)
|
||||
{
|
||||
|
@ -81,3 +114,4 @@ gfxPSSurface::GetDPI(double *xDPI, double *yDPI)
|
|||
*xDPI = mXDPI;
|
||||
*yDPI = mYDPI;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ gfxPattern::gfxPattern(cairo_pattern_t *aPattern)
|
|||
mPattern = cairo_pattern_reference(aPattern);
|
||||
}
|
||||
|
||||
gfxPattern::gfxPattern(gfxRGBA aColor)
|
||||
gfxPattern::gfxPattern(const gfxRGBA& aColor)
|
||||
{
|
||||
mPattern = cairo_pattern_create_rgba(aColor.r, aColor.g, aColor.b, aColor.a);
|
||||
}
|
||||
|
|
|
@ -127,12 +127,12 @@ gfxPlatform::DoesARGBImageDataHaveAlpha(PRUint8* data,
|
|||
}
|
||||
|
||||
already_AddRefed<gfxASurface>
|
||||
gfxPlatform::OptimizeImage(gfxImageSurface* aSurface)
|
||||
gfxPlatform::OptimizeImage(gfxImageSurface *aSurface)
|
||||
{
|
||||
nsRefPtr<gfxASurface> optSurface;
|
||||
const gfxIntSize& surfaceSize = aSurface->GetSize();
|
||||
|
||||
gfxASurface::gfxImageFormat realFormat = aSurface->Format();
|
||||
|
||||
gfxSize surfaceSize = aSurface->GetSize();
|
||||
if (realFormat == gfxASurface::ImageFormatARGB32) {
|
||||
// this might not really need alpha; figure that out
|
||||
if (!DoesARGBImageDataHaveAlpha(aSurface->Data(),
|
||||
|
@ -144,9 +144,7 @@ gfxPlatform::OptimizeImage(gfxImageSurface* aSurface)
|
|||
}
|
||||
}
|
||||
|
||||
optSurface = CreateOffscreenSurface(surfaceSize.width,
|
||||
surfaceSize.height,
|
||||
realFormat);
|
||||
nsRefPtr<gfxASurface> optSurface = CreateOffscreenSurface(surfaceSize, realFormat);
|
||||
|
||||
if (!optSurface)
|
||||
return nsnull;
|
||||
|
|
|
@ -87,8 +87,7 @@ gfxPlatformGtk::gfxPlatformGtk()
|
|||
}
|
||||
|
||||
already_AddRefed<gfxASurface>
|
||||
gfxPlatformGtk::CreateOffscreenSurface(PRUint32 width,
|
||||
PRUint32 height,
|
||||
gfxPlatformGtk::CreateOffscreenSurface(const gfxIntSize& size,
|
||||
gfxASurface::gfxImageFormat imageFormat)
|
||||
{
|
||||
gfxASurface *newSurface = nsnull;
|
||||
|
@ -132,7 +131,7 @@ gfxPlatformGtk::CreateOffscreenSurface(PRUint32 width,
|
|||
if (imageFormat == gfxASurface::ImageFormatRGB24) {
|
||||
vis = gdk_rgb_get_visual();
|
||||
if (vis->type == GDK_VISUAL_TRUE_COLOR)
|
||||
pixmap = gdk_pixmap_new(nsnull, width, height, vis->depth);
|
||||
pixmap = gdk_pixmap_new(nsnull, size.width, size.height, vis->depth);
|
||||
}
|
||||
|
||||
if (pixmap) {
|
||||
|
@ -140,21 +139,20 @@ gfxPlatformGtk::CreateOffscreenSurface(PRUint32 width,
|
|||
newSurface = new gfxXlibSurface(display,
|
||||
GDK_PIXMAP_XID(GDK_DRAWABLE(pixmap)),
|
||||
GDK_VISUAL_XVISUAL(vis),
|
||||
width,
|
||||
height);
|
||||
size);
|
||||
} else {
|
||||
// we couldn't create a Gdk Pixmap; fall back to image surface for the data
|
||||
newSurface = new gfxImageSurface(imageFormat, width, height);
|
||||
newSurface = new gfxImageSurface(imageFormat, size.width, height);
|
||||
}
|
||||
} else {
|
||||
pixmap = gdk_pixmap_new(nsnull, width, height,
|
||||
pixmap = gdk_pixmap_new(nsnull, size.width, size.height,
|
||||
xrenderFormat->depth);
|
||||
gdk_drawable_set_colormap(GDK_DRAWABLE(pixmap), nsnull);
|
||||
|
||||
newSurface = new gfxXlibSurface(display,
|
||||
GDK_PIXMAP_XID(GDK_DRAWABLE(pixmap)),
|
||||
xrenderFormat,
|
||||
width, height);
|
||||
size);
|
||||
}
|
||||
|
||||
if (pixmap && newSurface) {
|
||||
|
@ -176,16 +174,16 @@ gfxPlatformGtk::CreateOffscreenSurface(PRUint32 width,
|
|||
glitz_glx_create_pbuffer_drawable(display,
|
||||
DefaultScreen(display),
|
||||
gdformat,
|
||||
width,
|
||||
height);
|
||||
size.width,
|
||||
size.height);
|
||||
glitz_format_t *gformat =
|
||||
glitz_find_standard_format(gdraw, (glitz_format_name_t)glitzf);
|
||||
|
||||
glitz_surface_t *gsurf =
|
||||
glitz_surface_create(gdraw,
|
||||
gformat,
|
||||
width,
|
||||
height,
|
||||
size.width,
|
||||
size.height,
|
||||
0,
|
||||
NULL);
|
||||
|
||||
|
|
|
@ -57,14 +57,13 @@ gfxPlatformMac::gfxPlatformMac()
|
|||
}
|
||||
|
||||
already_AddRefed<gfxASurface>
|
||||
gfxPlatformMac::CreateOffscreenSurface(PRUint32 width,
|
||||
PRUint32 height,
|
||||
gfxPlatformMac::CreateOffscreenSurface(const gfxIntSize& size,
|
||||
gfxASurface::gfxImageFormat imageFormat)
|
||||
{
|
||||
gfxASurface *newSurface = nsnull;
|
||||
|
||||
if (!UseGlitz()) {
|
||||
newSurface = new gfxQuartzSurface(imageFormat, width, height);
|
||||
newSurface = new gfxQuartzSurface(size, imageFormat);
|
||||
} else {
|
||||
#ifdef MOZ_ENABLE_GLITZ
|
||||
int bpp, glitzf;
|
||||
|
@ -166,4 +165,4 @@ gfxPlatformMac::UpdateFontList()
|
|||
{
|
||||
gfxQuartzFontCache::SharedFontCache()->UpdateFontList();
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,12 +39,11 @@
|
|||
|
||||
#include "cairo-nquartz.h"
|
||||
|
||||
gfxQuartzSurface::gfxQuartzSurface(gfxImageFormat format,
|
||||
int width, int height)
|
||||
: mWidth(width), mHeight(height)
|
||||
gfxQuartzSurface::gfxQuartzSurface(const gfxSize& size, gfxImageFormat format)
|
||||
: mSize(size)
|
||||
{
|
||||
cairo_surface_t *surf = cairo_nquartz_surface_create
|
||||
((cairo_format_t) format, width, height);
|
||||
((cairo_format_t) format, floor(size.width), floor(size.height));
|
||||
|
||||
mCGContext = cairo_nquartz_surface_get_cg_context (surf);
|
||||
|
||||
|
@ -54,23 +53,24 @@ gfxQuartzSurface::gfxQuartzSurface(gfxImageFormat format,
|
|||
}
|
||||
|
||||
gfxQuartzSurface::gfxQuartzSurface(CGContextRef context,
|
||||
int width, int height,
|
||||
const gfxSize& size,
|
||||
PRBool y_grows_down)
|
||||
: mCGContext(context), mWidth(width), mHeight(height)
|
||||
: mCGContext(context), mSize(size)
|
||||
{
|
||||
cairo_surface_t *surf = cairo_nquartz_surface_create_for_cg_context
|
||||
(context, width, height, y_grows_down);
|
||||
cairo_surface_t *surf =
|
||||
cairo_nquartz_surface_create_for_cg_context(context,
|
||||
floor(size.width),
|
||||
floor(size.height),
|
||||
y_grows_down);
|
||||
|
||||
CGContextRetain(mCGContext);
|
||||
|
||||
Init(surf);
|
||||
}
|
||||
|
||||
gfxQuartzSurface::gfxQuartzSurface(cairo_surface_t *csurf)
|
||||
gfxQuartzSurface::gfxQuartzSurface(cairo_surface_t *csurf) :
|
||||
mSize(-1.0, -1.0)
|
||||
{
|
||||
mWidth = 0;
|
||||
mHeight = 0;
|
||||
|
||||
mCGContext = cairo_nquartz_surface_get_cg_context (csurf);
|
||||
CGContextRetain (mCGContext);
|
||||
|
||||
|
|
|
@ -66,11 +66,10 @@ gfxWindowsPlatform::~gfxWindowsPlatform()
|
|||
}
|
||||
|
||||
already_AddRefed<gfxASurface>
|
||||
gfxWindowsPlatform::CreateOffscreenSurface(PRUint32 width,
|
||||
PRUint32 height,
|
||||
gfxWindowsPlatform::CreateOffscreenSurface(const gfxIntSize& size,
|
||||
gfxASurface::gfxImageFormat imageFormat)
|
||||
{
|
||||
gfxASurface *surf = new gfxWindowsSurface(width, height, imageFormat);
|
||||
gfxASurface *surf = new gfxWindowsSurface(size, imageFormat);
|
||||
NS_IF_ADDREF(surf);
|
||||
return surf;
|
||||
}
|
||||
|
|
|
@ -57,11 +57,11 @@ gfxWindowsSurface::gfxWindowsSurface(HDC dc, PRBool deleteDC) :
|
|||
Init(cairo_win32_surface_create(mDC));
|
||||
}
|
||||
|
||||
gfxWindowsSurface::gfxWindowsSurface(unsigned long width, unsigned long height, gfxImageFormat imageFormat) :
|
||||
gfxWindowsSurface::gfxWindowsSurface(const gfxIntSize& size, gfxImageFormat imageFormat) :
|
||||
mOwnsDC(PR_FALSE), mWnd(nsnull)
|
||||
{
|
||||
cairo_surface_t *surf = cairo_win32_surface_create_with_dib((cairo_format_t)imageFormat,
|
||||
width, height);
|
||||
size.width, size.height);
|
||||
if (!surf || cairo_surface_status(surf)) {
|
||||
fprintf (stderr, "++++++++++++ gfxWindowsSurface: DIB surface creation failed!\n");
|
||||
}
|
||||
|
@ -71,11 +71,11 @@ gfxWindowsSurface::gfxWindowsSurface(unsigned long width, unsigned long height,
|
|||
mDC = cairo_win32_surface_get_dc(CairoSurface());
|
||||
}
|
||||
|
||||
gfxWindowsSurface::gfxWindowsSurface(HDC dc, unsigned long width, unsigned long height, gfxImageFormat imageFormat) :
|
||||
gfxWindowsSurface::gfxWindowsSurface(HDC dc, const gfxIntSize& size, gfxImageFormat imageFormat) :
|
||||
mOwnsDC(PR_FALSE), mWnd(nsnull)
|
||||
{
|
||||
cairo_surface_t *surf = cairo_win32_surface_create_with_ddb(dc, (cairo_format_t)imageFormat,
|
||||
width, height);
|
||||
size.width, size.height);
|
||||
if (!surf || cairo_surface_status(surf)) {
|
||||
fprintf (stderr, "++++++++++++ gfxWindowsSurface: DDB surface creation failed!\n");
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ gfxWindowsSurface::GetImageSurface()
|
|||
}
|
||||
|
||||
already_AddRefed<gfxWindowsSurface>
|
||||
gfxWindowsSurface::OptimizeToDDB(HDC dc, gfxImageFormat format, PRUint32 width, PRUint32 height)
|
||||
gfxWindowsSurface::OptimizeToDDB(HDC dc, const gfxIntSize& size, gfxImageFormat format)
|
||||
{
|
||||
gfxImageFormat realFormat = format;
|
||||
if (realFormat == ImageFormatARGB32) {
|
||||
|
@ -135,7 +135,7 @@ gfxWindowsSurface::OptimizeToDDB(HDC dc, gfxImageFormat format, PRUint32 width,
|
|||
if (realFormat != ImageFormatRGB24)
|
||||
return nsnull;
|
||||
|
||||
nsRefPtr<gfxWindowsSurface> wsurf = new gfxWindowsSurface (dc, width, height, realFormat);
|
||||
nsRefPtr<gfxWindowsSurface> wsurf = new gfxWindowsSurface(dc, size, realFormat);
|
||||
|
||||
nsRefPtr<gfxContext> tmpCtx(new gfxContext(wsurf));
|
||||
tmpCtx->SetOperator(gfxContext::OPERATOR_SOURCE);
|
||||
|
|
|
@ -55,62 +55,59 @@ gfxXlibSurface::gfxXlibSurface(Display *dpy, Drawable drawable, Visual *visual)
|
|||
: mPixmapTaken(PR_FALSE), mDisplay(dpy), mDrawable(drawable)
|
||||
{
|
||||
DoSizeQuery();
|
||||
cairo_surface_t *surf = cairo_xlib_surface_create(dpy, drawable, visual, mWidth, mHeight);
|
||||
cairo_surface_t *surf = cairo_xlib_surface_create(dpy, drawable, visual, mSize.width, mSize.height);
|
||||
Init(surf);
|
||||
}
|
||||
|
||||
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)
|
||||
gfxXlibSurface::gfxXlibSurface(Display *dpy, Drawable drawable, Visual *visual, const gfxIntSize& size)
|
||||
: mPixmapTaken(PR_FALSE), mDisplay(dpy), mDrawable(drawable), mSize(size)
|
||||
{
|
||||
cairo_surface_t *surf = cairo_xlib_surface_create(dpy, drawable, visual, width, height);
|
||||
cairo_surface_t *surf = cairo_xlib_surface_create(dpy, drawable, visual, mSize.width, mSize.height);
|
||||
Init(surf);
|
||||
}
|
||||
|
||||
gfxXlibSurface::gfxXlibSurface(Display *dpy, Visual *visual, unsigned long width, unsigned long height)
|
||||
: mPixmapTaken(PR_FALSE), mDisplay(dpy), mWidth(width), mHeight(height)
|
||||
gfxXlibSurface::gfxXlibSurface(Display *dpy, Visual *visual, const gfxIntSize& size)
|
||||
: mPixmapTaken(PR_FALSE), mDisplay(dpy), mSize(size)
|
||||
|
||||
{
|
||||
mDrawable = (Drawable)XCreatePixmap(dpy,
|
||||
RootWindow(dpy, DefaultScreen(dpy)),
|
||||
width, height,
|
||||
mSize.width, mSize.height,
|
||||
DefaultDepth(dpy, DefaultScreen(dpy)));
|
||||
|
||||
cairo_surface_t *surf = cairo_xlib_surface_create(dpy, mDrawable, visual, width, height);
|
||||
cairo_surface_t *surf = cairo_xlib_surface_create(dpy, mDrawable, visual, mSize.width, mSize.height);
|
||||
|
||||
Init(surf);
|
||||
TakePixmap();
|
||||
}
|
||||
|
||||
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)
|
||||
const gfxIntSize& size)
|
||||
: mPixmapTaken(PR_FALSE), mDisplay(dpy), mDrawable(drawable), mSize(size)
|
||||
{
|
||||
cairo_surface_t *surf = cairo_xlib_surface_create_with_xrender_format (dpy, drawable,
|
||||
ScreenOfDisplay(dpy,DefaultScreen(dpy)),
|
||||
format, width, height);
|
||||
cairo_surface_t *surf = cairo_xlib_surface_create_with_xrender_format(dpy, drawable,
|
||||
ScreenOfDisplay(dpy,DefaultScreen(dpy)),
|
||||
format, mSize.width, mSize.height);
|
||||
Init(surf);
|
||||
}
|
||||
|
||||
gfxXlibSurface::gfxXlibSurface(Display *dpy, XRenderPictFormat *format,
|
||||
unsigned long width, unsigned long height)
|
||||
: mPixmapTaken(PR_FALSE), mDisplay(dpy), mWidth(width), mHeight(height)
|
||||
gfxXlibSurface::gfxXlibSurface(Display *dpy, XRenderPictFormat *format, const gfxIntSize& size)
|
||||
: mPixmapTaken(PR_FALSE), mDisplay(dpy), mSize(size)
|
||||
{
|
||||
mDrawable = (Drawable)XCreatePixmap(dpy,
|
||||
RootWindow(dpy, DefaultScreen(dpy)),
|
||||
width, height,
|
||||
mSize.width, mSize.height,
|
||||
format->depth);
|
||||
|
||||
cairo_surface_t *surf = cairo_xlib_surface_create_with_xrender_format (dpy, mDrawable,
|
||||
ScreenOfDisplay(dpy,DefaultScreen(dpy)),
|
||||
format, width, height);
|
||||
cairo_surface_t *surf = cairo_xlib_surface_create_with_xrender_format(dpy, mDrawable,
|
||||
ScreenOfDisplay(dpy,DefaultScreen(dpy)),
|
||||
format, mSize.width, mSize.height);
|
||||
Init(surf);
|
||||
TakePixmap();
|
||||
}
|
||||
|
||||
gfxXlibSurface::gfxXlibSurface(cairo_surface_t *csurf)
|
||||
: mPixmapTaken(PR_FALSE), mWidth(-1), mHeight(-1)
|
||||
: mPixmapTaken(PR_FALSE), mSize(-1.0, -1.0)
|
||||
{
|
||||
mDrawable = cairo_xlib_surface_get_drawable(csurf);
|
||||
mDisplay = cairo_xlib_surface_get_display(csurf);
|
||||
|
@ -136,8 +133,8 @@ gfxXlibSurface::DoSizeQuery()
|
|||
&width, &height,
|
||||
&bwidth_ignore, &depth);
|
||||
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
mSize.width = width;
|
||||
mSize.height = height;
|
||||
}
|
||||
|
||||
XRenderPictFormat*
|
||||
|
|
|
@ -281,8 +281,7 @@ nsSVGFilterFrame::FilterPaint(nsSVGRenderState *aContext,
|
|||
|
||||
// paint the target geometry
|
||||
nsRefPtr<gfxImageSurface> tmpSurface =
|
||||
new gfxImageSurface(gfxASurface::ImageFormatARGB32,
|
||||
filterResX, filterResY);
|
||||
new gfxImageSurface(gfxIntSize(filterResX, filterResY), gfxASurface::ImageFormatARGB32);
|
||||
if (!tmpSurface) {
|
||||
FilterFailCleanup(aContext, aTarget);
|
||||
return NS_OK;
|
||||
|
|
|
@ -290,8 +290,7 @@ nsSVGPatternFrame::PaintPattern(cairo_surface_t** surface,
|
|||
#endif
|
||||
|
||||
nsRefPtr<gfxImageSurface> tmpSurface =
|
||||
new gfxImageSurface(gfxASurface::ImageFormatARGB32,
|
||||
(int)surfaceWidth, (int)surfaceHeight);
|
||||
new gfxImageSurface(gfxIntSize(surfaceWidth, surfaceHeight), gfxASurface::ImageFormatARGB32);
|
||||
if (!tmpSurface)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
|
|
@ -1622,7 +1622,7 @@ nsWindow::OnExposeEvent(GtkWidget *aWidget, GdkEventExpose *aEvent)
|
|||
new gfxXlibSurface(display, drawable, XVisual,
|
||||
boundsRect.width, boundsRect.height);
|
||||
if (bufferPixmapSurface) {
|
||||
bufferPixmapSurface->SetDeviceOffset(-boundsRect.x, -boundsRect.y);
|
||||
bufferPixmapSurface->SetDeviceOffset(gfxPoint(-boundsRect.x, -boundsRect.y));
|
||||
nsCOMPtr<nsIRenderingContext> newRC;
|
||||
nsresult rv = GetDeviceContext()->
|
||||
CreateRenderingContextInstance(*getter_AddRefs(newRC));
|
||||
|
@ -1669,9 +1669,9 @@ nsWindow::OnExposeEvent(GtkWidget *aWidget, GdkEventExpose *aEvent)
|
|||
ctx->Paint();
|
||||
|
||||
nsRefPtr<gfxImageSurface> img =
|
||||
new gfxImageSurface(gfxImageSurface::ImageFormatA8,
|
||||
boundsRect.width, boundsRect.height);
|
||||
img->SetDeviceOffset(-boundsRect.x, -boundsRect.y);
|
||||
new gfxImageSurface(gfxIntSize(boundsRect.width, boundsRect.height),
|
||||
gfxImageSurface::ImageFormatA8);
|
||||
img->SetDeviceOffset(gfxPoint(-boundsRect.x, -boundsRect.y));
|
||||
|
||||
nsRefPtr<gfxContext> imgCtx = new gfxContext(img);
|
||||
imgCtx->SetPattern(pattern);
|
||||
|
|
Загрузка…
Ссылка в новой задаче