Bug 1716796 [Wayland] Poll mozcontainer remap state, r=rmader

- Poll mozcontainer remap state by moz_container_wayland_remapped()
- Remove WindowSurface::Reset()
- Remove moz_container_wayland_set_window_surface() as it adds extra ref at WindowSurface() and causes cyclic dependency.

Differential Revision: https://phabricator.services.mozilla.com/D118272
This commit is contained in:
stransky 2021-06-19 09:33:19 +00:00
Родитель 192a45a34e
Коммит 0d56f086b9
6 изменённых файлов: 17 добавлений и 33 удалений

Просмотреть файл

@ -180,6 +180,7 @@ void moz_container_wayland_init(MozContainerWayland* container) {
container->opaque_region_subtract_corners = false;
container->opaque_region_used = false;
container->surface_needs_clear = true;
container->container_remapped = true;
container->subsurface_dx = 0;
container->subsurface_dy = 0;
container->before_first_size_alloc = true;
@ -297,6 +298,7 @@ static void moz_container_wayland_unmap_internal(MozContainer* container) {
wl_container->surface_needs_clear = true;
wl_container->ready_to_draw = false;
wl_container->buffer_scale = 1;
wl_container->container_remapped = true;
}
static gboolean moz_container_wayland_map_event(GtkWidget* widget,
@ -505,10 +507,6 @@ static bool moz_container_wayland_surface_create_locked(
}
wl_subsurface_set_desync(wl_container->subsurface);
if (wl_container->window_surface) {
wl_container->window_surface->Reset();
}
// Try to guess subsurface offset to avoid potential flickering.
int dx, dy;
if (moz_container_get_nsWindow(container)->GetCSDDecorationOffset(&dx, &dy)) {
@ -601,6 +599,12 @@ gboolean moz_container_wayland_surface_needs_clear(MozContainer* container) {
return ret;
}
gboolean moz_container_wayland_get_and_reset_remapped(MozContainer* container) {
int ret = container->wl_container.container_remapped;
container->wl_container.container_remapped = false;
return ret;
}
void moz_container_wayland_update_opaque_region(MozContainer* container,
bool aSubtractCorners) {
MozContainerWayland* wl_container = &container->wl_container;
@ -638,9 +642,3 @@ struct wp_viewport* moz_container_wayland_get_viewport(
}
return wl_container->viewport;
}
void moz_container_wayland_set_window_surface(
MozContainer* container, RefPtr<WindowSurface> window_surface) {
MozContainerWayland* wl_container = &container->wl_container;
wl_container->window_surface = window_surface;
}

Просмотреть файл

@ -45,8 +45,8 @@ struct MozContainerWayland {
gboolean surface_needs_clear;
gboolean ready_to_draw;
gboolean before_first_size_alloc;
gboolean container_remapped;
int buffer_scale;
RefPtr<mozilla::widget::WindowSurface> window_surface;
std::vector<std::function<void(void)>> initial_draw_cbs;
// mozcontainer is used from Compositor and Rendering threads
// so we need to control access to mozcontainer where wayland internals
@ -82,7 +82,6 @@ void moz_container_wayland_update_opaque_region(MozContainer* container,
gboolean moz_container_wayland_can_draw(MozContainer* container);
double moz_container_wayland_get_scale(MozContainer* container);
struct wp_viewport* moz_container_wayland_get_viewport(MozContainer* container);
void moz_container_wayland_set_window_surface(
MozContainer* container,
RefPtr<mozilla::widget::WindowSurface> window_surface);
gboolean moz_container_wayland_get_and_reset_remapped(MozContainer* container);
#endif /* __MOZ_CONTAINER_WAYLAND_H__ */

Просмотреть файл

@ -31,10 +31,6 @@ class WindowSurface {
// Whether the window surface represents a fallback method.
virtual bool IsFallback() const { return false; }
// Reset internal states (stored surfaces etc.) as attached
// Gtk widget was hidden/shown. Used on Wayland only.
virtual void Reset() {}
protected:
virtual ~WindowSurface() = default;
};

Просмотреть файл

@ -177,8 +177,6 @@ WindowSurfaceWayland::WindowSurfaceWayland(nsWindow* aWindow)
if (currentDesktop && strstr(currentDesktop, "KDE") != nullptr) {
mSmoothRendering = CACHE_NONE;
}
MozContainer* container = mWindow->GetMozContainer();
moz_container_wayland_set_window_surface(container, this);
}
WindowSurfaceWayland::~WindowSurfaceWayland() {
@ -186,9 +184,6 @@ WindowSurfaceWayland::~WindowSurfaceWayland() {
MutexAutoLock lock(mSurfaceLock);
MozContainer* container = mWindow->GetMozContainer();
moz_container_wayland_set_window_surface(container, nullptr);
if (mSurfaceReadyTimerID) {
g_source_remove(mSurfaceReadyTimerID);
mSurfaceReadyTimerID = 0;
@ -691,6 +686,12 @@ bool WindowSurfaceWayland::FlushPendingCommitsLocked() {
wl_proxy_set_queue((struct wl_proxy*)waylandSurface,
mWaylandDisplay->GetEventQueue());
// We can't use frame callbacks from previous surfaces
if (moz_container_wayland_get_and_reset_remapped(container)) {
mLastCommittedSurfaceID = -1;
g_clear_pointer(&mFrameCallback, wl_callback_destroy);
}
// We have an active frame callback request so handle it.
if (mFrameCallback) {
int waylandSurfaceID =
@ -813,10 +814,4 @@ void WindowSurfaceWayland::BufferReleaseCallbackHandler(void* aData,
surface->BufferReleaseCallbackHandler(aBuffer);
}
void WindowSurfaceWayland::Reset() {
LOGWAYLAND(("WindowSurfaceWayland::Reset [%p]\n", this));
// No need to lock WindowSurfaceWayland here.
mLastCommittedSurfaceID = -1;
}
} // namespace mozilla::widget

Просмотреть файл

@ -57,8 +57,6 @@ class WindowSurfaceWayland : public WindowSurface {
const LayoutDeviceIntRegion& aRegion) override;
void Commit(const LayoutDeviceIntRegion& aInvalidRegion) final;
void Reset() override;
// Try to commit all queued drawings to Wayland compositor. This is usually
// called from other routines but can be used to explicitly flush
// all drawings as we do when wl_buffer is released

Просмотреть файл

@ -723,11 +723,9 @@ void nsWindow::Destroy() {
// destroys the the gl context attached to it).
DestroyCompositor();
#ifdef MOZ_X11
// Ensure any resources assigned to the window get cleaned up first
// to avoid double-freeing.
mSurfaceProvider.CleanupResources();
#endif
ClearCachedResources();