/src/mozilla-central/gfx/2d/DataSourceSurfaceWrapper.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_DATASOURCESURFACEWRAPPER_H_ |
8 | | #define MOZILLA_GFX_DATASOURCESURFACEWRAPPER_H_ |
9 | | |
10 | | #include "2D.h" |
11 | | |
12 | | namespace mozilla { |
13 | | namespace gfx { |
14 | | |
15 | | // Wraps a DataSourceSurface and forwards all methods except for GetType(), |
16 | | // from which it always returns SurfaceType::DATA. |
17 | | class DataSourceSurfaceWrapper final : public DataSourceSurface |
18 | | { |
19 | | public: |
20 | | MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DataSourceSurfaceWrapper, override) |
21 | | explicit DataSourceSurfaceWrapper(DataSourceSurface *aSurface) |
22 | | : mSurface(aSurface) |
23 | 0 | {} |
24 | | |
25 | | bool Equals(SourceSurface* aOther, bool aSymmetric = true) override |
26 | 0 | { |
27 | 0 | return DataSourceSurface::Equals(aOther, aSymmetric) || |
28 | 0 | mSurface->Equals(aOther, aSymmetric); |
29 | 0 | } |
30 | | |
31 | 0 | virtual SurfaceType GetType() const override { return SurfaceType::DATA; } |
32 | | |
33 | 0 | virtual uint8_t *GetData() override { return mSurface->GetData(); } |
34 | 0 | virtual int32_t Stride() override { return mSurface->Stride(); } |
35 | 0 | virtual IntSize GetSize() const override { return mSurface->GetSize(); } |
36 | 0 | virtual SurfaceFormat GetFormat() const override { return mSurface->GetFormat(); } |
37 | 0 | virtual bool IsValid() const override { return mSurface->IsValid(); } |
38 | | |
39 | | bool Map(MapType aType, MappedSurface *aMappedSurface) override |
40 | 0 | { |
41 | 0 | return mSurface->Map(aType, aMappedSurface); |
42 | 0 | } |
43 | | |
44 | 0 | void Unmap() override { mSurface->Unmap(); } |
45 | | |
46 | | private: |
47 | | RefPtr<DataSourceSurface> mSurface; |
48 | | }; |
49 | | |
50 | | } // namespace gfx |
51 | | } // namespace mozilla |
52 | | |
53 | | #endif /* MOZILLA_GFX_DATASOURCESURFACEWRAPPER_H_ */ |