DataSourceSurfaceWrapper.h 1.4 KB

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