/src/mozilla-central/gfx/2d/SourceSurfaceCairo.h
Line | Count | Source (jump to first uncovered line) |
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/. */ |
6 | | |
7 | | #ifndef _MOZILLA_GFX_OP_SOURCESURFACE_CAIRO_H |
8 | | #define _MOZILLA_GFX_OP_SOURCESURFACE_CAIRO_H |
9 | | |
10 | | #include "2D.h" |
11 | | |
12 | | namespace mozilla { |
13 | | namespace gfx { |
14 | | |
15 | | class DrawTargetCairo; |
16 | | |
17 | | class SourceSurfaceCairo : public SourceSurface |
18 | | { |
19 | | public: |
20 | | MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SourceSurfaceCairo, override) |
21 | | |
22 | | // Create a SourceSurfaceCairo. The surface will not be copied, but simply |
23 | | // referenced. |
24 | | // If aDrawTarget is non-nullptr, it is assumed that this is a snapshot source |
25 | | // surface, and we'll call DrawTargetCairo::RemoveSnapshot(this) on it when |
26 | | // we're destroyed. |
27 | | SourceSurfaceCairo(cairo_surface_t* aSurface, const IntSize& aSize, |
28 | | const SurfaceFormat& aFormat, |
29 | | DrawTargetCairo* aDrawTarget = nullptr); |
30 | | virtual ~SourceSurfaceCairo(); |
31 | | |
32 | 0 | virtual SurfaceType GetType() const override { return SurfaceType::CAIRO; } |
33 | | virtual IntSize GetSize() const override; |
34 | | virtual SurfaceFormat GetFormat() const override; |
35 | | virtual already_AddRefed<DataSourceSurface> GetDataSurface() override; |
36 | | |
37 | | cairo_surface_t* GetSurface() const; |
38 | | |
39 | | private: // methods |
40 | | friend class DrawTargetCairo; |
41 | | void DrawTargetWillChange(); |
42 | | |
43 | | private: // data |
44 | | IntSize mSize; |
45 | | SurfaceFormat mFormat; |
46 | | cairo_surface_t* mSurface; |
47 | | DrawTargetCairo* mDrawTarget; |
48 | | }; |
49 | | |
50 | | class DataSourceSurfaceCairo : public DataSourceSurface |
51 | | { |
52 | | public: |
53 | | MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DataSourceSurfaceCairo, override) |
54 | | |
55 | | explicit DataSourceSurfaceCairo(cairo_surface_t* imageSurf); |
56 | | virtual ~DataSourceSurfaceCairo(); |
57 | | virtual unsigned char *GetData() override; |
58 | | virtual int32_t Stride() override; |
59 | | |
60 | 0 | virtual SurfaceType GetType() const override { return SurfaceType::CAIRO_IMAGE; } |
61 | | virtual IntSize GetSize() const override; |
62 | | virtual SurfaceFormat GetFormat() const override; |
63 | | |
64 | | cairo_surface_t* GetSurface() const; |
65 | | |
66 | | private: |
67 | | cairo_surface_t* mImageSurface; |
68 | | }; |
69 | | |
70 | | } // namespace gfx |
71 | | } // namespace mozilla |
72 | | |
73 | | #endif // _MOZILLA_GFX_OP_SOURCESURFACE_CAIRO_H |