diff --git a/gfx/cairo/cairo/src/cairo-qpainter-surface.cpp b/gfx/cairo/cairo/src/cairo-qpainter-surface.cpp index c8362440e4d..fd070009e39 100644 --- a/gfx/cairo/cairo/src/cairo-qpainter-surface.cpp +++ b/gfx/cairo/cairo/src/cairo-qpainter-surface.cpp @@ -1451,6 +1451,28 @@ cairo_qpainter_surface_get_qpainter (cairo_surface_t *surface) return qs->p; } +QImage * +cairo_qpainter_surface_get_qimage (cairo_surface_t *surface) +{ + cairo_qpainter_surface_t *qs = (cairo_qpainter_surface_t*) surface; + + if (surface->type != CAIRO_SURFACE_TYPE_QPAINTER) + return NULL; + + return qs->image; +} + +cairo_surface_t * +cairo_qpainter_surface_get_image (cairo_surface_t *surface) +{ + cairo_qpainter_surface_t *qs = (cairo_qpainter_surface_t*) surface; + + if (surface->type != CAIRO_SURFACE_TYPE_QPAINTER) + return NULL; + + return (cairo_surface_t*) qs->image_equiv; +} + /* * TODO: * diff --git a/gfx/cairo/cairo/src/cairo-qpainter.h b/gfx/cairo/cairo/src/cairo-qpainter.h index 03755e0f968..e334dc8ca5c 100644 --- a/gfx/cairo/cairo/src/cairo-qpainter.h +++ b/gfx/cairo/cairo/src/cairo-qpainter.h @@ -42,6 +42,7 @@ #if CAIRO_HAS_QPAINTER_SURFACE class QPainter; +class QImage; CAIRO_BEGIN_DECLS @@ -60,6 +61,12 @@ cairo_qpainter_surface_create_with_qpixmap (int width, cairo_public QPainter * cairo_qpainter_surface_get_qpainter (cairo_surface_t *surface); +cairo_public cairo_surface_t * +cairo_qpainter_surface_get_image (cairo_surface_t *surface); + +cairo_public QImage * +cairo_qpainter_surface_get_qimage (cairo_surface_t *surface); + CAIRO_END_DECLS #else /* CAIRO_HAS_QPAINTER_SURFACE */ diff --git a/gfx/thebes/public/gfxQPainterSurface.h b/gfx/thebes/public/gfxQPainterSurface.h index af566a518f9..b8f6c0a1cb9 100644 --- a/gfx/thebes/public/gfxQPainterSurface.h +++ b/gfx/thebes/public/gfxQPainterSurface.h @@ -42,6 +42,7 @@ #include "gfxImageSurface.h" class QPainter; +class QImage; class THEBES_API gfxQPainterSurface : public gfxASurface { public: @@ -55,6 +56,9 @@ public: QPainter *GetQPainter() { return mPainter; } + QImage *GetQImage(); + already_AddRefed GetImageSurface(); + protected: QPainter *mPainter; }; diff --git a/gfx/thebes/public/gfxQtPlatform.h b/gfx/thebes/public/gfxQtPlatform.h index 1265e94c730..98ee017a53b 100644 --- a/gfx/thebes/public/gfxQtPlatform.h +++ b/gfx/thebes/public/gfxQtPlatform.h @@ -60,6 +60,9 @@ public: already_AddRefed CreateOffscreenSurface(const gfxIntSize& size, gfxASurface::gfxImageFormat imageFormat); + already_AddRefed OptimizeImage(gfxImageSurface *aSurface, + gfxASurface::gfxImageFormat format); + nsresult GetFontList(const nsACString& aLangGroup, const nsACString& aGenericFamily, nsStringArray& aListOfFonts); diff --git a/gfx/thebes/src/gfxQPainterSurface.cpp b/gfx/thebes/src/gfxQPainterSurface.cpp index 2d53ef1962e..7b5cfe5f4c6 100644 --- a/gfx/thebes/src/gfxQPainterSurface.cpp +++ b/gfx/thebes/src/gfxQPainterSurface.cpp @@ -36,6 +36,7 @@ * ***** END LICENSE BLOCK ***** */ #include "gfxQPainterSurface.h" +#include "gfxImageSurface.h" #include "cairo-qpainter.h" @@ -77,3 +78,29 @@ gfxQPainterSurface::gfxQPainterSurface(cairo_surface_t *csurf) gfxQPainterSurface::~gfxQPainterSurface() { } + +QImage * +gfxQPainterSurface::GetQImage() +{ + if (!mSurfaceValid) + return nsnull; + + return cairo_qpainter_surface_get_qimage(CairoSurface()); +} + +already_AddRefed +gfxQPainterSurface::GetImageSurface() +{ + if (!mSurfaceValid) + return nsnull; + + cairo_surface_t *isurf = cairo_qpainter_surface_get_image(CairoSurface()); + if (!isurf) + return nsnull; + + if (cairo_surface_get_type(isurf) == CAIRO_SURFACE_TYPE_IMAGE) + return nsnull; + + nsRefPtr asurf = new gfxImageSurface(isurf); + return asurf.forget(); +} diff --git a/gfx/thebes/src/gfxQtPlatform.cpp b/gfx/thebes/src/gfxQtPlatform.cpp index aa2f218ce7b..458861c5c31 100644 --- a/gfx/thebes/src/gfxQtPlatform.cpp +++ b/gfx/thebes/src/gfxQtPlatform.cpp @@ -126,6 +126,31 @@ gfxQtPlatform::CreateOffscreenSurface(const gfxIntSize& size, return newSurface.forget(); } +already_AddRefed +gfxQtPlatform::OptimizeImage(gfxImageSurface *aSurface, + gfxASurface::gfxImageFormat format) +{ + NS_ADDREF(aSurface); + return aSurface; + +#if 0 + const gfxIntSize& surfaceSize = aSurface->GetSize(); + + nsRefPtr optSurface = CreateOffscreenSurface(surfaceSize, format); + if (!optSurface || optSurface->CairoStatus() != 0) + return nsnull; + + gfxContext tmpCtx(optSurface); + tmpCtx.SetOperator(gfxContext::OPERATOR_SOURCE); + tmpCtx.SetSource(aSurface); + tmpCtx.Paint(); + + gfxASurface *ret = optSurface; + NS_ADDREF(ret); + return ret; +#endif +} + nsresult gfxQtPlatform::GetFontList(const nsACString& aLangGroup, const nsACString& aGenericFamily,