tor-browser

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

RenderBufferTextureHost.h (2317B)


      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_RENDERBUFFERTEXTUREHOST_H
      8 #define MOZILLA_GFX_RENDERBUFFERTEXTUREHOST_H
      9 
     10 #include "RenderTextureHostSWGL.h"
     11 
     12 namespace mozilla {
     13 namespace wr {
     14 
     15 class RenderBufferTextureHost final : public RenderTextureHostSWGL {
     16 public:
     17  RenderBufferTextureHost(uint8_t* aBuffer,
     18                          const layers::BufferDescriptor& aDescriptor);
     19 
     20  // RenderTextureHost
     21  wr::WrExternalImage Lock(uint8_t aChannelIndex, gl::GLContext* aGL) override;
     22  void Unlock() override;
     23 
     24  size_t Bytes() override {
     25    return mSize.width * mSize.height * BytesPerPixel(mFormat);
     26  }
     27  class RenderBufferData {
     28   public:
     29    RenderBufferData(uint8_t* aData, size_t aBufferSize)
     30        : mData(aData), mBufferSize(aBufferSize) {}
     31    const uint8_t* mData;
     32    size_t mBufferSize;
     33  };
     34 
     35  RenderBufferData GetBufferDataForRender(uint8_t aChannelIndex);
     36 
     37  // RenderTextureHostSWGL
     38  size_t GetPlaneCount() const override;
     39 
     40  gfx::SurfaceFormat GetFormat() const override;
     41 
     42  gfx::ColorDepth GetColorDepth() const override;
     43 
     44  gfx::YUVRangedColorSpace GetYUVColorSpace() const override;
     45 
     46  bool MapPlane(RenderCompositor* aCompositor, uint8_t aChannelIndex,
     47                PlaneInfo& aPlaneInfo) override;
     48 
     49  void UnmapPlanes() override;
     50 
     51  void Destroy() override;
     52 
     53 private:
     54  virtual ~RenderBufferTextureHost();
     55 
     56  uint8_t* GetBuffer() const { return mBuffer; }
     57 
     58  uint8_t* mBuffer;
     59  layers::BufferDescriptor mDescriptor;
     60  gfx::IntSize mSize;
     61  gfx::SurfaceFormat mFormat;
     62 
     63  RefPtr<gfx::DataSourceSurface> mSurface;
     64  gfx::DataSourceSurface::MappedSurface mMap;
     65 
     66  RefPtr<gfx::DataSourceSurface> mYSurface;
     67  RefPtr<gfx::DataSourceSurface> mCbSurface;
     68  RefPtr<gfx::DataSourceSurface> mCrSurface;
     69  gfx::DataSourceSurface::MappedSurface mYMap;
     70  gfx::DataSourceSurface::MappedSurface mCbMap;
     71  gfx::DataSourceSurface::MappedSurface mCrMap;
     72 
     73  bool mLocked;
     74 
     75  bool mDestroyed = false;
     76 };
     77 
     78 }  // namespace wr
     79 }  // namespace mozilla
     80 
     81 #endif  // MOZILLA_GFX_RENDERBUFFERTEXTUREHOST_H