tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

DataSourceSurfaceWrapper.h (1760B)


      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 public:
     19  MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DataSourceSurfaceWrapper, override)
     20  explicit DataSourceSurfaceWrapper(DataSourceSurface* aSurface)
     21      : mSurface(aSurface) {}
     22 
     23  bool Equals(SourceSurface* aOther, bool aSymmetric = true) override {
     24    return DataSourceSurface::Equals(aOther, aSymmetric) ||
     25           mSurface->Equals(aOther, aSymmetric);
     26  }
     27 
     28  SurfaceType GetType() const override { return SurfaceType::DATA; }
     29 
     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(); }
     35 
     36  bool Map(MapType aType, MappedSurface* aMappedSurface) override {
     37    return mSurface->Map(aType, aMappedSurface);
     38  }
     39 
     40  void Unmap() override { mSurface->Unmap(); }
     41 
     42 private:
     43  RefPtr<DataSourceSurface> mSurface;
     44 };
     45 
     46 }  // namespace gfx
     47 }  // namespace mozilla
     48 
     49 #endif /* MOZILLA_GFX_DATASOURCESURFACEWRAPPER_H_ */