gfx/webrender_bindings/RenderD3D11TextureHostOGL.h
author Mike Hommey <mh+mozilla@glandium.org>
Thu, 28 Sep 2017 08:46:43 +0900
changeset 384593 d6dc8ba8b0762681e7c0ed4005ca5a194d48b325
parent 383573 507fd8ac4448aacff075960f38b979801636682a
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_RENDERD3D11TEXTUREHOSTOGL_H
#define MOZILLA_GFX_RENDERD3D11TEXTUREHOSTOGL_H

#include "RenderTextureHostOGL.h"
#include "GLTypes.h"

struct ID3D11Texture2D;
struct IDXGIKeyedMutex;

namespace mozilla {

namespace wr {

class RenderDXGITextureHostOGL final : public RenderTextureHostOGL
{
public:
  explicit RenderDXGITextureHostOGL(WindowsHandle aHandle,
                                    gfx::SurfaceFormat aFormat,
                                    gfx::IntSize aSize);

  virtual void SetGLContext(gl::GLContext* aContext) override;

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

  virtual gfx::IntSize GetSize(uint8_t aChannelIndex) const;
  virtual GLuint GetGLHandle(uint8_t aChannelIndex) const;

private:
  virtual ~RenderDXGITextureHostOGL();

  bool EnsureLockable();

  void DeleteTextureHandle();

  RefPtr<gl::GLContext> mGL;

  WindowsHandle mHandle;
  RefPtr<ID3D11Texture2D> mTexture;
  RefPtr<IDXGIKeyedMutex> mKeyedMutex;

  EGLSurface mSurface;
  EGLStreamKHR mStream;

  // We could use NV12 format for this texture. So, we might have 2 gl texture
  // handles for Y and CbCr data.
  GLuint mTextureHandle[2];

  gfx::SurfaceFormat mFormat;
  gfx::IntSize mSize;

  bool mLocked;
};

class RenderDXGIYCbCrTextureHostOGL final : public RenderTextureHostOGL
{
public:
  explicit RenderDXGIYCbCrTextureHostOGL(WindowsHandle (&aHandles)[3],
                                         gfx::IntSize aSize);

  virtual void SetGLContext(gl::GLContext* aContext) override;

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

  virtual gfx::IntSize GetSize(uint8_t aChannelIndex) const;
  virtual GLuint GetGLHandle(uint8_t aChannelIndex) const;

private:
  virtual ~RenderDXGIYCbCrTextureHostOGL();

  bool EnsureLockable();

  void DeleteTextureHandle();

  RefPtr<gl::GLContext> mGL;

  WindowsHandle mHandles[3];
  RefPtr<ID3D11Texture2D> mTextures[3];
  RefPtr<IDXGIKeyedMutex> mKeyedMutexs[3];

  EGLSurface mSurfaces[3];
  EGLStreamKHR mStreams[3];

  // The gl handles for Y, Cb and Cr data.
  GLuint mTextureHandles[3];

  gfx::IntSize mSize;

  bool mLocked;
};

} // namespace wr
} // namespace mozilla

#endif // MOZILLA_GFX_RENDERD3D11TEXTUREHOSTOGL_H