2017-10-28 02:10:06 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2012-05-21 15:12:37 +04:00
|
|
|
* 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:
|
2017-11-06 06:37:28 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SourceSurfaceCairo, override)
|
|
|
|
|
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
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
SurfaceType GetType() const override { return SurfaceType::CAIRO; }
|
|
|
|
IntSize GetSize() const override;
|
|
|
|
SurfaceFormat GetFormat() const override;
|
|
|
|
already_AddRefed<DataSourceSurface> GetDataSurface() override;
|
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:
|
2017-11-06 06:37:28 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DataSourceSurfaceCairo, override)
|
|
|
|
|
2014-09-01 07:31:20 +04:00
|
|
|
explicit DataSourceSurfaceCairo(cairo_surface_t* imageSurf);
|
2012-01-10 01:50:01 +04:00
|
|
|
virtual ~DataSourceSurfaceCairo();
|
2019-04-11 15:36:51 +03:00
|
|
|
unsigned char* GetData() override;
|
|
|
|
int32_t Stride() override;
|
|
|
|
|
|
|
|
SurfaceType GetType() const override { return SurfaceType::CAIRO_IMAGE; }
|
|
|
|
IntSize GetSize() const override;
|
|
|
|
SurfaceFormat GetFormat() const override;
|
2012-01-10 01:50:01 +04:00
|
|
|
|
|
|
|
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
|