2018-01-15 16:22:15 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* 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 MOZILLA_GFX_RENDERCOMPOSITOR_OGL_H
|
|
|
|
#define MOZILLA_GFX_RENDERCOMPOSITOR_OGL_H
|
|
|
|
|
|
|
|
#include "mozilla/webrender/RenderCompositor.h"
|
2019-11-28 02:07:51 +03:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2018-01-15 16:22:15 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
2018-01-19 05:01:04 +03:00
|
|
|
|
2019-10-29 23:50:33 +03:00
|
|
|
namespace layers {
|
|
|
|
class NativeLayerRoot;
|
|
|
|
class NativeLayer;
|
|
|
|
} // namespace layers
|
|
|
|
|
2018-01-15 16:22:15 +03:00
|
|
|
namespace wr {
|
|
|
|
|
|
|
|
class RenderCompositorOGL : public RenderCompositor {
|
|
|
|
public:
|
|
|
|
static UniquePtr<RenderCompositor> Create(
|
|
|
|
RefPtr<widget::CompositorWidget>&& aWidget);
|
|
|
|
|
|
|
|
RenderCompositorOGL(RefPtr<gl::GLContext>&& aGL,
|
2018-01-19 05:01:04 +03:00
|
|
|
RefPtr<widget::CompositorWidget>&& aWidget);
|
2018-01-15 16:22:15 +03:00
|
|
|
virtual ~RenderCompositorOGL();
|
|
|
|
|
2019-10-29 23:50:33 +03:00
|
|
|
bool BeginFrame() override;
|
2019-11-04 19:15:20 +03:00
|
|
|
RenderedFrameId EndFrame(const FfiVec<DeviceIntRect>& aDirtyRects) final;
|
2019-07-17 23:46:39 +03:00
|
|
|
bool WaitForGPU() override;
|
2018-01-15 16:22:15 +03:00
|
|
|
void Pause() override;
|
|
|
|
bool Resume() override;
|
|
|
|
|
|
|
|
gl::GLContext* gl() const override { return mGL; }
|
|
|
|
|
2018-01-19 05:01:04 +03:00
|
|
|
bool UseANGLE() const override { return false; }
|
2018-01-15 16:22:15 +03:00
|
|
|
|
2018-02-01 15:39:31 +03:00
|
|
|
LayoutDeviceIntSize GetBufferSize() override;
|
2018-01-15 16:22:15 +03:00
|
|
|
|
2019-10-29 23:54:09 +03:00
|
|
|
bool ShouldUseNativeCompositor() override;
|
2019-11-19 06:33:43 +03:00
|
|
|
uint32_t GetMaxUpdateRects() override;
|
2019-10-29 23:54:09 +03:00
|
|
|
|
|
|
|
// Interface for wr::Compositor
|
|
|
|
void CompositorBeginFrame() override;
|
|
|
|
void CompositorEndFrame() override;
|
|
|
|
void Bind(wr::NativeSurfaceId aId, wr::DeviceIntPoint* aOffset,
|
|
|
|
uint32_t* aFboId, wr::DeviceIntRect aDirtyRect) override;
|
|
|
|
void Unbind() override;
|
2019-10-30 23:49:44 +03:00
|
|
|
void CreateSurface(wr::NativeSurfaceId aId, wr::DeviceIntSize aSize,
|
|
|
|
bool aIsOpaque) override;
|
2019-10-29 23:54:09 +03:00
|
|
|
void DestroySurface(NativeSurfaceId aId) override;
|
|
|
|
void AddSurface(wr::NativeSurfaceId aId, wr::DeviceIntPoint aPosition,
|
|
|
|
wr::DeviceIntRect aClipRect) override;
|
|
|
|
|
2018-01-15 16:22:15 +03:00
|
|
|
protected:
|
2019-07-17 23:46:39 +03:00
|
|
|
void InsertFrameDoneSync();
|
|
|
|
|
2018-01-15 16:22:15 +03:00
|
|
|
RefPtr<gl::GLContext> mGL;
|
2019-07-17 23:46:39 +03:00
|
|
|
|
2019-10-29 23:50:33 +03:00
|
|
|
// Can be null.
|
|
|
|
RefPtr<layers::NativeLayerRoot> mNativeLayerRoot;
|
|
|
|
RefPtr<layers::NativeLayer> mNativeLayerForEntireWindow;
|
2019-10-29 22:25:39 +03:00
|
|
|
|
2019-10-29 23:54:09 +03:00
|
|
|
// Used in native compositor mode:
|
|
|
|
RefPtr<layers::NativeLayer> mCurrentlyBoundNativeLayer;
|
|
|
|
nsTArray<RefPtr<layers::NativeLayer>> mAddedLayers;
|
2019-11-28 02:07:26 +03:00
|
|
|
uint64_t mTotalPixelCount = 0;
|
2019-10-29 23:54:09 +03:00
|
|
|
uint64_t mAddedPixelCount = 0;
|
|
|
|
uint64_t mAddedClippedPixelCount = 0;
|
|
|
|
uint64_t mDrawnPixelCount = 0;
|
|
|
|
gfx::IntRect mVisibleBounds;
|
|
|
|
std::unordered_map<uint64_t, RefPtr<layers::NativeLayer>> mNativeLayers;
|
2019-11-28 02:07:51 +03:00
|
|
|
TimeStamp mBeginFrameTimeStamp;
|
2019-10-29 23:54:09 +03:00
|
|
|
|
2019-07-17 23:46:39 +03:00
|
|
|
// Used to apply back-pressure in WaitForGPU().
|
|
|
|
GLsync mPreviousFrameDoneSync;
|
|
|
|
GLsync mThisFrameDoneSync;
|
2018-01-15 16:22:15 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace wr
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|