Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8609cd5686 |
+1
-2
@@ -24,7 +24,7 @@ variables:
|
||||
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true"
|
||||
FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled"
|
||||
MESON_TEST_TIMEOUT_MULTIPLIER: 3
|
||||
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v28"
|
||||
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v27"
|
||||
FLATPAK_IMAGE: "registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master"
|
||||
DOCS_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora-docs:v25"
|
||||
|
||||
@@ -159,7 +159,6 @@ macos:
|
||||
- pip3 install --user meson==0.56
|
||||
- pip3 install --user ninja
|
||||
- export PATH=/Users/gitlabrunner/Library/Python/3.7/bin:$PATH
|
||||
- export MESON_FORCE_BACKTRACE=1
|
||||
script:
|
||||
- meson -Dx11-backend=false
|
||||
-Dintrospection=disabled
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM fedora:33
|
||||
FROM fedora:31
|
||||
|
||||
RUN dnf -y install \
|
||||
adwaita-icon-theme \
|
||||
@@ -66,7 +66,7 @@ RUN dnf -y install \
|
||||
mesa-dri-drivers \
|
||||
mesa-libEGL-devel \
|
||||
mesa-libGLES-devel \
|
||||
meson \
|
||||
mesa-libwayland-egl-devel \
|
||||
ninja-build \
|
||||
pango-devel \
|
||||
pcre-devel \
|
||||
@@ -87,3 +87,6 @@ RUN dnf -y install \
|
||||
which \
|
||||
xorg-x11-server-Xvfb \
|
||||
&& dnf clean all
|
||||
|
||||
RUN pip3 install meson==0.55.3
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM registry.gitlab.gnome.org/gnome/gtk/fedora-base:v28
|
||||
FROM registry.gitlab.gnome.org/gnome/gtk/fedora-base:v27
|
||||
|
||||
# Enable sudo for wheel users
|
||||
RUN sed -i -e 's/# %wheel/%wheel/' -e '0,/%wheel/{s/%wheel/# %wheel/}' /etc/sudoers
|
||||
|
||||
@@ -1,117 +1,3 @@
|
||||
Overview of Changes in 4.1.1
|
||||
============================
|
||||
|
||||
* Popover:
|
||||
- Support shadows on popover > contents
|
||||
|
||||
* Input:
|
||||
- Show preedit for compose sequences
|
||||
- Support long compose sequences
|
||||
- Support compose sequences producing multiple characters
|
||||
|
||||
* Themes:
|
||||
- Allow suggested and destructive actions in lists
|
||||
- Disable shadows on maximized, fullscreen and tiled windows
|
||||
- Fine-tune scrollbar transitions and size
|
||||
|
||||
* CSS:
|
||||
- Support drop-shadow filters
|
||||
- Correct blur filter spread interpretation
|
||||
|
||||
* Documentation:
|
||||
- Improvements and updates for dialogs and native dialog
|
||||
|
||||
* Printing:
|
||||
- Support Avahi-discovered printers better
|
||||
|
||||
* GSK:
|
||||
- Add another OpenGL render. It is not the default yet.
|
||||
To try it, use GSK_RENDERER=ngl
|
||||
|
||||
* Build:
|
||||
- Lots of static analysis fixes found by pvs
|
||||
- Add a -Dprofile=devel option for devel styling and
|
||||
use it for nightly flatpaks
|
||||
|
||||
* X11:
|
||||
- Fix DND of X11-specific types
|
||||
|
||||
* Wayland:
|
||||
- Fix lookup of font settings in flatpaks
|
||||
|
||||
* Windows:
|
||||
- Fix window resizing
|
||||
- Avoid UAC for gtk-update-icon-cache
|
||||
|
||||
* MacOs:
|
||||
- Use correct module file extension
|
||||
- Make OpenGL context opaque when possible
|
||||
- Fix window resizing
|
||||
|
||||
* Translation updates:
|
||||
British English
|
||||
Czech
|
||||
Danish
|
||||
Galician
|
||||
Hungarian
|
||||
Turkish
|
||||
|
||||
|
||||
Overview of Changes in 4.1.0
|
||||
============================
|
||||
|
||||
* GtkCheckButton:
|
||||
- Add back an activate signal
|
||||
|
||||
* GtkSearchBar, GtkSearchEntry:
|
||||
- Capture events in the bubble phase
|
||||
|
||||
* GtkEmojiChooser:
|
||||
- Adapt to small screen sizes
|
||||
|
||||
* GtkVideo:
|
||||
- Fix issues with GL support
|
||||
|
||||
* Themes:
|
||||
- Set sort arrows in CSS
|
||||
- Set menu button arrows in CSS
|
||||
- Make scrollbars larger
|
||||
- Supprt circular menubuttons
|
||||
|
||||
* CSS:
|
||||
- Implement transform-origin
|
||||
- Support overlines on text
|
||||
- Support colors in cross-fade()
|
||||
- More complete text-decoration-line support
|
||||
|
||||
* Text layout:
|
||||
- Use subpixel positioning with new enough cairo
|
||||
|
||||
* Inspector:
|
||||
- Fix slowness in navigation
|
||||
- Redo the controllers and shortcuts pages
|
||||
|
||||
* Accessibility:
|
||||
- Create AT context objects lazily
|
||||
|
||||
* Wayland:
|
||||
- Fix decoration negotiation under kwin
|
||||
|
||||
* GSK:
|
||||
- Optimize gradient shaders
|
||||
- Implement repeating gradients in shaders
|
||||
|
||||
* Translation updates
|
||||
- Czech
|
||||
- Greek
|
||||
- Hungarian
|
||||
- Persian
|
||||
- Punjabi
|
||||
- Romanian
|
||||
- Swedish
|
||||
- Ukrainian
|
||||
|
||||
|
||||
Overview of Changes in 4.0.2
|
||||
============================
|
||||
|
||||
|
||||
@@ -63,6 +63,36 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name" : "libsass",
|
||||
"buildsystem" : "meson",
|
||||
"builddir" : true,
|
||||
"config-opts" : [
|
||||
"--libdir=/app/lib"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
"type" : "git",
|
||||
"url" : "https://github.com/lazka/libsass.git",
|
||||
"branch" : "meson"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name" : "sassc",
|
||||
"buildsystem" : "meson",
|
||||
"builddir" : true,
|
||||
"config-opts" : [
|
||||
"--libdir=/app/lib"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
"type" : "git",
|
||||
"url" : "https://github.com/lazka/sassc.git",
|
||||
"branch" : "meson"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name" : "gtk",
|
||||
"buildsystem" : "meson",
|
||||
@@ -70,9 +100,7 @@
|
||||
"config-opts" : [
|
||||
"--libdir=/app/lib",
|
||||
"-Denable_vulkan=no",
|
||||
"-Dsassc=disabled",
|
||||
"-Dbuildtype=debugoptimized",
|
||||
"-Dprofile=devel"
|
||||
"-Dbuildtype=debugoptimized"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
|
||||
@@ -63,6 +63,36 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name" : "libsass",
|
||||
"buildsystem" : "meson",
|
||||
"builddir" : true,
|
||||
"config-opts" : [
|
||||
"--libdir=/app/lib"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
"type" : "git",
|
||||
"url" : "https://github.com/lazka/libsass.git",
|
||||
"branch" : "meson"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name" : "sassc",
|
||||
"buildsystem" : "meson",
|
||||
"builddir" : true,
|
||||
"config-opts" : [
|
||||
"--libdir=/app/lib"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
"type" : "git",
|
||||
"url" : "https://github.com/lazka/sassc.git",
|
||||
"branch" : "meson"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name" : "gtk",
|
||||
"buildsystem" : "meson",
|
||||
@@ -70,9 +100,7 @@
|
||||
"config-opts" : [
|
||||
"--libdir=/app/lib",
|
||||
"-Denable_vulkan=no",
|
||||
"-Dsassc=disabled",
|
||||
"-Dbuildtype=debugoptimized",
|
||||
"-Dprofile=devel"
|
||||
"-Dbuildtype=debugoptimized"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
|
||||
@@ -63,6 +63,36 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name" : "libsass",
|
||||
"buildsystem" : "meson",
|
||||
"builddir" : true,
|
||||
"config-opts" : [
|
||||
"--libdir=/app/lib"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
"type" : "git",
|
||||
"url" : "https://github.com/lazka/libsass.git",
|
||||
"branch" : "meson"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name" : "sassc",
|
||||
"buildsystem" : "meson",
|
||||
"builddir" : true,
|
||||
"config-opts" : [
|
||||
"--libdir=/app/lib"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
"type" : "git",
|
||||
"url" : "https://github.com/lazka/sassc.git",
|
||||
"branch" : "meson"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name" : "gtk",
|
||||
"buildsystem" : "meson",
|
||||
@@ -70,9 +100,7 @@
|
||||
"config-opts" : [
|
||||
"--libdir=/app/lib",
|
||||
"-Denable_vulkan=no",
|
||||
"-Dsassc=disabled",
|
||||
"-Dbuildtype=debugoptimized",
|
||||
"-Dprofile=devel"
|
||||
"-Dbuildtype=debugoptimized"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ create_application_list (void)
|
||||
}
|
||||
|
||||
/* This is the function we use for setting up new listitems to display.
|
||||
* We add just an #GtkImage and a #GtkLabel here to display the application's
|
||||
* We add just an #GtkImage and a #GtkKabel here to display the application's
|
||||
* icon and name, as this is just a simple demo.
|
||||
*/
|
||||
static void
|
||||
|
||||
+7
-16
@@ -25,8 +25,6 @@
|
||||
#include "demos.h"
|
||||
#include "fontify.h"
|
||||
|
||||
#include "demo_conf.h"
|
||||
|
||||
static GtkWidget *info_view;
|
||||
static GtkWidget *source_view;
|
||||
|
||||
@@ -198,20 +196,16 @@ activate_about (GSimpleAction *action,
|
||||
gtk_get_micro_version ());
|
||||
g_string_append_printf (s, "\nA link can appear here: <http://www.gtk.org>");
|
||||
|
||||
version = g_strdup_printf ("%s%s%s\nRunning against GTK %d.%d.%d",
|
||||
version = g_strdup_printf ("%s\nRunning against GTK %d.%d.%d",
|
||||
PACKAGE_VERSION,
|
||||
g_strcmp0 (PROFILE, "devel") == 0 ? "-" : "",
|
||||
g_strcmp0 (PROFILE, "devel") == 0 ? VCS_TAG : "",
|
||||
gtk_get_major_version (),
|
||||
gtk_get_minor_version (),
|
||||
gtk_get_micro_version ());
|
||||
|
||||
gtk_show_about_dialog (GTK_WINDOW (gtk_application_get_active_window (app)),
|
||||
"program-name", g_strcmp0 (PROFILE, "devel") == 0
|
||||
? "GTK Demo (Development)"
|
||||
: "GTK Demo",
|
||||
"program-name", "GTK Demo",
|
||||
"version", version,
|
||||
"copyright", "© 1997—2021 The GTK Team",
|
||||
"copyright", "© 1997—2020 The GTK Team",
|
||||
"license-type", GTK_LICENSE_LGPL_2_1,
|
||||
"website", "http://www.gtk.org",
|
||||
"comments", "Program to demonstrate GTK widgets",
|
||||
@@ -907,9 +901,6 @@ activate (GApplication *app)
|
||||
window = (GtkWidget *)gtk_builder_get_object (builder, "window");
|
||||
gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (window));
|
||||
|
||||
if (g_strcmp0 (PROFILE, "devel") == 0)
|
||||
gtk_widget_add_css_class (window, "devel");
|
||||
|
||||
action = g_simple_action_new ("run", NULL);
|
||||
g_signal_connect (action, "activate", G_CALLBACK (activate_run), window);
|
||||
g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (action));
|
||||
@@ -1052,10 +1043,10 @@ out:
|
||||
static void
|
||||
print_version (void)
|
||||
{
|
||||
g_print ("gtk4-demo %s%s%s\n",
|
||||
PACKAGE_VERSION,
|
||||
g_strcmp0 (PROFILE, "devel") == 0 ? "-" : "",
|
||||
g_strcmp0 (PROFILE, "devel") == 0 ? VCS_TAG : "");
|
||||
g_print ("gtk4-demo %d.%d.%d\n",
|
||||
gtk_get_major_version (),
|
||||
gtk_get_minor_version (),
|
||||
gtk_get_micro_version ());
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
@@ -167,8 +167,6 @@ foreach flag: common_cflags
|
||||
endif
|
||||
endforeach
|
||||
|
||||
gtkdemo_deps += [ demo_conf_h ]
|
||||
|
||||
executable('gtk4-demo',
|
||||
sources: [demos, demos_h, extra_demo_sources, gtkdemo_resources],
|
||||
c_args: gtkdemo_args + demo_cflags,
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#include "iconbrowserapp.h"
|
||||
#include "iconbrowserwin.h"
|
||||
|
||||
#include "demo_conf.h"
|
||||
|
||||
struct _IconBrowserApp
|
||||
{
|
||||
GtkApplication parent;
|
||||
@@ -77,25 +75,21 @@ about_activated (GSimpleAction *action,
|
||||
gtk_get_minor_version (),
|
||||
gtk_get_micro_version ());
|
||||
g_string_append_printf (s, "\nIcon theme\n\t%s", icon_theme);
|
||||
version = g_strdup_printf ("%s%s%s\nRunning against GTK %d.%d.%d",
|
||||
version = g_strdup_printf ("%s\nRunning against GTK %d.%d.%d",
|
||||
PACKAGE_VERSION,
|
||||
g_strcmp0 (PROFILE, "devel") == 0 ? "-" : "",
|
||||
g_strcmp0 (PROFILE, "devel") == 0 ? VCS_TAG : "",
|
||||
gtk_get_major_version (),
|
||||
gtk_get_minor_version (),
|
||||
gtk_get_micro_version ());
|
||||
|
||||
gtk_show_about_dialog (GTK_WINDOW (gtk_application_get_active_window (app)),
|
||||
"program-name", g_strcmp0 (PROFILE, "devel") == 0
|
||||
? "GTK Icon Browser (Development)"
|
||||
: "GTK Icon Browser",
|
||||
"program-name", "GTK Icon Browser",
|
||||
"version", version,
|
||||
"copyright", "© 1997—2021 The GTK Team",
|
||||
"copyright", "© 1997—2020 The GTK Team",
|
||||
"license-type", GTK_LICENSE_LGPL_2_1,
|
||||
"website", "http://www.gtk.org",
|
||||
"comments", "Program to browse themed icons",
|
||||
"authors", authors,
|
||||
"logo-icon-name", "org.gtk.IconBrowser4",
|
||||
"logo-icon-name", "org.gtk.Demo4",
|
||||
"title", "About GTK Icon Browser",
|
||||
"system-information", s->str,
|
||||
NULL);
|
||||
@@ -135,10 +129,6 @@ icon_browser_app_activate (GApplication *app)
|
||||
IconBrowserWindow *win;
|
||||
|
||||
win = icon_browser_window_new (ICON_BROWSER_APP (app));
|
||||
|
||||
if (g_strcmp0 (PROFILE, "devel") == 0)
|
||||
gtk_widget_add_css_class (GTK_WIDGET (win), "devel");
|
||||
|
||||
gtk_window_present (GTK_WINDOW (win));
|
||||
}
|
||||
|
||||
|
||||
@@ -279,31 +279,11 @@ drag_prepare_texture (GtkDragSource *source,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GdkPaintable *paintable = get_image_paintable (GTK_IMAGE (widget));
|
||||
GtkSnapshot *snapshot;
|
||||
double width, height;
|
||||
GskRenderNode *node;
|
||||
GskRenderer *renderer;
|
||||
GdkTexture *texture;
|
||||
GdkContentProvider *ret;
|
||||
|
||||
if (!GDK_IS_PAINTABLE (paintable))
|
||||
return NULL;
|
||||
|
||||
snapshot = gtk_snapshot_new ();
|
||||
width = gdk_paintable_get_intrinsic_width (paintable);
|
||||
height = gdk_paintable_get_intrinsic_height (paintable);
|
||||
gdk_paintable_snapshot (paintable, snapshot, width, height);
|
||||
node = gtk_snapshot_free_to_node (snapshot);
|
||||
|
||||
renderer = gtk_native_get_renderer (gtk_widget_get_native (widget));
|
||||
texture = gsk_renderer_render_texture (renderer, node, &GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
|
||||
ret = gdk_content_provider_new_typed (GDK_TYPE_TEXTURE, texture);
|
||||
|
||||
g_object_unref (texture);
|
||||
gsk_render_node_unref (node);
|
||||
|
||||
return ret;
|
||||
return gdk_content_provider_new_typed (GDK_TYPE_PAINTABLE, paintable);
|
||||
}
|
||||
|
||||
static GdkContentProvider *
|
||||
|
||||
@@ -14,7 +14,7 @@ iconbrowser_resources = gnome.compile_resources('iconbrowser_resources',
|
||||
executable('gtk4-icon-browser',
|
||||
sources: [iconbrowser_sources, iconbrowser_resources],
|
||||
c_args: common_cflags,
|
||||
dependencies: [ libgtk_dep, demo_conf_h ],
|
||||
dependencies: libgtk_dep,
|
||||
include_directories: confinc,
|
||||
gui_app: true,
|
||||
link_args: extra_demo_ldflags,
|
||||
|
||||
@@ -1,19 +1,3 @@
|
||||
demo_conf = configuration_data()
|
||||
demo_conf.set_quoted('PROFILE', get_option('profile'))
|
||||
demo_conf.set_quoted('VCS_TAG', '@VCS_TAG@')
|
||||
|
||||
demo_conf_h = declare_dependency(
|
||||
sources: vcs_tag(
|
||||
command: [ 'git', 'rev-parse', '--short', 'HEAD' ],
|
||||
fallback: get_option('profile') != 'default' ? 'devel' : '',
|
||||
input: configure_file(
|
||||
output: 'demo_conf.h.in',
|
||||
configuration: demo_conf
|
||||
),
|
||||
output: 'demo_conf.h'
|
||||
)
|
||||
)
|
||||
|
||||
subdir('constraint-editor')
|
||||
subdir('gtk-demo')
|
||||
subdir('icon-browser')
|
||||
|
||||
@@ -12,7 +12,7 @@ node_editor_resources = gnome.compile_resources('node_editor_resources',
|
||||
|
||||
executable('gtk4-node-editor',
|
||||
sources: [node_editor_sources, node_editor_resources],
|
||||
dependencies: [ libgtk_dep, demo_conf_h ],
|
||||
dependencies: libgtk_dep,
|
||||
include_directories: confinc,
|
||||
c_args: [
|
||||
'-DNODE_EDITOR_SOURCE_DIR="@0@/../../testsuite/gsk/compare/"'.format(meson.current_source_dir())
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
|
||||
#include "node-editor-window.h"
|
||||
|
||||
#include "demo_conf.h"
|
||||
|
||||
static const char *css =
|
||||
"textview.editor {"
|
||||
" color: rgb(192, 197, 206);"
|
||||
@@ -96,26 +94,22 @@ activate_about (GSimpleAction *action,
|
||||
|
||||
g_string_append_printf (s, "\nRenderer\n\t%s", renderer);
|
||||
|
||||
version = g_strdup_printf ("%s%s%s\nRunning against GTK %d.%d.%d",
|
||||
version = g_strdup_printf ("%s\nRunning against GTK %d.%d.%d",
|
||||
PACKAGE_VERSION,
|
||||
g_strcmp0 (PROFILE, "devel") == 0 ? "-" : "",
|
||||
g_strcmp0 (PROFILE, "devel") == 0 ? VCS_TAG : "",
|
||||
gtk_get_major_version (),
|
||||
gtk_get_minor_version (),
|
||||
gtk_get_micro_version ());
|
||||
|
||||
dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG,
|
||||
"transient-for", gtk_application_get_active_window (app),
|
||||
"program-name", g_strcmp0 (PROFILE, "devel") == 0
|
||||
? "GTK Node Editor (Development)"
|
||||
: "GTK Node Editor",
|
||||
"program-name", "GTK Node Editor",
|
||||
"version", version,
|
||||
"copyright", "© 2019—2021 The GTK Team",
|
||||
"copyright", "© 2019—2020 The GTK Team",
|
||||
"license-type", GTK_LICENSE_LGPL_2_1,
|
||||
"website", "http://www.gtk.org",
|
||||
"comments", "Program to test GTK rendering",
|
||||
"authors", (const char *[]){ "Benjamin Otte", "Timm Bäder", NULL},
|
||||
"logo-icon-name", "org.gtk.gtk4.NodeEditor",
|
||||
"logo-icon-name", "org.gtk.gtk4.NodeEditor.Devel",
|
||||
"title", "About GTK Node Editor",
|
||||
"system-information", s->str,
|
||||
NULL);
|
||||
@@ -213,10 +207,6 @@ node_editor_application_activate (GApplication *app)
|
||||
NodeEditorWindow *win;
|
||||
|
||||
win = node_editor_window_new (NODE_EDITOR_APPLICATION (app));
|
||||
|
||||
if (g_strcmp0 (PROFILE, "devel") == 0)
|
||||
gtk_widget_add_css_class (GTK_WIDGET (win), "devel");
|
||||
|
||||
gtk_window_present (GTK_WINDOW (win));
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
|
||||
#include "gsk/gskrendernodeparserprivate.h"
|
||||
#include "gsk/gl/gskglrenderer.h"
|
||||
#include "gsk/ngl/gsknglrenderer.h"
|
||||
#ifdef GDK_WINDOWING_BROADWAY
|
||||
#include "gsk/broadway/gskbroadwayrenderer.h"
|
||||
#endif
|
||||
@@ -701,16 +700,6 @@ out:
|
||||
g_free (source_dir);
|
||||
}
|
||||
|
||||
static void
|
||||
dark_mode_cb (GtkToggleButton *button,
|
||||
GParamSpec *pspec,
|
||||
NodeEditorWindow *self)
|
||||
{
|
||||
g_object_set (gtk_widget_get_settings (GTK_WIDGET (self)),
|
||||
"gtk-application-prefer-dark-theme", gtk_toggle_button_get_active (button),
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
node_editor_window_finalize (GObject *object)
|
||||
{
|
||||
@@ -763,9 +752,6 @@ node_editor_window_realize (GtkWidget *widget)
|
||||
node_editor_window_add_renderer (self,
|
||||
gsk_gl_renderer_new (),
|
||||
"OpenGL");
|
||||
node_editor_window_add_renderer (self,
|
||||
gsk_ngl_renderer_new (),
|
||||
"NGL");
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
node_editor_window_add_renderer (self,
|
||||
gsk_vulkan_renderer_new (),
|
||||
@@ -828,7 +814,6 @@ node_editor_window_class_init (NodeEditorWindowClass *class)
|
||||
gtk_widget_class_bind_template_callback (widget_class, export_image_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, testcase_save_clicked_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, testcase_name_entry_changed_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, dark_mode_cb);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
@@ -931,7 +916,7 @@ node_editor_window_init (NodeEditorWindow *self)
|
||||
"shadow {\n"
|
||||
" child: texture {\n"
|
||||
" bounds: 0 0 128 128;\n"
|
||||
" texture: url(\"resource:///org/gtk/gtk4/node-editor/icons/apps/org.gtk.gtk4.NodeEditor.svg\");\n"
|
||||
" texture: url(\"resource:///org/gtk/gtk4/node-editor/icons/apps/org.gtk.gtk4.NodeEditor.Devel.svg\");\n"
|
||||
" }\n"
|
||||
" shadows: rgba(0,0,0,0.5) 0 1 12;\n"
|
||||
"}\n"
|
||||
|
||||
@@ -139,15 +139,6 @@
|
||||
<property name="icon-name">open-menu-symbolic</property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="end">
|
||||
<object class="GtkToggleButton" id="dark_bg_button">
|
||||
<property name="valign">center</property>
|
||||
<property name="has-frame">0</property>
|
||||
<property name="icon-name">display-brightness-symbolic</property>
|
||||
<property name="tooltip-text" translatable="yes">Use a dark background</property>
|
||||
<signal name="notify::active" handler="dark_mode_cb" swapped="0"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
<file preprocess="xml-stripblanks">node-editor-window.ui</file>
|
||||
<file preprocess="xml-stripblanks">help-window.ui</file>
|
||||
<file>node-format.md</file>
|
||||
<file alias='icons/apps/org.gtk.gtk4.NodeEditor.svg'>data/scalable/apps/org.gtk.gtk4.NodeEditor.svg</file>
|
||||
<file alias='icons/apps/org.gtk.gtk4.NodeEditor.Devel.svg'>data/scalable/apps/org.gtk.gtk4.NodeEditor.Devel.svg</file>
|
||||
</gresource>
|
||||
</gresources>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
executable('gtk4-print-editor',
|
||||
sources: ['print-editor.c'],
|
||||
c_args: common_cflags,
|
||||
dependencies: [ libgtk_dep, demo_conf_h ],
|
||||
dependencies: libgtk_dep,
|
||||
include_directories: confinc,
|
||||
gui_app: true,
|
||||
link_args: extra_demo_ldflags,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Name=Print Editor
|
||||
Comment=A simple editor demonstrating GTK printing
|
||||
Exec=gtk4-print-editor %f
|
||||
Icon=org.gtk.PrintEditor4
|
||||
Icon=org.gtk.PrintEditor4.Devel
|
||||
Terminal=false
|
||||
Type=Application
|
||||
StartupNotify=true
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "demo_conf.h"
|
||||
|
||||
static GtkWidget *main_window;
|
||||
static GFile *filename = NULL;
|
||||
static GtkPageSetup *page_setup = NULL;
|
||||
@@ -643,26 +641,22 @@ activate_about (GSimpleAction *action,
|
||||
g_strfreev (backends);
|
||||
g_free (setting);
|
||||
|
||||
version = g_strdup_printf ("%s%s%s\nRunning against GTK %d.%d.%d",
|
||||
version = g_strdup_printf ("%s\nRunning against GTK %d.%d.%d",
|
||||
PACKAGE_VERSION,
|
||||
g_strcmp0 (PROFILE, "devel") == 0 ? "-" : "",
|
||||
g_strcmp0 (PROFILE, "devel") == 0 ? VCS_TAG : "",
|
||||
gtk_get_major_version (),
|
||||
gtk_get_minor_version (),
|
||||
gtk_get_micro_version ());
|
||||
|
||||
dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG,
|
||||
"transient-for", main_window,
|
||||
"program-name", g_strcmp0 (PROFILE, "devel") == 0
|
||||
? "GTK Print Editor (Development)"
|
||||
: "GTK Print Editor",
|
||||
"program-name", "GTK Print Editor",
|
||||
"version", version,
|
||||
"copyright", "© 2006-2021 Red Hat, Inc",
|
||||
"copyright", "© 2006-2020 Red Hat, Inc",
|
||||
"license-type", GTK_LICENSE_LGPL_2_1,
|
||||
"website", "http://www.gtk.org",
|
||||
"comments", "Program to demonstrate GTK printing",
|
||||
"authors", authors,
|
||||
"logo-icon-name", "org.gtk.PrintEditor4",
|
||||
"logo-icon-name", "org.gtk.PrintEditor4.Devel",
|
||||
"title", "About GTK Print Editor",
|
||||
"system-information", sysinfo->str,
|
||||
NULL);
|
||||
@@ -813,10 +807,6 @@ activate (GApplication *app)
|
||||
GtkWidget *contents;
|
||||
|
||||
main_window = gtk_application_window_new (GTK_APPLICATION (app));
|
||||
|
||||
if (g_strcmp0 (PROFILE, "devel") == 0)
|
||||
gtk_widget_add_css_class (GTK_WIDGET (main_window), "devel");
|
||||
|
||||
gtk_window_set_icon_name (GTK_WINDOW (main_window), "text-editor");
|
||||
gtk_window_set_default_size (GTK_WINDOW (main_window), 400, 600);
|
||||
gtk_application_window_set_show_menubar (GTK_APPLICATION_WINDOW (main_window), TRUE);
|
||||
|
||||
@@ -8,7 +8,7 @@ widgetfactory_resources = gnome.compile_resources('widgetfactory_resources',
|
||||
executable('gtk4-widget-factory',
|
||||
sources: ['widget-factory.c', widgetfactory_resources],
|
||||
c_args: common_cflags,
|
||||
dependencies: [ libgtk_dep, demo_conf_h ],
|
||||
dependencies: libgtk_dep,
|
||||
include_directories: confinc,
|
||||
gui_app: true,
|
||||
link_args: extra_demo_ldflags,
|
||||
|
||||
@@ -25,8 +25,6 @@
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "demo_conf.h"
|
||||
|
||||
static void
|
||||
change_dark_state (GSimpleAction *action,
|
||||
GVariant *state,
|
||||
@@ -302,10 +300,8 @@ activate_about (GSimpleAction *action,
|
||||
gtk_get_micro_version ());
|
||||
g_string_append_printf (s, "\nA link can appear here: <http://www.gtk.org>");
|
||||
|
||||
version = g_strdup_printf ("%s%s%s\nRunning against GTK %d.%d.%d",
|
||||
version = g_strdup_printf ("%s\nRunning against GTK %d.%d.%d",
|
||||
PACKAGE_VERSION,
|
||||
g_strcmp0 (PROFILE, "devel") == 0 ? "-" : "",
|
||||
g_strcmp0 (PROFILE, "devel") == 0 ? VCS_TAG : "",
|
||||
gtk_get_major_version (),
|
||||
gtk_get_minor_version (),
|
||||
gtk_get_micro_version ());
|
||||
@@ -313,11 +309,9 @@ activate_about (GSimpleAction *action,
|
||||
dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG,
|
||||
"transient-for", gtk_application_get_active_window (app),
|
||||
"modal", TRUE,
|
||||
"program-name", g_strcmp0 (PROFILE, "devel") == 0
|
||||
? "GTK Widget Factory (Development)"
|
||||
: "GTK Widget Factory",
|
||||
"program-name", "GTK Widget Factory",
|
||||
"version", version,
|
||||
"copyright", "© 1997—2021 The GTK Team",
|
||||
"copyright", "© 1997—2020 The GTK Team",
|
||||
"license-type", GTK_LICENSE_LGPL_2_1,
|
||||
"website", "http://www.gtk.org",
|
||||
"comments", "Program to demonstrate GTK themes and widgets",
|
||||
@@ -2071,10 +2065,6 @@ activate (GApplication *app)
|
||||
}
|
||||
|
||||
window = (GtkWindow *)gtk_builder_get_object (builder, "window");
|
||||
|
||||
if (g_strcmp0 (PROFILE, "devel") == 0)
|
||||
gtk_widget_add_css_class (GTK_WIDGET (window), "devel");
|
||||
|
||||
gtk_application_add_window (GTK_APPLICATION (app), window);
|
||||
g_action_map_add_action_entries (G_ACTION_MAP (window),
|
||||
win_entries, G_N_ELEMENTS (win_entries),
|
||||
@@ -2329,10 +2319,10 @@ activate (GApplication *app)
|
||||
static void
|
||||
print_version (void)
|
||||
{
|
||||
g_print ("gtk4-widget-factory %s%s%s\n",
|
||||
PACKAGE_VERSION,
|
||||
g_strcmp0 (PROFILE, "devel") == 0 ? "-" : "",
|
||||
g_strcmp0 (PROFILE, "devel") == 0 ? VCS_TAG : "");
|
||||
g_print ("gtk4-widget-factory %d.%d.%d\n",
|
||||
gtk_get_major_version (),
|
||||
gtk_get_minor_version (),
|
||||
gtk_get_micro_version ());
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
@@ -75,10 +75,6 @@
|
||||
<title>Index of all symbols</title>
|
||||
<xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include>
|
||||
</index>
|
||||
<index id="api-index-4-2" role="4.2">
|
||||
<title>Index of new symbols in 4.2</title>
|
||||
<xi:include href="xml/api-index-4.2.xml"><xi:fallback /></xi:include>
|
||||
</index>
|
||||
<index id="api-index-deprecated" role="deprecated">
|
||||
<title>Index of deprecated symbols</title>
|
||||
<xi:include href="xml/api-index-deprecated.xml"><xi:fallback /></xi:include>
|
||||
|
||||
@@ -627,8 +627,6 @@ gdk_popup_layout_set_anchor_hints
|
||||
gdk_popup_layout_get_anchor_hints
|
||||
gdk_popup_layout_set_offset
|
||||
gdk_popup_layout_get_offset
|
||||
gdk_popup_layout_set_shadow_width
|
||||
gdk_popup_layout_get_shadow_width
|
||||
<SUBSECTION Standard>
|
||||
GDK_TYPE_POPUP_LAYOUT
|
||||
gdk_popup_layout_get_type
|
||||
|
||||
@@ -1831,6 +1831,7 @@ GtkIMContextSimple
|
||||
gtk_im_context_simple_new
|
||||
gtk_im_context_simple_add_table
|
||||
gtk_im_context_simple_add_compose_file
|
||||
GTK_MAX_COMPOSE_LEN
|
||||
<SUBSECTION Standard>
|
||||
GTK_IM_CONTEXT_SIMPLE
|
||||
GTK_IS_IM_CONTEXT_SIMPLE
|
||||
|
||||
@@ -135,7 +135,7 @@ These functions are not supported in GTK 4. Instead, either use
|
||||
backend-specific APIs, or render your widgets using
|
||||
#GtkWidgetClass.snapshot() (once you are using GTK 4).
|
||||
|
||||
### Stop using GtkButton's image-related API
|
||||
Stop using GtkButton's image-related API
|
||||
|
||||
The functions and properties related to automatically add a GtkImage
|
||||
to a GtkButton, and using a GtkSetting to control its visibility, are
|
||||
|
||||
@@ -0,0 +1,293 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "exampleapp.h"
|
||||
#include "exampleappwin.h"
|
||||
|
||||
struct _ExampleAppWindow
|
||||
{
|
||||
GtkApplicationWindow parent;
|
||||
|
||||
GSettings *settings;
|
||||
GtkWidget *stack;
|
||||
GtkWidget *search;
|
||||
GtkWidget *searchbar;
|
||||
GtkWidget *searchentry;
|
||||
GtkWidget *gears;
|
||||
GtkWidget *sidebar;
|
||||
GtkWidget *words;
|
||||
GtkWidget *lines;
|
||||
GtkWidget *lines_label;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW)
|
||||
|
||||
static void
|
||||
search_text_changed (GtkEntry *entry,
|
||||
ExampleAppWindow *win)
|
||||
{
|
||||
const char *text;
|
||||
GtkWidget *tab;
|
||||
GtkWidget *view;
|
||||
GtkTextBuffer *buffer;
|
||||
GtkTextIter start, match_start, match_end;
|
||||
|
||||
text = gtk_editable_get_text (GTK_EDITABLE (entry));
|
||||
|
||||
if (text[0] == '\0')
|
||||
return;
|
||||
|
||||
tab = gtk_stack_get_visible_child (GTK_STACK (win->stack));
|
||||
view = gtk_scrolled_window_get_child (GTK_SCROLLED_WINDOW (tab));
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
|
||||
/* Very simple-minded search implementation */
|
||||
gtk_text_buffer_get_start_iter (buffer, &start);
|
||||
if (gtk_text_iter_forward_search (&start, text, GTK_TEXT_SEARCH_CASE_INSENSITIVE,
|
||||
&match_start, &match_end, NULL))
|
||||
{
|
||||
gtk_text_buffer_select_range (buffer, &match_start, &match_end);
|
||||
gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (view), &match_start,
|
||||
0.0, FALSE, 0.0, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
find_word (GtkButton *button,
|
||||
ExampleAppWindow *win)
|
||||
{
|
||||
const char *word;
|
||||
|
||||
word = gtk_button_get_label (button);
|
||||
gtk_editable_set_text (GTK_EDITABLE (win->searchentry), word);
|
||||
}
|
||||
|
||||
static void
|
||||
update_words (ExampleAppWindow *win)
|
||||
{
|
||||
GHashTable *strings;
|
||||
GHashTableIter iter;
|
||||
GtkWidget *tab, *view, *row;
|
||||
GtkTextBuffer *buffer;
|
||||
GtkTextIter start, end;
|
||||
char *word, *key;
|
||||
GtkWidget *child;
|
||||
|
||||
tab = gtk_stack_get_visible_child (GTK_STACK (win->stack));
|
||||
|
||||
if (tab == NULL)
|
||||
return;
|
||||
|
||||
view = gtk_scrolled_window_get_child (GTK_SCROLLED_WINDOW (tab));
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
|
||||
strings = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
||||
|
||||
gtk_text_buffer_get_start_iter (buffer, &start);
|
||||
while (!gtk_text_iter_is_end (&start))
|
||||
{
|
||||
while (!gtk_text_iter_starts_word (&start))
|
||||
{
|
||||
if (!gtk_text_iter_forward_char (&start))
|
||||
goto done;
|
||||
}
|
||||
end = start;
|
||||
if (!gtk_text_iter_forward_word_end (&end))
|
||||
goto done;
|
||||
word = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
|
||||
g_hash_table_add (strings, g_utf8_strdown (word, -1));
|
||||
g_free (word);
|
||||
start = end;
|
||||
}
|
||||
|
||||
done:
|
||||
while ((child = gtk_widget_get_first_child (win->words)))
|
||||
gtk_list_box_remove (GTK_LIST_BOX (win->words), child);
|
||||
|
||||
g_hash_table_iter_init (&iter, strings);
|
||||
while (g_hash_table_iter_next (&iter, (gpointer *)&key, NULL))
|
||||
{
|
||||
row = gtk_button_new_with_label (key);
|
||||
g_signal_connect (row, "clicked",
|
||||
G_CALLBACK (find_word), win);
|
||||
gtk_box_append (GTK_BOX (win->words), row);
|
||||
}
|
||||
|
||||
g_hash_table_unref (strings);
|
||||
}
|
||||
|
||||
static void
|
||||
update_lines (ExampleAppWindow *win)
|
||||
{
|
||||
GtkWidget *tab, *view;
|
||||
GtkTextBuffer *buffer;
|
||||
int count;
|
||||
char *lines;
|
||||
|
||||
tab = gtk_stack_get_visible_child (GTK_STACK (win->stack));
|
||||
|
||||
if (tab == NULL)
|
||||
return;
|
||||
|
||||
view = gtk_scrolled_window_get_child (GTK_SCROLLED_WINDOW (tab));
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
|
||||
count = gtk_text_buffer_get_line_count (buffer);
|
||||
lines = g_strdup_printf ("%d", count);
|
||||
gtk_label_set_text (GTK_LABEL (win->lines), lines);
|
||||
g_free (lines);
|
||||
}
|
||||
|
||||
static void
|
||||
visible_child_changed (GObject *stack,
|
||||
GParamSpec *pspec,
|
||||
ExampleAppWindow *win)
|
||||
{
|
||||
if (gtk_widget_in_destruction (GTK_WIDGET (stack)))
|
||||
return;
|
||||
|
||||
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (win->searchbar), FALSE);
|
||||
update_words (win);
|
||||
update_lines (win);
|
||||
}
|
||||
|
||||
static void
|
||||
words_changed (GObject *sidebar,
|
||||
GParamSpec *pspec,
|
||||
ExampleAppWindow *win)
|
||||
{
|
||||
update_words (win);
|
||||
}
|
||||
|
||||
static void
|
||||
example_app_window_init (ExampleAppWindow *win)
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
GMenuModel *menu;
|
||||
GAction *action;
|
||||
|
||||
gtk_widget_init_template (GTK_WIDGET (win));
|
||||
win->settings = g_settings_new ("org.gtk.exampleapp");
|
||||
|
||||
g_settings_bind (win->settings, "transition",
|
||||
win->stack, "transition-type",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
|
||||
g_settings_bind (win->settings, "show-words",
|
||||
win->sidebar, "reveal-child",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
|
||||
g_object_bind_property (win->search, "active",
|
||||
win->searchbar, "search-mode-enabled",
|
||||
G_BINDING_BIDIRECTIONAL);
|
||||
|
||||
g_signal_connect (win->sidebar, "notify::reveal-child",
|
||||
G_CALLBACK (words_changed), win);
|
||||
|
||||
builder = gtk_builder_new_from_resource ("/org/gtk/exampleapp/gears-menu.ui");
|
||||
menu = G_MENU_MODEL (gtk_builder_get_object (builder, "menu"));
|
||||
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (win->gears), menu);
|
||||
g_object_unref (builder);
|
||||
|
||||
action = g_settings_create_action (win->settings, "show-words");
|
||||
g_action_map_add_action (G_ACTION_MAP (win), action);
|
||||
g_object_unref (action);
|
||||
|
||||
action = (GAction*) g_property_action_new ("show-lines", win->lines, "visible");
|
||||
g_action_map_add_action (G_ACTION_MAP (win), action);
|
||||
g_object_unref (action);
|
||||
|
||||
g_object_bind_property (win->lines, "visible",
|
||||
win->lines_label, "visible",
|
||||
G_BINDING_DEFAULT);
|
||||
|
||||
g_object_set (gtk_settings_get_default (), "gtk-shell-shows-app-menu", FALSE, NULL);
|
||||
gtk_application_window_set_show_menubar (GTK_APPLICATION_WINDOW (win), TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
example_app_window_dispose (GObject *object)
|
||||
{
|
||||
ExampleAppWindow *win;
|
||||
|
||||
win = EXAMPLE_APP_WINDOW (object);
|
||||
|
||||
g_clear_object (&win->settings);
|
||||
|
||||
G_OBJECT_CLASS (example_app_window_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
example_app_window_class_init (ExampleAppWindowClass *class)
|
||||
{
|
||||
G_OBJECT_CLASS (class)->dispose = example_app_window_dispose;
|
||||
|
||||
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
|
||||
"/org/gtk/exampleapp/window.ui");
|
||||
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, search);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchbar);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchentry);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, gears);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, words);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, sidebar);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, lines);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, lines_label);
|
||||
|
||||
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), search_text_changed);
|
||||
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), visible_child_changed);
|
||||
}
|
||||
|
||||
ExampleAppWindow *
|
||||
example_app_window_new (ExampleApp *app)
|
||||
{
|
||||
return g_object_new (EXAMPLE_APP_WINDOW_TYPE, "application", app, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
example_app_window_open (ExampleAppWindow *win,
|
||||
GFile *file)
|
||||
{
|
||||
char *basename;
|
||||
GtkWidget *scrolled, *view;
|
||||
char *contents;
|
||||
gsize length;
|
||||
GtkTextBuffer *buffer;
|
||||
GtkTextTag *tag;
|
||||
GtkTextIter start_iter, end_iter;
|
||||
|
||||
basename = g_file_get_basename (file);
|
||||
|
||||
scrolled = gtk_scrolled_window_new ();
|
||||
gtk_widget_set_hexpand (scrolled, TRUE);
|
||||
gtk_widget_set_vexpand (scrolled, TRUE);
|
||||
view = gtk_text_view_new ();
|
||||
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
|
||||
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolled), view);
|
||||
gtk_stack_add_titled (GTK_STACK (win->stack), scrolled, basename, basename);
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
|
||||
if (g_file_load_contents (file, NULL, &contents, &length, NULL, NULL))
|
||||
{
|
||||
gtk_text_buffer_set_text (buffer, contents, length);
|
||||
g_free (contents);
|
||||
}
|
||||
|
||||
tag = gtk_text_buffer_create_tag (buffer, NULL, NULL);
|
||||
g_settings_bind (win->settings, "font",
|
||||
tag, "font",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
|
||||
gtk_text_buffer_get_start_iter (buffer, &start_iter);
|
||||
gtk_text_buffer_get_end_iter (buffer, &end_iter);
|
||||
gtk_text_buffer_apply_tag (buffer, tag, &start_iter, &end_iter);
|
||||
|
||||
g_free (basename);
|
||||
|
||||
gtk_widget_set_sensitive (win->search, TRUE);
|
||||
|
||||
update_words (win);
|
||||
update_lines (win);
|
||||
}
|
||||
@@ -36,10 +36,6 @@
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#if !GLIB_CHECK_VERSION (2, 67, 3)
|
||||
# define g_memdup2(mem,size) g_memdup((mem), (size))
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int id;
|
||||
guint32 tag;
|
||||
@@ -609,7 +605,7 @@ update_future_pointer_info (BroadwayServer *server, BroadwayInputPointerMsg *dat
|
||||
static void
|
||||
queue_input_message (BroadwayServer *server, BroadwayInputMsg *msg)
|
||||
{
|
||||
server->input_messages = g_list_append (server->input_messages, g_memdup2 (msg, sizeof (BroadwayInputMsg)));
|
||||
server->input_messages = g_list_append (server->input_messages, g_memdup (msg, sizeof (BroadwayInputMsg)));
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
#include "gdkbroadway-server.h"
|
||||
|
||||
#include "gdkprivate-broadway.h"
|
||||
#include "gdk-private.h"
|
||||
|
||||
#include <gdk/gdktextureprivate.h>
|
||||
|
||||
#include <glib.h>
|
||||
@@ -235,7 +233,7 @@ static void
|
||||
parse_all_input (GdkBroadwayServer *server)
|
||||
{
|
||||
guint8 *p, *end;
|
||||
size_t size;
|
||||
guint32 size;
|
||||
BroadwayReply *reply;
|
||||
|
||||
p = server->recv_buffer;
|
||||
@@ -247,7 +245,7 @@ parse_all_input (GdkBroadwayServer *server)
|
||||
if (p + size > end)
|
||||
break;
|
||||
|
||||
reply = g_memdup2 (p, size);
|
||||
reply = g_memdup (p, size);
|
||||
p += size;
|
||||
|
||||
server->incoming = g_list_append (server->incoming, reply);
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
#include "gdksurfaceprivate.h"
|
||||
#include "gdktextureprivate.h"
|
||||
#include "gdktoplevelprivate.h"
|
||||
#include "gdk-private.h"
|
||||
|
||||
#include <graphene.h>
|
||||
#include <stdlib.h>
|
||||
@@ -1026,7 +1025,7 @@ _gdk_broadway_moveresize_handle_event (GdkDisplay *display,
|
||||
*mv_resize->moveresize_pending_event = *event;
|
||||
else
|
||||
mv_resize->moveresize_pending_event =
|
||||
g_memdup2 (event, sizeof (BroadwayInputMsg));
|
||||
g_memdup (event, sizeof (BroadwayInputMsg));
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -1044,7 +1043,7 @@ _gdk_broadway_moveresize_handle_event (GdkDisplay *display,
|
||||
*mv_resize->moveresize_pending_event = *event;
|
||||
else
|
||||
mv_resize->moveresize_pending_event =
|
||||
g_memdup2 (event, sizeof (BroadwayInputMsg));
|
||||
g_memdup (event, sizeof (BroadwayInputMsg));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -49,12 +49,4 @@ guint gdk_parse_debug_var (const char *variable,
|
||||
const GdkDebugKey *keys,
|
||||
guint nkeys);
|
||||
|
||||
/* Backward compatibility shim, to avoid bumping up the minimum
|
||||
* required version of GLib; most of our uses of g_memdup() are
|
||||
* safe, and those that aren't have been fixed
|
||||
*/
|
||||
#if !GLIB_CHECK_VERSION (2, 67, 3)
|
||||
# define g_memdup2(mem,size) g_memdup((mem),(size))
|
||||
#endif
|
||||
|
||||
#endif /* __GDK__PRIVATE_H__ */
|
||||
|
||||
@@ -173,7 +173,7 @@ stash_desktop_startup_notification_id (void)
|
||||
if (!g_utf8_validate (desktop_startup_id, -1, NULL))
|
||||
g_warning ("DESKTOP_STARTUP_ID contains invalid UTF-8");
|
||||
else
|
||||
startup_notification_id = g_strdup (desktop_startup_id);
|
||||
startup_notification_id = g_strdup (desktop_startup_id ? desktop_startup_id : "");
|
||||
}
|
||||
|
||||
/* Clear the environment variable so it won't be inherited by
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
#include "gdkintl.h"
|
||||
#include "gdkcontentproviderimpl.h"
|
||||
|
||||
#include "gdk-private.h"
|
||||
|
||||
#define GDK_TYPE_CONTENT_PROVIDER_VALUE (gdk_content_provider_value_get_type ())
|
||||
#define GDK_CONTENT_PROVIDER_VALUE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_CONTENT_PROVIDER_VALUE, GdkContentProviderValue))
|
||||
#define GDK_IS_CONTENT_PROVIDER_VALUE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_CONTENT_PROVIDER_VALUE))
|
||||
@@ -428,7 +426,7 @@ gdk_content_provider_new_union (GdkContentProvider **providers,
|
||||
result = g_object_new (GDK_TYPE_CONTENT_PROVIDER_UNION, NULL);
|
||||
|
||||
result->n_providers = n_providers;
|
||||
result->providers = g_memdup2 (providers, sizeof (GdkContentProvider *) * n_providers);
|
||||
result->providers = g_memdup (providers, sizeof (GdkContentProvider *) * n_providers);
|
||||
|
||||
for (i = 0; i < n_providers; i++)
|
||||
{
|
||||
|
||||
+2
-2
@@ -332,7 +332,7 @@ gdk_event_type_register_static (const char *type_name,
|
||||
info.base_finalize = NULL;
|
||||
info.class_init = gdk_event_generic_class_init;
|
||||
info.class_finalize = NULL;
|
||||
info.class_data = g_memdup2 (type_info, sizeof (GdkEventTypeInfo));
|
||||
info.class_data = g_memdup (type_info, sizeof (GdkEventTypeInfo));
|
||||
|
||||
info.instance_size = type_info->instance_size;
|
||||
info.n_preallocs = 0;
|
||||
@@ -1146,7 +1146,7 @@ gdk_event_dup_axes (GdkEvent *event)
|
||||
|
||||
if (gdk_event_get_axes (event, &axes, &n_axes))
|
||||
{
|
||||
double *axes_copy = g_memdup2 (axes, n_axes * sizeof (double));
|
||||
double *axes_copy = g_memdup (axes, n_axes * sizeof (double));
|
||||
|
||||
return axes_copy;
|
||||
}
|
||||
|
||||
@@ -271,12 +271,6 @@ gdk_gl_context_upload_texture (GdkGLContext *context,
|
||||
gl_type = GL_UNSIGNED_BYTE;
|
||||
bpp = 3;
|
||||
}
|
||||
else if (data_format == GDK_MEMORY_B8G8R8)
|
||||
{
|
||||
gl_format = GL_BGR;
|
||||
gl_type = GL_UNSIGNED_BYTE;
|
||||
bpp = 3;
|
||||
}
|
||||
else /* Fall-back, convert to cairo-surface-format */
|
||||
{
|
||||
copy = g_malloc (width * height * 4);
|
||||
|
||||
+1
-69
@@ -74,10 +74,6 @@ struct _GdkPopupLayout
|
||||
GdkAnchorHints anchor_hints;
|
||||
int dx;
|
||||
int dy;
|
||||
int shadow_left;
|
||||
int shadow_right;
|
||||
int shadow_top;
|
||||
int shadow_bottom;
|
||||
};
|
||||
|
||||
G_DEFINE_BOXED_TYPE (GdkPopupLayout, gdk_popup_layout,
|
||||
@@ -169,10 +165,6 @@ gdk_popup_layout_copy (GdkPopupLayout *layout)
|
||||
new_layout->anchor_hints = layout->anchor_hints;
|
||||
new_layout->dx = layout->dx;
|
||||
new_layout->dy = layout->dy;
|
||||
new_layout->shadow_left = layout->shadow_left;
|
||||
new_layout->shadow_right = layout->shadow_right;
|
||||
new_layout->shadow_top = layout->shadow_top;
|
||||
new_layout->shadow_bottom = layout->shadow_bottom;
|
||||
|
||||
return new_layout;
|
||||
}
|
||||
@@ -199,11 +191,7 @@ gdk_popup_layout_equal (GdkPopupLayout *layout,
|
||||
layout->surface_anchor == other->surface_anchor &&
|
||||
layout->anchor_hints == other->anchor_hints &&
|
||||
layout->dx == other->dx &&
|
||||
layout->dy == other->dy &&
|
||||
layout->shadow_left == other->shadow_left &&
|
||||
layout->shadow_right == other->shadow_right &&
|
||||
layout->shadow_top == other->shadow_top &&
|
||||
layout->shadow_bottom == other->shadow_bottom);
|
||||
layout->dy == other->dy);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -358,59 +346,3 @@ gdk_popup_layout_get_offset (GdkPopupLayout *layout,
|
||||
if (dy)
|
||||
*dy = layout->dy;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_popup_layout_set_shadow_width:
|
||||
* @layout: a #GdkPopupLayout
|
||||
* @left: width of the left part of the shadow
|
||||
* @right: width of the right part of the shadow
|
||||
* @top: height of the top part of the shadow
|
||||
* @bottom: height of the bottom part of the shadow
|
||||
*
|
||||
* The shadow width corresponds to the part of the computed surface size
|
||||
* that would consist of the shadow margin surrounding the window, would
|
||||
* there be any.
|
||||
*
|
||||
* Since: 4.2
|
||||
*/
|
||||
void
|
||||
gdk_popup_layout_set_shadow_width (GdkPopupLayout *layout,
|
||||
int left,
|
||||
int right,
|
||||
int top,
|
||||
int bottom)
|
||||
{
|
||||
layout->shadow_left = left;
|
||||
layout->shadow_right = right;
|
||||
layout->shadow_top = top;
|
||||
layout->shadow_bottom = bottom;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_popup_layout_get_shadow_width:
|
||||
* @layout: a #GdkPopupLayout
|
||||
* @left: (out): return location for the left shadow width
|
||||
* @right: (out): return location for the right shadow width
|
||||
* @top: (out): return location for the top shadow width
|
||||
* @bottom: (out): return location for the bottom shadow width
|
||||
*
|
||||
* Obtains the shadow widths of this layout.
|
||||
*
|
||||
* Since: 4.2
|
||||
*/
|
||||
void
|
||||
gdk_popup_layout_get_shadow_width (GdkPopupLayout *layout,
|
||||
int *left,
|
||||
int *right,
|
||||
int *top,
|
||||
int *bottom)
|
||||
{
|
||||
if (left)
|
||||
*left = layout->shadow_left;
|
||||
if (right)
|
||||
*right = layout->shadow_right;
|
||||
if (top)
|
||||
*top = layout->shadow_top;
|
||||
if (bottom)
|
||||
*bottom = layout->shadow_bottom;
|
||||
}
|
||||
|
||||
@@ -137,20 +137,6 @@ void gdk_popup_layout_get_offset (GdkPopupLayout
|
||||
int *dx,
|
||||
int *dy);
|
||||
|
||||
GDK_AVAILABLE_IN_4_2
|
||||
void gdk_popup_layout_set_shadow_width (GdkPopupLayout *layout,
|
||||
int left,
|
||||
int right,
|
||||
int top,
|
||||
int bottom);
|
||||
GDK_AVAILABLE_IN_4_2
|
||||
void gdk_popup_layout_get_shadow_width (GdkPopupLayout *layout,
|
||||
int *left,
|
||||
int *right,
|
||||
int *top,
|
||||
int *bottom);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GDK_POPUP_LAYOUT_H__ */
|
||||
|
||||
@@ -73,23 +73,23 @@ void gdk_profiler_set_int_counter (guint id,
|
||||
gint64 value);
|
||||
|
||||
#ifndef HAVE_SYSPROF
|
||||
#define gdk_profiler_add_mark(b, d, n, m) G_STMT_START {} G_STMT_END
|
||||
#define gdk_profiler_end_mark(b, n, m) G_STMT_START {} G_STMT_END
|
||||
#define gdk_profiler_add_mark(b, d, n, m)
|
||||
#define gdk_profiler_end_mark(b, n, m)
|
||||
/* Optimise the whole call out */
|
||||
#if defined(G_HAVE_ISO_VARARGS)
|
||||
#define gdk_profiler_add_markf(b, d, n, m, ...) G_STMT_START {} G_STMT_END
|
||||
#define gdk_profiler_end_markf(b, n, m, ...) G_STMT_START {} G_STMT_END
|
||||
#define gdk_profiler_add_markf(b, d, n, m, ...)
|
||||
#define gdk_profiler_end_markf(b, n, m, ...)
|
||||
#elif defined(G_HAVE_GNUC_VARARGS)
|
||||
#define gdk_profiler_add_markf(b, d, n, m...) G_STMT_START {} G_STMT_END
|
||||
#define gdk_profiler_end_markf(b, n, m...) G_STMT_START {} G_STMT_END
|
||||
#define gdk_profiler_add_markf(b, d, n, m...)
|
||||
#define gdk_profiler_end_markf(b, n, m...)
|
||||
#else
|
||||
/* no varargs macro support; the call will have to be optimised out by the compiler */
|
||||
#endif
|
||||
|
||||
#define gdk_profiler_define_counter(n, d) 0
|
||||
#define gdk_profiler_define_int_counter(n, d) 0
|
||||
#define gdk_profiler_set_counter(i, v) G_STMT_START {} G_STMT_END
|
||||
#define gdk_profiler_set_int_counter(i, v) G_STMT_START {} G_STMT_END
|
||||
#define gdk_profiler_set_counter(i, v)
|
||||
#define gdk_profiler_set_int_counter(i, v)
|
||||
#endif
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
@@ -149,6 +149,12 @@ gdk_toplevel_size_validate (GdkToplevelSize *size)
|
||||
{
|
||||
int geometry_width, geometry_height;
|
||||
|
||||
if (size->min_width > size->bounds_width ||
|
||||
size->min_height > size->bounds_height)
|
||||
g_warning ("GdkToplevelSize: min_size (%d, %d) exceeds bounds (%d, %d)",
|
||||
size->min_width, size->min_height,
|
||||
size->bounds_width, size->bounds_height);
|
||||
|
||||
geometry_width = size->width;
|
||||
geometry_height = size->height;
|
||||
if (size->shadow.is_valid)
|
||||
@@ -156,4 +162,15 @@ gdk_toplevel_size_validate (GdkToplevelSize *size)
|
||||
geometry_width -= size->shadow.left + size->shadow.right;
|
||||
geometry_height -= size->shadow.top + size->shadow.bottom;
|
||||
}
|
||||
if (geometry_width > size->bounds_width ||
|
||||
geometry_height > size->bounds_height)
|
||||
g_warning ("GdkToplevelSize: geometry size (%d, %d) exceeds bounds (%d, %d)",
|
||||
size->width, size->height,
|
||||
size->bounds_width, size->bounds_height);
|
||||
|
||||
if (size->min_width > size->width ||
|
||||
size->min_height > size->height)
|
||||
g_warning ("GdkToplevelSize: min_size (%d, %d) exceeds size (%d, %d)",
|
||||
size->min_width, size->min_height,
|
||||
size->width, size->height);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
#include "gdkmacosclipboard-private.h"
|
||||
#include "gdkmacosutils-private.h"
|
||||
#include "gdk-private.h"
|
||||
|
||||
struct _GdkMacosClipboard
|
||||
{
|
||||
@@ -214,7 +213,7 @@ create_stream_from_nsdata (NSData *data)
|
||||
const guint8 *bytes = [data bytes];
|
||||
gsize len = [data length];
|
||||
|
||||
return g_memory_input_stream_new_from_data (g_memdup2 (bytes, len), len, g_free);
|
||||
return g_memory_input_stream_new_from_data (g_memdup (bytes, len), len, g_free);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -310,7 +309,7 @@ _gdk_macos_clipboard_read_async (GdkClipboard *clipboard,
|
||||
color[2] = 0xffff * [nscolor blueComponent];
|
||||
color[3] = 0xffff * [nscolor alphaComponent];
|
||||
|
||||
stream = g_memory_input_stream_new_from_data (g_memdup2 (&color, sizeof color),
|
||||
stream = g_memory_input_stream_new_from_data (g_memdup (&color, sizeof color),
|
||||
sizeof color,
|
||||
g_free);
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ struct _GdkMacosGLContext
|
||||
NSView *dummy_view;
|
||||
|
||||
cairo_region_t *damage;
|
||||
cairo_rectangle_int_t flush_rect;
|
||||
|
||||
guint is_attached : 1;
|
||||
guint needs_resize : 1;
|
||||
|
||||
@@ -136,7 +136,7 @@ ensure_gl_view (GdkMacosGLContext *self)
|
||||
nsview = _gdk_macos_surface_get_view (surface);
|
||||
nswindow = _gdk_macos_surface_get_native (surface);
|
||||
|
||||
if G_UNLIKELY (!GDK_IS_MACOS_GL_VIEW (nsview))
|
||||
if (!GDK_IS_MACOS_GL_VIEW (nsview))
|
||||
{
|
||||
NSRect frame;
|
||||
|
||||
@@ -267,34 +267,6 @@ gdk_macos_gl_context_real_realize (GdkGLContext *context,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
opaque_region_covers_surface (GdkMacosGLContext *self)
|
||||
{
|
||||
GdkSurface *surface;
|
||||
cairo_region_t *region;
|
||||
|
||||
g_assert (GDK_IS_MACOS_GL_CONTEXT (self));
|
||||
|
||||
surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (self));
|
||||
region = GDK_MACOS_SURFACE (surface)->opaque_region;
|
||||
|
||||
if (region != NULL &&
|
||||
cairo_region_num_rectangles (region) == 1)
|
||||
{
|
||||
cairo_rectangle_int_t extents;
|
||||
|
||||
cairo_region_get_extents (region, &extents);
|
||||
|
||||
if (extents.x == 0 &&
|
||||
extents.y == 0 &&
|
||||
extents.width == surface->width &&
|
||||
extents.height == surface->height)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_macos_gl_context_begin_frame (GdkDrawContext *context,
|
||||
cairo_region_t *painted)
|
||||
@@ -306,9 +278,6 @@ gdk_macos_gl_context_begin_frame (GdkDrawContext *context,
|
||||
|
||||
surface = gdk_draw_context_get_surface (context);
|
||||
|
||||
g_clear_pointer (&self->damage, cairo_region_destroy);
|
||||
self->damage = cairo_region_copy (painted);
|
||||
|
||||
/* If begin frame is called, that means we are trying to draw to
|
||||
* the NSWindow using our view. That might be a GdkMacosCairoView
|
||||
* but we need it to be a GL view. Also, only in this case do we
|
||||
@@ -317,7 +286,28 @@ gdk_macos_gl_context_begin_frame (GdkDrawContext *context,
|
||||
*/
|
||||
if (!self->is_attached &&
|
||||
gdk_gl_context_get_shared_context (GDK_GL_CONTEXT (context)))
|
||||
ensure_gl_view (self);
|
||||
{
|
||||
CGLContextObj glctx = [self->gl_context CGLContextObj];
|
||||
GLint swapRect[4];
|
||||
|
||||
ensure_gl_view (self);
|
||||
|
||||
g_clear_pointer (&self->damage, cairo_region_destroy);
|
||||
self->damage = cairo_region_copy (painted);
|
||||
|
||||
cairo_region_get_extents (painted, &self->flush_rect);
|
||||
|
||||
/* Coordinates are in display coordinates, where as flush_rect is
|
||||
* in GDK coordinates. Must flip Y to match display coordinates where
|
||||
* 0,0 is the bottom-left corner.
|
||||
*/
|
||||
swapRect[0] = self->flush_rect.x; /* left */
|
||||
swapRect[1] = surface->height - self->flush_rect.y; /* bottom */
|
||||
swapRect[2] = self->flush_rect.width; /* width */
|
||||
swapRect[3] = self->flush_rect.height; /* height */
|
||||
|
||||
CGLSetParameter (glctx, kCGLCPSwapRectangle, swapRect);
|
||||
}
|
||||
|
||||
if (self->needs_resize)
|
||||
{
|
||||
@@ -343,10 +333,6 @@ gdk_macos_gl_context_begin_frame (GdkDrawContext *context,
|
||||
else
|
||||
opaque = FALSE;
|
||||
|
||||
/* If we are maximized, we might be able to make it opaque */
|
||||
if (opaque == FALSE)
|
||||
opaque = opaque_region_covers_surface (self);
|
||||
|
||||
CGLSetParameter (cgl_context, kCGLCPSurfaceOpacity, &opaque);
|
||||
|
||||
[self->gl_context update];
|
||||
@@ -376,26 +362,7 @@ gdk_macos_gl_context_end_frame (GdkDrawContext *context,
|
||||
|
||||
GDK_DRAW_CONTEXT_CLASS (gdk_macos_gl_context_parent_class)->end_frame (context, painted);
|
||||
|
||||
if (!self->is_attached)
|
||||
{
|
||||
GdkSurface *surface = gdk_draw_context_get_surface (context);
|
||||
CGLContextObj glctx = [self->gl_context CGLContextObj];
|
||||
cairo_rectangle_int_t flush_rect;
|
||||
GLint swapRect[4];
|
||||
|
||||
/* Coordinates are in display coordinates, where as flush_rect is
|
||||
* in GDK coordinates. Must flip Y to match display coordinates where
|
||||
* 0,0 is the bottom-left corner.
|
||||
*/
|
||||
cairo_region_get_extents (painted, &flush_rect);
|
||||
swapRect[0] = flush_rect.x; /* left */
|
||||
swapRect[1] = surface->height - flush_rect.y; /* bottom */
|
||||
swapRect[2] = flush_rect.width; /* width */
|
||||
swapRect[3] = flush_rect.height; /* height */
|
||||
CGLSetParameter (glctx, kCGLCPSwapRectangle, swapRect);
|
||||
|
||||
[self->gl_context flushBuffer];
|
||||
}
|
||||
[self->gl_context flushBuffer];
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -66,12 +66,6 @@ gdk_macos_popup_surface_layout (GdkMacosPopupSurface *self,
|
||||
monitor = _gdk_macos_surface_get_best_monitor (GDK_MACOS_SURFACE (self));
|
||||
gdk_macos_monitor_get_workarea (monitor, &bounds);
|
||||
|
||||
gdk_popup_layout_get_shadow_width (layout,
|
||||
&self->parent_instance.shadow_left,
|
||||
&self->parent_instance.shadow_right,
|
||||
&self->parent_instance.shadow_top,
|
||||
&self->parent_instance.shadow_bottom);
|
||||
|
||||
gdk_surface_layout_popup_helper (GDK_SURFACE (self),
|
||||
width,
|
||||
height,
|
||||
|
||||
@@ -28,8 +28,6 @@
|
||||
#include "gdkmacosdevice.h"
|
||||
#include "gdkmacosseat-private.h"
|
||||
|
||||
#include "gdk-private.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
NSUInteger device_id;
|
||||
@@ -624,5 +622,6 @@ _gdk_macos_seat_get_tablet_axes_from_nsevent (GdkMacosSeat *seat,
|
||||
[nsevent rotation], &tablet->axes[GDK_AXIS_ROTATION]);
|
||||
}
|
||||
|
||||
return g_memdup2 (tablet->axes, sizeof (double) * GDK_AXIS_LAST);
|
||||
return g_memdup (tablet->axes,
|
||||
sizeof (double) * GDK_AXIS_LAST);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,6 @@ struct _GdkMacosSurface
|
||||
GdkMacosWindow *window;
|
||||
GPtrArray *monitors;
|
||||
cairo_region_t *input_region;
|
||||
cairo_region_t *opaque_region;
|
||||
char *title;
|
||||
|
||||
int root_x;
|
||||
|
||||
@@ -98,16 +98,9 @@ static void
|
||||
gdk_macos_surface_set_opaque_region (GdkSurface *surface,
|
||||
cairo_region_t *region)
|
||||
{
|
||||
GdkMacosSurface *self = (GdkMacosSurface *)surface;
|
||||
NSView *nsview;
|
||||
|
||||
g_assert (GDK_IS_MACOS_SURFACE (self));
|
||||
|
||||
if (region != self->opaque_region)
|
||||
{
|
||||
g_clear_pointer (&self->opaque_region, cairo_region_destroy);
|
||||
self->opaque_region = cairo_region_copy (region);
|
||||
}
|
||||
g_assert (GDK_IS_MACOS_SURFACE (surface));
|
||||
|
||||
if ((nsview = _gdk_macos_surface_get_view (GDK_MACOS_SURFACE (surface))) &&
|
||||
GDK_IS_MACOS_CAIRO_VIEW (nsview))
|
||||
@@ -393,7 +386,6 @@ gdk_macos_surface_destroy (GdkSurface *surface,
|
||||
}
|
||||
|
||||
g_clear_pointer (&self->title, g_free);
|
||||
g_clear_pointer (&self->opaque_region, cairo_region_destroy);
|
||||
|
||||
if (window != NULL)
|
||||
[window close];
|
||||
|
||||
@@ -33,9 +33,8 @@ typedef struct _GdkMacosToplevelSurfaceClass GdkMacosToplevelSurfaceClass;
|
||||
|
||||
struct _GdkMacosToplevelSurface
|
||||
{
|
||||
GdkMacosSurface parent_instance;
|
||||
GdkToplevelLayout *layout;
|
||||
guint decorated : 1;
|
||||
GdkMacosSurface parent_instance;
|
||||
guint decorated : 1;
|
||||
};
|
||||
|
||||
struct _GdkMacosToplevelSurfaceClass
|
||||
|
||||
@@ -102,12 +102,6 @@ _gdk_macos_toplevel_surface_present (GdkToplevel *toplevel,
|
||||
g_assert (GDK_IS_MACOS_TOPLEVEL_SURFACE (self));
|
||||
g_assert (GDK_IS_MACOS_WINDOW (nswindow));
|
||||
|
||||
if (layout != self->layout)
|
||||
{
|
||||
g_clear_pointer (&self->layout, gdk_toplevel_layout_unref);
|
||||
self->layout = gdk_toplevel_layout_copy (layout);
|
||||
}
|
||||
|
||||
_gdk_macos_toplevel_surface_attach_to_parent (self);
|
||||
|
||||
style_mask = [nswindow styleMask];
|
||||
@@ -380,6 +374,7 @@ static gboolean
|
||||
_gdk_macos_toplevel_surface_compute_size (GdkSurface *surface)
|
||||
{
|
||||
GdkMacosToplevelSurface *self = (GdkMacosToplevelSurface *)surface;
|
||||
NSWindow *nswindow = _gdk_macos_surface_get_native (GDK_MACOS_SURFACE (self));
|
||||
GdkToplevelSize size;
|
||||
GdkDisplay *display;
|
||||
GdkMonitor *monitor;
|
||||
@@ -387,6 +382,7 @@ _gdk_macos_toplevel_surface_compute_size (GdkSurface *surface)
|
||||
int width, height;
|
||||
GdkGeometry geometry;
|
||||
GdkSurfaceHints mask;
|
||||
NSWindowStyleMask style_mask;
|
||||
|
||||
g_assert (GDK_IS_MACOS_TOPLEVEL_SURFACE (self));
|
||||
|
||||
@@ -397,6 +393,7 @@ _gdk_macos_toplevel_surface_compute_size (GdkSurface *surface)
|
||||
|
||||
display = gdk_surface_get_display (surface);
|
||||
monitor = gdk_display_get_monitor_at_surface (display, surface);
|
||||
style_mask = [nswindow styleMask];
|
||||
|
||||
if (monitor)
|
||||
{
|
||||
@@ -418,11 +415,10 @@ _gdk_macos_toplevel_surface_compute_size (GdkSurface *surface)
|
||||
g_warn_if_fail (size.width > 0);
|
||||
g_warn_if_fail (size.height > 0);
|
||||
|
||||
width = surface->width;
|
||||
height = surface->height;
|
||||
width = size.width;
|
||||
height = size.height;
|
||||
|
||||
if (self->layout != NULL &&
|
||||
gdk_toplevel_layout_get_resizable (self->layout))
|
||||
if (style_mask & NSWindowStyleMaskResizable)
|
||||
{
|
||||
geometry.min_width = size.min_width;
|
||||
geometry.min_height = size.min_height;
|
||||
@@ -430,8 +426,8 @@ _gdk_macos_toplevel_surface_compute_size (GdkSurface *surface)
|
||||
}
|
||||
else
|
||||
{
|
||||
geometry.max_width = geometry.min_width = size.width;
|
||||
geometry.max_height = geometry.min_height = size.height;
|
||||
geometry.max_width = geometry.min_width = width;
|
||||
geometry.max_height = geometry.min_height = height;
|
||||
mask = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE;
|
||||
}
|
||||
|
||||
@@ -442,9 +438,8 @@ _gdk_macos_toplevel_surface_compute_size (GdkSurface *surface)
|
||||
size.shadow.bottom,
|
||||
size.shadow.left);
|
||||
|
||||
gdk_surface_constrain_size (&geometry, mask, width, height, &width, &height);
|
||||
|
||||
_gdk_macos_surface_set_geometry_hints (GDK_MACOS_SURFACE (self), &geometry, mask);
|
||||
gdk_surface_constrain_size (&geometry, mask, width, height, &width, &height);
|
||||
_gdk_macos_surface_resize (GDK_MACOS_SURFACE (self), width, height);
|
||||
|
||||
return FALSE;
|
||||
@@ -463,7 +458,6 @@ _gdk_macos_toplevel_surface_destroy (GdkSurface *surface,
|
||||
GdkMacosToplevelSurface *self = (GdkMacosToplevelSurface *)surface;
|
||||
|
||||
g_clear_object (&GDK_SURFACE (self)->transient_for);
|
||||
g_clear_pointer (&self->layout, gdk_toplevel_layout_unref);
|
||||
|
||||
GDK_SURFACE_CLASS (_gdk_macos_toplevel_surface_parent_class)->destroy (surface, foreign_destroy);
|
||||
}
|
||||
|
||||
@@ -39,8 +39,6 @@
|
||||
#include "gdkdropprivate.h"
|
||||
#include "gdkprimary-wayland.h"
|
||||
#include "gdkseatprivate.h"
|
||||
#include "gdk-private.h"
|
||||
|
||||
#include "pointer-gestures-unstable-v1-client-protocol.h"
|
||||
#include "tablet-unstable-v2-client-protocol.h"
|
||||
|
||||
@@ -3474,7 +3472,8 @@ tablet_tool_handle_proximity_out (void *data,
|
||||
static double *
|
||||
tablet_copy_axes (GdkWaylandTabletData *tablet)
|
||||
{
|
||||
return g_memdup2 (tablet->axes, sizeof (double) * GDK_AXIS_LAST);
|
||||
return g_memdup (tablet->axes,
|
||||
sizeof (double) * GDK_AXIS_LAST);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -339,48 +339,6 @@ get_format_name (enum wl_shm_format format)
|
||||
FORMAT(YVU422),
|
||||
FORMAT(YUV444),
|
||||
FORMAT(YVU444),
|
||||
FORMAT(R8),
|
||||
FORMAT(R16),
|
||||
FORMAT(RG88),
|
||||
FORMAT(GR88),
|
||||
FORMAT(RG1616),
|
||||
FORMAT(GR1616),
|
||||
FORMAT(XRGB16161616F),
|
||||
FORMAT(XBGR16161616F),
|
||||
FORMAT(ARGB16161616F),
|
||||
FORMAT(ABGR16161616F),
|
||||
FORMAT(XYUV8888),
|
||||
FORMAT(VUY888),
|
||||
FORMAT(VUY101010),
|
||||
FORMAT(Y210),
|
||||
FORMAT(Y212),
|
||||
FORMAT(Y216),
|
||||
FORMAT(Y410),
|
||||
FORMAT(Y412),
|
||||
FORMAT(Y416),
|
||||
FORMAT(XVYU12_16161616),
|
||||
FORMAT(XVYU16161616),
|
||||
FORMAT(Y0L0),
|
||||
FORMAT(X0L0),
|
||||
FORMAT(Y0L2),
|
||||
FORMAT(X0L2),
|
||||
FORMAT(YUV420_8BIT),
|
||||
FORMAT(YUV420_10BIT),
|
||||
FORMAT(XRGB8888_A8),
|
||||
FORMAT(XBGR8888_A8),
|
||||
FORMAT(RGBX8888_A8),
|
||||
FORMAT(BGRX8888_A8),
|
||||
FORMAT(RGB888_A8),
|
||||
FORMAT(BGR888_A8),
|
||||
FORMAT(RGB565_A8),
|
||||
FORMAT(BGR565_A8),
|
||||
FORMAT(NV24),
|
||||
FORMAT(NV42),
|
||||
FORMAT(P210),
|
||||
FORMAT(P010),
|
||||
FORMAT(P012),
|
||||
FORMAT(P016),
|
||||
|
||||
{ 0xffffffff, NULL }
|
||||
};
|
||||
#undef FORMAT
|
||||
@@ -1590,11 +1548,15 @@ update_xft_settings (GdkDisplay *display)
|
||||
}
|
||||
else
|
||||
{
|
||||
TranslationEntry *entry;
|
||||
GSettingsSchemaSource *source;
|
||||
GSettingsSchema *schema;
|
||||
|
||||
entry = find_translation_entry_by_schema ("org.gnome.desktop.interface", "font-antialiasing");
|
||||
source = g_settings_schema_source_get_default ();
|
||||
schema = g_settings_schema_source_lookup (source,
|
||||
"org.gnome.desktop.interface",
|
||||
FALSE);
|
||||
|
||||
if (entry && entry->valid)
|
||||
if (schema && g_settings_schema_has_key (schema, "font-antialiasing"))
|
||||
{
|
||||
settings = g_hash_table_lookup (display_wayland->settings,
|
||||
"org.gnome.desktop.interface");
|
||||
@@ -1618,6 +1580,9 @@ update_xft_settings (GdkDisplay *display)
|
||||
order = GSD_FONT_RGBA_ORDER_RGB;
|
||||
}
|
||||
|
||||
if (schema)
|
||||
g_settings_schema_unref (schema);
|
||||
|
||||
dpi = get_dpi_from_gsettings (display_wayland) * 1024;
|
||||
}
|
||||
|
||||
|
||||
@@ -630,19 +630,12 @@ static void
|
||||
configure_popup_geometry (GdkSurface *surface)
|
||||
{
|
||||
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
||||
int x, y;
|
||||
int width, height;
|
||||
|
||||
x = impl->next_layout.popup.x - impl->shadow_left;
|
||||
y = impl->next_layout.popup.y - impl->shadow_top;
|
||||
width =
|
||||
impl->next_layout.configured_width +
|
||||
(impl->shadow_left + impl->shadow_right);
|
||||
height =
|
||||
impl->next_layout.configured_height +
|
||||
(impl->shadow_top + impl->shadow_bottom);
|
||||
|
||||
gdk_wayland_surface_move_resize (surface, x, y, width, height);
|
||||
gdk_wayland_surface_move_resize (surface,
|
||||
impl->next_layout.popup.x,
|
||||
impl->next_layout.popup.y,
|
||||
impl->next_layout.configured_width,
|
||||
impl->next_layout.configured_height);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2296,17 +2289,12 @@ calculate_popup_rect (GdkSurface *surface,
|
||||
int width, height;
|
||||
GdkRectangle anchor_rect;
|
||||
int dx, dy;
|
||||
int shadow_left, shadow_right, shadow_top, shadow_bottom;
|
||||
int x = 0, y = 0;
|
||||
|
||||
gdk_popup_layout_get_shadow_width (layout,
|
||||
&shadow_left,
|
||||
&shadow_right,
|
||||
&shadow_top,
|
||||
&shadow_bottom);
|
||||
|
||||
width = (impl->popup.unconstrained_width - (shadow_left + shadow_right));
|
||||
height = (impl->popup.unconstrained_height - (shadow_top + shadow_bottom));
|
||||
width = (impl->popup.unconstrained_width -
|
||||
(impl->shadow_left + impl->shadow_right));
|
||||
height = (impl->popup.unconstrained_height -
|
||||
(impl->shadow_top + impl->shadow_bottom));
|
||||
|
||||
anchor_rect = *gdk_popup_layout_get_anchor_rect (layout);
|
||||
gdk_popup_layout_get_offset (layout, &dx, &dy);
|
||||
@@ -2490,6 +2478,7 @@ create_dynamic_positioner (GdkSurface *surface,
|
||||
GdkPopupLayout *layout,
|
||||
gboolean ack_parent_configure)
|
||||
{
|
||||
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
||||
GdkSurface *parent = surface->parent;
|
||||
GdkWaylandSurface *parent_impl = GDK_WAYLAND_SURFACE (parent);
|
||||
GdkWaylandDisplay *display =
|
||||
@@ -2504,21 +2493,12 @@ create_dynamic_positioner (GdkSurface *surface,
|
||||
GdkGravity rect_anchor;
|
||||
GdkGravity surface_anchor;
|
||||
GdkAnchorHints anchor_hints;
|
||||
int shadow_left;
|
||||
int shadow_right;
|
||||
int shadow_top;
|
||||
int shadow_bottom;
|
||||
|
||||
gdk_popup_layout_get_shadow_width (layout,
|
||||
&shadow_left,
|
||||
&shadow_right,
|
||||
&shadow_top,
|
||||
&shadow_bottom);
|
||||
geometry = (GdkRectangle) {
|
||||
.x = shadow_left,
|
||||
.y = shadow_top,
|
||||
.width = width - (shadow_left + shadow_right),
|
||||
.height = height - (shadow_top + shadow_bottom),
|
||||
.x = impl->shadow_left,
|
||||
.y = impl->shadow_top,
|
||||
.width = width - (impl->shadow_left + impl->shadow_right),
|
||||
.height = height - (impl->shadow_top + impl->shadow_bottom),
|
||||
};
|
||||
|
||||
anchor_rect = gdk_popup_layout_get_anchor_rect (layout);
|
||||
@@ -2744,12 +2724,6 @@ gdk_wayland_surface_create_xdg_popup (GdkSurface *surface,
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
gdk_popup_layout_get_shadow_width (layout,
|
||||
&impl->shadow_left,
|
||||
&impl->shadow_right,
|
||||
&impl->shadow_top,
|
||||
&impl->shadow_bottom);
|
||||
|
||||
if (grab_input_seat)
|
||||
{
|
||||
struct wl_seat *seat;
|
||||
|
||||
@@ -284,7 +284,6 @@ Otherwise it's similar to how the clipboard works. Only the DnD server
|
||||
#include "gdkwin32dnd-private.h"
|
||||
#include "gdkwin32.h"
|
||||
#include "gdkintl.h"
|
||||
#include "gdk-private.h"
|
||||
|
||||
#define HIDA_GetPIDLFolder(pida) (LPCITEMIDLIST)(((LPBYTE)pida)+(pida)->aoffset[0])
|
||||
#define HIDA_GetPIDLItem(pida, i) (LPCITEMIDLIST)(((LPBYTE)pida)+(pida)->aoffset[i+1])
|
||||
@@ -2074,7 +2073,7 @@ _gdk_win32_add_w32format_to_pairs (UINT w32format,
|
||||
|
||||
static void
|
||||
transmute_cf_unicodetext_to_utf8_string (const guchar *data,
|
||||
gsize length,
|
||||
int length,
|
||||
guchar **set_data,
|
||||
gsize *set_data_length,
|
||||
GDestroyNotify *set_data_destroy)
|
||||
@@ -2114,7 +2113,7 @@ transmute_cf_unicodetext_to_utf8_string (const guchar *data,
|
||||
|
||||
static void
|
||||
transmute_utf8_string_to_cf_unicodetext (const guchar *data,
|
||||
gsize length,
|
||||
int length,
|
||||
guchar **set_data,
|
||||
gsize *set_data_length,
|
||||
GDestroyNotify *set_data_destroy)
|
||||
@@ -2189,7 +2188,7 @@ wchar_to_str (const wchar_t *wstr,
|
||||
|
||||
static void
|
||||
transmute_utf8_string_to_cf_text (const guchar *data,
|
||||
gsize length,
|
||||
int length,
|
||||
guchar **set_data,
|
||||
gsize *set_data_length,
|
||||
GDestroyNotify *set_data_destroy)
|
||||
@@ -2275,7 +2274,7 @@ str_to_wchar (const char *str,
|
||||
|
||||
static void
|
||||
transmute_cf_text_to_utf8_string (const guchar *data,
|
||||
gsize length,
|
||||
int length,
|
||||
guchar **set_data,
|
||||
gsize *set_data_length,
|
||||
GDestroyNotify *set_data_destroy)
|
||||
@@ -2321,7 +2320,7 @@ transmute_cf_text_to_utf8_string (const guchar *data,
|
||||
|
||||
static void
|
||||
transmute_cf_dib_to_image_bmp (const guchar *data,
|
||||
gsize length,
|
||||
int length,
|
||||
guchar **set_data,
|
||||
gsize *set_data_length,
|
||||
GDestroyNotify *set_data_destroy)
|
||||
@@ -2355,8 +2354,8 @@ transmute_cf_dib_to_image_bmp (const guchar *data,
|
||||
BITMAPINFOHEADER *bi = (BITMAPINFOHEADER *) data;
|
||||
BITMAPFILEHEADER *bf;
|
||||
gpointer result;
|
||||
gsize data_length = length;
|
||||
gsize new_length;
|
||||
int data_length = length;
|
||||
int new_length;
|
||||
gboolean make_dibv5 = FALSE;
|
||||
BITMAPV5HEADER *bV5;
|
||||
guchar *p;
|
||||
@@ -2474,11 +2473,11 @@ transmute_cf_dib_to_image_bmp (const guchar *data,
|
||||
memcpy (p, ((char *) bi) + bi->biSize,
|
||||
data_length - sizeof (BITMAPINFOHEADER));
|
||||
|
||||
for (i = 0; i < bV5->bV5SizeImage / 4; i++)
|
||||
for (i = 0; i < bV5->bV5SizeImage/4; i++)
|
||||
{
|
||||
if (p[3] != 0)
|
||||
{
|
||||
double inverse_alpha = 255. / p[3];
|
||||
double inverse_alpha = 255./p[3];
|
||||
|
||||
p[0] = p[0] * inverse_alpha + 0.5;
|
||||
p[1] = p[1] * inverse_alpha + 0.5;
|
||||
@@ -2491,7 +2490,7 @@ transmute_cf_dib_to_image_bmp (const guchar *data,
|
||||
|
||||
static void
|
||||
transmute_cf_shell_id_list_to_text_uri_list (const guchar *data,
|
||||
gsize length,
|
||||
int length,
|
||||
guchar **set_data,
|
||||
gsize *set_data_length,
|
||||
GDestroyNotify *set_data_destroy)
|
||||
@@ -2541,12 +2540,12 @@ transmute_cf_shell_id_list_to_text_uri_list (const guchar *data,
|
||||
|
||||
void
|
||||
transmute_image_bmp_to_cf_dib (const guchar *data,
|
||||
gsize length,
|
||||
int length,
|
||||
guchar **set_data,
|
||||
gsize *set_data_length,
|
||||
GDestroyNotify *set_data_destroy)
|
||||
{
|
||||
gsize size;
|
||||
int size;
|
||||
guchar *ptr;
|
||||
|
||||
g_return_if_fail (length >= sizeof (BITMAPFILEHEADER));
|
||||
@@ -2573,9 +2572,7 @@ _gdk_win32_transmute_windows_data (UINT from_w32format,
|
||||
gsize *set_data_length)
|
||||
{
|
||||
const guchar *data;
|
||||
SIZE_T hdata_length;
|
||||
gsize length;
|
||||
gboolean res = FALSE;
|
||||
SIZE_T length;
|
||||
|
||||
/* FIXME: error reporting */
|
||||
|
||||
@@ -2584,11 +2581,7 @@ _gdk_win32_transmute_windows_data (UINT from_w32format,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
hdata_length = GlobalSize (hdata);
|
||||
if (hdata_length > G_MAXSIZE)
|
||||
goto out;
|
||||
|
||||
length = (gsize) hdata_length;
|
||||
length = GlobalSize (hdata);
|
||||
|
||||
if ((to_contentformat == _gdk_win32_clipdrop_atom (GDK_WIN32_ATOM_INDEX_IMAGE_PNG) &&
|
||||
from_w32format == _gdk_win32_clipdrop_cf (GDK_WIN32_CF_INDEX_PNG)) ||
|
||||
@@ -2598,51 +2591,46 @@ _gdk_win32_transmute_windows_data (UINT from_w32format,
|
||||
from_w32format == _gdk_win32_clipdrop_cf (GDK_WIN32_CF_INDEX_GIF)))
|
||||
{
|
||||
/* No transmutation needed */
|
||||
*set_data = g_memdup2 (data, length);
|
||||
*set_data = g_memdup (data, length);
|
||||
*set_data_length = length;
|
||||
}
|
||||
else if (to_contentformat == _gdk_win32_clipdrop_atom (GDK_WIN32_ATOM_INDEX_TEXT_PLAIN_UTF8) &&
|
||||
from_w32format == CF_UNICODETEXT)
|
||||
{
|
||||
transmute_cf_unicodetext_to_utf8_string (data, length, set_data, set_data_length, NULL);
|
||||
res = TRUE;
|
||||
}
|
||||
else if (to_contentformat == _gdk_win32_clipdrop_atom (GDK_WIN32_ATOM_INDEX_TEXT_PLAIN_UTF8) &&
|
||||
from_w32format == CF_TEXT)
|
||||
{
|
||||
transmute_cf_text_to_utf8_string (data, length, set_data, set_data_length, NULL);
|
||||
res = TRUE;
|
||||
}
|
||||
else if (to_contentformat == _gdk_win32_clipdrop_atom (GDK_WIN32_ATOM_INDEX_IMAGE_BMP) &&
|
||||
(from_w32format == CF_DIB || from_w32format == CF_DIBV5))
|
||||
{
|
||||
transmute_cf_dib_to_image_bmp (data, length, set_data, set_data_length, NULL);
|
||||
res = TRUE;
|
||||
}
|
||||
else if (to_contentformat == _gdk_win32_clipdrop_atom (GDK_WIN32_ATOM_INDEX_TEXT_URI_LIST) &&
|
||||
from_w32format == _gdk_win32_clipdrop_cf (GDK_WIN32_CF_INDEX_CFSTR_SHELLIDLIST))
|
||||
{
|
||||
transmute_cf_shell_id_list_to_text_uri_list (data, length, set_data, set_data_length, NULL);
|
||||
res = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("Don't know how to transmute W32 format 0x%x to content format 0x%p (%s)",
|
||||
from_w32format, to_contentformat, to_contentformat);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
out:
|
||||
GlobalUnlock (hdata);
|
||||
|
||||
return res;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gdk_win32_transmute_contentformat (const char *from_contentformat,
|
||||
UINT to_w32format,
|
||||
const guchar *data,
|
||||
gsize length,
|
||||
int length,
|
||||
guchar **set_data,
|
||||
gsize *set_data_length)
|
||||
{
|
||||
@@ -2654,7 +2642,7 @@ _gdk_win32_transmute_contentformat (const char *from_contentformat,
|
||||
to_w32format == _gdk_win32_clipdrop_cf (GDK_WIN32_CF_INDEX_GIF)))
|
||||
{
|
||||
/* No conversion needed */
|
||||
*set_data = g_memdup2 (data, length);
|
||||
*set_data = g_memdup (data, length);
|
||||
*set_data_length = length;
|
||||
}
|
||||
else if (from_contentformat == _gdk_win32_clipdrop_atom (GDK_WIN32_ATOM_INDEX_TEXT_PLAIN_UTF8) &&
|
||||
|
||||
@@ -252,7 +252,7 @@ void _gdk_win32_clipboard_default_output_done (GObject
|
||||
gboolean _gdk_win32_transmute_contentformat (const char *from_contentformat,
|
||||
UINT to_w32format,
|
||||
const guchar *data,
|
||||
gsize length,
|
||||
int length,
|
||||
guchar **set_data,
|
||||
gsize *set_data_length);
|
||||
|
||||
|
||||
@@ -477,7 +477,7 @@ _gdk_win32_local_drop_target_dragenter (GdkDrag *drag,
|
||||
drop = gdk_drop_new (display,
|
||||
gdk_seat_get_pointer (gdk_display_get_default_seat (display)),
|
||||
drag,
|
||||
gdk_drag_get_formats (drag),
|
||||
gdk_content_formats_ref (gdk_drag_get_formats (drag)),
|
||||
dest_surface,
|
||||
GDK_DRAG_PROTO_LOCAL);
|
||||
drop_win32 = GDK_WIN32_DROP (drop);
|
||||
@@ -519,7 +519,6 @@ idroptarget_dragenter (LPDROPTARGET This,
|
||||
GdkDrag *drag;
|
||||
GdkDragAction source_actions;
|
||||
GdkDragAction dest_actions;
|
||||
GdkContentFormats *formats;
|
||||
|
||||
GDK_NOTE (DND, g_print ("idroptarget_dragenter %p @ %ld : %ld"
|
||||
" for dest window 0x%p"
|
||||
@@ -539,17 +538,15 @@ idroptarget_dragenter (LPDROPTARGET This,
|
||||
drag = _gdk_win32_find_drag_for_dest_window (GDK_SURFACE_HWND (ctx->surface));
|
||||
|
||||
display = gdk_surface_get_display (ctx->surface);
|
||||
|
||||
formats = query_object_formats (pDataObj, NULL);
|
||||
drop = gdk_drop_new (display,
|
||||
gdk_seat_get_pointer (gdk_display_get_default_seat (display)),
|
||||
drag,
|
||||
formats,
|
||||
query_object_formats (pDataObj, NULL),
|
||||
ctx->surface,
|
||||
GDK_DRAG_PROTO_OLE2);
|
||||
drop_win32 = GDK_WIN32_DROP (drop);
|
||||
g_array_set_size (drop_win32->droptarget_w32format_contentformat_map, 0);
|
||||
gdk_content_formats_unref (formats);
|
||||
gdk_content_formats_unref (query_object_formats (pDataObj, drop_win32->droptarget_w32format_contentformat_map));
|
||||
|
||||
ctx->drop = drop;
|
||||
|
||||
|
||||
@@ -1201,12 +1201,6 @@ gdk_win32_surface_move (GdkSurface *surface,
|
||||
gdk_win32_surface_move_resize_internal (surface, TRUE, x, y, -1, -1);
|
||||
}
|
||||
|
||||
static void gdk_win32_surface_set_shadow_width (GdkSurface *window,
|
||||
int left,
|
||||
int right,
|
||||
int top,
|
||||
int bottom);
|
||||
|
||||
static void
|
||||
gdk_win32_surface_layout_popup (GdkSurface *surface,
|
||||
int width,
|
||||
@@ -1218,23 +1212,11 @@ gdk_win32_surface_layout_popup (GdkSurface *surface,
|
||||
GdkRectangle bounds;
|
||||
GdkRectangle final_rect;
|
||||
int x, y;
|
||||
int shadow_left, shadow_right, shadow_top, shadow_bottom;
|
||||
|
||||
monitor = gdk_surface_get_layout_monitor (surface, layout,
|
||||
gdk_win32_monitor_get_workarea);
|
||||
gdk_win32_monitor_get_workarea (monitor, &bounds);
|
||||
|
||||
gdk_popup_layout_get_shadow_width (layout,
|
||||
&shadow_left,
|
||||
&shadow_right,
|
||||
&shadow_top,
|
||||
&shadow_bottom);
|
||||
gdk_win32_surface_set_shadow_width (surface,
|
||||
shadow_left,
|
||||
shadow_right,
|
||||
shadow_top,
|
||||
shadow_bottom);
|
||||
|
||||
gdk_surface_layout_popup_helper (surface,
|
||||
width,
|
||||
height,
|
||||
@@ -1651,48 +1633,42 @@ gdk_win32_surface_get_geometry (GdkSurface *window,
|
||||
RECT rect;
|
||||
GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
|
||||
|
||||
if (GDK_IS_TOPLEVEL (window) && impl->drag_move_resize_context.native_move_resize_pending)
|
||||
rect = impl->next_layout.configured_rect;
|
||||
else
|
||||
{
|
||||
POINT pt;
|
||||
GdkSurface *parent;
|
||||
API_CALL (GetClientRect, (GDK_SURFACE_HWND (window), &rect));
|
||||
|
||||
POINT pt;
|
||||
GdkSurface *parent;
|
||||
|
||||
if (GDK_IS_TOPLEVEL (window))
|
||||
parent = NULL;
|
||||
else if (GDK_IS_POPUP (window))
|
||||
parent = gdk_popup_get_parent (GDK_POPUP (window));
|
||||
else
|
||||
parent = NULL;
|
||||
|
||||
|
||||
API_CALL (GetClientRect, (GDK_SURFACE_HWND (window), &rect));
|
||||
|
||||
pt.x = rect.left;
|
||||
pt.y = rect.top;
|
||||
ClientToScreen (GDK_SURFACE_HWND (window), &pt);
|
||||
pt.x = rect.left;
|
||||
pt.y = rect.top;
|
||||
ClientToScreen (GDK_SURFACE_HWND (window), &pt);
|
||||
if (parent)
|
||||
ScreenToClient (GDK_SURFACE_HWND (parent), &pt);
|
||||
ScreenToClient (GDK_SURFACE_HWND (parent), &pt);
|
||||
rect.left = pt.x;
|
||||
rect.top = pt.y;
|
||||
|
||||
rect.left = pt.x;
|
||||
rect.top = pt.y;
|
||||
|
||||
pt.x = rect.right;
|
||||
pt.y = rect.bottom;
|
||||
ClientToScreen (GDK_SURFACE_HWND (window), &pt);
|
||||
pt.x = rect.right;
|
||||
pt.y = rect.bottom;
|
||||
ClientToScreen (GDK_SURFACE_HWND (window), &pt);
|
||||
if (parent)
|
||||
ScreenToClient (GDK_SURFACE_HWND (parent), &pt);
|
||||
ScreenToClient (GDK_SURFACE_HWND (parent), &pt);
|
||||
rect.right = pt.x;
|
||||
rect.bottom = pt.y;
|
||||
|
||||
rect.right = pt.x;
|
||||
rect.bottom = pt.y;
|
||||
|
||||
if (parent == NULL)
|
||||
{
|
||||
rect.left += _gdk_offset_x * impl->surface_scale;
|
||||
rect.top += _gdk_offset_y * impl->surface_scale;
|
||||
rect.right += _gdk_offset_x * impl->surface_scale;
|
||||
rect.bottom += _gdk_offset_y * impl->surface_scale;
|
||||
}
|
||||
}
|
||||
if (parent == NULL)
|
||||
{
|
||||
rect.left += _gdk_offset_x * impl->surface_scale;
|
||||
rect.top += _gdk_offset_y * impl->surface_scale;
|
||||
rect.right += _gdk_offset_x * impl->surface_scale;
|
||||
rect.bottom += _gdk_offset_y * impl->surface_scale;
|
||||
}
|
||||
|
||||
if (x)
|
||||
*x = rect.left / impl->surface_scale;
|
||||
@@ -2297,6 +2273,7 @@ snap_up (GdkSurface *window)
|
||||
impl = GDK_WIN32_SURFACE (window);
|
||||
|
||||
impl->snap_state = GDK_WIN32_AEROSNAP_STATE_FULLUP;
|
||||
impl->resized = FALSE;
|
||||
|
||||
stash_window (window, impl);
|
||||
|
||||
@@ -2334,6 +2311,7 @@ snap_left (GdkSurface *window,
|
||||
impl = GDK_WIN32_SURFACE (window);
|
||||
|
||||
impl->snap_state = GDK_WIN32_AEROSNAP_STATE_HALFLEFT;
|
||||
impl->resized = FALSE;
|
||||
|
||||
gdk_win32_monitor_get_workarea (snap_monitor, &rect);
|
||||
|
||||
@@ -2362,6 +2340,7 @@ snap_right (GdkSurface *window,
|
||||
impl = GDK_WIN32_SURFACE (window);
|
||||
|
||||
impl->snap_state = GDK_WIN32_AEROSNAP_STATE_HALFRIGHT;
|
||||
impl->resized = FALSE;
|
||||
|
||||
gdk_win32_monitor_get_workarea (snap_monitor, &rect);
|
||||
|
||||
@@ -3971,10 +3950,9 @@ gdk_win32_surface_do_move_resize_drag (GdkSurface *window,
|
||||
|
||||
impl->unscaled_width = new_rect.right - new_rect.left;
|
||||
impl->unscaled_height = new_rect.bottom - new_rect.top;
|
||||
|
||||
impl->next_layout.configured_rect = new_rect;
|
||||
impl->next_layout.configured_width = (impl->unscaled_width + scale - 1) / scale;
|
||||
impl->next_layout.configured_height = (impl->unscaled_height + scale - 1) / scale;
|
||||
impl->resized = TRUE;
|
||||
}
|
||||
|
||||
context->native_move_resize_pending = TRUE;
|
||||
@@ -4127,6 +4105,7 @@ gdk_win32_surface_maximize (GdkSurface *window)
|
||||
_gdk_win32_surface_state_to_string (window->state)));
|
||||
|
||||
impl = GDK_WIN32_SURFACE (window);
|
||||
impl->resized = FALSE;
|
||||
|
||||
if (GDK_SURFACE_IS_MAPPED (window))
|
||||
GtkShowWindow (window, SW_MAXIMIZE);
|
||||
@@ -4571,7 +4550,7 @@ _gdk_win32_surface_request_layout (GdkSurface *surface)
|
||||
int scale = impl->surface_scale;
|
||||
RECT rect;
|
||||
|
||||
if (GDK_IS_TOPLEVEL (surface) && impl->drag_move_resize_context.native_move_resize_pending)
|
||||
if (GDK_IS_TOPLEVEL (surface) && impl->resized)
|
||||
{
|
||||
surface->width = impl->next_layout.configured_width;
|
||||
surface->height = impl->next_layout.configured_height;
|
||||
@@ -4599,7 +4578,7 @@ _gdk_win32_surface_compute_size (GdkSurface *surface)
|
||||
if (GDK_IS_TOPLEVEL (surface))
|
||||
compute_toplevel_size (surface, TRUE, &width, &height);
|
||||
|
||||
if (!impl->drag_move_resize_context.native_move_resize_pending)
|
||||
if (!impl->resized)
|
||||
{
|
||||
surface->width = impl->next_layout.configured_width;
|
||||
surface->height = impl->next_layout.configured_height;
|
||||
|
||||
@@ -342,8 +342,8 @@ struct _GdkWin32Surface
|
||||
struct {
|
||||
int configured_width;
|
||||
int configured_height;
|
||||
RECT configured_rect;
|
||||
} next_layout;
|
||||
gboolean resized;
|
||||
|
||||
#ifdef GDK_WIN32_ENABLE_EGL
|
||||
EGLSurface egl_surface;
|
||||
|
||||
@@ -26,8 +26,6 @@
|
||||
#include "gdkprivate-x11.h"
|
||||
#include "gdkdisplay-x11.h"
|
||||
|
||||
#include "gdk-private.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
@@ -762,7 +760,7 @@ gdk_x11_device_xi2_store_axes (GdkX11DeviceXI2 *device,
|
||||
g_free (device->last_axes);
|
||||
|
||||
if (axes && n_axes)
|
||||
device->last_axes = g_memdup2 (axes, sizeof (double) * n_axes);
|
||||
device->last_axes = g_memdup (axes, sizeof (double) * n_axes);
|
||||
else
|
||||
device->last_axes = NULL;
|
||||
}
|
||||
|
||||
+33
-54
@@ -296,20 +296,15 @@ gdk_x11_drag_find (GdkDisplay *display,
|
||||
static void
|
||||
precache_target_list (GdkDrag *drag)
|
||||
{
|
||||
GdkContentFormats *formats;
|
||||
GdkContentFormats *formats = gdk_drag_get_formats (drag);
|
||||
const char * const *atoms;
|
||||
gsize n_atoms;
|
||||
|
||||
formats = gdk_content_formats_ref (gdk_drag_get_formats (drag));
|
||||
formats = gdk_content_formats_union_serialize_mime_types (formats);
|
||||
|
||||
atoms = gdk_content_formats_get_mime_types (formats, &n_atoms);
|
||||
|
||||
_gdk_x11_precache_atoms (gdk_drag_get_display (drag),
|
||||
(const char **) atoms,
|
||||
n_atoms);
|
||||
|
||||
gdk_content_formats_unref (formats);
|
||||
}
|
||||
|
||||
/* Utility functions */
|
||||
@@ -922,12 +917,8 @@ xdnd_set_targets (GdkX11Drag *drag_x11)
|
||||
const char * const *atoms;
|
||||
gsize i, n_atoms;
|
||||
GdkDisplay *display = gdk_drag_get_display (drag);
|
||||
GdkContentFormats *formats;
|
||||
|
||||
formats = gdk_content_formats_ref (gdk_drag_get_formats (drag));
|
||||
formats = gdk_content_formats_union_serialize_mime_types (formats);
|
||||
|
||||
atoms = gdk_content_formats_get_mime_types (formats, &n_atoms);
|
||||
atoms = gdk_content_formats_get_mime_types (gdk_drag_get_formats (drag), &n_atoms);
|
||||
atomlist = g_new (Atom, n_atoms);
|
||||
for (i = 0; i < n_atoms; i++)
|
||||
atomlist[i] = gdk_x11_get_xatom_by_name_for_display (display, atoms[i]);
|
||||
@@ -941,8 +932,6 @@ xdnd_set_targets (GdkX11Drag *drag_x11)
|
||||
g_free (atomlist);
|
||||
|
||||
drag_x11->xdnd_targets_set = 1;
|
||||
|
||||
gdk_content_formats_unref (formats);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1106,8 +1095,6 @@ xdnd_send_enter (GdkX11Drag *drag_x11)
|
||||
}
|
||||
|
||||
xdnd_send_xevent (drag_x11, &xev);
|
||||
|
||||
gdk_content_formats_unref (formats);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1347,7 +1334,7 @@ _gdk_x11_display_get_drag_protocol (GdkDisplay *display,
|
||||
|
||||
static GdkSurfaceCache *
|
||||
drag_find_window_cache (GdkX11Drag *drag_x11,
|
||||
GdkDisplay *display)
|
||||
GdkDisplay *display)
|
||||
{
|
||||
if (!drag_x11->cache)
|
||||
drag_x11->cache = gdk_surface_cache_get (display);
|
||||
@@ -1378,7 +1365,7 @@ gdk_x11_drag_find_surface (GdkDrag *drag,
|
||||
drag_surface && GDK_IS_X11_SURFACE (drag_surface) ?
|
||||
GDK_SURFACE_XID (drag_surface) : None,
|
||||
x_root * screen_x11->surface_scale,
|
||||
y_root * screen_x11->surface_scale);
|
||||
y_root * screen_x11->surface_scale);
|
||||
|
||||
if (drag_x11->dest_xid != dest)
|
||||
{
|
||||
@@ -1408,8 +1395,8 @@ gdk_x11_drag_find_surface (GdkDrag *drag,
|
||||
|
||||
static void
|
||||
move_drag_surface (GdkDrag *drag,
|
||||
guint x_root,
|
||||
guint y_root)
|
||||
guint x_root,
|
||||
guint y_root)
|
||||
{
|
||||
GdkX11Drag *drag_x11 = GDK_X11_DRAG (drag);
|
||||
|
||||
@@ -1420,14 +1407,14 @@ move_drag_surface (GdkDrag *drag,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_x11_drag_drag_motion (GdkDrag *drag,
|
||||
Window proxy_xid,
|
||||
GdkDragProtocol protocol,
|
||||
int x_root,
|
||||
int y_root,
|
||||
GdkDragAction suggested_action,
|
||||
GdkDragAction possible_actions,
|
||||
guint32 time)
|
||||
gdk_x11_drag_drag_motion (GdkDrag *drag,
|
||||
Window proxy_xid,
|
||||
GdkDragProtocol protocol,
|
||||
int x_root,
|
||||
int y_root,
|
||||
GdkDragAction suggested_action,
|
||||
GdkDragAction possible_actions,
|
||||
guint32 time)
|
||||
{
|
||||
GdkX11Drag *drag_x11 = GDK_X11_DRAG (drag);
|
||||
|
||||
@@ -1619,8 +1606,8 @@ gdk_x11_drag_get_drag_surface (GdkDrag *drag)
|
||||
|
||||
static void
|
||||
gdk_x11_drag_set_hotspot (GdkDrag *drag,
|
||||
int hot_x,
|
||||
int hot_y)
|
||||
int hot_x,
|
||||
int hot_y)
|
||||
{
|
||||
GdkX11Drag *x11_drag = GDK_X11_DRAG (drag);
|
||||
|
||||
@@ -1636,8 +1623,8 @@ gdk_x11_drag_set_hotspot (GdkDrag *drag,
|
||||
|
||||
static void
|
||||
gdk_x11_drag_default_output_done (GObject *drag,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
@@ -1649,17 +1636,17 @@ gdk_x11_drag_default_output_done (GObject *drag,
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_x11_drag_default_output_handler (GOutputStream *stream,
|
||||
const char *mime_type,
|
||||
gpointer user_data)
|
||||
gdk_x11_drag_default_output_handler (GOutputStream *stream,
|
||||
const char *mime_type,
|
||||
gpointer user_data)
|
||||
{
|
||||
gdk_drag_write_async (GDK_DRAG (user_data),
|
||||
mime_type,
|
||||
stream,
|
||||
G_PRIORITY_DEFAULT,
|
||||
NULL,
|
||||
gdk_x11_drag_default_output_done,
|
||||
NULL);
|
||||
mime_type,
|
||||
stream,
|
||||
G_PRIORITY_DEFAULT,
|
||||
NULL,
|
||||
gdk_x11_drag_default_output_done,
|
||||
NULL);
|
||||
g_object_unref (stream);
|
||||
}
|
||||
|
||||
@@ -1688,7 +1675,7 @@ gdk_x11_drag_xevent (GdkDisplay *display,
|
||||
if (xevent->xselectionclear.time < x11_drag->timestamp)
|
||||
{
|
||||
GDK_DISPLAY_NOTE (display, CLIPBOARD, g_printerr ("ignoring SelectionClear with too old timestamp (%lu vs %lu)\n",
|
||||
xevent->xselectionclear.time, x11_drag->timestamp));
|
||||
xevent->xselectionclear.time, x11_drag->timestamp));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1698,7 +1685,6 @@ gdk_x11_drag_xevent (GdkDisplay *display,
|
||||
|
||||
case SelectionRequest:
|
||||
{
|
||||
GdkContentFormats *formats;
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
const char *target, *property;
|
||||
#endif
|
||||
@@ -1717,30 +1703,23 @@ gdk_x11_drag_xevent (GdkDisplay *display,
|
||||
if (xevent->xselectionrequest.requestor == None)
|
||||
{
|
||||
GDK_DISPLAY_NOTE (display, CLIPBOARD, g_printerr ("got SelectionRequest for %s @ %s with NULL window, ignoring\n",
|
||||
target, property));
|
||||
target, property));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GDK_DISPLAY_NOTE (display, CLIPBOARD, g_printerr ("got SelectionRequest for %s @ %s\n",
|
||||
target, property));
|
||||
|
||||
formats = gdk_content_formats_ref (gdk_drag_get_formats (drag));
|
||||
formats = gdk_content_formats_union_serialize_mime_types (formats);
|
||||
target, property));
|
||||
|
||||
gdk_x11_selection_output_streams_create (display,
|
||||
formats,
|
||||
gdk_drag_get_formats (drag),
|
||||
xevent->xselectionrequest.requestor,
|
||||
xevent->xselectionrequest.selection,
|
||||
xevent->xselectionrequest.target,
|
||||
xevent->xselectionrequest.property
|
||||
? xevent->xselectionrequest.property
|
||||
: xevent->xselectionrequest.target,
|
||||
xevent->xselectionrequest.property ? xevent->xselectionrequest.property
|
||||
: xevent->xselectionrequest.target,
|
||||
xevent->xselectionrequest.time,
|
||||
gdk_x11_drag_default_output_handler,
|
||||
drag);
|
||||
|
||||
gdk_content_formats_unref (formats);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
+5
-46
@@ -39,7 +39,6 @@
|
||||
#include "gdkscreen-x11.h"
|
||||
#include "gdkselectioninputstream-x11.h"
|
||||
#include "gdkselectionoutputstream-x11.h"
|
||||
#include "gdktextlistconverter-x11.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
@@ -104,49 +103,6 @@ static const struct {
|
||||
|
||||
G_DEFINE_TYPE (GdkX11Drop, gdk_x11_drop, GDK_TYPE_DROP)
|
||||
|
||||
static GInputStream *
|
||||
text_list_convert (GdkDisplay *display,
|
||||
GInputStream *stream,
|
||||
const char *encoding,
|
||||
int format)
|
||||
{
|
||||
GInputStream *converter_stream;
|
||||
GConverter *converter;
|
||||
|
||||
converter = gdk_x11_text_list_converter_to_utf8_new (display, encoding, format);
|
||||
converter_stream = g_converter_input_stream_new (stream, converter);
|
||||
|
||||
g_object_unref (converter);
|
||||
g_object_unref (stream);
|
||||
|
||||
return converter_stream;
|
||||
}
|
||||
|
||||
static GInputStream *
|
||||
no_convert (GdkDisplay *display,
|
||||
GInputStream *stream,
|
||||
const char *encoding,
|
||||
int format)
|
||||
{
|
||||
return stream;
|
||||
}
|
||||
|
||||
static const struct {
|
||||
const char *x_target;
|
||||
const char *mime_type;
|
||||
GInputStream * (* convert) (GdkDisplay *, GInputStream *, const char *, int);
|
||||
const char *type;
|
||||
int format;
|
||||
} special_targets[] = {
|
||||
{ "UTF8_STRING", "text/plain;charset=utf-8", no_convert, "UTF8_STRING", 8 },
|
||||
{ "COMPOUND_TEXT", "text/plain;charset=utf-8", text_list_convert, "COMPOUND_TEXT", 8 },
|
||||
{ "TEXT", "text/plain;charset=utf-8", text_list_convert, "STRING", 8 },
|
||||
{ "STRING", "text/plain;charset=utf-8", text_list_convert, "STRING", 8 },
|
||||
{ "TARGETS", NULL, NULL, "ATOM", 32 },
|
||||
{ "TIMESTAMP", NULL, NULL, "INTEGER", 32 },
|
||||
{ "SAVE_TARGETS", NULL, NULL, "NULL", 32 }
|
||||
};
|
||||
|
||||
static void
|
||||
gdk_x11_drop_read_got_stream (GObject *source,
|
||||
GAsyncResult *res,
|
||||
@@ -189,9 +145,9 @@ gdk_x11_drop_read_got_stream (GObject *source,
|
||||
}
|
||||
else
|
||||
{
|
||||
#if 0
|
||||
gsize i;
|
||||
const char *mime_type = ((GSList *) g_task_get_task_data (task))->data;
|
||||
GdkDrop *drop = GDK_DROP (g_task_get_source_object (task));
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (special_targets); i++)
|
||||
{
|
||||
@@ -199,12 +155,15 @@ gdk_x11_drop_read_got_stream (GObject *source,
|
||||
{
|
||||
g_assert (special_targets[i].mime_type != NULL);
|
||||
|
||||
GDK_DISPLAY_NOTE (CLIPBOARD, g_printerr ("%s: reading with converter from %s to %s\n",
|
||||
cb->selection, mime_type, special_targets[i].mime_type));
|
||||
mime_type = g_intern_string (special_targets[i].mime_type);
|
||||
g_task_set_task_data (task, g_slist_prepend (NULL, (gpointer) mime_type), (GDestroyNotify) g_slist_free);
|
||||
stream = special_targets[i].convert (gdk_drop_get_display (drop), stream, type, format);
|
||||
stream = special_targets[i].convert (cb, stream, type, format);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
GDK_NOTE (DND, g_printerr ("reading DND as %s now\n",
|
||||
(const char *)((GSList *) g_task_get_task_data (task))->data));
|
||||
|
||||
@@ -1383,7 +1383,7 @@ gdk_x11_keymap_translate_keyboard_state (GdkKeymap *keymap,
|
||||
|
||||
tmp_keyval = translate_keysym (keymap_x11, hardware_keycode,
|
||||
group, state,
|
||||
effective_group, level);
|
||||
level, effective_group);
|
||||
}
|
||||
|
||||
if (consumed_modifiers)
|
||||
|
||||
@@ -1814,12 +1814,6 @@ gdk_x11_surface_layout_popup (GdkSurface *surface,
|
||||
gdk_x11_monitor_get_workarea);
|
||||
gdk_x11_monitor_get_workarea (monitor, &bounds);
|
||||
|
||||
gdk_popup_layout_get_shadow_width (layout,
|
||||
&impl->shadow_left,
|
||||
&impl->shadow_right,
|
||||
&impl->shadow_top,
|
||||
&impl->shadow_bottom);
|
||||
|
||||
gdk_surface_layout_popup_helper (surface,
|
||||
width,
|
||||
height,
|
||||
@@ -4238,7 +4232,7 @@ _gdk_x11_moveresize_handle_event (const XEvent *event)
|
||||
*mv_resize->moveresize_pending_event = *event;
|
||||
else
|
||||
mv_resize->moveresize_pending_event =
|
||||
g_memdup2 (event, sizeof (XEvent));
|
||||
g_memdup (event, sizeof (XEvent));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1741,6 +1741,7 @@ render_rounded_clip_node (GskGLRenderer *self,
|
||||
return;
|
||||
}
|
||||
|
||||
/* TODO: Intersect current and new clip */
|
||||
ops_push_clip (builder, &transformed_clip);
|
||||
gsk_gl_renderer_add_render_ops (self, child, builder);
|
||||
ops_pop_clip (builder);
|
||||
@@ -1749,13 +1750,19 @@ render_rounded_clip_node (GskGLRenderer *self,
|
||||
{
|
||||
gboolean is_offscreen;
|
||||
TextureRegion region;
|
||||
|
||||
/* NOTE: We are *not* transforming the clip by the current modelview here.
|
||||
* We instead draw the untransformed clip to a texture and then transform
|
||||
* that texture.
|
||||
*
|
||||
* We do, however, apply the scale factor to the child clip of course.
|
||||
*/
|
||||
ops_push_clip (builder, &transformed_clip);
|
||||
if (!add_offscreen_ops (self, builder, &node->bounds,
|
||||
child,
|
||||
®ion, &is_offscreen,
|
||||
FORCE_OFFSCREEN))
|
||||
0))
|
||||
g_assert_not_reached ();
|
||||
|
||||
ops_pop_clip (builder);
|
||||
|
||||
ops_set_program (builder, &self->programs->blit_program);
|
||||
|
||||
+2
-5
@@ -139,9 +139,7 @@
|
||||
#include "gskglshader.h"
|
||||
#include "gskglshaderprivate.h"
|
||||
#include "gskdebugprivate.h"
|
||||
|
||||
#include "gl/gskglrendererprivate.h"
|
||||
#include "ngl/gsknglrendererprivate.h"
|
||||
|
||||
static GskGLUniformType
|
||||
uniform_type_from_glsl (const char *str)
|
||||
@@ -544,9 +542,8 @@ gsk_gl_shader_compile (GskGLShader *shader,
|
||||
g_return_val_if_fail (GSK_IS_GL_SHADER (shader), FALSE);
|
||||
|
||||
if (GSK_IS_GL_RENDERER (renderer))
|
||||
return gsk_gl_renderer_try_compile_gl_shader (GSK_GL_RENDERER (renderer), shader, error);
|
||||
else if (GSK_IS_NGL_RENDERER (renderer))
|
||||
return gsk_ngl_renderer_try_compile_gl_shader (GSK_NGL_RENDERER (renderer), shader, error);
|
||||
return gsk_gl_renderer_try_compile_gl_shader (GSK_GL_RENDERER (renderer),
|
||||
shader, error);
|
||||
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
"The renderer does not support gl shaders");
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
#include "gskcairorenderer.h"
|
||||
#include "gskdebugprivate.h"
|
||||
#include "gl/gskglrenderer.h"
|
||||
#include "ngl/gsknglrenderer.h"
|
||||
#include "gskprofilerprivate.h"
|
||||
#include "gskrendernodeprivate.h"
|
||||
|
||||
@@ -497,8 +496,6 @@ get_renderer_for_name (const char *renderer_name)
|
||||
else if (g_ascii_strcasecmp (renderer_name, "opengl") == 0
|
||||
|| g_ascii_strcasecmp (renderer_name, "gl") == 0)
|
||||
return GSK_TYPE_GL_RENDERER;
|
||||
else if (g_ascii_strcasecmp (renderer_name, "ngl") == 0)
|
||||
return GSK_TYPE_NGL_RENDERER;
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
else if (g_ascii_strcasecmp (renderer_name, "vulkan") == 0)
|
||||
return GSK_TYPE_VULKAN_RENDERER;
|
||||
@@ -514,7 +511,6 @@ get_renderer_for_name (const char *renderer_name)
|
||||
g_print (" cairo - Use the Cairo fallback renderer\n");
|
||||
g_print (" opengl - Use the default OpenGL renderer\n");
|
||||
g_print (" gl - Same as opengl\n");
|
||||
g_print (" ngl - Another OpenGL renderer\n");
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
g_print (" vulkan - Use the Vulkan renderer\n");
|
||||
#else
|
||||
|
||||
+1
-1
@@ -389,7 +389,7 @@ gsk_render_node_unref (GskRenderNode *node)
|
||||
* Returns: the type of the #GskRenderNode
|
||||
*/
|
||||
GskRenderNodeType
|
||||
gsk_render_node_get_node_type (const GskRenderNode *node)
|
||||
gsk_render_node_get_node_type (GskRenderNode *node)
|
||||
{
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE (node), GSK_NOT_A_RENDER_NODE);
|
||||
|
||||
|
||||
+79
-80
@@ -118,7 +118,7 @@ GDK_AVAILABLE_IN_ALL
|
||||
void gsk_render_node_unref (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNodeType gsk_render_node_get_node_type (const GskRenderNode *node);
|
||||
GskRenderNodeType gsk_render_node_get_node_type (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gsk_render_node_get_bounds (GskRenderNode *node,
|
||||
@@ -197,9 +197,9 @@ GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_debug_node_new (GskRenderNode *child,
|
||||
char *message);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_debug_node_get_child (const GskRenderNode *node) G_GNUC_PURE;
|
||||
GskRenderNode * gsk_debug_node_get_child (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const char * gsk_debug_node_get_message (const GskRenderNode *node) G_GNUC_PURE;
|
||||
const char * gsk_debug_node_get_message (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_color_node_get_type (void) G_GNUC_CONST;
|
||||
@@ -207,7 +207,7 @@ GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_color_node_new (const GdkRGBA *rgba,
|
||||
const graphene_rect_t *bounds);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const GdkRGBA * gsk_color_node_get_color (const GskRenderNode *node) G_GNUC_PURE;
|
||||
const GdkRGBA * gsk_color_node_get_color (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_texture_node_get_type (void) G_GNUC_CONST;
|
||||
@@ -215,7 +215,7 @@ GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_texture_node_new (GdkTexture *texture,
|
||||
const graphene_rect_t *bounds);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkTexture * gsk_texture_node_get_texture (const GskRenderNode *node) G_GNUC_PURE;
|
||||
GdkTexture * gsk_texture_node_get_texture (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_linear_gradient_node_get_type (void) G_GNUC_CONST;
|
||||
@@ -226,14 +226,14 @@ GskRenderNode * gsk_linear_gradient_node_new (const graph
|
||||
const GskColorStop *color_stops,
|
||||
gsize n_color_stops);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const graphene_point_t * gsk_linear_gradient_node_get_start (const GskRenderNode *node) G_GNUC_PURE;
|
||||
const graphene_point_t * gsk_linear_gradient_node_get_start (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const graphene_point_t * gsk_linear_gradient_node_get_end (const GskRenderNode *node) G_GNUC_PURE;
|
||||
const graphene_point_t * gsk_linear_gradient_node_get_end (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gsize gsk_linear_gradient_node_get_n_color_stops (const GskRenderNode *node) G_GNUC_PURE;
|
||||
gsize gsk_linear_gradient_node_get_n_color_stops (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const GskColorStop * gsk_linear_gradient_node_get_color_stops (const GskRenderNode *node,
|
||||
gsize *n_stops) G_GNUC_PURE;
|
||||
const GskColorStop * gsk_linear_gradient_node_get_color_stops (GskRenderNode *node,
|
||||
gsize *n_stops);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_repeating_linear_gradient_node_get_type (void) G_GNUC_CONST;
|
||||
@@ -253,16 +253,16 @@ GskRenderNode * gsk_conic_gradient_node_new (const graph
|
||||
const GskColorStop *color_stops,
|
||||
gsize n_color_stops);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const graphene_point_t * gsk_conic_gradient_node_get_center (const GskRenderNode *node) G_GNUC_PURE;
|
||||
const graphene_point_t * gsk_conic_gradient_node_get_center (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
float gsk_conic_gradient_node_get_rotation (const GskRenderNode *node) G_GNUC_PURE;
|
||||
float gsk_conic_gradient_node_get_rotation (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
float gsk_conic_gradient_node_get_angle (const GskRenderNode *node) G_GNUC_PURE;
|
||||
float gsk_conic_gradient_node_get_angle (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gsize gsk_conic_gradient_node_get_n_color_stops (const GskRenderNode *node) G_GNUC_PURE;
|
||||
gsize gsk_conic_gradient_node_get_n_color_stops (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const GskColorStop * gsk_conic_gradient_node_get_color_stops (const GskRenderNode *node,
|
||||
gsize *n_stops) G_GNUC_PURE;
|
||||
const GskColorStop * gsk_conic_gradient_node_get_color_stops (GskRenderNode *node,
|
||||
gsize *n_stops);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_radial_gradient_node_get_type (void) G_GNUC_CONST;
|
||||
@@ -276,20 +276,20 @@ GskRenderNode * gsk_radial_gradient_node_new (const graphene_rect_t
|
||||
const GskColorStop *color_stops,
|
||||
gsize n_color_stops);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gsize gsk_radial_gradient_node_get_n_color_stops (const GskRenderNode *node) G_GNUC_PURE;
|
||||
gsize gsk_radial_gradient_node_get_n_color_stops (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const GskColorStop * gsk_radial_gradient_node_get_color_stops (const GskRenderNode *node,
|
||||
gsize *n_stops) G_GNUC_PURE;
|
||||
const GskColorStop * gsk_radial_gradient_node_get_color_stops (GskRenderNode *node,
|
||||
gsize *n_stops);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const graphene_point_t *gsk_radial_gradient_node_get_center (const GskRenderNode *node) G_GNUC_PURE;
|
||||
const graphene_point_t *gsk_radial_gradient_node_get_center (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
float gsk_radial_gradient_node_get_hradius (const GskRenderNode *node) G_GNUC_PURE;
|
||||
float gsk_radial_gradient_node_get_hradius (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
float gsk_radial_gradient_node_get_vradius (const GskRenderNode *node) G_GNUC_PURE;
|
||||
float gsk_radial_gradient_node_get_vradius (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
float gsk_radial_gradient_node_get_start (const GskRenderNode *node) G_GNUC_PURE;
|
||||
float gsk_radial_gradient_node_get_start (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
float gsk_radial_gradient_node_get_end (const GskRenderNode *node) G_GNUC_PURE;
|
||||
float gsk_radial_gradient_node_get_end (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_repeating_radial_gradient_node_get_type (void) G_GNUC_CONST;
|
||||
@@ -310,11 +310,11 @@ GskRenderNode * gsk_border_node_new (const GskRounde
|
||||
const float border_width[4],
|
||||
const GdkRGBA border_color[4]);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const GskRoundedRect * gsk_border_node_get_outline (const GskRenderNode *node) G_GNUC_PURE;
|
||||
const GskRoundedRect * gsk_border_node_get_outline (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const float * gsk_border_node_get_widths (const GskRenderNode *node) G_GNUC_PURE;
|
||||
const float * gsk_border_node_get_widths (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const GdkRGBA * gsk_border_node_get_colors (const GskRenderNode *node) G_GNUC_PURE;
|
||||
const GdkRGBA * gsk_border_node_get_colors (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_inset_shadow_node_get_type (void) G_GNUC_CONST;
|
||||
@@ -326,17 +326,17 @@ GskRenderNode * gsk_inset_shadow_node_new (const GskRounde
|
||||
float spread,
|
||||
float blur_radius);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const GskRoundedRect * gsk_inset_shadow_node_get_outline (const GskRenderNode *node) G_GNUC_PURE;
|
||||
const GskRoundedRect * gsk_inset_shadow_node_get_outline (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const GdkRGBA * gsk_inset_shadow_node_get_color (const GskRenderNode *node) G_GNUC_PURE;
|
||||
const GdkRGBA * gsk_inset_shadow_node_get_color (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
float gsk_inset_shadow_node_get_dx (const GskRenderNode *node) G_GNUC_PURE;
|
||||
float gsk_inset_shadow_node_get_dx (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
float gsk_inset_shadow_node_get_dy (const GskRenderNode *node) G_GNUC_PURE;
|
||||
float gsk_inset_shadow_node_get_dy (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
float gsk_inset_shadow_node_get_spread (const GskRenderNode *node) G_GNUC_PURE;
|
||||
float gsk_inset_shadow_node_get_spread (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
float gsk_inset_shadow_node_get_blur_radius (const GskRenderNode *node) G_GNUC_PURE;
|
||||
float gsk_inset_shadow_node_get_blur_radius (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_outset_shadow_node_get_type (void) G_GNUC_CONST;
|
||||
@@ -348,17 +348,17 @@ GskRenderNode * gsk_outset_shadow_node_new (const GskRounde
|
||||
float spread,
|
||||
float blur_radius);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const GskRoundedRect * gsk_outset_shadow_node_get_outline (const GskRenderNode *node) G_GNUC_PURE;
|
||||
const GskRoundedRect * gsk_outset_shadow_node_get_outline (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const GdkRGBA * gsk_outset_shadow_node_get_color (const GskRenderNode *node) G_GNUC_PURE;
|
||||
const GdkRGBA * gsk_outset_shadow_node_get_color (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
float gsk_outset_shadow_node_get_dx (const GskRenderNode *node) G_GNUC_PURE;
|
||||
float gsk_outset_shadow_node_get_dx (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
float gsk_outset_shadow_node_get_dy (const GskRenderNode *node) G_GNUC_PURE;
|
||||
float gsk_outset_shadow_node_get_dy (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
float gsk_outset_shadow_node_get_spread (const GskRenderNode *node) G_GNUC_PURE;
|
||||
float gsk_outset_shadow_node_get_spread (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
float gsk_outset_shadow_node_get_blur_radius (const GskRenderNode *node) G_GNUC_PURE;
|
||||
float gsk_outset_shadow_node_get_blur_radius (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_cairo_node_get_type (void) G_GNUC_CONST;
|
||||
@@ -375,10 +375,10 @@ GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_container_node_new (GskRenderNode **children,
|
||||
guint n_children);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
guint gsk_container_node_get_n_children (const GskRenderNode *node) G_GNUC_PURE;
|
||||
guint gsk_container_node_get_n_children (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_container_node_get_child (const GskRenderNode *node,
|
||||
guint idx) G_GNUC_PURE;
|
||||
GskRenderNode * gsk_container_node_get_child (GskRenderNode *node,
|
||||
guint idx);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_transform_node_get_type (void) G_GNUC_CONST;
|
||||
@@ -386,9 +386,9 @@ GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_transform_node_new (GskRenderNode *child,
|
||||
GskTransform *transform);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_transform_node_get_child (const GskRenderNode *node) G_GNUC_PURE;
|
||||
GskRenderNode * gsk_transform_node_get_child (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskTransform * gsk_transform_node_get_transform (const GskRenderNode *node) G_GNUC_PURE;
|
||||
GskTransform * gsk_transform_node_get_transform (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_opacity_node_get_type (void) G_GNUC_CONST;
|
||||
@@ -396,9 +396,9 @@ GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_opacity_node_new (GskRenderNode *child,
|
||||
float opacity);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_opacity_node_get_child (const GskRenderNode *node) G_GNUC_PURE;
|
||||
GskRenderNode * gsk_opacity_node_get_child (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
float gsk_opacity_node_get_opacity (const GskRenderNode *node) G_GNUC_PURE;
|
||||
float gsk_opacity_node_get_opacity (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_color_matrix_node_get_type (void) G_GNUC_CONST;
|
||||
@@ -407,12 +407,12 @@ GskRenderNode * gsk_color_matrix_node_new (GskRenderNode
|
||||
const graphene_matrix_t *color_matrix,
|
||||
const graphene_vec4_t *color_offset);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_color_matrix_node_get_child (const GskRenderNode *node) G_GNUC_PURE;
|
||||
GskRenderNode * gsk_color_matrix_node_get_child (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const graphene_matrix_t *
|
||||
gsk_color_matrix_node_get_color_matrix (const GskRenderNode *node) G_GNUC_PURE;
|
||||
gsk_color_matrix_node_get_color_matrix (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const graphene_vec4_t * gsk_color_matrix_node_get_color_offset (const GskRenderNode *node) G_GNUC_PURE;
|
||||
const graphene_vec4_t * gsk_color_matrix_node_get_color_offset (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_repeat_node_get_type (void) G_GNUC_CONST;
|
||||
@@ -421,9 +421,9 @@ GskRenderNode * gsk_repeat_node_new (const graphene_
|
||||
GskRenderNode *child,
|
||||
const graphene_rect_t *child_bounds);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_repeat_node_get_child (const GskRenderNode *node) G_GNUC_PURE;
|
||||
GskRenderNode * gsk_repeat_node_get_child (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const graphene_rect_t * gsk_repeat_node_get_child_bounds (const GskRenderNode *node) G_GNUC_PURE;
|
||||
const graphene_rect_t * gsk_repeat_node_get_child_bounds (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_clip_node_get_type (void) G_GNUC_CONST;
|
||||
@@ -431,9 +431,9 @@ GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_clip_node_new (GskRenderNode *child,
|
||||
const graphene_rect_t *clip);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_clip_node_get_child (const GskRenderNode *node) G_GNUC_PURE;
|
||||
GskRenderNode * gsk_clip_node_get_child (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const graphene_rect_t * gsk_clip_node_get_clip (const GskRenderNode *node) G_GNUC_PURE;
|
||||
const graphene_rect_t * gsk_clip_node_get_clip (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_rounded_clip_node_get_type (void) G_GNUC_CONST;
|
||||
@@ -441,9 +441,9 @@ GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_rounded_clip_node_new (GskRenderNode *child,
|
||||
const GskRoundedRect *clip);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_rounded_clip_node_get_child (const GskRenderNode *node) G_GNUC_PURE;
|
||||
GskRenderNode * gsk_rounded_clip_node_get_child (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const GskRoundedRect * gsk_rounded_clip_node_get_clip (const GskRenderNode *node) G_GNUC_PURE;
|
||||
const GskRoundedRect * gsk_rounded_clip_node_get_clip (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_shadow_node_get_type (void) G_GNUC_CONST;
|
||||
@@ -452,12 +452,12 @@ GskRenderNode * gsk_shadow_node_new (GskRenderNode
|
||||
const GskShadow *shadows,
|
||||
gsize n_shadows);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_shadow_node_get_child (const GskRenderNode *node) G_GNUC_PURE;
|
||||
GskRenderNode * gsk_shadow_node_get_child (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const GskShadow * gsk_shadow_node_get_shadow (const GskRenderNode *node,
|
||||
gsize i) G_GNUC_PURE;
|
||||
const GskShadow * gsk_shadow_node_get_shadow (GskRenderNode *node,
|
||||
gsize i);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gsize gsk_shadow_node_get_n_shadows (const GskRenderNode *node) G_GNUC_PURE;
|
||||
gsize gsk_shadow_node_get_n_shadows (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_blend_node_get_type (void) G_GNUC_CONST;
|
||||
@@ -466,11 +466,11 @@ GskRenderNode * gsk_blend_node_new (GskRenderNode
|
||||
GskRenderNode *top,
|
||||
GskBlendMode blend_mode);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_blend_node_get_bottom_child (const GskRenderNode *node) G_GNUC_PURE;
|
||||
GskRenderNode * gsk_blend_node_get_bottom_child (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_blend_node_get_top_child (const GskRenderNode *node) G_GNUC_PURE;
|
||||
GskRenderNode * gsk_blend_node_get_top_child (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskBlendMode gsk_blend_node_get_blend_mode (const GskRenderNode *node) G_GNUC_PURE;
|
||||
GskBlendMode gsk_blend_node_get_blend_mode (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_cross_fade_node_get_type (void) G_GNUC_CONST;
|
||||
@@ -479,11 +479,11 @@ GskRenderNode * gsk_cross_fade_node_new (GskRenderNode
|
||||
GskRenderNode *end,
|
||||
float progress);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_cross_fade_node_get_start_child (const GskRenderNode *node) G_GNUC_PURE;
|
||||
GskRenderNode * gsk_cross_fade_node_get_start_child (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_cross_fade_node_get_end_child (const GskRenderNode *node) G_GNUC_PURE;
|
||||
GskRenderNode * gsk_cross_fade_node_get_end_child (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
float gsk_cross_fade_node_get_progress (const GskRenderNode *node) G_GNUC_PURE;
|
||||
float gsk_cross_fade_node_get_progress (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_text_node_get_type (void) G_GNUC_CONST;
|
||||
@@ -493,18 +493,17 @@ GskRenderNode * gsk_text_node_new (PangoFont
|
||||
const GdkRGBA *color,
|
||||
const graphene_point_t *offset);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
PangoFont * gsk_text_node_get_font (const GskRenderNode *node) G_GNUC_PURE;
|
||||
PangoFont * gsk_text_node_get_font (GskRenderNode *node);
|
||||
gboolean gsk_text_node_has_color_glyphs (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gsk_text_node_has_color_glyphs (const GskRenderNode *node) G_GNUC_PURE;
|
||||
guint gsk_text_node_get_num_glyphs (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
guint gsk_text_node_get_num_glyphs (const GskRenderNode *node) G_GNUC_PURE;
|
||||
const PangoGlyphInfo *gsk_text_node_get_glyphs (GskRenderNode *node,
|
||||
guint *n_glyphs);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const PangoGlyphInfo *gsk_text_node_get_glyphs (const GskRenderNode *node,
|
||||
guint *n_glyphs) G_GNUC_PURE;
|
||||
const GdkRGBA * gsk_text_node_get_color (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const GdkRGBA * gsk_text_node_get_color (const GskRenderNode *node) G_GNUC_PURE;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const graphene_point_t *gsk_text_node_get_offset (const GskRenderNode *node) G_GNUC_PURE;
|
||||
const graphene_point_t *gsk_text_node_get_offset (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_blur_node_get_type (void) G_GNUC_CONST;
|
||||
@@ -512,9 +511,9 @@ GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_blur_node_new (GskRenderNode *child,
|
||||
float radius);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_blur_node_get_child (const GskRenderNode *node) G_GNUC_PURE;
|
||||
GskRenderNode * gsk_blur_node_get_child (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
float gsk_blur_node_get_radius (const GskRenderNode *node) G_GNUC_PURE;
|
||||
float gsk_blur_node_get_radius (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_gl_shader_node_get_type (void) G_GNUC_CONST;
|
||||
@@ -525,14 +524,14 @@ GskRenderNode * gsk_gl_shader_node_new (GskGLShader
|
||||
GskRenderNode **children,
|
||||
guint n_children);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
guint gsk_gl_shader_node_get_n_children (const GskRenderNode *node) G_GNUC_PURE;
|
||||
guint gsk_gl_shader_node_get_n_children (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_gl_shader_node_get_child (const GskRenderNode *node,
|
||||
guint idx) G_GNUC_PURE;
|
||||
GskRenderNode * gsk_gl_shader_node_get_child (GskRenderNode *node,
|
||||
guint idx);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GBytes * gsk_gl_shader_node_get_args (const GskRenderNode *node) G_GNUC_PURE;
|
||||
GBytes * gsk_gl_shader_node_get_args (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskGLShader * gsk_gl_shader_node_get_shader (const GskRenderNode *node) G_GNUC_PURE;
|
||||
GskGLShader * gsk_gl_shader_node_get_shader (GskRenderNode *node);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
+256
-156
@@ -28,8 +28,6 @@
|
||||
#include "gsktransformprivate.h"
|
||||
|
||||
#include "gdk/gdktextureprivate.h"
|
||||
#include "gdk/gdk-private.h"
|
||||
|
||||
#include <cairo-ft.h>
|
||||
|
||||
static inline void
|
||||
@@ -101,7 +99,7 @@ gsk_color_node_diff (GskRenderNode *node1,
|
||||
* Returns: (transfer none): the color of the node
|
||||
*/
|
||||
const GdkRGBA *
|
||||
gsk_color_node_get_color (const GskRenderNode *node)
|
||||
gsk_color_node_get_color (GskRenderNode *node)
|
||||
{
|
||||
GskColorNode *self = (GskColorNode *) node;
|
||||
|
||||
@@ -348,9 +346,9 @@ gsk_repeating_linear_gradient_node_new (const graphene_rect_t *bounds,
|
||||
* Returns: (transfer none): the initial point
|
||||
*/
|
||||
const graphene_point_t *
|
||||
gsk_linear_gradient_node_get_start (const GskRenderNode *node)
|
||||
gsk_linear_gradient_node_get_start (GskRenderNode *node)
|
||||
{
|
||||
const GskLinearGradientNode *self = (const GskLinearGradientNode *) node;
|
||||
GskLinearGradientNode *self = (GskLinearGradientNode *) node;
|
||||
|
||||
return &self->start;
|
||||
}
|
||||
@@ -364,9 +362,9 @@ gsk_linear_gradient_node_get_start (const GskRenderNode *node)
|
||||
* Returns: (transfer none): the final point
|
||||
*/
|
||||
const graphene_point_t *
|
||||
gsk_linear_gradient_node_get_end (const GskRenderNode *node)
|
||||
gsk_linear_gradient_node_get_end (GskRenderNode *node)
|
||||
{
|
||||
const GskLinearGradientNode *self = (const GskLinearGradientNode *) node;
|
||||
GskLinearGradientNode *self = (GskLinearGradientNode *) node;
|
||||
|
||||
return &self->end;
|
||||
}
|
||||
@@ -380,9 +378,9 @@ gsk_linear_gradient_node_get_end (const GskRenderNode *node)
|
||||
* Returns: the number of color stops
|
||||
*/
|
||||
gsize
|
||||
gsk_linear_gradient_node_get_n_color_stops (const GskRenderNode *node)
|
||||
gsk_linear_gradient_node_get_n_color_stops (GskRenderNode *node)
|
||||
{
|
||||
const GskLinearGradientNode *self = (const GskLinearGradientNode *) node;
|
||||
GskLinearGradientNode *self = (GskLinearGradientNode *) node;
|
||||
|
||||
return self->n_stops;
|
||||
}
|
||||
@@ -397,10 +395,10 @@ gsk_linear_gradient_node_get_n_color_stops (const GskRenderNode *node)
|
||||
* Returns: (array length=n_stops): the color stops in the gradient
|
||||
*/
|
||||
const GskColorStop *
|
||||
gsk_linear_gradient_node_get_color_stops (const GskRenderNode *node,
|
||||
gsize *n_stops)
|
||||
gsk_linear_gradient_node_get_color_stops (GskRenderNode *node,
|
||||
gsize *n_stops)
|
||||
{
|
||||
const GskLinearGradientNode *self = (const GskLinearGradientNode *) node;
|
||||
GskLinearGradientNode *self = (GskLinearGradientNode *) node;
|
||||
|
||||
if (n_stops != NULL)
|
||||
*n_stops = self->n_stops;
|
||||
@@ -662,9 +660,9 @@ gsk_repeating_radial_gradient_node_new (const graphene_rect_t *bounds,
|
||||
* Returns: the number of color stops
|
||||
*/
|
||||
gsize
|
||||
gsk_radial_gradient_node_get_n_color_stops (const GskRenderNode *node)
|
||||
gsk_radial_gradient_node_get_n_color_stops (GskRenderNode *node)
|
||||
{
|
||||
const GskRadialGradientNode *self = (const GskRadialGradientNode *) node;
|
||||
GskRadialGradientNode *self = (GskRadialGradientNode *) node;
|
||||
|
||||
return self->n_stops;
|
||||
}
|
||||
@@ -679,10 +677,10 @@ gsk_radial_gradient_node_get_n_color_stops (const GskRenderNode *node)
|
||||
* Returns: (array length=n_stops): the color stops in the gradient
|
||||
*/
|
||||
const GskColorStop *
|
||||
gsk_radial_gradient_node_get_color_stops (const GskRenderNode *node,
|
||||
gsize *n_stops)
|
||||
gsk_radial_gradient_node_get_color_stops (GskRenderNode *node,
|
||||
gsize *n_stops)
|
||||
{
|
||||
const GskRadialGradientNode *self = (const GskRadialGradientNode *) node;
|
||||
GskRadialGradientNode *self = (GskRadialGradientNode *) node;
|
||||
|
||||
if (n_stops != NULL)
|
||||
*n_stops = self->n_stops;
|
||||
@@ -699,9 +697,9 @@ gsk_radial_gradient_node_get_color_stops (const GskRenderNode *node,
|
||||
* Returns: the center point for the gradient
|
||||
*/
|
||||
const graphene_point_t *
|
||||
gsk_radial_gradient_node_get_center (const GskRenderNode *node)
|
||||
gsk_radial_gradient_node_get_center (GskRenderNode *node)
|
||||
{
|
||||
const GskRadialGradientNode *self = (const GskRadialGradientNode *) node;
|
||||
GskRadialGradientNode *self = (GskRadialGradientNode *) node;
|
||||
|
||||
return &self->center;
|
||||
}
|
||||
@@ -715,9 +713,9 @@ gsk_radial_gradient_node_get_center (const GskRenderNode *node)
|
||||
* Returns: the horizontal radius for the gradient
|
||||
*/
|
||||
float
|
||||
gsk_radial_gradient_node_get_hradius (const GskRenderNode *node)
|
||||
gsk_radial_gradient_node_get_hradius (GskRenderNode *node)
|
||||
{
|
||||
const GskRadialGradientNode *self = (const GskRadialGradientNode *) node;
|
||||
GskRadialGradientNode *self = (GskRadialGradientNode *) node;
|
||||
|
||||
return self->hradius;
|
||||
}
|
||||
@@ -731,9 +729,9 @@ gsk_radial_gradient_node_get_hradius (const GskRenderNode *node)
|
||||
* Returns: the vertical radius for the gradient
|
||||
*/
|
||||
float
|
||||
gsk_radial_gradient_node_get_vradius (const GskRenderNode *node)
|
||||
gsk_radial_gradient_node_get_vradius (GskRenderNode *node)
|
||||
{
|
||||
const GskRadialGradientNode *self = (const GskRadialGradientNode *) node;
|
||||
GskRadialGradientNode *self = (GskRadialGradientNode *) node;
|
||||
|
||||
return self->vradius;
|
||||
}
|
||||
@@ -747,9 +745,9 @@ gsk_radial_gradient_node_get_vradius (const GskRenderNode *node)
|
||||
* Returns: the start value for the gradient
|
||||
*/
|
||||
float
|
||||
gsk_radial_gradient_node_get_start (const GskRenderNode *node)
|
||||
gsk_radial_gradient_node_get_start (GskRenderNode *node)
|
||||
{
|
||||
const GskRadialGradientNode *self = (const GskRadialGradientNode *) node;
|
||||
GskRadialGradientNode *self = (GskRadialGradientNode *) node;
|
||||
|
||||
return self->start;
|
||||
}
|
||||
@@ -763,9 +761,9 @@ gsk_radial_gradient_node_get_start (const GskRenderNode *node)
|
||||
* Returns: the end value for the gradient
|
||||
*/
|
||||
float
|
||||
gsk_radial_gradient_node_get_end (const GskRenderNode *node)
|
||||
gsk_radial_gradient_node_get_end (GskRenderNode *node)
|
||||
{
|
||||
const GskRadialGradientNode *self = (const GskRadialGradientNode *) node;
|
||||
GskRadialGradientNode *self = (GskRadialGradientNode *) node;
|
||||
|
||||
return self->end;
|
||||
}
|
||||
@@ -834,7 +832,7 @@ project (double angle,
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_conic_gradient_node_add_patch (cairo_pattern_t *pattern,
|
||||
gsk_conic_gradient_node_add_patch (cairo_pattern_t *pattern,
|
||||
float radius,
|
||||
float start_angle,
|
||||
const GdkRGBA *start_color,
|
||||
@@ -928,7 +926,7 @@ gsk_conic_gradient_node_draw (GskRenderNode *node,
|
||||
&stop2->color,
|
||||
(end_angle - offset1) / (offset2 - offset1));
|
||||
|
||||
gsk_conic_gradient_node_add_patch (pattern,
|
||||
gsk_conic_gradient_node_add_patch (pattern,
|
||||
radius,
|
||||
DEG_TO_RAD (start_angle),
|
||||
&start_color,
|
||||
@@ -1044,9 +1042,9 @@ gsk_conic_gradient_node_new (const graphene_rect_t *bounds,
|
||||
* Returns: the number of color stops
|
||||
*/
|
||||
gsize
|
||||
gsk_conic_gradient_node_get_n_color_stops (const GskRenderNode *node)
|
||||
gsk_conic_gradient_node_get_n_color_stops (GskRenderNode *node)
|
||||
{
|
||||
const GskConicGradientNode *self = (const GskConicGradientNode *) node;
|
||||
GskConicGradientNode *self = (GskConicGradientNode *) node;
|
||||
|
||||
return self->n_stops;
|
||||
}
|
||||
@@ -1061,10 +1059,10 @@ gsk_conic_gradient_node_get_n_color_stops (const GskRenderNode *node)
|
||||
* Returns: (array length=n_stops): the color stops in the gradient
|
||||
*/
|
||||
const GskColorStop *
|
||||
gsk_conic_gradient_node_get_color_stops (const GskRenderNode *node,
|
||||
gsize *n_stops)
|
||||
gsk_conic_gradient_node_get_color_stops (GskRenderNode *node,
|
||||
gsize *n_stops)
|
||||
{
|
||||
const GskConicGradientNode *self = (const GskConicGradientNode *) node;
|
||||
GskConicGradientNode *self = (GskConicGradientNode *) node;
|
||||
|
||||
if (n_stops != NULL)
|
||||
*n_stops = self->n_stops;
|
||||
@@ -1081,9 +1079,9 @@ gsk_conic_gradient_node_get_color_stops (const GskRenderNode *node,
|
||||
* Returns: the center point for the gradient
|
||||
*/
|
||||
const graphene_point_t *
|
||||
gsk_conic_gradient_node_get_center (const GskRenderNode *node)
|
||||
gsk_conic_gradient_node_get_center (GskRenderNode *node)
|
||||
{
|
||||
const GskConicGradientNode *self = (const GskConicGradientNode *) node;
|
||||
GskConicGradientNode *self = (GskConicGradientNode *) node;
|
||||
|
||||
return &self->center;
|
||||
}
|
||||
@@ -1097,9 +1095,9 @@ gsk_conic_gradient_node_get_center (const GskRenderNode *node)
|
||||
* Returns: the rotation for the gradient
|
||||
*/
|
||||
float
|
||||
gsk_conic_gradient_node_get_rotation (const GskRenderNode *node)
|
||||
gsk_conic_gradient_node_get_rotation (GskRenderNode *node)
|
||||
{
|
||||
const GskConicGradientNode *self = (const GskConicGradientNode *) node;
|
||||
GskConicGradientNode *self = (GskConicGradientNode *) node;
|
||||
|
||||
return self->rotation;
|
||||
}
|
||||
@@ -1117,9 +1115,9 @@ gsk_conic_gradient_node_get_rotation (const GskRenderNode *node)
|
||||
* Returns: the angle for the gradient
|
||||
*/
|
||||
float
|
||||
gsk_conic_gradient_node_get_angle (const GskRenderNode *node)
|
||||
gsk_conic_gradient_node_get_angle (GskRenderNode *node)
|
||||
{
|
||||
const GskConicGradientNode *self = (const GskConicGradientNode *) node;
|
||||
GskConicGradientNode *self = (GskConicGradientNode *) node;
|
||||
|
||||
return self->angle;
|
||||
}
|
||||
@@ -1322,9 +1320,9 @@ gsk_border_node_diff (GskRenderNode *node1,
|
||||
* Returns: the outline of the border
|
||||
*/
|
||||
const GskRoundedRect *
|
||||
gsk_border_node_get_outline (const GskRenderNode *node)
|
||||
gsk_border_node_get_outline (GskRenderNode *node)
|
||||
{
|
||||
const GskBorderNode *self = (const GskBorderNode *) node;
|
||||
GskBorderNode *self = (GskBorderNode *) node;
|
||||
|
||||
return &self->outline;
|
||||
}
|
||||
@@ -1340,9 +1338,9 @@ gsk_border_node_get_outline (const GskRenderNode *node)
|
||||
* respectively
|
||||
*/
|
||||
const float *
|
||||
gsk_border_node_get_widths (const GskRenderNode *node)
|
||||
gsk_border_node_get_widths (GskRenderNode *node)
|
||||
{
|
||||
const GskBorderNode *self = (const GskBorderNode *) node;
|
||||
GskBorderNode *self = (GskBorderNode *) node;
|
||||
|
||||
return self->border_width;
|
||||
}
|
||||
@@ -1357,9 +1355,9 @@ gsk_border_node_get_widths (const GskRenderNode *node)
|
||||
* for the top, right, bottom and left color of the border
|
||||
*/
|
||||
const GdkRGBA *
|
||||
gsk_border_node_get_colors (const GskRenderNode *node)
|
||||
gsk_border_node_get_colors (GskRenderNode *node)
|
||||
{
|
||||
const GskBorderNode *self = (const GskBorderNode *) node;
|
||||
GskBorderNode *self = (GskBorderNode *) node;
|
||||
|
||||
return self->border_color;
|
||||
}
|
||||
@@ -1415,9 +1413,9 @@ gsk_border_node_new (const GskRoundedRect *outline,
|
||||
|
||||
/* Private */
|
||||
bool
|
||||
gsk_border_node_get_uniform (const GskRenderNode *self)
|
||||
gsk_border_node_get_uniform (GskRenderNode *self)
|
||||
{
|
||||
return ((const GskBorderNode *)self)->uniform;
|
||||
return ((GskBorderNode *)self)->uniform;
|
||||
}
|
||||
|
||||
/*** GSK_TEXTURE_NODE ***/
|
||||
@@ -1498,9 +1496,11 @@ gsk_texture_node_diff (GskRenderNode *node1,
|
||||
* Returns: (transfer none): the #GdkTexture
|
||||
*/
|
||||
GdkTexture *
|
||||
gsk_texture_node_get_texture (const GskRenderNode *node)
|
||||
gsk_texture_node_get_texture (GskRenderNode *node)
|
||||
{
|
||||
const GskTextureNode *self = (const GskTextureNode *) node;
|
||||
GskTextureNode *self = (GskTextureNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_TEXTURE_NODE), 0);
|
||||
|
||||
return self->texture;
|
||||
}
|
||||
@@ -1746,7 +1746,7 @@ draw_shadow_corner (cairo_t *cr,
|
||||
cairo_fill (mask_cr);
|
||||
gsk_cairo_blur_surface (mask, radius, GSK_BLUR_X | GSK_BLUR_Y);
|
||||
cairo_destroy (mask_cr);
|
||||
g_hash_table_insert (corner_mask_cache, g_memdup2 (&key, sizeof (key)), mask);
|
||||
g_hash_table_insert (corner_mask_cache, g_memdup (&key, sizeof (key)), mask);
|
||||
}
|
||||
|
||||
gdk_cairo_set_source_rgba (cr, color);
|
||||
@@ -1999,9 +1999,11 @@ gsk_inset_shadow_node_new (const GskRoundedRect *outline,
|
||||
* Returns: (transfer none): a rounded rectangle
|
||||
*/
|
||||
const GskRoundedRect *
|
||||
gsk_inset_shadow_node_get_outline (const GskRenderNode *node)
|
||||
gsk_inset_shadow_node_get_outline (GskRenderNode *node)
|
||||
{
|
||||
const GskInsetShadowNode *self = (const GskInsetShadowNode *) node;
|
||||
GskInsetShadowNode *self = (GskInsetShadowNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_INSET_SHADOW_NODE), NULL);
|
||||
|
||||
return &self->outline;
|
||||
}
|
||||
@@ -2015,9 +2017,11 @@ gsk_inset_shadow_node_get_outline (const GskRenderNode *node)
|
||||
* Returns: (transfer none): the color of the shadow
|
||||
*/
|
||||
const GdkRGBA *
|
||||
gsk_inset_shadow_node_get_color (const GskRenderNode *node)
|
||||
gsk_inset_shadow_node_get_color (GskRenderNode *node)
|
||||
{
|
||||
const GskInsetShadowNode *self = (const GskInsetShadowNode *) node;
|
||||
GskInsetShadowNode *self = (GskInsetShadowNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_INSET_SHADOW_NODE), NULL);
|
||||
|
||||
return &self->color;
|
||||
}
|
||||
@@ -2031,9 +2035,11 @@ gsk_inset_shadow_node_get_color (const GskRenderNode *node)
|
||||
* Returns: an offset, in pixels
|
||||
*/
|
||||
float
|
||||
gsk_inset_shadow_node_get_dx (const GskRenderNode *node)
|
||||
gsk_inset_shadow_node_get_dx (GskRenderNode *node)
|
||||
{
|
||||
const GskInsetShadowNode *self = (const GskInsetShadowNode *) node;
|
||||
GskInsetShadowNode *self = (GskInsetShadowNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_INSET_SHADOW_NODE), 0.0f);
|
||||
|
||||
return self->dx;
|
||||
}
|
||||
@@ -2047,9 +2053,11 @@ gsk_inset_shadow_node_get_dx (const GskRenderNode *node)
|
||||
* Returns: an offset, in pixels
|
||||
*/
|
||||
float
|
||||
gsk_inset_shadow_node_get_dy (const GskRenderNode *node)
|
||||
gsk_inset_shadow_node_get_dy (GskRenderNode *node)
|
||||
{
|
||||
const GskInsetShadowNode *self = (const GskInsetShadowNode *) node;
|
||||
GskInsetShadowNode *self = (GskInsetShadowNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_INSET_SHADOW_NODE), 0.0f);
|
||||
|
||||
return self->dy;
|
||||
}
|
||||
@@ -2063,9 +2071,11 @@ gsk_inset_shadow_node_get_dy (const GskRenderNode *node)
|
||||
* Returns: the size of the shadow, in pixels
|
||||
*/
|
||||
float
|
||||
gsk_inset_shadow_node_get_spread (const GskRenderNode *node)
|
||||
gsk_inset_shadow_node_get_spread (GskRenderNode *node)
|
||||
{
|
||||
const GskInsetShadowNode *self = (const GskInsetShadowNode *) node;
|
||||
GskInsetShadowNode *self = (GskInsetShadowNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_INSET_SHADOW_NODE), 0.0f);
|
||||
|
||||
return self->spread;
|
||||
}
|
||||
@@ -2079,9 +2089,11 @@ gsk_inset_shadow_node_get_spread (const GskRenderNode *node)
|
||||
* Returns: the blur radius, in pixels
|
||||
*/
|
||||
float
|
||||
gsk_inset_shadow_node_get_blur_radius (const GskRenderNode *node)
|
||||
gsk_inset_shadow_node_get_blur_radius (GskRenderNode *node)
|
||||
{
|
||||
const GskInsetShadowNode *self = (const GskInsetShadowNode *) node;
|
||||
GskInsetShadowNode *self = (GskInsetShadowNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_INSET_SHADOW_NODE), 0.0f);
|
||||
|
||||
return self->blur_radius;
|
||||
}
|
||||
@@ -2301,9 +2313,11 @@ gsk_outset_shadow_node_new (const GskRoundedRect *outline,
|
||||
* Returns: (transfer none): a rounded rectangle
|
||||
*/
|
||||
const GskRoundedRect *
|
||||
gsk_outset_shadow_node_get_outline (const GskRenderNode *node)
|
||||
gsk_outset_shadow_node_get_outline (GskRenderNode *node)
|
||||
{
|
||||
const GskOutsetShadowNode *self = (const GskOutsetShadowNode *) node;
|
||||
GskOutsetShadowNode *self = (GskOutsetShadowNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_OUTSET_SHADOW_NODE), NULL);
|
||||
|
||||
return &self->outline;
|
||||
}
|
||||
@@ -2317,9 +2331,11 @@ gsk_outset_shadow_node_get_outline (const GskRenderNode *node)
|
||||
* Returns: (transfer none): a color
|
||||
*/
|
||||
const GdkRGBA *
|
||||
gsk_outset_shadow_node_get_color (const GskRenderNode *node)
|
||||
gsk_outset_shadow_node_get_color (GskRenderNode *node)
|
||||
{
|
||||
const GskOutsetShadowNode *self = (const GskOutsetShadowNode *) node;
|
||||
GskOutsetShadowNode *self = (GskOutsetShadowNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_OUTSET_SHADOW_NODE), NULL);
|
||||
|
||||
return &self->color;
|
||||
}
|
||||
@@ -2333,9 +2349,11 @@ gsk_outset_shadow_node_get_color (const GskRenderNode *node)
|
||||
* Returns: an offset, in pixels
|
||||
*/
|
||||
float
|
||||
gsk_outset_shadow_node_get_dx (const GskRenderNode *node)
|
||||
gsk_outset_shadow_node_get_dx (GskRenderNode *node)
|
||||
{
|
||||
const GskOutsetShadowNode *self = (const GskOutsetShadowNode *) node;
|
||||
GskOutsetShadowNode *self = (GskOutsetShadowNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_OUTSET_SHADOW_NODE), 0.0f);
|
||||
|
||||
return self->dx;
|
||||
}
|
||||
@@ -2349,9 +2367,11 @@ gsk_outset_shadow_node_get_dx (const GskRenderNode *node)
|
||||
* Returns: an offset, in pixels
|
||||
*/
|
||||
float
|
||||
gsk_outset_shadow_node_get_dy (const GskRenderNode *node)
|
||||
gsk_outset_shadow_node_get_dy (GskRenderNode *node)
|
||||
{
|
||||
const GskOutsetShadowNode *self = (const GskOutsetShadowNode *) node;
|
||||
GskOutsetShadowNode *self = (GskOutsetShadowNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_OUTSET_SHADOW_NODE), 0.0f);
|
||||
|
||||
return self->dy;
|
||||
}
|
||||
@@ -2365,9 +2385,11 @@ gsk_outset_shadow_node_get_dy (const GskRenderNode *node)
|
||||
* Returns: the size of the shadow, in pixels
|
||||
*/
|
||||
float
|
||||
gsk_outset_shadow_node_get_spread (const GskRenderNode *node)
|
||||
gsk_outset_shadow_node_get_spread (GskRenderNode *node)
|
||||
{
|
||||
const GskOutsetShadowNode *self = (const GskOutsetShadowNode *) node;
|
||||
GskOutsetShadowNode *self = (GskOutsetShadowNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_OUTSET_SHADOW_NODE), 0.0f);
|
||||
|
||||
return self->spread;
|
||||
}
|
||||
@@ -2381,9 +2403,11 @@ gsk_outset_shadow_node_get_spread (const GskRenderNode *node)
|
||||
* Returns: the blur radius, in pixels
|
||||
*/
|
||||
float
|
||||
gsk_outset_shadow_node_get_blur_radius (const GskRenderNode *node)
|
||||
gsk_outset_shadow_node_get_blur_radius (GskRenderNode *node)
|
||||
{
|
||||
const GskOutsetShadowNode *self = (const GskOutsetShadowNode *) node;
|
||||
GskOutsetShadowNode *self = (GskOutsetShadowNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_OUTSET_SHADOW_NODE), 0.0f);
|
||||
|
||||
return self->blur_radius;
|
||||
}
|
||||
@@ -2686,9 +2710,11 @@ gsk_container_node_new (GskRenderNode **children,
|
||||
* Returns: the number of children of the #GskRenderNode
|
||||
*/
|
||||
guint
|
||||
gsk_container_node_get_n_children (const GskRenderNode *node)
|
||||
gsk_container_node_get_n_children (GskRenderNode *node)
|
||||
{
|
||||
const GskContainerNode *self = (const GskContainerNode *) node;
|
||||
GskContainerNode *self = (GskContainerNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_CONTAINER_NODE), 0);
|
||||
|
||||
return self->n_children;
|
||||
}
|
||||
@@ -2703,13 +2729,13 @@ gsk_container_node_get_n_children (const GskRenderNode *node)
|
||||
* Returns: (transfer none): the @idx'th child of @container
|
||||
*/
|
||||
GskRenderNode *
|
||||
gsk_container_node_get_child (const GskRenderNode *node,
|
||||
guint idx)
|
||||
gsk_container_node_get_child (GskRenderNode *node,
|
||||
guint idx)
|
||||
{
|
||||
const GskContainerNode *self = (const GskContainerNode *) node;
|
||||
GskContainerNode *self = (GskContainerNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_CONTAINER_NODE), NULL);
|
||||
g_return_val_if_fail (idx < self->n_children, NULL);
|
||||
g_return_val_if_fail (idx < self->n_children, 0);
|
||||
|
||||
return self->children[idx];
|
||||
}
|
||||
@@ -2895,9 +2921,11 @@ gsk_transform_node_new (GskRenderNode *child,
|
||||
* Returns: (transfer none): The child that is getting transformed
|
||||
*/
|
||||
GskRenderNode *
|
||||
gsk_transform_node_get_child (const GskRenderNode *node)
|
||||
gsk_transform_node_get_child (GskRenderNode *node)
|
||||
{
|
||||
const GskTransformNode *self = (const GskTransformNode *) node;
|
||||
GskTransformNode *self = (GskTransformNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_TRANSFORM_NODE), NULL);
|
||||
|
||||
return self->child;
|
||||
}
|
||||
@@ -2911,9 +2939,11 @@ gsk_transform_node_get_child (const GskRenderNode *node)
|
||||
* Returns: (transfer none): a #GskTransform
|
||||
*/
|
||||
GskTransform *
|
||||
gsk_transform_node_get_transform (const GskRenderNode *node)
|
||||
gsk_transform_node_get_transform (GskRenderNode *node)
|
||||
{
|
||||
const GskTransformNode *self = (const GskTransformNode *) node;
|
||||
GskTransformNode *self = (GskTransformNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_TRANSFORM_NODE), NULL);
|
||||
|
||||
return self->transform;
|
||||
}
|
||||
@@ -3019,9 +3049,11 @@ gsk_opacity_node_new (GskRenderNode *child,
|
||||
* Returns: (transfer none): The child that is getting opacityed
|
||||
*/
|
||||
GskRenderNode *
|
||||
gsk_opacity_node_get_child (const GskRenderNode *node)
|
||||
gsk_opacity_node_get_child (GskRenderNode *node)
|
||||
{
|
||||
const GskOpacityNode *self = (const GskOpacityNode *) node;
|
||||
GskOpacityNode *self = (GskOpacityNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_OPACITY_NODE), NULL);
|
||||
|
||||
return self->child;
|
||||
}
|
||||
@@ -3035,9 +3067,11 @@ gsk_opacity_node_get_child (const GskRenderNode *node)
|
||||
* Returns: the opacity factor
|
||||
*/
|
||||
float
|
||||
gsk_opacity_node_get_opacity (const GskRenderNode *node)
|
||||
gsk_opacity_node_get_opacity (GskRenderNode *node)
|
||||
{
|
||||
const GskOpacityNode *self = (const GskOpacityNode *) node;
|
||||
GskOpacityNode *self = (GskOpacityNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_OPACITY_NODE), 1.0);
|
||||
|
||||
return self->opacity;
|
||||
}
|
||||
@@ -3223,9 +3257,11 @@ gsk_color_matrix_node_new (GskRenderNode *child,
|
||||
* Returns: (transfer none): The child that is getting its colors modified
|
||||
**/
|
||||
GskRenderNode *
|
||||
gsk_color_matrix_node_get_child (const GskRenderNode *node)
|
||||
gsk_color_matrix_node_get_child (GskRenderNode *node)
|
||||
{
|
||||
const GskColorMatrixNode *self = (const GskColorMatrixNode *) node;
|
||||
GskColorMatrixNode *self = (GskColorMatrixNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_COLOR_MATRIX_NODE), NULL);
|
||||
|
||||
return self->child;
|
||||
}
|
||||
@@ -3239,9 +3275,11 @@ gsk_color_matrix_node_get_child (const GskRenderNode *node)
|
||||
* Returns: a 4x4 color matrix
|
||||
*/
|
||||
const graphene_matrix_t *
|
||||
gsk_color_matrix_node_get_color_matrix (const GskRenderNode *node)
|
||||
gsk_color_matrix_node_get_color_matrix (GskRenderNode *node)
|
||||
{
|
||||
const GskColorMatrixNode *self = (const GskColorMatrixNode *) node;
|
||||
GskColorMatrixNode *self = (GskColorMatrixNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_COLOR_MATRIX_NODE), NULL);
|
||||
|
||||
return &self->color_matrix;
|
||||
}
|
||||
@@ -3255,9 +3293,11 @@ gsk_color_matrix_node_get_color_matrix (const GskRenderNode *node)
|
||||
* Returns: a color vector
|
||||
*/
|
||||
const graphene_vec4_t *
|
||||
gsk_color_matrix_node_get_color_offset (const GskRenderNode *node)
|
||||
gsk_color_matrix_node_get_color_offset (GskRenderNode *node)
|
||||
{
|
||||
const GskColorMatrixNode *self = (const GskColorMatrixNode *) node;
|
||||
GskColorMatrixNode *self = (GskColorMatrixNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_COLOR_MATRIX_NODE), NULL);
|
||||
|
||||
return &self->color_offset;
|
||||
}
|
||||
@@ -3372,9 +3412,11 @@ gsk_repeat_node_new (const graphene_rect_t *bounds,
|
||||
* Returns: (transfer none): a #GskRenderNode
|
||||
*/
|
||||
GskRenderNode *
|
||||
gsk_repeat_node_get_child (const GskRenderNode *node)
|
||||
gsk_repeat_node_get_child (GskRenderNode *node)
|
||||
{
|
||||
const GskRepeatNode *self = (const GskRepeatNode *) node;
|
||||
GskRepeatNode *self = (GskRepeatNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_REPEAT_NODE), NULL);
|
||||
|
||||
return self->child;
|
||||
}
|
||||
@@ -3388,9 +3430,11 @@ gsk_repeat_node_get_child (const GskRenderNode *node)
|
||||
* Returns: (transfer none): a bounding rectangle
|
||||
*/
|
||||
const graphene_rect_t *
|
||||
gsk_repeat_node_get_child_bounds (const GskRenderNode *node)
|
||||
gsk_repeat_node_get_child_bounds (GskRenderNode *node)
|
||||
{
|
||||
const GskRepeatNode *self = (const GskRepeatNode *) node;
|
||||
GskRepeatNode *self = (GskRepeatNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_REPEAT_NODE), NULL);
|
||||
|
||||
return &self->child_bounds;
|
||||
}
|
||||
@@ -3503,9 +3547,11 @@ gsk_clip_node_new (GskRenderNode *child,
|
||||
* Returns: (transfer none): The child that is getting clipped
|
||||
**/
|
||||
GskRenderNode *
|
||||
gsk_clip_node_get_child (const GskRenderNode *node)
|
||||
gsk_clip_node_get_child (GskRenderNode *node)
|
||||
{
|
||||
const GskClipNode *self = (const GskClipNode *) node;
|
||||
GskClipNode *self = (GskClipNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_CLIP_NODE), NULL);
|
||||
|
||||
return self->child;
|
||||
}
|
||||
@@ -3519,9 +3565,11 @@ gsk_clip_node_get_child (const GskRenderNode *node)
|
||||
* Returns: a clip rectangle
|
||||
*/
|
||||
const graphene_rect_t *
|
||||
gsk_clip_node_get_clip (const GskRenderNode *node)
|
||||
gsk_clip_node_get_clip (GskRenderNode *node)
|
||||
{
|
||||
const GskClipNode *self = (const GskClipNode *) node;
|
||||
GskClipNode *self = (GskClipNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_CLIP_NODE), NULL);
|
||||
|
||||
return &self->clip;
|
||||
}
|
||||
@@ -3634,9 +3682,11 @@ gsk_rounded_clip_node_new (GskRenderNode *child,
|
||||
* Returns: (transfer none): The child that is getting clipped
|
||||
**/
|
||||
GskRenderNode *
|
||||
gsk_rounded_clip_node_get_child (const GskRenderNode *node)
|
||||
gsk_rounded_clip_node_get_child (GskRenderNode *node)
|
||||
{
|
||||
const GskRoundedClipNode *self = (const GskRoundedClipNode *) node;
|
||||
GskRoundedClipNode *self = (GskRoundedClipNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_ROUNDED_CLIP_NODE), NULL);
|
||||
|
||||
return self->child;
|
||||
}
|
||||
@@ -3650,9 +3700,11 @@ gsk_rounded_clip_node_get_child (const GskRenderNode *node)
|
||||
* Returns: (transfer none): a rounded rectangle
|
||||
*/
|
||||
const GskRoundedRect *
|
||||
gsk_rounded_clip_node_get_clip (const GskRenderNode *node)
|
||||
gsk_rounded_clip_node_get_clip (GskRenderNode *node)
|
||||
{
|
||||
const GskRoundedClipNode *self = (const GskRoundedClipNode *) node;
|
||||
GskRoundedClipNode *self = (GskRoundedClipNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_ROUNDED_CLIP_NODE), NULL);
|
||||
|
||||
return &self->clip;
|
||||
}
|
||||
@@ -3853,9 +3905,11 @@ gsk_shadow_node_new (GskRenderNode *child,
|
||||
* Returns: (transfer none): the child render node
|
||||
*/
|
||||
GskRenderNode *
|
||||
gsk_shadow_node_get_child (const GskRenderNode *node)
|
||||
gsk_shadow_node_get_child (GskRenderNode *node)
|
||||
{
|
||||
const GskShadowNode *self = (const GskShadowNode *) node;
|
||||
GskShadowNode *self = (GskShadowNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_SHADOW_NODE), NULL);
|
||||
|
||||
return self->child;
|
||||
}
|
||||
@@ -3870,10 +3924,13 @@ gsk_shadow_node_get_child (const GskRenderNode *node)
|
||||
* Returns: (transfer none): the shadow data
|
||||
*/
|
||||
const GskShadow *
|
||||
gsk_shadow_node_get_shadow (const GskRenderNode *node,
|
||||
gsize i)
|
||||
gsk_shadow_node_get_shadow (GskRenderNode *node,
|
||||
gsize i)
|
||||
{
|
||||
const GskShadowNode *self = (const GskShadowNode *) node;
|
||||
GskShadowNode *self = (GskShadowNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_SHADOW_NODE), NULL);
|
||||
g_return_val_if_fail (i < self->n_shadows, NULL);
|
||||
|
||||
return &self->shadows[i];
|
||||
}
|
||||
@@ -3887,9 +3944,11 @@ gsk_shadow_node_get_shadow (const GskRenderNode *node,
|
||||
* Returns: the number of shadows.
|
||||
*/
|
||||
gsize
|
||||
gsk_shadow_node_get_n_shadows (const GskRenderNode *node)
|
||||
gsk_shadow_node_get_n_shadows (GskRenderNode *node)
|
||||
{
|
||||
const GskShadowNode *self = (const GskShadowNode *) node;
|
||||
GskShadowNode *self = (GskShadowNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_SHADOW_NODE), 0);
|
||||
|
||||
return self->n_shadows;
|
||||
}
|
||||
@@ -4046,9 +4105,11 @@ gsk_blend_node_new (GskRenderNode *bottom,
|
||||
* Returns: (transfer none): the bottom child node
|
||||
*/
|
||||
GskRenderNode *
|
||||
gsk_blend_node_get_bottom_child (const GskRenderNode *node)
|
||||
gsk_blend_node_get_bottom_child (GskRenderNode *node)
|
||||
{
|
||||
const GskBlendNode *self = (const GskBlendNode *) node;
|
||||
GskBlendNode *self = (GskBlendNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_BLEND_NODE), NULL);
|
||||
|
||||
return self->bottom;
|
||||
}
|
||||
@@ -4062,9 +4123,11 @@ gsk_blend_node_get_bottom_child (const GskRenderNode *node)
|
||||
* Returns: (transfer none): the top child node
|
||||
*/
|
||||
GskRenderNode *
|
||||
gsk_blend_node_get_top_child (const GskRenderNode *node)
|
||||
gsk_blend_node_get_top_child (GskRenderNode *node)
|
||||
{
|
||||
const GskBlendNode *self = (const GskBlendNode *) node;
|
||||
GskBlendNode *self = (GskBlendNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_BLEND_NODE), NULL);
|
||||
|
||||
return self->top;
|
||||
}
|
||||
@@ -4078,9 +4141,11 @@ gsk_blend_node_get_top_child (const GskRenderNode *node)
|
||||
* Returns: the blend mode
|
||||
*/
|
||||
GskBlendMode
|
||||
gsk_blend_node_get_blend_mode (const GskRenderNode *node)
|
||||
gsk_blend_node_get_blend_mode (GskRenderNode *node)
|
||||
{
|
||||
const GskBlendNode *self = (const GskBlendNode *) node;
|
||||
GskBlendNode *self = (GskBlendNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_BLEND_NODE), GSK_BLEND_MODE_DEFAULT);
|
||||
|
||||
return self->blend_mode;
|
||||
}
|
||||
@@ -4194,9 +4259,11 @@ gsk_cross_fade_node_new (GskRenderNode *start,
|
||||
* Returns: (transfer none): a #GskRenderNode
|
||||
*/
|
||||
GskRenderNode *
|
||||
gsk_cross_fade_node_get_start_child (const GskRenderNode *node)
|
||||
gsk_cross_fade_node_get_start_child (GskRenderNode *node)
|
||||
{
|
||||
const GskCrossFadeNode *self = (const GskCrossFadeNode *) node;
|
||||
GskCrossFadeNode *self = (GskCrossFadeNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_CROSS_FADE_NODE), NULL);
|
||||
|
||||
return self->start;
|
||||
}
|
||||
@@ -4210,9 +4277,11 @@ gsk_cross_fade_node_get_start_child (const GskRenderNode *node)
|
||||
* Returns: (transfer none): a #GskRenderNode
|
||||
*/
|
||||
GskRenderNode *
|
||||
gsk_cross_fade_node_get_end_child (const GskRenderNode *node)
|
||||
gsk_cross_fade_node_get_end_child (GskRenderNode *node)
|
||||
{
|
||||
const GskCrossFadeNode *self = (const GskCrossFadeNode *) node;
|
||||
GskCrossFadeNode *self = (GskCrossFadeNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_CROSS_FADE_NODE), NULL);
|
||||
|
||||
return self->end;
|
||||
}
|
||||
@@ -4226,9 +4295,11 @@ gsk_cross_fade_node_get_end_child (const GskRenderNode *node)
|
||||
* Returns: the progress value, between 0 and 1
|
||||
*/
|
||||
float
|
||||
gsk_cross_fade_node_get_progress (const GskRenderNode *node)
|
||||
gsk_cross_fade_node_get_progress (GskRenderNode *node)
|
||||
{
|
||||
const GskCrossFadeNode *self = (const GskCrossFadeNode *) node;
|
||||
GskCrossFadeNode *self = (GskCrossFadeNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_CROSS_FADE_NODE), 0.0);
|
||||
|
||||
return self->progress;
|
||||
}
|
||||
@@ -4399,9 +4470,11 @@ gsk_text_node_new (PangoFont *font,
|
||||
* Returns: (transfer none): the text color
|
||||
*/
|
||||
const GdkRGBA *
|
||||
gsk_text_node_get_color (const GskRenderNode *node)
|
||||
gsk_text_node_get_color (GskRenderNode *node)
|
||||
{
|
||||
const GskTextNode *self = (const GskTextNode *) node;
|
||||
GskTextNode *self = (GskTextNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_TEXT_NODE), NULL);
|
||||
|
||||
return &self->color;
|
||||
}
|
||||
@@ -4415,9 +4488,11 @@ gsk_text_node_get_color (const GskRenderNode *node)
|
||||
* Returns: (transfer none): the font
|
||||
*/
|
||||
PangoFont *
|
||||
gsk_text_node_get_font (const GskRenderNode *node)
|
||||
gsk_text_node_get_font (GskRenderNode *node)
|
||||
{
|
||||
const GskTextNode *self = (const GskTextNode *) node;
|
||||
GskTextNode *self = (GskTextNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_TEXT_NODE), NULL);
|
||||
|
||||
return self->font;
|
||||
}
|
||||
@@ -4431,9 +4506,11 @@ gsk_text_node_get_font (const GskRenderNode *node)
|
||||
* Returns: %TRUE if the text node has color glyphs
|
||||
*/
|
||||
gboolean
|
||||
gsk_text_node_has_color_glyphs (const GskRenderNode *node)
|
||||
gsk_text_node_has_color_glyphs (GskRenderNode *node)
|
||||
{
|
||||
const GskTextNode *self = (const GskTextNode *) node;
|
||||
GskTextNode *self = (GskTextNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_TEXT_NODE), FALSE);
|
||||
|
||||
return self->has_color_glyphs;
|
||||
}
|
||||
@@ -4447,9 +4524,11 @@ gsk_text_node_has_color_glyphs (const GskRenderNode *node)
|
||||
* Returns: the number of glyphs
|
||||
*/
|
||||
guint
|
||||
gsk_text_node_get_num_glyphs (const GskRenderNode *node)
|
||||
gsk_text_node_get_num_glyphs (GskRenderNode *node)
|
||||
{
|
||||
const GskTextNode *self = (const GskTextNode *) node;
|
||||
GskTextNode *self = (GskTextNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_TEXT_NODE), 0);
|
||||
|
||||
return self->num_glyphs;
|
||||
}
|
||||
@@ -4464,10 +4543,12 @@ gsk_text_node_get_num_glyphs (const GskRenderNode *node)
|
||||
* Returns: (transfer none) (array length=n_glyphs): the glyph information
|
||||
*/
|
||||
const PangoGlyphInfo *
|
||||
gsk_text_node_get_glyphs (const GskRenderNode *node,
|
||||
guint *n_glyphs)
|
||||
gsk_text_node_get_glyphs (GskRenderNode *node,
|
||||
guint *n_glyphs)
|
||||
{
|
||||
const GskTextNode *self = (const GskTextNode *) node;
|
||||
GskTextNode *self = (GskTextNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_TEXT_NODE), NULL);
|
||||
|
||||
if (n_glyphs != NULL)
|
||||
*n_glyphs = self->num_glyphs;
|
||||
@@ -4484,9 +4565,11 @@ gsk_text_node_get_glyphs (const GskRenderNode *node,
|
||||
* Returns: (transfer none): a point with the horizontal and vertical offsets
|
||||
*/
|
||||
const graphene_point_t *
|
||||
gsk_text_node_get_offset (const GskRenderNode *node)
|
||||
gsk_text_node_get_offset (GskRenderNode *node)
|
||||
{
|
||||
const GskTextNode *self = (const GskTextNode *) node;
|
||||
GskTextNode *self = (GskTextNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_TEXT_NODE), NULL);
|
||||
|
||||
return &self->offset;
|
||||
}
|
||||
@@ -4781,9 +4864,11 @@ gsk_blur_node_new (GskRenderNode *child,
|
||||
* Returns: (transfer none): the blurred child node
|
||||
*/
|
||||
GskRenderNode *
|
||||
gsk_blur_node_get_child (const GskRenderNode *node)
|
||||
gsk_blur_node_get_child (GskRenderNode *node)
|
||||
{
|
||||
const GskBlurNode *self = (const GskBlurNode *) node;
|
||||
GskBlurNode *self = (GskBlurNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_BLUR_NODE), NULL);
|
||||
|
||||
return self->child;
|
||||
}
|
||||
@@ -4797,9 +4882,11 @@ gsk_blur_node_get_child (const GskRenderNode *node)
|
||||
* Returns: the blur radius
|
||||
*/
|
||||
float
|
||||
gsk_blur_node_get_radius (const GskRenderNode *node)
|
||||
gsk_blur_node_get_radius (GskRenderNode *node)
|
||||
{
|
||||
const GskBlurNode *self = (const GskBlurNode *) node;
|
||||
GskBlurNode *self = (GskBlurNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_BLUR_NODE), 0.0);
|
||||
|
||||
return self->radius;
|
||||
}
|
||||
@@ -4903,9 +4990,11 @@ gsk_debug_node_new (GskRenderNode *child,
|
||||
* Returns: (transfer none): the child #GskRenderNode
|
||||
**/
|
||||
GskRenderNode *
|
||||
gsk_debug_node_get_child (const GskRenderNode *node)
|
||||
gsk_debug_node_get_child (GskRenderNode *node)
|
||||
{
|
||||
const GskDebugNode *self = (const GskDebugNode *) node;
|
||||
GskDebugNode *self = (GskDebugNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_DEBUG_NODE), NULL);
|
||||
|
||||
return self->child;
|
||||
}
|
||||
@@ -4919,9 +5008,11 @@ gsk_debug_node_get_child (const GskRenderNode *node)
|
||||
* Returns: (transfer none): The debug message
|
||||
**/
|
||||
const char *
|
||||
gsk_debug_node_get_message (const GskRenderNode *node)
|
||||
gsk_debug_node_get_message (GskRenderNode *node)
|
||||
{
|
||||
const GskDebugNode *self = (const GskDebugNode *) node;
|
||||
GskDebugNode *self = (GskDebugNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_DEBUG_NODE), "You run broken code!");
|
||||
|
||||
return self->message;
|
||||
}
|
||||
@@ -5068,9 +5159,11 @@ gsk_gl_shader_node_new (GskGLShader *shader,
|
||||
* Returns: The number of children
|
||||
*/
|
||||
guint
|
||||
gsk_gl_shader_node_get_n_children (const GskRenderNode *node)
|
||||
gsk_gl_shader_node_get_n_children (GskRenderNode *node)
|
||||
{
|
||||
const GskGLShaderNode *self = (const GskGLShaderNode *) node;
|
||||
GskGLShaderNode *self = (GskGLShaderNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_GL_SHADER_NODE), 0);
|
||||
|
||||
return self->n_children;
|
||||
}
|
||||
@@ -5085,10 +5178,13 @@ gsk_gl_shader_node_get_n_children (const GskRenderNode *node)
|
||||
* Returns: (transfer none): the @idx'th child of @node
|
||||
*/
|
||||
GskRenderNode *
|
||||
gsk_gl_shader_node_get_child (const GskRenderNode *node,
|
||||
guint idx)
|
||||
gsk_gl_shader_node_get_child (GskRenderNode *node,
|
||||
guint idx)
|
||||
{
|
||||
const GskGLShaderNode *self = (const GskGLShaderNode *) node;
|
||||
GskGLShaderNode *self = (GskGLShaderNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_GL_SHADER_NODE), NULL);
|
||||
g_return_val_if_fail (idx < self->n_children, NULL);
|
||||
|
||||
return self->children[idx];
|
||||
}
|
||||
@@ -5102,9 +5198,11 @@ gsk_gl_shader_node_get_child (const GskRenderNode *node,
|
||||
* Returns: (transfer none): the #GskGLShader shader
|
||||
*/
|
||||
GskGLShader *
|
||||
gsk_gl_shader_node_get_shader (const GskRenderNode *node)
|
||||
gsk_gl_shader_node_get_shader (GskRenderNode *node)
|
||||
{
|
||||
const GskGLShaderNode *self = (const GskGLShaderNode *) node;
|
||||
GskGLShaderNode *self = (GskGLShaderNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_GL_SHADER_NODE), 0);
|
||||
|
||||
return self->shader;
|
||||
}
|
||||
@@ -5118,9 +5216,11 @@ gsk_gl_shader_node_get_shader (const GskRenderNode *node)
|
||||
* Returns: (transfer none): A #GBytes with the uniform arguments
|
||||
*/
|
||||
GBytes *
|
||||
gsk_gl_shader_node_get_args (const GskRenderNode *node)
|
||||
gsk_gl_shader_node_get_args (GskRenderNode *node)
|
||||
{
|
||||
const GskGLShaderNode *self = (const GskGLShaderNode *) node;
|
||||
GskGLShaderNode *self = (GskGLShaderNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_GL_SHADER_NODE), NULL);
|
||||
|
||||
return self->args;
|
||||
}
|
||||
|
||||
@@ -1394,7 +1394,7 @@ parse_cairo_node (GtkCssParser *parser)
|
||||
if (surface != NULL)
|
||||
{
|
||||
cairo_t *cr = gsk_cairo_node_get_draw_context (node);
|
||||
cairo_set_source_surface (cr, surface, 0, 0);
|
||||
cairo_set_source_surface (cr, surface, bounds.origin.x, bounds.origin.y);
|
||||
cairo_paint (cr);
|
||||
cairo_destroy (cr);
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ void gsk_render_node_diff_impossible (GskRenderNode
|
||||
GskRenderNode *node2,
|
||||
cairo_region_t *region);
|
||||
|
||||
bool gsk_border_node_get_uniform (const GskRenderNode *self);
|
||||
bool gsk_border_node_get_uniform (GskRenderNode *self);
|
||||
|
||||
void gsk_text_node_serialize_glyphs (GskRenderNode *self,
|
||||
GString *str);
|
||||
|
||||
+11
-1
@@ -37,6 +37,16 @@
|
||||
|
||||
#include "gsktransformprivate.h"
|
||||
|
||||
typedef struct _GskTransformClass GskTransformClass;
|
||||
|
||||
struct _GskTransform
|
||||
{
|
||||
const GskTransformClass *transform_class;
|
||||
|
||||
GskTransformCategory category;
|
||||
GskTransform *next;
|
||||
};
|
||||
|
||||
struct _GskTransformClass
|
||||
{
|
||||
gsize struct_size;
|
||||
@@ -1737,7 +1747,7 @@ gsk_transform_equal (GskTransform *first,
|
||||
* Returns: The category of the transform
|
||||
**/
|
||||
GskTransformCategory
|
||||
(gsk_transform_get_category) (GskTransform *self)
|
||||
gsk_transform_get_category (GskTransform *self)
|
||||
{
|
||||
if (self == NULL)
|
||||
return GSK_TRANSFORM_CATEGORY_IDENTITY;
|
||||
|
||||
@@ -28,15 +28,6 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GskTransformClass GskTransformClass;
|
||||
|
||||
struct _GskTransform
|
||||
{
|
||||
const GskTransformClass *transform_class;
|
||||
|
||||
GskTransformCategory category;
|
||||
GskTransform *next;
|
||||
};
|
||||
|
||||
gboolean gsk_transform_parser_parse (GtkCssParser *parser,
|
||||
GskTransform **out_transform);
|
||||
@@ -54,8 +45,6 @@ void gsk_matrix_transform_rect (const graphene_matrix_t *m,
|
||||
const graphene_rect_t *r,
|
||||
graphene_quad_t *res);
|
||||
|
||||
#define gsk_transform_get_category(t) ((t) ? (t)->category : GSK_TRANSFORM_CATEGORY_IDENTITY)
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GSK_TRANSFORM_PRIVATE_H__ */
|
||||
|
||||
+1
-16
@@ -31,7 +31,6 @@ gsk_public_sources = files([
|
||||
'gskroundedrect.c',
|
||||
'gsktransform.c',
|
||||
'gl/gskglrenderer.c',
|
||||
'ngl/gsknglrenderer.c',
|
||||
])
|
||||
|
||||
gsk_private_sources = files([
|
||||
@@ -49,19 +48,6 @@ gsk_private_sources = files([
|
||||
'gl/gskgliconcache.c',
|
||||
'gl/opbuffer.c',
|
||||
'gl/stb_rect_pack.c',
|
||||
'ngl/gsknglattachmentstate.c',
|
||||
'ngl/gsknglbuffer.c',
|
||||
'ngl/gsknglcommandqueue.c',
|
||||
'ngl/gsknglcompiler.c',
|
||||
'ngl/gskngldriver.c',
|
||||
'ngl/gsknglglyphlibrary.c',
|
||||
'ngl/gskngliconlibrary.c',
|
||||
'ngl/gsknglprogram.c',
|
||||
'ngl/gsknglrenderjob.c',
|
||||
'ngl/gsknglshadowlibrary.c',
|
||||
'ngl/gskngltexturelibrary.c',
|
||||
'ngl/gskngluniformstate.c',
|
||||
'ngl/gskngltexturepool.c',
|
||||
])
|
||||
|
||||
gsk_public_headers = files([
|
||||
@@ -78,8 +64,7 @@ gsk_public_headers = files([
|
||||
install_headers(gsk_public_headers, 'gsk.h', subdir: 'gtk-4.0/gsk')
|
||||
|
||||
gsk_public_gl_headers = files([
|
||||
'gl/gskglrenderer.h',
|
||||
'ngl/gsknglrenderer.h',
|
||||
'gl/gskglrenderer.h'
|
||||
])
|
||||
install_headers(gsk_public_gl_headers, subdir: 'gtk-4.0/gsk/gl')
|
||||
gsk_public_headers += gsk_public_gl_headers
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
/* gsknglattachmentstate.c
|
||||
*
|
||||
* Copyright 2020 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* This file 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 file 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 General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gsknglattachmentstateprivate.h"
|
||||
|
||||
GskNglAttachmentState *
|
||||
gsk_ngl_attachment_state_new (void)
|
||||
{
|
||||
GskNglAttachmentState *self;
|
||||
|
||||
self = g_atomic_rc_box_new0 (GskNglAttachmentState);
|
||||
|
||||
self->fbo.changed = FALSE;
|
||||
self->fbo.id = 0;
|
||||
self->n_changed = 0;
|
||||
|
||||
/* Initialize textures, assume we are 2D by default since it
|
||||
* doesn't really matter until we bind something other than
|
||||
* GL_TEXTURE0 to it anyway.
|
||||
*/
|
||||
for (guint i = 0; i < G_N_ELEMENTS (self->textures); i++)
|
||||
{
|
||||
self->textures[i].target = GL_TEXTURE_2D;
|
||||
self->textures[i].texture = GL_TEXTURE0;
|
||||
self->textures[i].id = 0;
|
||||
self->textures[i].changed = FALSE;
|
||||
self->textures[i].initial = TRUE;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
GskNglAttachmentState *
|
||||
gsk_ngl_attachment_state_ref (GskNglAttachmentState *self)
|
||||
{
|
||||
return g_atomic_rc_box_acquire (self);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_ngl_attachment_state_unref (GskNglAttachmentState *self)
|
||||
{
|
||||
g_atomic_rc_box_release (self);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_ngl_attachment_state_bind_texture (GskNglAttachmentState *self,
|
||||
GLenum target,
|
||||
GLenum texture,
|
||||
guint id)
|
||||
{
|
||||
GskNglBindTexture *attach;
|
||||
|
||||
g_assert (self != NULL);
|
||||
g_assert (target == GL_TEXTURE_1D ||
|
||||
target == GL_TEXTURE_2D ||
|
||||
target == GL_TEXTURE_3D);
|
||||
g_assert (texture >= GL_TEXTURE0 && texture <= GL_TEXTURE16);
|
||||
|
||||
attach = &self->textures[texture - GL_TEXTURE0];
|
||||
|
||||
if (attach->target != target || attach->texture != texture || attach->id != id)
|
||||
{
|
||||
attach->target = target;
|
||||
attach->texture = texture;
|
||||
attach->id = id;
|
||||
attach->initial = FALSE;
|
||||
|
||||
if (attach->changed == FALSE)
|
||||
{
|
||||
attach->changed = TRUE;
|
||||
self->n_changed++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gsk_ngl_attachment_state_bind_framebuffer (GskNglAttachmentState *self,
|
||||
guint id)
|
||||
{
|
||||
g_assert (self != NULL);
|
||||
|
||||
if (self->fbo.id != id)
|
||||
{
|
||||
self->fbo.id = id;
|
||||
self->fbo.changed = TRUE;
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/* gsknglattachmentstateprivate.h
|
||||
*
|
||||
* Copyright 2020 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* This file 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 file 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 General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#ifndef __GSK_NGL_ATTACHMENT_STATE_PRIVATE_H__
|
||||
#define __GSK_NGL_ATTACHMENT_STATE_PRIVATE_H__
|
||||
|
||||
#include "gskngltypesprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GskNglAttachmentState GskNglAttachmentState;
|
||||
typedef struct _GskNglBindFramebuffer GskNglBindFramebuffer;
|
||||
typedef struct _GskNglBindTexture GskNglBindTexture;
|
||||
|
||||
struct _GskNglBindTexture
|
||||
{
|
||||
guint changed : 1;
|
||||
guint initial : 1;
|
||||
GLenum target : 30;
|
||||
GLenum texture;
|
||||
guint id;
|
||||
};
|
||||
|
||||
G_STATIC_ASSERT (sizeof (GskNglBindTexture) == 12);
|
||||
|
||||
struct _GskNglBindFramebuffer
|
||||
{
|
||||
guint changed : 1;
|
||||
guint id : 31;
|
||||
};
|
||||
|
||||
G_STATIC_ASSERT (sizeof (GskNglBindFramebuffer) == 4);
|
||||
|
||||
struct _GskNglAttachmentState
|
||||
{
|
||||
GskNglBindFramebuffer fbo;
|
||||
/* Increase if shaders add more textures */
|
||||
GskNglBindTexture textures[4];
|
||||
guint n_changed;
|
||||
};
|
||||
|
||||
GskNglAttachmentState *gsk_ngl_attachment_state_new (void);
|
||||
GskNglAttachmentState *gsk_ngl_attachment_state_ref (GskNglAttachmentState *self);
|
||||
void gsk_ngl_attachment_state_unref (GskNglAttachmentState *self);
|
||||
void gsk_ngl_attachment_state_bind_texture (GskNglAttachmentState *self,
|
||||
GLenum target,
|
||||
GLenum texture,
|
||||
guint id);
|
||||
void gsk_ngl_attachment_state_bind_framebuffer (GskNglAttachmentState *self,
|
||||
guint id);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GSK_NGL_ATTACHMENT_STATE_PRIVATE_H__ */
|
||||
@@ -1,69 +0,0 @@
|
||||
/* gsknglbufferprivate.h
|
||||
*
|
||||
* Copyright 2020 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* This file 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 file 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 General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "gsknglbufferprivate.h"
|
||||
|
||||
/**
|
||||
* gsk_ngl_buffer_init:
|
||||
* @target: the target buffer such as %GL_ARRAY_BUFFER or %GL_UNIFORM_BUFFER
|
||||
* @element_size: the size of elements within the buffer
|
||||
*
|
||||
* Creates a new #GskNglBuffer which can be used to deliver data to shaders
|
||||
* within a GLSL program. You can use this to store vertices such as with
|
||||
* %GL_ARRAY_BUFFER or uniform data with %GL_UNIFORM_BUFFER.
|
||||
*/
|
||||
void
|
||||
gsk_ngl_buffer_init (GskNglBuffer *self,
|
||||
GLenum target,
|
||||
guint element_size)
|
||||
{
|
||||
memset (self, 0, sizeof *self);
|
||||
|
||||
/* Default to 2 pages, power-of-two growth from there */
|
||||
self->buffer_len = 4096 * 2;
|
||||
self->buffer = g_malloc (self->buffer_len);
|
||||
self->target = target;
|
||||
self->element_size = element_size;
|
||||
}
|
||||
|
||||
GLuint
|
||||
gsk_ngl_buffer_submit (GskNglBuffer *buffer)
|
||||
{
|
||||
GLuint id;
|
||||
|
||||
glGenBuffers (1, &id);
|
||||
glBindBuffer (buffer->target, id);
|
||||
glBufferData (buffer->target, buffer->buffer_pos, buffer->buffer, GL_STATIC_DRAW);
|
||||
|
||||
buffer->buffer_pos = 0;
|
||||
buffer->count = 0;
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
void
|
||||
gsk_ngl_buffer_destroy (GskNglBuffer *buffer)
|
||||
{
|
||||
g_clear_pointer (&buffer->buffer, g_free);
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
/* gsknglbufferprivate.h
|
||||
*
|
||||
* Copyright 2020 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* This file 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 file 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 General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#ifndef __GSK_NGL_BUFFER_PRIVATE_H__
|
||||
#define __GSK_NGL_BUFFER_PRIVATE_H__
|
||||
|
||||
#include "gskngltypesprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GskNglBuffer
|
||||
{
|
||||
guint8 *buffer;
|
||||
gsize buffer_pos;
|
||||
gsize buffer_len;
|
||||
guint count;
|
||||
GLenum target;
|
||||
guint element_size;
|
||||
} GskNglBuffer;
|
||||
|
||||
void gsk_ngl_buffer_init (GskNglBuffer *self,
|
||||
GLenum target,
|
||||
guint element_size);
|
||||
void gsk_ngl_buffer_destroy (GskNglBuffer *buffer);
|
||||
GLuint gsk_ngl_buffer_submit (GskNglBuffer *buffer);
|
||||
|
||||
static inline gpointer
|
||||
gsk_ngl_buffer_advance (GskNglBuffer *buffer,
|
||||
guint count)
|
||||
{
|
||||
gpointer ret;
|
||||
gsize to_alloc = count * buffer->element_size;
|
||||
|
||||
if G_UNLIKELY (buffer->buffer_pos + to_alloc > buffer->buffer_len)
|
||||
{
|
||||
buffer->buffer_len *= 2;
|
||||
buffer->buffer = g_realloc (buffer->buffer, buffer->buffer_len);
|
||||
}
|
||||
|
||||
ret = buffer->buffer + buffer->buffer_pos;
|
||||
|
||||
buffer->buffer_pos += to_alloc;
|
||||
buffer->count += count;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void
|
||||
gsk_ngl_buffer_retract (GskNglBuffer *buffer,
|
||||
guint count)
|
||||
{
|
||||
buffer->buffer_pos -= count * buffer->element_size;
|
||||
buffer->count -= count;
|
||||
}
|
||||
|
||||
static inline guint
|
||||
gsk_ngl_buffer_get_offset (GskNglBuffer *buffer)
|
||||
{
|
||||
return buffer->count;
|
||||
}
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GSK_NGL_BUFFER_PRIVATE_H__ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,362 +0,0 @@
|
||||
/* gsknglcommandqueueprivate.h
|
||||
*
|
||||
* Copyright 2020 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* 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 program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#ifndef __GSK_NGL_COMMAND_QUEUE_PRIVATE_H__
|
||||
#define __GSK_NGL_COMMAND_QUEUE_PRIVATE_H__
|
||||
|
||||
#include <gsk/gskprofilerprivate.h>
|
||||
|
||||
#include "gskngltypesprivate.h"
|
||||
#include "gsknglbufferprivate.h"
|
||||
#include "gsknglattachmentstateprivate.h"
|
||||
#include "gskngluniformstateprivate.h"
|
||||
|
||||
#include "inlinearray.h"
|
||||
|
||||
#include "../gl/gskglprofilerprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GSK_TYPE_GL_COMMAND_QUEUE (gsk_ngl_command_queue_get_type())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GskNglCommandQueue, gsk_ngl_command_queue, GSK, NGL_COMMAND_QUEUE, GObject)
|
||||
|
||||
typedef enum _GskNglCommandKind
|
||||
{
|
||||
/* The batch will perform a glClear() */
|
||||
GSK_NGL_COMMAND_KIND_CLEAR,
|
||||
|
||||
/* The batch will perform a glDrawArrays() */
|
||||
GSK_NGL_COMMAND_KIND_DRAW,
|
||||
} GskNglCommandKind;
|
||||
|
||||
typedef struct _GskNglCommandBind
|
||||
{
|
||||
/* @texture is the value passed to glActiveTexture(), the "slot" the
|
||||
* texture will be placed into. We always use GL_TEXTURE_2D so we don't
|
||||
* waste any bits here to indicate that.
|
||||
*/
|
||||
guint texture : 5;
|
||||
|
||||
/* The identifier for the texture created with glGenTextures(). */
|
||||
guint id : 27;
|
||||
} GskNglCommandBind;
|
||||
|
||||
G_STATIC_ASSERT (sizeof (GskNglCommandBind) == 4);
|
||||
|
||||
typedef struct _GskNglCommandBatchAny
|
||||
{
|
||||
/* A GskNglCommandKind indicating what the batch will do */
|
||||
guint kind : 8;
|
||||
|
||||
/* The program's identifier to use for determining if we can merge two
|
||||
* batches together into a single set of draw operations. We put this
|
||||
* here instead of the GskNglCommandDraw so that we can use the extra
|
||||
* bits here without making the structure larger.
|
||||
*/
|
||||
guint program : 24;
|
||||
|
||||
/* The index of the next batch following this one. This is used
|
||||
* as a sort of integer-based linked list to simplify out-of-order
|
||||
* batching without moving memory around. -1 indicates last batch.
|
||||
*/
|
||||
gint16 next_batch_index;
|
||||
|
||||
/* Same but for reverse direction as we sort in reverse to get the
|
||||
* batches ordered by framebuffer.
|
||||
*/
|
||||
gint16 prev_batch_index;
|
||||
|
||||
/* The viewport size of the batch. We check this as we process
|
||||
* batches to determine if we need to resize the viewport.
|
||||
*/
|
||||
struct {
|
||||
guint16 width;
|
||||
guint16 height;
|
||||
} viewport;
|
||||
} GskNglCommandBatchAny;
|
||||
|
||||
G_STATIC_ASSERT (sizeof (GskNglCommandBatchAny) == 12);
|
||||
|
||||
typedef struct _GskNglCommandDraw
|
||||
{
|
||||
GskNglCommandBatchAny head;
|
||||
|
||||
/* There doesn't seem to be a limit on the framebuffer identifier that
|
||||
* can be returned, so we have to use a whole unsigned for the framebuffer
|
||||
* we are drawing to. When processing batches, we check to see if this
|
||||
* changes and adjust the render target accordingly. Some sorting is
|
||||
* performed to reduce the amount we change framebuffers.
|
||||
*/
|
||||
guint framebuffer;
|
||||
|
||||
/* The number of uniforms to change. This must be less than or equal to
|
||||
* GL_MAX_UNIFORM_LOCATIONS but only guaranteed up to 1024 by any OpenGL
|
||||
* implementation to be conformant.
|
||||
*/
|
||||
guint uniform_count : 11;
|
||||
|
||||
/* The number of textures to bind, which is only guaranteed up to 16
|
||||
* by the OpenGL specification to be conformant.
|
||||
*/
|
||||
guint bind_count : 5;
|
||||
|
||||
/* GL_MAX_ELEMENTS_VERTICES specifies 33000 for this which requires 16-bit
|
||||
* to address all possible counts <= GL_MAX_ELEMENTS_VERTICES.
|
||||
*/
|
||||
guint vbo_count : 16;
|
||||
|
||||
/* The offset within the VBO containing @vbo_count vertices to send with
|
||||
* glDrawArrays().
|
||||
*/
|
||||
guint vbo_offset;
|
||||
|
||||
/* The offset within the array of uniform changes to be made containing
|
||||
* @uniform_count #GskNglCommandUniform elements to apply.
|
||||
*/
|
||||
guint uniform_offset;
|
||||
|
||||
/* The offset within the array of bind changes to be made containing
|
||||
* @bind_count #GskNglCommandBind elements to apply.
|
||||
*/
|
||||
guint bind_offset;
|
||||
} GskNglCommandDraw;
|
||||
|
||||
G_STATIC_ASSERT (sizeof (GskNglCommandDraw) == 32);
|
||||
|
||||
typedef struct _GskNglCommandClear
|
||||
{
|
||||
GskNglCommandBatchAny any;
|
||||
guint bits;
|
||||
guint framebuffer;
|
||||
} GskNglCommandClear;
|
||||
|
||||
G_STATIC_ASSERT (sizeof (GskNglCommandClear) == 20);
|
||||
|
||||
typedef struct _GskNglCommandUniform
|
||||
{
|
||||
GskNglUniformInfo info;
|
||||
guint location;
|
||||
} GskNglCommandUniform;
|
||||
|
||||
G_STATIC_ASSERT (sizeof (GskNglCommandUniform) == 8);
|
||||
|
||||
typedef union _GskNglCommandBatch
|
||||
{
|
||||
GskNglCommandBatchAny any;
|
||||
GskNglCommandDraw draw;
|
||||
GskNglCommandClear clear;
|
||||
} GskNglCommandBatch;
|
||||
|
||||
G_STATIC_ASSERT (sizeof (GskNglCommandBatch) == 32);
|
||||
|
||||
DEFINE_INLINE_ARRAY (GskNglCommandBatches, gsk_ngl_command_batches, GskNglCommandBatch)
|
||||
DEFINE_INLINE_ARRAY (GskNglCommandBinds, gsk_ngl_command_binds, GskNglCommandBind)
|
||||
DEFINE_INLINE_ARRAY (GskNglCommandUniforms, gsk_ngl_command_uniforms, GskNglCommandUniform)
|
||||
|
||||
struct _GskNglCommandQueue
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
/* The GdkGLContext we make current before executing GL commands. */
|
||||
GdkGLContext *context;
|
||||
|
||||
/* Array of GskNglCommandBatch which is a fixed size structure that will
|
||||
* point into offsets of other arrays so that all similar data is stored
|
||||
* together. The idea here is that we reduce the need for pointers so that
|
||||
* using g_realloc()'d arrays is fine.
|
||||
*/
|
||||
GskNglCommandBatches batches;
|
||||
|
||||
/* Contains array of vertices and some wrapper code to help upload them
|
||||
* to the GL driver. We can also tweak this to use double buffered arrays
|
||||
* if we find that to be faster on some hardware and/or drivers.
|
||||
*/
|
||||
GskNglBuffer vertices;
|
||||
|
||||
/* The GskNglAttachmentState contains information about our FBO and texture
|
||||
* attachments as we process incoming operations. We snapshot them into
|
||||
* various batches so that we can compare differences between merge
|
||||
* candidates.
|
||||
*/
|
||||
GskNglAttachmentState *attachments;
|
||||
|
||||
/* The uniform state across all programs. We snapshot this into batches so
|
||||
* that we can compare uniform state between batches to give us more
|
||||
* chances at merging draw commands.
|
||||
*/
|
||||
GskNglUniformState *uniforms;
|
||||
|
||||
/* Current program if we are in a draw so that we can send commands
|
||||
* to the uniform state as needed.
|
||||
*/
|
||||
GskNglUniformProgram *program_info;
|
||||
|
||||
/* The profiler instance to deliver timing/etc data */
|
||||
GskProfiler *profiler;
|
||||
GskGLProfiler *gl_profiler;
|
||||
|
||||
/* Array of GskNglCommandBind which denote what textures need to be attached
|
||||
* to which slot. GskNglCommandDraw.bind_offset and bind_count reference this
|
||||
* array to determine what to attach.
|
||||
*/
|
||||
GskNglCommandBinds batch_binds;
|
||||
|
||||
/* Array of GskNglCommandUniform denoting which uniforms must be updated
|
||||
* before the glDrawArrays() may be called. These are referenced from the
|
||||
* GskNglCommandDraw.uniform_offset and uniform_count fields.
|
||||
*/
|
||||
GskNglCommandUniforms batch_uniforms;
|
||||
|
||||
/* String storage for debug groups */
|
||||
GStringChunk *debug_groups;
|
||||
|
||||
/* Discovered max texture size when loading the command queue so that we
|
||||
* can either scale down or slice textures to fit within this size. Assumed
|
||||
* to be both height and width.
|
||||
*/
|
||||
int max_texture_size;
|
||||
|
||||
/* The index of the last batch in @batches, which may not be the element
|
||||
* at the end of the array, as batches can be reordered. This is used to
|
||||
* update the "next" index when adding a new batch.
|
||||
*/
|
||||
gint16 tail_batch_index;
|
||||
gint16 head_batch_index;
|
||||
|
||||
/* Max framebuffer we used, so we can sort items faster */
|
||||
guint fbo_max;
|
||||
|
||||
/* Various GSK and GDK metric counter ids */
|
||||
struct {
|
||||
GQuark n_frames;
|
||||
GQuark cpu_time;
|
||||
GQuark gpu_time;
|
||||
guint n_binds;
|
||||
guint n_fbos;
|
||||
guint n_uniforms;
|
||||
guint n_uploads;
|
||||
guint queue_depth;
|
||||
} metrics;
|
||||
|
||||
/* Counter for uploads on the frame */
|
||||
guint n_uploads;
|
||||
|
||||
/* If we're inside a begin/end_frame pair */
|
||||
guint in_frame : 1;
|
||||
|
||||
/* If we're inside of a begin_draw()/end_draw() pair. */
|
||||
guint in_draw : 1;
|
||||
|
||||
/* If we've warned about truncating batches */
|
||||
guint have_truncated : 1;
|
||||
};
|
||||
|
||||
GskNglCommandQueue *gsk_ngl_command_queue_new (GdkGLContext *context,
|
||||
GskNglUniformState *uniforms);
|
||||
void gsk_ngl_command_queue_set_profiler (GskNglCommandQueue *self,
|
||||
GskProfiler *profiler);
|
||||
GdkGLContext *gsk_ngl_command_queue_get_context (GskNglCommandQueue *self);
|
||||
void gsk_ngl_command_queue_make_current (GskNglCommandQueue *self);
|
||||
void gsk_ngl_command_queue_begin_frame (GskNglCommandQueue *self);
|
||||
void gsk_ngl_command_queue_end_frame (GskNglCommandQueue *self);
|
||||
void gsk_ngl_command_queue_execute (GskNglCommandQueue *self,
|
||||
guint surface_height,
|
||||
guint scale_factor,
|
||||
const cairo_region_t *scissor);
|
||||
int gsk_ngl_command_queue_upload_texture (GskNglCommandQueue *self,
|
||||
GdkTexture *texture,
|
||||
guint x_offset,
|
||||
guint y_offset,
|
||||
guint width,
|
||||
guint height,
|
||||
int min_filter,
|
||||
int mag_filter);
|
||||
int gsk_ngl_command_queue_create_texture (GskNglCommandQueue *self,
|
||||
int width,
|
||||
int height,
|
||||
int min_filter,
|
||||
int mag_filter);
|
||||
guint gsk_ngl_command_queue_create_framebuffer (GskNglCommandQueue *self);
|
||||
gboolean gsk_ngl_command_queue_create_render_target (GskNglCommandQueue *self,
|
||||
int width,
|
||||
int height,
|
||||
int min_filter,
|
||||
int mag_filter,
|
||||
guint *out_fbo_id,
|
||||
guint *out_texture_id);
|
||||
void gsk_ngl_command_queue_delete_program (GskNglCommandQueue *self,
|
||||
guint program_id);
|
||||
void gsk_ngl_command_queue_clear (GskNglCommandQueue *self,
|
||||
guint clear_bits,
|
||||
const graphene_rect_t *viewport);
|
||||
void gsk_ngl_command_queue_begin_draw (GskNglCommandQueue *self,
|
||||
GskNglUniformProgram *program_info,
|
||||
guint width,
|
||||
guint height);
|
||||
void gsk_ngl_command_queue_end_draw (GskNglCommandQueue *self);
|
||||
void gsk_ngl_command_queue_split_draw (GskNglCommandQueue *self);
|
||||
|
||||
static inline GskNglCommandBatch *
|
||||
gsk_ngl_command_queue_get_batch (GskNglCommandQueue *self)
|
||||
{
|
||||
return gsk_ngl_command_batches_tail (&self->batches);
|
||||
}
|
||||
|
||||
static inline GskNglDrawVertex *
|
||||
gsk_ngl_command_queue_add_vertices (GskNglCommandQueue *self)
|
||||
{
|
||||
gsk_ngl_command_queue_get_batch (self)->draw.vbo_count += GSK_NGL_N_VERTICES;
|
||||
return gsk_ngl_buffer_advance (&self->vertices, GSK_NGL_N_VERTICES);
|
||||
}
|
||||
|
||||
static inline GskNglDrawVertex *
|
||||
gsk_ngl_command_queue_add_n_vertices (GskNglCommandQueue *self,
|
||||
guint count)
|
||||
{
|
||||
/* This is a batch form of gsk_ngl_command_queue_add_vertices(). Note that
|
||||
* it does *not* add the count to .draw.vbo_count as the caller is responsible
|
||||
* for that.
|
||||
*/
|
||||
return gsk_ngl_buffer_advance (&self->vertices, GSK_NGL_N_VERTICES * count);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gsk_ngl_command_queue_retract_n_vertices (GskNglCommandQueue *self,
|
||||
guint count)
|
||||
{
|
||||
/* Like gsk_ngl_command_queue_add_n_vertices(), this does not tweak
|
||||
* the draw vbo_count.
|
||||
*/
|
||||
gsk_ngl_buffer_retract (&self->vertices, GSK_NGL_N_VERTICES * count);
|
||||
}
|
||||
|
||||
static inline guint
|
||||
gsk_ngl_command_queue_bind_framebuffer (GskNglCommandQueue *self,
|
||||
guint framebuffer)
|
||||
{
|
||||
guint ret = self->attachments->fbo.id;
|
||||
gsk_ngl_attachment_state_bind_framebuffer (self->attachments, framebuffer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GSK_NGL_COMMAND_QUEUE_PRIVATE_H__ */
|
||||
@@ -1,678 +0,0 @@
|
||||
/* gsknglcompiler.c
|
||||
*
|
||||
* Copyright 2020 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* 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 program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gsk/gskdebugprivate.h>
|
||||
#include <gio/gio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gsknglcommandqueueprivate.h"
|
||||
#include "gsknglcompilerprivate.h"
|
||||
#include "gsknglprogramprivate.h"
|
||||
|
||||
#define SHADER_VERSION_GLES 100
|
||||
#define SHADER_VERSION_GL2_LEGACY 110
|
||||
#define SHADER_VERSION_GL3_LEGACY 130
|
||||
#define SHADER_VERSION_GL3 150
|
||||
|
||||
struct _GskNglCompiler
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GskNglDriver *driver;
|
||||
|
||||
GBytes *all_preamble;
|
||||
GBytes *fragment_preamble;
|
||||
GBytes *vertex_preamble;
|
||||
GBytes *fragment_source;
|
||||
GBytes *fragment_suffix;
|
||||
GBytes *vertex_source;
|
||||
GBytes *vertex_suffix;
|
||||
|
||||
GArray *attrib_locations;
|
||||
|
||||
int glsl_version;
|
||||
|
||||
guint gl3 : 1;
|
||||
guint gles : 1;
|
||||
guint legacy : 1;
|
||||
guint debug_shaders : 1;
|
||||
};
|
||||
|
||||
typedef struct _GskNglProgramAttrib
|
||||
{
|
||||
const char *name;
|
||||
guint location;
|
||||
} GskNglProgramAttrib;
|
||||
|
||||
static GBytes *empty_bytes;
|
||||
|
||||
G_DEFINE_TYPE (GskNglCompiler, gsk_ngl_compiler, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
gsk_ngl_compiler_finalize (GObject *object)
|
||||
{
|
||||
GskNglCompiler *self = (GskNglCompiler *)object;
|
||||
|
||||
g_clear_pointer (&self->all_preamble, g_bytes_unref);
|
||||
g_clear_pointer (&self->fragment_preamble, g_bytes_unref);
|
||||
g_clear_pointer (&self->vertex_preamble, g_bytes_unref);
|
||||
g_clear_pointer (&self->vertex_suffix, g_bytes_unref);
|
||||
g_clear_pointer (&self->fragment_source, g_bytes_unref);
|
||||
g_clear_pointer (&self->fragment_suffix, g_bytes_unref);
|
||||
g_clear_pointer (&self->vertex_source, g_bytes_unref);
|
||||
g_clear_pointer (&self->attrib_locations, g_array_unref);
|
||||
g_clear_object (&self->driver);
|
||||
|
||||
G_OBJECT_CLASS (gsk_ngl_compiler_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_compiler_class_init (GskNglCompilerClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = gsk_ngl_compiler_finalize;
|
||||
|
||||
empty_bytes = g_bytes_new (NULL, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_compiler_init (GskNglCompiler *self)
|
||||
{
|
||||
self->glsl_version = 150;
|
||||
self->attrib_locations = g_array_new (FALSE, FALSE, sizeof (GskNglProgramAttrib));
|
||||
self->all_preamble = g_bytes_ref (empty_bytes);
|
||||
self->vertex_preamble = g_bytes_ref (empty_bytes);
|
||||
self->fragment_preamble = g_bytes_ref (empty_bytes);
|
||||
self->vertex_source = g_bytes_ref (empty_bytes);
|
||||
self->vertex_suffix = g_bytes_ref (empty_bytes);
|
||||
self->fragment_source = g_bytes_ref (empty_bytes);
|
||||
self->fragment_suffix = g_bytes_ref (empty_bytes);
|
||||
}
|
||||
|
||||
GskNglCompiler *
|
||||
gsk_ngl_compiler_new (GskNglDriver *driver,
|
||||
gboolean debug_shaders)
|
||||
{
|
||||
GskNglCompiler *self;
|
||||
GdkGLContext *context;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_NGL_DRIVER (driver), NULL);
|
||||
g_return_val_if_fail (driver->shared_command_queue != NULL, NULL);
|
||||
|
||||
self = g_object_new (GSK_TYPE_GL_COMPILER, NULL);
|
||||
self->driver = g_object_ref (driver);
|
||||
self->debug_shaders = !!debug_shaders;
|
||||
|
||||
context = gsk_ngl_command_queue_get_context (self->driver->shared_command_queue);
|
||||
|
||||
if (gdk_gl_context_get_use_es (context))
|
||||
{
|
||||
self->glsl_version = SHADER_VERSION_GLES;
|
||||
self->gles = TRUE;
|
||||
}
|
||||
else if (gdk_gl_context_is_legacy (context))
|
||||
{
|
||||
int maj, min;
|
||||
|
||||
gdk_gl_context_get_version (context, &maj, &min);
|
||||
|
||||
if (maj == 3)
|
||||
self->glsl_version = SHADER_VERSION_GL3_LEGACY;
|
||||
else
|
||||
self->glsl_version = SHADER_VERSION_GL2_LEGACY;
|
||||
|
||||
self->legacy = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
self->glsl_version = SHADER_VERSION_GL3;
|
||||
self->gl3 = TRUE;
|
||||
}
|
||||
|
||||
gsk_ngl_command_queue_make_current (self->driver->shared_command_queue);
|
||||
|
||||
return g_steal_pointer (&self);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_ngl_compiler_bind_attribute (GskNglCompiler *self,
|
||||
const char *name,
|
||||
guint location)
|
||||
{
|
||||
GskNglProgramAttrib attrib;
|
||||
|
||||
g_return_if_fail (GSK_IS_NGL_COMPILER (self));
|
||||
g_return_if_fail (name != NULL);
|
||||
g_return_if_fail (location < 32);
|
||||
|
||||
attrib.name = g_intern_string (name);
|
||||
attrib.location = location;
|
||||
|
||||
g_array_append_val (self->attrib_locations, attrib);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_ngl_compiler_clear_attributes (GskNglCompiler *self)
|
||||
{
|
||||
g_return_if_fail (GSK_IS_NGL_COMPILER (self));
|
||||
|
||||
g_array_set_size (self->attrib_locations, 0);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_ngl_compiler_set_preamble (GskNglCompiler *self,
|
||||
GskNglCompilerKind kind,
|
||||
GBytes *preamble_bytes)
|
||||
{
|
||||
GBytes **loc = NULL;
|
||||
|
||||
g_return_if_fail (GSK_IS_NGL_COMPILER (self));
|
||||
g_return_if_fail (preamble_bytes != NULL);
|
||||
|
||||
if (kind == GSK_NGL_COMPILER_ALL)
|
||||
loc = &self->all_preamble;
|
||||
else if (kind == GSK_NGL_COMPILER_FRAGMENT)
|
||||
loc = &self->fragment_preamble;
|
||||
else if (kind == GSK_NGL_COMPILER_VERTEX)
|
||||
loc = &self->vertex_preamble;
|
||||
else
|
||||
g_return_if_reached ();
|
||||
|
||||
g_assert (loc != NULL);
|
||||
|
||||
if (*loc != preamble_bytes)
|
||||
{
|
||||
g_clear_pointer (loc, g_bytes_unref);
|
||||
*loc = preamble_bytes ? g_bytes_ref (preamble_bytes) : NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gsk_ngl_compiler_set_preamble_from_resource (GskNglCompiler *self,
|
||||
GskNglCompilerKind kind,
|
||||
const char *resource_path)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GBytes *bytes;
|
||||
|
||||
g_return_if_fail (GSK_IS_NGL_COMPILER (self));
|
||||
g_return_if_fail (kind == GSK_NGL_COMPILER_ALL ||
|
||||
kind == GSK_NGL_COMPILER_VERTEX ||
|
||||
kind == GSK_NGL_COMPILER_FRAGMENT);
|
||||
g_return_if_fail (resource_path != NULL);
|
||||
|
||||
bytes = g_resources_lookup_data (resource_path,
|
||||
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
||||
&error);
|
||||
|
||||
if (bytes == NULL)
|
||||
g_warning ("Cannot set shader from resource: %s", error->message);
|
||||
else
|
||||
gsk_ngl_compiler_set_preamble (self, kind, bytes);
|
||||
|
||||
g_clear_pointer (&bytes, g_bytes_unref);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_ngl_compiler_set_source (GskNglCompiler *self,
|
||||
GskNglCompilerKind kind,
|
||||
GBytes *source_bytes)
|
||||
{
|
||||
GBytes **loc = NULL;
|
||||
|
||||
g_return_if_fail (GSK_IS_NGL_COMPILER (self));
|
||||
g_return_if_fail (kind == GSK_NGL_COMPILER_ALL ||
|
||||
kind == GSK_NGL_COMPILER_VERTEX ||
|
||||
kind == GSK_NGL_COMPILER_FRAGMENT);
|
||||
|
||||
if (source_bytes == NULL)
|
||||
source_bytes = empty_bytes;
|
||||
|
||||
/* If kind is ALL, then we need to split the fragment and
|
||||
* vertex shaders from the bytes and assign them individually.
|
||||
* This safely scans for FRAGMENT_SHADER and VERTEX_SHADER as
|
||||
* specified within the GLSL resources. Some care is taken to
|
||||
* use GBytes which reference the original bytes instead of
|
||||
* copying them.
|
||||
*/
|
||||
if (kind == GSK_NGL_COMPILER_ALL)
|
||||
{
|
||||
gsize len = 0;
|
||||
const char *source;
|
||||
const char *vertex_shader_start;
|
||||
const char *fragment_shader_start;
|
||||
const char *endpos;
|
||||
GBytes *fragment_bytes;
|
||||
GBytes *vertex_bytes;
|
||||
|
||||
g_clear_pointer (&self->fragment_source, g_bytes_unref);
|
||||
g_clear_pointer (&self->vertex_source, g_bytes_unref);
|
||||
|
||||
source = g_bytes_get_data (source_bytes, &len);
|
||||
endpos = source + len;
|
||||
vertex_shader_start = g_strstr_len (source, len, "VERTEX_SHADER");
|
||||
fragment_shader_start = g_strstr_len (source, len, "FRAGMENT_SHADER");
|
||||
|
||||
if (vertex_shader_start == NULL)
|
||||
{
|
||||
g_warning ("Failed to locate VERTEX_SHADER in shader source");
|
||||
return;
|
||||
}
|
||||
|
||||
if (fragment_shader_start == NULL)
|
||||
{
|
||||
g_warning ("Failed to locate FRAGMENT_SHADER in shader source");
|
||||
return;
|
||||
}
|
||||
|
||||
if (vertex_shader_start > fragment_shader_start)
|
||||
{
|
||||
g_warning ("VERTEX_SHADER must come before FRAGMENT_SHADER");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Locate next newlines */
|
||||
while (vertex_shader_start < endpos && vertex_shader_start[0] != '\n')
|
||||
vertex_shader_start++;
|
||||
while (fragment_shader_start < endpos && fragment_shader_start[0] != '\n')
|
||||
fragment_shader_start++;
|
||||
|
||||
vertex_bytes = g_bytes_new_from_bytes (source_bytes,
|
||||
vertex_shader_start - source,
|
||||
fragment_shader_start - vertex_shader_start);
|
||||
fragment_bytes = g_bytes_new_from_bytes (source_bytes,
|
||||
fragment_shader_start - source,
|
||||
endpos - fragment_shader_start);
|
||||
|
||||
gsk_ngl_compiler_set_source (self, GSK_NGL_COMPILER_VERTEX, vertex_bytes);
|
||||
gsk_ngl_compiler_set_source (self, GSK_NGL_COMPILER_FRAGMENT, fragment_bytes);
|
||||
|
||||
g_bytes_unref (fragment_bytes);
|
||||
g_bytes_unref (vertex_bytes);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (kind == GSK_NGL_COMPILER_FRAGMENT)
|
||||
loc = &self->fragment_source;
|
||||
else if (kind == GSK_NGL_COMPILER_VERTEX)
|
||||
loc = &self->vertex_source;
|
||||
else
|
||||
g_return_if_reached ();
|
||||
|
||||
if (*loc != source_bytes)
|
||||
{
|
||||
g_clear_pointer (loc, g_bytes_unref);
|
||||
*loc = g_bytes_ref (source_bytes);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gsk_ngl_compiler_set_source_from_resource (GskNglCompiler *self,
|
||||
GskNglCompilerKind kind,
|
||||
const char *resource_path)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GBytes *bytes;
|
||||
|
||||
g_return_if_fail (GSK_IS_NGL_COMPILER (self));
|
||||
g_return_if_fail (kind == GSK_NGL_COMPILER_ALL ||
|
||||
kind == GSK_NGL_COMPILER_VERTEX ||
|
||||
kind == GSK_NGL_COMPILER_FRAGMENT);
|
||||
g_return_if_fail (resource_path != NULL);
|
||||
|
||||
bytes = g_resources_lookup_data (resource_path,
|
||||
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
||||
&error);
|
||||
|
||||
if (bytes == NULL)
|
||||
g_warning ("Cannot set shader from resource: %s", error->message);
|
||||
else
|
||||
gsk_ngl_compiler_set_source (self, kind, bytes);
|
||||
|
||||
g_clear_pointer (&bytes, g_bytes_unref);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_ngl_compiler_set_suffix (GskNglCompiler *self,
|
||||
GskNglCompilerKind kind,
|
||||
GBytes *suffix_bytes)
|
||||
{
|
||||
GBytes **loc;
|
||||
|
||||
g_return_if_fail (GSK_IS_NGL_COMPILER (self));
|
||||
g_return_if_fail (kind == GSK_NGL_COMPILER_VERTEX ||
|
||||
kind == GSK_NGL_COMPILER_FRAGMENT);
|
||||
g_return_if_fail (suffix_bytes != NULL);
|
||||
|
||||
if (suffix_bytes == NULL)
|
||||
suffix_bytes = empty_bytes;
|
||||
|
||||
if (kind == GSK_NGL_COMPILER_FRAGMENT)
|
||||
loc = &self->fragment_suffix;
|
||||
else if (kind == GSK_NGL_COMPILER_VERTEX)
|
||||
loc = &self->vertex_suffix;
|
||||
else
|
||||
g_return_if_reached ();
|
||||
|
||||
if (*loc != suffix_bytes)
|
||||
{
|
||||
g_clear_pointer (loc, g_bytes_unref);
|
||||
*loc = g_bytes_ref (suffix_bytes);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gsk_ngl_compiler_set_suffix_from_resource (GskNglCompiler *self,
|
||||
GskNglCompilerKind kind,
|
||||
const char *resource_path)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GBytes *bytes;
|
||||
|
||||
g_return_if_fail (GSK_IS_NGL_COMPILER (self));
|
||||
g_return_if_fail (kind == GSK_NGL_COMPILER_VERTEX ||
|
||||
kind == GSK_NGL_COMPILER_FRAGMENT);
|
||||
g_return_if_fail (resource_path != NULL);
|
||||
|
||||
bytes = g_resources_lookup_data (resource_path,
|
||||
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
||||
&error);
|
||||
|
||||
if (bytes == NULL)
|
||||
g_warning ("Cannot set suffix from resource: %s", error->message);
|
||||
else
|
||||
gsk_ngl_compiler_set_suffix (self, kind, bytes);
|
||||
|
||||
g_clear_pointer (&bytes, g_bytes_unref);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
static void
|
||||
prepend_line_numbers (char *code,
|
||||
GString *s)
|
||||
{
|
||||
char *p;
|
||||
int line;
|
||||
|
||||
p = code;
|
||||
line = 1;
|
||||
while (*p)
|
||||
{
|
||||
char *end = strchr (p, '\n');
|
||||
if (end)
|
||||
end = end + 1; /* Include newline */
|
||||
else
|
||||
end = p + strlen (p);
|
||||
|
||||
g_string_append_printf (s, "%3d| ", line++);
|
||||
g_string_append_len (s, p, end - p);
|
||||
|
||||
p = end;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
check_shader_error (int shader_id,
|
||||
GError **error)
|
||||
{
|
||||
GLint status;
|
||||
GLint log_len;
|
||||
GLint code_len;
|
||||
char *buffer;
|
||||
char *code;
|
||||
GString *s;
|
||||
|
||||
glGetShaderiv (shader_id, GL_COMPILE_STATUS, &status);
|
||||
|
||||
if G_LIKELY (status == GL_TRUE)
|
||||
return TRUE;
|
||||
|
||||
glGetShaderiv (shader_id, GL_INFO_LOG_LENGTH, &log_len);
|
||||
buffer = g_malloc0 (log_len + 1);
|
||||
glGetShaderInfoLog (shader_id, log_len, NULL, buffer);
|
||||
|
||||
glGetShaderiv (shader_id, GL_SHADER_SOURCE_LENGTH, &code_len);
|
||||
code = g_malloc0 (code_len + 1);
|
||||
glGetShaderSource (shader_id, code_len, NULL, code);
|
||||
|
||||
s = g_string_new ("");
|
||||
prepend_line_numbers (code, s);
|
||||
|
||||
g_set_error (error,
|
||||
GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_COMPILATION_FAILED,
|
||||
"Compilation failure in shader.\n"
|
||||
"Source Code: %s\n"
|
||||
"\n"
|
||||
"Error Message:\n"
|
||||
"%s\n"
|
||||
"\n",
|
||||
s->str,
|
||||
buffer);
|
||||
|
||||
g_string_free (s, TRUE);
|
||||
g_free (buffer);
|
||||
g_free (code);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
print_shader_info (const char *prefix,
|
||||
int shader_id,
|
||||
const char *name)
|
||||
{
|
||||
if (GSK_DEBUG_CHECK(SHADERS))
|
||||
{
|
||||
int code_len;
|
||||
|
||||
glGetShaderiv (shader_id, GL_SHADER_SOURCE_LENGTH, &code_len);
|
||||
|
||||
if (code_len > 0)
|
||||
{
|
||||
char *code;
|
||||
GString *s;
|
||||
|
||||
code = g_malloc0 (code_len + 1);
|
||||
glGetShaderSource (shader_id, code_len, NULL, code);
|
||||
|
||||
s = g_string_new (NULL);
|
||||
prepend_line_numbers (code, s);
|
||||
|
||||
g_message ("%s %d, %s:\n%s",
|
||||
prefix, shader_id,
|
||||
name ? name : "unnamed",
|
||||
s->str);
|
||||
g_string_free (s, TRUE);
|
||||
g_free (code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_shader_string (GBytes *bytes)
|
||||
{
|
||||
/* 0 length bytes will give us NULL back */
|
||||
const char *str = g_bytes_get_data (bytes, NULL);
|
||||
return str ? str : "";
|
||||
}
|
||||
|
||||
GskNglProgram *
|
||||
gsk_ngl_compiler_compile (GskNglCompiler *self,
|
||||
const char *name,
|
||||
GError **error)
|
||||
{
|
||||
char version[32];
|
||||
const char *debug = "";
|
||||
const char *legacy = "";
|
||||
const char *gl3 = "";
|
||||
const char *gles = "";
|
||||
int program_id;
|
||||
int vertex_id;
|
||||
int fragment_id;
|
||||
int status;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_NGL_COMPILER (self), NULL);
|
||||
g_return_val_if_fail (self->all_preamble != NULL, NULL);
|
||||
g_return_val_if_fail (self->fragment_preamble != NULL, NULL);
|
||||
g_return_val_if_fail (self->vertex_preamble != NULL, NULL);
|
||||
g_return_val_if_fail (self->fragment_source != NULL, NULL);
|
||||
g_return_val_if_fail (self->vertex_source != NULL, NULL);
|
||||
g_return_val_if_fail (self->driver != NULL, NULL);
|
||||
|
||||
gsk_ngl_command_queue_make_current (self->driver->command_queue);
|
||||
|
||||
g_snprintf (version, sizeof version, "#version %d\n", self->glsl_version);
|
||||
|
||||
if (self->debug_shaders)
|
||||
debug = "#define GSK_DEBUG 1\n";
|
||||
|
||||
if (self->legacy)
|
||||
legacy = "#define GSK_LEGACY 1\n";
|
||||
|
||||
if (self->gles)
|
||||
gles = "#define GSK_NGLES 1\n";
|
||||
|
||||
if (self->gl3)
|
||||
gl3 = "#define GSK_NGL3 1\n";
|
||||
|
||||
vertex_id = glCreateShader (GL_VERTEX_SHADER);
|
||||
glShaderSource (vertex_id,
|
||||
9,
|
||||
(const char *[]) {
|
||||
version, debug, legacy, gl3, gles,
|
||||
get_shader_string (self->all_preamble),
|
||||
get_shader_string (self->vertex_preamble),
|
||||
get_shader_string (self->vertex_source),
|
||||
get_shader_string (self->vertex_suffix),
|
||||
},
|
||||
(int[]) {
|
||||
strlen (version),
|
||||
strlen (debug),
|
||||
strlen (legacy),
|
||||
strlen (gl3),
|
||||
strlen (gles),
|
||||
g_bytes_get_size (self->all_preamble),
|
||||
g_bytes_get_size (self->vertex_preamble),
|
||||
g_bytes_get_size (self->vertex_source),
|
||||
g_bytes_get_size (self->vertex_suffix),
|
||||
});
|
||||
glCompileShader (vertex_id);
|
||||
|
||||
if (!check_shader_error (vertex_id, error))
|
||||
{
|
||||
glDeleteShader (vertex_id);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
print_shader_info ("Vertex shader", vertex_id, name);
|
||||
|
||||
fragment_id = glCreateShader (GL_FRAGMENT_SHADER);
|
||||
glShaderSource (fragment_id,
|
||||
9,
|
||||
(const char *[]) {
|
||||
version, debug, legacy, gl3, gles,
|
||||
get_shader_string (self->all_preamble),
|
||||
get_shader_string (self->fragment_preamble),
|
||||
get_shader_string (self->fragment_source),
|
||||
get_shader_string (self->fragment_suffix),
|
||||
},
|
||||
(int[]) {
|
||||
strlen (version),
|
||||
strlen (debug),
|
||||
strlen (legacy),
|
||||
strlen (gl3),
|
||||
strlen (gles),
|
||||
g_bytes_get_size (self->all_preamble),
|
||||
g_bytes_get_size (self->fragment_preamble),
|
||||
g_bytes_get_size (self->fragment_source),
|
||||
g_bytes_get_size (self->fragment_suffix),
|
||||
});
|
||||
glCompileShader (fragment_id);
|
||||
|
||||
if (!check_shader_error (fragment_id, error))
|
||||
{
|
||||
glDeleteShader (vertex_id);
|
||||
glDeleteShader (fragment_id);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
print_shader_info ("Fragment shader", fragment_id, name);
|
||||
|
||||
program_id = glCreateProgram ();
|
||||
glAttachShader (program_id, vertex_id);
|
||||
glAttachShader (program_id, fragment_id);
|
||||
|
||||
for (guint i = 0; i < self->attrib_locations->len; i++)
|
||||
{
|
||||
const GskNglProgramAttrib *attrib;
|
||||
|
||||
attrib = &g_array_index (self->attrib_locations, GskNglProgramAttrib, i);
|
||||
glBindAttribLocation (program_id, attrib->location, attrib->name);
|
||||
}
|
||||
|
||||
glLinkProgram (program_id);
|
||||
|
||||
glGetProgramiv (program_id, GL_LINK_STATUS, &status);
|
||||
|
||||
glDetachShader (program_id, vertex_id);
|
||||
glDeleteShader (vertex_id);
|
||||
|
||||
glDetachShader (program_id, fragment_id);
|
||||
glDeleteShader (fragment_id);
|
||||
|
||||
if (status == GL_FALSE)
|
||||
{
|
||||
char *buffer = NULL;
|
||||
int log_len = 0;
|
||||
|
||||
glGetProgramiv (program_id, GL_INFO_LOG_LENGTH, &log_len);
|
||||
|
||||
if (log_len > 0)
|
||||
{
|
||||
/* log_len includes NULL */
|
||||
buffer = g_malloc0 (log_len);
|
||||
glGetProgramInfoLog (program_id, log_len, NULL, buffer);
|
||||
}
|
||||
|
||||
g_warning ("Linking failure in shader:\n%s",
|
||||
buffer ? buffer : "");
|
||||
|
||||
g_set_error (error,
|
||||
GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_LINK_FAILED,
|
||||
"Linking failure in shader: %s",
|
||||
buffer ? buffer : "");
|
||||
|
||||
g_free (buffer);
|
||||
|
||||
glDeleteProgram (program_id);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return gsk_ngl_program_new (self->driver, name, program_id);
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/* gsknglcompilerprivate.h
|
||||
*
|
||||
* Copyright 2020 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* 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 program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#ifndef __GSK_NGL_COMPILER_PRIVATE_H__
|
||||
#define __GSK_NGL_COMPILER_PRIVATE_H__
|
||||
|
||||
#include "gskngltypesprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef enum _GskNglCompilerKind
|
||||
{
|
||||
GSK_NGL_COMPILER_ALL,
|
||||
GSK_NGL_COMPILER_FRAGMENT,
|
||||
GSK_NGL_COMPILER_VERTEX,
|
||||
} GskNglCompilerKind;
|
||||
|
||||
#define GSK_TYPE_GL_COMPILER (gsk_ngl_compiler_get_type())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GskNglCompiler, gsk_ngl_compiler, GSK, NGL_COMPILER, GObject)
|
||||
|
||||
GskNglCompiler *gsk_ngl_compiler_new (GskNglDriver *driver,
|
||||
gboolean debug);
|
||||
void gsk_ngl_compiler_set_preamble (GskNglCompiler *self,
|
||||
GskNglCompilerKind kind,
|
||||
GBytes *preamble_bytes);
|
||||
void gsk_ngl_compiler_set_preamble_from_resource (GskNglCompiler *self,
|
||||
GskNglCompilerKind kind,
|
||||
const char *resource_path);
|
||||
void gsk_ngl_compiler_set_source (GskNglCompiler *self,
|
||||
GskNglCompilerKind kind,
|
||||
GBytes *source_bytes);
|
||||
void gsk_ngl_compiler_set_source_from_resource (GskNglCompiler *self,
|
||||
GskNglCompilerKind kind,
|
||||
const char *resource_path);
|
||||
void gsk_ngl_compiler_set_suffix (GskNglCompiler *self,
|
||||
GskNglCompilerKind kind,
|
||||
GBytes *suffix_bytes);
|
||||
void gsk_ngl_compiler_set_suffix_from_resource (GskNglCompiler *self,
|
||||
GskNglCompilerKind kind,
|
||||
const char *resource_path);
|
||||
void gsk_ngl_compiler_bind_attribute (GskNglCompiler *self,
|
||||
const char *name,
|
||||
guint location);
|
||||
void gsk_ngl_compiler_clear_attributes (GskNglCompiler *self);
|
||||
GskNglProgram *gsk_ngl_compiler_compile (GskNglCompiler *self,
|
||||
const char *name,
|
||||
GError **error);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GSK_NGL_COMPILER_PRIVATE_H__ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,234 +0,0 @@
|
||||
/* gskngldriverprivate.h
|
||||
*
|
||||
* Copyright 2020 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* This file 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 file 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 General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#ifndef __GSK_NGL_DRIVER_PRIVATE_H__
|
||||
#define __GSK_NGL_DRIVER_PRIVATE_H__
|
||||
|
||||
#include <gdk/gdkgltextureprivate.h>
|
||||
|
||||
#include "gskngltypesprivate.h"
|
||||
#include "gskngltexturepoolprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
enum {
|
||||
UNIFORM_SHARED_ALPHA,
|
||||
UNIFORM_SHARED_SOURCE,
|
||||
UNIFORM_SHARED_CLIP_RECT,
|
||||
UNIFORM_SHARED_VIEWPORT,
|
||||
UNIFORM_SHARED_PROJECTION,
|
||||
UNIFORM_SHARED_MODELVIEW,
|
||||
|
||||
UNIFORM_SHARED_LAST
|
||||
};
|
||||
|
||||
enum {
|
||||
UNIFORM_CUSTOM_SIZE = UNIFORM_SHARED_LAST,
|
||||
UNIFORM_CUSTOM_TEXTURE1,
|
||||
UNIFORM_CUSTOM_TEXTURE2,
|
||||
UNIFORM_CUSTOM_TEXTURE3,
|
||||
UNIFORM_CUSTOM_TEXTURE4,
|
||||
|
||||
UNIFORM_CUSTOM_LAST
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
gconstpointer pointer;
|
||||
float scale_x;
|
||||
float scale_y;
|
||||
int filter;
|
||||
int pointer_is_child;
|
||||
graphene_rect_t parent_rect; /* Valid when pointer_is_child */
|
||||
} GskTextureKey;
|
||||
|
||||
#define GSL_GK_NO_UNIFORMS UNIFORM_INVALID_##__COUNTER__
|
||||
#define GSK_NGL_ADD_UNIFORM(pos, KEY, name) UNIFORM_##KEY = UNIFORM_SHARED_LAST + pos,
|
||||
#define GSK_NGL_DEFINE_PROGRAM(name, resource, uniforms) enum { uniforms };
|
||||
# include "gsknglprograms.defs"
|
||||
#undef GSK_NGL_DEFINE_PROGRAM
|
||||
#undef GSK_NGL_ADD_UNIFORM
|
||||
#undef GSL_GK_NO_UNIFORMS
|
||||
|
||||
#define GSK_TYPE_NGL_DRIVER (gsk_ngl_driver_get_type())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GskNglDriver, gsk_ngl_driver, GSK, NGL_DRIVER, GObject)
|
||||
|
||||
struct _GskNglRenderTarget
|
||||
{
|
||||
guint framebuffer_id;
|
||||
guint texture_id;
|
||||
int min_filter;
|
||||
int mag_filter;
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
|
||||
struct _GskNglDriver
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GskNglCommandQueue *shared_command_queue;
|
||||
GskNglCommandQueue *command_queue;
|
||||
|
||||
GskNglTexturePool texture_pool;
|
||||
|
||||
GskNglGlyphLibrary *glyphs;
|
||||
GskNglIconLibrary *icons;
|
||||
GskNglShadowLibrary *shadows;
|
||||
|
||||
GHashTable *textures;
|
||||
GHashTable *key_to_texture_id;
|
||||
GHashTable *texture_id_to_key;
|
||||
|
||||
GPtrArray *atlases;
|
||||
|
||||
GHashTable *shader_cache;
|
||||
|
||||
GArray *autorelease_framebuffers;
|
||||
GPtrArray *render_targets;
|
||||
|
||||
#define GSK_NGL_NO_UNIFORMS
|
||||
#define GSK_NGL_ADD_UNIFORM(pos, KEY, name)
|
||||
#define GSK_NGL_DEFINE_PROGRAM(name, resource, uniforms) GskNglProgram *name;
|
||||
# include "gsknglprograms.defs"
|
||||
#undef GSK_NGL_NO_UNIFORMS
|
||||
#undef GSK_NGL_ADD_UNIFORM
|
||||
#undef GSK_NGL_DEFINE_PROGRAM
|
||||
|
||||
gint64 current_frame_id;
|
||||
|
||||
/* Used to reduce number of comparisons */
|
||||
guint stamps[UNIFORM_SHARED_LAST];
|
||||
|
||||
guint debug : 1;
|
||||
guint in_frame : 1;
|
||||
};
|
||||
|
||||
GskNglDriver *gsk_ngl_driver_from_shared_context (GdkGLContext *context,
|
||||
gboolean debug_shaders,
|
||||
GError **error);
|
||||
GskNglCommandQueue *gsk_ngl_driver_create_command_queue (GskNglDriver *self,
|
||||
GdkGLContext *context);
|
||||
GdkGLContext *gsk_ngl_driver_get_context (GskNglDriver *self);
|
||||
gboolean gsk_ngl_driver_create_render_target (GskNglDriver *self,
|
||||
int width,
|
||||
int height,
|
||||
int min_filter,
|
||||
int mag_filter,
|
||||
GskNglRenderTarget **render_target);
|
||||
guint gsk_ngl_driver_release_render_target (GskNglDriver *self,
|
||||
GskNglRenderTarget *render_target,
|
||||
gboolean release_texture);
|
||||
void gsk_ngl_driver_begin_frame (GskNglDriver *self,
|
||||
GskNglCommandQueue *command_queue);
|
||||
void gsk_ngl_driver_end_frame (GskNglDriver *self);
|
||||
void gsk_ngl_driver_after_frame (GskNglDriver *self);
|
||||
GdkTexture *gsk_ngl_driver_create_gdk_texture (GskNglDriver *self,
|
||||
guint texture_id);
|
||||
void gsk_ngl_driver_cache_texture (GskNglDriver *self,
|
||||
const GskTextureKey *key,
|
||||
guint texture_id);
|
||||
guint gsk_ngl_driver_load_texture (GskNglDriver *self,
|
||||
GdkTexture *texture,
|
||||
int min_filter,
|
||||
int mag_filter);
|
||||
GskNglTexture *gsk_ngl_driver_create_texture (GskNglDriver *self,
|
||||
float width,
|
||||
float height,
|
||||
int min_filter,
|
||||
int mag_filter);
|
||||
void gsk_ngl_driver_release_texture (GskNglDriver *self,
|
||||
GskNglTexture *texture);
|
||||
void gsk_ngl_driver_release_texture_by_id (GskNglDriver *self,
|
||||
guint texture_id);
|
||||
GskNglTexture *gsk_ngl_driver_mark_texture_permanent (GskNglDriver *self,
|
||||
guint texture_id);
|
||||
void gsk_ngl_driver_add_texture_slices (GskNglDriver *self,
|
||||
GdkTexture *texture,
|
||||
GskNglTextureSlice **out_slices,
|
||||
guint *out_n_slices);
|
||||
GskNglProgram *gsk_ngl_driver_lookup_shader (GskNglDriver *self,
|
||||
GskGLShader *shader,
|
||||
GError **error);
|
||||
GskNglTextureAtlas *gsk_ngl_driver_create_atlas (GskNglDriver *self);
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
void gsk_ngl_driver_save_atlases_to_png (GskNglDriver *self,
|
||||
const char *directory);
|
||||
#endif
|
||||
|
||||
static inline GskNglTexture *
|
||||
gsk_ngl_driver_get_texture_by_id (GskNglDriver *self,
|
||||
guint texture_id)
|
||||
{
|
||||
return g_hash_table_lookup (self->textures, GUINT_TO_POINTER (texture_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_ngl_driver_lookup_texture:
|
||||
* @self: a #GskNglDriver
|
||||
* @key: the key for the texture
|
||||
*
|
||||
* Looks up a texture in the texture cache by @key.
|
||||
*
|
||||
* If the texture could not be found, then zero is returned.
|
||||
*
|
||||
* Returns: a positive integer if the texture was found; otherwise 0.
|
||||
*/
|
||||
static inline guint
|
||||
gsk_ngl_driver_lookup_texture (GskNglDriver *self,
|
||||
const GskTextureKey *key)
|
||||
{
|
||||
gpointer id;
|
||||
|
||||
if (g_hash_table_lookup_extended (self->key_to_texture_id, key, NULL, &id))
|
||||
{
|
||||
GskNglTexture *texture = g_hash_table_lookup (self->textures, id);
|
||||
|
||||
if (texture != NULL)
|
||||
texture->last_used_in_frame = self->current_frame_id;
|
||||
|
||||
return GPOINTER_TO_UINT (id);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void
|
||||
gsk_ngl_driver_slice_texture (GskNglDriver *self,
|
||||
GdkTexture *texture,
|
||||
GskNglTextureSlice **out_slices,
|
||||
guint *out_n_slices)
|
||||
{
|
||||
GskNglTexture *t;
|
||||
|
||||
if ((t = gdk_texture_get_render_data (texture, self)))
|
||||
{
|
||||
*out_slices = t->slices;
|
||||
*out_n_slices = t->n_slices;
|
||||
return;
|
||||
}
|
||||
|
||||
gsk_ngl_driver_add_texture_slices (self, texture, out_slices, out_n_slices);
|
||||
}
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GSK_NGL_DRIVER_PRIVATE_H__ */
|
||||
@@ -1,325 +0,0 @@
|
||||
/* gsknglglyphlibrary.c
|
||||
*
|
||||
* Copyright 2020 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* 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 program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gdk/gdkglcontextprivate.h>
|
||||
#include <gdk/gdkmemorytextureprivate.h>
|
||||
#include <gdk/gdkprofilerprivate.h>
|
||||
|
||||
#include "gsknglcommandqueueprivate.h"
|
||||
#include "gskngldriverprivate.h"
|
||||
#include "gsknglglyphlibraryprivate.h"
|
||||
|
||||
#define MAX_GLYPH_SIZE 128
|
||||
|
||||
G_DEFINE_TYPE (GskNglGlyphLibrary, gsk_ngl_glyph_library, GSK_TYPE_GL_TEXTURE_LIBRARY)
|
||||
|
||||
GskNglGlyphLibrary *
|
||||
gsk_ngl_glyph_library_new (GskNglDriver *driver)
|
||||
{
|
||||
g_return_val_if_fail (GSK_IS_NGL_DRIVER (driver), NULL);
|
||||
|
||||
return g_object_new (GSK_TYPE_GL_GLYPH_LIBRARY,
|
||||
"driver", driver,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static guint
|
||||
gsk_ngl_glyph_key_hash (gconstpointer data)
|
||||
{
|
||||
const GskNglGlyphKey *key = data;
|
||||
|
||||
/* We do not store the hash within the key because GHashTable will already
|
||||
* store the hash value for us and so this is called only a single time per
|
||||
* cached item. This saves an extra 4 bytes per GskNglGlyphKey which means on
|
||||
* 64-bit, we fit nicely within 2 pointers (the smallest allocation size
|
||||
* for GSlice).
|
||||
*/
|
||||
|
||||
return GPOINTER_TO_UINT (key->font) ^
|
||||
key->glyph ^
|
||||
(key->xshift << 24) ^
|
||||
(key->yshift << 26) ^
|
||||
key->scale;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gsk_ngl_glyph_key_equal (gconstpointer v1,
|
||||
gconstpointer v2)
|
||||
{
|
||||
return memcmp (v1, v2, sizeof (GskNglGlyphKey)) == 0;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_glyph_key_free (gpointer data)
|
||||
{
|
||||
GskNglGlyphKey *key = data;
|
||||
|
||||
g_clear_object (&key->font);
|
||||
g_slice_free (GskNglGlyphKey, key);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_glyph_value_free (gpointer data)
|
||||
{
|
||||
g_slice_free (GskNglGlyphValue, data);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_glyph_library_finalize (GObject *object)
|
||||
{
|
||||
GskNglGlyphLibrary *self = (GskNglGlyphLibrary *)object;
|
||||
|
||||
g_clear_pointer (&self->hash_table, g_hash_table_unref);
|
||||
g_clear_pointer (&self->surface_data, g_free);
|
||||
|
||||
G_OBJECT_CLASS (gsk_ngl_glyph_library_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_glyph_library_class_init (GskNglGlyphLibraryClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = gsk_ngl_glyph_library_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_glyph_library_init (GskNglGlyphLibrary *self)
|
||||
{
|
||||
GSK_NGL_TEXTURE_LIBRARY (self)->max_entry_size = MAX_GLYPH_SIZE;
|
||||
gsk_ngl_texture_library_set_funcs (GSK_NGL_TEXTURE_LIBRARY (self),
|
||||
gsk_ngl_glyph_key_hash,
|
||||
gsk_ngl_glyph_key_equal,
|
||||
gsk_ngl_glyph_key_free,
|
||||
gsk_ngl_glyph_value_free);
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
gsk_ngl_glyph_library_create_surface (GskNglGlyphLibrary *self,
|
||||
int stride,
|
||||
int width,
|
||||
int height,
|
||||
double device_scale)
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
gsize n_bytes;
|
||||
|
||||
g_assert (GSK_IS_NGL_GLYPH_LIBRARY (self));
|
||||
g_assert (width > 0);
|
||||
g_assert (height > 0);
|
||||
|
||||
n_bytes = stride * height;
|
||||
|
||||
if G_LIKELY (n_bytes > self->surface_data_len)
|
||||
{
|
||||
self->surface_data = g_realloc (self->surface_data, n_bytes);
|
||||
self->surface_data_len = n_bytes;
|
||||
}
|
||||
|
||||
memset (self->surface_data, 0, n_bytes);
|
||||
surface = cairo_image_surface_create_for_data (self->surface_data,
|
||||
CAIRO_FORMAT_ARGB32,
|
||||
width, height, stride);
|
||||
cairo_surface_set_device_scale (surface, device_scale, device_scale);
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
static void
|
||||
render_glyph (cairo_surface_t *surface,
|
||||
const cairo_scaled_font_t *scaled_font,
|
||||
const GskNglGlyphKey *key,
|
||||
const GskNglGlyphValue *value)
|
||||
{
|
||||
cairo_t *cr;
|
||||
PangoGlyphString glyph_string;
|
||||
PangoGlyphInfo glyph_info;
|
||||
|
||||
g_assert (surface != NULL);
|
||||
g_assert (scaled_font != NULL);
|
||||
|
||||
cr = cairo_create (surface);
|
||||
cairo_set_scaled_font (cr, scaled_font);
|
||||
cairo_set_source_rgba (cr, 1, 1, 1, 1);
|
||||
|
||||
glyph_info.glyph = key->glyph;
|
||||
glyph_info.geometry.width = value->ink_rect.width * 1024;
|
||||
if (glyph_info.glyph & PANGO_GLYPH_UNKNOWN_FLAG)
|
||||
glyph_info.geometry.x_offset = 250 * key->xshift;
|
||||
else
|
||||
glyph_info.geometry.x_offset = 250 * key->xshift - value->ink_rect.x * 1024;
|
||||
glyph_info.geometry.y_offset = 250 * key->yshift - value->ink_rect.y * 1024;
|
||||
|
||||
glyph_string.num_glyphs = 1;
|
||||
glyph_string.glyphs = &glyph_info;
|
||||
|
||||
pango_cairo_show_glyph_string (cr, key->font, &glyph_string);
|
||||
cairo_destroy (cr);
|
||||
|
||||
cairo_surface_flush (surface);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_glyph_library_upload_glyph (GskNglGlyphLibrary *self,
|
||||
const GskNglGlyphKey *key,
|
||||
const GskNglGlyphValue *value,
|
||||
int width,
|
||||
int height,
|
||||
double device_scale)
|
||||
{
|
||||
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
|
||||
cairo_scaled_font_t *scaled_font;
|
||||
GskNglTextureAtlas *atlas;
|
||||
cairo_surface_t *surface;
|
||||
guchar *pixel_data;
|
||||
guchar *free_data = NULL;
|
||||
guint gl_format;
|
||||
guint gl_type;
|
||||
guint texture_id;
|
||||
gsize stride;
|
||||
int x, y;
|
||||
|
||||
g_assert (GSK_IS_NGL_GLYPH_LIBRARY (self));
|
||||
g_assert (key != NULL);
|
||||
g_assert (value != NULL);
|
||||
|
||||
scaled_font = pango_cairo_font_get_scaled_font ((PangoCairoFont *)key->font);
|
||||
if G_UNLIKELY (scaled_font == NULL ||
|
||||
cairo_scaled_font_status (scaled_font) != CAIRO_STATUS_SUCCESS)
|
||||
return;
|
||||
|
||||
stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, width);
|
||||
atlas = value->entry.is_atlased ? value->entry.atlas : NULL;
|
||||
|
||||
gdk_gl_context_push_debug_group_printf (gdk_gl_context_get_current (),
|
||||
"Uploading glyph %d",
|
||||
key->glyph);
|
||||
|
||||
surface = gsk_ngl_glyph_library_create_surface (self, stride, width, height, device_scale);
|
||||
render_glyph (surface, scaled_font, key, value);
|
||||
|
||||
texture_id = GSK_NGL_TEXTURE_ATLAS_ENTRY_TEXTURE (value);
|
||||
|
||||
g_assert (texture_id > 0);
|
||||
|
||||
glPixelStorei (GL_UNPACK_ROW_LENGTH, stride / 4);
|
||||
glBindTexture (GL_TEXTURE_2D, texture_id);
|
||||
|
||||
if G_UNLIKELY (gdk_gl_context_get_use_es (gdk_gl_context_get_current ()))
|
||||
{
|
||||
pixel_data = free_data = g_malloc (width * height * 4);
|
||||
gdk_memory_convert (pixel_data,
|
||||
width * 4,
|
||||
GDK_MEMORY_R8G8B8A8_PREMULTIPLIED,
|
||||
cairo_image_surface_get_data (surface),
|
||||
width * 4,
|
||||
GDK_MEMORY_DEFAULT,
|
||||
width, height);
|
||||
gl_format = GL_RGBA;
|
||||
gl_type = GL_UNSIGNED_BYTE;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixel_data = cairo_image_surface_get_data (surface);
|
||||
gl_format = GL_BGRA;
|
||||
gl_type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
}
|
||||
|
||||
if G_LIKELY (atlas != NULL)
|
||||
{
|
||||
x = atlas->width * value->entry.area.x;
|
||||
y = atlas->width * value->entry.area.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
x = 0;
|
||||
y = 0;
|
||||
}
|
||||
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0, x, y, width, height,
|
||||
gl_format, gl_type, pixel_data);
|
||||
glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
|
||||
|
||||
cairo_surface_destroy (surface);
|
||||
g_free (free_data);
|
||||
|
||||
gdk_gl_context_pop_debug_group (gdk_gl_context_get_current ());
|
||||
|
||||
GSK_NGL_TEXTURE_LIBRARY (self)->driver->command_queue->n_uploads++;
|
||||
|
||||
if (gdk_profiler_is_running ())
|
||||
{
|
||||
char message[64];
|
||||
g_snprintf (message, sizeof message, "Size %dx%d", width, height);
|
||||
gdk_profiler_add_mark (start_time, GDK_PROFILER_CURRENT_TIME-start_time, "Upload Glyph", message);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gsk_ngl_glyph_library_add (GskNglGlyphLibrary *self,
|
||||
GskNglGlyphKey *key,
|
||||
const GskNglGlyphValue **out_value)
|
||||
{
|
||||
PangoRectangle ink_rect;
|
||||
GskNglGlyphValue *value;
|
||||
int width;
|
||||
int height;
|
||||
guint packed_x;
|
||||
guint packed_y;
|
||||
|
||||
g_assert (GSK_IS_NGL_GLYPH_LIBRARY (self));
|
||||
g_assert (key != NULL);
|
||||
g_assert (out_value != NULL);
|
||||
|
||||
pango_font_get_glyph_extents (key->font, key->glyph, &ink_rect, NULL);
|
||||
pango_extents_to_pixels (&ink_rect, NULL);
|
||||
|
||||
if (key->xshift != 0)
|
||||
ink_rect.width++;
|
||||
if (key->yshift != 0)
|
||||
ink_rect.height++;
|
||||
|
||||
width = ink_rect.width * key->scale / 1024;
|
||||
height = ink_rect.height * key->scale / 1024;
|
||||
|
||||
value = gsk_ngl_texture_library_pack (GSK_NGL_TEXTURE_LIBRARY (self),
|
||||
key,
|
||||
sizeof *value,
|
||||
width,
|
||||
height,
|
||||
0,
|
||||
&packed_x, &packed_y);
|
||||
|
||||
memcpy (&value->ink_rect, &ink_rect, sizeof ink_rect);
|
||||
|
||||
if (key->scale > 0 && width > 0 && height > 0)
|
||||
gsk_ngl_glyph_library_upload_glyph (self,
|
||||
key,
|
||||
value,
|
||||
width,
|
||||
height,
|
||||
key->scale / 1024.0);
|
||||
|
||||
*out_value = value;
|
||||
|
||||
return GSK_NGL_TEXTURE_ATLAS_ENTRY_TEXTURE (value) != 0;
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
/* gsknglglyphlibraryprivate.h
|
||||
*
|
||||
* Copyright 2020 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* 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 program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#ifndef __GSK_NGL_GLYPH_LIBRARY_PRIVATE_H__
|
||||
#define __GSK_NGL_GLYPH_LIBRARY_PRIVATE_H__
|
||||
|
||||
#include <pango/pango.h>
|
||||
|
||||
#include "gskngltexturelibraryprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GSK_TYPE_GL_GLYPH_LIBRARY (gsk_ngl_glyph_library_get_type())
|
||||
|
||||
typedef struct _GskNglGlyphKey
|
||||
{
|
||||
PangoFont *font;
|
||||
PangoGlyph glyph;
|
||||
guint xshift : 3;
|
||||
guint yshift : 3;
|
||||
guint scale : 26; /* times 1024 */
|
||||
} GskNglGlyphKey;
|
||||
|
||||
typedef struct _GskNglGlyphValue
|
||||
{
|
||||
GskNglTextureAtlasEntry entry;
|
||||
PangoRectangle ink_rect;
|
||||
} GskNglGlyphValue;
|
||||
|
||||
#if GLIB_SIZEOF_VOID_P == 8
|
||||
G_STATIC_ASSERT (sizeof (GskNglGlyphKey) == 16);
|
||||
#elif GLIB_SIZEOF_VOID_P == 4
|
||||
G_STATIC_ASSERT (sizeof (GskNglGlyphKey) == 12);
|
||||
#endif
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GskNglGlyphLibrary, gsk_ngl_glyph_library, GSK, NGL_GLYPH_LIBRARY, GskNglTextureLibrary)
|
||||
|
||||
struct _GskNglGlyphLibrary
|
||||
{
|
||||
GskNglTextureLibrary parent_instance;
|
||||
GHashTable *hash_table;
|
||||
guint8 *surface_data;
|
||||
gsize surface_data_len;
|
||||
struct {
|
||||
GskNglGlyphKey key;
|
||||
const GskNglGlyphValue *value;
|
||||
} front[256];
|
||||
};
|
||||
|
||||
GskNglGlyphLibrary *gsk_ngl_glyph_library_new (GskNglDriver *driver);
|
||||
gboolean gsk_ngl_glyph_library_add (GskNglGlyphLibrary *self,
|
||||
GskNglGlyphKey *key,
|
||||
const GskNglGlyphValue **out_value);
|
||||
|
||||
static inline int
|
||||
gsk_ngl_glyph_key_phase (float value)
|
||||
{
|
||||
return floor (4 * (value + 0.125)) - 4 * floor (value + 0.125);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gsk_ngl_glyph_key_set_glyph_and_shift (GskNglGlyphKey *key,
|
||||
PangoGlyph glyph,
|
||||
float x,
|
||||
float y)
|
||||
{
|
||||
key->glyph = glyph;
|
||||
key->xshift = gsk_ngl_glyph_key_phase (x);
|
||||
key->yshift = gsk_ngl_glyph_key_phase (y);
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
gsk_ngl_glyph_library_lookup_or_add (GskNglGlyphLibrary *self,
|
||||
const GskNglGlyphKey *key,
|
||||
const GskNglGlyphValue **out_value)
|
||||
{
|
||||
GskNglTextureAtlasEntry *entry;
|
||||
guint front_index = key->glyph & 0xFF;
|
||||
|
||||
if (memcmp (key, &self->front[front_index], sizeof *key) == 0)
|
||||
{
|
||||
*out_value = self->front[front_index].value;
|
||||
}
|
||||
else if (gsk_ngl_texture_library_lookup ((GskNglTextureLibrary *)self, key, &entry))
|
||||
{
|
||||
*out_value = (GskNglGlyphValue *)entry;
|
||||
self->front[front_index].key = *key;
|
||||
self->front[front_index].value = *out_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
GskNglGlyphKey *k = g_slice_copy (sizeof *key, key);
|
||||
g_object_ref (k->font);
|
||||
gsk_ngl_glyph_library_add (self, k, out_value);
|
||||
}
|
||||
|
||||
return GSK_NGL_TEXTURE_ATLAS_ENTRY_TEXTURE (*out_value) != 0;
|
||||
}
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GSK_NGL_GLYPH_LIBRARY_PRIVATE_H__ */
|
||||
@@ -1,213 +0,0 @@
|
||||
/* gskngliconlibrary.c
|
||||
*
|
||||
* Copyright 2020 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* 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 program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gdk/gdkglcontextprivate.h>
|
||||
#include <gdk/gdkmemorytextureprivate.h>
|
||||
#include <gdk/gdkprofilerprivate.h>
|
||||
#include <gdk/gdktextureprivate.h>
|
||||
|
||||
#include "gsknglcommandqueueprivate.h"
|
||||
#include "gskngldriverprivate.h"
|
||||
#include "gskngliconlibraryprivate.h"
|
||||
|
||||
struct _GskNglIconLibrary
|
||||
{
|
||||
GskNglTextureLibrary parent_instance;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GskNglIconLibrary, gsk_ngl_icon_library, GSK_TYPE_GL_TEXTURE_LIBRARY)
|
||||
|
||||
GskNglIconLibrary *
|
||||
gsk_ngl_icon_library_new (GskNglDriver *driver)
|
||||
{
|
||||
g_return_val_if_fail (GSK_IS_NGL_DRIVER (driver), NULL);
|
||||
|
||||
return g_object_new (GSK_TYPE_GL_ICON_LIBRARY,
|
||||
"driver", driver,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_icon_data_free (gpointer data)
|
||||
{
|
||||
GskNglIconData *icon_data = data;
|
||||
|
||||
g_clear_object (&icon_data->source_texture);
|
||||
g_slice_free (GskNglIconData, icon_data);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_icon_library_class_init (GskNglIconLibraryClass *klass)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_icon_library_init (GskNglIconLibrary *self)
|
||||
{
|
||||
GSK_NGL_TEXTURE_LIBRARY (self)->max_entry_size = 128;
|
||||
gsk_ngl_texture_library_set_funcs (GSK_NGL_TEXTURE_LIBRARY (self),
|
||||
NULL, NULL, NULL,
|
||||
gsk_ngl_icon_data_free);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_ngl_icon_library_add (GskNglIconLibrary *self,
|
||||
GdkTexture *key,
|
||||
const GskNglIconData **out_value)
|
||||
{
|
||||
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
|
||||
cairo_surface_t *surface;
|
||||
GskNglIconData *icon_data;
|
||||
guint8 *pixel_data;
|
||||
guint8 *surface_data;
|
||||
guint8 *free_data = NULL;
|
||||
guint gl_format;
|
||||
guint gl_type;
|
||||
guint packed_x;
|
||||
guint packed_y;
|
||||
int width;
|
||||
int height;
|
||||
guint texture_id;
|
||||
|
||||
g_assert (GSK_IS_NGL_ICON_LIBRARY (self));
|
||||
g_assert (GDK_IS_TEXTURE (key));
|
||||
g_assert (out_value != NULL);
|
||||
|
||||
width = key->width;
|
||||
height = key->height;
|
||||
|
||||
icon_data = gsk_ngl_texture_library_pack (GSK_NGL_TEXTURE_LIBRARY (self),
|
||||
key,
|
||||
sizeof (GskNglIconData),
|
||||
width, height, 1,
|
||||
&packed_x, &packed_y);
|
||||
icon_data->source_texture = g_object_ref (key);
|
||||
|
||||
/* actually upload the texture */
|
||||
surface = gdk_texture_download_surface (key);
|
||||
surface_data = cairo_image_surface_get_data (surface);
|
||||
gdk_gl_context_push_debug_group_printf (gdk_gl_context_get_current (),
|
||||
"Uploading texture");
|
||||
|
||||
if (gdk_gl_context_get_use_es (gdk_gl_context_get_current ()))
|
||||
{
|
||||
pixel_data = free_data = g_malloc (width * height * 4);
|
||||
gdk_memory_convert (pixel_data, width * 4,
|
||||
GDK_MEMORY_R8G8B8A8_PREMULTIPLIED,
|
||||
surface_data, cairo_image_surface_get_stride (surface),
|
||||
GDK_MEMORY_DEFAULT, width, height);
|
||||
gl_format = GL_RGBA;
|
||||
gl_type = GL_UNSIGNED_BYTE;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixel_data = surface_data;
|
||||
gl_format = GL_BGRA;
|
||||
gl_type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
}
|
||||
|
||||
texture_id = GSK_NGL_TEXTURE_ATLAS_ENTRY_TEXTURE (icon_data);
|
||||
|
||||
glBindTexture (GL_TEXTURE_2D, texture_id);
|
||||
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x + 1, packed_y + 1,
|
||||
width, height,
|
||||
gl_format, gl_type,
|
||||
pixel_data);
|
||||
/* Padding top */
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x + 1, packed_y,
|
||||
width, 1,
|
||||
gl_format, gl_type,
|
||||
pixel_data);
|
||||
/* Padding left */
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x, packed_y + 1,
|
||||
1, height,
|
||||
gl_format, gl_type,
|
||||
pixel_data);
|
||||
/* Padding top left */
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x, packed_y,
|
||||
1, 1,
|
||||
gl_format, gl_type,
|
||||
pixel_data);
|
||||
|
||||
/* Padding right */
|
||||
glPixelStorei (GL_UNPACK_ROW_LENGTH, width);
|
||||
glPixelStorei (GL_UNPACK_SKIP_PIXELS, width - 1);
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x + width + 1, packed_y + 1,
|
||||
1, height,
|
||||
gl_format, gl_type,
|
||||
pixel_data);
|
||||
/* Padding top right */
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x + width + 1, packed_y,
|
||||
1, 1,
|
||||
gl_format, gl_type,
|
||||
pixel_data);
|
||||
/* Padding bottom */
|
||||
glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
|
||||
glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
|
||||
glPixelStorei (GL_UNPACK_SKIP_ROWS, height - 1);
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x + 1, packed_y + 1 + height,
|
||||
width, 1,
|
||||
gl_format, gl_type,
|
||||
pixel_data);
|
||||
/* Padding bottom left */
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x, packed_y + 1 + height,
|
||||
1, 1,
|
||||
gl_format, gl_type,
|
||||
pixel_data);
|
||||
/* Padding bottom right */
|
||||
glPixelStorei (GL_UNPACK_ROW_LENGTH, width);
|
||||
glPixelStorei (GL_UNPACK_SKIP_PIXELS, width - 1);
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x + 1 + width, packed_y + 1 + height,
|
||||
1, 1,
|
||||
gl_format, gl_type,
|
||||
pixel_data);
|
||||
/* Reset this */
|
||||
glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
|
||||
glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
|
||||
glPixelStorei (GL_UNPACK_SKIP_ROWS, 0);
|
||||
|
||||
gdk_gl_context_pop_debug_group (gdk_gl_context_get_current ());
|
||||
|
||||
*out_value = icon_data;
|
||||
|
||||
cairo_surface_destroy (surface);
|
||||
g_free (free_data);
|
||||
|
||||
GSK_NGL_TEXTURE_LIBRARY (self)->driver->command_queue->n_uploads++;
|
||||
|
||||
if (gdk_profiler_is_running ())
|
||||
{
|
||||
char message[64];
|
||||
g_snprintf (message, sizeof message, "Size %dx%d", width, height);
|
||||
gdk_profiler_add_mark (start_time, GDK_PROFILER_CURRENT_TIME-start_time, "Upload Icon", message);
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/* gskngliconlibraryprivate.h
|
||||
*
|
||||
* Copyright 2020 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* 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 program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#ifndef __GSK_NGL_ICON_LIBRARY_PRIVATE_H__
|
||||
#define __GSK_NGL_ICON_LIBRARY_PRIVATE_H__
|
||||
|
||||
#include <pango/pango.h>
|
||||
|
||||
#include "gskngltexturelibraryprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GSK_TYPE_GL_ICON_LIBRARY (gsk_ngl_icon_library_get_type())
|
||||
|
||||
typedef struct _GskNglIconData
|
||||
{
|
||||
GskNglTextureAtlasEntry entry;
|
||||
GdkTexture *source_texture;
|
||||
} GskNglIconData;
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GskNglIconLibrary, gsk_ngl_icon_library, GSK, NGL_ICON_LIBRARY, GskNglTextureLibrary)
|
||||
|
||||
GskNglIconLibrary *gsk_ngl_icon_library_new (GskNglDriver *driver);
|
||||
void gsk_ngl_icon_library_add (GskNglIconLibrary *self,
|
||||
GdkTexture *key,
|
||||
const GskNglIconData **out_value);
|
||||
|
||||
static inline void
|
||||
gsk_ngl_icon_library_lookup_or_add (GskNglIconLibrary *self,
|
||||
GdkTexture *key,
|
||||
const GskNglIconData **out_value)
|
||||
{
|
||||
GskNglTextureAtlasEntry *entry;
|
||||
|
||||
if G_LIKELY (gsk_ngl_texture_library_lookup ((GskNglTextureLibrary *)self, key, &entry))
|
||||
*out_value = (GskNglIconData *)entry;
|
||||
else
|
||||
gsk_ngl_icon_library_add (self, key, out_value);
|
||||
}
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GSK_NGL_ICON_LIBRARY_PRIVATE_H__ */
|
||||
@@ -1,176 +0,0 @@
|
||||
/* gsknglprogram.c
|
||||
*
|
||||
* Copyright 2020 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* 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 program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gsknglcommandqueueprivate.h"
|
||||
#include "gsknglprogramprivate.h"
|
||||
#include "gskngluniformstateprivate.h"
|
||||
|
||||
G_DEFINE_TYPE (GskNglProgram, gsk_ngl_program, G_TYPE_OBJECT)
|
||||
|
||||
GskNglProgram *
|
||||
gsk_ngl_program_new (GskNglDriver *driver,
|
||||
const char *name,
|
||||
int program_id)
|
||||
{
|
||||
GskNglProgram *self;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_NGL_DRIVER (driver), NULL);
|
||||
g_return_val_if_fail (program_id >= -1, NULL);
|
||||
|
||||
self = g_object_new (GSK_TYPE_GL_PROGRAM, NULL);
|
||||
self->id = program_id;
|
||||
self->name = g_strdup (name);
|
||||
self->driver = g_object_ref (driver);
|
||||
self->n_uniforms = 0;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_program_finalize (GObject *object)
|
||||
{
|
||||
GskNglProgram *self = (GskNglProgram *)object;
|
||||
|
||||
if (self->id >= 0)
|
||||
g_warning ("Leaking GLSL program %d (%s)",
|
||||
self->id,
|
||||
self->name ? self->name : "");
|
||||
|
||||
g_clear_pointer (&self->name, g_free);
|
||||
g_clear_object (&self->driver);
|
||||
|
||||
G_OBJECT_CLASS (gsk_ngl_program_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_program_class_init (GskNglProgramClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = gsk_ngl_program_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_program_init (GskNglProgram *self)
|
||||
{
|
||||
self->id = -1;
|
||||
|
||||
for (guint i = 0; i < G_N_ELEMENTS (self->uniform_locations); i++)
|
||||
self->uniform_locations[i] = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_ngl_program_add_uniform:
|
||||
* @self: a #GskNglProgram
|
||||
* @name: the name of the uniform such as "u_source"
|
||||
* @key: the identifier to use for the uniform
|
||||
*
|
||||
* This method will create a mapping between @key and the location
|
||||
* of the uniform on the GPU. This simplifies calling code to not
|
||||
* need to know where the uniform location is and only register it
|
||||
* when creating the program.
|
||||
*
|
||||
* You might use this with an enum of all your uniforms for the
|
||||
* program and then register each of them like:
|
||||
*
|
||||
* ```
|
||||
* gsk_ngl_program_add_uniform (program, "u_source", UNIFORM_SOURCE);
|
||||
* ```
|
||||
*
|
||||
* That allows you to set values for the program with something
|
||||
* like the following:
|
||||
*
|
||||
* ```
|
||||
* gsk_ngl_program_set_uniform1i (program, UNIFORM_SOURCE, 1);
|
||||
* ```
|
||||
*
|
||||
* Returns: %TRUE if the uniform was found; otherwise %FALSE
|
||||
*/
|
||||
gboolean
|
||||
gsk_ngl_program_add_uniform (GskNglProgram *self,
|
||||
const char *name,
|
||||
guint key)
|
||||
{
|
||||
GLint location;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_NGL_PROGRAM (self), FALSE);
|
||||
g_return_val_if_fail (name != NULL, FALSE);
|
||||
g_return_val_if_fail (key < 1024, FALSE);
|
||||
|
||||
if (-1 == (location = glGetUniformLocation (self->id, name)))
|
||||
return FALSE;
|
||||
|
||||
self->uniform_locations[key] = location;
|
||||
|
||||
if (location >= self->n_uniforms)
|
||||
self->n_uniforms = location + 1;
|
||||
|
||||
#if 0
|
||||
g_print ("program [%d] %s uniform %s at location %d.\n",
|
||||
self->id, self->name, name, location);
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_ngl_program_delete:
|
||||
* @self: a #GskNglProgram
|
||||
*
|
||||
* Deletes the GLSL program.
|
||||
*
|
||||
* You must call gsk_ngl_program_use() before and
|
||||
* gsk_ngl_program_unuse() after this function.
|
||||
*/
|
||||
void
|
||||
gsk_ngl_program_delete (GskNglProgram *self)
|
||||
{
|
||||
g_return_if_fail (GSK_IS_NGL_PROGRAM (self));
|
||||
g_return_if_fail (self->driver->command_queue != NULL);
|
||||
|
||||
gsk_ngl_command_queue_delete_program (self->driver->command_queue, self->id);
|
||||
self->id = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_ngl_program_uniforms_added:
|
||||
* @self: a #GskNglProgram
|
||||
* @has_attachments: if any uniform is for a bind/texture attachment
|
||||
*
|
||||
* This function should be called after all of the uniforms ahve
|
||||
* been added with gsk_ngl_program_add_uniform().
|
||||
*
|
||||
* This function will setup the uniform state so that the program
|
||||
* has fast access to the data buffers without as many lookups at
|
||||
* runtime for comparison data.
|
||||
*/
|
||||
void
|
||||
gsk_ngl_program_uniforms_added (GskNglProgram *self,
|
||||
gboolean has_attachments)
|
||||
{
|
||||
g_return_if_fail (GSK_IS_NGL_PROGRAM (self));
|
||||
g_return_if_fail (self->uniforms == NULL);
|
||||
|
||||
self->uniforms = self->driver->command_queue->uniforms;
|
||||
self->program_info = gsk_ngl_uniform_state_get_program (self->uniforms, self->id, self->n_uniforms);
|
||||
self->program_info->has_attachments = has_attachments;
|
||||
}
|
||||
@@ -1,273 +0,0 @@
|
||||
/* gsknglprogramprivate.h
|
||||
*
|
||||
* Copyright 2020 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* 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 program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#ifndef __GSK_NGL_PROGRAM_PRIVATE_H__
|
||||
#define __GSK_NGL_PROGRAM_PRIVATE_H__
|
||||
|
||||
#include "gskngltypesprivate.h"
|
||||
|
||||
#include "gsknglcommandqueueprivate.h"
|
||||
#include "gskngldriverprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GSK_TYPE_GL_PROGRAM (gsk_ngl_program_get_type())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GskNglProgram, gsk_ngl_program, GSK, NGL_PROGRAM, GObject)
|
||||
|
||||
struct _GskNglProgram
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
int id;
|
||||
char *name;
|
||||
GskNglDriver *driver;
|
||||
|
||||
/* In reality, this is the largest uniform position
|
||||
* as returned after linking so that we can use direct
|
||||
* indexes based on location.
|
||||
*/
|
||||
guint n_uniforms;
|
||||
|
||||
/* Cached pointer to avoid lots of pointer chasing/lookups */
|
||||
GskNglUniformState *uniforms;
|
||||
GskNglUniformProgram *program_info;
|
||||
|
||||
/* For custom programs */
|
||||
int texture_locations[4];
|
||||
int args_locations[8];
|
||||
int size_location;
|
||||
|
||||
/* Static array for key->location transforms */
|
||||
int uniform_locations[32];
|
||||
};
|
||||
|
||||
GskNglProgram *gsk_ngl_program_new (GskNglDriver *driver,
|
||||
const char *name,
|
||||
int program_id);
|
||||
gboolean gsk_ngl_program_add_uniform (GskNglProgram *self,
|
||||
const char *name,
|
||||
guint key);
|
||||
void gsk_ngl_program_uniforms_added (GskNglProgram *self,
|
||||
gboolean has_attachments);
|
||||
void gsk_ngl_program_delete (GskNglProgram *self);
|
||||
|
||||
#define gsk_ngl_program_get_uniform_location(s,k) ((s)->uniform_locations[(k)])
|
||||
|
||||
static inline void
|
||||
gsk_ngl_program_set_uniform1fv (GskNglProgram *self,
|
||||
guint key,
|
||||
guint stamp,
|
||||
guint count,
|
||||
const float *values)
|
||||
{
|
||||
gsk_ngl_uniform_state_set1fv (self->uniforms, self->program_info,
|
||||
gsk_ngl_program_get_uniform_location (self, key),
|
||||
stamp, count, values);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gsk_ngl_program_set_uniform2fv (GskNglProgram *self,
|
||||
guint key,
|
||||
guint stamp,
|
||||
guint count,
|
||||
const float *values)
|
||||
{
|
||||
gsk_ngl_uniform_state_set2fv (self->uniforms, self->program_info,
|
||||
gsk_ngl_program_get_uniform_location (self, key),
|
||||
stamp, count, values);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gsk_ngl_program_set_uniform4fv (GskNglProgram *self,
|
||||
guint key,
|
||||
guint stamp,
|
||||
guint count,
|
||||
const float *values)
|
||||
{
|
||||
gsk_ngl_uniform_state_set4fv (self->uniforms, self->program_info,
|
||||
gsk_ngl_program_get_uniform_location (self, key),
|
||||
stamp, count, values);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gsk_ngl_program_set_uniform_rounded_rect (GskNglProgram *self,
|
||||
guint key,
|
||||
guint stamp,
|
||||
const GskRoundedRect *rounded_rect)
|
||||
{
|
||||
gsk_ngl_uniform_state_set_rounded_rect (self->uniforms, self->program_info,
|
||||
gsk_ngl_program_get_uniform_location (self, key),
|
||||
stamp, rounded_rect);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gsk_ngl_program_set_uniform1i (GskNglProgram *self,
|
||||
guint key,
|
||||
guint stamp,
|
||||
int value0)
|
||||
{
|
||||
gsk_ngl_uniform_state_set1i (self->uniforms,
|
||||
self->program_info,
|
||||
gsk_ngl_program_get_uniform_location (self, key),
|
||||
stamp, value0);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gsk_ngl_program_set_uniform2i (GskNglProgram *self,
|
||||
guint key,
|
||||
guint stamp,
|
||||
int value0,
|
||||
int value1)
|
||||
{
|
||||
gsk_ngl_uniform_state_set2i (self->uniforms,
|
||||
self->program_info,
|
||||
gsk_ngl_program_get_uniform_location (self, key),
|
||||
stamp, value0, value1);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gsk_ngl_program_set_uniform3i (GskNglProgram *self,
|
||||
guint key,
|
||||
guint stamp,
|
||||
int value0,
|
||||
int value1,
|
||||
int value2)
|
||||
{
|
||||
gsk_ngl_uniform_state_set3i (self->uniforms,
|
||||
self->program_info,
|
||||
gsk_ngl_program_get_uniform_location (self, key),
|
||||
stamp, value0, value1, value2);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gsk_ngl_program_set_uniform4i (GskNglProgram *self,
|
||||
guint key,
|
||||
guint stamp,
|
||||
int value0,
|
||||
int value1,
|
||||
int value2,
|
||||
int value3)
|
||||
{
|
||||
gsk_ngl_uniform_state_set4i (self->uniforms,
|
||||
self->program_info,
|
||||
gsk_ngl_program_get_uniform_location (self, key),
|
||||
stamp, value0, value1, value2, value3);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gsk_ngl_program_set_uniform1f (GskNglProgram *self,
|
||||
guint key,
|
||||
guint stamp,
|
||||
float value0)
|
||||
{
|
||||
gsk_ngl_uniform_state_set1f (self->uniforms,
|
||||
self->program_info,
|
||||
gsk_ngl_program_get_uniform_location (self, key),
|
||||
stamp, value0);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gsk_ngl_program_set_uniform2f (GskNglProgram *self,
|
||||
guint key,
|
||||
guint stamp,
|
||||
float value0,
|
||||
float value1)
|
||||
{
|
||||
gsk_ngl_uniform_state_set2f (self->uniforms,
|
||||
self->program_info,
|
||||
gsk_ngl_program_get_uniform_location (self, key),
|
||||
stamp, value0, value1);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gsk_ngl_program_set_uniform3f (GskNglProgram *self,
|
||||
guint key,
|
||||
guint stamp,
|
||||
float value0,
|
||||
float value1,
|
||||
float value2)
|
||||
{
|
||||
gsk_ngl_uniform_state_set3f (self->uniforms,
|
||||
self->program_info,
|
||||
gsk_ngl_program_get_uniform_location (self, key),
|
||||
stamp, value0, value1, value2);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gsk_ngl_program_set_uniform4f (GskNglProgram *self,
|
||||
guint key,
|
||||
guint stamp,
|
||||
float value0,
|
||||
float value1,
|
||||
float value2,
|
||||
float value3)
|
||||
{
|
||||
gsk_ngl_uniform_state_set4f (self->uniforms,
|
||||
self->program_info,
|
||||
gsk_ngl_program_get_uniform_location (self, key),
|
||||
stamp, value0, value1, value2, value3);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gsk_ngl_program_set_uniform_color (GskNglProgram *self,
|
||||
guint key,
|
||||
guint stamp,
|
||||
const GdkRGBA *color)
|
||||
{
|
||||
gsk_ngl_uniform_state_set_color (self->uniforms,
|
||||
self->program_info,
|
||||
gsk_ngl_program_get_uniform_location (self, key),
|
||||
stamp, color);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gsk_ngl_program_set_uniform_texture (GskNglProgram *self,
|
||||
guint key,
|
||||
guint stamp,
|
||||
GLenum texture_target,
|
||||
GLenum texture_slot,
|
||||
guint texture_id)
|
||||
{
|
||||
gsk_ngl_attachment_state_bind_texture (self->driver->command_queue->attachments,
|
||||
texture_target,
|
||||
texture_slot,
|
||||
texture_id);
|
||||
gsk_ngl_uniform_state_set_texture (self->uniforms,
|
||||
self->program_info,
|
||||
gsk_ngl_program_get_uniform_location (self, key),
|
||||
stamp, texture_slot);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gsk_ngl_program_set_uniform_matrix (GskNglProgram *self,
|
||||
guint key,
|
||||
guint stamp,
|
||||
const graphene_matrix_t *matrix)
|
||||
{
|
||||
gsk_ngl_uniform_state_set_matrix (self->uniforms,
|
||||
self->program_info,
|
||||
gsk_ngl_program_get_uniform_location (self, key),
|
||||
stamp, matrix);
|
||||
}
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GSK_NGL_PROGRAM_PRIVATE_H__ */
|
||||
@@ -1,83 +0,0 @@
|
||||
GSK_NGL_DEFINE_PROGRAM (blend,
|
||||
"/org/gtk/libgsk/glsl/blend.glsl",
|
||||
GSK_NGL_ADD_UNIFORM (1, BLEND_SOURCE2, u_source2)
|
||||
GSK_NGL_ADD_UNIFORM (2, BLEND_MODE, u_mode))
|
||||
|
||||
GSK_NGL_DEFINE_PROGRAM (blit,
|
||||
"/org/gtk/libgsk/glsl/blit.glsl",
|
||||
GSK_NGL_NO_UNIFORMS)
|
||||
|
||||
GSK_NGL_DEFINE_PROGRAM (blur,
|
||||
"/org/gtk/libgsk/glsl/blur.glsl",
|
||||
GSK_NGL_ADD_UNIFORM (1, BLUR_RADIUS, u_blur_radius)
|
||||
GSK_NGL_ADD_UNIFORM (2, BLUR_SIZE, u_blur_size)
|
||||
GSK_NGL_ADD_UNIFORM (3, BLUR_DIR, u_blur_dir))
|
||||
|
||||
GSK_NGL_DEFINE_PROGRAM (border,
|
||||
"/org/gtk/libgsk/glsl/border.glsl",
|
||||
GSK_NGL_ADD_UNIFORM (1, BORDER_COLOR, u_color)
|
||||
GSK_NGL_ADD_UNIFORM (2, BORDER_WIDTHS, u_widths)
|
||||
GSK_NGL_ADD_UNIFORM (3, BORDER_OUTLINE_RECT, u_outline_rect))
|
||||
|
||||
GSK_NGL_DEFINE_PROGRAM (color,
|
||||
"/org/gtk/libgsk/glsl/color.glsl",
|
||||
GSK_NGL_ADD_UNIFORM (1, COLOR_COLOR, u_color))
|
||||
|
||||
GSK_NGL_DEFINE_PROGRAM (coloring,
|
||||
"/org/gtk/libgsk/glsl/coloring.glsl",
|
||||
GSK_NGL_ADD_UNIFORM (1, COLORING_COLOR, u_color))
|
||||
|
||||
GSK_NGL_DEFINE_PROGRAM (color_matrix,
|
||||
"/org/gtk/libgsk/glsl/color_matrix.glsl",
|
||||
GSK_NGL_ADD_UNIFORM (1, COLOR_MATRIX_COLOR_MATRIX, u_color_matrix)
|
||||
GSK_NGL_ADD_UNIFORM (2, COLOR_MATRIX_COLOR_OFFSET, u_color_offset))
|
||||
|
||||
GSK_NGL_DEFINE_PROGRAM (conic_gradient,
|
||||
"/org/gtk/libgsk/glsl/conic_gradient.glsl",
|
||||
GSK_NGL_ADD_UNIFORM (1, CONIC_GRADIENT_COLOR_STOPS, u_color_stops)
|
||||
GSK_NGL_ADD_UNIFORM (2, CONIC_GRADIENT_NUM_COLOR_STOPS, u_num_color_stops)
|
||||
GSK_NGL_ADD_UNIFORM (3, CONIC_GRADIENT_GEOMETRY, u_geometry))
|
||||
|
||||
GSK_NGL_DEFINE_PROGRAM (cross_fade,
|
||||
"/org/gtk/libgsk/glsl/cross_fade.glsl",
|
||||
GSK_NGL_ADD_UNIFORM (1, CROSS_FADE_PROGRESS, u_progress)
|
||||
GSK_NGL_ADD_UNIFORM (2, CROSS_FADE_SOURCE2, u_source2))
|
||||
|
||||
GSK_NGL_DEFINE_PROGRAM (inset_shadow,
|
||||
"/org/gtk/libgsk/glsl/inset_shadow.glsl",
|
||||
GSK_NGL_ADD_UNIFORM (1, INSET_SHADOW_COLOR, u_color)
|
||||
GSK_NGL_ADD_UNIFORM (2, INSET_SHADOW_SPREAD, u_spread)
|
||||
GSK_NGL_ADD_UNIFORM (3, INSET_SHADOW_OFFSET, u_offset)
|
||||
GSK_NGL_ADD_UNIFORM (4, INSET_SHADOW_OUTLINE_RECT, u_outline_rect))
|
||||
|
||||
GSK_NGL_DEFINE_PROGRAM (linear_gradient,
|
||||
"/org/gtk/libgsk/glsl/linear_gradient.glsl",
|
||||
GSK_NGL_ADD_UNIFORM (1, LINEAR_GRADIENT_COLOR_STOPS, u_color_stops)
|
||||
GSK_NGL_ADD_UNIFORM (2, LINEAR_GRADIENT_NUM_COLOR_STOPS, u_num_color_stops)
|
||||
GSK_NGL_ADD_UNIFORM (3, LINEAR_GRADIENT_POINTS, u_points)
|
||||
GSK_NGL_ADD_UNIFORM (4, LINEAR_GRADIENT_REPEAT, u_repeat))
|
||||
|
||||
GSK_NGL_DEFINE_PROGRAM (outset_shadow,
|
||||
"/org/gtk/libgsk/glsl/outset_shadow.glsl",
|
||||
GSK_NGL_ADD_UNIFORM (1, OUTSET_SHADOW_COLOR, u_color)
|
||||
GSK_NGL_ADD_UNIFORM (2, OUTSET_SHADOW_OUTLINE_RECT, u_outline_rect))
|
||||
|
||||
GSK_NGL_DEFINE_PROGRAM (radial_gradient,
|
||||
"/org/gtk/libgsk/glsl/radial_gradient.glsl",
|
||||
GSK_NGL_ADD_UNIFORM (1, RADIAL_GRADIENT_COLOR_STOPS, u_color_stops)
|
||||
GSK_NGL_ADD_UNIFORM (2, RADIAL_GRADIENT_NUM_COLOR_STOPS, u_num_color_stops)
|
||||
GSK_NGL_ADD_UNIFORM (3, RADIAL_GRADIENT_REPEAT, u_repeat)
|
||||
GSK_NGL_ADD_UNIFORM (4, RADIAL_GRADIENT_RANGE, u_range)
|
||||
GSK_NGL_ADD_UNIFORM (5, RADIAL_GRADIENT_GEOMETRY, u_geometry))
|
||||
|
||||
GSK_NGL_DEFINE_PROGRAM (repeat,
|
||||
"/org/gtk/libgsk/glsl/repeat.glsl",
|
||||
GSK_NGL_ADD_UNIFORM (1, REPEAT_CHILD_BOUNDS, u_child_bounds)
|
||||
GSK_NGL_ADD_UNIFORM (2, REPEAT_TEXTURE_RECT, u_texture_rect))
|
||||
|
||||
GSK_NGL_DEFINE_PROGRAM (unblurred_outset_shadow,
|
||||
"/org/gtk/libgsk/glsl/unblurred_outset_shadow.glsl",
|
||||
GSK_NGL_ADD_UNIFORM (1, UNBLURRED_OUTSET_SHADOW_COLOR, u_color)
|
||||
GSK_NGL_ADD_UNIFORM (2, UNBLURRED_OUTSET_SHADOW_SPREAD, u_spread)
|
||||
GSK_NGL_ADD_UNIFORM (3, UNBLURRED_OUTSET_SHADOW_OFFSET, u_offset)
|
||||
GSK_NGL_ADD_UNIFORM (4, UNBLURRED_OUTSET_SHADOW_OUTLINE_RECT, u_outline_rect))
|
||||
@@ -1,312 +0,0 @@
|
||||
/* gsknglrenderer.c
|
||||
*
|
||||
* Copyright 2020 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* This file 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 file 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 General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gdk/gdkprofilerprivate.h>
|
||||
#include <gdk/gdksurfaceprivate.h>
|
||||
#include <gsk/gskdebugprivate.h>
|
||||
#include <gsk/gskrendererprivate.h>
|
||||
|
||||
#include "gsknglcommandqueueprivate.h"
|
||||
#include "gskngldriverprivate.h"
|
||||
#include "gsknglprogramprivate.h"
|
||||
#include "gsknglrenderjobprivate.h"
|
||||
#include "gsknglrendererprivate.h"
|
||||
|
||||
struct _GskNglRendererClass
|
||||
{
|
||||
GskRendererClass parent_class;
|
||||
};
|
||||
|
||||
struct _GskNglRenderer
|
||||
{
|
||||
GskRenderer parent_instance;
|
||||
|
||||
/* This context is used to swap buffers when we are rendering directly
|
||||
* to a GDK surface. It is also used to locate the shared driver for
|
||||
* the display that we use to drive the command queue.
|
||||
*/
|
||||
GdkGLContext *context;
|
||||
|
||||
/* Our command queue is private to this renderer and talks to the GL
|
||||
* context for our target surface. This ensure that framebuffer 0 matches
|
||||
* the surface we care about. Since the context is shared with other
|
||||
* contexts from other renderers on the display, texture atlases,
|
||||
* programs, and other objects are available to them all.
|
||||
*/
|
||||
GskNglCommandQueue *command_queue;
|
||||
|
||||
/* The driver manages our program state and command queues. It also
|
||||
* deals with caching textures, shaders, shadows, glyph, and icon
|
||||
* caches through various helpers.
|
||||
*/
|
||||
GskNglDriver *driver;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GskNglRenderer, gsk_ngl_renderer, GSK_TYPE_RENDERER)
|
||||
|
||||
GskRenderer *
|
||||
gsk_ngl_renderer_new (void)
|
||||
{
|
||||
return g_object_new (GSK_TYPE_NGL_RENDERER, NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gsk_ngl_renderer_realize (GskRenderer *renderer,
|
||||
GdkSurface *surface,
|
||||
GError **error)
|
||||
{
|
||||
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
|
||||
GskNglRenderer *self = (GskNglRenderer *)renderer;
|
||||
GdkGLContext *context = NULL;
|
||||
GdkGLContext *shared_context;
|
||||
GskNglDriver *driver = NULL;
|
||||
gboolean ret = FALSE;
|
||||
gboolean debug_shaders = FALSE;
|
||||
|
||||
g_assert (GSK_IS_NGL_RENDERER (self));
|
||||
g_assert (GDK_IS_SURFACE (surface));
|
||||
|
||||
if (self->context != NULL)
|
||||
return TRUE;
|
||||
|
||||
g_assert (self->driver == NULL);
|
||||
g_assert (self->context == NULL);
|
||||
g_assert (self->command_queue == NULL);
|
||||
|
||||
if (!(context = gdk_surface_create_gl_context (surface, error)) ||
|
||||
!gdk_gl_context_realize (context, error))
|
||||
goto failure;
|
||||
|
||||
if (!(shared_context = gdk_surface_get_shared_data_gl_context (surface)))
|
||||
{
|
||||
g_set_error (error,
|
||||
GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||
"Failed to locate shared GL context for driver");
|
||||
goto failure;
|
||||
}
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GSK_RENDERER_DEBUG_CHECK (GSK_RENDERER (self), SHADERS))
|
||||
debug_shaders = TRUE;
|
||||
#endif
|
||||
|
||||
if (!(driver = gsk_ngl_driver_from_shared_context (shared_context, debug_shaders, error)))
|
||||
goto failure;
|
||||
|
||||
self->command_queue = gsk_ngl_driver_create_command_queue (driver, context);
|
||||
self->context = g_steal_pointer (&context);
|
||||
self->driver = g_steal_pointer (&driver);
|
||||
|
||||
gsk_ngl_command_queue_set_profiler (self->command_queue,
|
||||
gsk_renderer_get_profiler (renderer));
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
failure:
|
||||
g_clear_object (&driver);
|
||||
g_clear_object (&context);
|
||||
|
||||
gdk_profiler_end_mark (start_time, "GskNglRenderer realize", NULL);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_renderer_unrealize (GskRenderer *renderer)
|
||||
{
|
||||
GskNglRenderer *self = (GskNglRenderer *)renderer;
|
||||
|
||||
g_assert (GSK_IS_NGL_RENDERER (renderer));
|
||||
|
||||
g_clear_object (&self->driver);
|
||||
g_clear_object (&self->context);
|
||||
g_clear_object (&self->command_queue);
|
||||
}
|
||||
|
||||
static cairo_region_t *
|
||||
get_render_region (GdkSurface *surface,
|
||||
GdkGLContext *context)
|
||||
{
|
||||
const cairo_region_t *damage;
|
||||
GdkRectangle whole_surface;
|
||||
GdkRectangle extents;
|
||||
|
||||
g_assert (GDK_IS_SURFACE (surface));
|
||||
g_assert (GDK_IS_GL_CONTEXT (context));
|
||||
|
||||
whole_surface.x = 0;
|
||||
whole_surface.y = 0;
|
||||
whole_surface.width = gdk_surface_get_width (surface);
|
||||
whole_surface.height = gdk_surface_get_height (surface);
|
||||
|
||||
/* Damage does not have scale factor applied so we can compare it to
|
||||
* @whole_surface which also doesn't have the scale factor applied.
|
||||
*/
|
||||
damage = gdk_draw_context_get_frame_region (GDK_DRAW_CONTEXT (context));
|
||||
|
||||
if (cairo_region_contains_rectangle (damage, &whole_surface) == CAIRO_REGION_OVERLAP_IN)
|
||||
return NULL;
|
||||
|
||||
/* If the extents match the full-scene, do the same as above */
|
||||
cairo_region_get_extents (damage, &extents);
|
||||
if (gdk_rectangle_equal (&extents, &whole_surface))
|
||||
return NULL;
|
||||
|
||||
/* Draw clipped to the bounding-box of the region. */
|
||||
return cairo_region_create_rectangle (&extents);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_renderer_render (GskRenderer *renderer,
|
||||
GskRenderNode *root,
|
||||
const cairo_region_t *update_area)
|
||||
{
|
||||
GskNglRenderer *self = (GskNglRenderer *)renderer;
|
||||
cairo_region_t *render_region;
|
||||
graphene_rect_t viewport;
|
||||
GskNglRenderJob *job;
|
||||
GdkSurface *surface;
|
||||
float scale_factor;
|
||||
|
||||
g_assert (GSK_IS_NGL_RENDERER (renderer));
|
||||
g_assert (root != NULL);
|
||||
|
||||
surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (self->context));
|
||||
scale_factor = gdk_surface_get_scale_factor (surface);
|
||||
|
||||
viewport.origin.x = 0;
|
||||
viewport.origin.y = 0;
|
||||
viewport.size.width = gdk_surface_get_width (surface) * scale_factor;
|
||||
viewport.size.height = gdk_surface_get_height (surface) * scale_factor;
|
||||
|
||||
gdk_gl_context_make_current (self->context);
|
||||
gdk_draw_context_begin_frame (GDK_DRAW_CONTEXT (self->context), update_area);
|
||||
|
||||
/* Must be called *AFTER* gdk_draw_context_begin_frame() */
|
||||
render_region = get_render_region (surface, self->context);
|
||||
|
||||
gsk_ngl_driver_begin_frame (self->driver, self->command_queue);
|
||||
job = gsk_ngl_render_job_new (self->driver, &viewport, scale_factor, render_region, 0);
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GSK_RENDERER_DEBUG_CHECK (GSK_RENDERER (self), FALLBACK))
|
||||
gsk_ngl_render_job_set_debug_fallback (job, TRUE);
|
||||
#endif
|
||||
gsk_ngl_render_job_render (job, root);
|
||||
gsk_ngl_driver_end_frame (self->driver);
|
||||
gsk_ngl_render_job_free (job);
|
||||
|
||||
gdk_gl_context_make_current (self->context);
|
||||
gdk_draw_context_end_frame (GDK_DRAW_CONTEXT (self->context));
|
||||
|
||||
gsk_ngl_driver_after_frame (self->driver);
|
||||
|
||||
cairo_region_destroy (render_region);
|
||||
}
|
||||
|
||||
static GdkTexture *
|
||||
gsk_ngl_renderer_render_texture (GskRenderer *renderer,
|
||||
GskRenderNode *root,
|
||||
const graphene_rect_t *viewport)
|
||||
{
|
||||
GskNglRenderer *self = (GskNglRenderer *)renderer;
|
||||
GskNglRenderTarget *render_target;
|
||||
GskNglRenderJob *job;
|
||||
GdkTexture *texture = NULL;
|
||||
guint texture_id;
|
||||
int width;
|
||||
int height;
|
||||
|
||||
g_assert (GSK_IS_NGL_RENDERER (renderer));
|
||||
g_assert (root != NULL);
|
||||
|
||||
width = ceilf (viewport->size.width);
|
||||
height = ceilf (viewport->size.height);
|
||||
|
||||
if (gsk_ngl_driver_create_render_target (self->driver,
|
||||
width, height,
|
||||
GL_NEAREST, GL_NEAREST,
|
||||
&render_target))
|
||||
{
|
||||
gsk_ngl_driver_begin_frame (self->driver, self->command_queue);
|
||||
job = gsk_ngl_render_job_new (self->driver, viewport, 1, NULL, render_target->framebuffer_id);
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GSK_RENDERER_DEBUG_CHECK (GSK_RENDERER (self), FALLBACK))
|
||||
gsk_ngl_render_job_set_debug_fallback (job, TRUE);
|
||||
#endif
|
||||
gsk_ngl_render_job_render_flipped (job, root);
|
||||
texture_id = gsk_ngl_driver_release_render_target (self->driver, render_target, FALSE);
|
||||
texture = gsk_ngl_driver_create_gdk_texture (self->driver, texture_id);
|
||||
gsk_ngl_driver_end_frame (self->driver);
|
||||
gsk_ngl_render_job_free (job);
|
||||
|
||||
gsk_ngl_driver_after_frame (self->driver);
|
||||
}
|
||||
|
||||
return g_steal_pointer (&texture);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_renderer_dispose (GObject *object)
|
||||
{
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
GskNglRenderer *self = (GskNglRenderer *)object;
|
||||
|
||||
g_assert (self->driver == NULL);
|
||||
#endif
|
||||
|
||||
G_OBJECT_CLASS (gsk_ngl_renderer_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_renderer_class_init (GskNglRendererClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GskRendererClass *renderer_class = GSK_RENDERER_CLASS (klass);
|
||||
|
||||
object_class->dispose = gsk_ngl_renderer_dispose;
|
||||
|
||||
renderer_class->realize = gsk_ngl_renderer_realize;
|
||||
renderer_class->unrealize = gsk_ngl_renderer_unrealize;
|
||||
renderer_class->render = gsk_ngl_renderer_render;
|
||||
renderer_class->render_texture = gsk_ngl_renderer_render_texture;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_renderer_init (GskNglRenderer *self)
|
||||
{
|
||||
}
|
||||
|
||||
gboolean
|
||||
gsk_ngl_renderer_try_compile_gl_shader (GskNglRenderer *renderer,
|
||||
GskGLShader *shader,
|
||||
GError **error)
|
||||
{
|
||||
GskNglProgram *program;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_NGL_RENDERER (renderer), FALSE);
|
||||
g_return_val_if_fail (shader != NULL, FALSE);
|
||||
|
||||
program = gsk_ngl_driver_lookup_shader (renderer->driver, shader, error);
|
||||
|
||||
return program != NULL;
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/* gsknglrenderer.h
|
||||
*
|
||||
* Copyright 2020 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* 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 program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#ifndef __GSK_NGL_RENDERER_H__
|
||||
#define __GSK_NGL_RENDERER_H__
|
||||
|
||||
#include <gsk/gskrenderer.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GSK_TYPE_NGL_RENDERER (gsk_ngl_renderer_get_type())
|
||||
|
||||
#define GSK_NGL_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSK_TYPE_NGL_RENDERER, GskNglRenderer))
|
||||
#define GSK_IS_NGL_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSK_TYPE_NGL_RENDERER))
|
||||
#define GSK_NGL_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSK_TYPE_NGL_RENDERER, GskNglRendererClass))
|
||||
#define GSK_IS_NGL_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSK_TYPE_NGL_RENDERER))
|
||||
#define GSK_NGL_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GSK_TYPE_NGL_RENDERER, GskNglRendererClass))
|
||||
|
||||
typedef struct _GskNglRenderer GskNglRenderer;
|
||||
typedef struct _GskNglRendererClass GskNglRendererClass;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gsk_ngl_renderer_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderer *gsk_ngl_renderer_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GSK_NGL_RENDERER__ */
|
||||
@@ -1,34 +0,0 @@
|
||||
/* gsknglrendererprivate.h
|
||||
*
|
||||
* Copyright 2021 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* 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 program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#ifndef __GSK_NGL_RENDERER_PRIVATE_H__
|
||||
#define __GSK_NGL_RENDERER_PRIVATE_H__
|
||||
|
||||
#include "gsknglrenderer.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
gboolean gsk_ngl_renderer_try_compile_gl_shader (GskNglRenderer *renderer,
|
||||
GskGLShader *shader,
|
||||
GError **error);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GSK_NGL_RENDERER_PRIVATE_H__ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,39 +0,0 @@
|
||||
/* gsknglrenderjobprivate.h
|
||||
*
|
||||
* Copyright 2020 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* 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 program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#ifndef __GSK_NGL_RENDER_JOB_H__
|
||||
#define __GSK_NGL_RENDER_JOB_H__
|
||||
|
||||
#include "gskngltypesprivate.h"
|
||||
|
||||
GskNglRenderJob *gsk_ngl_render_job_new (GskNglDriver *driver,
|
||||
const graphene_rect_t *viewport,
|
||||
float scale_factor,
|
||||
const cairo_region_t *region,
|
||||
guint framebuffer);
|
||||
void gsk_ngl_render_job_free (GskNglRenderJob *job);
|
||||
void gsk_ngl_render_job_render (GskNglRenderJob *job,
|
||||
GskRenderNode *root);
|
||||
void gsk_ngl_render_job_render_flipped (GskNglRenderJob *job,
|
||||
GskRenderNode *root);
|
||||
void gsk_ngl_render_job_set_debug_fallback (GskNglRenderJob *job,
|
||||
gboolean debug_fallback);
|
||||
|
||||
#endif /* __GSK_NGL_RENDER_JOB_H__ */
|
||||
@@ -1,228 +0,0 @@
|
||||
/* gsknglshadowlibrary.c
|
||||
*
|
||||
* Copyright 2020 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* 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 program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "gskngldriverprivate.h"
|
||||
#include "gsknglshadowlibraryprivate.h"
|
||||
|
||||
#define MAX_UNUSED_FRAMES (16 * 5)
|
||||
|
||||
struct _GskNglShadowLibrary
|
||||
{
|
||||
GObject parent_instance;
|
||||
GskNglDriver *driver;
|
||||
GArray *shadows;
|
||||
};
|
||||
|
||||
typedef struct _Shadow
|
||||
{
|
||||
GskRoundedRect outline;
|
||||
float blur_radius;
|
||||
guint texture_id;
|
||||
gint64 last_used_in_frame;
|
||||
} Shadow;
|
||||
|
||||
G_DEFINE_TYPE (GskNglShadowLibrary, gsk_ngl_shadow_library, G_TYPE_OBJECT)
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_DRIVER,
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
static GParamSpec *properties [N_PROPS];
|
||||
|
||||
GskNglShadowLibrary *
|
||||
gsk_ngl_shadow_library_new (GskNglDriver *driver)
|
||||
{
|
||||
g_return_val_if_fail (GSK_IS_NGL_DRIVER (driver), NULL);
|
||||
|
||||
return g_object_new (GSK_TYPE_GL_SHADOW_LIBRARY,
|
||||
"driver", driver,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_shadow_library_dispose (GObject *object)
|
||||
{
|
||||
GskNglShadowLibrary *self = (GskNglShadowLibrary *)object;
|
||||
|
||||
for (guint i = 0; i < self->shadows->len; i++)
|
||||
{
|
||||
const Shadow *shadow = &g_array_index (self->shadows, Shadow, i);
|
||||
gsk_ngl_driver_release_texture_by_id (self->driver, shadow->texture_id);
|
||||
}
|
||||
|
||||
g_clear_pointer (&self->shadows, g_array_unref);
|
||||
g_clear_object (&self->driver);
|
||||
|
||||
G_OBJECT_CLASS (gsk_ngl_shadow_library_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_shadow_library_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GskNglShadowLibrary *self = GSK_NGL_SHADOW_LIBRARY (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_DRIVER:
|
||||
g_value_set_object (value, self->driver);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_shadow_library_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GskNglShadowLibrary *self = GSK_NGL_SHADOW_LIBRARY (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_DRIVER:
|
||||
self->driver = g_value_dup_object (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_shadow_library_class_init (GskNglShadowLibraryClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->dispose = gsk_ngl_shadow_library_dispose;
|
||||
object_class->get_property = gsk_ngl_shadow_library_get_property;
|
||||
object_class->set_property = gsk_ngl_shadow_library_set_property;
|
||||
|
||||
properties [PROP_DRIVER] =
|
||||
g_param_spec_object ("driver",
|
||||
"Driver",
|
||||
"Driver",
|
||||
GSK_TYPE_NGL_DRIVER,
|
||||
(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_shadow_library_init (GskNglShadowLibrary *self)
|
||||
{
|
||||
self->shadows = g_array_new (FALSE, FALSE, sizeof (Shadow));
|
||||
}
|
||||
|
||||
void
|
||||
gsk_ngl_shadow_library_insert (GskNglShadowLibrary *self,
|
||||
const GskRoundedRect *outline,
|
||||
float blur_radius,
|
||||
guint texture_id)
|
||||
{
|
||||
Shadow *shadow;
|
||||
|
||||
g_assert (GSK_IS_NGL_SHADOW_LIBRARY (self));
|
||||
g_assert (outline != NULL);
|
||||
g_assert (texture_id != 0);
|
||||
|
||||
gsk_ngl_driver_mark_texture_permanent (self->driver, texture_id);
|
||||
|
||||
g_array_set_size (self->shadows, self->shadows->len + 1);
|
||||
|
||||
shadow = &g_array_index (self->shadows, Shadow, self->shadows->len - 1);
|
||||
shadow->outline = *outline;
|
||||
shadow->blur_radius = blur_radius;
|
||||
shadow->texture_id = texture_id;
|
||||
shadow->last_used_in_frame = self->driver->current_frame_id;
|
||||
}
|
||||
|
||||
guint
|
||||
gsk_ngl_shadow_library_lookup (GskNglShadowLibrary *self,
|
||||
const GskRoundedRect *outline,
|
||||
float blur_radius)
|
||||
{
|
||||
Shadow *ret = NULL;
|
||||
|
||||
g_assert (GSK_IS_NGL_SHADOW_LIBRARY (self));
|
||||
g_assert (outline != NULL);
|
||||
|
||||
/* Ensure GskRoundedRect is 12 packed floats without padding
|
||||
* so that we can use memcmp instead of float comparisons.
|
||||
*/
|
||||
G_STATIC_ASSERT (sizeof *outline == (sizeof (float) * 12));
|
||||
|
||||
for (guint i = 0; i < self->shadows->len; i++)
|
||||
{
|
||||
Shadow *shadow = &g_array_index (self->shadows, Shadow, i);
|
||||
|
||||
if (blur_radius == shadow->blur_radius &&
|
||||
memcmp (outline, &shadow->outline, sizeof *outline) == 0)
|
||||
{
|
||||
ret = shadow;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ret == NULL)
|
||||
return 0;
|
||||
|
||||
g_assert (ret->texture_id != 0);
|
||||
|
||||
ret->last_used_in_frame = self->driver->current_frame_id;
|
||||
|
||||
return ret->texture_id;
|
||||
}
|
||||
|
||||
void
|
||||
gsk_ngl_shadow_library_begin_frame (GskNglShadowLibrary *self)
|
||||
{
|
||||
gint64 watermark;
|
||||
int i;
|
||||
int p;
|
||||
|
||||
g_return_if_fail (GSK_IS_NGL_SHADOW_LIBRARY (self));
|
||||
|
||||
watermark = self->driver->current_frame_id - MAX_UNUSED_FRAMES;
|
||||
|
||||
for (i = 0, p = self->shadows->len; i < p; i++)
|
||||
{
|
||||
const Shadow *shadow = &g_array_index (self->shadows, Shadow, i);
|
||||
|
||||
if (shadow->last_used_in_frame < watermark)
|
||||
{
|
||||
gsk_ngl_driver_release_texture_by_id (self->driver, shadow->texture_id);
|
||||
g_array_remove_index_fast (self->shadows, i);
|
||||
p--;
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/* gsknglshadowlibraryprivate.h
|
||||
*
|
||||
* Copyright 2020 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* 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 program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#ifndef __GSK_NGL_SHADOW_LIBRARY_PRIVATE_H__
|
||||
#define __GSK_NGL_SHADOW_LIBRARY_PRIVATE_H__
|
||||
|
||||
#include "gskngltexturelibraryprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GSK_TYPE_GL_SHADOW_LIBRARY (gsk_ngl_shadow_library_get_type())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GskNglShadowLibrary, gsk_ngl_shadow_library, GSK, NGL_SHADOW_LIBRARY, GObject)
|
||||
|
||||
GskNglShadowLibrary *gsk_ngl_shadow_library_new (GskNglDriver *driver);
|
||||
void gsk_ngl_shadow_library_begin_frame (GskNglShadowLibrary *self);
|
||||
guint gsk_ngl_shadow_library_lookup (GskNglShadowLibrary *self,
|
||||
const GskRoundedRect *outline,
|
||||
float blur_radius);
|
||||
void gsk_ngl_shadow_library_insert (GskNglShadowLibrary *self,
|
||||
const GskRoundedRect *outline,
|
||||
float blur_radius,
|
||||
guint texture_id);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GSK_NGL_SHADOW_LIBRARY_PRIVATE_H__ */
|
||||
@@ -1,315 +0,0 @@
|
||||
/* gskngltexturelibrary.c
|
||||
*
|
||||
* Copyright 2020 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* 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 program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gsknglcommandqueueprivate.h"
|
||||
#include "gskngldriverprivate.h"
|
||||
#include "gskngltexturelibraryprivate.h"
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE (GskNglTextureLibrary, gsk_ngl_texture_library, G_TYPE_OBJECT)
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_DRIVER,
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
static GParamSpec *properties [N_PROPS];
|
||||
|
||||
static void
|
||||
gsk_ngl_texture_library_constructed (GObject *object)
|
||||
{
|
||||
G_OBJECT_CLASS (gsk_ngl_texture_library_parent_class)->constructed (object);
|
||||
|
||||
g_assert (GSK_NGL_TEXTURE_LIBRARY (object)->hash_table != NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_texture_library_dispose (GObject *object)
|
||||
{
|
||||
GskNglTextureLibrary *self = (GskNglTextureLibrary *)object;
|
||||
|
||||
g_clear_object (&self->driver);
|
||||
|
||||
G_OBJECT_CLASS (gsk_ngl_texture_library_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_texture_library_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GskNglTextureLibrary *self = GSK_NGL_TEXTURE_LIBRARY (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_DRIVER:
|
||||
g_value_set_object (value, self->driver);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_texture_library_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GskNglTextureLibrary *self = GSK_NGL_TEXTURE_LIBRARY (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_DRIVER:
|
||||
self->driver = g_value_dup_object (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_texture_library_class_init (GskNglTextureLibraryClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->constructed = gsk_ngl_texture_library_constructed;
|
||||
object_class->dispose = gsk_ngl_texture_library_dispose;
|
||||
object_class->get_property = gsk_ngl_texture_library_get_property;
|
||||
object_class->set_property = gsk_ngl_texture_library_set_property;
|
||||
|
||||
properties [PROP_DRIVER] =
|
||||
g_param_spec_object ("driver",
|
||||
"Driver",
|
||||
"Driver",
|
||||
GSK_TYPE_NGL_DRIVER,
|
||||
(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_texture_library_init (GskNglTextureLibrary *self)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
gsk_ngl_texture_library_set_funcs (GskNglTextureLibrary *self,
|
||||
GHashFunc hash_func,
|
||||
GEqualFunc equal_func,
|
||||
GDestroyNotify key_destroy,
|
||||
GDestroyNotify value_destroy)
|
||||
{
|
||||
g_return_if_fail (GSK_IS_NGL_TEXTURE_LIBRARY (self));
|
||||
g_return_if_fail (self->hash_table == NULL);
|
||||
|
||||
self->hash_table = g_hash_table_new_full (hash_func, equal_func,
|
||||
key_destroy, value_destroy);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_ngl_texture_library_begin_frame (GskNglTextureLibrary *self)
|
||||
{
|
||||
g_return_if_fail (GSK_IS_NGL_TEXTURE_LIBRARY (self));
|
||||
|
||||
if (GSK_NGL_TEXTURE_LIBRARY_GET_CLASS (self)->begin_frame)
|
||||
GSK_NGL_TEXTURE_LIBRARY_GET_CLASS (self)->begin_frame (self);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_ngl_texture_library_end_frame (GskNglTextureLibrary *self)
|
||||
{
|
||||
g_return_if_fail (GSK_IS_NGL_TEXTURE_LIBRARY (self));
|
||||
|
||||
if (GSK_NGL_TEXTURE_LIBRARY_GET_CLASS (self)->end_frame)
|
||||
GSK_NGL_TEXTURE_LIBRARY_GET_CLASS (self)->end_frame (self);
|
||||
}
|
||||
|
||||
static GskNglTexture *
|
||||
gsk_ngl_texture_library_pack_one (GskNglTextureLibrary *self,
|
||||
guint width,
|
||||
guint height)
|
||||
{
|
||||
GskNglTexture *texture;
|
||||
|
||||
g_assert (GSK_IS_NGL_TEXTURE_LIBRARY (self));
|
||||
|
||||
if (width > self->driver->command_queue->max_texture_size ||
|
||||
height > self->driver->command_queue->max_texture_size)
|
||||
{
|
||||
g_warning ("Clipping requested texture of size %ux%u to maximum allowable size %u.",
|
||||
width, height, self->driver->command_queue->max_texture_size);
|
||||
width = MIN (width, self->driver->command_queue->max_texture_size);
|
||||
height = MIN (height, self->driver->command_queue->max_texture_size);
|
||||
}
|
||||
|
||||
texture = gsk_ngl_driver_create_texture (self->driver, width, height, GL_LINEAR, GL_LINEAR);
|
||||
texture->permanent = TRUE;
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
gsk_ngl_texture_atlas_pack (GskNglTextureAtlas *self,
|
||||
int width,
|
||||
int height,
|
||||
int *out_x,
|
||||
int *out_y)
|
||||
{
|
||||
stbrp_rect rect;
|
||||
|
||||
rect.w = width;
|
||||
rect.h = height;
|
||||
|
||||
stbrp_pack_rects (&self->context, &rect, 1);
|
||||
|
||||
if (rect.was_packed)
|
||||
{
|
||||
*out_x = rect.x;
|
||||
*out_y = rect.y;
|
||||
}
|
||||
|
||||
return rect.was_packed;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_ngl_texture_atlases_pack (GskNglDriver *driver,
|
||||
int width,
|
||||
int height,
|
||||
GskNglTextureAtlas **out_atlas,
|
||||
int *out_x,
|
||||
int *out_y)
|
||||
{
|
||||
GskNglTextureAtlas *atlas = NULL;
|
||||
int x, y;
|
||||
|
||||
for (guint i = 0; i < driver->atlases->len; i++)
|
||||
{
|
||||
atlas = g_ptr_array_index (driver->atlases, i);
|
||||
|
||||
if (gsk_ngl_texture_atlas_pack (atlas, width, height, &x, &y))
|
||||
break;
|
||||
|
||||
atlas = NULL;
|
||||
}
|
||||
|
||||
if (atlas == NULL)
|
||||
{
|
||||
/* No atlas has enough space, so create a new one... */
|
||||
atlas = gsk_ngl_driver_create_atlas (driver);
|
||||
|
||||
/* Pack it onto that one, which surely has enough space... */
|
||||
if (!gsk_ngl_texture_atlas_pack (atlas, width, height, &x, &y))
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
*out_atlas = atlas;
|
||||
*out_x = x;
|
||||
*out_y = y;
|
||||
}
|
||||
|
||||
gpointer
|
||||
gsk_ngl_texture_library_pack (GskNglTextureLibrary *self,
|
||||
gpointer key,
|
||||
gsize valuelen,
|
||||
guint width,
|
||||
guint height,
|
||||
int padding,
|
||||
guint *out_packed_x,
|
||||
guint *out_packed_y)
|
||||
{
|
||||
GskNglTextureAtlasEntry *entry;
|
||||
GskNglTextureAtlas *atlas = NULL;
|
||||
|
||||
g_assert (GSK_IS_NGL_TEXTURE_LIBRARY (self));
|
||||
g_assert (key != NULL);
|
||||
g_assert (valuelen > sizeof (GskNglTextureAtlasEntry));
|
||||
g_assert (out_packed_x != NULL);
|
||||
g_assert (out_packed_y != NULL);
|
||||
|
||||
entry = g_slice_alloc0 (valuelen);
|
||||
entry->n_pixels = width * height;
|
||||
entry->accessed = TRUE;
|
||||
|
||||
/* If our size is invisible then we just want an entry in the
|
||||
* cache for faster lookups, but do not actually spend any texture
|
||||
* allocations on this entry.
|
||||
*/
|
||||
if (width <= 0 && height <= 0)
|
||||
{
|
||||
entry->is_atlased = FALSE;
|
||||
entry->texture = NULL;
|
||||
entry->area.x = 0.0f;
|
||||
entry->area.y = 0.0f;
|
||||
entry->area.x2 = 0.0f;
|
||||
entry->area.y2 = 0.0f;
|
||||
|
||||
*out_packed_x = 0;
|
||||
*out_packed_y = 0;
|
||||
}
|
||||
else if (width <= self->max_entry_size && height <= self->max_entry_size)
|
||||
{
|
||||
int packed_x;
|
||||
int packed_y;
|
||||
|
||||
gsk_ngl_texture_atlases_pack (self->driver,
|
||||
padding + width + padding,
|
||||
padding + height + padding,
|
||||
&atlas,
|
||||
&packed_x,
|
||||
&packed_y);
|
||||
|
||||
entry->atlas = atlas;
|
||||
entry->is_atlased = TRUE;
|
||||
entry->area.x = (float)(packed_x + padding) / atlas->width;
|
||||
entry->area.y = (float)(packed_y + padding) / atlas->height;
|
||||
entry->area.x2 = entry->area.x + (float)width / atlas->width;
|
||||
entry->area.y2 = entry->area.y + (float)height / atlas->height;
|
||||
|
||||
*out_packed_x = packed_x;
|
||||
*out_packed_y = packed_y;
|
||||
}
|
||||
else
|
||||
{
|
||||
GskNglTexture *texture = gsk_ngl_texture_library_pack_one (self,
|
||||
padding + width + padding,
|
||||
padding + height + padding);
|
||||
|
||||
entry->texture = texture;
|
||||
entry->is_atlased = FALSE;
|
||||
entry->accessed = TRUE;
|
||||
entry->area.x = 0.0f;
|
||||
entry->area.y = 0.0f;
|
||||
entry->area.x2 = 1.0f;
|
||||
entry->area.y2 = 1.0f;
|
||||
|
||||
*out_packed_x = padding;
|
||||
*out_packed_y = padding;
|
||||
}
|
||||
|
||||
g_hash_table_insert (self->hash_table, key, entry);
|
||||
|
||||
return entry;
|
||||
}
|
||||
@@ -1,202 +0,0 @@
|
||||
/* gskngltexturelibraryprivate.h
|
||||
*
|
||||
* Copyright 2020 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* This file 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 file 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 General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#ifndef __GSK_NGL_TEXTURE_LIBRARY_PRIVATE_H__
|
||||
#define __GSK_NGL_TEXTURE_LIBRARY_PRIVATE_H__
|
||||
|
||||
#include "gskngltypesprivate.h"
|
||||
#include "gskngltexturepoolprivate.h"
|
||||
|
||||
#include "../gl/stb_rect_pack.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GSK_TYPE_GL_TEXTURE_LIBRARY (gsk_ngl_texture_library_get_type ())
|
||||
#define GSK_NGL_TEXTURE_LIBRARY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSK_TYPE_GL_TEXTURE_LIBRARY, GskNglTextureLibrary))
|
||||
#define GSK_IS_NGL_TEXTURE_LIBRARY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSK_TYPE_GL_TEXTURE_LIBRARY))
|
||||
#define GSK_NGL_TEXTURE_LIBRARY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSK_TYPE_GL_TEXTURE_LIBRARY, GskNglTextureLibraryClass))
|
||||
#define GSK_IS_NGL_TEXTURE_LIBRARY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSK_TYPE_GL_TEXTURE_LIBRARY))
|
||||
#define GSK_NGL_TEXTURE_LIBRARY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GSK_TYPE_GL_TEXTURE_LIBRARY, GskNglTextureLibraryClass))
|
||||
|
||||
typedef struct _GskNglTextureAtlas
|
||||
{
|
||||
struct stbrp_context context;
|
||||
struct stbrp_node *nodes;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
|
||||
guint texture_id;
|
||||
|
||||
/* Pixels of rects that have been used at some point,
|
||||
* But are now unused.
|
||||
*/
|
||||
int unused_pixels;
|
||||
|
||||
void *user_data;
|
||||
} GskNglTextureAtlas;
|
||||
|
||||
typedef struct _GskNglTextureAtlasEntry
|
||||
{
|
||||
/* A backreference to either the atlas or texture containing
|
||||
* the contents of the atlas entry. For larger items, no atlas
|
||||
* is used and instead a direct texture.
|
||||
*/
|
||||
union {
|
||||
GskNglTextureAtlas *atlas;
|
||||
GskNglTexture *texture;
|
||||
};
|
||||
|
||||
/* The area within the atlas translated to 0..1 bounds */
|
||||
struct {
|
||||
float x;
|
||||
float y;
|
||||
float x2;
|
||||
float y2;
|
||||
} area;
|
||||
|
||||
/* Number of pixels in the entry, used to calculate usage
|
||||
* of an atlas while processing.
|
||||
*/
|
||||
guint n_pixels : 29;
|
||||
|
||||
/* If entry has marked pixels as used in the atlas this frame */
|
||||
guint used : 1;
|
||||
|
||||
/* If entry was accessed this frame */
|
||||
guint accessed : 1;
|
||||
|
||||
/* When true, backref is an atlas, otherwise texture */
|
||||
guint is_atlased : 1;
|
||||
|
||||
/* Suffix data that is per-library specific. gpointer used to
|
||||
* guarantee the alignment for the entries using this.
|
||||
*/
|
||||
gpointer data[0];
|
||||
} GskNglTextureAtlasEntry;
|
||||
|
||||
typedef struct _GskNglTextureLibrary
|
||||
{
|
||||
GObject parent_instance;
|
||||
GskNglDriver *driver;
|
||||
GHashTable *hash_table;
|
||||
guint max_entry_size;
|
||||
} GskNglTextureLibrary;
|
||||
|
||||
typedef struct _GskNglTextureLibraryClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
void (*begin_frame) (GskNglTextureLibrary *library);
|
||||
void (*end_frame) (GskNglTextureLibrary *library);
|
||||
} GskNglTextureLibraryClass;
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GskNglTextureLibrary, g_object_unref)
|
||||
|
||||
GType gsk_ngl_texture_library_get_type (void) G_GNUC_CONST;
|
||||
void gsk_ngl_texture_library_set_funcs (GskNglTextureLibrary *self,
|
||||
GHashFunc hash_func,
|
||||
GEqualFunc equal_func,
|
||||
GDestroyNotify key_destroy,
|
||||
GDestroyNotify value_destroy);
|
||||
void gsk_ngl_texture_library_begin_frame (GskNglTextureLibrary *self);
|
||||
void gsk_ngl_texture_library_end_frame (GskNglTextureLibrary *self);
|
||||
gpointer gsk_ngl_texture_library_pack (GskNglTextureLibrary *self,
|
||||
gpointer key,
|
||||
gsize valuelen,
|
||||
guint width,
|
||||
guint height,
|
||||
int padding,
|
||||
guint *out_packed_x,
|
||||
guint *out_packed_y);
|
||||
|
||||
static inline void
|
||||
gsk_ngl_texture_atlas_mark_unused (GskNglTextureAtlas *self,
|
||||
int n_pixels)
|
||||
{
|
||||
self->unused_pixels += n_pixels;
|
||||
}
|
||||
|
||||
static inline void
|
||||
gsk_ngl_texture_atlas_mark_used (GskNglTextureAtlas *self,
|
||||
int n_pixels)
|
||||
{
|
||||
self->unused_pixels -= n_pixels;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
gsk_ngl_texture_library_lookup (GskNglTextureLibrary *self,
|
||||
gconstpointer key,
|
||||
GskNglTextureAtlasEntry **out_entry)
|
||||
{
|
||||
GskNglTextureAtlasEntry *entry = g_hash_table_lookup (self->hash_table, key);
|
||||
|
||||
if G_LIKELY (entry != NULL && entry->accessed && entry->used)
|
||||
{
|
||||
*out_entry = entry;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (entry != NULL)
|
||||
{
|
||||
if (!entry->used && entry->is_atlased)
|
||||
{
|
||||
g_assert (entry->atlas != NULL);
|
||||
gsk_ngl_texture_atlas_mark_used (entry->atlas, entry->n_pixels);
|
||||
entry->used = TRUE;
|
||||
}
|
||||
|
||||
entry->accessed = TRUE;
|
||||
*out_entry = entry;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static inline guint
|
||||
GSK_NGL_TEXTURE_ATLAS_ENTRY_TEXTURE (gconstpointer d)
|
||||
{
|
||||
const GskNglTextureAtlasEntry *e = d;
|
||||
|
||||
return e->is_atlased ? e->atlas->texture_id
|
||||
: e->texture ? e->texture->texture_id : 0;
|
||||
}
|
||||
|
||||
static inline double
|
||||
gsk_ngl_texture_atlas_get_unused_ratio (const GskNglTextureAtlas *self)
|
||||
{
|
||||
if (self->unused_pixels > 0)
|
||||
return (double)(self->unused_pixels) / (double)(self->width * self->height);
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
gsk_ngl_texture_library_can_cache (GskNglTextureLibrary *self,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
g_assert (self->max_entry_size > 0);
|
||||
return width <= self->max_entry_size && height <= self->max_entry_size;
|
||||
}
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GSK_NGL_TEXTURE_LIBRARY_PRIVATE_H__ */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user