Backed out changeset 37aeebaea4bb (bug 1711244) for clang bustages on NativeLayerWayland.cpp . CLOSED TREE
authorNarcis Beleuzu <nbeleuzu@mozilla.com>
Thu, 03 Jun 2021 20:11:32 +0300
changeset 581863 84a47330bc5a93cd38b8db63f288d2dbb9690869
parent 581862 4ecd47e4e6d8377818aafabe9a8cc4fefceddf8c
child 581864 123c17cfaaf685a5225aeabb262260c216388c8c
push id144291
push usernbeleuzu@mozilla.com
push dateThu, 03 Jun 2021 17:12:27 +0000
treeherderautoland@84a47330bc5a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1711244
milestone91.0a1
backs out37aeebaea4bba256718f7ef208b11e4fe54b04f0
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 37aeebaea4bb (bug 1711244) for clang bustages on NativeLayerWayland.cpp . CLOSED TREE
gfx/layers/NativeLayerWayland.cpp
gfx/layers/NativeLayerWayland.h
gfx/webrender_bindings/RenderCompositorNative.cpp
--- a/gfx/layers/NativeLayerWayland.cpp
+++ b/gfx/layers/NativeLayerWayland.cpp
@@ -1,15 +1,14 @@
 /* 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/. */
 
 #include "mozilla/layers/NativeLayerWayland.h"
 
-#include <dlfcn.h>
 #include <utility>
 #include <algorithm>
 
 #include "gfxUtils.h"
 #include "GLContextProvider.h"
 #include "mozilla/layers/SurfacePoolWayland.h"
 #include "mozilla/StaticPrefs_widget.h"
 #include "mozilla/webrender/RenderThread.h"
@@ -224,130 +223,37 @@ void NativeLayerRootWayland::SetLayers(
     bufferClip.height /= scaleY;
 
     wp_viewport_set_source(nativeSurface->mViewport,
                            wl_fixed_from_double(bufferClip.x),
                            wl_fixed_from_double(bufferClip.y),
                            wl_fixed_from_double(bufferClip.width),
                            wl_fixed_from_double(bufferClip.height));
 
+    wl_compositor* compositor = widget::WaylandDisplayGet()->GetCompositor();
+    struct wl_region* region = wl_compositor_create_region(compositor);
+    if (layer->mIsOpaque &&
+        StaticPrefs::widget_wayland_opaque_region_enabled_AtStartup()) {
+      wl_region_add(region, 0, 0, INT32_MAX, INT32_MAX);
+    }
+    wl_surface_set_opaque_region(nativeSurface->mWlSurface, region);
+    wl_region_destroy(region);
+
     if (previousSurface) {
       wl_subsurface_place_above(nativeSurface->mWlSubsurface, previousSurface);
       previousSurface = nativeSurface->mWlSurface;
     } else {
       wl_surface* wlSurface = moz_container_wayland_surface_lock(mContainer);
       if (wlSurface) {
         wl_subsurface_place_above(nativeSurface->mWlSubsurface, wlSurface);
         moz_container_wayland_surface_unlock(mContainer, &wlSurface);
       }
       previousSurface = nativeSurface->mWlSurface;
     }
   }
-
-  RefPtr<nsIThread> mainThread =
-      static_cast<nsIThread*>(mozilla::GetMainThreadSerialEventTarget());
-
-  nsCOMPtr<nsIRunnable> updateLayersRunnable = NewRunnableMethod<>(
-      "layers::NativeLayerRootWayland::UpdateLayersOnMainThread", this,
-      &NativeLayerRootWayland::UpdateLayersOnMainThread);
-  MOZ_ALWAYS_SUCCEEDS(
-      mainThread->Dispatch(updateLayersRunnable, NS_DISPATCH_NORMAL));
-}
-
-static void sAfterFrameClockAfterPaint(
-    GdkFrameClock* aClock, NativeLayerRootWayland* aNativeLayerRoot) {
-  aNativeLayerRoot->AfterFrameClockAfterPaint();
-}
-
-void NativeLayerRootWayland::AfterFrameClockAfterPaint() {
-  MutexAutoLock lock(mMutex);
-  wl_surface* containerSurface = moz_container_wayland_surface_lock(mContainer);
-
-  for (const RefPtr<NativeLayerWayland>& layer : mSublayersOnMainThread) {
-    wl_surface_commit(layer->mNativeSurface->mWlSurface);
-  }
-  if (containerSurface) {
-    wl_surface_commit(containerSurface);
-    moz_container_wayland_surface_unlock(mContainer, &containerSurface);
-  }
-
-  wl_display_flush(widget::WaylandDisplayGet()->GetDisplay());
-}
-
-void NativeLayerRootWayland::UpdateLayersOnMainThread() {
-  AssertIsOnMainThread();
-  MutexAutoLock lock(mMutex);
-
-  if (!mCompositorRunning) {
-    return;
-  }
-
-  static auto sGdkWaylandWindowAddCallbackSurface =
-      (void (*)(GdkWindow*, struct wl_surface*))dlsym(
-          RTLD_DEFAULT, "gdk_wayland_window_add_frame_callback_surface");
-  static auto sGdkWaylandWindowRemoveCallbackSurface =
-      (void (*)(GdkWindow*, struct wl_surface*))dlsym(
-          RTLD_DEFAULT, "gdk_wayland_window_remove_frame_callback_surface");
-
-  GdkWindow* gdkWindow = gtk_widget_get_window(GTK_WIDGET(mContainer));
-  wl_surface* containerSurface = moz_container_wayland_surface_lock(mContainer);
-
-  mSublayersOnMainThread.RemoveElementsBy([&](const auto& layer) {
-    if (!mSublayers.Contains(layer)) {
-      if (layer->IsOpaque() &&
-          StaticPrefs::widget_wayland_opaque_region_enabled_AtStartup() &&
-          sGdkWaylandWindowAddCallbackSurface && gdkWindow) {
-        wl_surface* layerSurface = layer->mNativeSurface->mWlSurface;
-
-        sGdkWaylandWindowRemoveCallbackSurface(gdkWindow, layerSurface);
-
-        wl_compositor* compositor =
-            widget::WaylandDisplayGet()->GetCompositor();
-        wl_region* region = wl_compositor_create_region(compositor);
-        wl_surface_set_opaque_region(layerSurface, region);
-        wl_region_destroy(region);
-        wl_surface_commit(layerSurface);
-      }
-      return true;
-    }
-    return false;
-  });
-
-  for (const RefPtr<NativeLayerWayland>& layer : mSublayers) {
-    if (!mSublayersOnMainThread.Contains(layer)) {
-      if (layer->IsOpaque() &&
-          StaticPrefs::widget_wayland_opaque_region_enabled_AtStartup() &&
-          sGdkWaylandWindowRemoveCallbackSurface && gdkWindow) {
-        wl_surface* layerSurface = layer->mNativeSurface->mWlSurface;
-
-        sGdkWaylandWindowAddCallbackSurface(gdkWindow, layerSurface);
-
-        wl_compositor* compositor =
-            widget::WaylandDisplayGet()->GetCompositor();
-        wl_region* region = wl_compositor_create_region(compositor);
-        wl_region_add(region, 0, 0, INT32_MAX, INT32_MAX);
-        wl_surface_set_opaque_region(layerSurface, region);
-        wl_region_destroy(region);
-        wl_surface_commit(layerSurface);
-      }
-      mSublayersOnMainThread.AppendElement(layer);
-    }
-  }
-
-  if (containerSurface) {
-    wl_surface_commit(containerSurface);
-    moz_container_wayland_surface_unlock(mContainer, &containerSurface);
-  }
-
-  GdkFrameClock* frame_clock = gdk_window_get_frame_clock(gdkWindow);
-  if (!mGdkAfterPaintId) {
-    mGdkAfterPaintId =
-        g_signal_connect_after(frame_clock, "after-paint",
-                               G_CALLBACK(sAfterFrameClockAfterPaint), this);
-  }
 }
 
 void NativeLayerRootWayland::SetBackingScale(float aBackingScale) {
   MutexAutoLock lock(mMutex);
 
   mBackingScale = aBackingScale;
   for (const RefPtr<NativeLayerWayland>& layer : mSublayers) {
     layer->SetBackingScale(aBackingScale);
@@ -368,39 +274,31 @@ bool NativeLayerRootWayland::CommitToScr
     layer->mDirtyRegion.SetEmpty();
   }
 
   if (wlSurface) {
     wl_surface_commit(wlSurface);
     moz_container_wayland_surface_unlock(mContainer, &wlSurface);
   }
 
-  wl_display_flush(widget::WaylandDisplayGet()->GetDisplay());
-
   EnsureSurfaceInitialized();
   return true;
 }
 
 void NativeLayerRootWayland::PauseCompositor() {
   MutexAutoLock lock(mMutex);
 
   for (RefPtr<NativeLayerWayland>& layer : mSublayers) {
     UnmapLayer(layer);
   }
 
-  mCompositorRunning = false;
   mShmBuffer = nullptr;
 }
 
-bool NativeLayerRootWayland::ResumeCompositor() {
-  MutexAutoLock lock(mMutex);
-
-  mCompositorRunning = true;
-  return true;
-}
+bool NativeLayerRootWayland::ResumeCompositor() { return true; }
 
 UniquePtr<NativeLayerRootSnapshotter>
 NativeLayerRootWayland::CreateSnapshotter() {
   MutexAutoLock lock(mMutex);
   return nullptr;
 }
 
 NativeLayerWayland::NativeLayerWayland(
--- a/gfx/layers/NativeLayerWayland.h
+++ b/gfx/layers/NativeLayerWayland.h
@@ -37,53 +37,47 @@ class NativeLayerRootWayland : public Na
 
   // Overridden methods
   already_AddRefed<NativeLayer> CreateLayer(
       const IntSize& aSize, bool aIsOpaque,
       SurfacePoolHandle* aSurfacePoolHandle) override;
   void AppendLayer(NativeLayer* aLayer) override;
   void RemoveLayer(NativeLayer* aLayer) override;
   void SetLayers(const nsTArray<RefPtr<NativeLayer>>& aLayers) override;
-  void UpdateLayersOnMainThread();
   UniquePtr<NativeLayerRootSnapshotter> CreateSnapshotter() override;
   bool CommitToScreen() override;
 
   // When the compositor is paused the wl_surface of the MozContainer will
   // get destroyed. We thus have to recreate subsurface relationships for
   // all tiles after resume. This is a implementation specific quirk of
   // our GTK-Wayland backend.
   void PauseCompositor() override;
   bool ResumeCompositor() override;
 
   void SetBackingScale(float aBackingScale);
   float BackingScale();
 
   already_AddRefed<NativeLayer> CreateLayerForExternalTexture(
       bool aIsOpaque) override;
 
-  void AfterFrameClockAfterPaint();
-
  protected:
   explicit NativeLayerRootWayland(MozContainer* aContainer);
   ~NativeLayerRootWayland() = default;
 
   void EnsureSurfaceInitialized();
   bool EnsureShowLayer(const RefPtr<NativeLayerWayland>& aLayer);
   void EnsureHideLayer(const RefPtr<NativeLayerWayland>& aLayer);
   void UnmapLayer(const RefPtr<NativeLayerWayland>& aLayer);
 
   Mutex mMutex;
 
   nsTArray<RefPtr<NativeLayerWayland>> mSublayers;
-  nsTArray<RefPtr<NativeLayerWayland>> mSublayersOnMainThread;
   float mBackingScale = 1.0f;
   MozContainer* mContainer = nullptr;
   RefPtr<widget::WaylandShmBuffer> mShmBuffer;
-  bool mCompositorRunning = true;
-  gulong mGdkAfterPaintId = 0;
 };
 
 class NativeLayerWayland : public NativeLayer {
  public:
   virtual NativeLayerWayland* AsNativeLayerWayland() override { return this; }
 
   // Overridden methods
   IntSize GetSize() override;
--- a/gfx/webrender_bindings/RenderCompositorNative.cpp
+++ b/gfx/webrender_bindings/RenderCompositorNative.cpp
@@ -31,17 +31,16 @@ RenderCompositorNative::RenderCompositor
   if (pool) {
     mSurfacePoolHandle = pool->GetHandleForGL(aGL);
   }
 #endif
   MOZ_RELEASE_ASSERT(mSurfacePoolHandle);
 }
 
 RenderCompositorNative::~RenderCompositorNative() {
-  Pause();
   mProfilerScreenshotGrabber.Destroy();
   mNativeLayerRoot->SetLayers({});
   mNativeLayerForEntireWindow = nullptr;
   mNativeLayerRootSnapshotter = nullptr;
   mNativeLayerRoot = nullptr;
 }
 
 bool RenderCompositorNative::BeginFrame() {