From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- gfx/gl/GLScreenBuffer.h | 87 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 gfx/gl/GLScreenBuffer.h (limited to 'gfx/gl/GLScreenBuffer.h') diff --git a/gfx/gl/GLScreenBuffer.h b/gfx/gl/GLScreenBuffer.h new file mode 100644 index 0000000000..1b05a9c4b5 --- /dev/null +++ b/gfx/gl/GLScreenBuffer.h @@ -0,0 +1,87 @@ +/* -*- 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/. */ + +/* GLScreenBuffer is the abstraction for the "default framebuffer" used + * by an offscreen GLContext. Since it's only for offscreen GLContext's, + * it's only useful for things like WebGL, and is NOT used by the + * compositor's GLContext. Remember that GLContext provides an abstraction + * so that even if you want to draw to the 'screen', even if that's not + * actually the screen, just draw to 0. This GLScreenBuffer class takes the + * logic handling out of GLContext. + */ + +#ifndef SCREEN_BUFFER_H_ +#define SCREEN_BUFFER_H_ + +#include "GLTypes.h" +#include "mozilla/gfx/Point.h" +#include "mozilla/UniquePtr.h" + +#include +#include +#include + +namespace mozilla { +namespace gl { + +class SharedSurface; +class SurfaceFactory; +class SwapChain; + +class SwapChainPresenter final { + friend class SwapChain; + + SwapChain* mSwapChain; + std::shared_ptr mBackBuffer; + + public: + explicit SwapChainPresenter(SwapChain& swapChain); + ~SwapChainPresenter(); + + const auto& BackBuffer() const { return mBackBuffer; } + + std::shared_ptr SwapBackBuffer(std::shared_ptr); + GLuint Fb() const; +}; + +// - + +class SwapChain final { + friend class SwapChainPresenter; + + public: + UniquePtr mFactory; + + private: + std::queue> mPool; + std::shared_ptr mFrontBuffer; + std::function mDestroyedCallback; + + public: + std::shared_ptr + mPrevFrontBuffer; // Hold this ref while it's in-flight. + private: + SwapChainPresenter* mPresenter = nullptr; + + public: + SwapChain(); + virtual ~SwapChain(); + + void ClearPool(); + void StoreRecycledSurface(const std::shared_ptr& surf); + const auto& FrontBuffer() const { return mFrontBuffer; } + UniquePtr Acquire(const gfx::IntSize&, gfx::ColorSpace2); + + void SetDestroyedCallback(std::function&& aDestroyedCallback) { + MOZ_ASSERT(!mDestroyedCallback); + mDestroyedCallback = std::move(aDestroyedCallback); + mPool = {}; + } +}; + +} // namespace gl +} // namespace mozilla + +#endif // SCREEN_BUFFER_H_ -- cgit v1.2.3