зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1579794 - [Wayland] Use wl_surface_damage_buffer() and require wl_compositor v.4, r=jhorak
Use wl_surface_damage_buffer() to propagate wl_buffer damage to avoid rounding errors and rendering artifacts for HiDPI wl_buffers. Depends on D45165 Differential Revision: https://phabricator.services.mozilla.com/D45166 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
7a6c6dc9d7
Коммит
2ba6437bbb
|
@ -951,16 +951,6 @@ static void WaylandBufferDelayCommitHandler(WindowSurfaceWayland** aSurface) {
|
|||
}
|
||||
}
|
||||
|
||||
void WindowSurfaceWayland::CalcRectScale(LayoutDeviceIntRect& aRect,
|
||||
int aScale) {
|
||||
aRect.x = aRect.x / aScale;
|
||||
aRect.y = aRect.y / aScale;
|
||||
|
||||
// We don't need exact damage size - just safely cover the round errors.
|
||||
aRect.width = (aRect.width / aScale) + 2;
|
||||
aRect.height = (aRect.height / aScale) + 2;
|
||||
}
|
||||
|
||||
void WindowSurfaceWayland::CommitWaylandBuffer() {
|
||||
MOZ_ASSERT(mPendingCommit, "Committing empty surface!");
|
||||
|
||||
|
@ -1022,16 +1012,10 @@ void WindowSurfaceWayland::CommitWaylandBuffer() {
|
|||
mWholeWindowBufferDamage = false;
|
||||
mNeedScaleFactorUpdate = true;
|
||||
} else {
|
||||
gint scaleFactor = mWindow->GdkScaleFactor();
|
||||
for (auto iter = mWaylandBufferDamage.RectIter(); !iter.Done();
|
||||
iter.Next()) {
|
||||
mozilla::LayoutDeviceIntRect r = iter.Get();
|
||||
// We need to remove the scale factor because the wl_surface_damage
|
||||
// also multiplies by current scale factor.
|
||||
if (scaleFactor > 1) {
|
||||
CalcRectScale(r, scaleFactor);
|
||||
}
|
||||
wl_surface_damage(waylandSurface, r.x, r.y, r.width, r.height);
|
||||
wl_surface_damage_buffer(waylandSurface, r.x, r.y, r.width, r.height);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -204,7 +204,6 @@ class WindowSurfaceWayland : public WindowSurface {
|
|||
const LayoutDeviceIntRegion& aRegion,
|
||||
LayoutDeviceIntRegion& aWaylandBufferDamage);
|
||||
void CommitWaylandBuffer();
|
||||
void CalcRectScale(LayoutDeviceIntRect& aRect, int scale);
|
||||
|
||||
void DrawDelayedImageCommits(gfx::DrawTarget* aDrawTarget,
|
||||
LayoutDeviceIntRegion& aWaylandBufferDamage);
|
||||
|
|
|
@ -578,16 +578,12 @@ struct wl_surface* moz_container_get_wl_surface(MozContainer* container) {
|
|||
return nullptr;
|
||||
}
|
||||
GdkDisplay* display = gtk_widget_get_display(GTK_WIDGET(container));
|
||||
nsWaylandDisplay* waylandDisplay = WaylandDisplayGet(display);
|
||||
|
||||
// Available as of GTK 3.8+
|
||||
static auto sGdkWaylandDisplayGetWlCompositor =
|
||||
(wl_compositor * (*)(GdkDisplay*))
|
||||
dlsym(RTLD_DEFAULT, "gdk_wayland_display_get_wl_compositor");
|
||||
struct wl_compositor* compositor =
|
||||
sGdkWaylandDisplayGetWlCompositor(display);
|
||||
struct wl_compositor* compositor = waylandDisplay->GetCompositor();
|
||||
container->surface = wl_compositor_create_surface(compositor);
|
||||
|
||||
nsWaylandDisplay* waylandDisplay = WaylandDisplayGet(display);
|
||||
container->subsurface = wl_subcompositor_get_subsurface(
|
||||
waylandDisplay->GetSubcompositor(), container->surface,
|
||||
moz_container_get_gtk_container_surface(container));
|
||||
|
|
|
@ -30,6 +30,7 @@ const struct wl_interface wl_shm_pool_interface;
|
|||
const struct wl_interface wl_seat_interface;
|
||||
const struct wl_interface wl_surface_interface;
|
||||
const struct wl_interface wl_subsurface_interface;
|
||||
const struct wl_interface wl_compositor_interface;
|
||||
const struct wl_interface wl_subcompositor_interface;
|
||||
#pragma GCC visibility pop
|
||||
|
||||
|
|
|
@ -108,6 +108,17 @@ static inline void wl_subsurface_destroy(struct wl_subsurface* wl_subsurface) {
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifndef WL_SURFACE_DAMAGE_BUFFER
|
||||
# define WL_SURFACE_DAMAGE_BUFFER 9
|
||||
|
||||
static inline void wl_surface_damage_buffer(struct wl_surface* wl_surface,
|
||||
int32_t x, int32_t y, int32_t width,
|
||||
int32_t height) {
|
||||
wl_proxy_marshal((struct wl_proxy*)wl_surface, WL_SURFACE_DAMAGE_BUFFER, x, y,
|
||||
width, height);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -116,6 +116,10 @@ nsWaylandDisplay* WaylandDisplayGet(GdkDisplay* aGdkDisplay) {
|
|||
|
||||
void nsWaylandDisplay::SetShm(wl_shm* aShm) { mShm = aShm; }
|
||||
|
||||
void nsWaylandDisplay::SetCompositor(wl_compositor* aCompositor) {
|
||||
mCompositor = aCompositor;
|
||||
}
|
||||
|
||||
void nsWaylandDisplay::SetSubcompositor(wl_subcompositor* aSubcompositor) {
|
||||
mSubcompositor = aSubcompositor;
|
||||
}
|
||||
|
@ -223,6 +227,12 @@ static void global_registry_handler(void* data, wl_registry* registry,
|
|||
wl_proxy_set_queue((struct wl_proxy*)primary_selection_device_manager,
|
||||
display->GetEventQueue());
|
||||
display->SetPrimarySelectionDeviceManager(primary_selection_device_manager);
|
||||
} else if (strcmp(interface, "wl_compositor") == 0) {
|
||||
// Requested wl_compositor version 4 as we need wl_surface_damage_buffer().
|
||||
auto compositor = static_cast<wl_compositor*>(
|
||||
wl_registry_bind(registry, id, &wl_compositor_interface, 4));
|
||||
wl_proxy_set_queue((struct wl_proxy*)compositor, display->GetEventQueue());
|
||||
display->SetCompositor(compositor);
|
||||
} else if (strcmp(interface, "wl_subcompositor") == 0) {
|
||||
auto subcompositor = static_cast<wl_subcompositor*>(
|
||||
wl_registry_bind(registry, id, &wl_subcompositor_interface, 1));
|
||||
|
@ -306,6 +316,7 @@ nsWaylandDisplay::nsWaylandDisplay(wl_display* aDisplay)
|
|||
mDisplay(aDisplay),
|
||||
mEventQueue(nullptr),
|
||||
mDataDeviceManager(nullptr),
|
||||
mCompositor(nullptr),
|
||||
mSubcompositor(nullptr),
|
||||
mSeat(nullptr),
|
||||
mShm(nullptr),
|
||||
|
|
|
@ -45,6 +45,7 @@ class nsWaylandDisplay {
|
|||
MessageLoop* GetDispatcherThreadLoop() { return mDispatcherThreadLoop; }
|
||||
wl_display* GetDisplay() { return mDisplay; };
|
||||
wl_event_queue* GetEventQueue() { return mEventQueue; };
|
||||
wl_compositor* GetCompositor(void) { return mCompositor; };
|
||||
wl_subcompositor* GetSubcompositor(void) { return mSubcompositor; };
|
||||
wl_data_device_manager* GetDataDeviceManager(void) {
|
||||
return mDataDeviceManager;
|
||||
|
@ -56,6 +57,7 @@ class nsWaylandDisplay {
|
|||
};
|
||||
|
||||
void SetShm(wl_shm* aShm);
|
||||
void SetCompositor(wl_compositor* aCompositor);
|
||||
void SetSubcompositor(wl_subcompositor* aSubcompositor);
|
||||
void SetDataDeviceManager(wl_data_device_manager* aDataDeviceManager);
|
||||
void SetSeat(wl_seat* aSeat);
|
||||
|
@ -88,6 +90,7 @@ class nsWaylandDisplay {
|
|||
wl_display* mDisplay;
|
||||
wl_event_queue* mEventQueue;
|
||||
wl_data_device_manager* mDataDeviceManager;
|
||||
wl_compositor* mCompositor;
|
||||
wl_subcompositor* mSubcompositor;
|
||||
wl_seat* mSeat;
|
||||
wl_shm* mShm;
|
||||
|
|
Загрузка…
Ссылка в новой задаче