Line data Source code
1 : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 : * This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #ifndef _MOZILLA_GFX_OP_SOURCESURFACE_CAIRO_H
7 : #define _MOZILLA_GFX_OP_SOURCESURFACE_CAIRO_H
8 :
9 : #include "2D.h"
10 :
11 : namespace mozilla {
12 : namespace gfx {
13 :
14 : class DrawTargetCairo;
15 :
16 : class SourceSurfaceCairo : public SourceSurface
17 : {
18 : public:
19 0 : MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SourceSurfaceCairo)
20 : // Create a SourceSurfaceCairo. The surface will not be copied, but simply
21 : // referenced.
22 : // If aDrawTarget is non-nullptr, it is assumed that this is a snapshot source
23 : // surface, and we'll call DrawTargetCairo::RemoveSnapshot(this) on it when
24 : // we're destroyed.
25 : SourceSurfaceCairo(cairo_surface_t* aSurface, const IntSize& aSize,
26 : const SurfaceFormat& aFormat,
27 : DrawTargetCairo* aDrawTarget = nullptr);
28 : virtual ~SourceSurfaceCairo();
29 :
30 0 : virtual SurfaceType GetType() const { return SurfaceType::CAIRO; }
31 : virtual IntSize GetSize() const;
32 : virtual SurfaceFormat GetFormat() const;
33 : virtual already_AddRefed<DataSourceSurface> GetDataSurface();
34 :
35 : cairo_surface_t* GetSurface() const;
36 :
37 : private: // methods
38 : friend class DrawTargetCairo;
39 : void DrawTargetWillChange();
40 :
41 : private: // data
42 : IntSize mSize;
43 : SurfaceFormat mFormat;
44 : cairo_surface_t* mSurface;
45 : DrawTargetCairo* mDrawTarget;
46 : };
47 :
48 : class DataSourceSurfaceCairo : public DataSourceSurface
49 : {
50 : public:
51 0 : MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DataSourceSurfaceCairo)
52 : explicit DataSourceSurfaceCairo(cairo_surface_t* imageSurf);
53 : virtual ~DataSourceSurfaceCairo();
54 : virtual unsigned char *GetData();
55 : virtual int32_t Stride();
56 :
57 0 : virtual SurfaceType GetType() const { return SurfaceType::CAIRO_IMAGE; }
58 : virtual IntSize GetSize() const;
59 : virtual SurfaceFormat GetFormat() const;
60 :
61 : cairo_surface_t* GetSurface() const;
62 :
63 : private:
64 : cairo_surface_t* mImageSurface;
65 : };
66 :
67 : } // namespace gfx
68 : } // namespace mozilla
69 :
70 : #endif // _MOZILLA_GFX_OP_SOURCESURFACE_CAIRO_H
|