1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim:expandtab:shiftwidth=4:tabstop=4: 3 */ 4 /* This Source Code Form is subject to the terms of the Mozilla Public 5 * License, v. 2.0. If a copy of the MPL was not distributed with this 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 7 8 #ifndef __MOZ_CONTAINER_WAYLAND_H__ 9 #define __MOZ_CONTAINER_WAYLAND_H__ 10 11 #include <gtk/gtk.h> 12 #include <functional> 13 #include <vector> 14 #include "mozilla/Mutex.h" 15 #include "WindowSurface.h" 16 17 /* 18 * MozContainer 19 * 20 * This class serves three purposes in the nsIWidget implementation. 21 * 22 * - It provides objects to receive signals from GTK for events on native 23 * windows. 24 * 25 * - It provides GdkWindow to draw content on Wayland or when Gtk+ renders 26 * client side decorations to mShell. 27 */ 28 29 /* Workaround for bug at wayland-util.h, 30 * present in wayland-devel < 1.12 31 */ 32 struct wl_surface; 33 struct wl_subsurface; 34 35 struct MozContainerWayland { 36 struct wl_surface* surface; 37 struct wl_subsurface* subsurface; 38 int subsurface_dx, subsurface_dy; 39 struct wl_egl_window* eglwindow; 40 struct wl_callback* frame_callback_handler; 41 struct wp_viewport* viewport; 42 gboolean opaque_region_needs_updates; 43 gboolean opaque_region_subtract_corners; 44 gboolean opaque_region_used; 45 gboolean surface_needs_clear; 46 gboolean ready_to_draw; 47 gboolean before_first_size_alloc; 48 gboolean container_remapped; 49 int buffer_scale; 50 std::vector<std::function<void(void)>> initial_draw_cbs; 51 // mozcontainer is used from Compositor and Rendering threads 52 // so we need to control access to mozcontainer where wayland internals 53 // are used directly. 54 mozilla::Mutex* container_lock; 55 }; 56 57 struct _MozContainer; 58 struct _MozContainerClass; 59 typedef struct _MozContainer MozContainer; 60 typedef struct _MozContainerClass MozContainerClass; 61 62 void moz_container_wayland_class_init(MozContainerClass* klass); 63 void moz_container_wayland_init(MozContainerWayland* container); 64 65 struct wl_surface* moz_container_wayland_surface_lock(MozContainer* container); 66 void moz_container_wayland_surface_unlock(MozContainer* container, 67 struct wl_surface** surface); 68 69 struct wl_egl_window* moz_container_wayland_get_egl_window( 70 MozContainer* container, double scale); 71 72 gboolean moz_container_wayland_has_egl_window(MozContainer* container); 73 gboolean moz_container_wayland_surface_needs_clear(MozContainer* container); 74 void moz_container_wayland_egl_window_set_size(MozContainer* container, 75 int width, int height); 76 void moz_container_wayland_set_scale_factor(MozContainer* container); 77 void moz_container_wayland_add_initial_draw_callback( 78 MozContainer* container, const std::function<void(void)>& initial_draw_cb); 79 wl_surface* moz_gtk_widget_get_wl_surface(GtkWidget* aWidget); 80 void moz_container_wayland_update_opaque_region(MozContainer* container, 81 bool aSubtractCorners); 82 gboolean moz_container_wayland_can_draw(MozContainer* container); 83 double moz_container_wayland_get_scale(MozContainer* container); 84 struct wp_viewport* moz_container_wayland_get_viewport(MozContainer* container); 85 gboolean moz_container_wayland_get_and_reset_remapped(MozContainer* container); 86 87 #endif /* __MOZ_CONTAINER_WAYLAND_H__ */ 88