2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2012-05-21 04:12:37 -07:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef GFX_ASURFACE_H
|
|
|
|
#define GFX_ASURFACE_H
|
|
|
|
|
2012-07-05 11:07:37 -07:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
|
|
#define MOZ_DUMP_IMAGES
|
|
|
|
#endif
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "gfxTypes.h"
|
|
|
|
#include "gfxRect.h"
|
2010-04-01 11:05:40 -07:00
|
|
|
#include "nsAutoPtr.h"
|
2012-01-31 18:18:30 -08:00
|
|
|
#include "nsAutoRef.h"
|
|
|
|
#include "nsThreadUtils.h"
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
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);
|
|
|
|
|
2009-06-25 13:30:56 -07:00
|
|
|
class gfxImageSurface;
|
2011-03-09 09:27:37 -08:00
|
|
|
struct nsIntPoint;
|
|
|
|
struct nsIntRect;
|
2009-06-25 13:30:56 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* 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:
|
2012-01-06 06:44:25 -08:00
|
|
|
#ifdef MOZILLA_INTERNAL_API
|
2007-03-22 10:30:00 -07:00
|
|
|
nsrefcnt AddRef(void);
|
|
|
|
nsrefcnt Release(void);
|
|
|
|
|
2012-01-06 06:44:25 -08:00
|
|
|
// These functions exist so that browsercomps can refcount a gfxASurface
|
2012-07-27 07:03:25 -07:00
|
|
|
virtual nsrefcnt AddRefExternal(void)
|
2012-01-06 06:44:25 -08:00
|
|
|
{
|
|
|
|
return AddRef();
|
|
|
|
}
|
2012-07-27 07:03:25 -07:00
|
|
|
virtual nsrefcnt ReleaseExternal(void)
|
2012-01-06 06:44:25 -08:00
|
|
|
{
|
|
|
|
return Release();
|
|
|
|
}
|
|
|
|
#else
|
2012-07-27 07:03:25 -07:00
|
|
|
virtual nsrefcnt AddRef(void);
|
|
|
|
virtual nsrefcnt Release(void);
|
2012-01-06 06:44:25 -08:00
|
|
|
#endif
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* The format for an image surface. For all formats with alpha data, 0
|
|
|
|
* means transparent, 1 or 255 means fully opaque.
|
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
ImageFormatARGB32, ///< ARGB data in native endianness, using premultiplied alpha
|
|
|
|
ImageFormatRGB24, ///< xRGB data in native endianness
|
|
|
|
ImageFormatA8, ///< Only an alpha channel
|
|
|
|
ImageFormatA1, ///< Packed transparency information (one byte refers to 8 pixels)
|
2010-06-11 02:33:22 -07:00
|
|
|
ImageFormatRGB16_565, ///< RGB_565 data in native endianness
|
2007-03-22 10:30:00 -07:00
|
|
|
ImageFormatUnknown
|
|
|
|
} gfxImageFormat;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
SurfaceTypeImage,
|
|
|
|
SurfaceTypePDF,
|
|
|
|
SurfaceTypePS,
|
|
|
|
SurfaceTypeXlib,
|
|
|
|
SurfaceTypeXcb,
|
2011-12-18 14:54:50 -08:00
|
|
|
SurfaceTypeGlitz, // unused, but needed for cairo parity
|
2007-03-22 10:30:00 -07:00
|
|
|
SurfaceTypeQuartz,
|
|
|
|
SurfaceTypeWin32,
|
|
|
|
SurfaceTypeBeOS,
|
2011-12-18 14:54:50 -08:00
|
|
|
SurfaceTypeDirectFB, // unused, but needed for cairo parity
|
2007-03-22 10:30:00 -07:00
|
|
|
SurfaceTypeSVG,
|
2007-09-24 15:50:44 -07:00
|
|
|
SurfaceTypeOS2,
|
2008-02-05 22:48:47 -08:00
|
|
|
SurfaceTypeWin32Printing,
|
2008-04-19 06:34:30 -07:00
|
|
|
SurfaceTypeQuartzImage,
|
2010-01-16 09:04:52 -08:00
|
|
|
SurfaceTypeScript,
|
2009-04-22 17:48:30 -07:00
|
|
|
SurfaceTypeQPainter,
|
2010-09-07 20:27:34 -07:00
|
|
|
SurfaceTypeRecording,
|
|
|
|
SurfaceTypeVG,
|
|
|
|
SurfaceTypeGL,
|
|
|
|
SurfaceTypeDRM,
|
|
|
|
SurfaceTypeTee,
|
|
|
|
SurfaceTypeXML,
|
|
|
|
SurfaceTypeSkia,
|
2011-03-10 11:52:15 -08:00
|
|
|
SurfaceTypeSubsurface,
|
2010-09-07 20:27:34 -07:00
|
|
|
SurfaceTypeD2D,
|
2010-05-21 21:10:14 -07:00
|
|
|
SurfaceTypeMax
|
2007-03-22 10:30:00 -07:00
|
|
|
} gfxSurfaceType;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
CONTENT_COLOR = 0x1000,
|
|
|
|
CONTENT_ALPHA = 0x2000,
|
2012-07-12 05:51:57 -07:00
|
|
|
CONTENT_COLOR_ALPHA = 0x3000,
|
|
|
|
CONTENT_SENTINEL = 0xffff
|
2007-03-22 10:30:00 -07:00
|
|
|
} gfxContentType;
|
|
|
|
|
2010-06-18 02:21:15 -07:00
|
|
|
/** Wrap the given cairo surface and return a gfxASurface for it.
|
|
|
|
* This adds a reference to csurf (owned by the returned gfxASurface).
|
|
|
|
*/
|
2007-03-22 10:30:00 -07:00
|
|
|
static already_AddRefed<gfxASurface> Wrap(cairo_surface_t *csurf);
|
|
|
|
|
|
|
|
/*** this DOES NOT addref the surface */
|
2007-05-10 12:58:09 -07:00
|
|
|
cairo_surface_t *CairoSurface() {
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_ASSERTION(mSurface != nullptr, "gfxASurface::CairoSurface called with mSurface == nullptr!");
|
2007-05-10 12:58:09 -07:00
|
|
|
return mSurface;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
gfxSurfaceType GetType() const;
|
|
|
|
|
|
|
|
gfxContentType GetContentType() const;
|
|
|
|
|
|
|
|
void SetDeviceOffset(const gfxPoint& offset);
|
|
|
|
gfxPoint GetDeviceOffset() const;
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool GetRotateForLandscape() { return false; }
|
2011-07-14 10:02:20 -07:00
|
|
|
|
2010-08-08 19:19:17 -07:00
|
|
|
void Flush() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
void MarkDirty();
|
|
|
|
void MarkDirty(const gfxRect& r);
|
|
|
|
|
|
|
|
/* Printing backend functions */
|
2007-09-25 13:46:08 -07:00
|
|
|
virtual nsresult BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName);
|
|
|
|
virtual nsresult EndPrinting();
|
|
|
|
virtual nsresult AbortPrinting();
|
|
|
|
virtual nsresult BeginPage();
|
|
|
|
virtual nsresult EndPage();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void SetData(const cairo_user_data_key_t *key,
|
|
|
|
void *user_data,
|
|
|
|
thebes_destroy_func_t destroy);
|
|
|
|
void *GetData(const cairo_user_data_key_t *key);
|
|
|
|
|
|
|
|
virtual void Finish();
|
|
|
|
|
2010-05-31 16:37:44 -07:00
|
|
|
/**
|
|
|
|
* Create an offscreen surface that can be efficiently copied into
|
|
|
|
* this surface (at least if tiling is not involved).
|
|
|
|
* Returns null on error.
|
|
|
|
*/
|
|
|
|
virtual already_AddRefed<gfxASurface> CreateSimilarSurface(gfxContentType aType,
|
|
|
|
const gfxIntSize& aSize);
|
2010-11-11 12:31:22 -08:00
|
|
|
|
|
|
|
/**
|
2012-07-30 07:20:58 -07:00
|
|
|
* Returns an image surface for this surface, or nullptr if not supported.
|
2010-11-11 12:31:22 -08:00
|
|
|
* This will not copy image data, just wraps an image surface around
|
|
|
|
* pixel data already available in memory.
|
|
|
|
*/
|
|
|
|
virtual already_AddRefed<gfxImageSurface> GetAsImageSurface()
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-11-11 12:31:22 -08:00
|
|
|
}
|
|
|
|
|
2007-05-10 13:50:16 -07:00
|
|
|
int CairoStatus();
|
2007-05-10 12:58:09 -07:00
|
|
|
|
|
|
|
/* Make sure that the given dimensions don't overflow a 32-bit signed int
|
|
|
|
* using 4 bytes per pixel; optionally, make sure that either dimension
|
|
|
|
* doesn't exceed the given limit.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
static bool CheckSurfaceSize(const gfxIntSize& sz, int32_t limit = 0);
|
2007-05-10 12:58:09 -07:00
|
|
|
|
2011-03-15 15:01:00 -07:00
|
|
|
/* Provide a stride value that will respect all alignment requirements of
|
|
|
|
* the accelerated image-rendering code.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
static int32_t FormatStrideForWidth(gfxImageFormat format, int32_t width);
|
2011-03-15 15:01:00 -07:00
|
|
|
|
2007-11-29 12:06:56 -08:00
|
|
|
/* Return the default set of context flags for this surface; these are
|
|
|
|
* hints to the context about any special rendering considerations. See
|
|
|
|
* gfxContext::SetFlag for documentation.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual int32_t GetDefaultContextFlags() const { return 0; }
|
2007-11-29 12:06:56 -08:00
|
|
|
|
2008-04-28 18:15:30 -07:00
|
|
|
static gfxContentType ContentFromFormat(gfxImageFormat format);
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
void SetSubpixelAntialiasingEnabled(bool aEnabled);
|
|
|
|
bool GetSubpixelAntialiasingEnabled();
|
2011-01-02 17:48:08 -08:00
|
|
|
|
2010-05-21 21:10:14 -07:00
|
|
|
/**
|
|
|
|
* Record number of bytes for given surface type. Use positive bytes
|
|
|
|
* for allocations and negative bytes for deallocations.
|
|
|
|
*/
|
|
|
|
static void RecordMemoryUsedForSurfaceType(gfxASurface::gfxSurfaceType aType,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aBytes);
|
2010-05-21 21:10:14 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Same as above, but use current surface type as returned by GetType().
|
|
|
|
* The bytes will be accumulated until RecordMemoryFreed is called,
|
|
|
|
* in which case the value that was recorded for this surface will
|
|
|
|
* be freed.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
void RecordMemoryUsed(int32_t aBytes);
|
2010-05-21 21:10:14 -07:00
|
|
|
void RecordMemoryFreed();
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual int32_t KnownMemoryUsed() { return mBytesRecorded; }
|
2011-07-18 06:20:27 -07:00
|
|
|
|
2012-11-26 16:29:56 -08:00
|
|
|
virtual size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
|
|
|
|
virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
|
|
|
|
|
2011-07-18 06:20:27 -07:00
|
|
|
/**
|
|
|
|
* The memory used by this surface (as reported by KnownMemoryUsed()) can
|
|
|
|
* either live in this process's heap, in this process but outside the
|
|
|
|
* heap, or in another process altogether.
|
|
|
|
*/
|
|
|
|
enum MemoryLocation {
|
|
|
|
MEMORY_IN_PROCESS_HEAP,
|
|
|
|
MEMORY_IN_PROCESS_NONHEAP,
|
|
|
|
MEMORY_OUT_OF_PROCESS
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Where does this surface's memory live? By default, we say it's in this
|
|
|
|
* process's heap.
|
|
|
|
*/
|
|
|
|
virtual MemoryLocation GetMemoryLocation() const;
|
2010-05-21 21:10:14 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
static int32_t BytePerPixelFromFormat(gfxImageFormat format);
|
2010-06-11 02:33:22 -07:00
|
|
|
|
2010-09-07 17:36:57 -07:00
|
|
|
virtual const gfxIntSize GetSize() const { return gfxIntSize(-1, -1); }
|
|
|
|
|
2012-07-05 11:07:37 -07:00
|
|
|
#ifdef MOZ_DUMP_IMAGES
|
2011-10-25 20:19:13 -07:00
|
|
|
/**
|
|
|
|
* Debug functions to encode the current image as a PNG and export it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Writes a binary PNG file.
|
|
|
|
*/
|
|
|
|
void WriteAsPNG(const char* aFile);
|
|
|
|
|
2012-03-01 00:26:09 -08:00
|
|
|
/**
|
|
|
|
* Write as a PNG encoded Data URL to a file.
|
|
|
|
*/
|
|
|
|
void DumpAsDataURL(FILE* aOutput = stdout);
|
|
|
|
|
2011-10-25 20:19:13 -07:00
|
|
|
/**
|
|
|
|
* Write as a PNG encoded Data URL to stdout.
|
|
|
|
*/
|
2012-03-01 00:26:09 -08:00
|
|
|
void PrintAsDataURL();
|
2011-03-24 15:04:46 -07:00
|
|
|
|
2011-10-25 20:19:13 -07:00
|
|
|
/**
|
|
|
|
* Copy a PNG encoded Data URL to the clipboard.
|
|
|
|
*/
|
|
|
|
void CopyAsDataURL();
|
|
|
|
|
|
|
|
void WriteAsPNG_internal(FILE* aFile, bool aBinary);
|
|
|
|
#endif
|
|
|
|
|
2011-01-02 17:48:08 -08:00
|
|
|
void SetOpaqueRect(const gfxRect& aRect) {
|
|
|
|
if (aRect.IsEmpty()) {
|
2012-07-30 07:20:58 -07:00
|
|
|
mOpaqueRect = nullptr;
|
2011-01-02 17:48:08 -08:00
|
|
|
} else if (mOpaqueRect) {
|
|
|
|
*mOpaqueRect = aRect;
|
|
|
|
} else {
|
|
|
|
mOpaqueRect = new gfxRect(aRect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const gfxRect& GetOpaqueRect() {
|
|
|
|
if (mOpaqueRect)
|
|
|
|
return *mOpaqueRect;
|
|
|
|
static const gfxRect empty(0, 0, 0, 0);
|
|
|
|
return empty;
|
|
|
|
}
|
|
|
|
|
2011-03-09 09:27:37 -08:00
|
|
|
/**
|
|
|
|
* Move the pixels in |aSourceRect| to |aDestTopLeft|. Like with
|
|
|
|
* memmove(), |aSourceRect| and the rectangle defined by
|
|
|
|
* |aDestTopLeft| are allowed to overlap, and the effect is
|
|
|
|
* equivalent to copying |aSourceRect| to a scratch surface and
|
|
|
|
* then back to |aDestTopLeft|.
|
|
|
|
*
|
|
|
|
* |aSourceRect| and the destination rectangle defined by
|
|
|
|
* |aDestTopLeft| are clipped to this surface's bounds.
|
|
|
|
*/
|
|
|
|
virtual void MovePixels(const nsIntRect& aSourceRect,
|
|
|
|
const nsIntPoint& aDestTopLeft);
|
|
|
|
|
2011-01-02 17:48:09 -08:00
|
|
|
/**
|
|
|
|
* Mark the surface as being allowed/not allowed to be used as a source.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
void SetAllowUseAsSource(bool aAllow) { mAllowUseAsSource = aAllow; }
|
|
|
|
bool GetAllowUseAsSource() { return mAllowUseAsSource; }
|
2011-01-02 17:48:09 -08:00
|
|
|
|
2012-12-12 14:47:28 -08:00
|
|
|
static uint8_t BytesPerPixel(gfxImageFormat aImageFormat);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
2012-07-30 07:20:58 -07:00
|
|
|
gfxASurface() : mSurface(nullptr), mFloatingRefs(0), mBytesRecorded(0),
|
2011-10-17 07:59:28 -07:00
|
|
|
mSurfaceValid(false), mAllowUseAsSource(true)
|
2010-06-18 02:21:15 -07:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(gfxASurface);
|
|
|
|
}
|
2007-05-10 12:58:09 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
static gfxASurface* GetSurfaceWrapper(cairo_surface_t *csurf);
|
|
|
|
static void SetSurfaceWrapper(cairo_surface_t *csurf, gfxASurface *asurf);
|
|
|
|
|
2011-05-07 18:19:11 -07:00
|
|
|
/**
|
|
|
|
* An implementation of MovePixels that assumes the backend can
|
|
|
|
* internally handle this operation and doesn't allocate any
|
|
|
|
* temporary surfaces.
|
|
|
|
*/
|
|
|
|
void FastMovePixels(const nsIntRect& aSourceRect,
|
|
|
|
const nsIntPoint& aDestTopLeft);
|
|
|
|
|
2011-01-04 08:40:54 -08:00
|
|
|
// NB: Init() *must* be called from within subclass's
|
|
|
|
// constructors. It's unsafe to call it after the ctor finishes;
|
|
|
|
// leaks and use-after-frees are possible.
|
2011-09-28 23:19:26 -07:00
|
|
|
void Init(cairo_surface_t *surface, bool existingSurface = false);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-18 02:21:15 -07:00
|
|
|
virtual ~gfxASurface()
|
|
|
|
{
|
2010-05-21 21:10:14 -07:00
|
|
|
RecordMemoryFreed();
|
2010-06-18 02:21:15 -07:00
|
|
|
|
|
|
|
MOZ_COUNT_DTOR(gfxASurface);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-05-21 21:10:14 -07:00
|
|
|
|
2010-05-31 16:37:44 -07:00
|
|
|
cairo_surface_t *mSurface;
|
2011-01-02 17:48:08 -08:00
|
|
|
nsAutoPtr<gfxRect> mOpaqueRect;
|
2010-05-31 16:37:44 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
private:
|
2007-05-10 12:58:09 -07:00
|
|
|
static void SurfaceDestroyFunc(void *data);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mFloatingRefs;
|
|
|
|
int32_t mBytesRecorded;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-05-10 12:58:09 -07:00
|
|
|
protected:
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mSurfaceValid;
|
|
|
|
bool mAllowUseAsSource;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An Unknown surface; used to wrap unknown cairo_surface_t returns from cairo
|
|
|
|
*/
|
|
|
|
class THEBES_API gfxUnknownSurface : public gfxASurface {
|
|
|
|
public:
|
|
|
|
gfxUnknownSurface(cairo_surface_t *surf) {
|
2011-10-17 07:59:28 -07:00
|
|
|
Init(surf, true);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~gfxUnknownSurface() { }
|
|
|
|
};
|
|
|
|
|
2012-01-31 18:18:30 -08:00
|
|
|
#ifndef XPCOM_GLUE_AVOID_NSPR
|
|
|
|
/**
|
|
|
|
* We need to be able to hold a reference to a gfxASurface from Image
|
|
|
|
* subclasses. This is potentially a problem since Images can be addrefed
|
|
|
|
* or released off the main thread. We can ensure that we never AddRef
|
|
|
|
* a gfxASurface off the main thread, but we might want to Release due
|
|
|
|
* to an Image being destroyed off the main thread.
|
|
|
|
*
|
|
|
|
* We use nsCountedRef<nsMainThreadSurfaceRef> to reference the
|
|
|
|
* gfxASurface. When AddRefing, we assert that we're on the main thread.
|
|
|
|
* When Releasing, if we're not on the main thread, we post an event to
|
|
|
|
* the main thread to do the actual release.
|
|
|
|
*/
|
|
|
|
class nsMainThreadSurfaceRef;
|
|
|
|
|
|
|
|
template <>
|
|
|
|
class nsAutoRefTraits<nsMainThreadSurfaceRef> {
|
|
|
|
public:
|
|
|
|
typedef gfxASurface* RawRef;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The XPCOM event that will do the actual release on the main thread.
|
|
|
|
*/
|
|
|
|
class SurfaceReleaser : public nsRunnable {
|
|
|
|
public:
|
|
|
|
SurfaceReleaser(RawRef aRef) : mRef(aRef) {}
|
|
|
|
NS_IMETHOD Run() {
|
|
|
|
mRef->Release();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
RawRef mRef;
|
|
|
|
};
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
static RawRef Void() { return nullptr; }
|
2012-01-31 18:18:30 -08:00
|
|
|
static void Release(RawRef aRawRef)
|
|
|
|
{
|
|
|
|
if (NS_IsMainThread()) {
|
|
|
|
aRawRef->Release();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIRunnable> runnable = new SurfaceReleaser(aRawRef);
|
|
|
|
NS_DispatchToMainThread(runnable);
|
|
|
|
}
|
|
|
|
static void AddRef(RawRef aRawRef)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(),
|
|
|
|
"Can only add a reference on the main thread");
|
|
|
|
aRawRef->AddRef();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif /* GFX_ASURFACE_H */
|