2011-06-24 21:41:16 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2012-05-21 15:12:37 +04: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/. */
|
2011-05-26 23:41:33 +04:00
|
|
|
|
2013-09-06 00:50:52 +04:00
|
|
|
#ifndef _MOZILLA_GFX_OP_SOURCESURFACE_CAIRO_H
|
2011-06-24 21:41:16 +04:00
|
|
|
#define _MOZILLA_GFX_OP_SOURCESURFACE_CAIRO_H
|
2011-05-26 23:41:33 +04:00
|
|
|
|
2011-06-24 21:41:16 +04:00
|
|
|
#include "2D.h"
|
2011-05-26 23:41:33 +04:00
|
|
|
|
2011-06-24 21:41:16 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
2011-05-26 23:41:33 +04:00
|
|
|
|
2012-01-10 01:50:01 +04:00
|
|
|
class DrawTargetCairo;
|
|
|
|
|
2011-06-24 21:41:16 +04:00
|
|
|
class SourceSurfaceCairo : public SourceSurface
|
|
|
|
{
|
|
|
|
public:
|
2012-01-10 01:50:01 +04:00
|
|
|
// Create a SourceSurfaceCairo. The surface will not be copied, but simply
|
|
|
|
// referenced.
|
2012-08-14 22:06:12 +04:00
|
|
|
// If aDrawTarget is non-nullptr, it is assumed that this is a snapshot source
|
2012-01-10 01:50:01 +04:00
|
|
|
// surface, and we'll call DrawTargetCairo::RemoveSnapshot(this) on it when
|
|
|
|
// we're destroyed.
|
|
|
|
SourceSurfaceCairo(cairo_surface_t* aSurface, const IntSize& aSize,
|
|
|
|
const SurfaceFormat& aFormat,
|
2012-08-14 22:06:12 +04:00
|
|
|
DrawTargetCairo* aDrawTarget = nullptr);
|
2012-01-10 01:50:01 +04:00
|
|
|
virtual ~SourceSurfaceCairo();
|
2011-05-26 23:41:33 +04:00
|
|
|
|
2011-06-24 21:41:16 +04:00
|
|
|
virtual SurfaceType GetType() const { return SURFACE_CAIRO; }
|
|
|
|
virtual IntSize GetSize() const;
|
|
|
|
virtual SurfaceFormat GetFormat() const;
|
|
|
|
virtual TemporaryRef<DataSourceSurface> GetDataSurface();
|
2011-05-26 23:41:33 +04:00
|
|
|
|
2012-01-10 01:50:01 +04:00
|
|
|
cairo_surface_t* GetSurface() const;
|
2011-05-26 23:41:33 +04:00
|
|
|
|
2012-01-10 01:50:01 +04:00
|
|
|
private: // methods
|
|
|
|
friend class DrawTargetCairo;
|
|
|
|
void DrawTargetWillChange();
|
2011-05-26 23:41:33 +04:00
|
|
|
|
2012-01-10 01:50:01 +04:00
|
|
|
private: // data
|
2011-06-24 21:41:16 +04:00
|
|
|
IntSize mSize;
|
|
|
|
SurfaceFormat mFormat;
|
|
|
|
cairo_surface_t* mSurface;
|
2012-01-10 01:50:01 +04:00
|
|
|
DrawTargetCairo* mDrawTarget;
|
|
|
|
};
|
|
|
|
|
|
|
|
class DataSourceSurfaceCairo : public DataSourceSurface
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DataSourceSurfaceCairo(cairo_surface_t* imageSurf);
|
|
|
|
virtual ~DataSourceSurfaceCairo();
|
|
|
|
virtual unsigned char *GetData();
|
|
|
|
virtual int32_t Stride();
|
|
|
|
|
|
|
|
virtual SurfaceType GetType() const { return SURFACE_CAIRO_IMAGE; }
|
|
|
|
virtual IntSize GetSize() const;
|
|
|
|
virtual SurfaceFormat GetFormat() const;
|
|
|
|
|
|
|
|
cairo_surface_t* GetSurface() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
cairo_surface_t* mImageSurface;
|
2011-05-26 23:41:33 +04:00
|
|
|
};
|
|
|
|
|
2011-06-24 21:41:16 +04:00
|
|
|
}
|
2011-05-26 23:41:33 +04:00
|
|
|
}
|
|
|
|
|
2011-06-24 21:41:16 +04:00
|
|
|
#endif // _MOZILLA_GFX_OP_SOURCESURFACE_CAIRO_H
|