Backed out 4 changesets (bug 1813407) for causing Linux bp-hybrid bustages in WindowSurfaceProvider.h. CLOSED TREE

Backed out changeset 897b95c7fdad (bug 1813407)
Backed out changeset aba3e370a587 (bug 1813407)
Backed out changeset 61c79624c2ab (bug 1813407)
Backed out changeset f99d85efb04c (bug 1813407)
This commit is contained in:
Stanca Serban 2023-02-21 12:54:32 +02:00
parent 39598d7624
commit 200dca5cfb
10 changed files with 38 additions and 74 deletions

View File

@ -57,13 +57,6 @@ bool RenderCompositorSWGL::MakeCurrent() {
}
bool RenderCompositorSWGL::BeginFrame() {
mRenderWidgetSize = Some(mWidget->GetClientSize());
#ifdef MOZ_WAYLAND
if (mLastRenderWidgetSize != mRenderWidgetSize.value()) {
mLastRenderWidgetSize = mRenderWidgetSize.value();
mRequestFullRender = true;
}
#endif
// Set up a temporary region representing the entire window surface in case a
// dirty region is not supplied.
ClearMappedBuffer();
@ -248,10 +241,7 @@ void RenderCompositorSWGL::CommitMappedBuffer(bool aDirty) {
ClearMappedBuffer();
}
void RenderCompositorSWGL::CancelFrame() {
CommitMappedBuffer(false);
mRenderWidgetSize = Nothing();
}
void RenderCompositorSWGL::CancelFrame() { CommitMappedBuffer(false); }
RenderedFrameId RenderCompositorSWGL::EndFrame(
const nsTArray<DeviceIntRect>& aDirtyRects) {
@ -260,7 +250,6 @@ RenderedFrameId RenderCompositorSWGL::EndFrame(
// to EndRemoteDrawingInRegion as for StartRemoteDrawingInRegion.
RenderedFrameId frameId = GetNextRenderFrameId();
CommitMappedBuffer();
mRenderWidgetSize = Nothing();
return frameId;
}
@ -289,11 +278,7 @@ bool RenderCompositorSWGL::Resume() {
}
LayoutDeviceIntSize RenderCompositorSWGL::GetBufferSize() {
// If we're between BeginFrame() and EndFrame()/CancelFrame() calls
// return recent rendering size instead of actual underlying widget
// size. It prevents possible rendering artifacts if widget size was changed.
return mRenderWidgetSize ? mRenderWidgetSize.value()
: mWidget->GetClientSize();
return mWidget->GetClientSize();
}
void RenderCompositorSWGL::GetCompositorCapabilities(

View File

@ -63,16 +63,10 @@ class RenderCompositorSWGL : public RenderCompositor {
void* mContext = nullptr;
RefPtr<gfx::DrawTarget> mDT;
LayoutDeviceIntRegion mDirtyRegion;
// Keep consistent buffer size between BeginFrame and EndFrame/CancelFrame
// calls to make sure we don't change buffer size during rendering.
Maybe<LayoutDeviceIntSize> mRenderWidgetSize;
RefPtr<gfx::DataSourceSurface> mSurface;
uint8_t* mMappedData = nullptr;
int32_t mMappedStride = 0;
#ifdef MOZ_WAYLAND
// On Wayland we need to request full render if widget size is changed
// because SW rendering backend reallocates and clears target surface.
LayoutDeviceIntSize mLastRenderWidgetSize;
bool mRequestFullRender = false;
#endif

View File

@ -48,7 +48,7 @@ GtkCompositorWidget::GtkCompositorWidget(
#endif
#if defined(MOZ_WAYLAND)
if (GdkIsWaylandDisplay()) {
ConfigureWaylandBackend();
ConfigureWaylandBackend(mWidget);
LOG("GtkCompositorWidget::GtkCompositorWidget() [%p] mWidget %p "
"mIsRenderingSuspended %d\n",
(void*)mWidget.get(), (void*)mWidget, !!mIsRenderingSuspended);
@ -178,8 +178,8 @@ void GtkCompositorWidget::DisableRendering() {
}
#if defined(MOZ_WAYLAND)
bool GtkCompositorWidget::ConfigureWaylandBackend() {
mProvider.Initialize(this);
bool GtkCompositorWidget::ConfigureWaylandBackend(RefPtr<nsWindow> aWindow) {
mProvider.Initialize(aWindow);
return true;
}
#endif
@ -221,7 +221,7 @@ void GtkCompositorWidget::EnableRendering(const uintptr_t aXWindow,
#if defined(MOZ_WAYLAND)
if (GdkIsWaylandDisplay()) {
LOG(" configure widget %p\n", mWidget.get());
if (!ConfigureWaylandBackend()) {
if (!ConfigureWaylandBackend(mWidget)) {
return;
}
}

View File

@ -99,7 +99,7 @@ class GtkCompositorWidget : public CompositorWidget,
private:
#if defined(MOZ_WAYLAND)
bool ConfigureWaylandBackend();
bool ConfigureWaylandBackend(RefPtr<nsWindow> aWindow);
#endif
#if defined(MOZ_X11)
bool ConfigureX11Backend(Window aXWindow, bool aShaped);

View File

@ -7,7 +7,6 @@
#include "WindowSurfaceProvider.h"
#include "gfxPlatformGtk.h"
#include "GtkCompositorWidget.h"
#include "mozilla/gfx/Logging.h"
#include "mozilla/layers/LayersTypes.h"
#include "nsWindow.h"
@ -42,6 +41,10 @@ WindowSurfaceProvider::WindowSurfaceProvider()
: mWindowSurface(nullptr),
mMutex("WindowSurfaceProvider"),
mWindowSurfaceValid(false)
#ifdef MOZ_WAYLAND
,
mWidget(nullptr)
#endif
#ifdef MOZ_X11
,
mIsShaped(false),
@ -57,11 +60,6 @@ void WindowSurfaceProvider::Initialize(RefPtr<nsWindow> aWidget) {
mWindowSurfaceValid = false;
mWidget = std::move(aWidget);
}
void WindowSurfaceProvider::Initialize(GtkCompositorWidget* aCompositorWidget) {
mWindowSurfaceValid = false;
mCompositorWidget = aCompositorWidget;
mWidget = static_cast<nsWindow*>(aCompositorWidget->RealWidget());
}
#endif
#ifdef MOZ_X11
void WindowSurfaceProvider::Initialize(Window aWindow, Visual* aVisual,
@ -95,7 +93,7 @@ RefPtr<WindowSurface> WindowSurfaceProvider::CreateWindowSurface() {
if (!mWidget) {
return nullptr;
}
return MakeRefPtr<WindowSurfaceWaylandMB>(mWidget, mCompositorWidget);
return MakeRefPtr<WindowSurfaceWaylandMB>(mWidget);
}
#endif
#ifdef MOZ_X11

View File

@ -44,7 +44,6 @@ class WindowSurfaceProvider final {
*/
#ifdef MOZ_WAYLAND
void Initialize(RefPtr<nsWindow> aWidget);
void Initialize(GtkCompositorWidget* aCompositorWidget);
#endif
#ifdef MOZ_X11
void Initialize(Window aWindow, Visual* aVisual, int aDepth, bool aIsShaped);
@ -81,9 +80,6 @@ class WindowSurfaceProvider final {
mozilla::Atomic<bool> mWindowSurfaceValid;
#ifdef MOZ_WAYLAND
RefPtr<nsWindow> mWidget;
// WindowSurfaceProvider is owned by GtkCompositorWidget so we don't need
// to reference it.
GtkCompositorWidget* mCompositorWidget = nullptr;
#endif
#ifdef MOZ_X11
bool mIsShaped;

View File

@ -14,7 +14,6 @@
#include "gfx2DGlue.h"
#include "gfxPlatform.h"
#include "MozContainer.h"
#include "GtkCompositorWidget.h"
#include "mozilla/gfx/DataSurfaceHelpers.h"
#include "mozilla/gfx/Tools.h"
#include "mozilla/ScopeExit.h"
@ -153,29 +152,12 @@ using gfx::DataSourceSurface;
#define BACK_BUFFER_NUM 3
WindowSurfaceWaylandMB::WindowSurfaceWaylandMB(
RefPtr<nsWindow> aWindow, GtkCompositorWidget* aCompositorWidget)
WindowSurfaceWaylandMB::WindowSurfaceWaylandMB(RefPtr<nsWindow> aWindow)
: mSurfaceLock("WindowSurfaceWayland lock"),
mWindow(std::move(aWindow)),
mCompositorWidget(aCompositorWidget),
mFrameInProcess(false),
mCallbackRequested(false) {}
bool WindowSurfaceWaylandMB::MaybeUpdateWindowSize() {
// We want to get window size from compositor widget as it matches window
// size used by parent RenderCompositorSWGL rendrer.
// For main thread rendering mCompositorWidget is not available so get
// window size directly from nsWindow.
LayoutDeviceIntSize newWindowSize = mCompositorWidget
? mCompositorWidget->GetClientSize()
: mWindow->GetClientSize();
if (mWindowSize != newWindowSize) {
mWindowSize = newWindowSize;
return true;
}
return false;
}
already_AddRefed<DrawTarget> WindowSurfaceWaylandMB::Lock(
const LayoutDeviceIntRegion& aInvalidRegion) {
MutexAutoLock lock(mSurfaceLock);
@ -194,9 +176,11 @@ already_AddRefed<DrawTarget> WindowSurfaceWaylandMB::Lock(
CollectPendingSurfaces(lock);
if (MaybeUpdateWindowSize()) {
LOGWAYLAND(" new window size [%d x %d]", mWindowSize.width,
mWindowSize.height);
LayoutDeviceIntSize newMozContainerSize = mWindow->GetMozContainerSize();
if (mMozContainerSize != newMozContainerSize) {
mMozContainerSize = newMozContainerSize;
LOGWAYLAND(" new MozContainer size [%d x %d]", mMozContainerSize.width,
mMozContainerSize.height);
if (mInProgressBuffer) {
ReturnBufferToPool(lock, mInProgressBuffer);
mInProgressBuffer = nullptr;
@ -212,7 +196,7 @@ already_AddRefed<DrawTarget> WindowSurfaceWaylandMB::Lock(
if (mFrontBuffer && !mFrontBuffer->IsAttached()) {
mInProgressBuffer = mFrontBuffer;
} else {
mInProgressBuffer = ObtainBufferFromPool(lock, mWindowSize);
mInProgressBuffer = ObtainBufferFromPool(lock, mMozContainerSize);
if (!mInProgressBuffer) {
return nullptr;
}
@ -273,9 +257,9 @@ void WindowSurfaceWaylandMB::Commit(
gfx::IntRect invalidRect = aInvalidRegion.GetBounds().ToUnknownRect();
LOGWAYLAND(
"WindowSurfaceWaylandMB::Commit [%p] damage rect [%d, %d] -> [%d x %d] "
"Window [%d x %d]\n",
"MozContainer [%d x %d]\n",
(void*)mWindow.get(), invalidRect.x, invalidRect.y, invalidRect.width,
invalidRect.height, mWindowSize.width, mWindowSize.height);
invalidRect.height, mMozContainerSize.width, mMozContainerSize.height);
#endif
if (!mInProgressBuffer) {
@ -357,7 +341,7 @@ void WindowSurfaceWaylandMB::ReturnBufferToPool(
const RefPtr<WaylandBufferSHM>& aBuffer) {
if (aBuffer->IsAttached()) {
mPendingBuffers.AppendElement(aBuffer);
} else if (aBuffer->IsMatchingSize(mWindowSize)) {
} else if (aBuffer->IsMatchingSize(mMozContainerSize)) {
mAvailableBuffers.AppendElement(aBuffer);
}
mInUseBuffers.RemoveElement(aBuffer);
@ -381,7 +365,7 @@ void WindowSurfaceWaylandMB::CollectPendingSurfaces(
const MutexAutoLock& aProofOfLock) {
mPendingBuffers.RemoveElementsBy([&](auto& buffer) {
if (!buffer->IsAttached()) {
if (buffer->IsMatchingSize(mWindowSize)) {
if (buffer->IsMatchingSize(mMozContainerSize)) {
mAvailableBuffers.AppendElement(std::move(buffer));
}
return true;

View File

@ -24,8 +24,7 @@ using gfx::DrawTarget;
// and related management
class WindowSurfaceWaylandMB : public WindowSurface {
public:
WindowSurfaceWaylandMB(RefPtr<nsWindow> aWindow,
GtkCompositorWidget* aCompositorWidget);
explicit WindowSurfaceWaylandMB(RefPtr<nsWindow> aWindow);
~WindowSurfaceWaylandMB() = default;
// Lock() / Commit() are called by gecko when Firefox
@ -54,16 +53,11 @@ class WindowSurfaceWaylandMB : public WindowSurface {
void HandlePartialUpdate(const MutexAutoLock& aProofOfLock,
const LayoutDeviceIntRegion& aInvalidRegion);
void IncrementBufferAge(const MutexAutoLock& aProofOfLock);
// Return true if window size was updated.
bool MaybeUpdateWindowSize();
mozilla::Mutex mSurfaceLock MOZ_UNANNOTATED;
RefPtr<nsWindow> mWindow;
// WindowSurfaceWaylandMB is owned by GtkCompositorWidget so we can't
// reference it.
GtkCompositorWidget* mCompositorWidget;
LayoutDeviceIntSize mWindowSize;
LayoutDeviceIntSize mMozContainerSize;
RefPtr<WaylandBufferSHM> mInProgressBuffer;
RefPtr<WaylandBufferSHM> mFrontBuffer;

View File

@ -9660,6 +9660,18 @@ void nsWindow::SetEGLNativeWindowSize(
}
#endif
LayoutDeviceIntSize nsWindow::GetMozContainerSize() {
LayoutDeviceIntSize size(0, 0);
if (mContainer) {
GtkAllocation allocation;
gtk_widget_get_allocation(GTK_WIDGET(mContainer), &allocation);
double scale = FractionalScaleFactor();
size.width = round(allocation.width * scale);
size.height = round(allocation.height * scale);
}
return size;
}
nsWindow* nsWindow::GetWindow(GdkWindow* window) {
return get_window_for_gdk_window(window);
}

View File

@ -274,6 +274,7 @@ class nsWindow final : public nsBaseWidget {
static guint32 sLastButtonPressTime;
MozContainer* GetMozContainer() { return mContainer; }
LayoutDeviceIntSize GetMozContainerSize();
GdkWindow* GetGdkWindow() const { return mGdkWindow; };
GdkWindow* GetToplevelGdkWindow() const;
GtkWidget* GetGtkWidget() const { return mShell; }