summaryrefslogtreecommitdiffstats
path: root/gfx/gl/SharedSurfaceAndroidHardwareBuffer.h
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/gl/SharedSurfaceAndroidHardwareBuffer.h')
-rw-r--r--gfx/gl/SharedSurfaceAndroidHardwareBuffer.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/gfx/gl/SharedSurfaceAndroidHardwareBuffer.h b/gfx/gl/SharedSurfaceAndroidHardwareBuffer.h
new file mode 100644
index 0000000000..ef40ad622d
--- /dev/null
+++ b/gfx/gl/SharedSurfaceAndroidHardwareBuffer.h
@@ -0,0 +1,70 @@
+/* -*- 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_ANDROID_HARDWARE_BUFFER_H_
+#define SHARED_SURFACE_ANDROID_HARDWARE_BUFFER_H_
+
+#include "mozilla/Attributes.h"
+#include "mozilla/Mutex.h"
+#include "CompositorTypes.h"
+#include "SharedSurface.h"
+
+namespace mozilla {
+
+namespace layers {
+class AndroidHardwareBuffer;
+} // namespace layers
+
+namespace gl {
+
+class SharedSurface_AndroidHardwareBuffer final : public SharedSurface {
+ public:
+ const UniquePtr<Texture> mTex;
+ const RefPtr<layers::AndroidHardwareBuffer> mAndroidHardwareBuffer;
+ EGLSync mSync = 0;
+
+ static UniquePtr<SharedSurface_AndroidHardwareBuffer> Create(
+ const SharedSurfaceDesc&);
+
+ protected:
+ SharedSurface_AndroidHardwareBuffer(
+ const SharedSurfaceDesc&, UniquePtr<MozFramebuffer>, UniquePtr<Texture>,
+ RefPtr<layers::AndroidHardwareBuffer> buffer);
+
+ public:
+ virtual ~SharedSurface_AndroidHardwareBuffer();
+
+ void LockProdImpl() override {}
+ void UnlockProdImpl() override {}
+
+ void ProducerAcquireImpl() override {}
+ void ProducerReleaseImpl() override;
+
+ Maybe<layers::SurfaceDescriptor> ToSurfaceDescriptor() override;
+
+ void WaitForBufferOwnership() override;
+};
+
+class SurfaceFactory_AndroidHardwareBuffer final : public SurfaceFactory {
+ public:
+ static UniquePtr<SurfaceFactory_AndroidHardwareBuffer> Create(GLContext&);
+
+ private:
+ explicit SurfaceFactory_AndroidHardwareBuffer(
+ const PartialSharedSurfaceDesc& desc)
+ : SurfaceFactory(desc) {}
+
+ public:
+ virtual UniquePtr<SharedSurface> CreateSharedImpl(
+ const SharedSurfaceDesc& desc) override {
+ return SharedSurface_AndroidHardwareBuffer::Create(desc);
+ }
+};
+
+} // namespace gl
+
+} /* namespace mozilla */
+
+#endif /* SHARED_SURFACE_ANDROID_HARDWARE_BUFFER_H_ */