mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 23:50:41 -05:00
cogl: Add API for setting custom winsys
https://bugzilla.gnome.org/show_bug.cgi?id=768976
This commit is contained in:
parent
e2f5579391
commit
d6cde4b043
42
cogl/cogl/cogl-mutter.h
Normal file
42
cogl/cogl/cogl-mutter.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* A Low Level GPU Graphics and Utilities API
|
||||
*
|
||||
* Copyright (C) 2016 Red Hat Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy,
|
||||
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __COGL_MUTTER_H___
|
||||
#define __COGL_MUTTER_H___
|
||||
|
||||
#include <cogl/winsys/cogl-winsys-egl-kms-private.h>
|
||||
#include <cogl/winsys/cogl-winsys-private.h>
|
||||
|
||||
typedef const CoglWinsysVtable *(*CoglWinsysVtableGetter) (void);
|
||||
|
||||
void cogl_renderer_set_custom_winsys (CoglRenderer *renderer,
|
||||
CoglWinsysVtableGetter winsys_vtable_getter);
|
||||
|
||||
#endif /* __COGL_MUTTER_H___ */
|
@ -39,6 +39,7 @@
|
||||
#include "cogl-texture-driver.h"
|
||||
#include "cogl-context.h"
|
||||
#include "cogl-closure-list-private.h"
|
||||
#include "cogl-mutter.h"
|
||||
|
||||
#ifdef COGL_HAS_XLIB_SUPPORT
|
||||
#include <X11/Xlib.h>
|
||||
@ -52,6 +53,7 @@ struct _CoglRenderer
|
||||
const CoglDriverVtable *driver_vtable;
|
||||
const CoglTextureDriver *texture_driver;
|
||||
const CoglWinsysVtable *winsys_vtable;
|
||||
CoglWinsysVtableGetter custom_winsys_vtable_getter;
|
||||
CoglWinsysID winsys_id_override;
|
||||
GList *constraints;
|
||||
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "cogl-object.h"
|
||||
#include "cogl-context-private.h"
|
||||
#include "cogl-util-gl-private.h"
|
||||
#include "cogl-mutter.h"
|
||||
|
||||
#include "cogl-renderer.h"
|
||||
#include "cogl-renderer-private.h"
|
||||
@ -65,8 +66,6 @@
|
||||
#include "cogl-xlib-renderer.h"
|
||||
#endif
|
||||
|
||||
typedef const CoglWinsysVtable *(*CoglWinsysVtableGetter) (void);
|
||||
|
||||
#ifdef HAVE_COGL_GL
|
||||
extern const CoglTextureDriver _cogl_texture_driver_gl;
|
||||
extern const CoglDriverVtable _cogl_driver_gl;
|
||||
@ -564,6 +563,46 @@ _cogl_renderer_choose_driver (CoglRenderer *renderer,
|
||||
|
||||
/* Final connection API */
|
||||
|
||||
void
|
||||
cogl_renderer_set_custom_winsys (CoglRenderer *renderer,
|
||||
CoglWinsysVtableGetter winsys_vtable_getter)
|
||||
{
|
||||
renderer->custom_winsys_vtable_getter = winsys_vtable_getter;
|
||||
}
|
||||
|
||||
static CoglBool
|
||||
connect_custom_winsys (CoglRenderer *renderer,
|
||||
CoglError **error)
|
||||
{
|
||||
const CoglWinsysVtable *winsys = renderer->custom_winsys_vtable_getter();
|
||||
CoglError *tmp_error = NULL;
|
||||
GString *error_message;
|
||||
|
||||
renderer->winsys_vtable = winsys;
|
||||
|
||||
error_message = g_string_new ("");
|
||||
if (!winsys->renderer_connect (renderer, &tmp_error))
|
||||
{
|
||||
g_string_append_c (error_message, '\n');
|
||||
g_string_append (error_message, tmp_error->message);
|
||||
cogl_error_free (tmp_error);
|
||||
}
|
||||
else
|
||||
{
|
||||
renderer->connected = TRUE;
|
||||
g_string_free (error_message, TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
renderer->winsys_vtable = NULL;
|
||||
_cogl_set_error (error, COGL_WINSYS_ERROR,
|
||||
COGL_WINSYS_ERROR_INIT,
|
||||
"Failed to connected to any renderer: %s",
|
||||
error_message->str);
|
||||
g_string_free (error_message, TRUE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
CoglBool
|
||||
cogl_renderer_connect (CoglRenderer *renderer, CoglError **error)
|
||||
{
|
||||
@ -580,6 +619,9 @@ cogl_renderer_connect (CoglRenderer *renderer, CoglError **error)
|
||||
if (!_cogl_renderer_choose_driver (renderer, error))
|
||||
return FALSE;
|
||||
|
||||
if (renderer->custom_winsys_vtable_getter)
|
||||
return connect_custom_winsys (renderer, error);
|
||||
|
||||
error_message = g_string_new ("");
|
||||
for (i = 0; i < G_N_ELEMENTS (_cogl_winsys_vtable_getters); i++)
|
||||
{
|
||||
|
@ -96,6 +96,10 @@
|
||||
#include <cogl/deprecated/cogl-framebuffer-deprecated.h>
|
||||
#include <cogl/deprecated/cogl-auto-texture.h>
|
||||
|
||||
#ifdef COGL_ENABLE_MUTTER_API
|
||||
#include <cogl/cogl-mutter.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 2.0 api that's compatible with the 1.x api...
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user