2013-07-18 03:24:15 +00: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_SURFACEIO_H_
|
|
|
|
#define SHARED_SURFACEIO_H_
|
|
|
|
|
|
|
|
#include "mozilla/RefPtr.h"
|
2014-07-11 22:10:49 +00:00
|
|
|
#include "SharedSurface.h"
|
2013-07-18 03:24:15 +00:00
|
|
|
|
|
|
|
class MacIOSurface;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gl {
|
|
|
|
|
2014-07-11 22:10:49 +00:00
|
|
|
class SharedSurface_IOSurface : public SharedSurface
|
2013-07-18 03:24:15 +00:00
|
|
|
{
|
2015-06-05 00:15:38 +00:00
|
|
|
private:
|
|
|
|
const RefPtr<MacIOSurface> mIOSurf;
|
|
|
|
GLuint mProdTex;
|
|
|
|
|
2013-07-18 03:24:15 +00:00
|
|
|
public:
|
2014-08-16 00:38:08 +00:00
|
|
|
static UniquePtr<SharedSurface_IOSurface> Create(const RefPtr<MacIOSurface>& ioSurf,
|
2014-08-16 00:38:08 +00:00
|
|
|
GLContext* gl,
|
|
|
|
bool hasAlpha);
|
2013-07-18 03:24:15 +00:00
|
|
|
|
2015-06-05 00:15:38 +00:00
|
|
|
private:
|
|
|
|
SharedSurface_IOSurface(const RefPtr<MacIOSurface>& ioSurf,
|
|
|
|
GLContext* gl, const gfx::IntSize& size,
|
|
|
|
bool hasAlpha);
|
|
|
|
|
|
|
|
public:
|
2013-07-18 03:24:15 +00:00
|
|
|
~SharedSurface_IOSurface();
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void LockProdImpl() override { }
|
|
|
|
virtual void UnlockProdImpl() override { }
|
2013-07-18 03:24:15 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void Fence() override;
|
|
|
|
virtual bool WaitSync() override { return true; }
|
|
|
|
virtual bool PollSync() override { return true; }
|
2013-07-18 03:24:15 +00:00
|
|
|
|
2015-03-23 03:55:26 +00:00
|
|
|
virtual bool CopyTexImage2D(GLenum target, GLint level, GLenum internalformat,
|
|
|
|
GLint x, GLint y, GLsizei width, GLsizei height,
|
|
|
|
GLint border) override;
|
2013-07-18 03:24:15 +00:00
|
|
|
virtual bool ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
|
2015-03-21 16:28:04 +00:00
|
|
|
GLenum format, GLenum type, GLvoid *pixels) override;
|
2013-07-18 03:24:15 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual GLuint ProdTexture() override {
|
2014-03-11 02:08:50 +00:00
|
|
|
return mProdTex;
|
2013-07-18 03:24:15 +00:00
|
|
|
}
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual GLenum ProdTextureTarget() const override {
|
2013-07-18 03:24:15 +00:00
|
|
|
return LOCAL_GL_TEXTURE_RECTANGLE_ARB;
|
|
|
|
}
|
|
|
|
|
2014-03-11 02:08:49 +00:00
|
|
|
static SharedSurface_IOSurface* Cast(SharedSurface *surf) {
|
2014-07-11 22:10:49 +00:00
|
|
|
MOZ_ASSERT(surf->mType == SharedSurfaceType::IOSurface);
|
2013-07-18 03:24:15 +00:00
|
|
|
return static_cast<SharedSurface_IOSurface*>(surf);
|
|
|
|
}
|
|
|
|
|
2014-06-19 00:04:06 +00:00
|
|
|
MacIOSurface* GetIOSurface() const {
|
2014-08-16 00:38:08 +00:00
|
|
|
return mIOSurf;
|
2014-10-08 04:01:51 +00:00
|
|
|
}
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual bool NeedsIndirectReads() const override {
|
2014-10-08 04:01:51 +00:00
|
|
|
return true;
|
2014-06-19 00:04:06 +00:00
|
|
|
}
|
|
|
|
|
2015-06-05 00:15:38 +00:00
|
|
|
virtual bool ToSurfaceDescriptor(layers::SurfaceDescriptor* const out_descriptor) override;
|
2013-07-18 03:24:15 +00:00
|
|
|
};
|
|
|
|
|
2014-07-11 22:10:49 +00:00
|
|
|
class SurfaceFactory_IOSurface : public SurfaceFactory
|
2013-07-18 03:24:15 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-07-12 06:08:54 +00:00
|
|
|
// Infallible.
|
2014-08-16 00:38:08 +00:00
|
|
|
static UniquePtr<SurfaceFactory_IOSurface> Create(GLContext* gl,
|
2015-06-05 00:15:38 +00:00
|
|
|
const SurfaceCaps& caps,
|
|
|
|
const RefPtr<layers::ISurfaceAllocator>& allocator,
|
|
|
|
const layers::TextureFlags& flags);
|
2014-07-12 06:08:54 +00:00
|
|
|
protected:
|
|
|
|
const gfx::IntSize mMaxDims;
|
|
|
|
|
2015-06-05 00:15:38 +00:00
|
|
|
SurfaceFactory_IOSurface(GLContext* gl, const SurfaceCaps& caps,
|
|
|
|
const RefPtr<layers::ISurfaceAllocator>& allocator,
|
|
|
|
const layers::TextureFlags& flags,
|
2014-07-12 06:08:54 +00:00
|
|
|
const gfx::IntSize& maxDims)
|
2015-06-05 00:15:38 +00:00
|
|
|
: SurfaceFactory(SharedSurfaceType::IOSurface, gl, caps, allocator, flags)
|
2014-07-12 06:08:54 +00:00
|
|
|
, mMaxDims(maxDims)
|
2015-06-05 00:15:38 +00:00
|
|
|
{ }
|
2013-07-18 03:24:15 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual UniquePtr<SharedSurface> CreateShared(const gfx::IntSize& size) override;
|
2013-07-18 03:24:15 +00:00
|
|
|
};
|
|
|
|
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace gl
|
|
|
|
|
2013-07-18 03:24:15 +00:00
|
|
|
} /* namespace mozilla */
|
|
|
|
|
|
|
|
#endif /* SHARED_SURFACEIO_H_ */
|