Bug 1876335 - use GRADLE_MAVEN_REPOSITORIES in more places. r=owlish,geckoview-review...
[gecko.git] / gfx / 2d / SourceSurfaceCairo.h
blob4fcdfa2de8e7e6c5ec466e9b782d3d17e1d94aa2
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
10 #include "2D.h"
12 namespace mozilla {
13 namespace gfx {
15 class DrawTargetCairo;
17 class SourceSurfaceCairo : public SourceSurface {
18 public:
19 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SourceSurfaceCairo, override)
21 // Create a SourceSurfaceCairo. The surface will not be copied, but simply
22 // referenced.
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
25 // we're destroyed.
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;
38 private: // methods
39 friend class DrawTargetCairo;
40 void DrawTargetWillChange();
42 private: // data
43 IntSize mSize;
44 SurfaceFormat mFormat;
45 cairo_surface_t* mSurface;
46 DrawTargetCairo* mDrawTarget;
49 class DataSourceSurfaceCairo : public DataSourceSurface {
50 public:
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;
64 private:
65 cairo_surface_t* mImageSurface;
68 } // namespace gfx
69 } // namespace mozilla
71 #endif // _MOZILLA_GFX_OP_SOURCESURFACE_CAIRO_H