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