2017-10-28 02:10:06 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2013-11-27 15:21:21 +04:00
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef MOZILLA_GFX_DATASOURCESURFACEWRAPPER_H_
|
|
|
|
#define MOZILLA_GFX_DATASOURCESURFACEWRAPPER_H_
|
|
|
|
|
|
|
|
#include "2D.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
|
|
|
|
// Wraps a DataSourceSurface and forwards all methods except for GetType(),
|
2014-01-10 22:55:24 +04:00
|
|
|
// from which it always returns SurfaceType::DATA.
|
2018-01-11 16:48:46 +03:00
|
|
|
class DataSourceSurfaceWrapper final : public DataSourceSurface
|
2013-11-27 15:21:21 +04:00
|
|
|
{
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DataSourceSurfaceWrapper, override)
|
2014-08-08 05:17:30 +04:00
|
|
|
explicit DataSourceSurfaceWrapper(DataSourceSurface *aSurface)
|
2013-11-27 15:21:21 +04:00
|
|
|
: mSurface(aSurface)
|
|
|
|
{}
|
|
|
|
|
2018-01-11 16:48:46 +03:00
|
|
|
bool Equals(SourceSurface* aOther, bool aSymmetric = true) override
|
|
|
|
{
|
|
|
|
return DataSourceSurface::Equals(aOther, aSymmetric) ||
|
|
|
|
mSurface->Equals(aOther, aSymmetric);
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual SurfaceType GetType() const override { return SurfaceType::DATA; }
|
2013-11-27 15:21:21 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual uint8_t *GetData() override { return mSurface->GetData(); }
|
|
|
|
virtual int32_t Stride() override { return mSurface->Stride(); }
|
|
|
|
virtual IntSize GetSize() const override { return mSurface->GetSize(); }
|
|
|
|
virtual SurfaceFormat GetFormat() const override { return mSurface->GetFormat(); }
|
|
|
|
virtual bool IsValid() const override { return mSurface->IsValid(); }
|
2013-11-27 15:21:21 +04:00
|
|
|
|
2018-01-11 16:48:46 +03:00
|
|
|
bool Map(MapType aType, MappedSurface *aMappedSurface) override
|
|
|
|
{
|
|
|
|
return mSurface->Map(aType, aMappedSurface);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Unmap() override { mSurface->Unmap(); }
|
|
|
|
|
2013-11-27 15:21:21 +04:00
|
|
|
private:
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DataSourceSurface> mSurface;
|
2013-11-27 15:21:21 +04:00
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|
2013-11-27 15:21:21 +04:00
|
|
|
|
|
|
|
#endif /* MOZILLA_GFX_DATASOURCESURFACEWRAPPER_H_ */
|