Compare commits
10 Commits
wip/matthi
...
wip/mir-gd
Author | SHA1 | Date | |
---|---|---|---|
|
6f74d6cf73 | ||
|
49699adece | ||
|
53a9f3800a | ||
|
e85e320bc0 | ||
|
8b30d034d1 | ||
|
073a9a35f8 | ||
|
851fdf5597 | ||
|
8594cbc35a | ||
|
165b5a9f53 | ||
|
f4e7adc562 |
@@ -24,6 +24,7 @@ libgdk_mir_la_SOURCES = \
|
|||||||
gdkmirdevicemanager.c \
|
gdkmirdevicemanager.c \
|
||||||
gdkmirdisplay.c \
|
gdkmirdisplay.c \
|
||||||
gdkmireventsource.c \
|
gdkmireventsource.c \
|
||||||
|
gdkmirglcontext.c \
|
||||||
gdkmirkeyboard.c \
|
gdkmirkeyboard.c \
|
||||||
gdkmirkeymap.c \
|
gdkmirkeymap.c \
|
||||||
gdkmirpointer.c \
|
gdkmirpointer.c \
|
||||||
|
@@ -18,6 +18,8 @@
|
|||||||
#ifndef __GDK_PRIVATE_MIR_H__
|
#ifndef __GDK_PRIVATE_MIR_H__
|
||||||
#define __GDK_PRIVATE_MIR_H__
|
#define __GDK_PRIVATE_MIR_H__
|
||||||
|
|
||||||
|
#include <epoxy/egl.h>
|
||||||
|
|
||||||
#include "gdkmir.h"
|
#include "gdkmir.h"
|
||||||
#include "gdkdisplay.h"
|
#include "gdkdisplay.h"
|
||||||
#include "gdkscreen.h"
|
#include "gdkscreen.h"
|
||||||
@@ -77,6 +79,30 @@ void _gdk_mir_window_reference_unref (GdkMirWindowReference *ref);
|
|||||||
|
|
||||||
void _gdk_mir_event_source_queue (GdkMirWindowReference *window_ref, const MirEvent *event);
|
void _gdk_mir_event_source_queue (GdkMirWindowReference *window_ref, const MirEvent *event);
|
||||||
|
|
||||||
|
MirPixelFormat _gdk_mir_display_get_pixel_format (GdkDisplay *display, MirBufferUsage usage);
|
||||||
|
|
||||||
|
gboolean _gdk_mir_display_init_egl_display (GdkDisplay *display);
|
||||||
|
|
||||||
|
EGLDisplay _gdk_mir_display_get_egl_display (GdkDisplay *display);
|
||||||
|
|
||||||
|
gboolean _gdk_mir_display_have_egl_khr_create_context (GdkDisplay *display);
|
||||||
|
|
||||||
|
gboolean _gdk_mir_display_have_egl_buffer_age (GdkDisplay *display);
|
||||||
|
|
||||||
|
gboolean _gdk_mir_display_have_egl_swap_buffers_with_damage (GdkDisplay *display);
|
||||||
|
|
||||||
|
gboolean _gdk_mir_display_have_egl_surfaceless_context (GdkDisplay *display);
|
||||||
|
|
||||||
|
gboolean _gdk_mir_display_make_gl_context_current (GdkDisplay *display, GdkGLContext *context);
|
||||||
|
|
||||||
|
EGLSurface _gdk_mir_window_get_egl_surface (GdkWindow *window, EGLConfig config);
|
||||||
|
|
||||||
|
EGLSurface _gdk_mir_window_get_dummy_egl_surface (GdkWindow *window, EGLConfig config);
|
||||||
|
|
||||||
|
GdkGLContext *_gdk_mir_window_create_gl_context (GdkWindow *window, gboolean attach, GdkGLProfile profile, GdkGLContext *share, GError **error);
|
||||||
|
|
||||||
|
void _gdk_mir_window_invalidate_for_new_frame (GdkWindow *window, cairo_region_t *update_area);
|
||||||
|
|
||||||
void _gdk_mir_print_modifiers (unsigned int modifiers);
|
void _gdk_mir_print_modifiers (unsigned int modifiers);
|
||||||
|
|
||||||
void _gdk_mir_print_key_event (const MirKeyEvent *event);
|
void _gdk_mir_print_key_event (const MirKeyEvent *event);
|
||||||
|
@@ -24,16 +24,25 @@
|
|||||||
#define GDK_TYPE_MIR_DISPLAY (gdk_mir_display_get_type ())
|
#define GDK_TYPE_MIR_DISPLAY (gdk_mir_display_get_type ())
|
||||||
#define GDK_IS_MIR_DISPLAY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MIR_DISPLAY))
|
#define GDK_IS_MIR_DISPLAY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MIR_DISPLAY))
|
||||||
|
|
||||||
#define GDK_TYPE_MIR_WINDOW (gdk_mir_window_get_type ())
|
#define GDK_TYPE_MIR_GL_CONTEXT (gdk_mir_gl_context_get_type ())
|
||||||
#define GDK_IS_WINDOW_MIR(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MIR_WINDOW))
|
#define GDK_MIR_IS_GL_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_MIR_GL_CONTEXT))
|
||||||
|
|
||||||
|
#define GDK_TYPE_MIR_WINDOW (gdk_mir_window_get_type ())
|
||||||
|
#define GDK_IS_WINDOW_MIR(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MIR_WINDOW))
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_3_10
|
GDK_AVAILABLE_IN_3_10
|
||||||
GType gdk_mir_display_get_type (void);
|
GType gdk_mir_display_get_type (void);
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_3_10
|
GDK_AVAILABLE_IN_3_10
|
||||||
struct MirConnection *gdk_mir_display_get_mir_connection (GdkDisplay *display);
|
MirConnection *gdk_mir_display_get_mir_connection (GdkDisplay *display);
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_3_10
|
GDK_AVAILABLE_IN_3_10
|
||||||
GType gdk_mir_window_get_type (void);
|
GType gdk_mir_window_get_type (void);
|
||||||
|
|
||||||
|
GDK_AVAILABLE_IN_3_16
|
||||||
|
MirSurface *gdk_mir_window_get_mir_surface (GdkWindow *window);
|
||||||
|
|
||||||
|
GDK_AVAILABLE_IN_3_16
|
||||||
|
GType gdk_mir_gl_context_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
#endif /* __GDK_MIR_H__ */
|
#endif /* __GDK_MIR_H__ */
|
||||||
|
@@ -46,6 +46,15 @@ typedef struct GdkMirDisplay
|
|||||||
GdkScreen *screen;
|
GdkScreen *screen;
|
||||||
|
|
||||||
GdkKeymap *keymap;
|
GdkKeymap *keymap;
|
||||||
|
|
||||||
|
MirPixelFormat sw_pixel_format;
|
||||||
|
MirPixelFormat hw_pixel_format;
|
||||||
|
|
||||||
|
EGLDisplay egl_display;
|
||||||
|
guint have_egl_khr_create_context : 1;
|
||||||
|
guint have_egl_buffer_age : 1;
|
||||||
|
guint have_egl_swap_buffers_with_damage : 1;
|
||||||
|
guint have_egl_surfaceless_context : 1;
|
||||||
} GdkMirDisplay;
|
} GdkMirDisplay;
|
||||||
|
|
||||||
typedef struct GdkMirDisplayClass
|
typedef struct GdkMirDisplayClass
|
||||||
@@ -53,6 +62,8 @@ typedef struct GdkMirDisplayClass
|
|||||||
GdkDisplayClass parent_class;
|
GdkDisplayClass parent_class;
|
||||||
} GdkMirDisplayClass;
|
} GdkMirDisplayClass;
|
||||||
|
|
||||||
|
static void initialize_pixel_formats (GdkMirDisplay *display);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SECTION:mir_interaction
|
* SECTION:mir_interaction
|
||||||
* @Short_description: Mir backend-specific functions
|
* @Short_description: Mir backend-specific functions
|
||||||
@@ -112,6 +123,7 @@ _gdk_mir_display_open (const gchar *display_name)
|
|||||||
display->connection = connection;
|
display->connection = connection;
|
||||||
GDK_DISPLAY (display)->device_manager = _gdk_mir_device_manager_new (GDK_DISPLAY (display));
|
GDK_DISPLAY (display)->device_manager = _gdk_mir_device_manager_new (GDK_DISPLAY (display));
|
||||||
display->screen = _gdk_mir_screen_new (GDK_DISPLAY (display));
|
display->screen = _gdk_mir_screen_new (GDK_DISPLAY (display));
|
||||||
|
initialize_pixel_formats (display);
|
||||||
|
|
||||||
g_signal_emit_by_name (display, "opened");
|
g_signal_emit_by_name (display, "opened");
|
||||||
|
|
||||||
@@ -487,6 +499,137 @@ gdk_mir_display_utf8_to_string_target (GdkDisplay *display,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
initialize_pixel_formats (GdkMirDisplay *display)
|
||||||
|
{
|
||||||
|
MirPixelFormat formats[mir_pixel_formats];
|
||||||
|
unsigned int n_formats, i;
|
||||||
|
|
||||||
|
mir_connection_get_available_surface_formats (display->connection, formats,
|
||||||
|
mir_pixel_formats, &n_formats);
|
||||||
|
|
||||||
|
display->sw_pixel_format = mir_pixel_format_invalid;
|
||||||
|
display->hw_pixel_format = mir_pixel_format_invalid;
|
||||||
|
|
||||||
|
for (i = 0; i < n_formats; i++)
|
||||||
|
{
|
||||||
|
switch (formats[i])
|
||||||
|
{
|
||||||
|
case mir_pixel_format_abgr_8888:
|
||||||
|
case mir_pixel_format_xbgr_8888:
|
||||||
|
case mir_pixel_format_argb_8888:
|
||||||
|
case mir_pixel_format_xrgb_8888:
|
||||||
|
display->hw_pixel_format = formats[i];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (display->hw_pixel_format != mir_pixel_format_invalid)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < n_formats; i++)
|
||||||
|
{
|
||||||
|
if (formats[i] == mir_pixel_format_argb_8888)
|
||||||
|
{
|
||||||
|
display->sw_pixel_format = formats[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MirPixelFormat
|
||||||
|
_gdk_mir_display_get_pixel_format (GdkDisplay *display,
|
||||||
|
MirBufferUsage usage)
|
||||||
|
{
|
||||||
|
GdkMirDisplay *mir_dpy = GDK_MIR_DISPLAY (display);
|
||||||
|
|
||||||
|
if (usage == mir_buffer_usage_hardware)
|
||||||
|
return mir_dpy->hw_pixel_format;
|
||||||
|
|
||||||
|
return mir_dpy->sw_pixel_format;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
_gdk_mir_display_init_egl_display (GdkDisplay *display)
|
||||||
|
{
|
||||||
|
GdkMirDisplay *mir_dpy = GDK_MIR_DISPLAY (display);
|
||||||
|
EGLint major_version, minor_version;
|
||||||
|
EGLDisplay *dpy;
|
||||||
|
|
||||||
|
if (mir_dpy->egl_display)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
dpy = eglGetDisplay (mir_connection_get_egl_native_display (mir_dpy->connection));
|
||||||
|
if (dpy == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (!eglInitialize (dpy, &major_version, &minor_version))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (!eglBindAPI (EGL_OPENGL_API))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
mir_dpy->egl_display = dpy;
|
||||||
|
|
||||||
|
mir_dpy->have_egl_khr_create_context =
|
||||||
|
epoxy_has_egl_extension (dpy, "EGL_KHR_create_context");
|
||||||
|
|
||||||
|
mir_dpy->have_egl_buffer_age =
|
||||||
|
epoxy_has_egl_extension (dpy, "EGL_EXT_buffer_age");
|
||||||
|
|
||||||
|
mir_dpy->have_egl_swap_buffers_with_damage =
|
||||||
|
epoxy_has_egl_extension (dpy, "EGL_EXT_swap_buffers_with_damage");
|
||||||
|
|
||||||
|
mir_dpy->have_egl_surfaceless_context =
|
||||||
|
epoxy_has_egl_extension (dpy, "EGL_KHR_surfaceless_context");
|
||||||
|
|
||||||
|
GDK_NOTE (OPENGL,
|
||||||
|
g_print ("EGL API version %d.%d found\n"
|
||||||
|
" - Vendor: %s\n"
|
||||||
|
" - Version: %s\n"
|
||||||
|
" - Client APIs: %s\n"
|
||||||
|
" - Extensions:\n"
|
||||||
|
"\t%s\n",
|
||||||
|
major_version,
|
||||||
|
minor_version,
|
||||||
|
eglQueryString (dpy, EGL_VENDOR),
|
||||||
|
eglQueryString (dpy, EGL_VERSION),
|
||||||
|
eglQueryString (dpy, EGL_CLIENT_APIS),
|
||||||
|
eglQueryString (dpy, EGL_EXTENSIONS)));
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLDisplay _gdk_mir_display_get_egl_display (GdkDisplay *display)
|
||||||
|
{
|
||||||
|
return GDK_MIR_DISPLAY (display)->egl_display;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean _gdk_mir_display_have_egl_khr_create_context (GdkDisplay *display)
|
||||||
|
{
|
||||||
|
return GDK_MIR_DISPLAY (display)->have_egl_khr_create_context;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean _gdk_mir_display_have_egl_buffer_age (GdkDisplay *display)
|
||||||
|
{
|
||||||
|
return GDK_MIR_DISPLAY (display)->have_egl_buffer_age;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean _gdk_mir_display_have_egl_swap_buffers_with_damage (GdkDisplay *display)
|
||||||
|
{
|
||||||
|
/* FIXME: this seems to cause rendering problems, at least with radeon */
|
||||||
|
// return GDK_MIR_DISPLAY (display)->have_egl_swap_buffers_with_damage;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean _gdk_mir_display_have_egl_surfaceless_context (GdkDisplay *display)
|
||||||
|
{
|
||||||
|
return GDK_MIR_DISPLAY (display)->have_egl_surfaceless_context;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gdk_mir_display_init (GdkMirDisplay *display)
|
gdk_mir_display_init (GdkMirDisplay *display)
|
||||||
{
|
{
|
||||||
@@ -545,4 +688,5 @@ gdk_mir_display_class_init (GdkMirDisplayClass *klass)
|
|||||||
display_class->convert_selection = gdk_mir_display_convert_selection;
|
display_class->convert_selection = gdk_mir_display_convert_selection;
|
||||||
display_class->text_property_to_utf8_list = gdk_mir_display_text_property_to_utf8_list;
|
display_class->text_property_to_utf8_list = gdk_mir_display_text_property_to_utf8_list;
|
||||||
display_class->utf8_to_string_target = gdk_mir_display_utf8_to_string_target;
|
display_class->utf8_to_string_target = gdk_mir_display_utf8_to_string_target;
|
||||||
|
display_class->make_gl_context_current = _gdk_mir_display_make_gl_context_current;
|
||||||
}
|
}
|
||||||
|
397
gdk/mir/gdkmirglcontext.c
Normal file
397
gdk/mir/gdkmirglcontext.c
Normal file
@@ -0,0 +1,397 @@
|
|||||||
|
/* GDK - The GIMP Drawing Kit
|
||||||
|
*
|
||||||
|
* gdkmirglcontext.c: Mir specific OpenGL wrappers
|
||||||
|
*
|
||||||
|
* Copyright © 2014 Canonical Ltd
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "gdkmir-private.h"
|
||||||
|
#include "gdkinternals.h"
|
||||||
|
#include "gdkglcontextprivate.h"
|
||||||
|
#include "gdkintl.h"
|
||||||
|
|
||||||
|
#define GDK_MIR_GL_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_MIR_GL_CONTEXT, GdkMirGLContext))
|
||||||
|
|
||||||
|
struct _GdkMirGLContext
|
||||||
|
{
|
||||||
|
GdkGLContext parent_instance;
|
||||||
|
|
||||||
|
EGLContext egl_context;
|
||||||
|
EGLConfig egl_config;
|
||||||
|
gboolean is_attached;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GdkMirGLContextClass
|
||||||
|
{
|
||||||
|
GdkGLContextClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct _GdkMirGLContext GdkMirGLContext;
|
||||||
|
typedef struct _GdkMirGLContextClass GdkMirGLContextClass;
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (GdkMirGLContext, gdk_mir_gl_context, GDK_TYPE_GL_CONTEXT)
|
||||||
|
|
||||||
|
static void gdk_mir_gl_context_dispose (GObject *gobject);
|
||||||
|
|
||||||
|
void
|
||||||
|
_gdk_mir_window_invalidate_for_new_frame (GdkWindow *window,
|
||||||
|
cairo_region_t *update_area)
|
||||||
|
{
|
||||||
|
cairo_rectangle_int_t window_rect;
|
||||||
|
GdkDisplay *display = gdk_window_get_display (window);
|
||||||
|
GdkMirGLContext *context_mir;
|
||||||
|
int buffer_age;
|
||||||
|
gboolean invalidate_all;
|
||||||
|
EGLSurface egl_surface;
|
||||||
|
|
||||||
|
/* Minimal update is ok if we're not drawing with gl */
|
||||||
|
if (window->gl_paint_context == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
context_mir = GDK_MIR_GL_CONTEXT (window->gl_paint_context);
|
||||||
|
buffer_age = 0;
|
||||||
|
|
||||||
|
egl_surface = _gdk_mir_window_get_egl_surface (window, context_mir->egl_config);
|
||||||
|
|
||||||
|
if (_gdk_mir_display_have_egl_buffer_age (display))
|
||||||
|
{
|
||||||
|
gdk_gl_context_make_current (window->gl_paint_context);
|
||||||
|
eglQuerySurface (_gdk_mir_display_get_egl_display (display), egl_surface,
|
||||||
|
EGL_BUFFER_AGE_EXT, &buffer_age);
|
||||||
|
}
|
||||||
|
|
||||||
|
invalidate_all = FALSE;
|
||||||
|
if (buffer_age == 0 || buffer_age >= 4)
|
||||||
|
invalidate_all = TRUE;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (buffer_age >= 2)
|
||||||
|
{
|
||||||
|
if (window->old_updated_area[0])
|
||||||
|
cairo_region_union (update_area, window->old_updated_area[0]);
|
||||||
|
else
|
||||||
|
invalidate_all = TRUE;
|
||||||
|
}
|
||||||
|
if (buffer_age >= 3)
|
||||||
|
{
|
||||||
|
if (window->old_updated_area[1])
|
||||||
|
cairo_region_union (update_area, window->old_updated_area[1]);
|
||||||
|
else
|
||||||
|
invalidate_all = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (invalidate_all)
|
||||||
|
{
|
||||||
|
window_rect.x = 0;
|
||||||
|
window_rect.y = 0;
|
||||||
|
window_rect.width = gdk_window_get_width (window);
|
||||||
|
window_rect.height = gdk_window_get_height (window);
|
||||||
|
|
||||||
|
/* If nothing else is known, repaint everything so that the back
|
||||||
|
buffer is fully up-to-date for the swapbuffer */
|
||||||
|
cairo_region_union_rectangle (update_area, &window_rect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gdk_mir_gl_context_update (GdkGLContext *context)
|
||||||
|
{
|
||||||
|
GdkWindow *window = gdk_gl_context_get_window (context);
|
||||||
|
int width, height;
|
||||||
|
|
||||||
|
gdk_gl_context_make_current (context);
|
||||||
|
|
||||||
|
width = gdk_window_get_width (window);
|
||||||
|
height = gdk_window_get_height (window);
|
||||||
|
|
||||||
|
GDK_NOTE (OPENGL, g_print ("Updating GL viewport size to { %d, %d } for window %p (context: %p)\n",
|
||||||
|
width, height,
|
||||||
|
window, context));
|
||||||
|
|
||||||
|
glViewport (0, 0, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gdk_mir_gl_context_end_frame (GdkGLContext *context,
|
||||||
|
cairo_region_t *painted,
|
||||||
|
cairo_region_t *damage)
|
||||||
|
{
|
||||||
|
GdkWindow *window = gdk_gl_context_get_window (context);
|
||||||
|
GdkDisplay *display = gdk_window_get_display (window);
|
||||||
|
GdkMirGLContext *context_mir = GDK_MIR_GL_CONTEXT (context);
|
||||||
|
EGLDisplay egl_display = _gdk_mir_display_get_egl_display (display);
|
||||||
|
EGLSurface egl_surface;
|
||||||
|
|
||||||
|
gdk_gl_context_make_current (context);
|
||||||
|
|
||||||
|
egl_surface = _gdk_mir_window_get_egl_surface (window,
|
||||||
|
context_mir->egl_config);
|
||||||
|
|
||||||
|
if (_gdk_mir_display_have_egl_swap_buffers_with_damage (display))
|
||||||
|
{
|
||||||
|
int i, j, n_rects = cairo_region_num_rectangles (damage);
|
||||||
|
EGLint *rects = g_new (EGLint, n_rects * 4);
|
||||||
|
cairo_rectangle_int_t rect;
|
||||||
|
int window_height = gdk_window_get_height (window);
|
||||||
|
|
||||||
|
for (i = 0, j = 0; i < n_rects; i++)
|
||||||
|
{
|
||||||
|
cairo_region_get_rectangle (damage, i, &rect);
|
||||||
|
rects[j++] = rect.x;
|
||||||
|
rects[j++] = window_height - rect.height - rect.y;
|
||||||
|
rects[j++] = rect.width;
|
||||||
|
rects[j++] = rect.height;
|
||||||
|
}
|
||||||
|
eglSwapBuffersWithDamageEXT (egl_display, egl_surface, rects, n_rects);
|
||||||
|
g_free (rects);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
eglSwapBuffers (egl_display, egl_surface);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gdk_mir_gl_context_class_init (GdkMirGLContextClass *klass)
|
||||||
|
{
|
||||||
|
GdkGLContextClass *context_class = GDK_GL_CONTEXT_CLASS (klass);
|
||||||
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
context_class->update = gdk_mir_gl_context_update;
|
||||||
|
context_class->end_frame = gdk_mir_gl_context_end_frame;
|
||||||
|
gobject_class->dispose = gdk_mir_gl_context_dispose;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gdk_mir_gl_context_init (GdkMirGLContext *self)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#define MAX_EGL_ATTRS 30
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
find_eglconfig_for_window (GdkWindow *window,
|
||||||
|
EGLConfig *egl_config_out,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
GdkDisplay *display = gdk_window_get_display (window);
|
||||||
|
EGLDisplay *egl_display = _gdk_mir_display_get_egl_display (display);
|
||||||
|
GdkVisual *visual = gdk_window_get_visual (window);
|
||||||
|
EGLint attrs[MAX_EGL_ATTRS];
|
||||||
|
EGLint count;
|
||||||
|
EGLConfig *configs;
|
||||||
|
gboolean use_rgba;
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
attrs[i++] = EGL_SURFACE_TYPE;
|
||||||
|
attrs[i++] = EGL_WINDOW_BIT;
|
||||||
|
|
||||||
|
attrs[i++] = EGL_COLOR_BUFFER_TYPE;
|
||||||
|
attrs[i++] = EGL_RGB_BUFFER;
|
||||||
|
|
||||||
|
attrs[i++] = EGL_RED_SIZE;
|
||||||
|
attrs[i++] = 1;
|
||||||
|
attrs[i++] = EGL_GREEN_SIZE;
|
||||||
|
attrs[i++] = 1;
|
||||||
|
attrs[i++] = EGL_BLUE_SIZE;
|
||||||
|
attrs[i++] = 1;
|
||||||
|
|
||||||
|
use_rgba = (visual == gdk_screen_get_rgba_visual (gdk_display_get_default_screen (display)));
|
||||||
|
|
||||||
|
if (use_rgba)
|
||||||
|
{
|
||||||
|
attrs[i++] = EGL_ALPHA_SIZE;
|
||||||
|
attrs[i++] = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
attrs[i++] = EGL_ALPHA_SIZE;
|
||||||
|
attrs[i++] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
attrs[i++] = EGL_NONE;
|
||||||
|
g_assert (i < MAX_EGL_ATTRS);
|
||||||
|
|
||||||
|
if (!eglChooseConfig (egl_display, attrs, NULL, 0, &count) || count < 1)
|
||||||
|
{
|
||||||
|
g_set_error_literal (error, GDK_GL_ERROR,
|
||||||
|
GDK_GL_ERROR_UNSUPPORTED_FORMAT,
|
||||||
|
_("No available configurations for the given pixel format"));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
configs = g_new (EGLConfig, count);
|
||||||
|
|
||||||
|
if (!eglChooseConfig (egl_display, attrs, configs, count, &count) || count < 1)
|
||||||
|
{
|
||||||
|
g_set_error_literal (error, GDK_GL_ERROR,
|
||||||
|
GDK_GL_ERROR_UNSUPPORTED_FORMAT,
|
||||||
|
_("No available configurations for the given pixel format"));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Pick first valid configuration i guess? */
|
||||||
|
|
||||||
|
if (egl_config_out != NULL)
|
||||||
|
*egl_config_out = configs[0];
|
||||||
|
|
||||||
|
g_free (configs);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
GdkGLContext *
|
||||||
|
_gdk_mir_window_create_gl_context (GdkWindow *window,
|
||||||
|
gboolean attached,
|
||||||
|
GdkGLProfile profile,
|
||||||
|
GdkGLContext *share,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
GdkDisplay *display = gdk_window_get_display (window);
|
||||||
|
GdkMirGLContext *context;
|
||||||
|
EGLContext ctx;
|
||||||
|
EGLConfig config;
|
||||||
|
int i;
|
||||||
|
EGLint context_attribs[3];
|
||||||
|
|
||||||
|
if (!_gdk_mir_display_init_egl_display (display))
|
||||||
|
{
|
||||||
|
g_set_error_literal (error, GDK_GL_ERROR,
|
||||||
|
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||||
|
_("No GL implementation is available"));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (profile == GDK_GL_PROFILE_DEFAULT)
|
||||||
|
profile = GDK_GL_PROFILE_LEGACY;
|
||||||
|
|
||||||
|
if (profile == GDK_GL_PROFILE_3_2_CORE &&
|
||||||
|
!_gdk_mir_display_have_egl_khr_create_context (display))
|
||||||
|
{
|
||||||
|
g_set_error_literal (error, GDK_GL_ERROR,
|
||||||
|
GDK_GL_ERROR_UNSUPPORTED_PROFILE,
|
||||||
|
_("3.2 core GL profile is not available on EGL implementation"));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!find_eglconfig_for_window (window, &config, error))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
if (profile == GDK_GL_PROFILE_3_2_CORE)
|
||||||
|
{
|
||||||
|
context_attribs[i++] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
|
||||||
|
context_attribs[i++] = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
|
||||||
|
}
|
||||||
|
context_attribs[i++] = EGL_NONE;
|
||||||
|
|
||||||
|
ctx = eglCreateContext (_gdk_mir_display_get_egl_display (display),
|
||||||
|
config,
|
||||||
|
share ? GDK_MIR_GL_CONTEXT (share)->egl_context : EGL_NO_CONTEXT,
|
||||||
|
context_attribs);
|
||||||
|
if (ctx == NULL)
|
||||||
|
{
|
||||||
|
g_set_error_literal (error, GDK_GL_ERROR,
|
||||||
|
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||||
|
_("Unable to create a GL context"));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
GDK_NOTE (OPENGL,
|
||||||
|
g_print ("Created EGL context[%p]\n", ctx));
|
||||||
|
|
||||||
|
context = g_object_new (GDK_TYPE_MIR_GL_CONTEXT,
|
||||||
|
"display", display,
|
||||||
|
"window", window,
|
||||||
|
"profile", profile,
|
||||||
|
"shared-context", share,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
context->egl_config = config;
|
||||||
|
context->egl_context = ctx;
|
||||||
|
context->is_attached = attached;
|
||||||
|
|
||||||
|
return GDK_GL_CONTEXT (context);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gdk_mir_gl_context_dispose (GObject *gobject)
|
||||||
|
{
|
||||||
|
GdkMirGLContext *context_mir = GDK_MIR_GL_CONTEXT (gobject);
|
||||||
|
|
||||||
|
if (context_mir->egl_context != NULL)
|
||||||
|
{
|
||||||
|
GdkGLContext *context = GDK_GL_CONTEXT (gobject);
|
||||||
|
GdkWindow *window = gdk_gl_context_get_window (context);
|
||||||
|
GdkDisplay *display = gdk_window_get_display (window);
|
||||||
|
EGLDisplay egl_display = _gdk_mir_display_get_egl_display (display);
|
||||||
|
|
||||||
|
if (eglGetCurrentContext () == context_mir->egl_context)
|
||||||
|
eglMakeCurrent (egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||||
|
|
||||||
|
GDK_NOTE (OPENGL, g_print ("Destroying EGL context\n"));
|
||||||
|
|
||||||
|
eglDestroyContext (egl_display, context_mir->egl_context);
|
||||||
|
context_mir->egl_context = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (gdk_mir_gl_context_parent_class)->dispose (gobject);
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
_gdk_mir_display_make_gl_context_current (GdkDisplay *display,
|
||||||
|
GdkGLContext *context)
|
||||||
|
{
|
||||||
|
EGLDisplay egl_display = _gdk_mir_display_get_egl_display (display);
|
||||||
|
GdkMirGLContext *mir_context;
|
||||||
|
GdkWindow *window;
|
||||||
|
EGLSurface egl_surface;
|
||||||
|
|
||||||
|
if (context == NULL)
|
||||||
|
{
|
||||||
|
eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
mir_context = GDK_MIR_GL_CONTEXT (context);
|
||||||
|
window = gdk_gl_context_get_window (context);
|
||||||
|
|
||||||
|
if (mir_context->is_attached)
|
||||||
|
{
|
||||||
|
egl_surface = _gdk_mir_window_get_egl_surface (window,
|
||||||
|
mir_context->egl_config);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_gdk_mir_display_have_egl_surfaceless_context (display))
|
||||||
|
egl_surface = EGL_NO_SURFACE;
|
||||||
|
else
|
||||||
|
egl_surface = _gdk_mir_window_get_dummy_egl_surface (window,
|
||||||
|
mir_context->egl_config);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!eglMakeCurrent (egl_display, egl_surface, egl_surface, mir_context->egl_context))
|
||||||
|
{
|
||||||
|
g_warning ("eglMakeCurrent failed");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
@@ -64,6 +64,13 @@ struct _GdkMirWindowImpl
|
|||||||
/* Cairo context for current frame */
|
/* Cairo context for current frame */
|
||||||
cairo_surface_t *cairo_surface;
|
cairo_surface_t *cairo_surface;
|
||||||
|
|
||||||
|
/* Egl surface for the current mir surface */
|
||||||
|
EGLSurface egl_surface;
|
||||||
|
|
||||||
|
/* Dummy MIR and EGL surfaces */
|
||||||
|
MirSurface *dummy_surface;
|
||||||
|
EGLSurface dummy_egl_surface;
|
||||||
|
|
||||||
/* TRUE if the window can be seen */
|
/* TRUE if the window can be seen */
|
||||||
gboolean visible;
|
gboolean visible;
|
||||||
|
|
||||||
@@ -135,12 +142,6 @@ gdk_mir_window_impl_init (GdkMirWindowImpl *impl)
|
|||||||
impl->surface_state = mir_surface_state_unknown;
|
impl->surface_state = mir_surface_state_unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
static MirConnection *
|
|
||||||
get_connection (GdkWindow *window)
|
|
||||||
{
|
|
||||||
return gdk_mir_display_get_mir_connection (gdk_window_get_display (window));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_surface_state (GdkMirWindowImpl *impl,
|
set_surface_state (GdkMirWindowImpl *impl,
|
||||||
MirSurfaceState state)
|
MirSurfaceState state)
|
||||||
@@ -173,13 +174,32 @@ event_cb (MirSurface *surface,
|
|||||||
_gdk_mir_event_source_queue (context, event);
|
_gdk_mir_event_source_queue (context, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static MirSurface *
|
||||||
|
create_mir_surface (GdkDisplay *display,
|
||||||
|
gint width,
|
||||||
|
gint height,
|
||||||
|
MirBufferUsage buffer_usage)
|
||||||
|
{
|
||||||
|
MirSurfaceParameters parameters;
|
||||||
|
MirConnection *connection;
|
||||||
|
|
||||||
|
parameters.name = "GTK+ Mir";
|
||||||
|
parameters.width = width;
|
||||||
|
parameters.height = height;
|
||||||
|
parameters.pixel_format = _gdk_mir_display_get_pixel_format (display, buffer_usage);
|
||||||
|
parameters.buffer_usage = buffer_usage;
|
||||||
|
parameters.output_id = mir_display_output_id_invalid;
|
||||||
|
|
||||||
|
connection = gdk_mir_display_get_mir_connection (display);
|
||||||
|
|
||||||
|
return mir_connection_create_surface_sync (connection, ¶meters);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ensure_surface (GdkWindow *window)
|
ensure_surface_full (GdkWindow *window,
|
||||||
|
MirBufferUsage buffer_usage)
|
||||||
{
|
{
|
||||||
GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
|
GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
|
||||||
MirPixelFormat formats[mir_pixel_formats], pixel_format = mir_pixel_format_invalid;
|
|
||||||
unsigned int n_formats, i;
|
|
||||||
MirSurfaceParameters parameters;
|
|
||||||
MirEventDelegate event_delegate = { event_cb, NULL };
|
MirEventDelegate event_delegate = { event_cb, NULL };
|
||||||
GdkMirWindowReference *window_ref;
|
GdkMirWindowReference *window_ref;
|
||||||
|
|
||||||
@@ -193,34 +213,17 @@ ensure_surface (GdkWindow *window)
|
|||||||
|
|
||||||
event_delegate.context = window_ref;
|
event_delegate.context = window_ref;
|
||||||
|
|
||||||
// Should probably calculate this once?
|
impl->surface = create_mir_surface (gdk_window_get_display (window),
|
||||||
// Should prefer certain formats over others
|
window->width, window->height,
|
||||||
mir_connection_get_available_surface_formats (get_connection (window), formats, mir_pixel_formats, &n_formats);
|
buffer_usage);
|
||||||
for (i = 0; i < n_formats; i++)
|
|
||||||
if (formats[i] == mir_pixel_format_argb_8888)
|
|
||||||
{
|
|
||||||
pixel_format = formats[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
parameters.name = "GTK+ Mir";
|
|
||||||
parameters.width = window->width;
|
|
||||||
parameters.height = window->height;
|
|
||||||
parameters.pixel_format = pixel_format;
|
|
||||||
parameters.buffer_usage = mir_buffer_usage_software;
|
|
||||||
parameters.output_id = mir_display_output_id_invalid;
|
|
||||||
impl->surface = mir_connection_create_surface_sync (get_connection (window), ¶meters);
|
|
||||||
|
|
||||||
MirGraphicsRegion region;
|
|
||||||
MirEvent resize_event;
|
MirEvent resize_event;
|
||||||
|
|
||||||
mir_surface_get_graphics_region (impl->surface, ®ion);
|
|
||||||
|
|
||||||
/* Send the initial configure with the size the server gave... */
|
/* Send the initial configure with the size the server gave... */
|
||||||
resize_event.resize.type = mir_event_type_resize;
|
resize_event.resize.type = mir_event_type_resize;
|
||||||
resize_event.resize.surface_id = 0;
|
resize_event.resize.surface_id = 0;
|
||||||
resize_event.resize.width = region.width;
|
resize_event.resize.width = window->width;
|
||||||
resize_event.resize.height = region.height;
|
resize_event.resize.height = window->height;
|
||||||
|
|
||||||
_gdk_mir_event_source_queue (window_ref, &resize_event);
|
_gdk_mir_event_source_queue (window_ref, &resize_event);
|
||||||
|
|
||||||
@@ -229,6 +232,14 @@ ensure_surface (GdkWindow *window)
|
|||||||
set_surface_state (impl, impl->surface_state);
|
set_surface_state (impl, impl->surface_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
ensure_surface (GdkWindow *window)
|
||||||
|
{
|
||||||
|
ensure_surface_full (window, window->gl_paint_context ?
|
||||||
|
mir_buffer_usage_hardware :
|
||||||
|
mir_buffer_usage_software);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ensure_no_surface (GdkWindow *window)
|
ensure_no_surface (GdkWindow *window)
|
||||||
{
|
{
|
||||||
@@ -237,15 +248,30 @@ ensure_no_surface (GdkWindow *window)
|
|||||||
if (impl->cairo_surface)
|
if (impl->cairo_surface)
|
||||||
{
|
{
|
||||||
cairo_surface_finish (impl->cairo_surface);
|
cairo_surface_finish (impl->cairo_surface);
|
||||||
cairo_surface_destroy (impl->cairo_surface);
|
g_clear_pointer (&impl->cairo_surface, cairo_surface_destroy);
|
||||||
impl->cairo_surface = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (impl->surface)
|
if (window->gl_paint_context)
|
||||||
{
|
{
|
||||||
mir_surface_release_sync (impl->surface);
|
GdkDisplay *display = gdk_window_get_display (window);
|
||||||
impl->surface = NULL;
|
EGLDisplay egl_display = _gdk_mir_display_get_egl_display (display);
|
||||||
|
|
||||||
|
if (impl->egl_surface)
|
||||||
|
{
|
||||||
|
eglDestroySurface (egl_display, impl->egl_surface);
|
||||||
|
impl->egl_surface = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (impl->dummy_egl_surface)
|
||||||
|
{
|
||||||
|
eglDestroySurface (egl_display, impl->dummy_egl_surface);
|
||||||
|
impl->dummy_egl_surface = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_clear_pointer (&impl->dummy_surface, mir_surface_release_sync);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_clear_pointer(&impl->surface, mir_surface_release_sync);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -303,11 +329,7 @@ send_buffer (GdkWindow *window)
|
|||||||
mir_surface_swap_buffers_sync (impl->surface);
|
mir_surface_swap_buffers_sync (impl->surface);
|
||||||
|
|
||||||
/* The Cairo context is no longer valid */
|
/* The Cairo context is no longer valid */
|
||||||
if (impl->cairo_surface)
|
g_clear_pointer (&impl->cairo_surface, cairo_surface_destroy);
|
||||||
{
|
|
||||||
cairo_surface_destroy (impl->cairo_surface);
|
|
||||||
impl->cairo_surface = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static cairo_surface_t *
|
static cairo_surface_t *
|
||||||
@@ -316,7 +338,7 @@ gdk_mir_window_impl_ref_cairo_surface (GdkWindow *window)
|
|||||||
//g_printerr ("gdk_mir_window_impl_ref_cairo_surface window=%p\n", window);
|
//g_printerr ("gdk_mir_window_impl_ref_cairo_surface window=%p\n", window);
|
||||||
GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
|
GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
|
||||||
MirGraphicsRegion region;
|
MirGraphicsRegion region;
|
||||||
cairo_format_t pixel_format = CAIRO_FORMAT_INVALID;
|
cairo_format_t pixel_format = CAIRO_FORMAT_ARGB32;
|
||||||
cairo_surface_t *cairo_surface;
|
cairo_surface_t *cairo_surface;
|
||||||
cairo_t *c;
|
cairo_t *c;
|
||||||
|
|
||||||
@@ -327,31 +349,16 @@ gdk_mir_window_impl_ref_cairo_surface (GdkWindow *window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Transient windows get rendered into a buffer and copied onto their parent */
|
/* Transient windows get rendered into a buffer and copied onto their parent */
|
||||||
if (impl->transient_for)
|
if (impl->transient_for || window->gl_paint_context)
|
||||||
{
|
{
|
||||||
cairo_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, window->width, window->height);
|
cairo_surface = cairo_image_surface_create (pixel_format, window->width, window->height);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ensure_surface (window);
|
ensure_surface (window);
|
||||||
|
|
||||||
mir_surface_get_graphics_region (impl->surface, ®ion);
|
mir_surface_get_graphics_region (impl->surface, ®ion);
|
||||||
|
g_assert (region.pixel_format == mir_pixel_format_argb_8888);
|
||||||
// FIXME: Should calculate this once
|
|
||||||
switch (region.pixel_format)
|
|
||||||
{
|
|
||||||
case mir_pixel_format_argb_8888:
|
|
||||||
pixel_format = CAIRO_FORMAT_ARGB32;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
case mir_pixel_format_abgr_8888:
|
|
||||||
case mir_pixel_format_xbgr_8888:
|
|
||||||
case mir_pixel_format_xrgb_8888:
|
|
||||||
case mir_pixel_format_bgr_888:
|
|
||||||
// uh-oh...
|
|
||||||
g_printerr ("Unsupported pixel format %d\n", region.pixel_format);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
cairo_surface = cairo_image_surface_create_for_data ((unsigned char *) region.vaddr,
|
cairo_surface = cairo_image_surface_create_for_data ((unsigned char *) region.vaddr,
|
||||||
pixel_format,
|
pixel_format,
|
||||||
@@ -421,10 +428,13 @@ gdk_mir_window_impl_show (GdkWindow *window,
|
|||||||
/* Make sure there's a surface to see */
|
/* Make sure there's a surface to see */
|
||||||
ensure_surface (window);
|
ensure_surface (window);
|
||||||
|
|
||||||
/* Make sure something is rendered and then show first frame */
|
if (!window->gl_paint_context)
|
||||||
s = gdk_mir_window_impl_ref_cairo_surface (window);
|
{
|
||||||
send_buffer (window);
|
/* Make sure something is rendered and then show first frame */
|
||||||
cairo_surface_destroy (s);
|
s = gdk_mir_window_impl_ref_cairo_surface (window);
|
||||||
|
send_buffer (window);
|
||||||
|
cairo_surface_destroy (s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -666,7 +676,7 @@ gdk_mir_window_impl_end_paint (GdkWindow *window)
|
|||||||
GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
|
GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
|
||||||
|
|
||||||
//g_printerr ("gdk_mir_window_impl_end_paint window=%p\n", window);
|
//g_printerr ("gdk_mir_window_impl_end_paint window=%p\n", window);
|
||||||
if (impl->visible)
|
if (impl->visible && !window->current_paint.use_gl)
|
||||||
send_buffer (window);
|
send_buffer (window);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1245,6 +1255,72 @@ gdk_mir_window_impl_set_shadow_width (GdkWindow *window,
|
|||||||
g_printerr ("gdk_mir_window_impl_set_shadow_width window=%p\n", window);
|
g_printerr ("gdk_mir_window_impl_set_shadow_width window=%p\n", window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EGLSurface
|
||||||
|
_gdk_mir_window_get_egl_surface (GdkWindow *window,
|
||||||
|
EGLConfig config)
|
||||||
|
{
|
||||||
|
GdkMirWindowImpl *impl;
|
||||||
|
|
||||||
|
impl = GDK_MIR_WINDOW_IMPL (window->impl);
|
||||||
|
|
||||||
|
if (!impl->egl_surface)
|
||||||
|
{
|
||||||
|
EGLDisplay egl_display;
|
||||||
|
EGLNativeWindowType egl_window;
|
||||||
|
|
||||||
|
ensure_no_surface (window);
|
||||||
|
ensure_surface_full (window, mir_buffer_usage_hardware);
|
||||||
|
|
||||||
|
egl_display = _gdk_mir_display_get_egl_display (gdk_window_get_display (window));
|
||||||
|
egl_window = (EGLNativeWindowType) mir_surface_get_egl_native_window (impl->surface);
|
||||||
|
|
||||||
|
impl->egl_surface =
|
||||||
|
eglCreateWindowSurface (egl_display, config, egl_window, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return impl->egl_surface;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLSurface
|
||||||
|
_gdk_mir_window_get_dummy_egl_surface (GdkWindow *window,
|
||||||
|
EGLConfig config)
|
||||||
|
{
|
||||||
|
GdkMirWindowImpl *impl;
|
||||||
|
|
||||||
|
impl = GDK_MIR_WINDOW_IMPL (window->impl);
|
||||||
|
|
||||||
|
if (!impl->dummy_egl_surface)
|
||||||
|
{
|
||||||
|
GdkDisplay *display;
|
||||||
|
EGLDisplay egl_display;
|
||||||
|
EGLNativeWindowType egl_window;
|
||||||
|
|
||||||
|
display = gdk_window_get_display (window);
|
||||||
|
impl->dummy_surface = create_mir_surface (display, 1, 1,
|
||||||
|
mir_buffer_usage_hardware);
|
||||||
|
|
||||||
|
egl_display = _gdk_mir_display_get_egl_display (display);
|
||||||
|
egl_window = (EGLNativeWindowType) mir_surface_get_egl_native_window (impl->surface);
|
||||||
|
|
||||||
|
impl->dummy_egl_surface =
|
||||||
|
eglCreateWindowSurface (egl_display, config, egl_window, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return impl->dummy_egl_surface;
|
||||||
|
}
|
||||||
|
|
||||||
|
MirSurface *
|
||||||
|
gdk_mir_window_get_mir_surface (GdkWindow *window)
|
||||||
|
{
|
||||||
|
GdkMirWindowImpl *impl;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GDK_IS_WINDOW_MIR (window), NULL);
|
||||||
|
|
||||||
|
impl = GDK_MIR_WINDOW_IMPL (window->impl);
|
||||||
|
|
||||||
|
return impl->surface;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gdk_mir_window_impl_class_init (GdkMirWindowImplClass *klass)
|
gdk_mir_window_impl_class_init (GdkMirWindowImplClass *klass)
|
||||||
{
|
{
|
||||||
@@ -1333,4 +1409,6 @@ gdk_mir_window_impl_class_init (GdkMirWindowImplClass *klass)
|
|||||||
impl_class->get_scale_factor = gdk_mir_window_impl_get_scale_factor;
|
impl_class->get_scale_factor = gdk_mir_window_impl_get_scale_factor;
|
||||||
impl_class->set_opaque_region = gdk_mir_window_impl_set_opaque_region;
|
impl_class->set_opaque_region = gdk_mir_window_impl_set_opaque_region;
|
||||||
impl_class->set_shadow_width = gdk_mir_window_impl_set_shadow_width;
|
impl_class->set_shadow_width = gdk_mir_window_impl_set_shadow_width;
|
||||||
|
impl_class->create_gl_context = _gdk_mir_window_create_gl_context;
|
||||||
|
impl_class->invalidate_for_new_frame = _gdk_mir_window_invalidate_for_new_frame;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user