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_DATASOURCESURFACEWRAPPER_H_
7 : #define MOZILLA_GFX_DATASOURCESURFACEWRAPPER_H_
8 :
9 : #include "2D.h"
10 :
11 : namespace mozilla {
12 : namespace gfx {
13 :
14 : // Wraps a DataSourceSurface and forwards all methods except for GetType(),
15 : // from which it always returns SurfaceType::DATA.
16 0 : class DataSourceSurfaceWrapper : public DataSourceSurface
17 : {
18 : public:
19 0 : MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DataSourceSurfaceWrapper, override)
20 0 : explicit DataSourceSurfaceWrapper(DataSourceSurface *aSurface)
21 0 : : mSurface(aSurface)
22 0 : {}
23 :
24 0 : virtual SurfaceType GetType() const override { return SurfaceType::DATA; }
25 :
26 0 : virtual uint8_t *GetData() override { return mSurface->GetData(); }
27 0 : virtual int32_t Stride() override { return mSurface->Stride(); }
28 0 : virtual IntSize GetSize() const override { return mSurface->GetSize(); }
29 0 : virtual SurfaceFormat GetFormat() const override { return mSurface->GetFormat(); }
30 0 : virtual bool IsValid() const override { return mSurface->IsValid(); }
31 :
32 : private:
33 : RefPtr<DataSourceSurface> mSurface;
34 : };
35 :
36 : } // namespace gfx
37 : } // namespace mozilla
38 :
39 : #endif /* MOZILLA_GFX_DATASOURCESURFACEWRAPPER_H_ */
|