gfx/webrender_bindings/RenderBufferTextureHost.h
author Mike Hommey <mh+mozilla@glandium.org>
Thu, 28 Sep 2017 08:46:43 +0900
changeset 384593 d6dc8ba8b0762681e7c0ed4005ca5a194d48b325
parent 362717 b46936cf531ecac952dd3fa87918a040d8712593
child 389027 5f74d262924171a8fa0b4483a64f4cac34c4c9b8
child 389104 40ec5550739449f1cb8ad7d030a40cc10f9653bc
permissions -rw-r--r--
Bug 1403366 - Don't use nsDirectoryService::Create in nsDirectoryService::GetCurrentProcessDirectory. r=froydnj Back in the day, there was no global with an already initialized DirectoryService. But now there is, and, in fact, GetCurrentProcessDirectory already errors out if that global is not set by the time it's called. All calling nsDirectoryService::Create achieves is doing the check again and calling QueryInterface, which we don't need to do anyways.

/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 * This Source Code Form is subject to the terms of the Mozilla Public
 * 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_RENDERBUFFERTEXTUREHOST_H
#define MOZILLA_GFX_RENDERBUFFERTEXTUREHOST_H

#include "RenderTextureHost.h"

namespace mozilla {
namespace wr {

class RenderBufferTextureHost final : public RenderTextureHost
{
public:
  RenderBufferTextureHost(uint8_t* aBuffer,
                          const layers::BufferDescriptor& aDescriptor);

  virtual bool Lock() override;
  virtual void Unlock() override;

  virtual RenderBufferTextureHost* AsBufferTextureHost() override
  {
    return this;
  }

  class RenderBufferData
  {
  public:
    RenderBufferData(uint8_t* aData, size_t aBufferSize)
      : mData(aData)
      , mBufferSize(aBufferSize)
    {
    }
    const uint8_t* mData;
    size_t mBufferSize;
  };

  RenderBufferData GetBufferDataForRender(uint8_t aChannelIndex);

private:
  virtual ~RenderBufferTextureHost();

  uint8_t* GetBuffer() const
  {
    return mBuffer;
  }

  uint8_t* mBuffer;
  layers::BufferDescriptor mDescriptor;
  gfx::IntSize mSize;
  gfx::SurfaceFormat mFormat;

  RefPtr<gfx::DataSourceSurface> mSurface;
  gfx::DataSourceSurface::MappedSurface mMap;

  RefPtr<gfx::DataSourceSurface> mYSurface;
  RefPtr<gfx::DataSourceSurface> mCbSurface;
  RefPtr<gfx::DataSourceSurface> mCrSurface;
  gfx::DataSourceSurface::MappedSurface mYMap;
  gfx::DataSourceSurface::MappedSurface mCbMap;
  gfx::DataSourceSurface::MappedSurface mCrMap;

  bool mLocked;
};

} // namespace wr
} // namespace mozilla

#endif // MOZILLA_GFX_RENDERBUFFERTEXTUREHOST_H