1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef _MOZILLA_GFX_OP_SOURCESURFACE_CAIRO_H
8 #define _MOZILLA_GFX_OP_SOURCESURFACE_CAIRO_H
15 class DrawTargetCairo
;
17 class SourceSurfaceCairo
: public SourceSurface
{
19 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SourceSurfaceCairo
, override
)
21 // Create a SourceSurfaceCairo. The surface will not be copied, but simply
23 // If aDrawTarget is non-nullptr, it is assumed that this is a snapshot source
24 // surface, and we'll call DrawTargetCairo::RemoveSnapshot(this) on it when
26 SourceSurfaceCairo(cairo_surface_t
* aSurface
, const IntSize
& aSize
,
27 const SurfaceFormat
& aFormat
,
28 DrawTargetCairo
* aDrawTarget
= nullptr);
29 virtual ~SourceSurfaceCairo();
31 SurfaceType
GetType() const override
{ return SurfaceType::CAIRO
; }
32 IntSize
GetSize() const override
;
33 SurfaceFormat
GetFormat() const override
;
34 already_AddRefed
<DataSourceSurface
> GetDataSurface() override
;
36 cairo_surface_t
* GetSurface() const;
39 friend class DrawTargetCairo
;
40 void DrawTargetWillChange();
44 SurfaceFormat mFormat
;
45 cairo_surface_t
* mSurface
;
46 DrawTargetCairo
* mDrawTarget
;
49 class DataSourceSurfaceCairo
: public DataSourceSurface
{
51 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DataSourceSurfaceCairo
, override
)
53 explicit DataSourceSurfaceCairo(cairo_surface_t
* imageSurf
);
54 virtual ~DataSourceSurfaceCairo();
55 unsigned char* GetData() override
;
56 int32_t Stride() override
;
58 SurfaceType
GetType() const override
{ return SurfaceType::CAIRO_IMAGE
; }
59 IntSize
GetSize() const override
;
60 SurfaceFormat
GetFormat() const override
;
62 cairo_surface_t
* GetSurface() const;
65 cairo_surface_t
* mImageSurface
;
69 } // namespace mozilla
71 #endif // _MOZILLA_GFX_OP_SOURCESURFACE_CAIRO_H