From 559ae8b32662a90ab62f0e44b06983cbed20188a Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 1 May 2019 23:58:57 +0200 Subject: [PATCH] gsk: Export Cairo renderer --- docs/reference/gsk/gsk4-sections.txt | 4 ++- gsk/gsk.h | 2 ++ gsk/gskcairorenderer.c | 42 +++++++++++++++++++++++- gsk/gskcairorenderer.h | 48 ++++++++++++++++++++++++++++ gsk/gskcairorendererprivate.h | 24 -------------- gsk/gskrenderer.c | 2 +- gsk/meson.build | 3 +- 7 files changed, 97 insertions(+), 28 deletions(-) create mode 100644 gsk/gskcairorenderer.h delete mode 100644 gsk/gskcairorendererprivate.h diff --git a/docs/reference/gsk/gsk4-sections.txt b/docs/reference/gsk/gsk4-sections.txt index ea27a54f02..21f50cdc45 100644 --- a/docs/reference/gsk/gsk4-sections.txt +++ b/docs/reference/gsk/gsk4-sections.txt @@ -1,12 +1,14 @@
GskRenderer -gsk_renderer_new_for_surface gsk_renderer_get_surface gsk_renderer_realize gsk_renderer_unrealize gsk_renderer_is_realized gsk_renderer_render gsk_renderer_render_texture + +gsk_renderer_new_for_surface +gsk_cairo_renderer_new GSK_IS_RENDERER GSK_RENDERER diff --git a/gsk/gsk.h b/gsk/gsk.h index 88f312c210..523b24c81a 100644 --- a/gsk/gsk.h +++ b/gsk/gsk.h @@ -26,6 +26,8 @@ #include #include +#include + #include #include diff --git a/gsk/gskcairorenderer.c b/gsk/gskcairorenderer.c index 3d37e838cb..074b54b97f 100644 --- a/gsk/gskcairorenderer.c +++ b/gsk/gskcairorenderer.c @@ -1,6 +1,26 @@ +/* + * Copyright © 2016 Endless + * 2018 Benjamin Otte + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Authors: Benjamin Otte + */ + #include "config.h" -#include "gskcairorendererprivate.h" +#include "gskcairorenderer.h" #include "gskdebugprivate.h" #include "gskrendererprivate.h" @@ -159,3 +179,23 @@ gsk_cairo_renderer_init (GskCairoRenderer *self) self->profile_timers.cpu_time = gsk_profiler_add_timer (profiler, "cpu-time", "CPU time", FALSE, TRUE); #endif } + +/** + * gsk_cairo_renderer_new: + * + * Creates a new Cairo renderer. + * + * The Cairo renderer is the fallback renderer drawing in ways similar + * to how GTK 3 drew its content. Its primary use is as comparison tool. + * + * The Cairo renderer is incomplete. It cannot render 3D transformed + * content and will instead render an error marker. Its usage should be + * avoided. + * + * Returns: a new Cairo renderer. + **/ +GskRenderer * +gsk_cairo_renderer_new (void) +{ + return g_object_new (GSK_TYPE_CAIRO_RENDERER, NULL); +} diff --git a/gsk/gskcairorenderer.h b/gsk/gskcairorenderer.h new file mode 100644 index 0000000000..047bd69555 --- /dev/null +++ b/gsk/gskcairorenderer.h @@ -0,0 +1,48 @@ +/* + * Copyright © 2016 Endless + * 2018 Benjamin Otte + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Authors: Benjamin Otte + */ + +#ifndef __GSK_CAIRO_RENDERER_H__ +#define __GSK_CAIRO_RENDERER_H__ + +#include +#include + +G_BEGIN_DECLS + +#define GSK_TYPE_CAIRO_RENDERER (gsk_cairo_renderer_get_type ()) + +#define GSK_CAIRO_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSK_TYPE_CAIRO_RENDERER, GskCairoRenderer)) +#define GSK_IS_CAIRO_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSK_TYPE_CAIRO_RENDERER)) +#define GSK_CAIRO_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSK_TYPE_CAIRO_RENDERER, GskCairoRendererClass)) +#define GSK_IS_CAIRO_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSK_TYPE_CAIRO_RENDERER)) +#define GSK_CAIRO_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GSK_TYPE_CAIRO_RENDERER, GskCairoRendererClass)) + +typedef struct _GskCairoRenderer GskCairoRenderer; +typedef struct _GskCairoRendererClass GskCairoRendererClass; + +GDK_AVAILABLE_IN_ALL +GType gsk_cairo_renderer_get_type (void) G_GNUC_CONST; + +GDK_AVAILABLE_IN_ALL +GskRenderer * gsk_cairo_renderer_new (void); + +G_END_DECLS + +#endif /* __GSK_CAIRO_RENDERER_H__ */ diff --git a/gsk/gskcairorendererprivate.h b/gsk/gskcairorendererprivate.h deleted file mode 100644 index e456ff20db..0000000000 --- a/gsk/gskcairorendererprivate.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef __GSK_CAIRO_RENDERER_PRIVATE_H__ -#define __GSK_CAIRO_RENDERER_PRIVATE_H__ - -#include -#include - -G_BEGIN_DECLS - -#define GSK_TYPE_CAIRO_RENDERER (gsk_cairo_renderer_get_type ()) - -#define GSK_CAIRO_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSK_TYPE_CAIRO_RENDERER, GskCairoRenderer)) -#define GSK_IS_CAIRO_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSK_TYPE_CAIRO_RENDERER)) -#define GSK_CAIRO_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSK_TYPE_CAIRO_RENDERER, GskCairoRendererClass)) -#define GSK_IS_CAIRO_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSK_TYPE_CAIRO_RENDERER)) -#define GSK_CAIRO_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GSK_TYPE_CAIRO_RENDERER, GskCairoRendererClass)) - -typedef struct _GskCairoRenderer GskCairoRenderer; -typedef struct _GskCairoRendererClass GskCairoRendererClass; - -GType gsk_cairo_renderer_get_type (void) G_GNUC_CONST; - -G_END_DECLS - -#endif /* __GSK_CAIRO_RENDERER_PRIVATE_H__ */ diff --git a/gsk/gskrenderer.c b/gsk/gskrenderer.c index 0fdfbc63e7..8f202d96ea 100644 --- a/gsk/gskrenderer.c +++ b/gsk/gskrenderer.c @@ -36,7 +36,7 @@ #include "gskrendererprivate.h" -#include "gskcairorendererprivate.h" +#include "gskcairorenderer.h" #include "gskdebugprivate.h" #include "gl/gskglrendererprivate.h" #include "gskprofilerprivate.h" diff --git a/gsk/meson.build b/gsk/meson.build index 73806fea27..d05d1d8292 100644 --- a/gsk/meson.build +++ b/gsk/meson.build @@ -22,6 +22,7 @@ gsk_private_gl_shaders = [ gsk_public_sources = files([ 'gskdiff.c', + 'gskcairorenderer.c', 'gskrenderer.c', 'gskrendernode.c', 'gskrendernodeimpl.c', @@ -31,7 +32,6 @@ gsk_public_sources = files([ gsk_private_sources = files([ 'gskcairoblur.c', - 'gskcairorenderer.c', 'gskdebug.c', 'gskprivate.c', 'gskprofiler.c', @@ -48,6 +48,7 @@ gsk_private_sources = files([ ]) gsk_public_headers = files([ + 'gskcairorenderer.h', 'gskenums.h', 'gskrenderer.h', 'gskrendernode.h',