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:
|
2014-02-24 17:23:37 +04:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SourceSurfaceCairo)
|
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
|
|
|
|
2014-01-10 22:55:24 +04:00
|
|
|
virtual SurfaceType GetType() const { return SurfaceType::CAIRO; }
|
2011-06-24 21:41:16 +04:00
|
|
|
virtual IntSize GetSize() const;
|
|
|
|
virtual SurfaceFormat GetFormat() const;
|
2015-06-17 17:00:52 +03:00
|
|
|
virtual already_AddRefed<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:
|
2014-02-24 17:23:37 +04:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DataSourceSurfaceCairo)
|
2014-09-01 07:31:20 +04:00
|
|
|
explicit DataSourceSurfaceCairo(cairo_surface_t* imageSurf);
|
2012-01-10 01:50:01 +04:00
|
|
|
virtual ~DataSourceSurfaceCairo();
|
|
|
|
virtual unsigned char *GetData();
|
|
|
|
virtual int32_t Stride();
|
|
|
|
|
2014-01-10 22:55:24 +04:00
|
|
|
virtual SurfaceType GetType() const { return SurfaceType::CAIRO_IMAGE; }
|
2012-01-10 01:50:01 +04:00
|
|
|
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
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|
2011-05-26 23:41:33 +04:00
|
|
|
|
2011-06-24 21:41:16 +04:00
|
|
|
#endif // _MOZILLA_GFX_OP_SOURCESURFACE_CAIRO_H
|