2013-02-13 15:26:24 -08:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */
|
|
|
|
/* 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 SHARED_SURFACE_ANGLE_H_
|
|
|
|
#define SHARED_SURFACE_ANGLE_H_
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
2014-07-11 15:10:49 -07:00
|
|
|
#include "SharedSurface.h"
|
|
|
|
|
2013-02-13 15:26:24 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace gl {
|
|
|
|
|
|
|
|
class GLContext;
|
2014-07-11 15:10:49 -07:00
|
|
|
class GLLibraryEGL;
|
2013-02-13 15:26:24 -08:00
|
|
|
|
|
|
|
class SharedSurface_ANGLEShareHandle
|
2014-07-11 15:10:49 -07:00
|
|
|
: public SharedSurface
|
2013-02-13 15:26:24 -08:00
|
|
|
{
|
|
|
|
public:
|
2014-08-15 17:38:08 -07:00
|
|
|
static UniquePtr<SharedSurface_ANGLEShareHandle> Create(GLContext* gl,
|
|
|
|
EGLContext context,
|
|
|
|
EGLConfig config,
|
|
|
|
const gfx::IntSize& size,
|
|
|
|
bool hasAlpha);
|
2013-02-13 15:26:24 -08:00
|
|
|
|
|
|
|
static SharedSurface_ANGLEShareHandle* Cast(SharedSurface* surf) {
|
2014-07-11 15:10:49 -07:00
|
|
|
MOZ_ASSERT(surf->mType == SharedSurfaceType::EGLSurfaceANGLE);
|
2013-02-13 15:26:24 -08:00
|
|
|
|
|
|
|
return (SharedSurface_ANGLEShareHandle*)surf;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
GLLibraryEGL* const mEGL;
|
|
|
|
const EGLContext mContext;
|
|
|
|
const EGLSurface mPBuffer;
|
2014-06-18 17:04:05 -07:00
|
|
|
const HANDLE mShareHandle;
|
2013-02-13 15:26:24 -08:00
|
|
|
|
|
|
|
SharedSurface_ANGLEShareHandle(GLContext* gl,
|
|
|
|
GLLibraryEGL* egl,
|
2013-12-10 08:11:58 -08:00
|
|
|
const gfx::IntSize& size,
|
2013-02-13 15:26:24 -08:00
|
|
|
bool hasAlpha,
|
|
|
|
EGLContext context,
|
|
|
|
EGLSurface pbuffer,
|
2014-06-18 17:04:05 -07:00
|
|
|
HANDLE shareHandle)
|
2014-07-11 15:10:49 -07:00
|
|
|
: SharedSurface(SharedSurfaceType::EGLSurfaceANGLE,
|
|
|
|
AttachmentType::Screen,
|
|
|
|
gl,
|
|
|
|
size,
|
|
|
|
hasAlpha)
|
2013-02-13 15:26:24 -08:00
|
|
|
, mEGL(egl)
|
|
|
|
, mContext(context)
|
|
|
|
, mPBuffer(pbuffer)
|
2014-06-18 17:04:05 -07:00
|
|
|
, mShareHandle(shareHandle)
|
2013-02-13 15:26:24 -08:00
|
|
|
{}
|
|
|
|
|
|
|
|
EGLDisplay Display();
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~SharedSurface_ANGLEShareHandle();
|
|
|
|
|
2014-03-10 19:08:49 -07:00
|
|
|
virtual void LockProdImpl() MOZ_OVERRIDE;
|
|
|
|
virtual void UnlockProdImpl() MOZ_OVERRIDE;
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2014-03-10 19:08:49 -07:00
|
|
|
virtual void Fence() MOZ_OVERRIDE;
|
2014-08-04 22:10:47 -07:00
|
|
|
virtual bool WaitSync() MOZ_OVERRIDE { return true; } // Fence is glFinish.
|
|
|
|
virtual bool PollSync() MOZ_OVERRIDE { return true; }
|
2013-02-13 15:26:24 -08:00
|
|
|
|
|
|
|
// Implementation-specific functions below:
|
2014-06-18 17:04:05 -07:00
|
|
|
HANDLE GetShareHandle() {
|
|
|
|
return mShareHandle;
|
2013-02-13 15:26:24 -08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SurfaceFactory_ANGLEShareHandle
|
2014-07-11 15:10:49 -07:00
|
|
|
: public SurfaceFactory
|
2013-02-13 15:26:24 -08:00
|
|
|
{
|
|
|
|
protected:
|
|
|
|
GLContext* const mProdGL;
|
|
|
|
GLLibraryEGL* const mEGL;
|
|
|
|
EGLContext mContext;
|
|
|
|
EGLConfig mConfig;
|
|
|
|
|
|
|
|
public:
|
2014-08-15 17:38:08 -07:00
|
|
|
static UniquePtr<SurfaceFactory_ANGLEShareHandle> Create(GLContext* gl,
|
|
|
|
const SurfaceCaps& caps);
|
2013-02-13 15:26:24 -08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
SurfaceFactory_ANGLEShareHandle(GLContext* gl,
|
|
|
|
GLLibraryEGL* egl,
|
|
|
|
const SurfaceCaps& caps);
|
|
|
|
|
2014-08-15 17:38:08 -07:00
|
|
|
virtual UniquePtr<SharedSurface> CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE {
|
2013-02-13 15:26:24 -08:00
|
|
|
bool hasAlpha = mReadCaps.alpha;
|
2014-06-18 17:04:05 -07:00
|
|
|
return SharedSurface_ANGLEShareHandle::Create(mProdGL,
|
2013-02-13 15:26:24 -08:00
|
|
|
mContext, mConfig,
|
|
|
|
size, hasAlpha);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace gfx */
|
|
|
|
} /* namespace mozilla */
|
|
|
|
|
|
|
|
#endif /* SHARED_SURFACE_ANGLE_H_ */
|