2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 4; -*- */
|
2013-02-14 03:26:24 +04:00
|
|
|
/* 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 "GLContextTypes.h"
|
|
|
|
#include "GLDefs.h"
|
2014-02-12 19:07:46 +04:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2013-12-10 20:12:18 +04:00
|
|
|
#include "mozilla/gfx/Point.h"
|
2014-08-16 04:38:08 +04:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2014-10-08 08:15:39 +04:00
|
|
|
#include "SurfaceTypes.h"
|
2013-02-14 03:26:24 +04:00
|
|
|
|
2020-06-17 21:56:16 +03:00
|
|
|
#include <queue>
|
|
|
|
#include <memory>
|
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace gl {
|
|
|
|
|
2014-07-12 02:10:49 +04:00
|
|
|
class SharedSurface;
|
2014-10-08 08:01:51 +04:00
|
|
|
class SurfaceFactory;
|
2020-06-15 21:25:55 +03:00
|
|
|
class SwapChain;
|
2014-07-12 02:10:49 +04:00
|
|
|
|
2020-06-15 21:25:55 +03:00
|
|
|
class SwapChainPresenter final {
|
|
|
|
friend class SwapChain;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2020-06-15 21:25:55 +03:00
|
|
|
SwapChain* mSwapChain;
|
2020-06-17 21:56:16 +03:00
|
|
|
std::shared_ptr<SharedSurface> mBackBuffer;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2014-07-12 02:10:49 +04:00
|
|
|
public:
|
2020-06-15 21:25:55 +03:00
|
|
|
explicit SwapChainPresenter(SwapChain& swapChain);
|
|
|
|
~SwapChainPresenter();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2020-06-15 21:25:55 +03:00
|
|
|
const auto& BackBuffer() const { return mBackBuffer; }
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2020-06-17 21:56:16 +03:00
|
|
|
std::shared_ptr<SharedSurface> SwapBackBuffer(std::shared_ptr<SharedSurface>);
|
2020-06-15 21:25:55 +03:00
|
|
|
GLuint Fb() const;
|
2013-02-14 03:26:24 +04:00
|
|
|
};
|
|
|
|
|
2020-06-15 21:25:55 +03:00
|
|
|
// -
|
2013-02-14 03:26:24 +04:00
|
|
|
|
2020-06-15 21:25:55 +03:00
|
|
|
class SwapChain final {
|
|
|
|
friend class SwapChainPresenter;
|
2020-01-09 01:19:14 +03:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
public:
|
2014-08-16 04:38:08 +04:00
|
|
|
UniquePtr<SurfaceFactory> mFactory;
|
2014-10-08 08:01:07 +04:00
|
|
|
|
2020-02-16 01:48:36 +03:00
|
|
|
private:
|
2020-06-17 21:56:16 +03:00
|
|
|
std::shared_ptr<SharedSurface> mFrontBuffer;
|
2020-06-15 21:25:55 +03:00
|
|
|
SwapChainPresenter* mPresenter = nullptr;
|
2013-02-14 03:26:24 +04:00
|
|
|
|
2020-06-17 21:56:16 +03:00
|
|
|
private:
|
|
|
|
std::queue<std::shared_ptr<SharedSurface>> mPool;
|
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
public:
|
2020-06-15 21:25:55 +03:00
|
|
|
SwapChain();
|
|
|
|
virtual ~SwapChain();
|
2013-02-14 03:26:24 +04:00
|
|
|
|
2020-06-17 21:56:16 +03:00
|
|
|
void ClearPool();
|
2020-06-15 21:25:55 +03:00
|
|
|
const auto& FrontBuffer() const { return mFrontBuffer; }
|
|
|
|
UniquePtr<SwapChainPresenter> Acquire(const gfx::IntSize&);
|
2013-02-14 03:26:24 +04:00
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace gl
|
|
|
|
} // namespace mozilla
|
2013-02-14 03:26:24 +04:00
|
|
|
|
|
|
|
#endif // SCREEN_BUFFER_H_
|