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