Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0f2bce941a | |||
| 0a7fb26909 |
+5
-15
@@ -222,7 +222,7 @@ macos:
|
||||
-Dcpp_std=c++11
|
||||
-Dpixman:tests=disabled
|
||||
-Dlibjpeg-turbo:simd=disabled
|
||||
-Dbuild-demos=false
|
||||
-Ddemos=false
|
||||
-Dbuild-tests=false
|
||||
-Dbuild-examples=false
|
||||
-Dbuild-testsuite=false
|
||||
@@ -385,27 +385,17 @@ asan-build:
|
||||
tags: [ asan ]
|
||||
stage: analysis
|
||||
needs: []
|
||||
when: manual
|
||||
variables:
|
||||
script:
|
||||
- export PATH="$HOME/.local/bin:$PATH"
|
||||
- CC=clang meson setup
|
||||
--buildtype=debugoptimized
|
||||
-Db_sanitize=address
|
||||
-Db_lundef=false
|
||||
-Dbuild-demos=false
|
||||
-Dbuild-tests=false
|
||||
-Dbuild-examples=false
|
||||
-Dintrospection=disabled
|
||||
-Df16c=disabled
|
||||
_build
|
||||
- CC=clang meson setup --buildtype=debugoptimized -Db_sanitize=address -Db_lundef=false -Dintrospection=disabled -Df16c=disabled _build
|
||||
- ninja -C _build
|
||||
- .gitlab-ci/run-tests.sh _build wayland
|
||||
- .gitlab-ci/run-tests.sh _build wayland_gles
|
||||
- .gitlab-ci/run-tests.sh _build x11
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
- "${CI_PROJECT_DIR}/_build/meson-logs"
|
||||
- _build/meson-logs
|
||||
allow_failure: true
|
||||
|
||||
reference:
|
||||
image: $FEDORA_IMAGE
|
||||
|
||||
@@ -9,7 +9,7 @@ backend=$2
|
||||
multiplier=${MESON_TEST_TIMEOUT_MULTIPLIER:-1}
|
||||
|
||||
# Ignore memory leaks lower in dependencies
|
||||
export LSAN_OPTIONS=suppressions=$srcdir/lsan.supp:print_suppressions=0:detect_leaks=0:allocator_may_return_null=1
|
||||
export LSAN_OPTIONS=suppressions=$srcdir/lsan.supp:print_suppressions=0:verbosity=1:log_threads=1
|
||||
export G_SLICE=always-malloc
|
||||
|
||||
case "${backend}" in
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
Overview of Changes in 4.11.4, xx-xx-xxxx
|
||||
=========================================
|
||||
|
||||
Overview of Changes in 4.11.3, 05-06-2023
|
||||
Overview of Changes in 4.11.3, xx-xx-xxxx
|
||||
=========================================
|
||||
|
||||
* GtkGridView:
|
||||
@@ -23,41 +20,22 @@ Overview of Changes in 4.11.3, 05-06-2023
|
||||
* GtkPopoverMenu:
|
||||
- Avoid unnecessary left padding
|
||||
|
||||
* GtkSearchEntry:
|
||||
- Improve size allocation for the clear icon
|
||||
|
||||
* GtkBoxLayout:
|
||||
- Fix a regression from recent baseline work
|
||||
|
||||
* CSS:
|
||||
* Css:
|
||||
- Add new binding-friendly css provider apis
|
||||
|
||||
* GDK:
|
||||
- Support grayscale texture and alpha texture formats
|
||||
for loading and saving to png and tiff, and in GL
|
||||
|
||||
* Theme:
|
||||
- Show focus in the shortcuts window
|
||||
|
||||
* GDK:
|
||||
- Support grayscale and alpha texture formats for loading
|
||||
and saving to png and tiff, and in GL
|
||||
- Fix some regressions in GL context initialization
|
||||
|
||||
* GSK:
|
||||
- Support grayscale and alpha texture formats in the GL renderer
|
||||
- Support straight alpha textures in the GL renderer
|
||||
- Many improvements to the experimental Vulkan renderer
|
||||
* Tests:
|
||||
- Improve test coverage
|
||||
|
||||
* Wayland:
|
||||
- Make exporting surface handles more flexible
|
||||
|
||||
* X11:
|
||||
- Trap XRandr errors
|
||||
- Stop using passive grabs during DND
|
||||
|
||||
* Windows:
|
||||
- Many cleanups and simplifications
|
||||
|
||||
* Tests:
|
||||
- Improve test coverage
|
||||
|
||||
* Build:
|
||||
- Some build options have been renamed:
|
||||
demos -> build-demos
|
||||
@@ -77,7 +55,6 @@ Overview of Changes in 4.11.3, 05-06-2023
|
||||
* Translation updates:
|
||||
Basque
|
||||
Catalan
|
||||
Georgian
|
||||
Russian
|
||||
Turkish
|
||||
|
||||
|
||||
@@ -162,10 +162,6 @@ create_page4 (GtkWidget *assistant)
|
||||
gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), progress_bar, GTK_ASSISTANT_PAGE_PROGRESS);
|
||||
gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), progress_bar, "Applying changes");
|
||||
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (progress_bar),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, "Applying changes",
|
||||
-1);
|
||||
|
||||
/* This prevents the assistant window from being
|
||||
* closed while we're "busy" applying changes.
|
||||
*/
|
||||
|
||||
@@ -49,7 +49,6 @@
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="mnemonic-widget">switch</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
@@ -74,7 +73,6 @@
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="mnemonic-widget">check</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
@@ -112,7 +110,6 @@
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="opacity">0</property>
|
||||
<property name="accessible-role">status</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
@@ -153,11 +150,10 @@
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="mnemonic-widget">scale</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScale" id="scale">
|
||||
<object class="GtkScale">
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="draw-value">0</property>
|
||||
@@ -189,11 +185,10 @@
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="mnemonic-widget">spin</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinButton" id="spin">
|
||||
<object class="GtkSpinButton">
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="adjustment">
|
||||
@@ -222,11 +217,10 @@
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="mnemonic-widget">dropdown</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkDropDown" id="dropdown">
|
||||
<object class="GtkDropDown">
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="model">
|
||||
@@ -258,11 +252,10 @@
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="mnemonic-widget">entry</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="entry">
|
||||
<object class="GtkEntry">
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="placeholder-text">Type here…</property>
|
||||
|
||||
@@ -368,38 +368,6 @@ match_func (MatchObject *obj,
|
||||
g_free (tmp2);
|
||||
}
|
||||
|
||||
static void
|
||||
setup_header (GtkSignalListItemFactory *factory,
|
||||
GObject *list_item,
|
||||
gpointer data)
|
||||
{
|
||||
GtkListHeader *self = GTK_LIST_HEADER (list_item);
|
||||
GtkWidget *child;
|
||||
|
||||
child = gtk_label_new ("");
|
||||
gtk_label_set_xalign (GTK_LABEL (child), 0);
|
||||
gtk_label_set_use_markup (GTK_LABEL (child), TRUE);
|
||||
gtk_widget_set_margin_top (child, 10);
|
||||
gtk_widget_set_margin_bottom (child, 10);
|
||||
|
||||
gtk_list_header_set_child (self, child);
|
||||
}
|
||||
|
||||
static void
|
||||
bind_header (GtkSignalListItemFactory *factory,
|
||||
GObject *list_item,
|
||||
gpointer data)
|
||||
{
|
||||
GtkListHeader *self = GTK_LIST_HEADER (list_item);
|
||||
GtkWidget *child = gtk_list_header_get_child (self);
|
||||
GObject *item = gtk_list_header_get_item (self);
|
||||
|
||||
if (strstr (gtk_string_object_get_string (GTK_STRING_OBJECT (item)), "hour"))
|
||||
gtk_label_set_label (GTK_LABEL (child), "<big><b>Hours</b></big>");
|
||||
else
|
||||
gtk_label_set_label (GTK_LABEL (child), "<big><b>Minutes</b></big>");
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_listview_selections (GtkWidget *do_widget)
|
||||
{
|
||||
@@ -409,12 +377,10 @@ do_listview_selections (GtkWidget *do_widget)
|
||||
GtkExpression *expression;
|
||||
GtkListItemFactory *factory;
|
||||
const char * const times[] = { "1 minute", "2 minutes", "5 minutes", "20 minutes", NULL };
|
||||
const char * const minutes[] = {
|
||||
const char * const many_times[] = {
|
||||
"1 minute", "2 minutes", "5 minutes", "10 minutes", "15 minutes", "20 minutes",
|
||||
"25 minutes", "30 minutes", "35 minutes", "40 minutes", "45 minutes", "50 minutes",
|
||||
"55 minutes", NULL
|
||||
};
|
||||
const char * const hours[] = { "1 hour", "2 hours", "3 hours", "5 hours", "6 hours", "7 hours",
|
||||
"55 minutes", "1 hour", "2 hours", "3 hours", "5 hours", "6 hours", "7 hours",
|
||||
"8 hours", "9 hours", "10 hours", "11 hours", "12 hours", NULL
|
||||
};
|
||||
const char * const device_titles[] = { "Digital Output", "Headphones", "Digital Output", "Analog Output", NULL };
|
||||
@@ -429,10 +395,6 @@ do_listview_selections (GtkWidget *do_widget)
|
||||
|
||||
if (!window)
|
||||
{
|
||||
GtkStringList *minutes_model, *hours_model;
|
||||
GListStore *store;
|
||||
GtkFlattenListModel *flat;
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
@@ -460,25 +422,14 @@ do_listview_selections (GtkWidget *do_widget)
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
|
||||
/* A dropdown using an expression to obtain strings */
|
||||
minutes_model = gtk_string_list_new (minutes);
|
||||
hours_model = gtk_string_list_new (hours);
|
||||
store = g_list_store_new (G_TYPE_LIST_MODEL);
|
||||
g_list_store_append (store, minutes_model);
|
||||
g_list_store_append (store, hours_model);
|
||||
g_object_unref (minutes_model);
|
||||
g_object_unref (hours_model);
|
||||
flat = gtk_flatten_list_model_new (G_LIST_MODEL (store));
|
||||
button = drop_down_new_from_strings (many_times, NULL, NULL);
|
||||
gtk_drop_down_set_enable_search (GTK_DROP_DOWN (button), TRUE);
|
||||
expression = gtk_cclosure_expression_new (G_TYPE_STRING, NULL,
|
||||
0, NULL,
|
||||
(GCallback)get_title,
|
||||
NULL, NULL);
|
||||
button = gtk_drop_down_new (G_LIST_MODEL (flat), expression);
|
||||
gtk_drop_down_set_enable_search (GTK_DROP_DOWN (button), TRUE);
|
||||
factory = gtk_signal_list_item_factory_new ();
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (setup_header), NULL);
|
||||
g_signal_connect (factory, "bind", G_CALLBACK (bind_header), NULL);
|
||||
gtk_drop_down_set_header_factory (GTK_DROP_DOWN (button), factory);
|
||||
g_object_unref (factory);
|
||||
gtk_drop_down_set_expression (GTK_DROP_DOWN (button), expression);
|
||||
gtk_expression_unref (expression);
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
|
||||
button = gtk_drop_down_new (NULL, NULL);
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
<property name="child">
|
||||
<object class="GtkInscription">
|
||||
<property name="hexpand">1</property>
|
||||
<property name="nat-chars">25</property>
|
||||
<property name="text-overflow">ellipsize-end</property>
|
||||
<binding name="text">
|
||||
<lookup name="title" type="GtkDemo">
|
||||
<lookup name="item">expander</lookup>
|
||||
|
||||
+24
-38
@@ -18,6 +18,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
@@ -267,9 +268,9 @@ activate_run (GSimpleAction *action,
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
display_image (const char *format,
|
||||
const char *resource,
|
||||
GtkWidget *label)
|
||||
display_image (const char *format,
|
||||
const char *resource,
|
||||
char **label)
|
||||
{
|
||||
GtkWidget *sw, *image;
|
||||
|
||||
@@ -279,17 +280,13 @@ display_image (const char *format,
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), image);
|
||||
|
||||
gtk_accessible_update_relation (GTK_ACCESSIBLE (image),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY, label, NULL,
|
||||
-1);
|
||||
|
||||
return sw;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
display_images (const char *format,
|
||||
const char *resource_dir,
|
||||
GtkWidget *label)
|
||||
display_images (const char *format,
|
||||
const char *resource_dir,
|
||||
char **label)
|
||||
{
|
||||
char **resources;
|
||||
GtkWidget *grid;
|
||||
@@ -314,15 +311,13 @@ display_images (const char *format,
|
||||
{
|
||||
char *resource_name;
|
||||
GtkWidget *box;
|
||||
GtkWidget *image_label;
|
||||
|
||||
resource_name = g_strconcat (resource_dir, "/", resources[i], NULL);
|
||||
|
||||
image_label = gtk_label_new (resources[i]);
|
||||
widget = display_image (NULL, resource_name, image_label);
|
||||
widget = display_image (NULL, resource_name, NULL);
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_box_append (GTK_BOX (box), widget);
|
||||
gtk_box_append (GTK_BOX (box), image_label);
|
||||
gtk_box_append (GTK_BOX (box), gtk_label_new (resources[i]));
|
||||
gtk_flow_box_insert (GTK_FLOW_BOX (grid), box, -1);
|
||||
|
||||
g_free (resource_name);
|
||||
@@ -330,19 +325,15 @@ display_images (const char *format,
|
||||
|
||||
g_strfreev (resources);
|
||||
|
||||
gtk_label_set_label (GTK_LABEL (label), "Images");
|
||||
|
||||
gtk_accessible_update_relation (GTK_ACCESSIBLE (grid),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY, label, NULL,
|
||||
-1);
|
||||
*label = g_strdup ("Images");
|
||||
|
||||
return sw;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
display_text (const char *format,
|
||||
const char *resource,
|
||||
GtkWidget *label)
|
||||
display_text (const char *format,
|
||||
const char *resource,
|
||||
char **label)
|
||||
{
|
||||
GtkTextBuffer *buffer;
|
||||
GtkWidget *textview, *sw;
|
||||
@@ -377,10 +368,6 @@ display_text (const char *format,
|
||||
|
||||
gtk_text_view_set_buffer (GTK_TEXT_VIEW (textview), buffer);
|
||||
|
||||
gtk_accessible_update_relation (GTK_ACCESSIBLE (textview),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY, label, NULL,
|
||||
-1);
|
||||
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
@@ -391,19 +378,15 @@ display_text (const char *format,
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
display_video (const char *format,
|
||||
const char *resource,
|
||||
GtkWidget *label)
|
||||
display_video (const char *format,
|
||||
const char *resource,
|
||||
char **label)
|
||||
{
|
||||
GtkWidget *video;
|
||||
|
||||
video = gtk_video_new_for_resource (resource);
|
||||
gtk_video_set_loop (GTK_VIDEO (video), TRUE);
|
||||
|
||||
gtk_accessible_update_relation (GTK_ACCESSIBLE (video),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY, label, NULL,
|
||||
-1);
|
||||
|
||||
return video;
|
||||
}
|
||||
|
||||
@@ -425,9 +408,9 @@ display_nothing (const char *resource)
|
||||
static struct {
|
||||
const char *extension;
|
||||
const char *format;
|
||||
GtkWidget * (* display_func) (const char *format,
|
||||
const char *resource,
|
||||
GtkWidget *label);
|
||||
GtkWidget * (* display_func) (const char *format,
|
||||
const char *resource,
|
||||
char **label);
|
||||
} display_funcs[] = {
|
||||
{ ".gif", NULL, display_image },
|
||||
{ ".jpg", NULL, display_image },
|
||||
@@ -450,6 +433,7 @@ add_data_tab (const char *demoname)
|
||||
char **resources;
|
||||
GtkWidget *widget, *label;
|
||||
guint i, j;
|
||||
char *label_string;
|
||||
|
||||
resource_dir = g_strconcat ("/", demoname, NULL);
|
||||
resources = g_resources_enumerate_children (resource_dir, 0, NULL);
|
||||
@@ -469,21 +453,23 @@ add_data_tab (const char *demoname)
|
||||
break;
|
||||
}
|
||||
|
||||
label = gtk_label_new (resources[i]);
|
||||
label_string = NULL;
|
||||
|
||||
if (j < G_N_ELEMENTS (display_funcs))
|
||||
widget = display_funcs[j].display_func (display_funcs[j].format,
|
||||
resource_name,
|
||||
label);
|
||||
&label_string);
|
||||
else
|
||||
widget = display_nothing (resource_name);
|
||||
|
||||
label = gtk_label_new (label_string ? label_string : resources[i]);
|
||||
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), widget, label);
|
||||
g_object_set (gtk_notebook_get_page (GTK_NOTEBOOK (notebook), widget),
|
||||
"tab-expand", FALSE,
|
||||
NULL);
|
||||
|
||||
g_free (resource_name);
|
||||
g_free (label_string);
|
||||
}
|
||||
|
||||
g_strfreev (resources);
|
||||
|
||||
@@ -57,17 +57,14 @@
|
||||
<object class="GtkBox">
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="width-request">220</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkSearchBar" id="searchbar">
|
||||
<accessibility>
|
||||
<relation name="labelled-by">search-entry</relation>
|
||||
</accessibility>
|
||||
<property name="key-capture-widget">window</property>
|
||||
<child>
|
||||
<object class="GtkSearchEntry" id="search-entry">
|
||||
<accessibility>
|
||||
<property name="label" translatable="yes">Search</property>
|
||||
<relation name="controls">listview</relation>
|
||||
</accessibility>
|
||||
</object>
|
||||
@@ -79,15 +76,15 @@
|
||||
<style>
|
||||
<class name="sidebar"/>
|
||||
</style>
|
||||
<property name="width-request">120</property>
|
||||
<property name="hscrollbar-policy">never</property>
|
||||
<property name="propagate-natural-width">1</property>
|
||||
<property name="min-content-width">150</property>
|
||||
<property name="vexpand">1</property>
|
||||
<child>
|
||||
<object class="GtkListView" id="listview">
|
||||
<style>
|
||||
<class name="navigation-sidebar"/>
|
||||
</style>
|
||||
<property name="tab-behavior">item</property>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="resource">/ui/main-listitem.ui</property>
|
||||
|
||||
@@ -68,9 +68,6 @@ do_password_entry (GtkWidget *do_widget)
|
||||
"placeholder-text", "Password",
|
||||
"activates-default", TRUE,
|
||||
NULL);
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (entry),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, "Password",
|
||||
-1);
|
||||
g_signal_connect (entry, "notify::text", G_CALLBACK (update_button), NULL);
|
||||
gtk_box_append (GTK_BOX (box), entry);
|
||||
|
||||
@@ -80,9 +77,6 @@ do_password_entry (GtkWidget *do_widget)
|
||||
"placeholder-text", "Confirm",
|
||||
"activates-default", TRUE,
|
||||
NULL);
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (entry2),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, "Confirm",
|
||||
-1);
|
||||
g_signal_connect (entry2, "notify::text", G_CALLBACK (update_button), NULL);
|
||||
gtk_box_append (GTK_BOX (box), entry2);
|
||||
|
||||
|
||||
@@ -189,7 +189,6 @@ do_pickers (GtkWidget *do_widget)
|
||||
gtk_grid_attach (GTK_GRID (table), label, 0, 0, 1, 1);
|
||||
|
||||
picker = gtk_color_dialog_button_new (gtk_color_dialog_new ());
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), picker);
|
||||
gtk_grid_attach (GTK_GRID (table), picker, 1, 0, 1, 1);
|
||||
|
||||
label = gtk_label_new ("Font:");
|
||||
@@ -199,7 +198,6 @@ do_pickers (GtkWidget *do_widget)
|
||||
gtk_grid_attach (GTK_GRID (table), label, 0, 1, 1, 1);
|
||||
|
||||
picker = gtk_font_dialog_button_new (gtk_font_dialog_new ());
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), picker);
|
||||
gtk_grid_attach (GTK_GRID (table), picker, 1, 1, 1, 1);
|
||||
|
||||
label = gtk_label_new ("File:");
|
||||
@@ -210,9 +208,6 @@ do_pickers (GtkWidget *do_widget)
|
||||
|
||||
picker = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||
button = gtk_button_new_from_icon_name ("document-open-symbolic");
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (button),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, "Select File",
|
||||
-1);
|
||||
|
||||
label = gtk_label_new ("None");
|
||||
|
||||
@@ -228,9 +223,6 @@ do_pickers (GtkWidget *do_widget)
|
||||
gtk_box_append (GTK_BOX (picker), button);
|
||||
app_picker = gtk_button_new_from_icon_name ("emblem-system-symbolic");
|
||||
gtk_widget_set_halign (app_picker, GTK_ALIGN_END);
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (app_picker),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, "Open File",
|
||||
-1);
|
||||
gtk_widget_set_sensitive (app_picker, FALSE);
|
||||
g_signal_connect (app_picker, "clicked", G_CALLBACK (open_app), NULL);
|
||||
gtk_box_append (GTK_BOX (picker), app_picker);
|
||||
|
||||
@@ -23,7 +23,7 @@ When it comes to rendering, GTK follows the CSS box model as far as practical.
|
||||
|
||||
The CSS stylesheet that is in use determines the sizes (and appearance) of the
|
||||
margin, border and padding areas for each widget. The size of the content area
|
||||
is determined by GTKs layout algorithm using each widget’s [vfunc@Gtk.Widget.measure]
|
||||
is determined by GTKs layout algorithm using each widgets [vfunc@Gtk.Widget.measure]
|
||||
and [vfunc@Gtk.Widget.size_allocate] vfuncs.
|
||||
|
||||
You can learn more about the CSS box model by reading the
|
||||
@@ -37,11 +37,11 @@ To learn more about where GTK CSS differs from CSS on the web, see the
|
||||
|
||||
The content area in the CSS box model is the region that the widget considers its own.
|
||||
|
||||
The origin of the widget’s coordinate system is the top left corner of the content area,
|
||||
and its size is the widget’s size. The size can be queried with [method@Gtk.Widget.get_width]
|
||||
The origin of the widgets coordinate system is the top left corner of the content area,
|
||||
and its size is the widgets size. The size can be queried with [method@Gtk.Widget.get_width]
|
||||
and [method@Gtk.Widget.get_height]. GTK allows general 3D transformations to position
|
||||
widgets (although most of the time, the transformation will be a simple 2D translation).
|
||||
The transform to go from one widget’s coordinate system to another one can be obtained
|
||||
The transform to go from one widgets coordinate system to another one can be obtained
|
||||
with [method@Gtk.Widget.compute_transform].
|
||||
|
||||
In addition to a size, widgets can optionally have a **_baseline_** to position text on.
|
||||
@@ -55,8 +55,8 @@ or [method@Gtk.Widget.compute_bounds]. These methods can fail (either because th
|
||||
don't share a common ancestor, or because of a singular transformation), and callers need
|
||||
to handle this eventuality.
|
||||
|
||||
Another area that is occasionally relevant are the widget’s **_bounds_**, which is the area
|
||||
that a widget’s rendering is typically confined to (technically, widgets can draw outside
|
||||
Another area that is occasionally relevant are the widgets **_bounds_**, which is the area
|
||||
that a widgets rendering is typically confined to (technically, widgets can draw outside
|
||||
of this area, unless clipping is enforced via the [property@Gtk.Widget:overflow] property).
|
||||
In CSS terms, the bounds of a widget correspond to the border area.
|
||||
|
||||
|
||||
@@ -208,9 +208,6 @@ A number of options affect behavior instead of logging:
|
||||
`nograbs`
|
||||
: Turn off all pointer and keyboard grabs
|
||||
|
||||
`portals`
|
||||
: Force the use of [portals](https://docs.flatpak.org/en/latest/portals.html)
|
||||
|
||||
`gl-disable`
|
||||
: Disable OpenGL support
|
||||
|
||||
|
||||
@@ -204,17 +204,19 @@ you should ensure that:
|
||||
readable and localised action performed when pressed; for instance "Copy",
|
||||
"Paste", "Add layer", or "Remove"
|
||||
|
||||
GTK will try to fill in some information by using ancillary UI control properties,
|
||||
for instance the accessible name will be taken from the label used by the UI control,
|
||||
or from its tooltip, if the `GTK_ACCESSIBLE_PROPERTY_LABEL` property or the
|
||||
`GTK_ACCESSIBLE_RELATION_LABELLED_BY` relation are unset. Similary for the accessible
|
||||
description. Nevertheless, it is good practice and project hygiene to explicitly specify
|
||||
the accessible properties, just like it's good practice to specify tooltips and style classes.
|
||||
GTK will try to fill in some information by using ancillary UI control
|
||||
properties, for instance the accessible label will be taken from the label or
|
||||
placeholder text used by the UI control, or from its tooltip, if the
|
||||
`GTK_ACCESSIBLE_PROPERTY_LABEL` property or the `GTK_ACCESSIBLE_RELATION_LABELLED_BY`
|
||||
relation are unset. Nevertheless, it is good practice and project hygiene
|
||||
to explicitly specify the accessible properties, just like it's good practice
|
||||
to specify tooltips and style classes.
|
||||
|
||||
Application developers using GTK **should** ensure that their UI controls
|
||||
are accessible as part of the development process. The GTK Inspector shows
|
||||
the accessible attributes of each widget, and also provides an overlay that
|
||||
can highlight accessibility issues.
|
||||
are accessible as part of the development process. When using `GtkBuilder`
|
||||
templates and UI definition files, GTK provides a validation tool that
|
||||
verifies that each UI element has a valid role and properties; this tool can
|
||||
be used as part of the application's test suite to avoid regressions.
|
||||
|
||||
## Implementations
|
||||
|
||||
|
||||
@@ -645,9 +645,6 @@ gdk_content_formats_builder_clear (GdkContentFormatsBuilder *builder)
|
||||
{
|
||||
g_clear_pointer (&builder->gtypes, g_slist_free);
|
||||
g_clear_pointer (&builder->mime_types, g_slist_free);
|
||||
|
||||
builder->n_gtypes = 0;
|
||||
builder->n_mime_types = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -383,9 +383,6 @@ gdk_display_dispose (GObject *object)
|
||||
#endif
|
||||
g_clear_error (&priv->gl_error);
|
||||
|
||||
for (GList *l = display->seats; l; l = l->next)
|
||||
g_object_run_dispose (G_OBJECT (l->data));
|
||||
|
||||
G_OBJECT_CLASS (gdk_display_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
|
||||
+6
-2
@@ -173,8 +173,12 @@ static GPrivate thread_current_context = G_PRIVATE_INIT (unref_unmasked);
|
||||
static void
|
||||
gdk_gl_context_clear_old_updated_area (GdkGLContext *context)
|
||||
{
|
||||
for (unsigned int i = 0; i < GDK_GL_MAX_TRACKED_BUFFERS; i++)
|
||||
g_clear_pointer (&context->old_updated_area[i], cairo_region_destroy);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
g_clear_pointer (&context->old_updated_area[i], cairo_region_destroy);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ typedef enum {
|
||||
GDK_SEAT_CAPABILITY_KEYBOARD = 1 << 3,
|
||||
GDK_SEAT_CAPABILITY_TABLET_PAD = 1 << 4,
|
||||
GDK_SEAT_CAPABILITY_ALL_POINTING = (GDK_SEAT_CAPABILITY_POINTER | GDK_SEAT_CAPABILITY_TOUCH | GDK_SEAT_CAPABILITY_TABLET_STYLUS),
|
||||
GDK_SEAT_CAPABILITY_ALL = (GDK_SEAT_CAPABILITY_ALL_POINTING | GDK_SEAT_CAPABILITY_KEYBOARD | GDK_SEAT_CAPABILITY_TABLET_PAD)
|
||||
GDK_SEAT_CAPABILITY_ALL = (GDK_SEAT_CAPABILITY_ALL_POINTING | GDK_SEAT_CAPABILITY_KEYBOARD)
|
||||
} GdkSeatCapabilities;
|
||||
|
||||
struct _GdkSeat
|
||||
|
||||
+10
-15
@@ -1053,30 +1053,26 @@ gdk_display_create_vulkan_device (GdkDisplay *display,
|
||||
|
||||
device_extensions = g_ptr_array_new ();
|
||||
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_SWAPCHAIN_EXTENSION_NAME);
|
||||
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_MAINTENANCE_3_EXTENSION_NAME);
|
||||
g_ptr_array_add (device_extensions, (gpointer) VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
|
||||
if (has_incremental_present)
|
||||
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
|
||||
|
||||
GDK_DISPLAY_DEBUG (display, VULKAN, "Using Vulkan device %u, queue %u", i, j);
|
||||
if (GDK_VK_CHECK (vkCreateDevice, devices[i],
|
||||
&(VkDeviceCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
|
||||
.queueCreateInfoCount = 1,
|
||||
.pQueueCreateInfos = &(VkDeviceQueueCreateInfo) {
|
||||
VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
|
||||
NULL,
|
||||
0,
|
||||
1,
|
||||
&(VkDeviceQueueCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,
|
||||
.queueFamilyIndex = j,
|
||||
.queueCount = 1,
|
||||
.pQueuePriorities = (float []) { 1.0f },
|
||||
},
|
||||
.enabledExtensionCount = device_extensions->len,
|
||||
.ppEnabledExtensionNames = (const char * const *) device_extensions->pdata,
|
||||
.pNext = &(VkPhysicalDeviceDescriptorIndexingFeatures) {
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES,
|
||||
.descriptorBindingPartiallyBound = VK_TRUE,
|
||||
.descriptorBindingVariableDescriptorCount = VK_TRUE,
|
||||
.descriptorBindingSampledImageUpdateAfterBind = VK_TRUE,
|
||||
}
|
||||
0,
|
||||
NULL,
|
||||
device_extensions->len,
|
||||
(const char * const *) device_extensions->pdata
|
||||
},
|
||||
NULL,
|
||||
&display->vk_device) != VK_SUCCESS)
|
||||
@@ -1148,7 +1144,6 @@ gdk_display_create_vulkan_instance (GdkDisplay *display,
|
||||
|
||||
used_extensions = g_ptr_array_new ();
|
||||
g_ptr_array_add (used_extensions, (gpointer) VK_KHR_SURFACE_EXTENSION_NAME);
|
||||
g_ptr_array_add (used_extensions, (gpointer) VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
|
||||
g_ptr_array_add (used_extensions, (gpointer) GDK_DISPLAY_GET_CLASS (display)->vk_extension_name);
|
||||
|
||||
for (i = 0; i < n_extensions; i++)
|
||||
@@ -1220,7 +1215,7 @@ gdk_display_create_vulkan_instance (GdkDisplay *display,
|
||||
.enabledLayerCount = used_layers->len,
|
||||
.ppEnabledLayerNames = (const char * const *) used_layers->pdata,
|
||||
.enabledExtensionCount = used_extensions->len,
|
||||
.ppEnabledExtensionNames = (const char * const *) used_extensions->pdata,
|
||||
.ppEnabledExtensionNames = (const char * const *) used_extensions->pdata
|
||||
},
|
||||
NULL,
|
||||
&display->vk_instance);
|
||||
|
||||
@@ -207,7 +207,7 @@ wl_cursor_create_from_xcursor_images(struct wl_cursor_theme *theme,
|
||||
{
|
||||
char *path;
|
||||
XcursorImages *images;
|
||||
struct wl_cursor *cursor;
|
||||
struct cursor *cursor;
|
||||
struct cursor_image *image;
|
||||
int i, nbytes;
|
||||
unsigned int load_size;
|
||||
@@ -240,16 +240,17 @@ wl_cursor_create_from_xcursor_images(struct wl_cursor_theme *theme,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cursor->images =
|
||||
malloc(images->nimage * sizeof cursor->images[0]);
|
||||
if (!cursor->images) {
|
||||
cursor->cursor.images =
|
||||
malloc(images->nimage * sizeof cursor->cursor.images[0]);
|
||||
if (!cursor->cursor.images) {
|
||||
free(cursor);
|
||||
xcursor_images_destroy (images);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cursor->name = strdup(name);
|
||||
cursor->size = load_size;
|
||||
cursor->cursor.name = strdup(name);
|
||||
cursor->cursor.size = load_size;
|
||||
cursor->total_delay = 0;
|
||||
|
||||
for (i = 0; i < images->nimage; i++) {
|
||||
image = malloc(sizeof *image);
|
||||
@@ -290,13 +291,14 @@ wl_cursor_create_from_xcursor_images(struct wl_cursor_theme *theme,
|
||||
}
|
||||
}
|
||||
}
|
||||
cursor->images[i] = (struct wl_cursor_image *) image;
|
||||
cursor->total_delay += image->image.delay;
|
||||
cursor->cursor.images[i] = (struct wl_cursor_image *) image;
|
||||
}
|
||||
cursor->image_count = i;
|
||||
cursor->cursor.image_count = i;
|
||||
|
||||
if (cursor->image_count == 0) {
|
||||
free(cursor->name);
|
||||
free(cursor->images);
|
||||
if (cursor->cursor.image_count == 0) {
|
||||
free(cursor->cursor.name);
|
||||
free(cursor->cursor.images);
|
||||
free(cursor);
|
||||
xcursor_images_destroy (images);
|
||||
return NULL;
|
||||
@@ -304,7 +306,7 @@ wl_cursor_create_from_xcursor_images(struct wl_cursor_theme *theme,
|
||||
|
||||
xcursor_images_destroy (images);
|
||||
|
||||
return cursor;
|
||||
return &cursor->cursor;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -698,36 +698,7 @@ gdk_wayland_display_dispose (GObject *object)
|
||||
|
||||
g_list_free_full (display_wayland->on_has_globals_closures, g_free);
|
||||
|
||||
g_clear_pointer (&display_wayland->cursor_theme, wl_cursor_theme_destroy);
|
||||
g_clear_pointer (&display_wayland->compositor, wl_compositor_destroy);
|
||||
g_clear_pointer (&display_wayland->xdg_wm_base, xdg_wm_base_destroy);
|
||||
g_clear_pointer (&display_wayland->zxdg_shell_v6, zxdg_shell_v6_destroy);
|
||||
g_clear_pointer (&display_wayland->gtk_shell, gtk_shell1_destroy);
|
||||
g_clear_pointer (&display_wayland->data_device_manager, wl_data_device_manager_destroy);
|
||||
g_clear_pointer (&display_wayland->subcompositor, wl_subcompositor_destroy);
|
||||
g_clear_pointer (&display_wayland->pointer_gestures, zwp_pointer_gestures_v1_destroy);
|
||||
g_clear_pointer (&display_wayland->primary_selection_manager, zwp_primary_selection_device_manager_v1_destroy);
|
||||
g_clear_pointer (&display_wayland->tablet_manager, zwp_tablet_manager_v2_destroy);
|
||||
g_clear_pointer (&display_wayland->xdg_exporter, zxdg_exporter_v1_destroy);
|
||||
g_clear_pointer (&display_wayland->xdg_exporter_v2, zxdg_exporter_v2_destroy);
|
||||
g_clear_pointer (&display_wayland->xdg_importer, zxdg_importer_v1_destroy);
|
||||
g_clear_pointer (&display_wayland->xdg_importer_v2, zxdg_importer_v2_destroy);
|
||||
g_clear_pointer (&display_wayland->keyboard_shortcuts_inhibit, zwp_keyboard_shortcuts_inhibit_manager_v1_destroy);
|
||||
g_clear_pointer (&display_wayland->server_decoration_manager, org_kde_kwin_server_decoration_manager_destroy);
|
||||
g_clear_pointer (&display_wayland->xdg_output_manager, zxdg_output_manager_v1_destroy);
|
||||
g_clear_pointer (&display_wayland->idle_inhibit_manager, zwp_idle_inhibit_manager_v1_destroy);
|
||||
g_clear_pointer (&display_wayland->xdg_activation, xdg_activation_v1_destroy);
|
||||
g_clear_pointer (&display_wayland->fractional_scale, wp_fractional_scale_manager_v1_destroy);
|
||||
g_clear_pointer (&display_wayland->viewporter, wp_viewporter_destroy);
|
||||
|
||||
g_clear_pointer (&display_wayland->shm, wl_shm_destroy);
|
||||
g_clear_pointer (&display_wayland->wl_registry, wl_registry_destroy);
|
||||
|
||||
g_list_store_remove_all (display_wayland->monitors);
|
||||
|
||||
G_OBJECT_CLASS (gdk_wayland_display_parent_class)->dispose (object);
|
||||
|
||||
g_clear_pointer (&display_wayland->wl_display, wl_display_disconnect);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -737,17 +708,22 @@ gdk_wayland_display_finalize (GObject *object)
|
||||
|
||||
_gdk_wayland_display_finalize_cursors (display_wayland);
|
||||
|
||||
g_object_unref (display_wayland->monitors);
|
||||
|
||||
g_free (display_wayland->startup_notification_id);
|
||||
g_free (display_wayland->cursor_theme_name);
|
||||
xkb_context_unref (display_wayland->xkb_context);
|
||||
|
||||
g_clear_pointer (&display_wayland->cursor_theme, wl_cursor_theme_destroy);
|
||||
|
||||
g_list_store_remove_all (display_wayland->monitors);
|
||||
g_object_unref (display_wayland->monitors);
|
||||
|
||||
if (display_wayland->settings)
|
||||
g_hash_table_destroy (display_wayland->settings);
|
||||
|
||||
g_clear_object (&display_wayland->settings_portal);
|
||||
|
||||
wl_display_disconnect (display_wayland->wl_display);
|
||||
|
||||
G_OBJECT_CLASS (gdk_wayland_display_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
|
||||
@@ -98,6 +98,7 @@ struct _GdkWaylandDisplay
|
||||
struct xdg_wm_base *xdg_wm_base;
|
||||
struct zxdg_shell_v6 *zxdg_shell_v6;
|
||||
struct gtk_shell1 *gtk_shell;
|
||||
struct wl_input_device *input_device;
|
||||
struct wl_data_device_manager *data_device_manager;
|
||||
struct wl_subcompositor *subcompositor;
|
||||
struct zwp_pointer_gestures_v1 *pointer_gestures;
|
||||
|
||||
@@ -2143,13 +2143,10 @@ _gdk_wayland_seat_remove_tablet_pad (GdkWaylandSeat *seat,
|
||||
{
|
||||
seat->tablet_pads = g_list_remove (seat->tablet_pads, pad);
|
||||
|
||||
if (pad->device)
|
||||
{
|
||||
gdk_seat_device_removed (GDK_SEAT (seat), pad->device);
|
||||
_gdk_device_set_associated_device (pad->device, NULL);
|
||||
g_object_unref (pad->device);
|
||||
}
|
||||
gdk_seat_device_removed (GDK_SEAT (seat), pad->device);
|
||||
_gdk_device_set_associated_device (pad->device, NULL);
|
||||
|
||||
g_object_unref (pad->device);
|
||||
g_free (pad);
|
||||
}
|
||||
|
||||
@@ -3538,10 +3535,21 @@ static void
|
||||
tablet_pad_handle_done (void *data,
|
||||
struct zwp_tablet_pad_v2 *wp_tablet_pad)
|
||||
{
|
||||
G_GNUC_UNUSED GdkWaylandTabletPadData *pad = data;
|
||||
GdkWaylandTabletPadData *pad = data;
|
||||
|
||||
GDK_SEAT_DEBUG (pad->seat, EVENTS,
|
||||
"tablet pad handle done, pad = %p", wp_tablet_pad);
|
||||
|
||||
pad->device =
|
||||
g_object_new (GDK_TYPE_WAYLAND_DEVICE_PAD,
|
||||
"name", "Pad device",
|
||||
"source", GDK_SOURCE_TABLET_PAD,
|
||||
"display", gdk_seat_get_display (pad->seat),
|
||||
"seat", pad->seat,
|
||||
NULL);
|
||||
|
||||
_gdk_device_set_associated_device (pad->device, GDK_WAYLAND_SEAT (pad->seat)->logical_keyboard);
|
||||
gdk_seat_device_added (GDK_SEAT (pad->seat), pad->device);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -3598,44 +3606,9 @@ tablet_pad_handle_enter (void *data,
|
||||
"tablet pad handle enter, pad = %p, tablet = %p surface = %p",
|
||||
wp_tablet_pad, wp_tablet, surface);
|
||||
|
||||
if (pad->device && pad->current_tablet != tablet)
|
||||
{
|
||||
gdk_seat_device_removed (GDK_SEAT (pad->seat), pad->device);
|
||||
_gdk_device_set_associated_device (pad->device, NULL);
|
||||
g_clear_object (&pad->device);
|
||||
}
|
||||
|
||||
/* Relate pad and tablet */
|
||||
tablet->pads = g_list_prepend (tablet->pads, pad);
|
||||
pad->current_tablet = tablet;
|
||||
|
||||
if (!pad->device)
|
||||
{
|
||||
gchar *name, *vid, *pid;
|
||||
|
||||
name = g_strdup_printf ("%s Pad %d",
|
||||
tablet->name,
|
||||
g_list_index (tablet->pads, pad) + 1);
|
||||
vid = g_strdup_printf ("%.4x", tablet->vid);
|
||||
pid = g_strdup_printf ("%.4x", tablet->pid);
|
||||
|
||||
pad->device =
|
||||
g_object_new (GDK_TYPE_WAYLAND_DEVICE_PAD,
|
||||
"name", name,
|
||||
"vendor-id", vid,
|
||||
"product-id", pid,
|
||||
"source", GDK_SOURCE_TABLET_PAD,
|
||||
"display", gdk_seat_get_display (pad->seat),
|
||||
"seat", pad->seat,
|
||||
NULL);
|
||||
|
||||
_gdk_device_set_associated_device (pad->device, GDK_WAYLAND_SEAT (pad->seat)->logical_keyboard);
|
||||
gdk_seat_device_added (GDK_SEAT (pad->seat), pad->device);
|
||||
|
||||
g_free (name);
|
||||
g_free (vid);
|
||||
g_free (pid);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -3651,7 +3624,10 @@ tablet_pad_handle_leave (void *data,
|
||||
wp_tablet_pad, surface);
|
||||
|
||||
if (pad->current_tablet)
|
||||
pad->current_tablet->pads = g_list_remove (pad->current_tablet->pads, pad);
|
||||
{
|
||||
pad->current_tablet->pads = g_list_remove (pad->current_tablet->pads, pad);
|
||||
pad->current_tablet = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -3899,23 +3875,6 @@ gdk_wayland_pointer_data_finalize (GdkWaylandPointerData *pointer)
|
||||
g_slist_free (pointer->pointer_surface_outputs);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_seat_dispose (GObject *object)
|
||||
{
|
||||
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (object);
|
||||
|
||||
g_clear_pointer (&seat->wl_seat, wl_seat_destroy);
|
||||
g_clear_pointer (&seat->wl_pointer, wl_pointer_destroy);
|
||||
g_clear_pointer (&seat->wl_keyboard, wl_keyboard_destroy);
|
||||
g_clear_pointer (&seat->wl_touch, wl_touch_destroy);
|
||||
g_clear_pointer (&seat->wp_pointer_gesture_swipe, zwp_pointer_gesture_swipe_v1_destroy);
|
||||
g_clear_pointer (&seat->wp_pointer_gesture_pinch, zwp_pointer_gesture_pinch_v1_destroy);
|
||||
g_clear_pointer (&seat->wp_pointer_gesture_hold, zwp_pointer_gesture_hold_v1_destroy);
|
||||
g_clear_pointer (&seat->wp_tablet_seat, zwp_tablet_seat_v2_destroy);
|
||||
|
||||
G_OBJECT_CLASS (gdk_wayland_seat_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_seat_finalize (GObject *object)
|
||||
{
|
||||
@@ -4230,7 +4189,6 @@ gdk_wayland_seat_class_init (GdkWaylandSeatClass *klass)
|
||||
GdkSeatClass *seat_class = GDK_SEAT_CLASS (klass);
|
||||
|
||||
object_class->finalize = gdk_wayland_seat_finalize;
|
||||
object_class->dispose = gdk_wayland_seat_dispose;
|
||||
|
||||
seat_class->get_capabilities = gdk_wayland_seat_get_capabilities;
|
||||
seat_class->grab = gdk_wayland_seat_grab;
|
||||
|
||||
@@ -2734,10 +2734,6 @@ gdk_event_translate (MSG *msg,
|
||||
if (GDK_IS_DRAG_SURFACE (window) ||
|
||||
_gdk_modal_blocked (window))
|
||||
{
|
||||
/* Focus the modal window */
|
||||
GdkSurface *modal_window = _gdk_modal_current ();
|
||||
if (modal_window != NULL)
|
||||
SetFocus (GDK_SURFACE_HWND (modal_window));
|
||||
*ret_valp = MA_NOACTIVATE;
|
||||
return_val = TRUE;
|
||||
}
|
||||
@@ -2748,10 +2744,6 @@ gdk_event_translate (MSG *msg,
|
||||
if (GDK_IS_DRAG_SURFACE (window) ||
|
||||
_gdk_modal_blocked (window))
|
||||
{
|
||||
/* Focus the modal window */
|
||||
GdkSurface *modal_window = _gdk_modal_current ();
|
||||
if (modal_window != NULL)
|
||||
SetFocus (GDK_SURFACE_HWND (modal_window));
|
||||
*ret_valp = PA_NOACTIVATE;
|
||||
return_val = TRUE;
|
||||
}
|
||||
|
||||
@@ -725,7 +725,11 @@ show_window_internal (GdkSurface *window,
|
||||
|
||||
if (center)
|
||||
{
|
||||
GetWindowRect (GDK_SURFACE_HWND (window), &window_rect);
|
||||
window_rect.left = 0;
|
||||
window_rect.top = 0;
|
||||
window_rect.right = window->width * surface->surface_scale;
|
||||
window_rect.bottom = window->height * surface->surface_scale;
|
||||
_gdk_win32_adjust_client_rect (window, &window_rect);
|
||||
|
||||
x = center_on_rect.left + ((center_on_rect.right - center_on_rect.left) - (window_rect.right - window_rect.left)) / 2;
|
||||
y = center_on_rect.top + ((center_on_rect.bottom - center_on_rect.top) - (window_rect.bottom - window_rect.top)) / 2;
|
||||
|
||||
+24
-36
@@ -549,6 +549,8 @@ gdk_x11_context_create_glx_context (GdkGLContext *context,
|
||||
context_attribs [major_idx] = gdk_gl_version_get_major (&supported_versions[j]);
|
||||
context_attribs [minor_idx] = gdk_gl_version_get_minor (&supported_versions[j]);
|
||||
|
||||
gdk_x11_display_error_trap_push (display);
|
||||
|
||||
/* If we don't have access to GLX_ARB_create_context_profile, then
|
||||
* we have to fall back to the old GLX 1.3 API.
|
||||
*/
|
||||
@@ -566,16 +568,19 @@ gdk_x11_context_create_glx_context (GdkGLContext *context,
|
||||
True,
|
||||
context_attribs);
|
||||
|
||||
if (ctx != NULL)
|
||||
if (ctx == NULL)
|
||||
{
|
||||
gdk_x11_display_error_trap_pop_ignored (display);
|
||||
}
|
||||
else if (gdk_x11_display_error_trap_pop (display))
|
||||
{
|
||||
glXDestroyContext (dpy, ctx);
|
||||
ctx = NULL;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (ctx == NULL)
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (display, OPENGL, "Failed to create a GLX context");
|
||||
return 0;
|
||||
}
|
||||
|
||||
GDK_DISPLAY_DEBUG (display, OPENGL,
|
||||
"Realized GLX context[%p], %s, version: %d.%d",
|
||||
context_glx->glx_context,
|
||||
@@ -656,42 +661,25 @@ gdk_x11_gl_context_glx_realize (GdkGLContext *context,
|
||||
if (share != NULL && gdk_gl_context_is_legacy (share))
|
||||
legacy = TRUE;
|
||||
|
||||
gdk_x11_display_error_trap_push (display);
|
||||
|
||||
/* Increase XNextRequest because GLX may fake errors with the last request
|
||||
* and we want the error trap to catch them */
|
||||
XChangeWindowAttributes (GDK_DISPLAY_XDISPLAY (display),
|
||||
GDK_X11_DISPLAY (display)->leader_window,
|
||||
0,
|
||||
(XSetWindowAttributes[1]) { 0, });
|
||||
|
||||
if (preferred_api == GDK_GL_API_GL)
|
||||
{
|
||||
api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, legacy);
|
||||
if (api == 0)
|
||||
api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GLES, legacy);
|
||||
if (api == 0)
|
||||
api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, TRUE);
|
||||
if ((api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, legacy)) ||
|
||||
(api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GLES, legacy)) ||
|
||||
(api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, TRUE)))
|
||||
return api;
|
||||
}
|
||||
else
|
||||
{
|
||||
api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GLES, FALSE);
|
||||
if (api == 0)
|
||||
api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, legacy);
|
||||
if (api == 0)
|
||||
api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, TRUE);
|
||||
if ((api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GLES, FALSE)) ||
|
||||
(api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, legacy)) ||
|
||||
(api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, TRUE)))
|
||||
return api;
|
||||
}
|
||||
|
||||
gdk_x11_display_error_trap_pop_ignored (display);
|
||||
|
||||
if (api == 0)
|
||||
{
|
||||
g_set_error_literal (error, GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||
_("Unable to create a GL context"));
|
||||
}
|
||||
|
||||
return api;
|
||||
g_set_error_literal (error, GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||
_("Unable to create a GL context"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
#undef N_GLX_ATTRS
|
||||
|
||||
@@ -204,7 +204,6 @@ gsk_gl_texture_library_dispose (GObject *object)
|
||||
|
||||
g_clear_pointer (&self->atlases, g_ptr_array_unref);
|
||||
g_clear_object (&self->driver);
|
||||
g_clear_pointer (&self->hash_table, g_hash_table_unref);
|
||||
|
||||
G_OBJECT_CLASS (gsk_gl_texture_library_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
+2
-1
@@ -15,7 +15,8 @@ static const GdkDebugKey gsk_debug_keys[] = {
|
||||
{ "geometry", GSK_DEBUG_GEOMETRY, "Show borders (when using cairo)" },
|
||||
{ "full-redraw", GSK_DEBUG_FULL_REDRAW, "Force full redraws" },
|
||||
{ "sync", GSK_DEBUG_SYNC, "Sync after each frame" },
|
||||
{ "staging", GSK_DEBUG_STAGING, "Use a staging image for texture upload (Vulkan only)" },
|
||||
{ "vulkan-staging-image", GSK_DEBUG_VULKAN_STAGING_IMAGE, "Use a staging image for Vulkan texture upload" },
|
||||
{ "vulkan-staging-buffer", GSK_DEBUG_VULKAN_STAGING_BUFFER, "Use a staging buffer for Vulkan texture upload" }
|
||||
};
|
||||
|
||||
static guint gsk_debug_flags;
|
||||
|
||||
@@ -18,7 +18,8 @@ typedef enum {
|
||||
GSK_DEBUG_GEOMETRY = 1 << 9,
|
||||
GSK_DEBUG_FULL_REDRAW = 1 << 10,
|
||||
GSK_DEBUG_SYNC = 1 << 11,
|
||||
GSK_DEBUG_STAGING = 1 << 12
|
||||
GSK_DEBUG_VULKAN_STAGING_IMAGE = 1 << 12,
|
||||
GSK_DEBUG_VULKAN_STAGING_BUFFER = 1 << 13
|
||||
} GskDebugFlags;
|
||||
|
||||
#define GSK_DEBUG_ANY ((1 << 13) - 1)
|
||||
|
||||
@@ -372,8 +372,6 @@ gsk_renderer_render_texture (GskRenderer *renderer,
|
||||
gsk_render_node_get_bounds (root, &real_viewport);
|
||||
viewport = &real_viewport;
|
||||
}
|
||||
g_return_val_if_fail (viewport->size.width > 0, NULL);
|
||||
g_return_val_if_fail (viewport->size.height > 0, NULL);
|
||||
|
||||
texture = GSK_RENDERER_GET_CLASS (renderer)->render_texture (renderer, root, viewport);
|
||||
|
||||
|
||||
+12
-17
@@ -3956,29 +3956,27 @@ gsk_repeat_node_draw (GskRenderNode *node,
|
||||
cairo_pattern_t *pattern;
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *surface_cr;
|
||||
double scale_x, scale_y, width, height;
|
||||
cairo_matrix_t matrix;
|
||||
|
||||
cairo_get_matrix (cr, &matrix);
|
||||
width = ceil (self->child_bounds.size.width * (ABS (matrix.xx) + ABS (matrix.yx)));
|
||||
height = ceil (self->child_bounds.size.height * (ABS (matrix.xy) + ABS (matrix.yy)));
|
||||
surface = cairo_surface_create_similar (cairo_get_target (cr),
|
||||
CAIRO_CONTENT_COLOR_ALPHA,
|
||||
width, height);
|
||||
cairo_surface_get_device_scale (surface, &scale_x, &scale_y);
|
||||
scale_x *= width / self->child_bounds.size.width;
|
||||
scale_y *= height / self->child_bounds.size.height;
|
||||
cairo_surface_set_device_scale (surface, scale_x, scale_y);
|
||||
cairo_surface_set_device_offset (surface,
|
||||
- self->child_bounds.origin.x * scale_x,
|
||||
- self->child_bounds.origin.y * scale_y);
|
||||
|
||||
ceilf (self->child_bounds.size.width),
|
||||
ceilf (self->child_bounds.size.height));
|
||||
surface_cr = cairo_create (surface);
|
||||
cairo_translate (surface_cr,
|
||||
- self->child_bounds.origin.x,
|
||||
- self->child_bounds.origin.y);
|
||||
gsk_render_node_draw (self->child, surface_cr);
|
||||
cairo_destroy (surface_cr);
|
||||
|
||||
pattern = cairo_pattern_create_for_surface (surface);
|
||||
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
|
||||
cairo_pattern_set_matrix (pattern,
|
||||
&(cairo_matrix_t) {
|
||||
.xx = 1.0,
|
||||
.yy = 1.0,
|
||||
.x0 = - self->child_bounds.origin.x,
|
||||
.y0 = - self->child_bounds.origin.y
|
||||
});
|
||||
cairo_set_source (cr, pattern);
|
||||
cairo_pattern_destroy (pattern);
|
||||
cairo_surface_destroy (surface);
|
||||
@@ -5638,12 +5636,9 @@ static void
|
||||
gsk_mask_node_finalize (GskRenderNode *node)
|
||||
{
|
||||
GskMaskNode *self = (GskMaskNode *) node;
|
||||
GskRenderNodeClass *parent_class = g_type_class_peek (g_type_parent (GSK_TYPE_MASK_NODE));
|
||||
|
||||
gsk_render_node_unref (self->source);
|
||||
gsk_render_node_unref (self->mask);
|
||||
|
||||
parent_class->finalize (node);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
+4
-133
@@ -689,134 +689,6 @@ gsk_rounded_rect_intersect_with_rect (const GskRoundedRect *self,
|
||||
return GSK_INTERSECTION_NONEMPTY;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
check_nonintersecting_corner (const GskRoundedRect *out,
|
||||
const GskRoundedRect *in,
|
||||
GskCorner corner,
|
||||
float diff_x,
|
||||
float diff_y,
|
||||
GskRoundedRect *result)
|
||||
{
|
||||
g_assert (diff_x >= 0);
|
||||
g_assert (diff_y >= 0);
|
||||
|
||||
if (out->corner[corner].width < diff_x ||
|
||||
out->corner[corner].height < diff_y ||
|
||||
(out->corner[corner].width <= in->corner[corner].width + diff_x &&
|
||||
out->corner[corner].height <= in->corner[corner].height + diff_y))
|
||||
{
|
||||
result->corner[corner] = in->corner[corner];
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (diff_x > 0 || diff_y > 0)
|
||||
return FALSE;
|
||||
|
||||
if (out->corner[corner].width > in->corner[corner].width &&
|
||||
out->corner[corner].height > in->corner[corner].height)
|
||||
{
|
||||
result->corner[corner] = out->corner[corner];
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* a is outside in x direction, b is outside in y direction */
|
||||
static gboolean
|
||||
check_intersecting_corner (const GskRoundedRect *a,
|
||||
const GskRoundedRect *b,
|
||||
GskCorner corner,
|
||||
float diff_x,
|
||||
float diff_y,
|
||||
GskRoundedRect *result)
|
||||
{
|
||||
g_assert (diff_x > 0);
|
||||
g_assert (diff_y > 0);
|
||||
|
||||
if (diff_x < a->corner[corner].width ||
|
||||
diff_x > a->bounds.size.width - a->corner[corner].width - a->corner[OPPOSITE_CORNER_X (corner)].width ||
|
||||
diff_y < b->corner[corner].height ||
|
||||
diff_y > b->bounds.size.height - b->corner[corner].height - b->corner[OPPOSITE_CORNER_Y (corner)].height)
|
||||
return FALSE;
|
||||
|
||||
result->corner[corner] = GRAPHENE_SIZE_INIT (0, 0);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
check_corner (const GskRoundedRect *a,
|
||||
const GskRoundedRect *b,
|
||||
GskCorner corner,
|
||||
float diff_x,
|
||||
float diff_y,
|
||||
GskRoundedRect *result)
|
||||
{
|
||||
if (diff_x >= 0)
|
||||
{
|
||||
if (diff_y >= 0)
|
||||
{
|
||||
return check_nonintersecting_corner (a, b, corner, diff_x, diff_y, result);
|
||||
}
|
||||
else if (diff_x == 0)
|
||||
{
|
||||
return check_nonintersecting_corner (b, a, corner, 0, - diff_y, result);
|
||||
}
|
||||
else
|
||||
{
|
||||
return check_intersecting_corner (a, b, corner, diff_x, - diff_y, result);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (diff_y <= 0)
|
||||
{
|
||||
return check_nonintersecting_corner (b, a, corner, - diff_x, - diff_y, result);
|
||||
}
|
||||
else
|
||||
{
|
||||
return check_intersecting_corner (b, a, corner, - diff_x, diff_y, result);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GskRoundedRectIntersection
|
||||
gsk_rounded_rect_intersection (const GskRoundedRect *a,
|
||||
const GskRoundedRect *b,
|
||||
GskRoundedRect *result)
|
||||
{
|
||||
float top, left, bottom, right;
|
||||
|
||||
if (!graphene_rect_intersection (&a->bounds, &b->bounds, &result->bounds))
|
||||
return GSK_INTERSECTION_EMPTY;
|
||||
|
||||
left = b->bounds.origin.x - a->bounds.origin.x;
|
||||
top = b->bounds.origin.y - a->bounds.origin.y;
|
||||
right = a->bounds.origin.x + a->bounds.size.width - b->bounds.origin.x - b->bounds.size.width;
|
||||
bottom = a->bounds.origin.y + a->bounds.size.height - b->bounds.origin.y - b->bounds.size.height;
|
||||
|
||||
if (check_corner (a, b,
|
||||
GSK_CORNER_TOP_LEFT,
|
||||
left, top,
|
||||
result) &&
|
||||
check_corner (a, b,
|
||||
GSK_CORNER_TOP_RIGHT,
|
||||
right, top,
|
||||
result) &&
|
||||
check_corner (a, b,
|
||||
GSK_CORNER_BOTTOM_LEFT,
|
||||
left, bottom,
|
||||
result) &&
|
||||
check_corner (a, b,
|
||||
GSK_CORNER_BOTTOM_RIGHT,
|
||||
right, bottom,
|
||||
result))
|
||||
return GSK_INTERSECTION_NONEMPTY;
|
||||
|
||||
return GSK_INTERSECTION_NOT_REPRESENTABLE;
|
||||
}
|
||||
|
||||
static void
|
||||
append_arc (cairo_t *cr, double angle1, double angle2, gboolean negative)
|
||||
{
|
||||
@@ -894,14 +766,13 @@ gsk_rounded_rect_path (const GskRoundedRect *self,
|
||||
* only look at the last vec4 if they have to.
|
||||
*/
|
||||
void
|
||||
gsk_rounded_rect_to_float (const GskRoundedRect *self,
|
||||
const graphene_point_t *offset,
|
||||
float rect[12])
|
||||
gsk_rounded_rect_to_float (const GskRoundedRect *self,
|
||||
float rect[12])
|
||||
{
|
||||
guint i;
|
||||
|
||||
rect[0] = self->bounds.origin.x + offset->x;
|
||||
rect[1] = self->bounds.origin.y + offset->y;
|
||||
rect[0] = self->bounds.origin.x;
|
||||
rect[1] = self->bounds.origin.y;
|
||||
rect[2] = self->bounds.size.width;
|
||||
rect[3] = self->bounds.size.height;
|
||||
|
||||
|
||||
@@ -6,24 +6,6 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define OPPOSITE_CORNER(corner) ((corner) ^ 2)
|
||||
G_STATIC_ASSERT (OPPOSITE_CORNER (GSK_CORNER_TOP_LEFT) == GSK_CORNER_BOTTOM_RIGHT);
|
||||
G_STATIC_ASSERT (OPPOSITE_CORNER (GSK_CORNER_TOP_RIGHT) == GSK_CORNER_BOTTOM_LEFT);
|
||||
G_STATIC_ASSERT (OPPOSITE_CORNER (GSK_CORNER_BOTTOM_LEFT) == GSK_CORNER_TOP_RIGHT);
|
||||
G_STATIC_ASSERT (OPPOSITE_CORNER (GSK_CORNER_BOTTOM_RIGHT) == GSK_CORNER_TOP_LEFT);
|
||||
|
||||
#define OPPOSITE_CORNER_X(corner) ((corner) ^ 1)
|
||||
G_STATIC_ASSERT (OPPOSITE_CORNER_X (GSK_CORNER_TOP_LEFT) == GSK_CORNER_TOP_RIGHT);
|
||||
G_STATIC_ASSERT (OPPOSITE_CORNER_X (GSK_CORNER_TOP_RIGHT) == GSK_CORNER_TOP_LEFT);
|
||||
G_STATIC_ASSERT (OPPOSITE_CORNER_X (GSK_CORNER_BOTTOM_LEFT) == GSK_CORNER_BOTTOM_RIGHT);
|
||||
G_STATIC_ASSERT (OPPOSITE_CORNER_X (GSK_CORNER_BOTTOM_RIGHT) == GSK_CORNER_BOTTOM_LEFT);
|
||||
|
||||
#define OPPOSITE_CORNER_Y(corner) ((corner) ^ 3)
|
||||
G_STATIC_ASSERT (OPPOSITE_CORNER_Y (GSK_CORNER_TOP_LEFT) == GSK_CORNER_BOTTOM_LEFT);
|
||||
G_STATIC_ASSERT (OPPOSITE_CORNER_Y (GSK_CORNER_TOP_RIGHT) == GSK_CORNER_BOTTOM_RIGHT);
|
||||
G_STATIC_ASSERT (OPPOSITE_CORNER_Y (GSK_CORNER_BOTTOM_LEFT) == GSK_CORNER_TOP_LEFT);
|
||||
G_STATIC_ASSERT (OPPOSITE_CORNER_Y (GSK_CORNER_BOTTOM_RIGHT) == GSK_CORNER_TOP_RIGHT);
|
||||
|
||||
#define GSK_ROUNDED_RECT_INIT_FROM_RECT(_r) \
|
||||
(GskRoundedRect) { .bounds = _r, \
|
||||
.corner = { \
|
||||
@@ -46,7 +28,6 @@ gboolean gsk_rounded_rect_is_circular (const GskRounde
|
||||
void gsk_rounded_rect_path (const GskRoundedRect *self,
|
||||
cairo_t *cr);
|
||||
void gsk_rounded_rect_to_float (const GskRoundedRect *self,
|
||||
const graphene_point_t *offset,
|
||||
float rect[12]);
|
||||
|
||||
gboolean gsk_rounded_rect_equal (gconstpointer rect1,
|
||||
@@ -62,9 +43,6 @@ typedef enum {
|
||||
GskRoundedRectIntersection gsk_rounded_rect_intersect_with_rect (const GskRoundedRect *self,
|
||||
const graphene_rect_t *rect,
|
||||
GskRoundedRect *result) G_GNUC_PURE;
|
||||
GskRoundedRectIntersection gsk_rounded_rect_intersection (const GskRoundedRect *a,
|
||||
const GskRoundedRect *b,
|
||||
GskRoundedRect *result);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
@@ -12,12 +12,8 @@ typedef struct _GskVulkanBlendModeInstance GskVulkanBlendModeInstance;
|
||||
struct _GskVulkanBlendModeInstance
|
||||
{
|
||||
float rect[4];
|
||||
float top_rect[4];
|
||||
float bottom_rect[4];
|
||||
float top_tex_rect[4];
|
||||
float bottom_tex_rect[4];
|
||||
guint32 top_tex_id[2];
|
||||
guint32 bottom_tex_id[2];
|
||||
float start_tex_rect[4];
|
||||
float end_tex_rect[4];
|
||||
guint32 blend_mode;
|
||||
};
|
||||
|
||||
@@ -44,42 +40,18 @@ gsk_vulkan_blend_mode_pipeline_get_input_state_create_info (GskVulkanPipeline *s
|
||||
.location = 1,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanBlendModeInstance, top_rect),
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanBlendModeInstance, start_tex_rect),
|
||||
},
|
||||
{
|
||||
.location = 2,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanBlendModeInstance, bottom_rect),
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanBlendModeInstance, end_tex_rect),
|
||||
},
|
||||
{
|
||||
.location = 3,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanBlendModeInstance, top_tex_rect),
|
||||
},
|
||||
{
|
||||
.location = 4,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanBlendModeInstance, bottom_tex_rect),
|
||||
},
|
||||
{
|
||||
.location = 5,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32_UINT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanBlendModeInstance, top_tex_id),
|
||||
},
|
||||
{
|
||||
.location = 6,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32_UINT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanBlendModeInstance, bottom_tex_id),
|
||||
},
|
||||
{
|
||||
.location = 7,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32_UINT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanBlendModeInstance, blend_mode),
|
||||
}
|
||||
};
|
||||
@@ -126,50 +98,37 @@ gsk_vulkan_blend_mode_pipeline_new (GdkVulkanContext *context,
|
||||
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_BLEND_MODE_PIPELINE, context, layout, shader_name, render_pass);
|
||||
}
|
||||
|
||||
gsize
|
||||
gsk_vulkan_blend_mode_pipeline_count_vertex_data (GskVulkanBlendModePipeline *pipeline)
|
||||
{
|
||||
return sizeof (GskVulkanBlendModeInstance);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_vulkan_blend_mode_pipeline_collect_vertex_data (GskVulkanBlendModePipeline *pipeline,
|
||||
guchar *data,
|
||||
guint32 top_tex_id[2],
|
||||
guint32 bottom_tex_id[2],
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *bounds,
|
||||
const graphene_rect_t *top_bounds,
|
||||
const graphene_rect_t *bottom_bounds,
|
||||
const graphene_rect_t *top_tex_rect,
|
||||
const graphene_rect_t *bottom_tex_rect,
|
||||
GskBlendMode blend_mode)
|
||||
guchar *data,
|
||||
const graphene_rect_t *bounds,
|
||||
const graphene_rect_t *start_tex_rect,
|
||||
const graphene_rect_t *end_tex_rect,
|
||||
GskBlendMode blend_mode)
|
||||
{
|
||||
GskVulkanBlendModeInstance *instance = (GskVulkanBlendModeInstance *) data;
|
||||
|
||||
instance->rect[0] = bounds->origin.x + offset->x;
|
||||
instance->rect[1] = bounds->origin.y + offset->y;
|
||||
instance->rect[0] = bounds->origin.x;
|
||||
instance->rect[1] = bounds->origin.y;
|
||||
instance->rect[2] = bounds->size.width;
|
||||
instance->rect[3] = bounds->size.height;
|
||||
|
||||
instance->top_rect[0] = top_bounds->origin.x + offset->x;
|
||||
instance->top_rect[1] = top_bounds->origin.y + offset->y;
|
||||
instance->top_rect[2] = top_bounds->size.width;
|
||||
instance->top_rect[3] = top_bounds->size.height;
|
||||
instance->start_tex_rect[0] = start_tex_rect->origin.x;
|
||||
instance->start_tex_rect[1] = start_tex_rect->origin.y;
|
||||
instance->start_tex_rect[2] = start_tex_rect->size.width;
|
||||
instance->start_tex_rect[3] = start_tex_rect->size.height;
|
||||
|
||||
instance->bottom_rect[0] = bottom_bounds->origin.x + offset->x;
|
||||
instance->bottom_rect[1] = bottom_bounds->origin.y + offset->y;
|
||||
instance->bottom_rect[2] = bottom_bounds->size.width;
|
||||
instance->bottom_rect[3] = bottom_bounds->size.height;
|
||||
instance->end_tex_rect[0] = end_tex_rect->origin.x;
|
||||
instance->end_tex_rect[1] = end_tex_rect->origin.y;
|
||||
instance->end_tex_rect[2] = end_tex_rect->size.width;
|
||||
instance->end_tex_rect[3] = end_tex_rect->size.height;
|
||||
|
||||
instance->top_tex_rect[0] = top_tex_rect->origin.x;
|
||||
instance->top_tex_rect[1] = top_tex_rect->origin.y;
|
||||
instance->top_tex_rect[2] = top_tex_rect->size.width;
|
||||
instance->top_tex_rect[3] = top_tex_rect->size.height;
|
||||
|
||||
instance->bottom_tex_rect[0] = bottom_tex_rect->origin.x;
|
||||
instance->bottom_tex_rect[1] = bottom_tex_rect->origin.y;
|
||||
instance->bottom_tex_rect[2] = bottom_tex_rect->size.width;
|
||||
instance->bottom_tex_rect[3] = bottom_tex_rect->size.height;
|
||||
|
||||
instance->top_tex_id[0] = top_tex_id[0];
|
||||
instance->top_tex_id[1] = top_tex_id[1];
|
||||
instance->bottom_tex_id[0] = bottom_tex_id[0];
|
||||
instance->bottom_tex_id[1] = bottom_tex_id[1];
|
||||
instance->blend_mode = blend_mode;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,16 +18,12 @@ GskVulkanPipeline * gsk_vulkan_blend_mode_pipeline_new (GdkVulka
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass);
|
||||
|
||||
gsize gsk_vulkan_blend_mode_pipeline_count_vertex_data (GskVulkanBlendModePipeline *pipeline);
|
||||
void gsk_vulkan_blend_mode_pipeline_collect_vertex_data (GskVulkanBlendModePipeline *pipeline,
|
||||
guchar *data,
|
||||
guint32 top_tex_id[2],
|
||||
guint32 bottom_tex_id[2],
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *bounds,
|
||||
const graphene_rect_t *top_bounds,
|
||||
const graphene_rect_t *bottom_bounds,
|
||||
const graphene_rect_t *top_tex_rect,
|
||||
const graphene_rect_t *bottom_tex_rect,
|
||||
const graphene_rect_t *start_bounds,
|
||||
const graphene_rect_t *end_bounds,
|
||||
GskBlendMode blend_mode);
|
||||
gsize gsk_vulkan_blend_mode_pipeline_draw (GskVulkanBlendModePipeline *pipeline,
|
||||
VkCommandBuffer command_buffer,
|
||||
|
||||
@@ -14,7 +14,6 @@ struct _GskVulkanBlurInstance
|
||||
float rect[4];
|
||||
float tex_rect[4];
|
||||
float blur_radius;
|
||||
guint32 tex_id[2];
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GskVulkanBlurPipeline, gsk_vulkan_blur_pipeline, GSK_TYPE_VULKAN_PIPELINE)
|
||||
@@ -47,12 +46,6 @@ gsk_vulkan_blur_pipeline_get_input_state_create_info (GskVulkanPipeline *self)
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32_SFLOAT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanBlurInstance, blur_radius),
|
||||
},
|
||||
{
|
||||
.location = 3,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32_UINT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanBlurInstance, tex_id),
|
||||
}
|
||||
};
|
||||
static const VkPipelineVertexInputStateCreateInfo info = {
|
||||
@@ -98,19 +91,23 @@ gsk_vulkan_blur_pipeline_new (GdkVulkanContext *context,
|
||||
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_BLUR_PIPELINE, context, layout, shader_name, render_pass);
|
||||
}
|
||||
|
||||
gsize
|
||||
gsk_vulkan_blur_pipeline_count_vertex_data (GskVulkanBlurPipeline *pipeline)
|
||||
{
|
||||
return sizeof (GskVulkanBlurInstance);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_vulkan_blur_pipeline_collect_vertex_data (GskVulkanBlurPipeline *pipeline,
|
||||
guchar *data,
|
||||
guint32 tex_id[2],
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *rect,
|
||||
const graphene_rect_t *tex_rect,
|
||||
double blur_radius)
|
||||
gsk_vulkan_blur_pipeline_collect_vertex_data (GskVulkanBlurPipeline *pipeline,
|
||||
guchar *data,
|
||||
const graphene_rect_t *rect,
|
||||
const graphene_rect_t *tex_rect,
|
||||
double blur_radius)
|
||||
{
|
||||
GskVulkanBlurInstance *instance = (GskVulkanBlurInstance *) data;
|
||||
|
||||
instance->rect[0] = rect->origin.x + offset->x;
|
||||
instance->rect[1] = rect->origin.y + offset->y;
|
||||
instance->rect[0] = rect->origin.x;
|
||||
instance->rect[1] = rect->origin.y;
|
||||
instance->rect[2] = rect->size.width;
|
||||
instance->rect[3] = rect->size.height;
|
||||
instance->tex_rect[0] = tex_rect->origin.x;
|
||||
@@ -118,8 +115,6 @@ gsk_vulkan_blur_pipeline_collect_vertex_data (GskVulkanBlurPipeline *pipeline,
|
||||
instance->tex_rect[2] = tex_rect->size.width;
|
||||
instance->tex_rect[3] = tex_rect->size.height;
|
||||
instance->blur_radius = blur_radius;
|
||||
instance->tex_id[0] = tex_id[0];
|
||||
instance->tex_id[1] = tex_id[1];
|
||||
}
|
||||
|
||||
gsize
|
||||
|
||||
@@ -17,10 +17,9 @@ GskVulkanPipeline * gsk_vulkan_blur_pipeline_new (GdkVulka
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass);
|
||||
|
||||
gsize gsk_vulkan_blur_pipeline_count_vertex_data (GskVulkanBlurPipeline *pipeline);
|
||||
void gsk_vulkan_blur_pipeline_collect_vertex_data (GskVulkanBlurPipeline *pipeline,
|
||||
guchar *data,
|
||||
guint32 tex_id[2],
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *rect,
|
||||
const graphene_rect_t *tex_rect,
|
||||
double radius);
|
||||
|
||||
@@ -123,10 +123,15 @@ gsk_vulkan_border_pipeline_new (GdkVulkanContext *context,
|
||||
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_BORDER_PIPELINE, context, layout, shader_name, render_pass);
|
||||
}
|
||||
|
||||
gsize
|
||||
gsk_vulkan_border_pipeline_count_vertex_data (GskVulkanBorderPipeline *pipeline)
|
||||
{
|
||||
return sizeof (GskVulkanBorderInstance);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_vulkan_border_pipeline_collect_vertex_data (GskVulkanBorderPipeline *pipeline,
|
||||
guchar *data,
|
||||
const graphene_point_t *offset,
|
||||
const GskRoundedRect *rect,
|
||||
const float widths[4],
|
||||
const GdkRGBA colors[4])
|
||||
@@ -134,7 +139,7 @@ gsk_vulkan_border_pipeline_collect_vertex_data (GskVulkanBorderPipeline *pipelin
|
||||
GskVulkanBorderInstance *instance = (GskVulkanBorderInstance *) data;
|
||||
guint i;
|
||||
|
||||
gsk_rounded_rect_to_float (rect, offset, instance->rect);
|
||||
gsk_rounded_rect_to_float (rect, instance->rect);
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
instance->widths[i] = widths[i];
|
||||
|
||||
@@ -18,9 +18,9 @@ GskVulkanPipeline * gsk_vulkan_border_pipeline_new (GdkVulk
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass);
|
||||
|
||||
gsize gsk_vulkan_border_pipeline_count_vertex_data (GskVulkanBorderPipeline *pipeline);
|
||||
void gsk_vulkan_border_pipeline_collect_vertex_data (GskVulkanBorderPipeline *pipeline,
|
||||
guchar *data,
|
||||
const graphene_point_t *offset,
|
||||
const GskRoundedRect *rect,
|
||||
const float widths[4],
|
||||
const GdkRGBA colors[4]);
|
||||
|
||||
@@ -119,10 +119,15 @@ gsk_vulkan_box_shadow_pipeline_new (GdkVulkanContext *context,
|
||||
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_BOX_SHADOW_PIPELINE, context, layout, shader_name, render_pass);
|
||||
}
|
||||
|
||||
gsize
|
||||
gsk_vulkan_box_shadow_pipeline_count_vertex_data (GskVulkanBoxShadowPipeline *pipeline)
|
||||
{
|
||||
return sizeof (GskVulkanBoxShadowInstance);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_vulkan_box_shadow_pipeline_collect_vertex_data (GskVulkanBoxShadowPipeline *pipeline,
|
||||
guchar *data,
|
||||
const graphene_point_t *offset,
|
||||
const GskRoundedRect *outline,
|
||||
const GdkRGBA *color,
|
||||
float dx,
|
||||
@@ -132,7 +137,7 @@ gsk_vulkan_box_shadow_pipeline_collect_vertex_data (GskVulkanBoxShadowPipeline *
|
||||
{
|
||||
GskVulkanBoxShadowInstance *instance = (GskVulkanBoxShadowInstance *) data;
|
||||
|
||||
gsk_rounded_rect_to_float (outline, offset, instance->outline);
|
||||
gsk_rounded_rect_to_float (outline, instance->outline);
|
||||
instance->color[0] = color->red;
|
||||
instance->color[1] = color->green;
|
||||
instance->color[2] = color->blue;
|
||||
|
||||
@@ -18,9 +18,9 @@ GskVulkanPipeline * gsk_vulkan_box_shadow_pipeline_new (GdkVulk
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass);
|
||||
|
||||
gsize gsk_vulkan_box_shadow_pipeline_count_vertex_data (GskVulkanBoxShadowPipeline *pipeline);
|
||||
void gsk_vulkan_box_shadow_pipeline_collect_vertex_data (GskVulkanBoxShadowPipeline *pipeline,
|
||||
guchar *data,
|
||||
const graphene_point_t *offset,
|
||||
const GskRoundedRect *outline,
|
||||
const GdkRGBA *color,
|
||||
float dx,
|
||||
|
||||
@@ -64,13 +64,6 @@ gsk_vulkan_buffer_new (GdkVulkanContext *context,
|
||||
| VK_BUFFER_USAGE_VERTEX_BUFFER_BIT);
|
||||
}
|
||||
|
||||
GskVulkanBuffer *
|
||||
gsk_vulkan_buffer_new_storage (GdkVulkanContext *context,
|
||||
gsize size)
|
||||
{
|
||||
return gsk_vulkan_buffer_new_internal (context, size, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT);
|
||||
}
|
||||
|
||||
GskVulkanBuffer *
|
||||
gsk_vulkan_buffer_new_staging (GdkVulkanContext *context,
|
||||
gsize size)
|
||||
|
||||
@@ -8,8 +8,6 @@ typedef struct _GskVulkanBuffer GskVulkanBuffer;
|
||||
|
||||
GskVulkanBuffer * gsk_vulkan_buffer_new (GdkVulkanContext *context,
|
||||
gsize size);
|
||||
GskVulkanBuffer * gsk_vulkan_buffer_new_storage (GdkVulkanContext *context,
|
||||
gsize size);
|
||||
GskVulkanBuffer * gsk_vulkan_buffer_new_staging (GdkVulkanContext *context,
|
||||
gsize size);
|
||||
GskVulkanBuffer * gsk_vulkan_buffer_new_download (GdkVulkanContext *context,
|
||||
|
||||
+44
-91
@@ -13,15 +13,7 @@ gsk_vulkan_clip_init_empty (GskVulkanClip *clip,
|
||||
gsk_rounded_rect_init_from_rect (&clip->rect, rect, 0);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_vulkan_clip_init_rect (GskVulkanClip *clip,
|
||||
const graphene_rect_t *rect)
|
||||
{
|
||||
clip->type = GSK_VULKAN_CLIP_RECT;
|
||||
gsk_rounded_rect_init_from_rect (&clip->rect, rect, 0);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
gsk_vulkan_clip_init_copy (GskVulkanClip *self,
|
||||
const GskVulkanClip *src)
|
||||
{
|
||||
@@ -29,30 +21,11 @@ gsk_vulkan_clip_init_copy (GskVulkanClip *self,
|
||||
gsk_rounded_rect_init_copy (&self->rect, &src->rect);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gsk_vulkan_clip_init_after_intersection (GskVulkanClip *self,
|
||||
GskRoundedRectIntersection res)
|
||||
{
|
||||
if (res == GSK_INTERSECTION_NOT_REPRESENTABLE)
|
||||
return FALSE;
|
||||
|
||||
if (res == GSK_INTERSECTION_EMPTY)
|
||||
self->type = GSK_VULKAN_CLIP_ALL_CLIPPED;
|
||||
else if (gsk_rounded_rect_is_rectilinear (&self->rect))
|
||||
self->type = GSK_VULKAN_CLIP_RECT;
|
||||
else
|
||||
self->type = GSK_VULKAN_CLIP_ROUNDED;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gsk_vulkan_clip_intersect_rect (GskVulkanClip *dest,
|
||||
const GskVulkanClip *src,
|
||||
const graphene_rect_t *rect)
|
||||
{
|
||||
GskRoundedRectIntersection res;
|
||||
|
||||
if (graphene_rect_contains_rect (rect, &src->rect.bounds))
|
||||
{
|
||||
gsk_vulkan_clip_init_copy (dest, src);
|
||||
@@ -84,10 +57,22 @@ gsk_vulkan_clip_intersect_rect (GskVulkanClip *dest,
|
||||
dest->type = GSK_VULKAN_CLIP_ALL_CLIPPED;
|
||||
break;
|
||||
|
||||
case GSK_VULKAN_CLIP_ROUNDED_CIRCULAR:
|
||||
case GSK_VULKAN_CLIP_ROUNDED:
|
||||
res = gsk_rounded_rect_intersect_with_rect (&src->rect, rect, &dest->rect);
|
||||
if (!gsk_vulkan_clip_init_after_intersection (dest, res))
|
||||
return FALSE;
|
||||
if (gsk_rounded_rect_contains_rect (&src->rect, rect))
|
||||
{
|
||||
dest->type = GSK_VULKAN_CLIP_RECT;
|
||||
gsk_rounded_rect_init_from_rect (&dest->rect, rect, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* some points of rect are inside src's rounded rect,
|
||||
* some are outside. */
|
||||
/* XXX: If the 2 rects don't intersect on rounded corners,
|
||||
* we could actually compute a new clip here.
|
||||
*/
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -103,8 +88,6 @@ gsk_vulkan_clip_intersect_rounded_rect (GskVulkanClip *dest,
|
||||
const GskVulkanClip *src,
|
||||
const GskRoundedRect *rounded)
|
||||
{
|
||||
GskRoundedRectIntersection res;
|
||||
|
||||
if (gsk_rounded_rect_contains_rect (rounded, &src->rect.bounds))
|
||||
{
|
||||
gsk_vulkan_clip_init_copy (dest, src);
|
||||
@@ -123,21 +106,34 @@ gsk_vulkan_clip_intersect_rounded_rect (GskVulkanClip *dest,
|
||||
break;
|
||||
|
||||
case GSK_VULKAN_CLIP_NONE:
|
||||
dest->type = GSK_VULKAN_CLIP_ROUNDED;
|
||||
dest->type = gsk_rounded_rect_is_circular (rounded) ? GSK_VULKAN_CLIP_ROUNDED_CIRCULAR : GSK_VULKAN_CLIP_ROUNDED;
|
||||
gsk_rounded_rect_init_copy (&dest->rect, rounded);
|
||||
break;
|
||||
|
||||
case GSK_VULKAN_CLIP_RECT:
|
||||
res = gsk_rounded_rect_intersect_with_rect (rounded, &src->rect.bounds, &dest->rect);
|
||||
if (!gsk_vulkan_clip_init_after_intersection (dest, res))
|
||||
return FALSE;
|
||||
break;
|
||||
if (graphene_rect_contains_rect (&src->rect.bounds, &rounded->bounds))
|
||||
{
|
||||
dest->type = gsk_rounded_rect_is_circular (rounded) ? GSK_VULKAN_CLIP_ROUNDED_CIRCULAR : GSK_VULKAN_CLIP_ROUNDED;
|
||||
gsk_rounded_rect_init_copy (&dest->rect, rounded);
|
||||
return TRUE;
|
||||
}
|
||||
/* some points of rect are inside src's rounded rect,
|
||||
* some are outside. */
|
||||
/* XXX: If the 2 rects don't intersect on rounded corners,
|
||||
* we could actually compute a new clip here.
|
||||
*/
|
||||
return FALSE;
|
||||
|
||||
case GSK_VULKAN_CLIP_ROUNDED_CIRCULAR:
|
||||
case GSK_VULKAN_CLIP_ROUNDED:
|
||||
res = gsk_rounded_rect_intersection (&src->rect, rounded, &dest->rect);
|
||||
if (!gsk_vulkan_clip_init_after_intersection (dest, res))
|
||||
return FALSE;
|
||||
break;
|
||||
if (gsk_rounded_rect_contains_rect (&src->rect, &rounded->bounds))
|
||||
{
|
||||
dest->type = gsk_rounded_rect_is_circular (rounded) ? GSK_VULKAN_CLIP_ROUNDED_CIRCULAR : GSK_VULKAN_CLIP_ROUNDED;
|
||||
gsk_rounded_rect_init_copy (&dest->rect, rounded);
|
||||
return TRUE;
|
||||
}
|
||||
/* XXX: Can be improved for the case where one of the rects is a slightly shrunk version of the other */
|
||||
return FALSE;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
@@ -147,19 +143,6 @@ gsk_vulkan_clip_intersect_rounded_rect (GskVulkanClip *dest,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
gsk_vulkan_clip_scale (GskVulkanClip *dest,
|
||||
const GskVulkanClip *src,
|
||||
float scale_x,
|
||||
float scale_y)
|
||||
{
|
||||
dest->type = src->type;
|
||||
gsk_rounded_rect_scale_affine (&dest->rect,
|
||||
&src->rect,
|
||||
1.0f / scale_x, 1.0f / scale_y,
|
||||
0, 0);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gsk_vulkan_clip_transform (GskVulkanClip *dest,
|
||||
const GskVulkanClip *src,
|
||||
@@ -181,6 +164,7 @@ gsk_vulkan_clip_transform (GskVulkanClip *dest,
|
||||
return TRUE;
|
||||
|
||||
case GSK_VULKAN_CLIP_RECT:
|
||||
case GSK_VULKAN_CLIP_ROUNDED_CIRCULAR:
|
||||
case GSK_VULKAN_CLIP_ROUNDED:
|
||||
switch (gsk_transform_get_category (transform))
|
||||
{
|
||||
@@ -236,41 +220,9 @@ gsk_vulkan_clip_transform (GskVulkanClip *dest,
|
||||
}
|
||||
|
||||
gboolean
|
||||
gsk_vulkan_clip_intersects_rect (const GskVulkanClip *self,
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *rect)
|
||||
gsk_vulkan_clip_contains_rect (const GskVulkanClip *self,
|
||||
const graphene_rect_t *rect)
|
||||
{
|
||||
graphene_rect_t r = *rect;
|
||||
r.origin.x += offset->x;
|
||||
r.origin.y += offset->y;
|
||||
|
||||
switch (self->type)
|
||||
{
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
case GSK_VULKAN_CLIP_ALL_CLIPPED:
|
||||
return FALSE;
|
||||
|
||||
case GSK_VULKAN_CLIP_NONE:
|
||||
return r.size.width > 0 && r.size.height > 0;
|
||||
|
||||
case GSK_VULKAN_CLIP_RECT:
|
||||
return graphene_rect_intersection (&self->rect.bounds, &r, NULL);
|
||||
|
||||
case GSK_VULKAN_CLIP_ROUNDED:
|
||||
return gsk_rounded_rect_intersects_rect (&self->rect, &r);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gsk_vulkan_clip_contains_rect (const GskVulkanClip *self,
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *rect)
|
||||
{
|
||||
graphene_rect_t r = *rect;
|
||||
r.origin.x += offset->x;
|
||||
r.origin.y += offset->y;
|
||||
|
||||
switch (self->type)
|
||||
{
|
||||
default:
|
||||
@@ -282,9 +234,10 @@ gsk_vulkan_clip_contains_rect (const GskVulkanClip *self,
|
||||
return TRUE;
|
||||
|
||||
case GSK_VULKAN_CLIP_RECT:
|
||||
return graphene_rect_contains_rect (&self->rect.bounds, &r);
|
||||
return graphene_rect_contains_rect (&self->rect.bounds, rect);
|
||||
|
||||
case GSK_VULKAN_CLIP_ROUNDED_CIRCULAR:
|
||||
case GSK_VULKAN_CLIP_ROUNDED:
|
||||
return gsk_rounded_rect_contains_rect (&self->rect, &r);
|
||||
return gsk_rounded_rect_contains_rect (&self->rect, rect);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,10 @@ typedef enum {
|
||||
GSK_VULKAN_CLIP_NONE,
|
||||
/* The clip is a rectangular area */
|
||||
GSK_VULKAN_CLIP_RECT,
|
||||
/* The clip is a rounded rectangle, and for every corner
|
||||
* corner.width == corner.height is true
|
||||
*/
|
||||
GSK_VULKAN_CLIP_ROUNDED_CIRCULAR,
|
||||
/* The clip is a rounded rectangle */
|
||||
GSK_VULKAN_CLIP_ROUNDED
|
||||
} GskVulkanClipComplexity;
|
||||
@@ -32,10 +36,6 @@ struct _GskVulkanClip
|
||||
|
||||
void gsk_vulkan_clip_init_empty (GskVulkanClip *clip,
|
||||
const graphene_rect_t *rect);
|
||||
void gsk_vulkan_clip_init_copy (GskVulkanClip *self,
|
||||
const GskVulkanClip *src);
|
||||
void gsk_vulkan_clip_init_rect (GskVulkanClip *clip,
|
||||
const graphene_rect_t *rect);
|
||||
|
||||
gboolean gsk_vulkan_clip_intersect_rect (GskVulkanClip *dest,
|
||||
const GskVulkanClip *src,
|
||||
@@ -43,20 +43,12 @@ gboolean gsk_vulkan_clip_intersect_rect (GskVulk
|
||||
gboolean gsk_vulkan_clip_intersect_rounded_rect (GskVulkanClip *dest,
|
||||
const GskVulkanClip *src,
|
||||
const GskRoundedRect *rounded) G_GNUC_WARN_UNUSED_RESULT;
|
||||
void gsk_vulkan_clip_scale (GskVulkanClip *dest,
|
||||
const GskVulkanClip *src,
|
||||
float scale_x,
|
||||
float scale_y);
|
||||
gboolean gsk_vulkan_clip_transform (GskVulkanClip *dest,
|
||||
const GskVulkanClip *src,
|
||||
GskTransform *transform,
|
||||
const graphene_rect_t *viewport) G_GNUC_WARN_UNUSED_RESULT;
|
||||
|
||||
gboolean gsk_vulkan_clip_contains_rect (const GskVulkanClip *self,
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *rect) G_GNUC_WARN_UNUSED_RESULT;
|
||||
gboolean gsk_vulkan_clip_intersects_rect (const GskVulkanClip *self,
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *rect) G_GNUC_WARN_UNUSED_RESULT;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
@@ -84,17 +84,22 @@ gsk_vulkan_color_pipeline_new (GdkVulkanContext *context,
|
||||
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_COLOR_PIPELINE, context, layout, shader_name, render_pass);
|
||||
}
|
||||
|
||||
gsize
|
||||
gsk_vulkan_color_pipeline_count_vertex_data (GskVulkanColorPipeline *pipeline)
|
||||
{
|
||||
return sizeof (GskVulkanColorInstance);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_vulkan_color_pipeline_collect_vertex_data (GskVulkanColorPipeline *pipeline,
|
||||
guchar *data,
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *rect,
|
||||
const GdkRGBA *color)
|
||||
{
|
||||
GskVulkanColorInstance *instance = (GskVulkanColorInstance *) data;
|
||||
|
||||
instance->rect[0] = rect->origin.x + offset->x;
|
||||
instance->rect[1] = rect->origin.y + offset->y;
|
||||
instance->rect[0] = rect->origin.x;
|
||||
instance->rect[1] = rect->origin.y;
|
||||
instance->rect[2] = rect->size.width;
|
||||
instance->rect[3] = rect->size.height;
|
||||
instance->color[0] = color->red;
|
||||
|
||||
@@ -17,9 +17,9 @@ GskVulkanPipeline * gsk_vulkan_color_pipeline_new (GdkVulk
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass);
|
||||
|
||||
gsize gsk_vulkan_color_pipeline_count_vertex_data (GskVulkanColorPipeline *pipeline);
|
||||
void gsk_vulkan_color_pipeline_collect_vertex_data (GskVulkanColorPipeline *pipeline,
|
||||
guchar *data,
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *rect,
|
||||
const GdkRGBA *color);
|
||||
gsize gsk_vulkan_color_pipeline_draw (GskVulkanColorPipeline *pipeline,
|
||||
|
||||
@@ -13,7 +13,6 @@ struct _GskVulkanColorTextInstance
|
||||
{
|
||||
float rect[4];
|
||||
float tex_rect[4];
|
||||
guint32 tex_id[2];
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GskVulkanColorTextPipeline, gsk_vulkan_color_text_pipeline, GSK_TYPE_VULKAN_PIPELINE)
|
||||
@@ -41,12 +40,6 @@ gsk_vulkan_color_text_pipeline_get_input_state_create_info (GskVulkanPipeline *s
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanColorTextInstance, tex_rect),
|
||||
},
|
||||
{
|
||||
.location = 2,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32_UINT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanColorTextInstance, tex_id),
|
||||
}
|
||||
};
|
||||
static const VkPipelineVertexInputStateCreateInfo info = {
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
|
||||
@@ -91,12 +84,18 @@ gsk_vulkan_color_text_pipeline_new (GdkVulkanContext *context,
|
||||
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_COLOR_TEXT_PIPELINE, context, layout, shader_name, render_pass);
|
||||
}
|
||||
|
||||
gsize
|
||||
gsk_vulkan_color_text_pipeline_count_vertex_data (GskVulkanColorTextPipeline *pipeline,
|
||||
int num_instances)
|
||||
{
|
||||
return sizeof (GskVulkanColorTextInstance) * num_instances;
|
||||
}
|
||||
|
||||
void
|
||||
gsk_vulkan_color_text_pipeline_collect_vertex_data (GskVulkanColorTextPipeline *pipeline,
|
||||
guchar *data,
|
||||
GskVulkanRenderer *renderer,
|
||||
const graphene_rect_t *rect,
|
||||
guint tex_id[2],
|
||||
PangoFont *font,
|
||||
guint total_glyphs,
|
||||
const PangoGlyphInfo *glyphs,
|
||||
@@ -141,9 +140,6 @@ gsk_vulkan_color_text_pipeline_collect_vertex_data (GskVulkanColorTextPipeline *
|
||||
instance->tex_rect[2] = glyph->tw;
|
||||
instance->tex_rect[3] = glyph->th;
|
||||
|
||||
instance->tex_id[0] = tex_id[0];
|
||||
instance->tex_id[1] = tex_id[1];
|
||||
|
||||
count++;
|
||||
}
|
||||
x_position += gi->geometry.width;
|
||||
|
||||
@@ -18,11 +18,12 @@ GskVulkanPipeline * gsk_vulkan_color_text_pipeline_new (Gd
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass);
|
||||
|
||||
gsize gsk_vulkan_color_text_pipeline_count_vertex_data (GskVulkanColorTextPipeline *pipeline,
|
||||
int num_instances);
|
||||
void gsk_vulkan_color_text_pipeline_collect_vertex_data (GskVulkanColorTextPipeline *pipeline,
|
||||
guchar *data,
|
||||
GskVulkanRenderer *renderer,
|
||||
const graphene_rect_t *rect,
|
||||
guint tex_id[2],
|
||||
PangoFont *font,
|
||||
guint total_glyphs,
|
||||
const PangoGlyphInfo *glyphs,
|
||||
|
||||
@@ -12,12 +12,8 @@ typedef struct _GskVulkanCrossFadeInstance GskVulkanCrossFadeInstance;
|
||||
struct _GskVulkanCrossFadeInstance
|
||||
{
|
||||
float rect[4];
|
||||
float start_rect[4];
|
||||
float end_rect[4];
|
||||
float start_tex_rect[4];
|
||||
float end_tex_rect[4];
|
||||
guint32 start_tex_id[2];
|
||||
guint32 end_tex_id[2];
|
||||
float progress;
|
||||
};
|
||||
|
||||
@@ -44,40 +40,16 @@ gsk_vulkan_cross_fade_pipeline_get_input_state_create_info (GskVulkanPipeline *s
|
||||
.location = 1,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, start_rect),
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, start_tex_rect),
|
||||
},
|
||||
{
|
||||
.location = 2,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, end_rect),
|
||||
},
|
||||
{
|
||||
.location = 3,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, start_tex_rect),
|
||||
},
|
||||
{
|
||||
.location = 4,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, end_tex_rect),
|
||||
},
|
||||
{
|
||||
.location = 5,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32_UINT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, start_tex_id),
|
||||
},
|
||||
{
|
||||
.location = 6,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32_UINT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, end_tex_id),
|
||||
},
|
||||
{
|
||||
.location = 7,
|
||||
.location = 3,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32_SFLOAT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, progress),
|
||||
@@ -126,36 +98,27 @@ gsk_vulkan_cross_fade_pipeline_new (GdkVulkanContext *context,
|
||||
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_CROSS_FADE_PIPELINE, context, layout, shader_name, render_pass);
|
||||
}
|
||||
|
||||
gsize
|
||||
gsk_vulkan_cross_fade_pipeline_count_vertex_data (GskVulkanCrossFadePipeline *pipeline)
|
||||
{
|
||||
return sizeof (GskVulkanCrossFadeInstance);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_vulkan_cross_fade_pipeline_collect_vertex_data (GskVulkanCrossFadePipeline *pipeline,
|
||||
guchar *data,
|
||||
guint32 start_tex_id[2],
|
||||
guint32 end_tex_id[2],
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *bounds,
|
||||
const graphene_rect_t *start_bounds,
|
||||
const graphene_rect_t *end_bounds,
|
||||
const graphene_rect_t *start_tex_rect,
|
||||
const graphene_rect_t *end_tex_rect,
|
||||
double progress)
|
||||
guchar *data,
|
||||
const graphene_rect_t *bounds,
|
||||
const graphene_rect_t *start_tex_rect,
|
||||
const graphene_rect_t *end_tex_rect,
|
||||
double progress)
|
||||
{
|
||||
GskVulkanCrossFadeInstance *instance = (GskVulkanCrossFadeInstance *) data;
|
||||
|
||||
instance->rect[0] = bounds->origin.x + offset->x;
|
||||
instance->rect[1] = bounds->origin.y + offset->y;
|
||||
instance->rect[0] = bounds->origin.x;
|
||||
instance->rect[1] = bounds->origin.y;
|
||||
instance->rect[2] = bounds->size.width;
|
||||
instance->rect[3] = bounds->size.height;
|
||||
|
||||
instance->start_rect[0] = start_bounds->origin.x + offset->x;
|
||||
instance->start_rect[1] = start_bounds->origin.y + offset->y;
|
||||
instance->start_rect[2] = start_bounds->size.width;
|
||||
instance->start_rect[3] = start_bounds->size.height;
|
||||
|
||||
instance->end_rect[0] = end_bounds->origin.x + offset->x;
|
||||
instance->end_rect[1] = end_bounds->origin.y + offset->y;
|
||||
instance->end_rect[2] = end_bounds->size.width;
|
||||
instance->end_rect[3] = end_bounds->size.height;
|
||||
|
||||
instance->start_tex_rect[0] = start_tex_rect->origin.x;
|
||||
instance->start_tex_rect[1] = start_tex_rect->origin.y;
|
||||
instance->start_tex_rect[2] = start_tex_rect->size.width;
|
||||
@@ -166,10 +129,6 @@ gsk_vulkan_cross_fade_pipeline_collect_vertex_data (GskVulkanCrossFadePipeline *
|
||||
instance->end_tex_rect[2] = end_tex_rect->size.width;
|
||||
instance->end_tex_rect[3] = end_tex_rect->size.height;
|
||||
|
||||
instance->start_tex_id[0] = start_tex_id[0];
|
||||
instance->start_tex_id[1] = start_tex_id[1];
|
||||
instance->end_tex_id[0] = end_tex_id[0];
|
||||
instance->end_tex_id[1] = end_tex_id[1];
|
||||
instance->progress = progress;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,16 +17,12 @@ GskVulkanPipeline * gsk_vulkan_cross_fade_pipeline_new (GdkVulka
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass);
|
||||
|
||||
gsize gsk_vulkan_cross_fade_pipeline_count_vertex_data (GskVulkanCrossFadePipeline *pipeline);
|
||||
void gsk_vulkan_cross_fade_pipeline_collect_vertex_data (GskVulkanCrossFadePipeline *pipeline,
|
||||
guchar *data,
|
||||
guint32 start_tex_id[2],
|
||||
guint32 end_tex_id[2],
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *bounds,
|
||||
const graphene_rect_t *start_bounds,
|
||||
const graphene_rect_t *end_bounds,
|
||||
const graphene_rect_t *start_tex_rect,
|
||||
const graphene_rect_t *end_tex_rect,
|
||||
double progress);
|
||||
gsize gsk_vulkan_cross_fade_pipeline_draw (GskVulkanCrossFadePipeline *pipeline,
|
||||
VkCommandBuffer command_buffer,
|
||||
|
||||
@@ -15,7 +15,6 @@ struct _GskVulkanEffectInstance
|
||||
float tex_rect[4];
|
||||
float color_matrix[16];
|
||||
float color_offset[4];
|
||||
guint32 tex_id[2];
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GskVulkanEffectPipeline, gsk_vulkan_effect_pipeline, GSK_TYPE_VULKAN_PIPELINE)
|
||||
@@ -72,12 +71,6 @@ gsk_vulkan_effect_pipeline_get_input_state_create_info (GskVulkanPipeline *self)
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanEffectInstance, color_offset),
|
||||
},
|
||||
{
|
||||
.location = 7,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32_UINT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanEffectInstance, tex_id),
|
||||
}
|
||||
};
|
||||
static const VkPipelineVertexInputStateCreateInfo info = {
|
||||
@@ -123,11 +116,15 @@ gsk_vulkan_effect_pipeline_new (GdkVulkanContext *context,
|
||||
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_EFFECT_PIPELINE, context, layout, shader_name, render_pass);
|
||||
}
|
||||
|
||||
gsize
|
||||
gsk_vulkan_effect_pipeline_count_vertex_data (GskVulkanEffectPipeline *pipeline)
|
||||
{
|
||||
return sizeof (GskVulkanEffectInstance);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_vulkan_effect_pipeline_collect_vertex_data (GskVulkanEffectPipeline *pipeline,
|
||||
guchar *data,
|
||||
guint32 tex_id[2],
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *rect,
|
||||
const graphene_rect_t *tex_rect,
|
||||
const graphene_matrix_t *color_matrix,
|
||||
@@ -135,8 +132,8 @@ gsk_vulkan_effect_pipeline_collect_vertex_data (GskVulkanEffectPipeline *pipelin
|
||||
{
|
||||
GskVulkanEffectInstance *instance = (GskVulkanEffectInstance *) data;
|
||||
|
||||
instance->rect[0] = rect->origin.x + offset->x;
|
||||
instance->rect[1] = rect->origin.y + offset->y;
|
||||
instance->rect[0] = rect->origin.x;
|
||||
instance->rect[1] = rect->origin.y;
|
||||
instance->rect[2] = rect->size.width;
|
||||
instance->rect[3] = rect->size.height;
|
||||
instance->tex_rect[0] = tex_rect->origin.x;
|
||||
@@ -145,8 +142,6 @@ gsk_vulkan_effect_pipeline_collect_vertex_data (GskVulkanEffectPipeline *pipelin
|
||||
instance->tex_rect[3] = tex_rect->size.height;
|
||||
graphene_matrix_to_float (color_matrix, instance->color_matrix);
|
||||
graphene_vec4_to_float (color_offset, instance->color_offset);
|
||||
instance->tex_id[0] = tex_id[0];
|
||||
instance->tex_id[1] = tex_id[1];
|
||||
}
|
||||
|
||||
gsize
|
||||
|
||||
@@ -17,10 +17,9 @@ GskVulkanPipeline * gsk_vulkan_effect_pipeline_new (GdkVulk
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass);
|
||||
|
||||
gsize gsk_vulkan_effect_pipeline_count_vertex_data (GskVulkanEffectPipeline *pipeline);
|
||||
void gsk_vulkan_effect_pipeline_collect_vertex_data (GskVulkanEffectPipeline *pipeline,
|
||||
guchar *data,
|
||||
guint32 tex_id[2],
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *rect,
|
||||
const graphene_rect_t *tex_rect,
|
||||
const graphene_matrix_t *color_matrix,
|
||||
|
||||
+206
-118
@@ -209,8 +209,6 @@ gsk_vulkan_image_new (GdkVulkanContext *context,
|
||||
VkMemoryRequirements requirements;
|
||||
GskVulkanImage *self;
|
||||
|
||||
g_assert (width > 0 && height > 0);
|
||||
|
||||
self = g_object_new (GSK_TYPE_VULKAN_IMAGE, NULL);
|
||||
|
||||
self->vulkan = g_object_ref (context);
|
||||
@@ -254,6 +252,43 @@ gsk_vulkan_image_new (GdkVulkanContext *context,
|
||||
return self;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_vulkan_image_upload_data (GskVulkanImage *self,
|
||||
guchar *data,
|
||||
gsize width,
|
||||
gsize height,
|
||||
gsize data_stride)
|
||||
{
|
||||
VkImageSubresource image_res;
|
||||
VkSubresourceLayout image_layout;
|
||||
gsize mem_stride;
|
||||
guchar *mem;
|
||||
|
||||
image_res.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
image_res.mipLevel = 0;
|
||||
image_res.arrayLayer = 0;
|
||||
|
||||
mem_stride = width * 4;
|
||||
vkGetImageSubresourceLayout (gdk_vulkan_context_get_device (self->vulkan),
|
||||
self->vk_image, &image_res, &image_layout);
|
||||
|
||||
mem = gsk_vulkan_memory_map (self->memory) + image_layout.offset;
|
||||
|
||||
if (image_layout.rowPitch == width * 4 && data_stride == mem_stride)
|
||||
{
|
||||
memcpy (mem, data, data_stride * height);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (gsize i = 0; i < height; i++)
|
||||
{
|
||||
memcpy (mem + i * image_layout.rowPitch, data + i * data_stride, width * 4);
|
||||
}
|
||||
}
|
||||
|
||||
gsk_vulkan_memory_unmap (self->memory);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_vulkan_image_ensure_view (GskVulkanImage *self,
|
||||
VkFormat format)
|
||||
@@ -283,99 +318,34 @@ gsk_vulkan_image_ensure_view (GskVulkanImage *self,
|
||||
&self->vk_image_view);
|
||||
}
|
||||
|
||||
GskVulkanImage *
|
||||
gsk_vulkan_image_new_from_texture (GskVulkanUploader *uploader,
|
||||
GdkTexture *texture)
|
||||
{
|
||||
GdkTextureDownloader *downloader;
|
||||
GskVulkanImage *result;
|
||||
GskVulkanImageMap map;
|
||||
|
||||
downloader = gdk_texture_downloader_new (texture);
|
||||
result = gsk_vulkan_image_new_for_upload (uploader,
|
||||
gdk_texture_get_width (texture),
|
||||
gdk_texture_get_height (texture));
|
||||
gsk_vulkan_image_map_memory (result, uploader, &map);
|
||||
gdk_texture_downloader_download_into (downloader, map.data, map.stride);
|
||||
gsk_vulkan_image_unmap_memory (result, uploader, &map);
|
||||
gdk_texture_downloader_free (downloader);
|
||||
return result;
|
||||
}
|
||||
|
||||
GskVulkanImage *
|
||||
gsk_vulkan_image_new_for_upload (GskVulkanUploader *uploader,
|
||||
gsize width,
|
||||
gsize height)
|
||||
static GskVulkanImage *
|
||||
gsk_vulkan_image_new_from_data_via_staging_buffer (GskVulkanUploader *uploader,
|
||||
guchar *data,
|
||||
gsize width,
|
||||
gsize height,
|
||||
gsize stride)
|
||||
{
|
||||
GskVulkanImage *self;
|
||||
GskVulkanBuffer *staging;
|
||||
gsize buffer_size = width * height * 4;
|
||||
guchar *mem;
|
||||
|
||||
self = gsk_vulkan_image_new (uploader->vulkan,
|
||||
width,
|
||||
height,
|
||||
VK_IMAGE_TILING_LINEAR,
|
||||
VK_IMAGE_USAGE_TRANSFER_DST_BIT |
|
||||
VK_IMAGE_USAGE_SAMPLED_BIT,
|
||||
VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||
staging = gsk_vulkan_buffer_new_staging (uploader->vulkan, buffer_size);
|
||||
mem = gsk_vulkan_buffer_map (staging);
|
||||
|
||||
gsk_vulkan_image_ensure_view (self, VK_FORMAT_B8G8R8A8_UNORM);
|
||||
if (stride == width * 4)
|
||||
{
|
||||
memcpy (mem, data, stride * height);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (gsize i = 0; i < height; i++)
|
||||
{
|
||||
memcpy (mem + i * width * 4, data + i * stride, width * 4);
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_vulkan_image_map_memory_direct (GskVulkanImage *self,
|
||||
GskVulkanUploader *uploader,
|
||||
GskVulkanImageMap *map)
|
||||
{
|
||||
VkImageSubresource image_res;
|
||||
VkSubresourceLayout image_layout;
|
||||
|
||||
image_res.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
image_res.mipLevel = 0;
|
||||
image_res.arrayLayer = 0;
|
||||
|
||||
vkGetImageSubresourceLayout (gdk_vulkan_context_get_device (self->vulkan),
|
||||
self->vk_image, &image_res, &image_layout);
|
||||
|
||||
map->staging_buffer = NULL;
|
||||
map->data = gsk_vulkan_memory_map (self->memory) + image_layout.offset;
|
||||
map->stride = image_layout.rowPitch;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_vulkan_image_unmap_memory_direct (GskVulkanImage *self,
|
||||
GskVulkanUploader *uploader,
|
||||
GskVulkanImageMap *map)
|
||||
{
|
||||
gsk_vulkan_memory_unmap (self->memory);
|
||||
|
||||
gsk_vulkan_uploader_add_image_barrier (uploader,
|
||||
TRUE,
|
||||
self,
|
||||
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||
VK_ACCESS_SHADER_READ_BIT);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_vulkan_image_map_memory_indirect (GskVulkanImage *self,
|
||||
GskVulkanUploader *uploader,
|
||||
GskVulkanImageMap *map)
|
||||
{
|
||||
gsize buffer_size = self->width * self->height * 4;
|
||||
|
||||
map->staging_buffer = gsk_vulkan_buffer_new_staging (uploader->vulkan, buffer_size);
|
||||
map->data = gsk_vulkan_buffer_map (map->staging_buffer);
|
||||
map->stride = self->width * 4;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_vulkan_image_unmap_memory_indirect (GskVulkanImage *self,
|
||||
GskVulkanUploader *uploader,
|
||||
GskVulkanImageMap *map)
|
||||
{
|
||||
gsk_vulkan_buffer_unmap (map->staging_buffer);
|
||||
gsk_vulkan_buffer_unmap (staging);
|
||||
|
||||
gsk_vulkan_uploader_add_buffer_barrier (uploader,
|
||||
FALSE,
|
||||
@@ -385,11 +355,21 @@ gsk_vulkan_image_unmap_memory_indirect (GskVulkanImage *self,
|
||||
.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT,
|
||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.buffer = gsk_vulkan_buffer_get_buffer (map->staging_buffer),
|
||||
.buffer = gsk_vulkan_buffer_get_buffer (staging),
|
||||
.offset = 0,
|
||||
.size = VK_WHOLE_SIZE,
|
||||
.size = buffer_size,
|
||||
});
|
||||
|
||||
self = gsk_vulkan_image_new (uploader->vulkan,
|
||||
width,
|
||||
height,
|
||||
VK_IMAGE_TILING_OPTIMAL,
|
||||
VK_IMAGE_USAGE_TRANSFER_DST_BIT |
|
||||
VK_IMAGE_USAGE_SAMPLED_BIT,
|
||||
VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||
|
||||
gsk_vulkan_uploader_add_image_barrier (uploader,
|
||||
FALSE,
|
||||
self,
|
||||
@@ -397,7 +377,7 @@ gsk_vulkan_image_unmap_memory_indirect (GskVulkanImage *self,
|
||||
VK_ACCESS_TRANSFER_WRITE_BIT);
|
||||
|
||||
vkCmdCopyBufferToImage (gsk_vulkan_uploader_get_copy_buffer (uploader),
|
||||
gsk_vulkan_buffer_get_buffer (map->staging_buffer),
|
||||
gsk_vulkan_buffer_get_buffer (staging),
|
||||
self->vk_image,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
1,
|
||||
@@ -412,8 +392,8 @@ gsk_vulkan_image_unmap_memory_indirect (GskVulkanImage *self,
|
||||
},
|
||||
.imageOffset = { 0, 0, 0 },
|
||||
.imageExtent = {
|
||||
.width = self->width,
|
||||
.height = self->height,
|
||||
.width = width,
|
||||
.height = height,
|
||||
.depth = 1
|
||||
}
|
||||
}
|
||||
@@ -425,33 +405,141 @@ gsk_vulkan_image_unmap_memory_indirect (GskVulkanImage *self,
|
||||
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||
VK_ACCESS_SHADER_READ_BIT);
|
||||
|
||||
uploader->staging_buffer_free_list = g_slist_prepend (uploader->staging_buffer_free_list,
|
||||
map->staging_buffer);
|
||||
uploader->staging_buffer_free_list = g_slist_prepend (uploader->staging_buffer_free_list, staging);
|
||||
|
||||
gsk_vulkan_image_ensure_view (self, VK_FORMAT_B8G8R8A8_UNORM);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
void
|
||||
gsk_vulkan_image_map_memory (GskVulkanImage *self,
|
||||
GskVulkanUploader *uploader,
|
||||
GskVulkanImageMap *map)
|
||||
static GskVulkanImage *
|
||||
gsk_vulkan_image_new_from_data_via_staging_image (GskVulkanUploader *uploader,
|
||||
guchar *data,
|
||||
gsize width,
|
||||
gsize height,
|
||||
gsize stride)
|
||||
{
|
||||
g_assert (self->vk_image_layout == VK_IMAGE_LAYOUT_UNDEFINED ||
|
||||
self->vk_image_layout == VK_IMAGE_LAYOUT_PREINITIALIZED);
|
||||
GskVulkanImage *self, *staging;
|
||||
|
||||
if (!GSK_DEBUG_CHECK (STAGING) && gsk_vulkan_memory_can_map (self->memory, TRUE))
|
||||
gsk_vulkan_image_map_memory_direct (self, uploader, map);
|
||||
else
|
||||
gsk_vulkan_image_map_memory_indirect (self, uploader, map);
|
||||
staging = gsk_vulkan_image_new (uploader->vulkan,
|
||||
width,
|
||||
height,
|
||||
VK_IMAGE_TILING_LINEAR,
|
||||
VK_IMAGE_USAGE_TRANSFER_DST_BIT |
|
||||
VK_IMAGE_USAGE_TRANSFER_SRC_BIT,
|
||||
VK_IMAGE_LAYOUT_PREINITIALIZED,
|
||||
VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
|
||||
|
||||
gsk_vulkan_image_upload_data (staging, data, width, height, stride);
|
||||
|
||||
self = gsk_vulkan_image_new (uploader->vulkan,
|
||||
width,
|
||||
height,
|
||||
VK_IMAGE_TILING_OPTIMAL,
|
||||
VK_IMAGE_USAGE_TRANSFER_DST_BIT |
|
||||
VK_IMAGE_USAGE_SAMPLED_BIT,
|
||||
VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||
|
||||
gsk_vulkan_uploader_add_image_barrier (uploader,
|
||||
FALSE,
|
||||
staging,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
VK_ACCESS_TRANSFER_READ_BIT);
|
||||
|
||||
gsk_vulkan_uploader_add_image_barrier (uploader,
|
||||
FALSE,
|
||||
self,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
VK_ACCESS_TRANSFER_WRITE_BIT);
|
||||
|
||||
vkCmdCopyImage (gsk_vulkan_uploader_get_copy_buffer (uploader),
|
||||
staging->vk_image,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
self->vk_image,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
1,
|
||||
&(VkImageCopy) {
|
||||
.srcSubresource = {
|
||||
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
.mipLevel = 0,
|
||||
.baseArrayLayer = 0,
|
||||
.layerCount = 1
|
||||
},
|
||||
.srcOffset = { 0, 0, 0 },
|
||||
.dstSubresource = {
|
||||
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
.mipLevel = 0,
|
||||
.baseArrayLayer = 0,
|
||||
.layerCount = 1
|
||||
},
|
||||
.dstOffset = { 0, 0, 0 },
|
||||
.extent = {
|
||||
.width = width,
|
||||
.height = height,
|
||||
.depth = 1
|
||||
}
|
||||
});
|
||||
|
||||
gsk_vulkan_uploader_add_image_barrier (uploader,
|
||||
TRUE,
|
||||
self,
|
||||
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||
VK_ACCESS_SHADER_READ_BIT);
|
||||
|
||||
uploader->staging_image_free_list = g_slist_prepend (uploader->staging_image_free_list, staging);
|
||||
|
||||
gsk_vulkan_image_ensure_view (self, VK_FORMAT_B8G8R8A8_UNORM);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
void
|
||||
gsk_vulkan_image_unmap_memory (GskVulkanImage *self,
|
||||
GskVulkanUploader *uploader,
|
||||
GskVulkanImageMap *map)
|
||||
static GskVulkanImage *
|
||||
gsk_vulkan_image_new_from_data_directly (GskVulkanUploader *uploader,
|
||||
guchar *data,
|
||||
gsize width,
|
||||
gsize height,
|
||||
gsize stride)
|
||||
{
|
||||
if (map->staging_buffer)
|
||||
gsk_vulkan_image_unmap_memory_indirect (self, uploader, map);
|
||||
GskVulkanImage *self;
|
||||
|
||||
self = gsk_vulkan_image_new (uploader->vulkan,
|
||||
width,
|
||||
height,
|
||||
VK_IMAGE_TILING_LINEAR,
|
||||
VK_IMAGE_USAGE_SAMPLED_BIT,
|
||||
VK_IMAGE_LAYOUT_PREINITIALIZED,
|
||||
VK_ACCESS_HOST_WRITE_BIT,
|
||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
|
||||
|
||||
gsk_vulkan_image_upload_data (self, data, width, height, stride);
|
||||
|
||||
gsk_vulkan_uploader_add_image_barrier (uploader,
|
||||
TRUE,
|
||||
self,
|
||||
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||
VK_ACCESS_SHADER_READ_BIT);
|
||||
|
||||
gsk_vulkan_image_ensure_view (self, VK_FORMAT_B8G8R8A8_UNORM);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
GskVulkanImage *
|
||||
gsk_vulkan_image_new_from_data (GskVulkanUploader *uploader,
|
||||
guchar *data,
|
||||
gsize width,
|
||||
gsize height,
|
||||
gsize stride)
|
||||
{
|
||||
if (GSK_DEBUG_CHECK (VULKAN_STAGING_BUFFER))
|
||||
return gsk_vulkan_image_new_from_data_via_staging_buffer (uploader, data, width, height, stride);
|
||||
else if (GSK_DEBUG_CHECK (VULKAN_STAGING_IMAGE))
|
||||
return gsk_vulkan_image_new_from_data_via_staging_image (uploader, data, width, height, stride);
|
||||
else
|
||||
gsk_vulkan_image_unmap_memory_direct (self, uploader, map);
|
||||
return gsk_vulkan_image_new_from_data_directly (uploader, data, width, height, stride);
|
||||
}
|
||||
|
||||
GskVulkanImage *
|
||||
@@ -518,9 +606,9 @@ gsk_vulkan_image_new_for_atlas (GdkVulkanContext *context,
|
||||
}
|
||||
|
||||
GskVulkanImage *
|
||||
gsk_vulkan_image_new_for_offscreen (GdkVulkanContext *context,
|
||||
gsize width,
|
||||
gsize height)
|
||||
gsk_vulkan_image_new_for_texture (GdkVulkanContext *context,
|
||||
gsize width,
|
||||
gsize height)
|
||||
{
|
||||
GskVulkanImage *self;
|
||||
|
||||
@@ -532,7 +620,7 @@ gsk_vulkan_image_new_for_offscreen (GdkVulkanContext *context,
|
||||
VK_IMAGE_USAGE_SAMPLED_BIT |
|
||||
VK_IMAGE_USAGE_TRANSFER_SRC_BIT,
|
||||
VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
||||
0,
|
||||
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||
|
||||
gsk_vulkan_image_ensure_view (self, VK_FORMAT_B8G8R8A8_UNORM);
|
||||
|
||||
@@ -24,8 +24,11 @@ GskVulkanImage * gsk_vulkan_image_new_for_swapchain (GdkVulk
|
||||
VkFormat format,
|
||||
gsize width,
|
||||
gsize height);
|
||||
GskVulkanImage * gsk_vulkan_image_new_from_texture (GskVulkanUploader *uploader,
|
||||
GdkTexture *texture);
|
||||
GskVulkanImage * gsk_vulkan_image_new_from_data (GskVulkanUploader *uploader,
|
||||
guchar *data,
|
||||
gsize width,
|
||||
gsize height,
|
||||
gsize stride);
|
||||
|
||||
typedef struct {
|
||||
guchar *data;
|
||||
@@ -46,34 +49,13 @@ GskVulkanImage * gsk_vulkan_image_new_for_framebuffer (GdkVulk
|
||||
GskVulkanImage * gsk_vulkan_image_new_for_atlas (GdkVulkanContext *context,
|
||||
gsize width,
|
||||
gsize height);
|
||||
GskVulkanImage * gsk_vulkan_image_new_for_offscreen (GdkVulkanContext *context,
|
||||
GskVulkanImage * gsk_vulkan_image_new_for_texture (GdkVulkanContext *context,
|
||||
gsize width,
|
||||
gsize height);
|
||||
|
||||
GdkTexture * gsk_vulkan_image_download (GskVulkanImage *self,
|
||||
GskVulkanUploader *uploader);
|
||||
|
||||
typedef struct _GskVulkanImageMap GskVulkanImageMap;
|
||||
|
||||
struct _GskVulkanImageMap
|
||||
{
|
||||
guchar *data;
|
||||
gsize stride;
|
||||
|
||||
/* private */
|
||||
gpointer staging_buffer;
|
||||
};
|
||||
|
||||
GskVulkanImage * gsk_vulkan_image_new_for_upload (GskVulkanUploader *uploader,
|
||||
gsize width,
|
||||
gsize height);
|
||||
void gsk_vulkan_image_map_memory (GskVulkanImage *self,
|
||||
GskVulkanUploader *uploader,
|
||||
GskVulkanImageMap *map);
|
||||
void gsk_vulkan_image_unmap_memory (GskVulkanImage *self,
|
||||
GskVulkanUploader *uploader,
|
||||
GskVulkanImageMap *map);
|
||||
|
||||
gsize gsk_vulkan_image_get_width (GskVulkanImage *self);
|
||||
gsize gsk_vulkan_image_get_height (GskVulkanImage *self);
|
||||
VkImage gsk_vulkan_image_get_image (GskVulkanImage *self);
|
||||
|
||||
@@ -15,8 +15,9 @@ struct _GskVulkanLinearGradientInstance
|
||||
float start[2];
|
||||
float end[2];
|
||||
gint32 repeating;
|
||||
gint32 offset;
|
||||
gint32 stop_count;
|
||||
float offsets[GSK_VULKAN_LINEAR_GRADIENT_PIPELINE_MAX_COLOR_STOPS];
|
||||
float colors[GSK_VULKAN_LINEAR_GRADIENT_PIPELINE_MAX_COLOR_STOPS][4];
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GskVulkanLinearGradientPipeline, gsk_vulkan_linear_gradient_pipeline, GSK_TYPE_VULKAN_PIPELINE)
|
||||
@@ -60,13 +61,67 @@ gsk_vulkan_linear_gradient_pipeline_get_input_state_create_info (GskVulkanPipeli
|
||||
.location = 4,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32_SINT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanLinearGradientInstance, offset),
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanLinearGradientInstance, stop_count),
|
||||
},
|
||||
{
|
||||
.location = 5,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32_SINT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanLinearGradientInstance, stop_count),
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanLinearGradientInstance, offsets),
|
||||
},
|
||||
{
|
||||
.location = 6,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanLinearGradientInstance, offsets) + sizeof (float) * 4,
|
||||
},
|
||||
{
|
||||
.location = 7,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanLinearGradientInstance, colors[0]),
|
||||
},
|
||||
{
|
||||
.location = 8,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanLinearGradientInstance, colors[1]),
|
||||
},
|
||||
{
|
||||
.location = 9,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanLinearGradientInstance, colors[2]),
|
||||
},
|
||||
{
|
||||
.location = 10,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanLinearGradientInstance, colors[3]),
|
||||
},
|
||||
{
|
||||
.location = 11,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanLinearGradientInstance, colors[4]),
|
||||
},
|
||||
{
|
||||
.location = 12,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanLinearGradientInstance, colors[5]),
|
||||
},
|
||||
{
|
||||
.location = 13,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanLinearGradientInstance, colors[6]),
|
||||
},
|
||||
{
|
||||
.location = 14,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanLinearGradientInstance, colors[7]),
|
||||
}
|
||||
};
|
||||
static const VkPipelineVertexInputStateCreateInfo info = {
|
||||
@@ -112,30 +167,48 @@ gsk_vulkan_linear_gradient_pipeline_new (GdkVulkanContext *context,
|
||||
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_LINEAR_GRADIENT_PIPELINE, context, layout, shader_name, render_pass);
|
||||
}
|
||||
|
||||
gsize
|
||||
gsk_vulkan_linear_gradient_pipeline_count_vertex_data (GskVulkanLinearGradientPipeline *pipeline)
|
||||
{
|
||||
return sizeof (GskVulkanLinearGradientInstance);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_vulkan_linear_gradient_pipeline_collect_vertex_data (GskVulkanLinearGradientPipeline *pipeline,
|
||||
guchar *data,
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *rect,
|
||||
const graphene_point_t *start,
|
||||
const graphene_point_t *end,
|
||||
gboolean repeating,
|
||||
gsize gradient_offset,
|
||||
gsize n_stops)
|
||||
guchar *data,
|
||||
const graphene_rect_t *rect,
|
||||
const graphene_point_t *start,
|
||||
const graphene_point_t *end,
|
||||
gboolean repeating,
|
||||
gsize n_stops,
|
||||
const GskColorStop *stops)
|
||||
{
|
||||
GskVulkanLinearGradientInstance *instance = (GskVulkanLinearGradientInstance *) data;
|
||||
gsize i;
|
||||
|
||||
instance->rect[0] = rect->origin.x + offset->x;
|
||||
instance->rect[1] = rect->origin.y + offset->y;
|
||||
if (n_stops > GSK_VULKAN_LINEAR_GRADIENT_PIPELINE_MAX_COLOR_STOPS)
|
||||
{
|
||||
g_warning ("Only %u color stops supported.", GSK_VULKAN_LINEAR_GRADIENT_PIPELINE_MAX_COLOR_STOPS);
|
||||
n_stops = GSK_VULKAN_LINEAR_GRADIENT_PIPELINE_MAX_COLOR_STOPS;
|
||||
}
|
||||
instance->rect[0] = rect->origin.x;
|
||||
instance->rect[1] = rect->origin.y;
|
||||
instance->rect[2] = rect->size.width;
|
||||
instance->rect[3] = rect->size.height;
|
||||
instance->start[0] = start->x + offset->x;
|
||||
instance->start[1] = start->y + offset->y;
|
||||
instance->end[0] = end->x + offset->x;
|
||||
instance->end[1] = end->y + offset->y;
|
||||
instance->start[0] = start->x;
|
||||
instance->start[1] = start->y;
|
||||
instance->end[0] = end->x;
|
||||
instance->end[1] = end->y;
|
||||
instance->repeating = repeating;
|
||||
instance->offset = gradient_offset;
|
||||
instance->stop_count = n_stops;
|
||||
for (i = 0; i < n_stops; i++)
|
||||
{
|
||||
instance->offsets[i] = stops[i].offset;
|
||||
instance->colors[i][0] = stops[i].color.red;
|
||||
instance->colors[i][1] = stops[i].color.green;
|
||||
instance->colors[i][2] = stops[i].color.blue;
|
||||
instance->colors[i][3] = stops[i].color.alpha;
|
||||
}
|
||||
}
|
||||
|
||||
gsize
|
||||
|
||||
@@ -20,16 +20,17 @@ GskVulkanPipeline * gsk_vulkan_linear_gradient_pipeline_new (GdkVulk
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass);
|
||||
|
||||
gsize gsk_vulkan_linear_gradient_pipeline_count_vertex_data
|
||||
(GskVulkanLinearGradientPipeline*pipeline);
|
||||
void gsk_vulkan_linear_gradient_pipeline_collect_vertex_data
|
||||
(GskVulkanLinearGradientPipeline*pipeline,
|
||||
guchar *data,
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *rect,
|
||||
const graphene_point_t *start,
|
||||
const graphene_point_t *end,
|
||||
gboolean repeating,
|
||||
gsize gradient_offset,
|
||||
gsize n_stops);
|
||||
gsize n_stops,
|
||||
const GskColorStop *stops);
|
||||
gsize gsk_vulkan_linear_gradient_pipeline_draw (GskVulkanLinearGradientPipeline*pipeline,
|
||||
VkCommandBuffer command_buffer,
|
||||
gsize offset,
|
||||
|
||||
@@ -9,7 +9,6 @@ struct _GskVulkanMemory
|
||||
|
||||
gsize size;
|
||||
|
||||
VkMemoryType vk_memory_type;
|
||||
VkDeviceMemory vk_memory;
|
||||
};
|
||||
|
||||
@@ -42,7 +41,6 @@ gsk_vulkan_memory_new (GdkVulkanContext *context,
|
||||
|
||||
g_assert (i < properties.memoryTypeCount);
|
||||
|
||||
self->vk_memory_type = properties.memoryTypes[i];
|
||||
GSK_VK_CHECK (vkAllocateMemory, gdk_vulkan_context_get_device (context),
|
||||
&(VkMemoryAllocateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
|
||||
@@ -73,33 +71,11 @@ gsk_vulkan_memory_get_device_memory (GskVulkanMemory *self)
|
||||
return self->vk_memory;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gsk_vulkan_memory_can_map (GskVulkanMemory *self,
|
||||
gboolean fast)
|
||||
{
|
||||
if (!(self->vk_memory_type.propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT))
|
||||
return FALSE;
|
||||
|
||||
/* FIXME: no support implemented for this */
|
||||
if (!(self->vk_memory_type.propertyFlags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT))
|
||||
return FALSE;
|
||||
|
||||
if (!fast)
|
||||
return TRUE;
|
||||
|
||||
if (!(self->vk_memory_type.propertyFlags & VK_MEMORY_PROPERTY_HOST_CACHED_BIT))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
guchar *
|
||||
gsk_vulkan_memory_map (GskVulkanMemory *self)
|
||||
{
|
||||
void *data;
|
||||
|
||||
g_assert (gsk_vulkan_memory_can_map (self, FALSE));
|
||||
|
||||
GSK_VK_CHECK (vkMapMemory, gdk_vulkan_context_get_device (self->vulkan),
|
||||
self->vk_memory,
|
||||
0,
|
||||
|
||||
@@ -14,8 +14,6 @@ void gsk_vulkan_memory_free (GskVulk
|
||||
|
||||
VkDeviceMemory gsk_vulkan_memory_get_device_memory (GskVulkanMemory *self);
|
||||
|
||||
gboolean gsk_vulkan_memory_can_map (GskVulkanMemory *self,
|
||||
gboolean fast);
|
||||
guchar * gsk_vulkan_memory_map (GskVulkanMemory *self);
|
||||
void gsk_vulkan_memory_unmap (GskVulkanMemory *self);
|
||||
|
||||
|
||||
@@ -16,11 +16,10 @@ struct _GskVulkanPipelinePrivate
|
||||
GdkVulkanContext *context;
|
||||
|
||||
VkPipeline pipeline;
|
||||
VkPipelineLayout layout;
|
||||
|
||||
GskVulkanShader *vertex_shader;
|
||||
GskVulkanShader *fragment_shader;
|
||||
|
||||
gsize vertex_stride;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GskVulkanPipeline, gsk_vulkan_pipeline, G_TYPE_OBJECT)
|
||||
@@ -55,13 +54,12 @@ gsk_vulkan_pipeline_init (GskVulkanPipeline *self)
|
||||
}
|
||||
|
||||
GskVulkanPipeline *
|
||||
gsk_vulkan_pipeline_new (GType pipeline_type,
|
||||
GdkVulkanContext *context,
|
||||
VkPipelineLayout layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass)
|
||||
gsk_vulkan_pipeline_new (GType pipeline_type,
|
||||
GdkVulkanContext *context,
|
||||
VkPipelineLayout layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass)
|
||||
{
|
||||
const VkPipelineVertexInputStateCreateInfo *vertex_input_state;
|
||||
GskVulkanPipelinePrivate *priv;
|
||||
GskVulkanPipeline *self;
|
||||
VkDevice device;
|
||||
@@ -78,14 +76,11 @@ gsk_vulkan_pipeline_new (GType pipeline_type,
|
||||
device = gdk_vulkan_context_get_device (context);
|
||||
|
||||
priv->context = context;
|
||||
priv->layout = layout;
|
||||
|
||||
priv->vertex_shader = gsk_vulkan_shader_new_from_resource (context, GSK_VULKAN_SHADER_VERTEX, shader_name, NULL);
|
||||
priv->fragment_shader = gsk_vulkan_shader_new_from_resource (context, GSK_VULKAN_SHADER_FRAGMENT, shader_name, NULL);
|
||||
|
||||
vertex_input_state = GSK_VULKAN_PIPELINE_GET_CLASS (self)->get_input_state_create_info (self);
|
||||
g_assert (vertex_input_state->vertexBindingDescriptionCount == 1);
|
||||
priv->vertex_stride = vertex_input_state->pVertexBindingDescriptions[0].stride;
|
||||
|
||||
GSK_VK_CHECK (vkCreateGraphicsPipelines, device,
|
||||
VK_NULL_HANDLE,
|
||||
1,
|
||||
@@ -96,7 +91,7 @@ gsk_vulkan_pipeline_new (GType pipeline_type,
|
||||
GST_VULKAN_SHADER_STAGE_CREATE_INFO (priv->vertex_shader),
|
||||
GST_VULKAN_SHADER_STAGE_CREATE_INFO (priv->fragment_shader)
|
||||
},
|
||||
.pVertexInputState = vertex_input_state,
|
||||
.pVertexInputState = GSK_VULKAN_PIPELINE_GET_CLASS (self)->get_input_state_create_info (self),
|
||||
.pInputAssemblyState = &(VkPipelineInputAssemblyStateCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
|
||||
.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
|
||||
@@ -113,7 +108,7 @@ gsk_vulkan_pipeline_new (GType pipeline_type,
|
||||
.depthClampEnable = VK_FALSE,
|
||||
.rasterizerDiscardEnable = VK_FALSE,
|
||||
.polygonMode = VK_POLYGON_MODE_FILL,
|
||||
.cullMode = VK_CULL_MODE_NONE,
|
||||
.cullMode = VK_CULL_MODE_BACK_BIT,
|
||||
.frontFace = VK_FRONT_FACE_CLOCKWISE,
|
||||
.lineWidth = 1.0f,
|
||||
},
|
||||
@@ -151,7 +146,7 @@ gsk_vulkan_pipeline_new (GType pipeline_type,
|
||||
VK_DYNAMIC_STATE_SCISSOR
|
||||
},
|
||||
},
|
||||
.layout = layout,
|
||||
.layout = priv->layout,
|
||||
.renderPass = render_pass,
|
||||
.subpass = 0,
|
||||
.basePipelineHandle = VK_NULL_HANDLE,
|
||||
@@ -171,10 +166,10 @@ gsk_vulkan_pipeline_get_pipeline (GskVulkanPipeline *self)
|
||||
return priv->pipeline;
|
||||
}
|
||||
|
||||
gsize
|
||||
gsk_vulkan_pipeline_get_vertex_stride (GskVulkanPipeline *self)
|
||||
VkPipelineLayout
|
||||
gsk_vulkan_pipeline_get_pipeline_layout (GskVulkanPipeline *self)
|
||||
{
|
||||
GskVulkanPipelinePrivate *priv = gsk_vulkan_pipeline_get_instance_private (self);
|
||||
|
||||
return priv->vertex_stride;
|
||||
return priv->layout;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ GskVulkanPipeline * gsk_vulkan_pipeline_new (GType
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass);
|
||||
VkPipeline gsk_vulkan_pipeline_get_pipeline (GskVulkanPipeline *self);
|
||||
gsize gsk_vulkan_pipeline_get_vertex_stride (GskVulkanPipeline *self);
|
||||
VkPipelineLayout gsk_vulkan_pipeline_get_pipeline_layout (GskVulkanPipeline *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -12,37 +12,83 @@ struct _GskVulkanPushConstantsWire
|
||||
struct {
|
||||
float mvp[16];
|
||||
float clip[12];
|
||||
float scale[2];
|
||||
} common;
|
||||
};
|
||||
|
||||
/* This is the value we know every conformant GPU must provide.
|
||||
* See value for maxPushConstantsSize in table 55 of
|
||||
* https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#limits-minmax
|
||||
*/
|
||||
G_STATIC_ASSERT (sizeof (GskVulkanPushConstantsWire) <= 128);
|
||||
|
||||
static void
|
||||
gsk_vulkan_push_constants_wire_init (GskVulkanPushConstantsWire *wire,
|
||||
const graphene_vec2_t *scale,
|
||||
const graphene_matrix_t *mvp,
|
||||
const GskRoundedRect *clip)
|
||||
void
|
||||
gsk_vulkan_push_constants_init (GskVulkanPushConstants *constants,
|
||||
const graphene_matrix_t *mvp,
|
||||
const graphene_rect_t *viewport)
|
||||
{
|
||||
graphene_matrix_to_float (mvp, wire->common.mvp);
|
||||
gsk_rounded_rect_to_float (clip, graphene_point_zero (), wire->common.clip);
|
||||
graphene_vec2_to_float (scale, wire->common.scale);
|
||||
graphene_matrix_init_from_matrix (&constants->mvp, mvp);
|
||||
gsk_vulkan_clip_init_empty (&constants->clip, viewport);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_vulkan_push_constants_push (VkCommandBuffer command_buffer,
|
||||
VkPipelineLayout pipeline_layout,
|
||||
const graphene_vec2_t *scale,
|
||||
const graphene_matrix_t *mvp,
|
||||
const GskRoundedRect *clip)
|
||||
gsk_vulkan_push_constants_init_copy (GskVulkanPushConstants *self,
|
||||
const GskVulkanPushConstants *src)
|
||||
{
|
||||
*self = *src;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gsk_vulkan_push_constants_transform (GskVulkanPushConstants *self,
|
||||
const GskVulkanPushConstants *src,
|
||||
GskTransform *transform,
|
||||
const graphene_rect_t *viewport)
|
||||
|
||||
{
|
||||
graphene_matrix_t matrix;
|
||||
|
||||
if (!gsk_vulkan_clip_transform (&self->clip, &src->clip, transform, viewport))
|
||||
return FALSE;
|
||||
|
||||
gsk_transform_to_matrix (transform, &matrix);
|
||||
graphene_matrix_multiply (&matrix, &src->mvp, &self->mvp);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gsk_vulkan_push_constants_intersect_rect (GskVulkanPushConstants *self,
|
||||
const GskVulkanPushConstants *src,
|
||||
const graphene_rect_t *rect)
|
||||
{
|
||||
if (!gsk_vulkan_clip_intersect_rect (&self->clip, &src->clip, rect))
|
||||
return FALSE;
|
||||
|
||||
graphene_matrix_init_from_matrix (&self->mvp, &src->mvp);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gsk_vulkan_push_constants_intersect_rounded (GskVulkanPushConstants *self,
|
||||
const GskVulkanPushConstants *src,
|
||||
const GskRoundedRect *rect)
|
||||
{
|
||||
if (!gsk_vulkan_clip_intersect_rounded_rect (&self->clip, &src->clip, rect))
|
||||
return FALSE;
|
||||
|
||||
graphene_matrix_init_from_matrix (&self->mvp, &src->mvp);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_vulkan_push_constants_wire_init (GskVulkanPushConstantsWire *wire,
|
||||
const GskVulkanPushConstants *self)
|
||||
{
|
||||
graphene_matrix_to_float (&self->mvp, wire->common.mvp);
|
||||
gsk_rounded_rect_to_float (&self->clip.rect, wire->common.clip);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_vulkan_push_constants_push (const GskVulkanPushConstants *self,
|
||||
VkCommandBuffer command_buffer,
|
||||
VkPipelineLayout pipeline_layout)
|
||||
{
|
||||
GskVulkanPushConstantsWire wire;
|
||||
|
||||
gsk_vulkan_push_constants_wire_init (&wire, scale, mvp, clip);
|
||||
gsk_vulkan_push_constants_wire_init (&wire, self);
|
||||
|
||||
vkCmdPushConstants (command_buffer,
|
||||
pipeline_layout,
|
||||
|
||||
@@ -6,15 +6,38 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GskVulkanPushConstants GskVulkanPushConstants;
|
||||
|
||||
struct _GskVulkanPushConstants
|
||||
{
|
||||
graphene_matrix_t mvp;
|
||||
GskVulkanClip clip;
|
||||
};
|
||||
|
||||
const VkPushConstantRange *
|
||||
gsk_vulkan_push_constants_get_ranges (void) G_GNUC_PURE;
|
||||
uint32_t gsk_vulkan_push_constants_get_range_count (void) G_GNUC_PURE;
|
||||
|
||||
void gsk_vulkan_push_constants_push (VkCommandBuffer command_buffer,
|
||||
VkPipelineLayout pipeline_layout,
|
||||
const graphene_vec2_t *scale,
|
||||
void gsk_vulkan_push_constants_init (GskVulkanPushConstants *constants,
|
||||
const graphene_matrix_t *mvp,
|
||||
const GskRoundedRect *clip);
|
||||
const graphene_rect_t *viewport);
|
||||
void gsk_vulkan_push_constants_init_copy (GskVulkanPushConstants *self,
|
||||
const GskVulkanPushConstants *src);
|
||||
|
||||
gboolean gsk_vulkan_push_constants_transform (GskVulkanPushConstants *self,
|
||||
const GskVulkanPushConstants *src,
|
||||
GskTransform *transform,
|
||||
const graphene_rect_t *viewport);
|
||||
gboolean gsk_vulkan_push_constants_intersect_rect (GskVulkanPushConstants *self,
|
||||
const GskVulkanPushConstants *src,
|
||||
const graphene_rect_t *rect);
|
||||
gboolean gsk_vulkan_push_constants_intersect_rounded (GskVulkanPushConstants *self,
|
||||
const GskVulkanPushConstants *src,
|
||||
const GskRoundedRect *rect);
|
||||
|
||||
void gsk_vulkan_push_constants_push (const GskVulkanPushConstants *self,
|
||||
VkCommandBuffer command_buffer,
|
||||
VkPipelineLayout pipeline_layout);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
+183
-301
@@ -23,23 +23,8 @@
|
||||
#include "gskvulkantexturepipelineprivate.h"
|
||||
#include "gskvulkanpushconstantsprivate.h"
|
||||
|
||||
#define DESCRIPTOR_POOL_MAXITEMS 50000
|
||||
|
||||
#define GDK_ARRAY_NAME gsk_descriptor_image_infos
|
||||
#define GDK_ARRAY_TYPE_NAME GskDescriptorImageInfos
|
||||
#define GDK_ARRAY_ELEMENT_TYPE VkDescriptorImageInfo
|
||||
#define GDK_ARRAY_BY_VALUE 1
|
||||
#define GDK_ARRAY_PREALLOC 1024
|
||||
#define GDK_ARRAY_NO_MEMSET 1
|
||||
#include "gdk/gdkarrayimpl.c"
|
||||
|
||||
#define GDK_ARRAY_NAME gsk_descriptor_buffer_infos
|
||||
#define GDK_ARRAY_TYPE_NAME GskDescriptorBufferInfos
|
||||
#define GDK_ARRAY_ELEMENT_TYPE VkDescriptorBufferInfo
|
||||
#define GDK_ARRAY_BY_VALUE 1
|
||||
#define GDK_ARRAY_PREALLOC 1024
|
||||
#define GDK_ARRAY_NO_MEMSET 1
|
||||
#include "gdk/gdkarrayimpl.c"
|
||||
#define DESCRIPTOR_POOL_MAXSETS 128
|
||||
#define DESCRIPTOR_POOL_MAXSETS_INCREASE 128
|
||||
|
||||
struct _GskVulkanRender
|
||||
{
|
||||
@@ -55,22 +40,20 @@ struct _GskVulkanRender
|
||||
VkFence fence;
|
||||
VkRenderPass render_pass;
|
||||
VkDescriptorSetLayout descriptor_set_layout;
|
||||
VkPipelineLayout pipeline_layout;
|
||||
VkPipelineLayout pipeline_layout[3]; /* indexed by number of textures */
|
||||
GskVulkanUploader *uploader;
|
||||
|
||||
GskDescriptorImageInfos descriptor_images;
|
||||
GskDescriptorImageInfos descriptor_samplers;
|
||||
GskDescriptorBufferInfos descriptor_buffers;
|
||||
GHashTable *descriptor_set_indexes;
|
||||
VkDescriptorPool descriptor_pool;
|
||||
VkDescriptorSet descriptor_set;
|
||||
uint32_t descriptor_pool_maxsets;
|
||||
VkDescriptorSet *descriptor_sets;
|
||||
gsize n_descriptor_sets;
|
||||
GskVulkanPipeline *pipelines[GSK_VULKAN_N_PIPELINES];
|
||||
|
||||
GskVulkanImage *target;
|
||||
|
||||
VkSampler samplers[3];
|
||||
GskVulkanBuffer *storage_buffer;
|
||||
guchar *storage_buffer_memory;
|
||||
gsize storage_buffer_used;
|
||||
VkSampler sampler;
|
||||
VkSampler repeating_sampler;
|
||||
|
||||
GList *render_passes;
|
||||
GSList *cleanup_images;
|
||||
@@ -120,6 +103,9 @@ gsk_vulkan_render_setup (GskVulkanRender *self,
|
||||
}
|
||||
}
|
||||
|
||||
static guint desc_set_index_hash (gconstpointer v);
|
||||
static gboolean desc_set_index_equal (gconstpointer v1, gconstpointer v2);
|
||||
|
||||
GskVulkanRender *
|
||||
gsk_vulkan_render_new (GskRenderer *renderer,
|
||||
GdkVulkanContext *context)
|
||||
@@ -132,9 +118,7 @@ gsk_vulkan_render_new (GskRenderer *renderer,
|
||||
self->vulkan = context;
|
||||
self->renderer = renderer;
|
||||
self->framebuffers = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
gsk_descriptor_image_infos_init (&self->descriptor_images);
|
||||
gsk_descriptor_image_infos_init (&self->descriptor_samplers);
|
||||
gsk_descriptor_buffer_infos_init (&self->descriptor_buffers);
|
||||
self->descriptor_set_indexes = g_hash_table_new_full (desc_set_index_hash, desc_set_index_equal, NULL, g_free);
|
||||
|
||||
device = gdk_vulkan_context_get_device (self->vulkan);
|
||||
|
||||
@@ -147,24 +131,16 @@ gsk_vulkan_render_new (GskRenderer *renderer,
|
||||
NULL,
|
||||
&self->fence);
|
||||
|
||||
self->descriptor_pool_maxsets = DESCRIPTOR_POOL_MAXSETS;
|
||||
GSK_VK_CHECK (vkCreateDescriptorPool, device,
|
||||
&(VkDescriptorPoolCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
|
||||
.flags = VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT,
|
||||
.maxSets = 1,
|
||||
.poolSizeCount = 3,
|
||||
.pPoolSizes = (VkDescriptorPoolSize[3]) {
|
||||
.maxSets = self->descriptor_pool_maxsets,
|
||||
.poolSizeCount = 1,
|
||||
.pPoolSizes = (VkDescriptorPoolSize[1]) {
|
||||
{
|
||||
.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
|
||||
.descriptorCount = DESCRIPTOR_POOL_MAXITEMS
|
||||
},
|
||||
{
|
||||
.type = VK_DESCRIPTOR_TYPE_SAMPLER,
|
||||
.descriptorCount = DESCRIPTOR_POOL_MAXITEMS
|
||||
},
|
||||
{
|
||||
.type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
||||
.descriptorCount = DESCRIPTOR_POOL_MAXITEMS
|
||||
.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||
.descriptorCount = self->descriptor_pool_maxsets
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -214,74 +190,53 @@ gsk_vulkan_render_new (GskRenderer *renderer,
|
||||
GSK_VK_CHECK (vkCreateDescriptorSetLayout, device,
|
||||
&(VkDescriptorSetLayoutCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
|
||||
.bindingCount = 3,
|
||||
.flags = VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT,
|
||||
.pBindings = (VkDescriptorSetLayoutBinding[3]) {
|
||||
.bindingCount = 1,
|
||||
.pBindings = (VkDescriptorSetLayoutBinding[1]) {
|
||||
{
|
||||
.binding = 0,
|
||||
.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
|
||||
.descriptorCount = DESCRIPTOR_POOL_MAXITEMS,
|
||||
.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||
.descriptorCount = 1,
|
||||
.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT
|
||||
},
|
||||
{
|
||||
.binding = 1,
|
||||
.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER,
|
||||
.descriptorCount = DESCRIPTOR_POOL_MAXITEMS,
|
||||
.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT
|
||||
},
|
||||
{
|
||||
.binding = 2,
|
||||
.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
||||
.descriptorCount = DESCRIPTOR_POOL_MAXITEMS,
|
||||
.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT
|
||||
},
|
||||
},
|
||||
.pNext = &(VkDescriptorSetLayoutBindingFlagsCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO,
|
||||
.bindingCount = 3,
|
||||
.pBindingFlags = (VkDescriptorBindingFlags[3]) {
|
||||
VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT
|
||||
| VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT
|
||||
| VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT,
|
||||
VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT
|
||||
| VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT
|
||||
| VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT,
|
||||
VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT
|
||||
| VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT
|
||||
| VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT,
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
NULL,
|
||||
&self->descriptor_set_layout);
|
||||
|
||||
GSK_VK_CHECK (vkCreatePipelineLayout, device,
|
||||
&(VkPipelineLayoutCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
|
||||
.setLayoutCount = 1,
|
||||
.pSetLayouts = (VkDescriptorSetLayout[1]) {
|
||||
self->descriptor_set_layout
|
||||
for (guint i = 0; i < 3; i++)
|
||||
{
|
||||
VkDescriptorSetLayout layouts[3] = {
|
||||
self->descriptor_set_layout,
|
||||
self->descriptor_set_layout,
|
||||
self->descriptor_set_layout
|
||||
};
|
||||
|
||||
GSK_VK_CHECK (vkCreatePipelineLayout, device,
|
||||
&(VkPipelineLayoutCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
|
||||
.setLayoutCount = i,
|
||||
.pSetLayouts = layouts,
|
||||
.pushConstantRangeCount = gsk_vulkan_push_constants_get_range_count (),
|
||||
.pPushConstantRanges = gsk_vulkan_push_constants_get_ranges ()
|
||||
},
|
||||
.pushConstantRangeCount = gsk_vulkan_push_constants_get_range_count (),
|
||||
.pPushConstantRanges = gsk_vulkan_push_constants_get_ranges ()
|
||||
},
|
||||
NULL,
|
||||
&self->pipeline_layout);
|
||||
NULL,
|
||||
&self->pipeline_layout[i]);
|
||||
}
|
||||
|
||||
GSK_VK_CHECK (vkCreateSampler, device,
|
||||
&(VkSamplerCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
|
||||
.magFilter = VK_FILTER_LINEAR,
|
||||
.minFilter = VK_FILTER_LINEAR,
|
||||
.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||
.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||
.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,
|
||||
.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,
|
||||
.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT,
|
||||
.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK,
|
||||
.unnormalizedCoordinates = VK_FALSE,
|
||||
.maxAnisotropy = 1.0,
|
||||
},
|
||||
NULL,
|
||||
&self->samplers[GSK_VULKAN_SAMPLER_DEFAULT]);
|
||||
&self->sampler);
|
||||
|
||||
GSK_VK_CHECK (vkCreateSampler, device,
|
||||
&(VkSamplerCreateInfo) {
|
||||
@@ -296,23 +251,7 @@ gsk_vulkan_render_new (GskRenderer *renderer,
|
||||
.maxAnisotropy = 1.0,
|
||||
},
|
||||
NULL,
|
||||
&self->samplers[GSK_VULKAN_SAMPLER_REPEAT]);
|
||||
|
||||
GSK_VK_CHECK (vkCreateSampler, device,
|
||||
&(VkSamplerCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
|
||||
.magFilter = VK_FILTER_NEAREST,
|
||||
.minFilter = VK_FILTER_NEAREST,
|
||||
.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||
.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||
.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT,
|
||||
.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK,
|
||||
.unnormalizedCoordinates = VK_FALSE,
|
||||
.maxAnisotropy = 1.0,
|
||||
},
|
||||
NULL,
|
||||
&self->samplers[GSK_VULKAN_SAMPLER_NEAREST]);
|
||||
|
||||
&self->repeating_sampler);
|
||||
|
||||
self->uploader = gsk_vulkan_uploader_new (self->vulkan, self->command_pool);
|
||||
|
||||
@@ -376,12 +315,6 @@ gsk_vulkan_render_get_framebuffer (GskVulkanRender *self,
|
||||
return fb->framebuffer;
|
||||
}
|
||||
|
||||
VkFence
|
||||
gsk_vulkan_render_get_fence (GskVulkanRender *self)
|
||||
{
|
||||
return self->fence;
|
||||
}
|
||||
|
||||
void
|
||||
gsk_vulkan_render_add_cleanup_image (GskVulkanRender *self,
|
||||
GskVulkanImage *image)
|
||||
@@ -405,13 +338,15 @@ gsk_vulkan_render_add_node (GskVulkanRender *self,
|
||||
GskRenderNode *node)
|
||||
{
|
||||
GskVulkanRenderPass *pass;
|
||||
graphene_vec2_t scale;
|
||||
graphene_matrix_t mv;
|
||||
|
||||
graphene_vec2_init (&scale, self->scale, self->scale);
|
||||
graphene_matrix_init_scale (&mv, self->scale, self->scale, 1.0);
|
||||
|
||||
pass = gsk_vulkan_render_pass_new (self->vulkan,
|
||||
self->target,
|
||||
&scale,
|
||||
self->scale,
|
||||
self->scale,
|
||||
&mv,
|
||||
&self->viewport,
|
||||
self->clip,
|
||||
VK_NULL_HANDLE);
|
||||
@@ -490,7 +425,7 @@ gsk_vulkan_render_get_pipeline (GskVulkanRender *self,
|
||||
|
||||
if (self->pipelines[type] == NULL)
|
||||
self->pipelines[type] = pipeline_info[type].create_func (self->vulkan,
|
||||
self->pipeline_layout,
|
||||
self->pipeline_layout[pipeline_info[type].num_textures],
|
||||
pipeline_info[type].name,
|
||||
self->render_pass);
|
||||
|
||||
@@ -498,130 +433,71 @@ gsk_vulkan_render_get_pipeline (GskVulkanRender *self,
|
||||
}
|
||||
|
||||
VkDescriptorSet
|
||||
gsk_vulkan_render_get_descriptor_set (GskVulkanRender *self)
|
||||
gsk_vulkan_render_get_descriptor_set (GskVulkanRender *self,
|
||||
gsize id)
|
||||
{
|
||||
return self->descriptor_set;
|
||||
g_assert (id < self->n_descriptor_sets);
|
||||
|
||||
return self->descriptor_sets[id];
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
gsize index;
|
||||
GskVulkanImage *image;
|
||||
gboolean repeat;
|
||||
} HashDescriptorSetIndexEntry;
|
||||
|
||||
static guint
|
||||
desc_set_index_hash (gconstpointer v)
|
||||
{
|
||||
const HashDescriptorSetIndexEntry *e = v;
|
||||
|
||||
return GPOINTER_TO_UINT (e->image) + e->repeat;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
desc_set_index_equal (gconstpointer v1, gconstpointer v2)
|
||||
{
|
||||
const HashDescriptorSetIndexEntry *e1 = v1;
|
||||
const HashDescriptorSetIndexEntry *e2 = v2;
|
||||
|
||||
return e1->image == e2->image && e1->repeat == e2->repeat;
|
||||
}
|
||||
|
||||
gsize
|
||||
gsk_vulkan_render_get_sampler_descriptor (GskVulkanRender *self,
|
||||
GskVulkanRenderSampler render_sampler)
|
||||
gsk_vulkan_render_reserve_descriptor_set (GskVulkanRender *self,
|
||||
GskVulkanImage *source,
|
||||
gboolean repeat)
|
||||
{
|
||||
VkSampler sampler = self->samplers[render_sampler];
|
||||
gsize i;
|
||||
HashDescriptorSetIndexEntry lookup;
|
||||
HashDescriptorSetIndexEntry *entry;
|
||||
|
||||
/* If this ever shows up in profiles, add a hash table */
|
||||
for (i = 0; i < gsk_descriptor_image_infos_get_size (&self->descriptor_samplers); i++)
|
||||
{
|
||||
if (gsk_descriptor_image_infos_get (&self->descriptor_samplers, i)->sampler == sampler)
|
||||
return i;
|
||||
}
|
||||
g_assert (source != NULL);
|
||||
|
||||
g_assert (i < DESCRIPTOR_POOL_MAXITEMS);
|
||||
lookup.image = source;
|
||||
lookup.repeat = repeat;
|
||||
|
||||
gsk_descriptor_image_infos_append (&self->descriptor_samplers,
|
||||
&(VkDescriptorImageInfo) {
|
||||
.sampler = sampler,
|
||||
});
|
||||
entry = g_hash_table_lookup (self->descriptor_set_indexes, &lookup);
|
||||
if (entry)
|
||||
return entry->index;
|
||||
|
||||
return i;
|
||||
}
|
||||
entry = g_new (HashDescriptorSetIndexEntry, 1);
|
||||
entry->image = source;
|
||||
entry->repeat = repeat;
|
||||
entry->index = g_hash_table_size (self->descriptor_set_indexes);
|
||||
g_hash_table_add (self->descriptor_set_indexes, entry);
|
||||
|
||||
gsize
|
||||
gsk_vulkan_render_get_image_descriptor (GskVulkanRender *self,
|
||||
GskVulkanImage *image)
|
||||
{
|
||||
gsize result;
|
||||
|
||||
result = gsk_descriptor_image_infos_get_size (&self->descriptor_images);
|
||||
gsk_descriptor_image_infos_append (&self->descriptor_images,
|
||||
&(VkDescriptorImageInfo) {
|
||||
.sampler = VK_NULL_HANDLE,
|
||||
.imageView = gsk_vulkan_image_get_image_view (image),
|
||||
.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
|
||||
});
|
||||
|
||||
g_assert (result < DESCRIPTOR_POOL_MAXITEMS);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_vulkan_render_ensure_storage_buffer (GskVulkanRender *self)
|
||||
{
|
||||
if (self->storage_buffer_memory != NULL)
|
||||
return;
|
||||
|
||||
if (self->storage_buffer == NULL)
|
||||
{
|
||||
self->storage_buffer = gsk_vulkan_buffer_new_storage (self->vulkan,
|
||||
/* random */
|
||||
sizeof (float) * 1024 * 1024);
|
||||
}
|
||||
|
||||
self->storage_buffer_memory = gsk_vulkan_buffer_map (self->storage_buffer);
|
||||
|
||||
if (gsk_vulkan_render_get_buffer_descriptor (self, self->storage_buffer) != 0)
|
||||
{
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
|
||||
gsize
|
||||
gsk_vulkan_render_get_buffer_descriptor (GskVulkanRender *self,
|
||||
GskVulkanBuffer *buffer)
|
||||
{
|
||||
gsize result;
|
||||
|
||||
gsk_vulkan_render_ensure_storage_buffer (self);
|
||||
|
||||
result = gsk_descriptor_buffer_infos_get_size (&self->descriptor_buffers);
|
||||
gsk_descriptor_buffer_infos_append (&self->descriptor_buffers,
|
||||
&(VkDescriptorBufferInfo) {
|
||||
.buffer = gsk_vulkan_buffer_get_buffer (buffer),
|
||||
.offset = 0,
|
||||
.range = VK_WHOLE_SIZE
|
||||
});
|
||||
|
||||
g_assert (result < DESCRIPTOR_POOL_MAXITEMS);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline gsize
|
||||
round_up (gsize number, gsize divisor)
|
||||
{
|
||||
return (number + divisor - 1) / divisor * divisor;
|
||||
}
|
||||
|
||||
guchar *
|
||||
gsk_vulkan_render_get_buffer_memory (GskVulkanRender *self,
|
||||
gsize size,
|
||||
gsize alignment,
|
||||
gsize *out_offset)
|
||||
{
|
||||
guchar *result;
|
||||
|
||||
g_assert (alignment >= sizeof (float));
|
||||
|
||||
gsk_vulkan_render_ensure_storage_buffer (self);
|
||||
|
||||
self->storage_buffer_used = round_up (self->storage_buffer_used, alignment);
|
||||
result = self->storage_buffer_memory + self->storage_buffer_used;
|
||||
*out_offset = self->storage_buffer_used / sizeof (float);
|
||||
|
||||
self->storage_buffer_used += size;
|
||||
|
||||
return result;
|
||||
return entry->index;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_vulkan_render_prepare_descriptor_sets (GskVulkanRender *self)
|
||||
{
|
||||
GHashTableIter iter;
|
||||
gpointer key;
|
||||
VkDevice device;
|
||||
VkWriteDescriptorSet descriptor_sets[3];
|
||||
gsize n_descriptor_sets;
|
||||
GList *l;
|
||||
guint i, needed_sets;
|
||||
|
||||
device = gdk_vulkan_context_get_device (self->vulkan);
|
||||
|
||||
@@ -631,77 +507,85 @@ gsk_vulkan_render_prepare_descriptor_sets (GskVulkanRender *self)
|
||||
gsk_vulkan_render_pass_reserve_descriptor_sets (pass, self);
|
||||
}
|
||||
|
||||
if (gsk_descriptor_image_infos_get_size (&self->descriptor_samplers) == 0 &&
|
||||
gsk_descriptor_image_infos_get_size (&self->descriptor_images) == 0 &&
|
||||
gsk_descriptor_buffer_infos_get_size (&self->descriptor_buffers) == 0)
|
||||
return;
|
||||
|
||||
if (self->storage_buffer_memory)
|
||||
needed_sets = g_hash_table_size (self->descriptor_set_indexes);
|
||||
if (needed_sets > self->n_descriptor_sets)
|
||||
{
|
||||
gsk_vulkan_buffer_unmap (self->storage_buffer);
|
||||
self->storage_buffer_memory = NULL;
|
||||
if (needed_sets > self->descriptor_pool_maxsets)
|
||||
{
|
||||
guint added_sets = needed_sets - self->descriptor_pool_maxsets;
|
||||
added_sets = added_sets + DESCRIPTOR_POOL_MAXSETS_INCREASE - 1;
|
||||
added_sets -= added_sets % DESCRIPTOR_POOL_MAXSETS_INCREASE;
|
||||
|
||||
vkDestroyDescriptorPool (device,
|
||||
self->descriptor_pool,
|
||||
NULL);
|
||||
self->descriptor_pool_maxsets += added_sets;
|
||||
GSK_VK_CHECK (vkCreateDescriptorPool, device,
|
||||
&(VkDescriptorPoolCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
|
||||
.maxSets = self->descriptor_pool_maxsets,
|
||||
.poolSizeCount = 1,
|
||||
.pPoolSizes = (VkDescriptorPoolSize[1]) {
|
||||
{
|
||||
.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||
.descriptorCount = self->descriptor_pool_maxsets
|
||||
}
|
||||
}
|
||||
},
|
||||
NULL,
|
||||
&self->descriptor_pool);
|
||||
}
|
||||
else
|
||||
{
|
||||
GSK_VK_CHECK (vkResetDescriptorPool, device,
|
||||
self->descriptor_pool,
|
||||
0);
|
||||
}
|
||||
|
||||
self->n_descriptor_sets = needed_sets;
|
||||
self->descriptor_sets = g_renew (VkDescriptorSet, self->descriptor_sets, needed_sets);
|
||||
}
|
||||
|
||||
VkDescriptorSetLayout *layouts = g_newa (VkDescriptorSetLayout, needed_sets);
|
||||
for (i = 0; i < needed_sets; i++)
|
||||
layouts[i] = self->descriptor_set_layout;
|
||||
|
||||
GSK_VK_CHECK (vkAllocateDescriptorSets, device,
|
||||
&(VkDescriptorSetAllocateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
|
||||
.descriptorPool = self->descriptor_pool,
|
||||
.descriptorSetCount = 1,
|
||||
.pSetLayouts = &self->descriptor_set_layout,
|
||||
.pNext = &(VkDescriptorSetVariableDescriptorCountAllocateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO,
|
||||
.descriptorSetCount = 1,
|
||||
.pDescriptorCounts = (uint32_t[1]) {
|
||||
gsk_descriptor_image_infos_get_size (&self->descriptor_images)
|
||||
+ gsk_descriptor_image_infos_get_size (&self->descriptor_samplers)
|
||||
+ gsk_descriptor_buffer_infos_get_size (&self->descriptor_buffers)
|
||||
}
|
||||
}
|
||||
.descriptorSetCount = needed_sets,
|
||||
.pSetLayouts = layouts
|
||||
},
|
||||
&self->descriptor_set);
|
||||
self->descriptor_sets);
|
||||
|
||||
n_descriptor_sets = 0;
|
||||
if (gsk_descriptor_image_infos_get_size (&self->descriptor_images) > 0)
|
||||
g_hash_table_iter_init (&iter, self->descriptor_set_indexes);
|
||||
while (g_hash_table_iter_next (&iter, &key, NULL))
|
||||
{
|
||||
descriptor_sets[n_descriptor_sets++] = (VkWriteDescriptorSet) {
|
||||
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
||||
.dstSet = self->descriptor_set,
|
||||
.dstBinding = 0,
|
||||
.dstArrayElement = 0,
|
||||
.descriptorCount = gsk_descriptor_image_infos_get_size (&self->descriptor_images),
|
||||
.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
|
||||
.pImageInfo = gsk_descriptor_image_infos_get_data (&self->descriptor_images)
|
||||
};
|
||||
}
|
||||
if (gsk_descriptor_image_infos_get_size (&self->descriptor_samplers) > 0)
|
||||
{
|
||||
descriptor_sets[n_descriptor_sets++] = (VkWriteDescriptorSet) {
|
||||
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
||||
.dstSet = self->descriptor_set,
|
||||
.dstBinding = 1,
|
||||
.dstArrayElement = 0,
|
||||
.descriptorCount = gsk_descriptor_image_infos_get_size (&self->descriptor_samplers),
|
||||
.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER,
|
||||
.pImageInfo = gsk_descriptor_image_infos_get_data (&self->descriptor_samplers)
|
||||
};
|
||||
}
|
||||
if (gsk_descriptor_buffer_infos_get_size (&self->descriptor_buffers) > 0)
|
||||
{
|
||||
descriptor_sets[n_descriptor_sets++] = (VkWriteDescriptorSet) {
|
||||
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
||||
.dstSet = self->descriptor_set,
|
||||
.dstBinding = 2,
|
||||
.dstArrayElement = 0,
|
||||
.descriptorCount = gsk_descriptor_buffer_infos_get_size (&self->descriptor_buffers),
|
||||
.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
||||
.pBufferInfo = gsk_descriptor_buffer_infos_get_data (&self->descriptor_buffers)
|
||||
};
|
||||
}
|
||||
HashDescriptorSetIndexEntry *entry = key;
|
||||
GskVulkanImage *image = entry->image;
|
||||
gsize id = entry->index;
|
||||
gboolean repeat = entry->repeat;
|
||||
|
||||
vkUpdateDescriptorSets (device,
|
||||
n_descriptor_sets,
|
||||
descriptor_sets,
|
||||
0, NULL);
|
||||
vkUpdateDescriptorSets (device,
|
||||
1,
|
||||
(VkWriteDescriptorSet[1]) {
|
||||
{
|
||||
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
||||
.dstSet = self->descriptor_sets[id],
|
||||
.dstBinding = 0,
|
||||
.dstArrayElement = 0,
|
||||
.descriptorCount = 1,
|
||||
.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||
.pImageInfo = &(VkDescriptorImageInfo) {
|
||||
.sampler = repeat ? self->repeating_sampler : self->sampler,
|
||||
.imageView = gsk_vulkan_image_get_image_view (image),
|
||||
.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
|
||||
}
|
||||
}
|
||||
},
|
||||
0, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -730,7 +614,7 @@ gsk_vulkan_render_draw (GskVulkanRender *self)
|
||||
|
||||
command_buffer = gsk_vulkan_command_pool_get_buffer (self->command_pool);
|
||||
|
||||
gsk_vulkan_render_pass_draw (pass, self, self->pipeline_layout, command_buffer);
|
||||
gsk_vulkan_render_pass_draw (pass, self, 3, self->pipeline_layout, command_buffer);
|
||||
|
||||
gsk_vulkan_command_pool_submit_buffer (self->command_pool,
|
||||
command_buffer,
|
||||
@@ -791,12 +675,10 @@ gsk_vulkan_render_cleanup (GskVulkanRender *self)
|
||||
|
||||
gsk_vulkan_command_pool_reset (self->command_pool);
|
||||
|
||||
g_hash_table_remove_all (self->descriptor_set_indexes);
|
||||
GSK_VK_CHECK (vkResetDescriptorPool, device,
|
||||
self->descriptor_pool,
|
||||
0);
|
||||
gsk_descriptor_image_infos_set_size (&self->descriptor_images, 0);
|
||||
gsk_descriptor_image_infos_set_size (&self->descriptor_samplers, 0);
|
||||
gsk_descriptor_buffer_infos_set_size (&self->descriptor_buffers, 0);
|
||||
|
||||
g_list_free_full (self->render_passes, (GDestroyNotify) gsk_vulkan_render_pass_free);
|
||||
self->render_passes = NULL;
|
||||
@@ -838,10 +720,10 @@ gsk_vulkan_render_free (GskVulkanRender *self)
|
||||
|
||||
g_clear_pointer (&self->uploader, gsk_vulkan_uploader_free);
|
||||
|
||||
|
||||
vkDestroyPipelineLayout (device,
|
||||
self->pipeline_layout,
|
||||
NULL);
|
||||
for (i = 0; i < 3; i++)
|
||||
vkDestroyPipelineLayout (device,
|
||||
self->pipeline_layout[i],
|
||||
NULL);
|
||||
|
||||
vkDestroyRenderPass (device,
|
||||
self->render_pass,
|
||||
@@ -850,9 +732,8 @@ gsk_vulkan_render_free (GskVulkanRender *self)
|
||||
vkDestroyDescriptorPool (device,
|
||||
self->descriptor_pool,
|
||||
NULL);
|
||||
gsk_descriptor_image_infos_clear (&self->descriptor_images);
|
||||
gsk_descriptor_image_infos_clear (&self->descriptor_samplers);
|
||||
gsk_descriptor_buffer_infos_clear (&self->descriptor_buffers);
|
||||
g_free (self->descriptor_sets);
|
||||
g_hash_table_unref (self->descriptor_set_indexes);
|
||||
|
||||
vkDestroyDescriptorSetLayout (device,
|
||||
self->descriptor_set_layout,
|
||||
@@ -862,12 +743,13 @@ gsk_vulkan_render_free (GskVulkanRender *self)
|
||||
self->fence,
|
||||
NULL);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (self->samplers); i++)
|
||||
{
|
||||
vkDestroySampler (device,
|
||||
self->samplers[i],
|
||||
NULL);
|
||||
}
|
||||
vkDestroySampler (device,
|
||||
self->sampler,
|
||||
NULL);
|
||||
|
||||
vkDestroySampler (device,
|
||||
self->repeating_sampler,
|
||||
NULL);
|
||||
|
||||
gsk_vulkan_command_pool_free (self->command_pool);
|
||||
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
|
||||
#include <graphene.h>
|
||||
|
||||
#define GSK_VULKAN_MAX_RENDERS 4
|
||||
|
||||
typedef struct _GskVulkanTextureData GskVulkanTextureData;
|
||||
|
||||
struct _GskVulkanTextureData {
|
||||
@@ -53,7 +51,7 @@ struct _GskVulkanRenderer
|
||||
guint n_targets;
|
||||
GskVulkanImage **targets;
|
||||
|
||||
GskVulkanRender *renders[GSK_VULKAN_MAX_RENDERS];
|
||||
GskVulkanRender *render;
|
||||
|
||||
GSList *textures;
|
||||
|
||||
@@ -163,38 +161,6 @@ gsk_vulkan_renderer_update_images_cb (GdkVulkanContext *context,
|
||||
}
|
||||
}
|
||||
|
||||
static GskVulkanRender *
|
||||
gsk_vulkan_renderer_get_render (GskVulkanRenderer *self)
|
||||
{
|
||||
VkFence fences[G_N_ELEMENTS (self->renders)];
|
||||
VkDevice device;
|
||||
guint i;
|
||||
|
||||
device = gdk_vulkan_context_get_device (self->vulkan);
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
for (i = 0; i < G_N_ELEMENTS (self->renders); i++)
|
||||
{
|
||||
if (self->renders[i] == NULL)
|
||||
{
|
||||
self->renders[i] = gsk_vulkan_render_new (GSK_RENDERER (self), self->vulkan);
|
||||
return self->renders[i];
|
||||
}
|
||||
|
||||
fences[i] = gsk_vulkan_render_get_fence (self->renders[i]);
|
||||
if (vkGetFenceStatus (device, fences[i]) == VK_SUCCESS)
|
||||
return self->renders[i];
|
||||
}
|
||||
|
||||
GSK_VK_CHECK (vkWaitForFences, device,
|
||||
G_N_ELEMENTS (fences),
|
||||
fences,
|
||||
VK_FALSE,
|
||||
INT64_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gsk_vulkan_renderer_realize (GskRenderer *renderer,
|
||||
GdkSurface *surface,
|
||||
@@ -219,6 +185,8 @@ gsk_vulkan_renderer_realize (GskRenderer *renderer,
|
||||
self);
|
||||
gsk_vulkan_renderer_update_images_cb (self->vulkan, self);
|
||||
|
||||
self->render = gsk_vulkan_render_new (renderer, self->vulkan);
|
||||
|
||||
self->glyph_cache = gsk_vulkan_glyph_cache_new (renderer, self->vulkan);
|
||||
|
||||
return TRUE;
|
||||
@@ -229,7 +197,6 @@ gsk_vulkan_renderer_unrealize (GskRenderer *renderer)
|
||||
{
|
||||
GskVulkanRenderer *self = GSK_VULKAN_RENDERER (renderer);
|
||||
GSList *l;
|
||||
guint i;
|
||||
|
||||
g_clear_object (&self->glyph_cache);
|
||||
|
||||
@@ -242,8 +209,7 @@ gsk_vulkan_renderer_unrealize (GskRenderer *renderer)
|
||||
}
|
||||
g_clear_pointer (&self->textures, g_slist_free);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (self->renders); i++)
|
||||
g_clear_pointer (&self->renders[i], gsk_vulkan_render_free);
|
||||
g_clear_pointer (&self->render, gsk_vulkan_render_free);
|
||||
|
||||
gsk_vulkan_renderer_free_targets (self);
|
||||
g_signal_handlers_disconnect_by_func(self->vulkan,
|
||||
@@ -262,7 +228,6 @@ gsk_vulkan_renderer_render_texture (GskRenderer *renderer,
|
||||
GskVulkanRender *render;
|
||||
GskVulkanImage *image;
|
||||
GdkTexture *texture;
|
||||
graphene_rect_t rounded_viewport;
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
GskProfiler *profiler;
|
||||
gint64 cpu_time;
|
||||
@@ -279,15 +244,11 @@ gsk_vulkan_renderer_render_texture (GskRenderer *renderer,
|
||||
|
||||
render = gsk_vulkan_render_new (renderer, self->vulkan);
|
||||
|
||||
rounded_viewport = GRAPHENE_RECT_INIT (viewport->origin.x,
|
||||
viewport->origin.y,
|
||||
ceil (viewport->size.width),
|
||||
ceil (viewport->size.height));
|
||||
image = gsk_vulkan_image_new_for_framebuffer (self->vulkan,
|
||||
rounded_viewport.size.width,
|
||||
rounded_viewport.size.height);
|
||||
ceil (viewport->size.width),
|
||||
ceil (viewport->size.height));
|
||||
|
||||
gsk_vulkan_render_reset (render, image, &rounded_viewport, NULL);
|
||||
gsk_vulkan_render_reset (render, image, viewport, NULL);
|
||||
gsk_vulkan_render_add_node (render, root);
|
||||
gsk_vulkan_render_upload (render);
|
||||
gsk_vulkan_render_draw (render);
|
||||
@@ -340,7 +301,7 @@ gsk_vulkan_renderer_render (GskRenderer *renderer,
|
||||
#endif
|
||||
|
||||
gdk_draw_context_begin_frame (GDK_DRAW_CONTEXT (self->vulkan), region);
|
||||
render = gsk_vulkan_renderer_get_render (self);
|
||||
render = self->render;
|
||||
|
||||
render_region = get_render_region (self);
|
||||
draw_index = gdk_vulkan_context_get_draw_index (self->vulkan);
|
||||
@@ -422,13 +383,20 @@ gsk_vulkan_renderer_ref_texture_image (GskVulkanRenderer *self,
|
||||
GskVulkanUploader *uploader)
|
||||
{
|
||||
GskVulkanTextureData *data;
|
||||
cairo_surface_t *surface;
|
||||
GskVulkanImage *image;
|
||||
|
||||
data = gdk_texture_get_render_data (texture, self);
|
||||
if (data)
|
||||
return g_object_ref (data->image);
|
||||
|
||||
image = gsk_vulkan_image_new_from_texture (uploader, texture);
|
||||
surface = gdk_texture_download_surface (texture);
|
||||
image = gsk_vulkan_image_new_from_data (uploader,
|
||||
cairo_image_surface_get_data (surface),
|
||||
cairo_image_surface_get_width (surface),
|
||||
cairo_image_surface_get_height (surface),
|
||||
cairo_image_surface_get_stride (surface));
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
data = g_new0 (GskVulkanTextureData, 1);
|
||||
data->image = image;
|
||||
|
||||
+879
-1070
File diff suppressed because it is too large
Load Diff
@@ -12,8 +12,10 @@ G_BEGIN_DECLS
|
||||
|
||||
GskVulkanRenderPass * gsk_vulkan_render_pass_new (GdkVulkanContext *context,
|
||||
GskVulkanImage *target,
|
||||
const graphene_vec2_t *scale,
|
||||
const graphene_rect_t *viewport,
|
||||
float scale_x,
|
||||
float scale_y,
|
||||
graphene_matrix_t *mv,
|
||||
graphene_rect_t *viewport,
|
||||
cairo_region_t *clip,
|
||||
VkSemaphore signal_semaphore);
|
||||
|
||||
@@ -30,7 +32,8 @@ void gsk_vulkan_render_pass_reserve_descriptor_sets (GskVulk
|
||||
GskVulkanRender *render);
|
||||
void gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self,
|
||||
GskVulkanRender *render,
|
||||
VkPipelineLayout pipeline_layout,
|
||||
guint layout_count,
|
||||
VkPipelineLayout *pipeline_layout,
|
||||
VkCommandBuffer command_buffer);
|
||||
gsize gsk_vulkan_render_pass_get_wait_semaphores (GskVulkanRenderPass *self,
|
||||
VkSemaphore **semaphores);
|
||||
|
||||
@@ -51,12 +51,6 @@ typedef enum {
|
||||
GSK_VULKAN_N_PIPELINES
|
||||
} GskVulkanPipelineType;
|
||||
|
||||
typedef enum {
|
||||
GSK_VULKAN_SAMPLER_DEFAULT,
|
||||
GSK_VULKAN_SAMPLER_REPEAT,
|
||||
GSK_VULKAN_SAMPLER_NEAREST
|
||||
} GskVulkanRenderSampler;
|
||||
|
||||
GskVulkanRender * gsk_vulkan_render_new (GskRenderer *renderer,
|
||||
GdkVulkanContext *context);
|
||||
void gsk_vulkan_render_free (GskVulkanRender *self);
|
||||
@@ -82,18 +76,11 @@ void gsk_vulkan_render_upload (GskVulk
|
||||
|
||||
GskVulkanPipeline * gsk_vulkan_render_get_pipeline (GskVulkanRender *self,
|
||||
GskVulkanPipelineType pipeline_type);
|
||||
gsize gsk_vulkan_render_get_sampler_descriptor (GskVulkanRender *self,
|
||||
GskVulkanRenderSampler render_sampler);
|
||||
gsize gsk_vulkan_render_get_image_descriptor (GskVulkanRender *self,
|
||||
GskVulkanImage *source);
|
||||
gsize gsk_vulkan_render_get_buffer_descriptor (GskVulkanRender *self,
|
||||
GskVulkanBuffer *buffer);
|
||||
guchar * gsk_vulkan_render_get_buffer_memory (GskVulkanRender *self,
|
||||
gsize size,
|
||||
gsize alignment,
|
||||
gsize *out_offset);
|
||||
VkDescriptorSet gsk_vulkan_render_get_descriptor_set (GskVulkanRender *self);
|
||||
|
||||
VkDescriptorSet gsk_vulkan_render_get_descriptor_set (GskVulkanRender *self,
|
||||
gsize id);
|
||||
gsize gsk_vulkan_render_reserve_descriptor_set (GskVulkanRender *self,
|
||||
GskVulkanImage *source,
|
||||
gboolean repeat);
|
||||
void gsk_vulkan_render_draw (GskVulkanRender *self);
|
||||
|
||||
void gsk_vulkan_render_submit (GskVulkanRender *self);
|
||||
@@ -101,7 +88,6 @@ void gsk_vulkan_render_submit (GskVulk
|
||||
GdkTexture * gsk_vulkan_render_download_target (GskVulkanRender *self);
|
||||
VkFramebuffer gsk_vulkan_render_get_framebuffer (GskVulkanRender *self,
|
||||
GskVulkanImage *image);
|
||||
VkFence gsk_vulkan_render_get_fence (GskVulkanRender *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ struct _GskVulkanTextInstance
|
||||
float rect[4];
|
||||
float tex_rect[4];
|
||||
float color[4];
|
||||
guint32 tex_id[2];
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GskVulkanTextPipeline, gsk_vulkan_text_pipeline, GSK_TYPE_VULKAN_PIPELINE)
|
||||
@@ -47,12 +46,6 @@ gsk_vulkan_text_pipeline_get_input_state_create_info (GskVulkanPipeline *self)
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanTextInstance, color),
|
||||
},
|
||||
{
|
||||
.location = 3,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32_UINT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanTextInstance, tex_id),
|
||||
}
|
||||
};
|
||||
static const VkPipelineVertexInputStateCreateInfo info = {
|
||||
@@ -98,12 +91,18 @@ gsk_vulkan_text_pipeline_new (GdkVulkanContext *context,
|
||||
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_TEXT_PIPELINE, context, layout, shader_name, render_pass);
|
||||
}
|
||||
|
||||
gsize
|
||||
gsk_vulkan_text_pipeline_count_vertex_data (GskVulkanTextPipeline *pipeline,
|
||||
int num_instances)
|
||||
{
|
||||
return sizeof (GskVulkanTextInstance) * num_instances;
|
||||
}
|
||||
|
||||
void
|
||||
gsk_vulkan_text_pipeline_collect_vertex_data (GskVulkanTextPipeline *pipeline,
|
||||
guchar *data,
|
||||
GskVulkanRenderer *renderer,
|
||||
const graphene_rect_t *rect,
|
||||
guint tex_id[2],
|
||||
PangoFont *font,
|
||||
guint total_glyphs,
|
||||
const PangoGlyphInfo *glyphs,
|
||||
@@ -154,9 +153,6 @@ gsk_vulkan_text_pipeline_collect_vertex_data (GskVulkanTextPipeline *pipeline,
|
||||
instance->color[2] = color->blue;
|
||||
instance->color[3] = color->alpha;
|
||||
|
||||
instance->tex_id[0] = tex_id[0];
|
||||
instance->tex_id[1] = tex_id[1];
|
||||
|
||||
count++;
|
||||
}
|
||||
x_position += gi->geometry.width;
|
||||
|
||||
@@ -18,23 +18,24 @@ GskVulkanPipeline * gsk_vulkan_text_pipeline_new (GdkVulka
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass);
|
||||
|
||||
gsize gsk_vulkan_text_pipeline_count_vertex_data (GskVulkanTextPipeline *pipeline,
|
||||
int num_instances);
|
||||
void gsk_vulkan_text_pipeline_collect_vertex_data (GskVulkanTextPipeline *pipeline,
|
||||
guchar *data,
|
||||
GskVulkanRenderer *renderer,
|
||||
const graphene_rect_t *rect,
|
||||
guint32 tex_id[2],
|
||||
PangoFont *font,
|
||||
guint total_glyphs,
|
||||
const PangoGlyphInfo *glyphs,
|
||||
const GdkRGBA *color,
|
||||
const graphene_point_t *offset,
|
||||
guint start_glyph,
|
||||
guint num_glyphs,
|
||||
float scale);
|
||||
guchar *data,
|
||||
GskVulkanRenderer *renderer,
|
||||
const graphene_rect_t *rect,
|
||||
PangoFont *font,
|
||||
guint total_glyphs,
|
||||
const PangoGlyphInfo *glyphs,
|
||||
const GdkRGBA *color,
|
||||
const graphene_point_t *offset,
|
||||
guint start_glyph,
|
||||
guint num_glyphs,
|
||||
float scale);
|
||||
gsize gsk_vulkan_text_pipeline_draw (GskVulkanTextPipeline *pipeline,
|
||||
VkCommandBuffer command_buffer,
|
||||
gsize offset,
|
||||
gsize n_commands);
|
||||
VkCommandBuffer command_buffer,
|
||||
gsize offset,
|
||||
gsize n_commands);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ struct _GskVulkanTextureInstance
|
||||
{
|
||||
float rect[4];
|
||||
float tex_rect[4];
|
||||
guint32 tex_id[2];
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GskVulkanTexturePipeline, gsk_vulkan_texture_pipeline, GSK_TYPE_VULKAN_PIPELINE)
|
||||
@@ -40,12 +39,6 @@ gsk_vulkan_texture_pipeline_get_input_state_create_info (GskVulkanPipeline *self
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanTextureInstance, tex_rect),
|
||||
},
|
||||
{
|
||||
.location = 2,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32_UINT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanTextureInstance, tex_id),
|
||||
}
|
||||
};
|
||||
static const VkPipelineVertexInputStateCreateInfo info = {
|
||||
@@ -91,26 +84,28 @@ gsk_vulkan_texture_pipeline_new (GdkVulkanContext *context,
|
||||
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_TEXTURE_PIPELINE, context, layout, shader_name, render_pass);
|
||||
}
|
||||
|
||||
gsize
|
||||
gsk_vulkan_texture_pipeline_count_vertex_data (GskVulkanTexturePipeline *pipeline)
|
||||
{
|
||||
return sizeof (GskVulkanTextureInstance);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_vulkan_texture_pipeline_collect_vertex_data (GskVulkanTexturePipeline *pipeline,
|
||||
guchar *data,
|
||||
guint32 tex_id[2],
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *rect,
|
||||
const graphene_rect_t *tex_rect)
|
||||
{
|
||||
GskVulkanTextureInstance *instance = (GskVulkanTextureInstance *) data;
|
||||
|
||||
instance->rect[0] = rect->origin.x + offset->x;
|
||||
instance->rect[1] = rect->origin.y + offset->y;
|
||||
instance->rect[0] = rect->origin.x;
|
||||
instance->rect[1] = rect->origin.y;
|
||||
instance->rect[2] = rect->size.width;
|
||||
instance->rect[3] = rect->size.height;
|
||||
instance->tex_rect[0] = tex_rect->origin.x;
|
||||
instance->tex_rect[1] = tex_rect->origin.y;
|
||||
instance->tex_rect[2] = tex_rect->size.width;
|
||||
instance->tex_rect[3] = tex_rect->size.height;
|
||||
instance->tex_id[0] = tex_id[0];
|
||||
instance->tex_id[1] = tex_id[1];
|
||||
}
|
||||
|
||||
gsize
|
||||
|
||||
@@ -17,10 +17,9 @@ GskVulkanPipeline * gsk_vulkan_texture_pipeline_new (GdkVulk
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass);
|
||||
|
||||
gsize gsk_vulkan_texture_pipeline_count_vertex_data (GskVulkanTexturePipeline *pipeline);
|
||||
void gsk_vulkan_texture_pipeline_collect_vertex_data (GskVulkanTexturePipeline *pipeline,
|
||||
guchar *data,
|
||||
guint32 tex_id[2],
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *rect,
|
||||
const graphene_rect_t *tex_rect);
|
||||
gsize gsk_vulkan_texture_pipeline_draw (GskVulkanTexturePipeline *pipeline,
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
#version 450
|
||||
#version 420 core
|
||||
|
||||
#include "common.frag.glsl"
|
||||
#include "clip.frag.glsl"
|
||||
#include "rect.frag.glsl"
|
||||
|
||||
layout(location = 0) in vec2 inPos;
|
||||
layout(location = 1) in Rect inTopRect;
|
||||
layout(location = 2) in Rect inBottomRect;
|
||||
layout(location = 3) in vec2 inTopTexCoord;
|
||||
layout(location = 4) in vec2 inBottomTexCoord;
|
||||
layout(location = 5) flat in uvec2 inTopTexId;
|
||||
layout(location = 6) flat in uvec2 inBottomTexId;
|
||||
layout(location = 7) flat in uint inBlendMode;
|
||||
layout(location = 1) in vec2 inStartTexCoord;
|
||||
layout(location = 2) in vec2 inEndTexCoord;
|
||||
layout(location = 3) flat in uint inBlendMode;
|
||||
|
||||
layout(location = 0) out vec4 color;
|
||||
layout(set = 0, binding = 0) uniform sampler2D startTexture;
|
||||
layout(set = 1, binding = 0) uniform sampler2D endTexture;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
float
|
||||
combine (float source, float backdrop)
|
||||
@@ -245,7 +242,7 @@ set_sat (vec3 c, float s)
|
||||
}
|
||||
|
||||
vec4
|
||||
colorize (vec4 Cs, vec4 Cb)
|
||||
color (vec4 Cs, vec4 Cb)
|
||||
{
|
||||
vec3 B = set_lum (Cs.rgb, lum (Cb.rgb));
|
||||
return composite (Cs, Cb, B);
|
||||
@@ -274,10 +271,8 @@ luminosity (vec4 Cs, vec4 Cb)
|
||||
|
||||
void main()
|
||||
{
|
||||
float source_alpha = rect_coverage (inTopRect, inPos);
|
||||
vec4 source = texture (get_sampler (inTopTexId), inTopTexCoord) * source_alpha;
|
||||
float backdrop_alpha = rect_coverage (inBottomRect, inPos);
|
||||
vec4 backdrop = texture (get_sampler (inBottomTexId), inBottomTexCoord) * backdrop_alpha;
|
||||
vec4 source = texture (startTexture, inStartTexCoord);
|
||||
vec4 backdrop = texture (endTexture, inEndTexCoord);
|
||||
vec4 result;
|
||||
|
||||
if (inBlendMode == 0)
|
||||
@@ -305,7 +300,7 @@ void main()
|
||||
else if (inBlendMode == 11)
|
||||
result = exclusion (source, backdrop);
|
||||
else if (inBlendMode == 12)
|
||||
result = colorize (source, backdrop);
|
||||
result = color (source, backdrop);
|
||||
else if (inBlendMode == 13)
|
||||
result = hue (source, backdrop);
|
||||
else if (inBlendMode == 14)
|
||||
@@ -315,5 +310,5 @@ void main()
|
||||
else
|
||||
discard;
|
||||
|
||||
color = clip_scaled (inPos, result);
|
||||
outColor = clip (inPos, result);
|
||||
}
|
||||
|
||||
@@ -1,36 +1,40 @@
|
||||
#version 450
|
||||
#version 420 core
|
||||
|
||||
#include "common.vert.glsl"
|
||||
#include "rect.vert.glsl"
|
||||
#include "clip.vert.glsl"
|
||||
|
||||
layout(location = 0) in vec4 inRect;
|
||||
layout(location = 1) in vec4 inTopRect;
|
||||
layout(location = 2) in vec4 inBottomRect;
|
||||
layout(location = 3) in vec4 inTopTexRect;
|
||||
layout(location = 4) in vec4 inBottomTexRect;
|
||||
layout(location = 5) in uvec2 inTopTexId;
|
||||
layout(location = 6) in uvec2 inBottomTexId;
|
||||
layout(location = 7) in uint inBlendMode;
|
||||
layout(location = 1) in vec4 inStartTexRect;
|
||||
layout(location = 2) in vec4 inEndTexRect;
|
||||
layout(location = 3) in uint inBlendMode;
|
||||
|
||||
layout(location = 0) out vec2 outPos;
|
||||
layout(location = 1) flat out Rect outTopRect;
|
||||
layout(location = 2) flat out Rect outBottomRect;
|
||||
layout(location = 3) out vec2 outTopTexCoord;
|
||||
layout(location = 4) out vec2 outBottomTexCoord;
|
||||
layout(location = 5) flat out uvec2 outTopTexId;
|
||||
layout(location = 6) flat out uvec2 outBottomTexId;
|
||||
layout(location = 7) flat out uint outBlendMode;
|
||||
layout(location = 1) out vec2 outStartTexCoord;
|
||||
layout(location = 2) out vec2 outEndTexCoord;
|
||||
layout(location = 3) flat out uint outBlendMode;
|
||||
|
||||
vec2 offsets[6] = { vec2(0.0, 0.0),
|
||||
vec2(1.0, 0.0),
|
||||
vec2(0.0, 1.0),
|
||||
vec2(0.0, 1.0),
|
||||
vec2(1.0, 0.0),
|
||||
vec2(1.0, 1.0) };
|
||||
|
||||
void main() {
|
||||
Rect r = rect_from_gsk (inRect);
|
||||
vec2 pos = set_position_from_rect (r);
|
||||
vec4 rect = clip (inRect);
|
||||
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
|
||||
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
|
||||
|
||||
outPos = pos;
|
||||
outTopRect = rect_from_gsk (inTopRect);
|
||||
outBottomRect = rect_from_gsk (inBottomRect);
|
||||
outTopTexCoord = scale_tex_coord (pos, r, inTopTexRect);
|
||||
outBottomTexCoord = scale_tex_coord (pos, r, inBottomTexRect);
|
||||
outTopTexId = inTopTexId;
|
||||
outBottomTexId = inBottomTexId;
|
||||
|
||||
vec4 texrect = vec4((rect.xy - inRect.xy) / inRect.zw,
|
||||
rect.zw / inRect.zw);
|
||||
vec4 starttexrect = vec4(inStartTexRect.xy + inStartTexRect.zw * texrect.xy,
|
||||
inStartTexRect.zw * texrect.zw);
|
||||
vec4 endtexrect = vec4(inEndTexRect.xy + inEndTexRect.zw * texrect.xy,
|
||||
inEndTexRect.zw * texrect.zw);
|
||||
|
||||
outStartTexCoord = starttexrect.xy + starttexrect.zw * offsets[gl_VertexIndex];
|
||||
outEndTexCoord = endtexrect.xy + endtexrect.zw * offsets[gl_VertexIndex];
|
||||
|
||||
outBlendMode = inBlendMode;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#version 450
|
||||
#version 420 core
|
||||
|
||||
#include "common.frag.glsl"
|
||||
#include "clip.frag.glsl"
|
||||
|
||||
layout(location = 0) in vec2 inPos;
|
||||
layout(location = 1) in flat vec2 inSize;
|
||||
layout(location = 2) in vec2 inTexCoord;
|
||||
layout(location = 3) in float inRadius;
|
||||
layout(location = 4) in flat uvec2 inTexId;
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D inTexture;
|
||||
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
@@ -38,7 +38,7 @@ vec4 blur_pixel (in vec2 uv)
|
||||
float fx = Gaussian (inRadius, float(x) - float(half_samples_x));
|
||||
float offset_x = float(x - half_samples_x) * pixel_size_x;
|
||||
total += fx * fy;
|
||||
ret += texture(get_sampler (inTexId), uv + vec2(offset_x, offset_y)) * fx * fy;
|
||||
ret += texture(inTexture, uv + vec2(offset_x, offset_y)) * fx * fy;
|
||||
}
|
||||
}
|
||||
return ret / total;
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
|
||||
#version 450
|
||||
#version 420 core
|
||||
|
||||
#include "clip.vert.glsl"
|
||||
|
||||
layout(location = 0) in vec4 inRect;
|
||||
layout(location = 1) in vec4 inTexRect;
|
||||
layout(location = 2) in float inRadius;
|
||||
layout(location = 3) in uvec2 inTexId;
|
||||
|
||||
layout(location = 0) out vec2 outPos;
|
||||
layout(location = 1) out flat vec2 outSize;
|
||||
layout(location = 2) out vec2 outTexCoord;
|
||||
layout(location = 3) out flat float outRadius;
|
||||
layout(location = 4) out flat uvec2 outTexId;
|
||||
|
||||
vec2 offsets[6] = { vec2(0.0, 0.0),
|
||||
vec2(1.0, 0.0),
|
||||
@@ -24,7 +22,7 @@ vec2 offsets[6] = { vec2(0.0, 0.0),
|
||||
void main() {
|
||||
vec4 rect = clip (inRect);
|
||||
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
|
||||
gl_Position = push.mvp * vec4 (push.scale * pos, 0.0, 1.0);
|
||||
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
|
||||
|
||||
outPos = pos;
|
||||
outSize = inRect.zw;
|
||||
@@ -34,6 +32,6 @@ void main() {
|
||||
texrect = vec4(inTexRect.xy + inTexRect.zw * texrect.xy,
|
||||
inTexRect.zw * texrect.zw);
|
||||
outTexCoord = texrect.xy + texrect.zw * offsets[gl_VertexIndex];
|
||||
outTexId = inTexId;
|
||||
|
||||
outRadius = inRadius;
|
||||
}
|
||||
|
||||
@@ -1,22 +1,24 @@
|
||||
#version 450
|
||||
#version 420 core
|
||||
|
||||
#include "clip.frag.glsl"
|
||||
#include "rounded-rect.glsl"
|
||||
|
||||
layout(location = 0) in vec2 inPos;
|
||||
layout(location = 1) in vec4 inColor;
|
||||
layout(location = 2) in RoundedRect inRect;
|
||||
layout(location = 2) in vec4 inRect;
|
||||
layout(location = 3) in vec4 inCornerWidths;
|
||||
layout(location = 4) in vec4 inCornerHeights;
|
||||
layout(location = 5) in vec4 inBorderWidths;
|
||||
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
RoundedRect routside = inRect;
|
||||
RoundedRect routside = RoundedRect (vec4(inRect.xy, inRect.xy + inRect.zw), inCornerWidths, inCornerHeights);
|
||||
RoundedRect rinside = rounded_rect_shrink (routside, inBorderWidths);
|
||||
|
||||
float alpha = clamp (rounded_rect_coverage (routside, inPos) -
|
||||
rounded_rect_coverage (rinside, inPos),
|
||||
0.0, 1.0);
|
||||
color = clip_scaled (inPos, vec4(inColor.rgb * inColor.a, inColor.a) * alpha);
|
||||
color = clip (inPos, vec4(inColor.rgb * inColor.a, inColor.a) * alpha);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#version 450
|
||||
#version 420 core
|
||||
|
||||
#include "clip.vert.glsl"
|
||||
#include "rounded-rect.glsl"
|
||||
|
||||
layout(location = 0) in vec4 inRect;
|
||||
layout(location = 1) in vec4 inCornerWidths;
|
||||
@@ -11,7 +10,9 @@ layout(location = 4) in mat4 inBorderColors;
|
||||
|
||||
layout(location = 0) out vec2 outPos;
|
||||
layout(location = 1) out flat vec4 outColor;
|
||||
layout(location = 2) out flat RoundedRect outRect;
|
||||
layout(location = 2) out flat vec4 outRect;
|
||||
layout(location = 3) out flat vec4 outCornerWidths;
|
||||
layout(location = 4) out flat vec4 outCornerHeights;
|
||||
layout(location = 5) out flat vec4 outBorderWidths;
|
||||
|
||||
vec2 offsets[6] = { vec2(0.0, 0.0),
|
||||
@@ -47,59 +48,51 @@ void main() {
|
||||
vec4 corner_widths = max (inCornerWidths, inBorderWidths.wyyw);
|
||||
vec4 corner_heights = max (inCornerHeights, inBorderWidths.xxzz);
|
||||
|
||||
Rect rect;
|
||||
vec4 rect;
|
||||
|
||||
switch (slice_index)
|
||||
{
|
||||
case SLICE_TOP_LEFT:
|
||||
rect = rect_from_gsk (vec4(inRect.xy, corner_widths[TOP_LEFT], corner_heights[TOP_LEFT]));
|
||||
rect = rect_round_larger (rect);
|
||||
rect = vec4(inRect.xy, corner_widths[TOP_LEFT], corner_heights[TOP_LEFT]);
|
||||
vert_index = (vert_index + 3) % 6;
|
||||
break;
|
||||
case SLICE_TOP:
|
||||
rect = rect_from_gsk (vec4(inRect.x + corner_widths[TOP_LEFT], inRect.y, inRect.z - corner_widths[TOP_LEFT] - corner_widths[TOP_RIGHT], inBorderWidths[TOP]));
|
||||
rect = rect_round_smaller_larger (rect);
|
||||
rect = vec4(inRect.x + corner_widths[TOP_LEFT], inRect.y, inRect.z - corner_widths[TOP_LEFT] - corner_widths[TOP_RIGHT], inBorderWidths[TOP]);
|
||||
outColor = inBorderColors[TOP];
|
||||
break;
|
||||
case SLICE_TOP_RIGHT:
|
||||
rect = rect_from_gsk (vec4(inRect.x + inRect.z - corner_widths[TOP_RIGHT], inRect.y, corner_widths[TOP_RIGHT], corner_heights[TOP_RIGHT]));
|
||||
rect = rect_round_larger (rect);
|
||||
rect = vec4(inRect.x + inRect.z - corner_widths[TOP_RIGHT], inRect.y, corner_widths[TOP_RIGHT], corner_heights[TOP_RIGHT]);
|
||||
break;
|
||||
case SLICE_RIGHT:
|
||||
rect = rect_from_gsk (vec4(inRect.x + inRect.z - inBorderWidths[RIGHT], inRect.y + corner_heights[TOP_RIGHT], inBorderWidths[RIGHT], inRect.w - corner_heights[TOP_RIGHT] - corner_heights[BOTTOM_RIGHT]));
|
||||
rect = rect_round_larger_smaller (rect);
|
||||
rect = vec4(inRect.x + inRect.z - inBorderWidths[RIGHT], inRect.y + corner_heights[TOP_RIGHT], inBorderWidths[RIGHT], inRect.w - corner_heights[TOP_RIGHT] - corner_heights[BOTTOM_RIGHT]);
|
||||
outColor = inBorderColors[RIGHT];
|
||||
break;
|
||||
case SLICE_BOTTOM_RIGHT:
|
||||
rect = rect_from_gsk (vec4(inRect.x + inRect.z - corner_widths[BOTTOM_RIGHT], inRect.y + inRect.w - corner_heights[BOTTOM_RIGHT], corner_widths[BOTTOM_RIGHT], corner_heights[BOTTOM_RIGHT]));
|
||||
rect = rect_round_larger (rect);
|
||||
rect = vec4(inRect.x + inRect.z - corner_widths[BOTTOM_RIGHT], inRect.y + inRect.w - corner_heights[BOTTOM_RIGHT], corner_widths[BOTTOM_RIGHT], corner_heights[BOTTOM_RIGHT]);
|
||||
break;
|
||||
case SLICE_BOTTOM:
|
||||
rect = rect_from_gsk (vec4(inRect.x + corner_widths[BOTTOM_LEFT], inRect.y + inRect.w - inBorderWidths[BOTTOM], inRect.z - corner_widths[BOTTOM_LEFT] - corner_widths[BOTTOM_RIGHT], inBorderWidths[BOTTOM]));
|
||||
rect = rect_round_smaller_larger (rect);
|
||||
rect = vec4(inRect.x + corner_widths[BOTTOM_LEFT], inRect.y + inRect.w - inBorderWidths[BOTTOM], inRect.z - corner_widths[BOTTOM_LEFT] - corner_widths[BOTTOM_RIGHT], inBorderWidths[BOTTOM]);
|
||||
break;
|
||||
case SLICE_BOTTOM_LEFT:
|
||||
rect = rect_from_gsk (vec4(inRect.x, inRect.y + inRect.w - corner_heights[BOTTOM_LEFT], corner_widths[BOTTOM_LEFT], corner_heights[BOTTOM_LEFT]));
|
||||
rect = vec4(inRect.x, inRect.y + inRect.w - corner_heights[BOTTOM_LEFT], corner_widths[BOTTOM_LEFT], corner_heights[BOTTOM_LEFT]);
|
||||
vert_index = (vert_index + 3) % 6;
|
||||
rect = rect_round_larger (rect);
|
||||
break;
|
||||
case SLICE_LEFT:
|
||||
rect = rect_from_gsk (vec4(inRect.x, inRect.y + corner_heights[TOP_LEFT], inBorderWidths[LEFT], inRect.w - corner_heights[TOP_LEFT] - corner_heights[BOTTOM_LEFT]));
|
||||
rect = rect_round_larger_smaller (rect);
|
||||
rect = vec4(inRect.x, inRect.y + corner_heights[TOP_LEFT], inBorderWidths[LEFT], inRect.w - corner_heights[TOP_LEFT] - corner_heights[BOTTOM_LEFT]);
|
||||
break;
|
||||
}
|
||||
|
||||
rect = clip_rect (rect);
|
||||
|
||||
rect = clip (rect);
|
||||
vec2 pos;
|
||||
if ((slice_index % 4) != 0 || (vert_index % 3) != 2)
|
||||
pos = mix (rect.bounds.xy, rect.bounds.zw, offsets[vert_index]);
|
||||
pos = rect.xy + rect.zw * offsets[vert_index];
|
||||
else
|
||||
pos = mix (rect.bounds.zy, rect.bounds.xw, offsets[vert_index]);
|
||||
pos = rect.xy + rect.zw * vec2(1.0 - offsets[vert_index].x, offsets[vert_index].y);
|
||||
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
|
||||
outColor = inBorderColors[((gl_VertexIndex / 3 + 15) / 4) % 4];
|
||||
outPos = pos;
|
||||
outRect = RoundedRect(inRect.xyxy + vec4(0,0,inRect.zw), inCornerWidths, inCornerHeights);
|
||||
outRect = rounded_rect_scale (outRect, push.scale);
|
||||
outBorderWidths = inBorderWidths * push.scale.yxyx;
|
||||
outRect = inRect;
|
||||
outCornerWidths = inCornerWidths;
|
||||
outCornerHeights = inCornerHeights;
|
||||
outBorderWidths = inBorderWidths;
|
||||
}
|
||||
|
||||
@@ -1,45 +1,29 @@
|
||||
#include "constants.glsl"
|
||||
#include "rounded-rect.frag.glsl"
|
||||
#include "rounded-rect.glsl"
|
||||
|
||||
#ifndef _CLIP_
|
||||
#define _CLIP_
|
||||
|
||||
#ifdef CLIP_ROUNDED_RECT
|
||||
|
||||
vec4
|
||||
clip_scaled (vec2 pos, vec4 color)
|
||||
vec4 clip(vec2 pos, vec4 color)
|
||||
{
|
||||
RoundedRect r = RoundedRect(vec4(push.clip_bounds.xy, push.clip_bounds.xy + push.clip_bounds.zw), push.clip_widths, push.clip_heights);
|
||||
|
||||
r = rounded_rect_scale (r, push.scale);
|
||||
|
||||
return color * rounded_rect_coverage (r, pos);
|
||||
}
|
||||
|
||||
#elif defined(CLIP_RECT)
|
||||
|
||||
vec4
|
||||
clip_scaled (vec2 pos, vec4 color)
|
||||
vec4 clip(vec2 pos, vec4 color)
|
||||
{
|
||||
/* clipped in vertex shader already */
|
||||
return color;
|
||||
}
|
||||
|
||||
#elif defined(CLIP_NONE)
|
||||
|
||||
vec4
|
||||
clip_scaled (vec2 pos, vec4 color)
|
||||
vec4 clip(vec2 pos, vec4 color)
|
||||
{
|
||||
return color;
|
||||
}
|
||||
|
||||
#else
|
||||
#error "No clipping define given. Need CLIP_NONE, CLIP_RECT or CLIP_ROUNDED_RECT"
|
||||
#endif
|
||||
|
||||
vec4
|
||||
clip (vec2 pos, vec4 color)
|
||||
{
|
||||
return clip_scaled (pos * push.scale, color);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "constants.glsl"
|
||||
#include "rect.vert.glsl"
|
||||
|
||||
#ifndef _CLIP_
|
||||
#define _CLIP_
|
||||
@@ -15,47 +14,21 @@ vec4 intersect(vec4 a, vec4 b)
|
||||
}
|
||||
|
||||
#ifdef CLIP_ROUNDED_RECT
|
||||
|
||||
vec4
|
||||
clip(vec4 rect)
|
||||
vec4 clip(vec4 rect)
|
||||
{
|
||||
/* rounded corner clipping is done in fragment shader */
|
||||
return intersect(rect, push.clip_bounds);
|
||||
}
|
||||
|
||||
Rect
|
||||
clip_rect (Rect r)
|
||||
{
|
||||
/* rounded corner clipping is done in fragment shader */
|
||||
return rect_intersect (r, rect_round_larger (rect_from_gsk (push.clip_bounds)));
|
||||
}
|
||||
|
||||
#elif defined(CLIP_RECT)
|
||||
|
||||
vec4
|
||||
clip(vec4 rect)
|
||||
vec4 clip(vec4 rect)
|
||||
{
|
||||
return intersect(rect, push.clip_bounds);
|
||||
}
|
||||
|
||||
Rect
|
||||
clip_rect (Rect r)
|
||||
{
|
||||
return rect_intersect (r, rect_round_larger (rect_from_gsk (push.clip_bounds)));
|
||||
}
|
||||
|
||||
#elif defined(CLIP_NONE)
|
||||
vec4 clip(vec4 rect)
|
||||
{
|
||||
return rect;
|
||||
}
|
||||
|
||||
Rect
|
||||
clip_rect (Rect r)
|
||||
{
|
||||
return r;
|
||||
}
|
||||
|
||||
#else
|
||||
#error "No clipping define given. Need CLIP_NONE, CLIP_RECT or CLIP_ROUNDED_RECT"
|
||||
#endif
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#version 450
|
||||
#version 420 core
|
||||
|
||||
#include "common.frag.glsl"
|
||||
#include "clip.frag.glsl"
|
||||
|
||||
layout(location = 0) in vec2 inPos;
|
||||
layout(location = 1) in vec2 inTexCoord;
|
||||
layout(location = 2) in flat mat4 inColorMatrix;
|
||||
layout(location = 6) in flat vec4 inColorOffset;
|
||||
layout(location = 7) in flat uvec2 inTexId;
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D inTexture;
|
||||
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
@@ -29,5 +29,5 @@ color_matrix (vec4 color, mat4 color_matrix, vec4 color_offset)
|
||||
|
||||
void main()
|
||||
{
|
||||
color = clip (inPos, color_matrix (texture (get_sampler (inTexId), inTexCoord), inColorMatrix, inColorOffset));
|
||||
color = clip (inPos, color_matrix (texture (inTexture, inTexCoord), inColorMatrix, inColorOffset));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#version 450
|
||||
#version 420 core
|
||||
|
||||
#include "clip.vert.glsl"
|
||||
|
||||
@@ -6,13 +6,11 @@ layout(location = 0) in vec4 inRect;
|
||||
layout(location = 1) in vec4 inTexRect;
|
||||
layout(location = 2) in mat4 inColorMatrix;
|
||||
layout(location = 6) in vec4 inColorOffset;
|
||||
layout(location = 7) in uvec2 inTexId;
|
||||
|
||||
layout(location = 0) out vec2 outPos;
|
||||
layout(location = 1) out vec2 outTexCoord;
|
||||
layout(location = 2) out flat mat4 outColorMatrix;
|
||||
layout(location = 6) out flat vec4 outColorOffset;
|
||||
layout(location = 7) out flat uvec2 outTexId;
|
||||
|
||||
vec2 offsets[6] = { vec2(0.0, 0.0),
|
||||
vec2(1.0, 0.0),
|
||||
@@ -24,7 +22,7 @@ vec2 offsets[6] = { vec2(0.0, 0.0),
|
||||
void main() {
|
||||
vec4 rect = clip (inRect);
|
||||
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
|
||||
gl_Position = push.mvp * vec4 (push.scale * pos, 0.0, 1.0);
|
||||
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
|
||||
|
||||
outPos = pos;
|
||||
|
||||
@@ -33,7 +31,6 @@ void main() {
|
||||
texrect = vec4(inTexRect.xy + inTexRect.zw * texrect.xy,
|
||||
inTexRect.zw * texrect.zw);
|
||||
outTexCoord = texrect.xy + texrect.zw * offsets[gl_VertexIndex];
|
||||
outTexId = inTexId;
|
||||
outColorMatrix = inColorMatrix;
|
||||
outColorOffset = inColorOffset;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
#version 420 core
|
||||
|
||||
#include "clip.frag.glsl"
|
||||
#include "rect.frag.glsl"
|
||||
|
||||
layout(location = 0) in vec2 inPos;
|
||||
layout(location = 1) in Rect inRect;
|
||||
layout(location = 2) in vec4 inColor;
|
||||
layout(location = 1) in vec4 inColor;
|
||||
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
float alpha = inColor.a * rect_coverage (inRect, inPos);
|
||||
color = clip_scaled (inPos, vec4(inColor.rgb, 1) * alpha);
|
||||
color = clip (inPos, vec4(inColor.rgb * inColor.a, inColor.a));
|
||||
}
|
||||
|
||||
@@ -1,18 +1,25 @@
|
||||
#version 450
|
||||
#version 420 core
|
||||
|
||||
#include "common.vert.glsl"
|
||||
#include "rect.vert.glsl"
|
||||
#include "clip.vert.glsl"
|
||||
|
||||
layout(location = 0) in vec4 inRect;
|
||||
layout(location = 1) in vec4 inColor;
|
||||
|
||||
layout(location = 0) out vec2 outPos;
|
||||
layout(location = 1) out flat Rect outRect;
|
||||
layout(location = 2) out flat vec4 outColor;
|
||||
layout(location = 1) out flat vec4 outColor;
|
||||
|
||||
vec2 offsets[6] = { vec2(0.0, 0.0),
|
||||
vec2(1.0, 0.0),
|
||||
vec2(0.0, 1.0),
|
||||
vec2(0.0, 1.0),
|
||||
vec2(1.0, 0.0),
|
||||
vec2(1.0, 1.0) };
|
||||
|
||||
void main() {
|
||||
Rect r = rect_from_gsk (inRect);
|
||||
outPos = set_position_from_rect (r);
|
||||
outRect = r;
|
||||
vec4 rect = clip (inRect);
|
||||
|
||||
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
|
||||
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
|
||||
outPos = pos;
|
||||
outColor = inColor;
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
layout(set = 0, binding = 0) uniform texture2D textures[50000];
|
||||
layout(set = 0, binding = 1) uniform sampler samplers[50000];
|
||||
layout(set = 0, binding = 2) readonly buffer FloatBuffers {
|
||||
float floats[];
|
||||
} buffers[50000];
|
||||
|
||||
#define get_sampler(id) sampler2D(textures[id.x], samplers[id.y])
|
||||
#define get_buffer(id) buffers[id]
|
||||
#define get_float(id) get_buffer(0).floats[id]
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
#ifndef _COMMON_VERT_
|
||||
#define _COMMON_VERT_
|
||||
|
||||
#include "clip.vert.glsl"
|
||||
#include "constants.glsl"
|
||||
#include "rect.glsl"
|
||||
|
||||
vec2 offsets[6] = { vec2(0.0, 0.0),
|
||||
vec2(1.0, 0.0),
|
||||
vec2(0.0, 1.0),
|
||||
vec2(0.0, 1.0),
|
||||
vec2(1.0, 0.0),
|
||||
vec2(1.0, 1.0) };
|
||||
|
||||
vec2
|
||||
set_position_from_rect (Rect rect)
|
||||
{
|
||||
Rect r = rect_round_larger (clip_rect (rect));
|
||||
|
||||
vec2 pos = mix (r.bounds.xy, r.bounds.zw, offsets[gl_VertexIndex]);
|
||||
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
vec2
|
||||
scale_tex_coord (vec2 in_pos,
|
||||
Rect in_rect,
|
||||
vec4 tex_rect)
|
||||
{
|
||||
return tex_rect.xy + (in_pos - in_rect.bounds.xy) / rect_size (in_rect) * tex_rect.zw;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -6,7 +6,6 @@ layout(push_constant) uniform PushConstants {
|
||||
vec4 clip_bounds;
|
||||
vec4 clip_widths;
|
||||
vec4 clip_heights;
|
||||
vec2 scale;
|
||||
} push;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,26 +1,21 @@
|
||||
#version 450
|
||||
#version 420 core
|
||||
|
||||
#include "common.frag.glsl"
|
||||
#include "clip.frag.glsl"
|
||||
#include "rect.frag.glsl"
|
||||
|
||||
layout(location = 0) in vec2 inPos;
|
||||
layout(location = 1) in Rect inStartRect;
|
||||
layout(location = 2) in Rect inEndRect;
|
||||
layout(location = 3) in vec2 inStartTexCoord;
|
||||
layout(location = 4) in vec2 inEndTexCoord;
|
||||
layout(location = 5) flat in uvec2 inStartTexId;
|
||||
layout(location = 6) flat in uvec2 inEndTexId;
|
||||
layout(location = 7) in float inProgress;
|
||||
layout(location = 1) in vec2 inStartTexCoord;
|
||||
layout(location = 2) in vec2 inEndTexCoord;
|
||||
layout(location = 3) in float inProgress;
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D startTexture;
|
||||
layout(set = 1, binding = 0) uniform sampler2D endTexture;
|
||||
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
float start_alpha = rect_coverage (inStartRect, inPos);
|
||||
vec4 start = texture (get_sampler (inStartTexId), inStartTexCoord) * start_alpha;
|
||||
float end_alpha = rect_coverage (inEndRect, inPos);
|
||||
vec4 end = texture (get_sampler (inEndTexId), inEndTexCoord) * end_alpha;
|
||||
vec4 start = texture (startTexture, inStartTexCoord);
|
||||
vec4 end = texture (endTexture, inEndTexCoord);
|
||||
|
||||
color = clip_scaled (inPos, mix (start, end, inProgress));
|
||||
color = clip (inPos, mix (start, end, inProgress));
|
||||
}
|
||||
|
||||
@@ -1,36 +1,40 @@
|
||||
#version 450
|
||||
#version 420 core
|
||||
|
||||
#include "common.vert.glsl"
|
||||
#include "rect.vert.glsl"
|
||||
#include "clip.vert.glsl"
|
||||
|
||||
layout(location = 0) in vec4 inRect;
|
||||
layout(location = 1) in vec4 inStartRect;
|
||||
layout(location = 2) in vec4 inEndRect;
|
||||
layout(location = 3) in vec4 inStartTexRect;
|
||||
layout(location = 4) in vec4 inEndTexRect;
|
||||
layout(location = 5) in uvec2 inStartTexId;
|
||||
layout(location = 6) in uvec2 inEndTexId;
|
||||
layout(location = 7) in float inProgress;
|
||||
layout(location = 1) in vec4 inStartTexRect;
|
||||
layout(location = 2) in vec4 inEndTexRect;
|
||||
layout(location = 3) in float inProgress;
|
||||
|
||||
layout(location = 0) out vec2 outPos;
|
||||
layout(location = 1) flat out Rect outStartRect;
|
||||
layout(location = 2) flat out Rect outEndRect;
|
||||
layout(location = 3) out vec2 outStartTexCoord;
|
||||
layout(location = 4) out vec2 outEndTexCoord;
|
||||
layout(location = 5) flat out uvec2 outStartTexId;
|
||||
layout(location = 6) flat out uvec2 outEndTexId;
|
||||
layout(location = 7) flat out float outProgress;
|
||||
layout(location = 1) out vec2 outStartTexCoord;
|
||||
layout(location = 2) out vec2 outEndTexCoord;
|
||||
layout(location = 3) out float outProgress;
|
||||
|
||||
vec2 offsets[6] = { vec2(0.0, 0.0),
|
||||
vec2(1.0, 0.0),
|
||||
vec2(0.0, 1.0),
|
||||
vec2(0.0, 1.0),
|
||||
vec2(1.0, 0.0),
|
||||
vec2(1.0, 1.0) };
|
||||
|
||||
void main() {
|
||||
Rect r = rect_from_gsk (inRect);
|
||||
vec2 pos = set_position_from_rect (r);
|
||||
vec4 rect = clip (inRect);
|
||||
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
|
||||
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
|
||||
|
||||
outPos = pos;
|
||||
outStartRect = rect_from_gsk (inStartRect);
|
||||
outEndRect = rect_from_gsk (inEndRect);
|
||||
outStartTexCoord = scale_tex_coord (pos, r, inStartTexRect);
|
||||
outEndTexCoord = scale_tex_coord (pos, r, inEndTexRect);
|
||||
outStartTexId = inStartTexId;
|
||||
outEndTexId = inEndTexId;
|
||||
|
||||
vec4 texrect = vec4((rect.xy - inRect.xy) / inRect.zw,
|
||||
rect.zw / inRect.zw);
|
||||
vec4 starttexrect = vec4(inStartTexRect.xy + inStartTexRect.zw * texrect.xy,
|
||||
inStartTexRect.zw * texrect.zw);
|
||||
vec4 endtexrect = vec4(inEndTexRect.xy + inEndTexRect.zw * texrect.xy,
|
||||
inEndTexRect.zw * texrect.zw);
|
||||
|
||||
outStartTexCoord = starttexrect.xy + starttexrect.zw * offsets[gl_VertexIndex];
|
||||
outEndTexCoord = endtexrect.xy + endtexrect.zw * offsets[gl_VertexIndex];
|
||||
|
||||
outProgress = inProgress;
|
||||
}
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
#ifndef _ELLIPSE_
|
||||
#define _ELLIPSE_
|
||||
|
||||
struct Ellipse
|
||||
{
|
||||
vec2 center;
|
||||
vec2 radius;
|
||||
};
|
||||
|
||||
float
|
||||
ellipse_distance (Ellipse r, vec2 p)
|
||||
{
|
||||
vec2 e = r.radius;
|
||||
p = p - r.center;
|
||||
|
||||
if (e.x == e.y)
|
||||
return length (p) - e.x;
|
||||
|
||||
/* from https://www.shadertoy.com/view/tt3yz7 */
|
||||
vec2 pAbs = abs(p);
|
||||
vec2 ei = 1.0 / e;
|
||||
vec2 e2 = e*e;
|
||||
vec2 ve = ei * vec2(e2.x - e2.y, e2.y - e2.x);
|
||||
|
||||
vec2 t = vec2(0.70710678118654752, 0.70710678118654752);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
vec2 v = ve*t*t*t;
|
||||
vec2 u = normalize(pAbs - v) * length(t * e - v);
|
||||
vec2 w = ei * (v + u);
|
||||
t = normalize(clamp(w, 0.0, 1.0));
|
||||
}
|
||||
|
||||
vec2 nearestAbs = t * e;
|
||||
float dist = length(pAbs - nearestAbs);
|
||||
return dot(pAbs, pAbs) < dot(nearestAbs, nearestAbs) ? -dist : dist;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,4 @@
|
||||
#version 450
|
||||
#version 420 core
|
||||
|
||||
#include "clip.frag.glsl"
|
||||
#include "rounded-rect.glsl"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#version 450
|
||||
#version 420 core
|
||||
|
||||
#include "clip.vert.glsl"
|
||||
|
||||
@@ -29,7 +29,7 @@ void main() {
|
||||
vec4 rect = clip (inOutline);
|
||||
|
||||
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
|
||||
gl_Position = push.mvp * vec4 (push.scale * pos, 0.0, 1.0);
|
||||
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
|
||||
outPos = pos;
|
||||
|
||||
outOutline = inOutline;
|
||||
|
||||
@@ -1,128 +1,36 @@
|
||||
#version 450
|
||||
#version 420 core
|
||||
|
||||
#include "common.frag.glsl"
|
||||
#include "clip.frag.glsl"
|
||||
#include "rect.frag.glsl"
|
||||
|
||||
struct ColorStop {
|
||||
float offset;
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
layout(location = 0) in vec2 inPos;
|
||||
layout(location = 1) in flat Rect inRect;
|
||||
layout(location = 2) in float inGradientPos;
|
||||
layout(location = 3) in flat int inRepeating;
|
||||
layout(location = 4) in flat int inStopOffset;
|
||||
layout(location = 5) in flat int inStopCount;
|
||||
layout(location = 1) in float inGradientPos;
|
||||
layout(location = 2) in flat int inRepeating;
|
||||
layout(location = 3) in flat int inStopCount;
|
||||
layout(location = 4) in flat ColorStop inStops[8];
|
||||
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
float
|
||||
get_offset (int i)
|
||||
{
|
||||
return get_float (inStopOffset + i * 5);
|
||||
}
|
||||
|
||||
vec4
|
||||
get_color (int i)
|
||||
{
|
||||
i = clamp (i, 0, inStopCount - 1);
|
||||
return color = vec4 (get_float (inStopOffset + i * 5 + 1),
|
||||
get_float (inStopOffset + i * 5 + 2),
|
||||
get_float (inStopOffset + i * 5 + 3),
|
||||
get_float (inStopOffset + i * 5 + 4));
|
||||
}
|
||||
|
||||
vec4
|
||||
get_color_for_range_unscaled (float start,
|
||||
float end)
|
||||
{
|
||||
vec4 result = vec4 (0);
|
||||
float offset;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < inStopCount; i++)
|
||||
{
|
||||
offset = get_offset (i);
|
||||
if (offset >= start)
|
||||
break;
|
||||
}
|
||||
if (i == inStopCount)
|
||||
offset = 1;
|
||||
|
||||
float last_offset = i > 0 ? get_offset (i - 1) : 0;
|
||||
vec4 last_color = get_color (i - 1);
|
||||
vec4 color = get_color (i);
|
||||
if (last_offset < start)
|
||||
{
|
||||
last_color = mix (last_color, color, (start - last_offset) / (offset - last_offset));
|
||||
last_offset = start;
|
||||
}
|
||||
if (end <= start)
|
||||
return last_color;
|
||||
|
||||
for (; i < inStopCount; i++)
|
||||
{
|
||||
offset = get_offset (i);
|
||||
color = get_color (i);
|
||||
if (offset >= end)
|
||||
break;
|
||||
result += 0.5 * (color + last_color) * (offset - last_offset);
|
||||
last_offset = offset;
|
||||
last_color = color;
|
||||
}
|
||||
if (i == inStopCount)
|
||||
{
|
||||
offset = 1;
|
||||
color = get_color (i);
|
||||
}
|
||||
if (offset > end)
|
||||
{
|
||||
color = mix (last_color, color, (end - last_offset) / (offset - last_offset));
|
||||
offset = end;
|
||||
}
|
||||
result += 0.5 * (color + last_color) * (offset - last_offset);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
vec4
|
||||
get_color_for_range (float start,
|
||||
float end)
|
||||
{
|
||||
return get_color_for_range_unscaled (start, end) / (end - start);
|
||||
}
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 c;
|
||||
float pos_start, pos_end;
|
||||
float dPos = 0.5 * abs (fwidth (inGradientPos));
|
||||
|
||||
float pos;
|
||||
if (inRepeating != 0)
|
||||
{
|
||||
pos_start = inGradientPos - dPos;
|
||||
pos_end = inGradientPos + dPos;
|
||||
if (floor (pos_end) > floor (pos_start))
|
||||
{
|
||||
float fract_end = fract(pos_end);
|
||||
float fract_start = fract(pos_start);
|
||||
float n = floor (pos_end) - floor (pos_start);
|
||||
if (fract_end > fract_start + 0.01)
|
||||
c = get_color_for_range_unscaled (fract_start, fract_end);
|
||||
else if (fract_start > fract_end + 0.01)
|
||||
c = -get_color_for_range_unscaled (fract_end, fract_start);
|
||||
c += get_color_for_range_unscaled (0.0, 1.0) * n;
|
||||
c /= pos_end - pos_start;
|
||||
}
|
||||
else
|
||||
{
|
||||
c = get_color_for_range (fract (pos_start), fract (pos_end));
|
||||
}
|
||||
}
|
||||
pos = fract (inGradientPos);
|
||||
else
|
||||
{
|
||||
pos_start = clamp (inGradientPos - dPos, 0, 1);
|
||||
pos_end = clamp (inGradientPos + dPos, 0, 1);
|
||||
c = get_color_for_range (pos_start, pos_end);
|
||||
}
|
||||
pos = clamp (inGradientPos, 0, 1);
|
||||
|
||||
float alpha = c.a * rect_coverage (inRect, inPos);
|
||||
color = clip_scaled (inPos, vec4(c.rgb, 1) * alpha);
|
||||
vec4 color = inStops[0].color;
|
||||
int n = clamp (inStopCount, 2, 8);
|
||||
for (int i = 1; i < n; i++)
|
||||
{
|
||||
if (inStops[i].offset > inStops[i-1].offset)
|
||||
color = mix (color, inStops[i].color, clamp((pos - inStops[i-1].offset) / (inStops[i].offset - inStops[i-1].offset), 0, 1));
|
||||
}
|
||||
|
||||
//outColor = vec4(pos, pos, pos, 1.0);
|
||||
outColor = clip (inPos, color);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#version 450
|
||||
#version 420 core
|
||||
|
||||
#include "common.vert.glsl"
|
||||
#include "rect.vert.glsl"
|
||||
#include "clip.vert.glsl"
|
||||
|
||||
struct ColorStop {
|
||||
float offset;
|
||||
@@ -12,32 +11,62 @@ layout(location = 0) in vec4 inRect;
|
||||
layout(location = 1) in vec2 inStart;
|
||||
layout(location = 2) in vec2 inEnd;
|
||||
layout(location = 3) in int inRepeating;
|
||||
layout(location = 4) in int inStopOffset;
|
||||
layout(location = 5) in int inStopCount;
|
||||
layout(location = 4) in int inStopCount;
|
||||
layout(location = 5) in vec4 inOffsets0;
|
||||
layout(location = 6) in vec4 inOffsets1;
|
||||
layout(location = 7) in vec4 inColors0;
|
||||
layout(location = 8) in vec4 inColors1;
|
||||
layout(location = 9) in vec4 inColors2;
|
||||
layout(location = 10) in vec4 inColors3;
|
||||
layout(location = 11) in vec4 inColors4;
|
||||
layout(location = 12) in vec4 inColors5;
|
||||
layout(location = 13) in vec4 inColors6;
|
||||
layout(location = 14) in vec4 inColors7;
|
||||
|
||||
layout(location = 0) out vec2 outPos;
|
||||
layout(location = 1) out flat Rect outRect;
|
||||
layout(location = 2) out float outGradientPos;
|
||||
layout(location = 3) out flat int outRepeating;
|
||||
layout(location = 4) out flat int outStopOffset;
|
||||
layout(location = 5) out flat int outStopCount;
|
||||
layout(location = 1) out float outGradientPos;
|
||||
layout(location = 2) out flat int outRepeating;
|
||||
layout(location = 3) out flat int outStopCount;
|
||||
layout(location = 4) out flat ColorStop outStops[8];
|
||||
|
||||
vec2 offsets[6] = { vec2(0.0, 0.0),
|
||||
vec2(1.0, 0.0),
|
||||
vec2(0.0, 1.0),
|
||||
vec2(0.0, 1.0),
|
||||
vec2(1.0, 0.0),
|
||||
vec2(1.0, 1.0) };
|
||||
|
||||
float
|
||||
get_gradient_pos (vec2 pos)
|
||||
{
|
||||
pos = pos - inStart * push.scale;
|
||||
vec2 grad = (inEnd - inStart) * push.scale;
|
||||
pos = pos - inStart;
|
||||
vec2 grad = inEnd - inStart;
|
||||
|
||||
return dot (pos, grad) / dot (grad, grad);
|
||||
}
|
||||
|
||||
void main() {
|
||||
Rect r = rect_from_gsk (inRect);
|
||||
vec2 pos = set_position_from_rect (r);
|
||||
vec4 rect = clip (inRect);
|
||||
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
|
||||
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
|
||||
outPos = pos;
|
||||
outRect = r;
|
||||
outGradientPos = get_gradient_pos (pos);
|
||||
outRepeating = inRepeating;
|
||||
outStopOffset = inStopOffset;
|
||||
outStopCount = inStopCount;
|
||||
outStops[0].offset = inOffsets0[0];
|
||||
outStops[0].color = inColors0 * vec4(inColors0.aaa, 1.0);
|
||||
outStops[1].offset = inOffsets0[1];
|
||||
outStops[1].color = inColors1 * vec4(inColors1.aaa, 1.0);
|
||||
outStops[2].offset = inOffsets0[2];
|
||||
outStops[2].color = inColors2 * vec4(inColors2.aaa, 1.0);
|
||||
outStops[3].offset = inOffsets0[3];
|
||||
outStops[3].color = inColors3 * vec4(inColors3.aaa, 1.0);
|
||||
outStops[4].offset = inOffsets1[0];
|
||||
outStops[4].color = inColors4 * vec4(inColors4.aaa, 1.0);
|
||||
outStops[5].offset = inOffsets1[1];
|
||||
outStops[5].color = inColors5 * vec4(inColors5.aaa, 1.0);
|
||||
outStops[6].offset = inOffsets1[2];
|
||||
outStops[6].color = inColors6 * vec4(inColors6.aaa, 1.0);
|
||||
outStops[7].offset = inOffsets1[3];
|
||||
outStops[7].color = inColors7 * vec4(inColors7.aaa, 1.0);
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
#version 450
|
||||
#version 420 core
|
||||
|
||||
#include "common.frag.glsl"
|
||||
#include "clip.frag.glsl"
|
||||
|
||||
layout(location = 0) in vec2 inPos;
|
||||
layout(location = 1) in vec2 inTexCoord;
|
||||
layout(location = 2) in vec4 inColor;
|
||||
layout(location = 3) flat in uvec2 inTexId;
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D inTexture;
|
||||
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
color = clip (inPos, vec4(inColor.rgb * inColor.a, inColor.a) * texture(get_sampler (inTexId), inTexCoord).a);
|
||||
color = clip (inPos, vec4(inColor.rgb * inColor.a, inColor.a) * texture(inTexture, inTexCoord).a);
|
||||
}
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
#version 450
|
||||
#version 420 core
|
||||
|
||||
#include "clip.vert.glsl"
|
||||
|
||||
layout(location = 0) in vec4 inRect;
|
||||
layout(location = 1) in vec4 inTexRect;
|
||||
layout(location = 2) in vec4 inColor;
|
||||
layout(location = 3) in uvec2 inTexId;
|
||||
|
||||
layout(location = 0) out vec2 outPos;
|
||||
layout(location = 1) out vec2 outTexCoord;
|
||||
layout(location = 2) out flat vec4 outColor;
|
||||
layout(location = 3) out flat uvec2 outTexId;
|
||||
|
||||
vec2 offsets[6] = { vec2(0.0, 0.0),
|
||||
vec2(1.0, 0.0),
|
||||
@@ -22,7 +20,7 @@ vec2 offsets[6] = { vec2(0.0, 0.0),
|
||||
void main() {
|
||||
vec4 rect = clip (inRect);
|
||||
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
|
||||
gl_Position = push.mvp * vec4 (push.scale * pos, 0.0, 1.0);
|
||||
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
|
||||
|
||||
outPos = pos;
|
||||
|
||||
@@ -31,6 +29,6 @@ void main() {
|
||||
texrect = vec4(inTexRect.xy + inTexRect.zw * texrect.xy,
|
||||
inTexRect.zw * texrect.zw);
|
||||
outTexCoord = texrect.xy + texrect.zw * offsets[gl_VertexIndex];
|
||||
outTexId = inTexId;
|
||||
|
||||
outColor = inColor;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
gsk_private_vulkan_include_shaders = [
|
||||
'clip.frag.glsl',
|
||||
'clip.vert.glsl',
|
||||
'common.frag.glsl',
|
||||
'common.vert.glsl',
|
||||
'constants.glsl',
|
||||
'rect.glsl',
|
||||
'rect.frag.glsl',
|
||||
'rect.vert.glsl',
|
||||
'rounded-rect.glsl',
|
||||
'rounded-rect.frag.glsl',
|
||||
]
|
||||
|
||||
gsk_private_vulkan_fragment_shaders = [
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#version 450
|
||||
#version 420 core
|
||||
|
||||
#include "clip.frag.glsl"
|
||||
#include "rounded-rect.glsl"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#version 450
|
||||
#version 420 core
|
||||
|
||||
#include "clip.vert.glsl"
|
||||
|
||||
@@ -38,7 +38,7 @@ void main() {
|
||||
clip (inOutline);
|
||||
|
||||
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
|
||||
gl_Position = push.mvp * vec4 (push.scale * pos, 0.0, 1.0);
|
||||
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
|
||||
outPos = pos;
|
||||
|
||||
outOutline = inOutline;
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
#ifndef _RECT_FRAG_
|
||||
#define _RECT_FRAG_
|
||||
|
||||
#include "rect.glsl"
|
||||
|
||||
float
|
||||
rect_coverage (Rect r, vec2 p)
|
||||
{
|
||||
vec2 dFdp = abs(fwidth (p));
|
||||
Rect prect = Rect(vec4(p - 0.5 * dFdp, p + 0.5 * dFdp));
|
||||
Rect coverect = rect_intersect (r, prect);
|
||||
vec2 coverage = rect_size(coverect) / dFdp;
|
||||
return coverage.x * coverage.y;
|
||||
}
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user