2020-02-05 09:32:25 +03:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 4; -*- */
|
|
|
|
/* 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_DMABUF_H_
|
|
|
|
#define SHARED_SURFACE_DMABUF_H_
|
|
|
|
|
|
|
|
#include "SharedSurface.h"
|
2020-06-21 16:59:17 +03:00
|
|
|
#include "mozilla/widget/DMABufSurface.h"
|
2020-02-05 09:32:25 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gl {
|
|
|
|
|
|
|
|
class GLContext;
|
|
|
|
class GLLibraryEGL;
|
|
|
|
|
|
|
|
class SharedSurface_DMABUF final : public SharedSurface {
|
|
|
|
public:
|
2020-06-21 16:59:17 +03:00
|
|
|
const RefPtr<DMABufSurface> mSurface;
|
2020-02-05 09:32:25 +03:00
|
|
|
|
2020-06-15 21:25:55 +03:00
|
|
|
static UniquePtr<SharedSurface_DMABUF> Create(const SharedSurfaceDesc&);
|
2020-02-05 09:32:25 +03:00
|
|
|
|
2020-06-15 21:25:55 +03:00
|
|
|
private:
|
|
|
|
SharedSurface_DMABUF(const SharedSurfaceDesc&, UniquePtr<MozFramebuffer>,
|
2020-06-21 16:59:17 +03:00
|
|
|
RefPtr<DMABufSurface>);
|
2020-02-05 09:32:25 +03:00
|
|
|
|
|
|
|
void UpdateProdTexture(const MutexAutoLock& curAutoLock);
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~SharedSurface_DMABUF();
|
|
|
|
|
|
|
|
// Exclusive Content/WebGL lock/unlock of surface for write
|
|
|
|
virtual void LockProdImpl() override {}
|
|
|
|
virtual void UnlockProdImpl() override {}
|
|
|
|
|
|
|
|
// Non-exclusive Content/WebGL lock/unlock of surface for write
|
|
|
|
virtual void ProducerAcquireImpl() override {}
|
|
|
|
virtual void ProducerReleaseImpl() override;
|
|
|
|
|
|
|
|
// Non-exclusive Content/WebGL lock/unlock for read from surface
|
|
|
|
virtual void ProducerReadAcquireImpl() override {}
|
|
|
|
virtual void ProducerReadReleaseImpl() override {}
|
|
|
|
|
2020-06-15 21:25:55 +03:00
|
|
|
Maybe<layers::SurfaceDescriptor> ToSurfaceDescriptor() override;
|
2020-02-05 09:32:25 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
class SurfaceFactory_DMABUF : public SurfaceFactory {
|
|
|
|
public:
|
2020-06-25 08:57:40 +03:00
|
|
|
static UniquePtr<SurfaceFactory_DMABUF> Create(GLContext& gl);
|
|
|
|
|
2020-06-15 21:25:55 +03:00
|
|
|
explicit SurfaceFactory_DMABUF(GLContext&);
|
2020-02-05 09:32:25 +03:00
|
|
|
|
|
|
|
public:
|
2020-06-15 21:25:55 +03:00
|
|
|
virtual UniquePtr<SharedSurface> CreateSharedImpl(
|
|
|
|
const SharedSurfaceDesc& desc) override {
|
|
|
|
return SharedSurface_DMABUF::Create(desc);
|
2020-02-05 09:32:25 +03:00
|
|
|
}
|
2020-06-25 08:57:40 +03:00
|
|
|
|
|
|
|
bool CanCreateSurface() {
|
|
|
|
UniquePtr<SharedSurface> test = CreateShared(gfx::IntSize(1, 1));
|
|
|
|
return test != nullptr;
|
|
|
|
}
|
2020-02-05 09:32:25 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace gl
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif /* SHARED_SURFACE_DMABUF_H_ */
|