Enable Wayland backend

This commit is contained in:
Martin Stransky 2018-05-25 12:50:35 +02:00
parent 0437509b0b
commit dd0eb4d9d8
15 changed files with 3160 additions and 5 deletions

233
firefox-wayland.desktop Normal file
View File

@ -0,0 +1,233 @@
[Desktop Entry]
Version=1.0
Name=Firefox on Wayland
GenericName=Web Browser
Comment=Browse the Web
Exec=firefox-wayland %u
Icon=firefox
Terminal=false
Type=Application
MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;x-scheme-handler/http;x-scheme-handler/https;
StartupNotify=true
Categories=Network;WebBrowser;
Keywords=web;browser;internet;
Actions=new-window;new-private-window;
[Desktop Action new-window]
Name=Open a New Window
Name[ach]=Dirica manyen
Name[af]=Nuwe venster
Name[an]=Nueva finestra
Name[ar]=نافذة جديدة
Name[as]=
Name[ast]=Ventana nueva
Name[az]=Yeni Pəncərə
Name[be]=Новае акно
Name[bg]=Нов прозорец
Name[bn-BD]= (N)
Name[bn-IN]=
Name[br]=Prenestr nevez
Name[brx]= '(N)
Name[bs]=Novi prozor
Name[ca]=Finestra nova
Name[cak]=K'ak'a' tzuwäch
Name[cs]=Nové okno
Name[cy]=Ffenestr Newydd
Name[da]=Nyt vindue
Name[de]=Neues Fenster
Name[dsb]=Nowe wokno
Name[el]=Νέο παράθυρο
Name[en-GB]=New Window
Name[en-US]=New Window
Name[en-ZA]=New Window
Name[eo]=Nova fenestro
Name[es-AR]=Nueva ventana
Name[es-CL]=Nueva ventana
Name[es-ES]=Nueva ventana
Name[es-MX]=Nueva ventana
Name[et]=Uus aken
Name[eu]=Leiho berria
Name[fa]=پنجره جدید
Name[ff]=Henorde Hesere
Name[fi]=Uusi ikkuna
Name[fr]=Nouvelle fenêtre
Name[fy-NL]=Nij finster
Name[ga-IE]=Fuinneog Nua
Name[gd]=Uinneag ùr
Name[gl]=Nova xanela
Name[gn]=Ovetã pyahu
Name[gu-IN]= િ
Name[he]=חלון חדש
Name[hi-IN]= ि
Name[hr]=Novi prozor
Name[hsb]=Nowe wokno
Name[hu]=Új ablak
Name[hy-AM]=Նոր Պատուհան
Name[id]=Jendela Baru
Name[is]=Nýr gluggi
Name[it]=Nuova finestra
Name[ja]=
Name[ja-JP-mac]=
Name[ka]=
Name[kk]=Жаңа терезе
Name[km]=
Name[kn]= ಿಿ
Name[ko]=
Name[kok]=
Name[ks]=نئئ وِنڈو
Name[lij]=Neuvo barcon
Name[lo]=
Name[lt]=Naujas langas
Name[ltg]=Jauns lūgs
Name[lv]=Jauns logs
Name[mai]= ि
Name[mk]=Нов прозорец
Name[ml]=ി
Name[mr]=
Name[ms]=Tetingkap Baru
Name[my]=
Name[nb-NO]=Nytt vindu
Name[ne-NP]=
Name[nl]=Nieuw venster
Name[nn-NO]=Nytt vindauge
Name[or]= ି
Name[pa-IN]= ਿ
Name[pl]=Nowe okno
Name[pt-BR]=Nova janela
Name[pt-PT]=Nova janela
Name[rm]=Nova fanestra
Name[ro]=Fereastră nouă
Name[ru]=Новое окно
Name[sat]= ि (N)
Name[si]=
Name[sk]=Nové okno
Name[sl]=Novo okno
Name[son]=Zanfun taaga
Name[sq]=Dritare e Re
Name[sr]=Нови прозор
Name[sv-SE]=Nytt fönster
Name[ta]=ி
Name[te]= ి
Name[th]=
Name[tr]=Yeni pencere
Name[tsz]=Eraatarakua jimpani
Name[uk]=Нове вікно
Name[ur]=نیا دریچہ
Name[uz]=Yangi oyna
Name[vi]=Ca s mi
Name[wo]=Palanteer bu bees
Name[xh]=Ifestile entsha
Name[zh-CN]=
Name[zh-TW]=
Exec=firefox-wayland %u
[Desktop Action new-private-window]
Name=Open a New Private Window
Name[ach]=Dirica manyen me mung
Name[af]=Nuwe privaatvenster
Name[an]=Nueva finestra privada
Name[ar]=نافذة خاصة جديدة
Name[as]= ি
Name[ast]=Ventana privada nueva
Name[az]=Yeni Məxfi Pəncərə
Name[be]=Новае акно адасаблення
Name[bg]=Нов прозорец за поверително сърфиране
Name[bn-BD]= ি
Name[bn-IN]= ি
Name[br]=Prenestr merdeiñ prevez nevez
Name[brx]= '
Name[bs]=Novi privatni prozor
Name[ca]=Finestra privada nova
Name[cak]=K'ak'a' ichinan tzuwäch
Name[cs]=Nové anonymní okno
Name[cy]=Ffenestr Breifat Newydd
Name[da]=Nyt privat vindue
Name[de]=Neues privates Fenster
Name[dsb]=Nowe priwatne wokno
Name[el]=Νέο παράθυρο ιδιωτικής περιήγησης
Name[en-GB]=New Private Window
Name[en-US]=New Private Window
Name[en-ZA]=New Private Window
Name[eo]=Nova privata fenestro
Name[es-AR]=Nueva ventana privada
Name[es-CL]=Nueva ventana privada
Name[es-ES]=Nueva ventana privada
Name[es-MX]=Nueva ventana privada
Name[et]=Uus privaatne aken
Name[eu]=Leiho pribatu berria
Name[fa]=پنجره ناشناس جدید
Name[ff]=Henorde Suturo Hesere
Name[fi]=Uusi yksityinen ikkuna
Name[fr]=Nouvelle fenêtre de navigation privée
Name[fy-NL]=Nij priveefinster
Name[ga-IE]=Fuinneog Nua Phríobháideach
Name[gd]=Uinneag phrìobhaideach ùr
Name[gl]=Nova xanela privada
Name[gn]=Ovetã ñemi pyahu
Name[gu-IN]= િ
Name[he]=חלון פרטי חדש
Name[hi-IN]= ि ि
Name[hr]=Novi privatni prozor
Name[hsb]=Nowe priwatne wokno
Name[hu]=Új privát ablak
Name[hy-AM]=Սկսել Գաղտնի դիտարկում
Name[id]=Jendela Mode Pribadi Baru
Name[is]=Nýr huliðsgluggi
Name[it]=Nuova finestra anonima
Name[ja]=
Name[ja-JP-mac]=
Name[ka]=
Name[kk]=Жаңа жекелік терезе
Name[km]=
Name[kn]= ಿ ಿಿ
Name[ko]=
Name[kok]= ि
Name[ks]=نْو پرایوٹ وینڈو&
Name[lij]=Neuvo barcon privou
Name[lo]=
Name[lt]=Naujas privataus naršymo langas
Name[ltg]=Jauns privatais lūgs
Name[lv]=Jauns privātais logs
Name[mai]= ि ि (W)
Name[mk]=Нов приватен прозорец
Name[ml]=ി
Name[mr]= ि
Name[ms]=Tetingkap Persendirian Baharu
Name[my]=New Private Window
Name[nb-NO]=Nytt privat vindu
Name[ne-NP]= ि
Name[nl]=Nieuw privévenster
Name[nn-NO]=Nytt privat vindauge
Name[or]= ି ି
Name[pa-IN]= ਿ
Name[pl]=Nowe okno prywatne
Name[pt-BR]=Nova janela privativa
Name[pt-PT]=Nova janela privada
Name[rm]=Nova fanestra privata
Name[ro]=Fereastră privată nouă
Name[ru]=Новое приватное окно
Name[sat]= ि ि (W )
Name[si]= (W)
Name[sk]=Nové okno v režime Súkromné prehliadanie
Name[sl]=Novo zasebno okno
Name[son]=Sutura zanfun taaga
Name[sq]=Dritare e Re Private
Name[sr]=Нови приватан прозор
Name[sv-SE]=Nytt privat fönster
Name[ta]=ி ி
Name[te]= ి ి
Name[th]=
Name[tr]=Yeni gizli pencere
Name[tsz]=Juchiiti eraatarakua jimpani
Name[uk]=Приватне вікно
Name[ur]=نیا نجی دریچہ
Name[uz]=Yangi maxfiy oyna
Name[vi]=Ca s riêng tư mi
Name[wo]=Panlanteeru biir bu bees
Name[xh]=Ifestile yangasese entsha
Name[zh-CN]=
Name[zh-TW]=
Exec=firefox-wayland --private-window %u

View File

@ -6,7 +6,7 @@
# for details.
#
# Build with Wayland Gtk+ backend?
%global wayland_backend 0
%global wayland_backend 1
# Use system hunspell?
%if 0%{?fedora} > 25
@ -102,7 +102,7 @@
Summary: Mozilla Firefox Web browser
Name: firefox
Version: 60.0.1
Release: 1%{?pre_tag}%{?dist}
Release: 2%{?pre_tag}%{?dist}
URL: https://www.mozilla.org/firefox/
License: MPLv1.1 or GPLv2+ or LGPLv2+
Source0: https://hg.mozilla.org/releases/mozilla-release/archive/firefox-%{version}%{?pre_version}.source.tar.xz
@ -119,6 +119,7 @@ Source25: firefox-symbolic.svg
Source26: distribution.ini
Source27: google-api-key
Source28: firefox-wayland.sh.in
Source29: firefox-wayland.desktop
# Build patches
Patch3: mozilla-build-arm.patch
@ -162,6 +163,21 @@ Patch417: bug1375074-save-restore-x28.patch
Patch421: complete-csd-window-offset-mozilla-1457691.patch
# Wayland specific upstream patches
Patch450: mozilla-1438131.patch
Patch451: mozilla-1438136.patch
Patch452: mozilla-1460603.patch
Patch453: mozilla-1460605-1.patch
Patch454: mozilla-1460605-2.patch
Patch455: mozilla-1460810.patch
Patch456: mozilla-1461306.patch
Patch457: mozilla-1462622.patch
Patch458: mozilla-1462642.patch
Patch459: mozilla-1463753.patch
Patch560: rb244010.patch
Patch561: rb244012.patch
Patch562: rb246410.patch
# Debian patches
Patch500: mozilla-440908.patch
@ -339,6 +355,23 @@ This package contains results of tests executed during build.
%patch26 -p1 -b .icu
%endif
# Wayland specific upstream patches
%if %{?wayland_backend}
%patch453 -p1 -b .mozilla-1460605-1
%patch454 -p1 -b .mozilla-1460605-2
%patch455 -p1 -b .mozilla-1460810
%patch456 -p1 -b .mozilla-1461306
%patch457 -p1 -b .mozilla-1462622
%patch451 -p1 -b .mozilla-1438136
%patch450 -p1 -b .mozilla-1438131
%patch459 -p1 -b .mozilla-1463753
%patch458 -p1 -b .mozilla-1462642
%patch452 -p1 -b .mozilla-1460603
%patch560 -p1 -b .rb244010
%patch561 -p1 -b .rb244012
%patch562 -p1 -b .rb246410
%endif
%{__rm} -f .mozconfig
%{__cp} %{SOURCE10} .mozconfig
%if %{?wayland_backend}
@ -596,6 +629,9 @@ DESTDIR=%{buildroot} make -C objdir install
%{__mkdir_p} %{buildroot}{%{_libdir},%{_bindir},%{_datadir}/applications}
desktop-file-install --dir %{buildroot}%{_datadir}/applications %{SOURCE20}
%if %{?wayland_backend}
desktop-file-install --dir %{buildroot}%{_datadir}/applications %{SOURCE29}
%endif
# set up the firefox start script
%{__rm} -rf %{buildroot}%{_bindir}/firefox
@ -744,9 +780,6 @@ sed -i -e "s/\[Crash Reporter\]/[Crash Reporter]\nEnabled=1/" %{buildroot}/%{moz
# Default
%{__cp} %{SOURCE12} %{buildroot}%{mozappdir}/browser/defaults/preferences
%if %{?wayland_backend}
echo 'pref("webgl.force-enabled",true);' >> %{buildroot}%{mozappdir}/browser/defaults/preferences
%endif
# Copy over run-mozilla.sh
%{__cp} build/unix/run-mozilla.sh %{buildroot}%{mozappdir}
@ -873,6 +906,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
#---------------------------------------------------------------------
%changelog
* Fri May 25 2018 Martin Stransky <stransky@redhat.com> - 60.0.1-2
- Enable Wayland backend.
* Wed May 23 2018 Jan Horak <jhorak@redhat.com> - 60.0.1-1
- Update to 60.0.1

1558
mozilla-1438131.patch Normal file

File diff suppressed because it is too large Load Diff

34
mozilla-1438136.patch Normal file
View File

@ -0,0 +1,34 @@
# HG changeset patch
# User Evan Klitzke <evan@eklitzke.org>
# Date 1526337180 -10800
# Node ID 5c1d015760f220f5438ffa23a585140db7a9801d
# Parent 505667081ae29ee0a66ef5ba19c3870570b08564
Bug 1438136 - [Wayland/Clipboard] Null terminate text string returned by GetClipboardText(), r=stransky
diff --git a/widget/gtk/nsClipboardWayland.cpp b/widget/gtk/nsClipboardWayland.cpp
--- a/widget/gtk/nsClipboardWayland.cpp
+++ b/widget/gtk/nsClipboardWayland.cpp
@@ -666,19 +666,20 @@ void
nsRetrievalContextWayland::TransferFastTrackClipboard(
int aClipboardRequestNumber, GtkSelectionData *aSelectionData)
{
if (mClipboardRequestNumber == aClipboardRequestNumber) {
int dataLength = gtk_selection_data_get_length(aSelectionData);
if (dataLength > 0) {
mClipboardDataLength = dataLength;
mClipboardData = reinterpret_cast<char*>(
- g_malloc(sizeof(char)*mClipboardDataLength));
+ g_malloc(sizeof(char)*(mClipboardDataLength+1)));
memcpy(mClipboardData, gtk_selection_data_get_data(aSelectionData),
sizeof(char)*mClipboardDataLength);
+ mClipboardData[mClipboardDataLength] = '\0';
}
} else {
NS_WARNING("Received obsoleted clipboard data!");
}
}
const char*
nsRetrievalContextWayland::GetClipboardData(const char* aMimeType,

46
mozilla-1460603.patch Normal file
View File

@ -0,0 +1,46 @@
diff -up firefox-60.0.1/gfx/gl/GLLibraryEGL.cpp.mozilla-1460603 firefox-60.0.1/gfx/gl/GLLibraryEGL.cpp
--- firefox-60.0.1/gfx/gl/GLLibraryEGL.cpp.mozilla-1460603 2018-05-16 07:38:30.000000000 +0200
+++ firefox-60.0.1/gfx/gl/GLLibraryEGL.cpp 2018-05-25 10:58:45.170047851 +0200
@@ -31,6 +31,13 @@
#include "GLContextProvider.h"
#include "gfxPrefs.h"
#include "ScopedGLHelpers.h"
+#ifdef MOZ_WIDGET_GTK
+#include <gdk/gdk.h>
+#ifdef MOZ_WAYLAND
+#include <gdk/gdkwayland.h>
+#include <dlfcn.h>
+#endif // MOZ_WIDGET_GTK
+#endif // MOZ_WAYLAND
namespace mozilla {
namespace gl {
@@ -566,7 +573,22 @@ GLLibraryEGL::EnsureInitialized(bool for
mIsWARP = true;
}
} else {
- chosenDisplay = GetAndInitDisplay(*this, EGL_DEFAULT_DISPLAY);
+ void *nativeDisplay = EGL_DEFAULT_DISPLAY;
+#ifdef MOZ_WAYLAND
+ // Some drivers doesn't support EGL_DEFAULT_DISPLAY
+ GdkDisplay *gdkDisplay = gdk_display_get_default();
+ if (GDK_IS_WAYLAND_DISPLAY(gdkDisplay)) {
+ static auto sGdkWaylandDisplayGetWlDisplay =
+ (wl_display *(*)(GdkDisplay *))
+ dlsym(RTLD_DEFAULT, "gdk_wayland_display_get_wl_display");
+ nativeDisplay = sGdkWaylandDisplayGetWlDisplay(gdkDisplay);
+ if (!nativeDisplay) {
+ NS_WARNING("Failed to get wl_display.");
+ return false;
+ }
+ }
+#endif
+ chosenDisplay = GetAndInitDisplay(*this, nativeDisplay);
}
if (!chosenDisplay) {
@@ -872,4 +894,3 @@ AfterEGLCall(const char* glFunction)
} /* namespace gl */
} /* namespace mozilla */
-

40
mozilla-1460605-1.patch Normal file
View File

@ -0,0 +1,40 @@
# HG changeset patch
# User Martin Stransky <stransky@redhat.com>
# Date 1525961643 -7200
# Node ID c085f9360dfa4d0fc3d04d6db40d37e1369616b3
# Parent acaaa40ebdf142fda38d5661f7631f029a2406c6
Bug 1460605 - Use NS_NATIVE_EGL_WINDOW instead of NS_NATIVE_WINDOW on GTK r=lsalzman
Original patch author is Takuro Ashie <ashie@clear-code.com>
NS_NATIVE_EGL_WINDOW is exported by Gtk toolkit code and provides both X11 window
handle for X11 Gtk backend and EGL window handle for Wayland backend.
MozReview-Commit-ID: DEmlaLL7zGY
diff --git a/gfx/gl/GLContextProviderEGL.cpp b/gfx/gl/GLContextProviderEGL.cpp
--- a/gfx/gl/GLContextProviderEGL.cpp
+++ b/gfx/gl/GLContextProviderEGL.cpp
@@ -1,18 +1,16 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* 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/. */
#if defined(MOZ_WIDGET_GTK)
- #include <gdk/gdkx.h>
- // we're using default display for now
- #define GET_NATIVE_WINDOW_FROM_REAL_WIDGET(aWidget) ((EGLNativeWindowType)GDK_WINDOW_XID((GdkWindow*)aWidget->GetNativeData(NS_NATIVE_WINDOW)))
- #define GET_NATIVE_WINDOW_FROM_COMPOSITOR_WIDGET(aWidget) ((EGLNativeWindowType)GDK_WINDOW_XID((GdkWindow*)aWidget->RealWidget()->GetNativeData(NS_NATIVE_WINDOW)))
+ #define GET_NATIVE_WINDOW_FROM_REAL_WIDGET(aWidget) ((EGLNativeWindowType)aWidget->GetNativeData(NS_NATIVE_EGL_WINDOW))
+ #define GET_NATIVE_WINDOW_FROM_COMPOSITOR_WIDGET(aWidget) ((EGLNativeWindowType)aWidget->RealWidget()->GetNativeData(NS_NATIVE_EGL_WINDOW))
#elif defined(MOZ_WIDGET_ANDROID)
#define GET_NATIVE_WINDOW_FROM_REAL_WIDGET(aWidget) ((EGLNativeWindowType)aWidget->GetNativeData(NS_JAVA_SURFACE))
#define GET_NATIVE_WINDOW_FROM_COMPOSITOR_WIDGET(aWidget) (aWidget->AsAndroid()->GetEGLNativeWindow())
#elif defined(XP_WIN)
#define GET_NATIVE_WINDOW_FROM_REAL_WIDGET(aWidget) ((EGLNativeWindowType)aWidget->GetNativeData(NS_NATIVE_WINDOW))
#define GET_NATIVE_WINDOW_FROM_COMPOSITOR_WIDGET(aWidget) ((EGLNativeWindowType)aWidget->AsWindows()->GetHwnd())
#else
#define GET_NATIVE_WINDOW_FROM_REAL_WIDGET(aWidget) ((EGLNativeWindowType)aWidget->GetNativeData(NS_NATIVE_WINDOW))

292
mozilla-1460605-2.patch Normal file
View File

@ -0,0 +1,292 @@
# HG changeset patch
# User Martin Stransky <stransky@redhat.com>
# Date 1525961060 -7200
# Node ID acaaa40ebdf142fda38d5661f7631f029a2406c6
# Parent 5543294befe9494593370f33c40ba50c8239e0c6
Bug 1460605 - Provide NS_NATIVE_EGL_WINDOW to get a native EGL window on Wayland, r=jhorak
Original patch author is Takuro Ashie <ashie@clear-code.com>
Provide ability to create native EGL window and provide it under NS_NATIVE_EGL_WINDOW
to GL code. The native EGL window is owned/managed by mozcontainer.
MozReview-Commit-ID: 4d0Kk6DRSaD
diff --git a/config/system-headers.mozbuild b/config/system-headers.mozbuild
--- a/config/system-headers.mozbuild
+++ b/config/system-headers.mozbuild
@@ -1334,8 +1334,14 @@ if CONFIG['MOZ_SYSTEM_ICU']:
'unicode/unistr.h',
'unicode/unorm.h',
'unicode/unum.h',
'unicode/upluralrules.h',
'unicode/ureldatefmt.h',
'unicode/ustring.h',
'unicode/utypes.h',
]
+
+if CONFIG['MOZ_WAYLAND']:
+ system_headers += [
+ 'wayland-client.h',
+ 'wayland-egl.h',
+ ]
diff --git a/widget/gtk/mozcontainer.cpp b/widget/gtk/mozcontainer.cpp
--- a/widget/gtk/mozcontainer.cpp
+++ b/widget/gtk/mozcontainer.cpp
@@ -5,16 +5,17 @@
* 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 "mozcontainer.h"
#include <gtk/gtk.h>
#ifdef MOZ_WAYLAND
#include <gdk/gdkx.h>
#include <gdk/gdkwayland.h>
+#include <wayland-egl.h>
#endif
#include <stdio.h>
#include <dlfcn.h>
#ifdef ACCESSIBILITY
#include <atk/atk.h>
#include "maiRedundantObjectFactory.h"
#endif
@@ -202,16 +203,21 @@ void
moz_container_init (MozContainer *container)
{
gtk_widget_set_can_focus(GTK_WIDGET(container), TRUE);
gtk_container_set_resize_mode(GTK_CONTAINER(container), GTK_RESIZE_IMMEDIATE);
gtk_widget_set_redraw_on_allocate(GTK_WIDGET(container), FALSE);
#if defined(MOZ_WAYLAND)
{
+ container->subcompositor = nullptr;
+ container->surface = nullptr;
+ container->subsurface = nullptr;
+ container->eglwindow = nullptr;
+
GdkDisplay *gdk_display = gtk_widget_get_display(GTK_WIDGET(container));
if (GDK_IS_WAYLAND_DISPLAY (gdk_display)) {
// Available as of GTK 3.8+
static auto sGdkWaylandDisplayGetWlDisplay =
(wl_display *(*)(GdkDisplay *))
dlsym(RTLD_DEFAULT, "gdk_wayland_display_get_wl_display");
wl_display* display = sGdkWaylandDisplayGetWlDisplay(gdk_display);
@@ -284,16 +290,17 @@ moz_container_map_surface(MozContainer *
wl_region_destroy(region);
}
return true;
}
static void
moz_container_unmap_surface(MozContainer *container)
{
+ g_clear_pointer(&container->eglwindow, wl_egl_window_destroy);
g_clear_pointer(&container->subsurface, wl_subsurface_destroy);
g_clear_pointer(&container->surface, wl_surface_destroy);
}
#endif
void
moz_container_map (GtkWidget *widget)
@@ -429,16 +436,21 @@ moz_container_size_allocate (GtkWidget
// We need to position our subsurface according to GdkWindow
// when offset changes (GdkWindow is maximized for instance).
// see gtk-clutter-embed.c for reference.
if (container->subsurface) {
gint x, y;
gdk_window_get_position(gtk_widget_get_window(widget), &x, &y);
wl_subsurface_set_position(container->subsurface, x, y);
}
+ if (container->eglwindow) {
+ wl_egl_window_resize(container->eglwindow,
+ allocation->width, allocation->height,
+ 0, 0);
+ }
#endif
}
void
moz_container_remove (GtkContainer *container, GtkWidget *child_widget)
{
MozContainerChild *child;
MozContainer *moz_container;
@@ -554,9 +566,32 @@ moz_container_get_wl_surface(MozContaine
if (!gdk_window_is_visible(window))
return nullptr;
moz_container_map_surface(container);
}
return container->surface;
}
+
+struct wl_egl_window *
+moz_container_get_wl_egl_window(MozContainer *container)
+{
+ if (!container->eglwindow) {
+ struct wl_surface *wlsurf = moz_container_get_wl_surface(container);
+ if (!wlsurf)
+ return nullptr;
+
+ GdkWindow *window = gtk_widget_get_window(GTK_WIDGET(container));
+ container->eglwindow
+ = wl_egl_window_create(wlsurf,
+ gdk_window_get_width(window),
+ gdk_window_get_height(window));
+ }
+ return container->eglwindow;
+}
+
+gboolean
+moz_container_has_wl_egl_window(MozContainer *container)
+{
+ return container->eglwindow ? true : false;
+}
#endif
diff --git a/widget/gtk/mozcontainer.h b/widget/gtk/mozcontainer.h
--- a/widget/gtk/mozcontainer.h
+++ b/widget/gtk/mozcontainer.h
@@ -67,16 +67,17 @@ struct _MozContainer
{
GtkContainer container;
GList *children;
#ifdef MOZ_WAYLAND
struct wl_subcompositor *subcompositor;
struct wl_surface *surface;
struct wl_subsurface *subsurface;
+ struct wl_egl_window *eglwindow;
#endif
};
struct _MozContainerClass
{
GtkContainerClass parent_class;
};
@@ -90,11 +91,13 @@ void moz_container_move (
GtkWidget *child_widget,
gint x,
gint y,
gint width,
gint height);
#ifdef MOZ_WAYLAND
struct wl_surface* moz_container_get_wl_surface(MozContainer *container);
+struct wl_egl_window* moz_container_get_wl_egl_window(MozContainer *container);
+gboolean moz_container_has_wl_egl_window(MozContainer *container);
#endif
#endif /* __MOZ_CONTAINER_H__ */
diff --git a/widget/gtk/mozwayland/mozwayland.c b/widget/gtk/mozwayland/mozwayland.c
--- a/widget/gtk/mozwayland/mozwayland.c
+++ b/widget/gtk/mozwayland/mozwayland.c
@@ -266,8 +266,26 @@ wl_display_read_events(struct wl_display
return -1;
}
MOZ_EXPORT void
wl_log_set_handler_client(wl_log_func_t handler)
{
}
+MOZ_EXPORT struct wl_egl_window *
+wl_egl_window_create(struct wl_surface *surface,
+ int width, int height)
+{
+ return NULL;
+}
+
+MOZ_EXPORT void
+wl_egl_window_destroy(struct wl_egl_window *egl_window)
+{
+}
+
+MOZ_EXPORT void
+wl_egl_window_resize(struct wl_egl_window *egl_window,
+ int width, int height,
+ int dx, int dy)
+{
+}
diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -1734,16 +1734,25 @@ nsWindow::GetNativeData(uint32_t aDataTy
return mIMContext.get();
}
case NS_NATIVE_OPENGL_CONTEXT:
return nullptr;
#ifdef MOZ_X11
case NS_NATIVE_COMPOSITOR_DISPLAY:
return gfxPlatformGtk::GetPlatform()->GetCompositorDisplay();
#endif // MOZ_X11
+ case NS_NATIVE_EGL_WINDOW: {
+ if (mIsX11Display)
+ return mGdkWindow ? (void*)GDK_WINDOW_XID(mGdkWindow) : nullptr;
+#ifdef MOZ_WAYLAND
+ if (mContainer)
+ return moz_container_get_wl_egl_window(mContainer);
+#endif
+ return nullptr;
+ }
default:
NS_WARNING("nsWindow::GetNativeData called with bad value");
return nullptr;
}
}
nsresult
nsWindow::SetTitle(const nsAString& aTitle)
@@ -4303,16 +4312,26 @@ nsWindow::NativeShow(bool aAction)
else if (mContainer) {
gtk_widget_show(GTK_WIDGET(mContainer));
}
else if (mGdkWindow) {
gdk_window_show_unraised(mGdkWindow);
}
}
else {
+#ifdef MOZ_WAYLAND
+ if (mContainer && moz_container_has_wl_egl_window(mContainer)) {
+ // Because wl_egl_window is destroyed on moz_container_unmap(),
+ // the current compositor cannot use it anymore. To avoid crash,
+ // destroy the compositor & recreate a new compositor on next
+ // expose event.
+ DestroyLayerManager();
+ }
+#endif
+
if (mIsTopLevel) {
// Workaround window freezes on GTK versions before 3.21.2 by
// ensuring that configure events get dispatched to windows before
// they are unmapped. See bug 1225044.
if (gtk_check_version(3, 21, 2) != nullptr && mPendingConfigures > 0) {
GtkAllocation allocation;
gtk_widget_get_allocation(GTK_WIDGET(mShell), &allocation);
diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h
--- a/widget/nsIWidget.h
+++ b/widget/nsIWidget.h
@@ -138,16 +138,17 @@ typedef void* nsNativeWidget;
#define NS_NATIVE_CHILD_OF_SHAREABLE_WINDOW 105
#endif
#if defined(MOZ_WIDGET_GTK)
// set/get nsPluginNativeWindowGtk, e10s specific
#define NS_NATIVE_PLUGIN_OBJECT_PTR 104
#ifdef MOZ_X11
#define NS_NATIVE_COMPOSITOR_DISPLAY 105
#endif // MOZ_X11
+#define NS_NATIVE_EGL_WINDOW 106
#endif
#ifdef MOZ_WIDGET_ANDROID
#define NS_JAVA_SURFACE 100
#define NS_PRESENTATION_WINDOW 101
#define NS_PRESENTATION_SURFACE 102
#endif
// Must be kept in sync with xpcom/rust/xpcom/src/interfaces/nonidl.rs

30
mozilla-1460810.patch Normal file
View File

@ -0,0 +1,30 @@
# HG changeset patch
# User Evan Klitzke <evan@eklitzke.org>
# Parent c5e0ee17388381f96d0acf4bdd9d163827719096
Bug 1460810 - [Gtk/Wayland] Handle error value (-1) returned by gtk_section_data_get_length(), r=stransky
diff --git a/widget/gtk/nsClipboardWayland.cpp b/widget/gtk/nsClipboardWayland.cpp
--- a/widget/gtk/nsClipboardWayland.cpp
+++ b/widget/gtk/nsClipboardWayland.cpp
@@ -662,18 +662,19 @@ wayland_clipboard_contents_received(GtkC
delete fastTrack;
}
void
nsRetrievalContextWayland::TransferFastTrackClipboard(
int aClipboardRequestNumber, GtkSelectionData *aSelectionData)
{
if (mClipboardRequestNumber == aClipboardRequestNumber) {
- mClipboardDataLength = gtk_selection_data_get_length(aSelectionData);
- if (mClipboardDataLength > 0) {
+ int dataLength = gtk_selection_data_get_length(aSelectionData);
+ if (dataLength > 0) {
+ mClipboardDataLength = dataLength;
mClipboardData = reinterpret_cast<char*>(
g_malloc(sizeof(char)*mClipboardDataLength));
memcpy(mClipboardData, gtk_selection_data_get_data(aSelectionData),
sizeof(char)*mClipboardDataLength);
}
} else {
NS_WARNING("Received obsoleted clipboard data!");
}

33
mozilla-1461306.patch Normal file
View File

@ -0,0 +1,33 @@
# HG changeset patch
# User Martin Stransky <stransky@redhat.com>
# Date 1526299286 -7200
# Node ID 6495ae9d01e06109539413c538fd25ed942f6eb8
# Parent 67553a1262de53d0ec85fdfcf1a2b55631eaca44
Bug 1461306 - [Wayland] Don't use sizeof() to get mime type array size, r=jhorak
MozReview-Commit-ID: GE5helkqoUt
diff --git a/widget/gtk/nsClipboardWayland.cpp b/widget/gtk/nsClipboardWayland.cpp
--- a/widget/gtk/nsClipboardWayland.cpp
+++ b/widget/gtk/nsClipboardWayland.cpp
@@ -723,17 +723,17 @@ const char*
nsRetrievalContextWayland::GetClipboardText(int32_t aWhichClipboard)
{
GdkAtom selection = GetSelectionAtom(aWhichClipboard);
DataOffer* dataOffer = (selection == GDK_SELECTION_PRIMARY) ?
mPrimaryOffer : mClipboardOffer;
if (!dataOffer)
return nullptr;
- for (unsigned int i = 0; i < sizeof(sTextMimeTypes); i++) {
+ for (unsigned int i = 0; i < TEXT_MIME_TYPES_NUM; i++) {
if (dataOffer->HasTarget(sTextMimeTypes[i])) {
uint32_t unused;
return GetClipboardData(sTextMimeTypes[i], aWhichClipboard,
&unused);
}
}
return nullptr;
}

36
mozilla-1462622.patch Normal file
View File

@ -0,0 +1,36 @@
# HG changeset patch
# User Martin Stransky <stransky@redhat.com>
# Date 1526647470 -7200
# Node ID d41fee41e38400fab5da0689c1f49e30f80e2d1b
# Parent d2b91476bebc48f9e89f9d3e6c7b33decb2ae941
Bug 1462622 - [Gtk/Linux] Don't use GLXVsyncSource() on non-X11 displays, r=lsalzman
MozReview-Commit-ID: BBtnNLWqSiq
diff --git a/gfx/thebes/gfxPlatformGtk.cpp b/gfx/thebes/gfxPlatformGtk.cpp
--- a/gfx/thebes/gfxPlatformGtk.cpp
+++ b/gfx/thebes/gfxPlatformGtk.cpp
@@ -736,18 +736,20 @@ private:
};
already_AddRefed<gfx::VsyncSource>
gfxPlatformGtk::CreateHardwareVsyncSource()
{
// Only use GLX vsync when the OpenGL compositor is being used.
// The extra cost of initializing a GLX context while blocking the main
// thread is not worth it when using basic composition.
+ // Also don't use it on non-X11 displays.
if (gfxConfig::IsEnabled(Feature::HW_COMPOSITING)) {
- if (gl::sGLXLibrary.SupportsVideoSync()) {
+ if (GDK_IS_X11_DISPLAY(gdk_display_get_default()) &&
+ gl::sGLXLibrary.SupportsVideoSync()) {
RefPtr<VsyncSource> vsyncSource = new GLXVsyncSource();
VsyncSource::Display& display = vsyncSource->GetGlobalDisplay();
if (!static_cast<GLXVsyncSource::GLXDisplay&>(display).Setup()) {
NS_WARNING("Failed to setup GLContext, falling back to software vsync.");
return gfxPlatform::CreateHardwareVsyncSource();
}
return vsyncSource.forget();
}

183
mozilla-1462642.patch Normal file
View File

@ -0,0 +1,183 @@
diff -up firefox-60.0.1/gfx/gl/GLContextEGL.h.mozilla-1462642 firefox-60.0.1/gfx/gl/GLContextEGL.h
--- firefox-60.0.1/gfx/gl/GLContextEGL.h.mozilla-1462642 2018-05-16 07:38:29.000000000 +0200
+++ firefox-60.0.1/gfx/gl/GLContextEGL.h 2018-05-25 10:54:09.271902218 +0200
@@ -133,6 +133,10 @@ protected:
static EGLSurface CreatePBufferSurfaceTryingPowerOfTwo(EGLConfig config,
EGLenum bindToTextureFormat,
gfx::IntSize& pbsize);
+#if defined(MOZ_WAYLAND)
+ static EGLSurface CreateWaylandBufferSurface(EGLConfig config,
+ gfx::IntSize& pbsize);
+#endif
#if defined(MOZ_WIDGET_ANDROID)
public:
EGLSurface CreateCompatibleSurface(void* aWindow);
diff -up firefox-60.0.1/gfx/gl/GLContextProviderEGL.cpp.mozilla-1462642 firefox-60.0.1/gfx/gl/GLContextProviderEGL.cpp
--- firefox-60.0.1/gfx/gl/GLContextProviderEGL.cpp.mozilla-1462642 2018-05-25 10:54:09.258902265 +0200
+++ firefox-60.0.1/gfx/gl/GLContextProviderEGL.cpp 2018-05-25 10:55:57.634553279 +0200
@@ -63,6 +63,17 @@
#include "ScopedGLHelpers.h"
#include "TextureImageEGL.h"
+#if defined(MOZ_WAYLAND)
+#include "nsAutoPtr.h"
+#include "nsDataHashtable.h"
+
+#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
+#include <gdk/gdkwayland.h>
+#include <wayland-egl.h>
+#include <dlfcn.h>
+#endif
+
using namespace mozilla::gfx;
namespace mozilla {
@@ -70,6 +81,35 @@ namespace gl {
using namespace mozilla::widget;
+#if defined(MOZ_WAYLAND)
+class WaylandGLSurface {
+public:
+ WaylandGLSurface(struct wl_surface *aWaylandSurface,
+ struct wl_egl_window *aEGLWindow);
+ ~WaylandGLSurface();
+private:
+ struct wl_surface *mWaylandSurface;
+ struct wl_egl_window *mEGLWindow;
+};
+
+static nsDataHashtable<nsPtrHashKey<void>, WaylandGLSurface*>
+ sWaylandGLSurface;
+
+void
+DeleteWaylandGLSurface(EGLSurface surface)
+{
+ // We're running on Wayland which means our EGLSurface may
+ // have attached Wayland backend data which must be released.
+ if (GDK_IS_WAYLAND_DISPLAY(gdk_display_get_default())) {
+ auto entry = sWaylandGLSurface.Lookup(surface);
+ if (entry) {
+ delete entry.Data();
+ entry.Remove();
+ }
+ }
+}
+#endif
+
#define ADD_ATTR_2(_array, _k, _v) do { \
(_array).AppendElement(_k); \
(_array).AppendElement(_v); \
@@ -125,6 +165,9 @@ DestroySurface(EGLSurface oldSurface) {
EGL_NO_SURFACE, EGL_NO_SURFACE,
EGL_NO_CONTEXT);
sEGLLibrary.fDestroySurface(EGL_DISPLAY(), oldSurface);
+#if defined(MOZ_WAYLAND)
+ DeleteWaylandGLSurface(oldSurface);
+#endif
}
}
@@ -588,6 +631,52 @@ TRY_AGAIN_POWER_OF_TWO:
return surface;
}
+#if defined(MOZ_WAYLAND)
+WaylandGLSurface::WaylandGLSurface(struct wl_surface *aWaylandSurface,
+ struct wl_egl_window *aEGLWindow)
+ : mWaylandSurface(aWaylandSurface)
+ , mEGLWindow(aEGLWindow)
+{
+}
+
+WaylandGLSurface::~WaylandGLSurface()
+{
+ wl_egl_window_destroy(mEGLWindow);
+ wl_surface_destroy(mWaylandSurface);
+}
+
+EGLSurface
+GLContextEGL::CreateWaylandBufferSurface(EGLConfig config,
+ mozilla::gfx::IntSize& pbsize)
+{
+ // Available as of GTK 3.8+
+ static auto sGdkWaylandDisplayGetWlCompositor =
+ (wl_compositor *(*)(GdkDisplay *))
+ dlsym(RTLD_DEFAULT, "gdk_wayland_display_get_wl_compositor");
+
+ if (!sGdkWaylandDisplayGetWlCompositor)
+ return nullptr;
+
+ struct wl_compositor *compositor =
+ sGdkWaylandDisplayGetWlCompositor(gdk_display_get_default());
+ struct wl_surface *wlsurface = wl_compositor_create_surface(compositor);
+ struct wl_egl_window *eglwindow =
+ wl_egl_window_create(wlsurface, pbsize.width, pbsize.height);
+
+ EGLSurface surface =
+ sEGLLibrary.fCreateWindowSurface(EGL_DISPLAY(), config, eglwindow, 0);
+
+ if (surface) {
+ WaylandGLSurface* waylandData =
+ new WaylandGLSurface(wlsurface, eglwindow);
+ auto entry = sWaylandGLSurface.LookupForAdd(surface);
+ entry.OrInsert([&waylandData](){ return waylandData; });
+ }
+
+ return surface;
+}
+#endif
+
static const EGLint kEGLConfigAttribsOffscreenPBuffer[] = {
LOCAL_EGL_SURFACE_TYPE, LOCAL_EGL_PBUFFER_BIT,
LOCAL_EGL_RENDERABLE_TYPE, LOCAL_EGL_OPENGL_ES2_BIT,
@@ -807,7 +896,17 @@ FillContextAttribs(bool alpha, bool dept
bool es3, nsTArray<EGLint>* out)
{
out->AppendElement(LOCAL_EGL_SURFACE_TYPE);
+#if defined(MOZ_WAYLAND)
+ if (GDK_IS_WAYLAND_DISPLAY(gdk_display_get_default())) {
+ // Wayland on desktop does not support PBuffer or FBO.
+ // We create a dummy wl_egl_window instead.
+ out->AppendElement(LOCAL_EGL_WINDOW_BIT);
+ } else {
+ out->AppendElement(LOCAL_EGL_PBUFFER_BIT);
+ }
+#else
out->AppendElement(LOCAL_EGL_PBUFFER_BIT);
+#endif
out->AppendElement(LOCAL_EGL_RENDERABLE_TYPE);
if (es3) {
@@ -926,9 +1025,17 @@ GLContextEGL::CreateEGLPBufferOffscreenC
}
mozilla::gfx::IntSize pbSize(size);
- EGLSurface surface = GLContextEGL::CreatePBufferSurfaceTryingPowerOfTwo(config,
- LOCAL_EGL_NONE,
- pbSize);
+ EGLSurface surface = nullptr;
+#if defined(MOZ_WAYLAND)
+ if (GDK_IS_WAYLAND_DISPLAY(gdk_display_get_default())) {
+ surface = GLContextEGL::CreateWaylandBufferSurface(config, pbSize);
+ } else
+#endif
+ {
+ surface = GLContextEGL::CreatePBufferSurfaceTryingPowerOfTwo(config,
+ LOCAL_EGL_NONE,
+ pbSize);
+ }
if (!surface) {
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_POT");
NS_WARNING("Failed to create PBuffer for context!");
@@ -941,6 +1048,9 @@ GLContextEGL::CreateEGLPBufferOffscreenC
if (!gl) {
NS_WARNING("Failed to create GLContext from PBuffer");
sEGLLibrary.fDestroySurface(sEGLLibrary.Display(), surface);
+#if defined(MOZ_WAYLAND)
+ DeleteWaylandGLSurface(surface);
+#endif
return nullptr;
}

127
mozilla-1463753.patch Normal file
View File

@ -0,0 +1,127 @@
# HG changeset patch
# User Martin Stransky <stransky@redhat.com>
# Date 1527155477 -7200
# Node ID 172827af80fa02953e0c7723c0dee915c411c286
# Parent a5c04fe7278db916b3efd5f06a5f2a9da0d64ad2
Bug 1463753 - [DragAndDrop] Update mTarget(Wayland)DragContext unconditionally and check its validity after that, r=jhorak
MozReview-Commit-ID: KiNaPDDVvLu
diff --git a/widget/gtk/nsDragService.cpp b/widget/gtk/nsDragService.cpp
--- a/widget/gtk/nsDragService.cpp
+++ b/widget/gtk/nsDragService.cpp
@@ -1043,21 +1043,21 @@ nsDragService::IsDataFlavorSupported(con
}
// check the target context vs. this flavor, one at a time
GList *tmp = nullptr;
if (mTargetDragContext) {
tmp = gdk_drag_context_list_targets(mTargetDragContext);
}
#ifdef MOZ_WAYLAND
- else {
+ else if (mTargetWaylandDragContext) {
tmp = mTargetWaylandDragContext->GetTargets();
}
+ GList *tmp_head = tmp;
#endif
- GList *tmp_head = tmp;
for (; tmp; tmp = tmp->next) {
/* Bug 331198 */
GdkAtom atom = GDK_POINTER_TO_ATOM(tmp->data);
gchar *name = nullptr;
name = gdk_atom_name(atom);
MOZ_LOG(sDragLm, LogLevel::Debug,
("checking %s against %s\n", name, aDataFlavor));
@@ -1095,21 +1095,23 @@ nsDragService::IsDataFlavorSupported(con
MOZ_LOG(sDragLm, LogLevel::Debug,
("good! ( it's text plain and we're checking \
against text/unicode or application/x-moz-file)\n"));
*_retval = true;
}
g_free(name);
}
+#ifdef MOZ_WAYLAND
// mTargetWaylandDragContext->GetTargets allocates the list
// so we need to free it here.
- if (!mTargetDragContext) {
+ if (!mTargetDragContext && tmp_head) {
g_list_free(tmp_head);
}
+#endif
return NS_OK;
}
void
nsDragService::ReplyToDragMotion(GdkDragContext* aDragContext)
{
MOZ_LOG(sDragLm, LogLevel::Debug,
@@ -2007,23 +2009,19 @@ nsDragService::RunScheduledTask()
// This may be the start of a destination drag session.
StartDragSession();
// mTargetWidget may be nullptr if the window has been destroyed.
// (The leave event is not scheduled if a drop task is still scheduled.)
// We still reply appropriately to indicate that the drop will or didn't
// succeeed.
mTargetWidget = mTargetWindow->GetMozContainerWidget();
- if (mTargetDragContext) {
- mTargetDragContext.steal(mPendingDragContext);
- }
+ mTargetDragContext.steal(mPendingDragContext);
#ifdef MOZ_WAYLAND
- else {
- mTargetWaylandDragContext = mPendingWaylandDragContext.forget();
- }
+ mTargetWaylandDragContext = mPendingWaylandDragContext.forget();
#endif
mTargetTime = mPendingTime;
// http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#drag-and-drop-processing-model
// (as at 27 December 2010) indicates that a "drop" event should only be
// fired (at the current target element) if the current drag operation is
// not none. The current drag operation will only be set to a non-none
// value during a "dragover" event.
@@ -2056,17 +2054,17 @@ nsDragService::RunScheduledTask()
#endif
} else {
// Reply to tell the source whether we can drop and what
// action would be taken.
if (mTargetDragContext) {
ReplyToDragMotion(mTargetDragContext);
}
#ifdef MOZ_WAYLAND
- else {
+ else if (mTargetWaylandDragContext) {
ReplyToDragMotion(mTargetWaylandDragContext);
}
#endif
}
}
}
if (task == eDragTaskDrop) {
@@ -2123,17 +2121,17 @@ nsDragService::UpdateDragAction()
// default is to do nothing
int action = nsIDragService::DRAGDROP_ACTION_NONE;
GdkDragAction gdkAction = GDK_ACTION_DEFAULT;
if (mTargetDragContext) {
gdkAction = gdk_drag_context_get_actions(mTargetDragContext);
}
#ifdef MOZ_WAYLAND
- else {
+ else if (mTargetWaylandDragContext) {
// We got the selected D&D action from compositor on Wayland.
gdkAction = mTargetWaylandDragContext->GetSelectedDragAction();
}
#endif
// set the default just in case nothing matches below
if (gdkAction & GDK_ACTION_DEFAULT)
action = nsIDragService::DRAGDROP_ACTION_MOVE;

149
rb244010.patch Normal file
View File

@ -0,0 +1,149 @@
diff --git a/gfx/gl/GLContextProviderWayland.cpp b/gfx/gl/GLContextProviderWayland.cpp
new file mode 100644
--- /dev/null
+++ b/gfx/gl/GLContextProviderWayland.cpp
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* 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/. */
+
+#ifdef MOZ_WIDGET_GTK
+#include <gdk/gdk.h>
+#include <gdk/gdkx.h>
+#endif
+
+#include "GLContextProvider.h"
+
+namespace mozilla {
+namespace gl {
+
+using namespace mozilla::gfx;
+using namespace mozilla::widget;
+
+static class GLContextProviderGLX sGLContextProviderGLX;
+static class GLContextProviderEGL sGLContextProviderEGL;
+
+already_AddRefed<GLContext>
+GLContextProviderWayland::CreateWrappingExisting(void* aContext, void* aSurface)
+{
+ if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
+ return sGLContextProviderGLX.CreateWrappingExisting(aContext, aSurface);
+ } else {
+ return sGLContextProviderEGL.CreateWrappingExisting(aContext, aSurface);
+ }
+}
+
+already_AddRefed<GLContext>
+GLContextProviderWayland::CreateForCompositorWidget(CompositorWidget* aCompositorWidget, bool aForceAccelerated)
+{
+ if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
+ return sGLContextProviderGLX.CreateForCompositorWidget(aCompositorWidget, aForceAccelerated);
+ } else {
+ return sGLContextProviderEGL.CreateForCompositorWidget(aCompositorWidget, aForceAccelerated);
+ }
+}
+
+already_AddRefed<GLContext>
+GLContextProviderWayland::CreateForWindow(nsIWidget* aWidget,
+ bool aWebRender,
+ bool aForceAccelerated)
+{
+ if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
+ return sGLContextProviderGLX.CreateForWindow(aWidget, aWebRender, aForceAccelerated);
+ } else {
+ return sGLContextProviderEGL.CreateForWindow(aWidget, aWebRender, aForceAccelerated);
+ }
+}
+
+/*static*/ already_AddRefed<GLContext>
+GLContextProviderWayland::CreateHeadless(CreateContextFlags flags,
+ nsACString* const out_failureId)
+{
+ if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
+ return sGLContextProviderGLX.CreateHeadless(flags, out_failureId);
+ } else {
+ return sGLContextProviderEGL.CreateHeadless(flags, out_failureId);
+ }
+}
+
+/*static*/ already_AddRefed<GLContext>
+GLContextProviderWayland::CreateOffscreen(const IntSize& size,
+ const SurfaceCaps& minCaps,
+ CreateContextFlags flags,
+ nsACString* const out_failureId)
+{
+ if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
+ return sGLContextProviderGLX.CreateOffscreen(size, minCaps, flags, out_failureId);
+ } else {
+ return sGLContextProviderEGL.CreateOffscreen(size, minCaps, flags, out_failureId);
+ }
+}
+
+/*static*/ GLContext*
+GLContextProviderWayland::GetGlobalContext()
+{
+ if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
+ return sGLContextProviderGLX.GetGlobalContext();
+ } else {
+ return sGLContextProviderEGL.GetGlobalContext();
+ }
+}
+
+/*static*/ void
+GLContextProviderWayland::Shutdown()
+{
+ if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
+ sGLContextProviderGLX.Shutdown();
+ } else {
+ sGLContextProviderEGL.Shutdown();
+ }
+}
+
+} /* namespace gl */
+} /* namespace mozilla */
diff --git a/gfx/gl/moz.build b/gfx/gl/moz.build
--- a/gfx/gl/moz.build
+++ b/gfx/gl/moz.build
@@ -8,17 +8,17 @@ gl_provider = 'Null'
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
gl_provider = 'WGL'
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
gl_provider = 'CGL'
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'uikit':
gl_provider = 'EAGL'
elif 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']:
- if CONFIG['MOZ_EGL_XRENDER_COMPOSITE'] or CONFIG['MOZ_WAYLAND']:
+ if CONFIG['MOZ_EGL_XRENDER_COMPOSITE']:
gl_provider = 'EGL'
else:
gl_provider = 'GLX'
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
gl_provider = 'EGL'
if CONFIG['MOZ_GL_PROVIDER']:
gl_provider = CONFIG['MOZ_GL_PROVIDER']
@@ -114,16 +114,21 @@ elif gl_provider == 'GLX':
SOURCES += [
'GLContextProviderGLX.cpp',
'SharedSurfaceGLX.cpp'
]
EXPORTS += [
'SharedSurfaceGLX.h'
]
+if CONFIG['MOZ_WAYLAND']:
+ SOURCES += [
+ 'GLContextProviderWayland.cpp',
+ ]
+
UNIFIED_SOURCES += [
'AndroidSurfaceTexture.cpp',
'DecomposeIntoNoRepeatTriangles.cpp',
'EGLUtils.cpp',
'GfxTexturesReporter.cpp',
'GLBlitHelper.cpp',
'GLContext.cpp',
'GLContextFeatures.cpp',

44
rb244012.patch Normal file
View File

@ -0,0 +1,44 @@
diff --git a/gfx/gl/GLContextProvider.h b/gfx/gl/GLContextProvider.h
--- a/gfx/gl/GLContextProvider.h
+++ b/gfx/gl/GLContextProvider.h
@@ -36,30 +36,38 @@ namespace gl {
#ifdef XP_MACOSX
#define GL_CONTEXT_PROVIDER_NAME GLContextProviderCGL
#include "GLContextProviderImpl.h"
#undef GL_CONTEXT_PROVIDER_NAME
#define GL_CONTEXT_PROVIDER_DEFAULT GLContextProviderCGL
#endif
-#if defined(MOZ_X11) && !defined(MOZ_WAYLAND)
+#if defined(MOZ_X11)
#define GL_CONTEXT_PROVIDER_NAME GLContextProviderGLX
#include "GLContextProviderImpl.h"
#undef GL_CONTEXT_PROVIDER_NAME
#define GL_CONTEXT_PROVIDER_DEFAULT GLContextProviderGLX
#endif
#define GL_CONTEXT_PROVIDER_NAME GLContextProviderEGL
#include "GLContextProviderImpl.h"
#undef GL_CONTEXT_PROVIDER_NAME
#ifndef GL_CONTEXT_PROVIDER_DEFAULT
#define GL_CONTEXT_PROVIDER_DEFAULT GLContextProviderEGL
#endif
+#if defined(MOZ_WAYLAND)
+ #define GL_CONTEXT_PROVIDER_NAME GLContextProviderWayland
+ #include "GLContextProviderImpl.h"
+ #undef GL_CONTEXT_PROVIDER_NAME
+ #undef GL_CONTEXT_PROVIDER_DEFAULT
+ #define GL_CONTEXT_PROVIDER_DEFAULT GLContextProviderWayland
+#endif
+
#if defined(MOZ_WIDGET_UIKIT)
#define GL_CONTEXT_PROVIDER_NAME GLContextProviderEAGL
#include "GLContextProviderImpl.h"
#undef GL_CONTEXT_PROVIDER_NAME
#ifndef GL_CONTEXT_PROVIDER_DEFAULT
#define GL_CONTEXT_PROVIDER_DEFAULT GLContextProviderEAGL
#endif
#endif

314
rb246410.patch Normal file
View File

@ -0,0 +1,314 @@
diff -up firefox-60.0.1/gfx/gl/GLScreenBuffer.cpp.rb246410 firefox-60.0.1/gfx/gl/GLScreenBuffer.cpp
--- firefox-60.0.1/gfx/gl/GLScreenBuffer.cpp.rb246410 2018-05-16 07:38:30.000000000 +0200
+++ firefox-60.0.1/gfx/gl/GLScreenBuffer.cpp 2018-05-25 11:50:38.260890405 +0200
@@ -29,7 +29,7 @@
#include "SharedSurfaceIO.h"
#endif
-#ifdef GL_PROVIDER_GLX
+#ifdef MOZ_X11
#include "GLXLibrary.h"
#include "SharedSurfaceGLX.h"
#endif
@@ -83,7 +83,7 @@ GLScreenBuffer::CreateFactory(GLContext*
if (useGl) {
#if defined(XP_MACOSX)
factory = SurfaceFactory_IOSurface::Create(gl, caps, ipcChannel, flags);
-#elif defined(GL_PROVIDER_GLX)
+#elif defined(MOZ_X11)
if (sGLXLibrary.UseTextureFromPixmap())
factory = SurfaceFactory_GLXDrawable::Create(gl, caps, ipcChannel, flags);
#elif defined(MOZ_WIDGET_UIKIT)
@@ -119,7 +119,7 @@ GLScreenBuffer::CreateFactory(GLContext*
#endif
}
-#ifdef GL_PROVIDER_GLX
+#ifdef MOZ_X11
if (!factory && sGLXLibrary.UseTextureFromPixmap()) {
factory = SurfaceFactory_GLXDrawable::Create(gl, caps, ipcChannel, flags);
}
diff -up firefox-60.0.1/gfx/layers/client/TextureClient.cpp.rb246410 firefox-60.0.1/gfx/layers/client/TextureClient.cpp
--- firefox-60.0.1/gfx/layers/client/TextureClient.cpp.rb246410 2018-05-16 07:38:30.000000000 +0200
+++ firefox-60.0.1/gfx/layers/client/TextureClient.cpp 2018-05-25 11:50:38.260890405 +0200
@@ -45,10 +45,8 @@
#endif
#ifdef MOZ_X11
#include "mozilla/layers/TextureClientX11.h"
-#ifdef GL_PROVIDER_GLX
#include "GLXLibrary.h"
#endif
-#endif
#ifdef XP_MACOSX
#include "mozilla/layers/MacIOSurfaceTextureClientOGL.h"
@@ -1122,7 +1120,6 @@ TextureClient::CreateForDrawing(TextureF
{
data = X11TextureData::Create(aSize, aFormat, aTextureFlags, aAllocator);
}
-#ifdef GL_PROVIDER_GLX
if (!data && aLayersBackend == LayersBackend::LAYERS_OPENGL &&
type == gfxSurfaceType::Xlib &&
aFormat != SurfaceFormat::A8 &&
@@ -1131,7 +1128,6 @@ TextureClient::CreateForDrawing(TextureF
data = X11TextureData::Create(aSize, aFormat, aTextureFlags, aAllocator);
}
#endif
-#endif
#ifdef XP_MACOSX
if (!data && gfxPrefs::UseIOSurfaceTextures()) {
diff -up firefox-60.0.1/gfx/layers/composite/X11TextureHost.cpp.rb246410 firefox-60.0.1/gfx/layers/composite/X11TextureHost.cpp
--- firefox-60.0.1/gfx/layers/composite/X11TextureHost.cpp.rb246410 2018-05-16 07:38:29.000000000 +0200
+++ firefox-60.0.1/gfx/layers/composite/X11TextureHost.cpp 2018-05-25 11:50:38.260890405 +0200
@@ -7,10 +7,8 @@
#include "X11TextureHost.h"
#include "mozilla/layers/BasicCompositor.h"
#include "mozilla/layers/X11TextureSourceBasic.h"
-#ifdef GL_PROVIDER_GLX
#include "mozilla/layers/CompositorOGL.h"
#include "mozilla/layers/X11TextureSourceOGL.h"
-#endif
#include "gfxXlibSurface.h"
#include "gfx2DGlue.h"
@@ -43,12 +41,10 @@ X11TextureHost::Lock()
mTextureSource =
new X11TextureSourceBasic(mCompositor->AsBasicCompositor(), mSurface);
break;
-#ifdef GL_PROVIDER_GLX
case LayersBackend::LAYERS_OPENGL:
mTextureSource =
new X11TextureSourceOGL(mCompositor->AsCompositorOGL(), mSurface);
break;
-#endif
default:
return false;
}
@@ -78,11 +74,9 @@ X11TextureHost::GetFormat() const
return SurfaceFormat::UNKNOWN;
}
gfxContentType type = mSurface->GetContentType();
-#ifdef GL_PROVIDER_GLX
if (mCompositor->GetBackendType() == LayersBackend::LAYERS_OPENGL) {
return X11TextureSourceOGL::ContentTypeToSurfaceFormat(type);
}
-#endif
return X11TextureSourceBasic::ContentTypeToSurfaceFormat(type);
}
diff -up firefox-60.0.1/gfx/layers/ipc/ShadowLayerUtilsX11.cpp.rb246410 firefox-60.0.1/gfx/layers/ipc/ShadowLayerUtilsX11.cpp
--- firefox-60.0.1/gfx/layers/ipc/ShadowLayerUtilsX11.cpp.rb246410 2018-05-16 07:38:30.000000000 +0200
+++ firefox-60.0.1/gfx/layers/ipc/ShadowLayerUtilsX11.cpp 2018-05-25 11:50:38.260890405 +0200
@@ -74,11 +74,9 @@ SurfaceDescriptorX11::SurfaceDescriptorX
mFormat = cairo_xlib_surface_get_visual(aSurf->CairoSurface())->visualid;
}
-#ifdef GL_PROVIDER_GLX
if (aForwardGLX) {
mGLXPixmap = aSurf->GetGLXPixmap();
}
-#endif
}
SurfaceDescriptorX11::SurfaceDescriptorX11(Drawable aDrawable, XID aFormatID,
@@ -109,10 +107,8 @@ SurfaceDescriptorX11::OpenForeign() cons
surf = new gfxXlibSurface(display, mId, visual, mSize);
}
-#ifdef GL_PROVIDER_GLX
if (mGLXPixmap)
surf->BindGLXPixmap(mGLXPixmap);
-#endif
return surf->CairoStatus() ? nullptr : surf.forget();
}
diff -up firefox-60.0.1/gfx/layers/opengl/X11TextureSourceOGL.cpp.rb246410 firefox-60.0.1/gfx/layers/opengl/X11TextureSourceOGL.cpp
--- firefox-60.0.1/gfx/layers/opengl/X11TextureSourceOGL.cpp.rb246410 2018-05-16 07:38:30.000000000 +0200
+++ firefox-60.0.1/gfx/layers/opengl/X11TextureSourceOGL.cpp 2018-05-25 11:50:38.260890405 +0200
@@ -4,7 +4,7 @@
* 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/. */
-#ifdef GL_PROVIDER_GLX
+#ifdef MOZ_X11
#include "X11TextureSourceOGL.h"
#include "gfxXlibSurface.h"
diff -up firefox-60.0.1/gfx/layers/opengl/X11TextureSourceOGL.h.rb246410 firefox-60.0.1/gfx/layers/opengl/X11TextureSourceOGL.h
--- firefox-60.0.1/gfx/layers/opengl/X11TextureSourceOGL.h.rb246410 2018-05-16 07:38:30.000000000 +0200
+++ firefox-60.0.1/gfx/layers/opengl/X11TextureSourceOGL.h 2018-05-25 11:50:38.260890405 +0200
@@ -7,7 +7,7 @@
#ifndef MOZILLA_GFX_X11TEXTURESOURCEOGL__H
#define MOZILLA_GFX_X11TEXTURESOURCEOGL__H
-#ifdef GL_PROVIDER_GLX
+#ifdef MOZ_X11
#include "mozilla/layers/CompositorOGL.h"
#include "mozilla/layers/TextureHostOGL.h"
diff -up firefox-60.0.1/gfx/thebes/gfxPlatformGtk.cpp.rb246410 firefox-60.0.1/gfx/thebes/gfxPlatformGtk.cpp
--- firefox-60.0.1/gfx/thebes/gfxPlatformGtk.cpp.rb246410 2018-05-25 11:50:38.250890430 +0200
+++ firefox-60.0.1/gfx/thebes/gfxPlatformGtk.cpp 2018-05-25 11:52:21.336628487 +0200
@@ -41,11 +41,9 @@
#include "mozilla/Preferences.h"
#include "mozilla/X11Util.h"
-#ifdef GL_PROVIDER_GLX
#include "GLContextProvider.h"
#include "GLContextGLX.h"
#include "GLXLibrary.h"
-#endif
/* Undefine the Status from Xlib since it will conflict with system headers on OSX */
#if defined(__APPLE__) && defined(Status)
@@ -528,7 +526,7 @@ gfxPlatformGtk::GetPlatformCMSOutputProf
}
-#ifdef GL_PROVIDER_GLX
+#ifdef MOZ_X11
class GLXVsyncSource final : public VsyncSource
{
diff -up firefox-60.0.1/gfx/thebes/gfxPlatformGtk.h.rb246410 firefox-60.0.1/gfx/thebes/gfxPlatformGtk.h
--- firefox-60.0.1/gfx/thebes/gfxPlatformGtk.h.rb246410 2018-05-16 07:38:30.000000000 +0200
+++ firefox-60.0.1/gfx/thebes/gfxPlatformGtk.h 2018-05-25 11:50:38.260890405 +0200
@@ -117,7 +117,7 @@ public:
bool AccelerateLayersByDefault() override;
-#ifdef GL_PROVIDER_GLX
+#ifdef MOZ_X11
already_AddRefed<mozilla::gfx::VsyncSource> CreateHardwareVsyncSource() override;
#endif
diff -up firefox-60.0.1/gfx/thebes/gfxXlibSurface.cpp.rb246410 firefox-60.0.1/gfx/thebes/gfxXlibSurface.cpp
--- firefox-60.0.1/gfx/thebes/gfxXlibSurface.cpp.rb246410 2018-05-16 07:38:30.000000000 +0200
+++ firefox-60.0.1/gfx/thebes/gfxXlibSurface.cpp 2018-05-25 11:51:59.741683360 +0200
@@ -25,9 +25,7 @@ using namespace mozilla::gfx;
gfxXlibSurface::gfxXlibSurface(Display *dpy, Drawable drawable, Visual *visual)
: mPixmapTaken(false), mDisplay(dpy), mDrawable(drawable)
-#if defined(GL_PROVIDER_GLX)
, mGLXPixmap(X11None)
-#endif
{
const gfx::IntSize size = DoSizeQuery();
cairo_surface_t *surf = cairo_xlib_surface_create(dpy, drawable, visual, size.width, size.height);
@@ -36,9 +34,7 @@ gfxXlibSurface::gfxXlibSurface(Display *
gfxXlibSurface::gfxXlibSurface(Display *dpy, Drawable drawable, Visual *visual, const gfx::IntSize& size)
: mPixmapTaken(false), mDisplay(dpy), mDrawable(drawable)
-#if defined(GL_PROVIDER_GLX)
, mGLXPixmap(X11None)
-#endif
{
NS_ASSERTION(Factory::CheckSurfaceSize(size, XLIB_IMAGE_SIDE_SIZE_LIMIT),
"Bad size");
@@ -51,9 +47,7 @@ gfxXlibSurface::gfxXlibSurface(Screen *s
const gfx::IntSize& size)
: mPixmapTaken(false), mDisplay(DisplayOfScreen(screen)),
mDrawable(drawable)
-#if defined(GL_PROVIDER_GLX)
- , mGLXPixmap(X11None)
-#endif
+ , mGLXPixmap(X11None)
{
NS_ASSERTION(Factory::CheckSurfaceSize(size, XLIB_IMAGE_SIDE_SIZE_LIMIT),
"Bad Size");
@@ -67,9 +61,7 @@ gfxXlibSurface::gfxXlibSurface(Screen *s
gfxXlibSurface::gfxXlibSurface(cairo_surface_t *csurf)
: mPixmapTaken(false)
-#if defined(GL_PROVIDER_GLX)
- , mGLXPixmap(X11None)
-#endif
+ , mGLXPixmap(X11None)
{
NS_PRECONDITION(cairo_surface_status(csurf) == 0,
"Not expecting an error surface");
@@ -84,11 +76,9 @@ gfxXlibSurface::~gfxXlibSurface()
{
// gfxASurface's destructor calls RecordMemoryFreed().
if (mPixmapTaken) {
-#if defined(GL_PROVIDER_GLX)
if (mGLXPixmap) {
gl::sGLXLibrary.DestroyPixmap(mDisplay, mGLXPixmap);
}
-#endif
XFreePixmap (mDisplay, mDrawable);
}
}
@@ -120,7 +110,7 @@ gfxXlibSurface::TakePixmap()
// The bit depth returned from Cairo is technically int, but this is
// the last place we'd be worried about that scenario.
unsigned int bitDepth = cairo_xlib_surface_get_depth(CairoSurface());
- MOZ_ASSERT((bitDepth % 8) == 0, "Memory used not recorded correctly");
+ MOZ_ASSERT((bitDepth % 8) == 0, "Memory used not recorded correctly");
// Divide by 8 because surface_get_depth gives us the number of *bits* per
// pixel.
@@ -272,7 +262,7 @@ gfxXlibSurface::CreateSimilarSurface(gfx
void
gfxXlibSurface::Finish()
{
-#if defined(GL_PROVIDER_GLX)
+#if defined(MOZ_X11)
if (mPixmapTaken && mGLXPixmap) {
gl::sGLXLibrary.DestroyPixmap(mDisplay, mGLXPixmap);
mGLXPixmap = X11None;
@@ -498,7 +488,7 @@ gfxXlibSurface::DepthOfVisual(const Scre
NS_ERROR("Visual not on Screen.");
return 0;
}
-
+
/* static */
Visual*
gfxXlibSurface::FindVisual(Screen *screen, gfxImageFormat format)
@@ -587,7 +577,7 @@ gfxXlibSurface::XRenderFormat()
return cairo_xlib_surface_get_xrender_format(CairoSurface());
}
-#if defined(GL_PROVIDER_GLX)
+#if defined(MOZ_X11)
GLXPixmap
gfxXlibSurface::GetGLXPixmap()
{
diff -up firefox-60.0.1/gfx/thebes/gfxXlibSurface.h.rb246410 firefox-60.0.1/gfx/thebes/gfxXlibSurface.h
--- firefox-60.0.1/gfx/thebes/gfxXlibSurface.h.rb246410 2018-05-16 07:38:30.000000000 +0200
+++ firefox-60.0.1/gfx/thebes/gfxXlibSurface.h 2018-05-25 11:50:38.261890402 +0200
@@ -12,9 +12,7 @@
#include <X11/Xlib.h>
#include "X11UndefineNone.h"
-#if defined(GL_PROVIDER_GLX)
#include "GLXLibrary.h"
-#endif
#include "nsSize.h"
@@ -86,12 +84,10 @@ public:
// Find a visual and colormap pair suitable for rendering to this surface.
bool GetColormapAndVisual(Colormap* colormap, Visual **visual);
-#if defined(GL_PROVIDER_GLX)
GLXPixmap GetGLXPixmap();
// Binds a GLXPixmap backed by this context's surface.
// Primarily for use in sharing surfaces.
void BindGLXPixmap(GLXPixmap aPixmap);
-#endif
// Return true if cairo will take its slow path when this surface is used
// in a pattern with EXTEND_PAD. As a workaround for XRender's RepeatPad
@@ -114,9 +110,7 @@ protected:
const mozilla::gfx::IntSize DoSizeQuery();
-#if defined(GL_PROVIDER_GLX)
GLXPixmap mGLXPixmap;
-#endif
};
#endif /* GFX_XLIBSURFACE_H */