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_DATASOURCESURFACEWRAPPER_H_
8 #define MOZILLA_GFX_DATASOURCESURFACEWRAPPER_H_
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
{
19 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DataSourceSurfaceWrapper
, override
)
20 explicit DataSourceSurfaceWrapper(DataSourceSurface
* aSurface
)
21 : mSurface(aSurface
) {}
23 bool Equals(SourceSurface
* aOther
, bool aSymmetric
= true) override
{
24 return DataSourceSurface::Equals(aOther
, aSymmetric
) ||
25 mSurface
->Equals(aOther
, aSymmetric
);
28 SurfaceType
GetType() const override
{ return SurfaceType::DATA
; }
30 uint8_t* GetData() override
{ return mSurface
->GetData(); }
31 int32_t Stride() override
{ return mSurface
->Stride(); }
32 IntSize
GetSize() const override
{ return mSurface
->GetSize(); }
33 SurfaceFormat
GetFormat() const override
{ return mSurface
->GetFormat(); }
34 bool IsValid() const override
{ return mSurface
->IsValid(); }
36 bool Map(MapType aType
, MappedSurface
* aMappedSurface
) override
{
37 return mSurface
->Map(aType
, aMappedSurface
);
40 void Unmap() override
{ mSurface
->Unmap(); }
43 RefPtr
<DataSourceSurface
> mSurface
;
47 } // namespace mozilla
49 #endif /* MOZILLA_GFX_DATASOURCESURFACEWRAPPER_H_ */