michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef _MOZILLA_GFX_OP_SOURCESURFACE_CAIRO_H michael@0: #define _MOZILLA_GFX_OP_SOURCESURFACE_CAIRO_H michael@0: michael@0: #include "2D.h" michael@0: michael@0: namespace mozilla { michael@0: namespace gfx { michael@0: michael@0: class DrawTargetCairo; michael@0: michael@0: class SourceSurfaceCairo : public SourceSurface michael@0: { michael@0: public: michael@0: MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SourceSurfaceCairo) michael@0: // Create a SourceSurfaceCairo. The surface will not be copied, but simply michael@0: // referenced. michael@0: // If aDrawTarget is non-nullptr, it is assumed that this is a snapshot source michael@0: // surface, and we'll call DrawTargetCairo::RemoveSnapshot(this) on it when michael@0: // we're destroyed. michael@0: SourceSurfaceCairo(cairo_surface_t* aSurface, const IntSize& aSize, michael@0: const SurfaceFormat& aFormat, michael@0: DrawTargetCairo* aDrawTarget = nullptr); michael@0: virtual ~SourceSurfaceCairo(); michael@0: michael@0: virtual SurfaceType GetType() const { return SurfaceType::CAIRO; } michael@0: virtual IntSize GetSize() const; michael@0: virtual SurfaceFormat GetFormat() const; michael@0: virtual TemporaryRef GetDataSurface(); michael@0: michael@0: cairo_surface_t* GetSurface() const; michael@0: michael@0: private: // methods michael@0: friend class DrawTargetCairo; michael@0: void DrawTargetWillChange(); michael@0: michael@0: private: // data michael@0: IntSize mSize; michael@0: SurfaceFormat mFormat; michael@0: cairo_surface_t* mSurface; michael@0: DrawTargetCairo* mDrawTarget; michael@0: }; michael@0: michael@0: class DataSourceSurfaceCairo : public DataSourceSurface michael@0: { michael@0: public: michael@0: MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DataSourceSurfaceCairo) michael@0: DataSourceSurfaceCairo(cairo_surface_t* imageSurf); michael@0: virtual ~DataSourceSurfaceCairo(); michael@0: virtual unsigned char *GetData(); michael@0: virtual int32_t Stride(); michael@0: michael@0: virtual SurfaceType GetType() const { return SurfaceType::CAIRO_IMAGE; } michael@0: virtual IntSize GetSize() const; michael@0: virtual SurfaceFormat GetFormat() const; michael@0: michael@0: cairo_surface_t* GetSurface() const; michael@0: michael@0: private: michael@0: cairo_surface_t* mImageSurface; michael@0: }; michael@0: michael@0: } michael@0: } michael@0: michael@0: #endif // _MOZILLA_GFX_OP_SOURCESURFACE_CAIRO_H