Compare commits
307 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 914bfc6cdf | |||
| 4466f89b02 | |||
| cc603bf657 | |||
| 0652e05e0b | |||
| 1347d23658 | |||
| 3cf349eb6e | |||
| 53503e3f19 | |||
| 8106dc0f46 | |||
| 8dec07b6c4 | |||
| 29cf15a444 | |||
| abe5eda0f0 | |||
| fa98e2baf3 | |||
| e5eba26eac | |||
| 611439aad7 | |||
| cb3045bf38 | |||
| 447d1fab62 | |||
| 9836389fde | |||
| 7f26f5a160 | |||
| 6a009b7182 | |||
| 17dd100f43 | |||
| 49c2c2da1a | |||
| f88b1cef21 | |||
| c27e412ff1 | |||
| 0c72f19cb1 | |||
| cb4e92946b | |||
| e7c86f4608 | |||
| 4d026857dc | |||
| c523c68cef | |||
| 9f4320a4ac | |||
| 8f6cc19fdb | |||
| 9831632fbd | |||
| bef1c69254 | |||
| f381cdef5b | |||
| f8fd04402e | |||
| e5f570045e | |||
| 4bee0e2454 | |||
| fb6ce30fb4 | |||
| 11108ed048 | |||
| deac44962a | |||
| 0f6219c9ca | |||
| cf980cdefb | |||
| 51265e2367 | |||
| f1484df60a | |||
| 92a8cf3f29 | |||
| 5a877c8d43 | |||
| 1ffaf486af | |||
| 9c3e514d3f | |||
| 1b829c7d01 | |||
| 0f39069be1 | |||
| bc27b54367 | |||
| 9e784f47c9 | |||
| ade66c84ed | |||
| 57c34fca96 | |||
| 10e91f6281 | |||
| aada893352 | |||
| 79847f20c4 | |||
| 22548785b0 | |||
| 2349f13f45 | |||
| 084b4361b6 | |||
| d0ebd42e3e | |||
| a4330aae38 | |||
| a02fc2d290 | |||
| 9df935591c | |||
| 1f8045ddbe | |||
| 82ba8c848b | |||
| cf48f83709 | |||
| 9d79982677 | |||
| 27599d688e | |||
| c0d8716366 | |||
| 3681144768 | |||
| c2fef6f6fd | |||
| f06cfa2967 | |||
| 2cbee7cf86 | |||
| f5cdd6fa32 | |||
| c49c971f47 | |||
| 4746e0bdc4 | |||
| f20ef5a0fc | |||
| cf30a4f304 | |||
| ca189cb5f5 | |||
| 5e07710f5a | |||
| 46bb5837e2 | |||
| 1888f1e422 | |||
| e606313ad1 | |||
| b69bfe3799 | |||
| 5d07c71dd2 | |||
| 8155b08de8 | |||
| 0790f24773 | |||
| 5f02631812 | |||
| c8133ecb50 | |||
| b439398d09 | |||
| fcb9048043 | |||
| 5816e2fe51 | |||
| 298fed6d94 | |||
| 0557b29f5b | |||
| 4c65bdf707 | |||
| 351d747909 | |||
| 53af7208e6 | |||
| c67f3c5038 | |||
| 1bee1cd180 | |||
| e77a17b227 | |||
| d8b4249ee9 | |||
| da47d9cc3d | |||
| 53bebd2ed1 | |||
| ca9f0abdd8 | |||
| 8497f97dec | |||
| f22788a3a8 | |||
| a30e0fad1f | |||
| f033b6c2c6 | |||
| 45656ba426 | |||
| 83efe2b66c | |||
| 84840f1f2e | |||
| 2883f4b7a2 | |||
| 0a0f0d9e7e | |||
| e3cc3f7841 | |||
| d1135f9e3c | |||
| 2d89dfea29 | |||
| 89f20c2fb6 | |||
| c019eb9eea | |||
| 216e415186 | |||
| 28fb91e85e | |||
| 7f3d4fa66e | |||
| 0505c8fac9 | |||
| ccb7c9057a | |||
| ac6f18da12 | |||
| 0d7069452b | |||
| 5aa62b6273 | |||
| 41d03c68f8 | |||
| 30ff352960 | |||
| 2adc017048 | |||
| d1aae4bffa | |||
| 434a747d42 | |||
| 50cf1c08dd | |||
| caaeaedf1f | |||
| 19362522e0 | |||
| 50c3ea064b | |||
| 84e345adac | |||
| d2638f0955 | |||
| e580dcf18d | |||
| 14e44f36bf | |||
| 1e60ad1430 | |||
| 2c67d9f7cf | |||
| 4bcaeab4dc | |||
| 97a4cc301a | |||
| baaa748248 | |||
| cf69fecc87 | |||
| 29ad2c1247 | |||
| 1450789052 | |||
| 51f4ad55cf | |||
| 94d65f6ef1 | |||
| c3f446a95a | |||
| ad8e5c3a39 | |||
| 6b26a4f9be | |||
| 40f215ea46 | |||
| 55dd5f4780 | |||
| 1e878d3928 | |||
| 66c57a8f4e | |||
| ee22f8f52f | |||
| 9070c457d6 | |||
| bba324ce30 | |||
| c322ab34c7 | |||
| 8c5e046574 | |||
| 8860a2a688 | |||
| 5ca40c3660 | |||
| a9f9fb2022 | |||
| a8a49d270b | |||
| 419c431f29 | |||
| fd5d15004e | |||
| 5409f0b350 | |||
| f1b1aacc34 | |||
| e7201968d6 | |||
| 67f2ad817e | |||
| f420c143e0 | |||
| 1cf6dfab2f | |||
| 330a8b1cdb | |||
| 8d19db6732 | |||
| 0f1b039306 | |||
| b791aa0301 | |||
| 7fd94c1828 | |||
| dd4c1167b2 | |||
| d411912396 | |||
| 0e93ad8671 | |||
| d98991a0ad | |||
| 1f7dcc1286 | |||
| 328cdf7b2a | |||
| 79a227bc64 | |||
| 0fee26252c | |||
| d48b6b9ad5 | |||
| d4618ea8a6 | |||
| a73530f952 | |||
| 3e620a8fe5 | |||
| 6d8c8199d9 | |||
| 968ceb71d5 | |||
| 7f5504bea4 | |||
| 4b2b239550 | |||
| 23c10d434c | |||
| 87c9503293 | |||
| 76634cb68b | |||
| 52eefdb7d9 | |||
| ea9f0a3372 | |||
| 8561ff37c4 | |||
| a09580b9ef | |||
| 0511227379 | |||
| 4183ce0b52 | |||
| 57222cc64c | |||
| b3c1284382 | |||
| b02e054592 | |||
| 870ee06d1f | |||
| 8d586be693 | |||
| 94ab11b999 | |||
| 9b1dcd3872 | |||
| c37171f4d6 | |||
| c479f93372 | |||
| 186e056c56 | |||
| d8b9c3ae96 | |||
| 5de6f12e88 | |||
| 5422c12577 | |||
| bb145b9bc1 | |||
| a55fda0b49 | |||
| 5b93a32f90 | |||
| 495ee1be3d | |||
| 7f1bd1f047 | |||
| da147dca92 | |||
| 8ba5ff98aa | |||
| 34f4493c36 | |||
| 314923d4b5 | |||
| d2f45dae96 | |||
| 0e31cf9542 | |||
| af901a10e3 | |||
| 3d1a607367 | |||
| 1be21a33d9 | |||
| 64bcdb713c | |||
| 4a868736f9 | |||
| cfeaa0ac72 | |||
| b44ef07e22 | |||
| 7f119b5ad2 | |||
| d427933c61 | |||
| 85bafbdff0 | |||
| 7ae7356284 | |||
| 444d5fa500 | |||
| c380d17621 | |||
| 686d18dfc2 | |||
| 0a1702ae99 | |||
| 0016fea36b | |||
| 7ef46293aa | |||
| 6b59c138b2 | |||
| b7e3a231b4 | |||
| c8c895d160 | |||
| acbd7f212e | |||
| f2a2889153 | |||
| a4ae215309 | |||
| fa16ba12cf | |||
| ec2421b187 | |||
| 1fce2b1e06 | |||
| 38bf843de8 | |||
| 7b8a5235d4 | |||
| 3c9b3ead6f | |||
| 1549ec5f9b | |||
| 4339e8e464 | |||
| 39f4d5ccf7 | |||
| 957fa87fce | |||
| e8bdd46d8d | |||
| d03b27b441 | |||
| f4cbe26af3 | |||
| 24af4b48cc | |||
| 1c8caf745f | |||
| 395d80f131 | |||
| 74229572e7 | |||
| cbb3d3f177 | |||
| 8861d0eb53 | |||
| a23bc894e9 | |||
| 156e25b6aa | |||
| 96f6787a3e | |||
| cc665f29ea | |||
| 8d2047c824 | |||
| a79da8b655 | |||
| f29c7e76f5 | |||
| 29867e7ae1 | |||
| 876b439d4a | |||
| 4f6d7c69a1 | |||
| 2bf2635635 | |||
| 67ed09f5ae | |||
| 1c72f46eed | |||
| f5e7a1d4cc | |||
| 0f61c52593 | |||
| a4bae6a62d | |||
| d141ac5adf | |||
| 894a4bda85 | |||
| 2b88505ca4 | |||
| ef8c835762 | |||
| 50115d70c6 | |||
| 1a058a41c9 | |||
| be4f6ff3da | |||
| 4fcf899852 | |||
| 371e860184 | |||
| bce1e0bfdd | |||
| 468d2cb7f2 | |||
| b520a5ceda | |||
| e6bc82cff5 | |||
| d021aa7bd2 | |||
| 3dc3d03a08 | |||
| 788bd575d6 | |||
| 94a2dc4c47 | |||
| 169a7f83e6 | |||
| 703494c7fa | |||
| d642072603 | |||
| ab7a4f64cb | |||
| cfef21501c |
+15
-5
@@ -222,7 +222,7 @@ macos:
|
||||
-Dcpp_std=c++11
|
||||
-Dpixman:tests=disabled
|
||||
-Dlibjpeg-turbo:simd=disabled
|
||||
-Ddemos=false
|
||||
-Dbuild-demos=false
|
||||
-Dbuild-tests=false
|
||||
-Dbuild-examples=false
|
||||
-Dbuild-testsuite=false
|
||||
@@ -385,17 +385,27 @@ 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 -Dintrospection=disabled -Df16c=disabled _build
|
||||
- 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
|
||||
- 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:
|
||||
- _build/meson-logs
|
||||
allow_failure: true
|
||||
- "${CI_PROJECT_DIR}/_build/meson-logs"
|
||||
|
||||
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:verbosity=1:log_threads=1
|
||||
export LSAN_OPTIONS=suppressions=$srcdir/lsan.supp:print_suppressions=0:detect_leaks=0:allocator_may_return_null=1
|
||||
export G_SLICE=always-malloc
|
||||
|
||||
case "${backend}" in
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
Overview of Changes in 4.11.3, xx-xx-xxxx
|
||||
Overview of Changes in 4.11.4, xx-xx-xxxx
|
||||
=========================================
|
||||
|
||||
Overview of Changes in 4.11.3, 05-06-2023
|
||||
=========================================
|
||||
|
||||
* GtkGridView:
|
||||
@@ -8,6 +11,9 @@ Overview of Changes in 4.11.3, xx-xx-xxxx
|
||||
* GtkListView:
|
||||
- Don't leak the factories
|
||||
|
||||
* GtkColumnView:
|
||||
- Support displaying sections
|
||||
|
||||
* GtkNotebook:
|
||||
- Make the pages model implement GtkSelectionModel
|
||||
|
||||
@@ -17,18 +23,41 @@ Overview of Changes in 4.11.3, xx-xx-xxxx
|
||||
* GtkPopoverMenu:
|
||||
- Avoid unnecessary left padding
|
||||
|
||||
* Css:
|
||||
* GtkSearchEntry:
|
||||
- Improve size allocation for the clear icon
|
||||
|
||||
* GtkBoxLayout:
|
||||
- Fix a regression from recent baseline work
|
||||
|
||||
* CSS:
|
||||
- Add new binding-friendly css provider apis
|
||||
|
||||
* Theme:
|
||||
- Show focus in the shortcuts window
|
||||
|
||||
* Tests:
|
||||
- Improve test coverage
|
||||
* 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
|
||||
|
||||
* 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
|
||||
@@ -48,7 +77,9 @@ Overview of Changes in 4.11.3, xx-xx-xxxx
|
||||
* Translation updates:
|
||||
Basque
|
||||
Catalan
|
||||
Georgian
|
||||
Russian
|
||||
Turkish
|
||||
|
||||
|
||||
Overview of Changes in 4.11.2, 09-05-2023
|
||||
|
||||
@@ -162,6 +162,10 @@ 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,6 +49,7 @@
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="mnemonic-widget">switch</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
@@ -73,6 +74,7 @@
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="mnemonic-widget">check</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
@@ -110,6 +112,7 @@
|
||||
<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>
|
||||
@@ -150,10 +153,11 @@
|
||||
<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">
|
||||
<object class="GtkScale" id="scale">
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="draw-value">0</property>
|
||||
@@ -185,10 +189,11 @@
|
||||
<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">
|
||||
<object class="GtkSpinButton" id="spin">
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="adjustment">
|
||||
@@ -217,10 +222,11 @@
|
||||
<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">
|
||||
<object class="GtkDropDown" id="dropdown">
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="model">
|
||||
@@ -252,10 +258,11 @@
|
||||
<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">
|
||||
<object class="GtkEntry" id="entry">
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="placeholder-text">Type here…</property>
|
||||
|
||||
@@ -368,6 +368,38 @@ 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)
|
||||
{
|
||||
@@ -377,10 +409,12 @@ 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 many_times[] = {
|
||||
const char * const minutes[] = {
|
||||
"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", "1 hour", "2 hours", "3 hours", "5 hours", "6 hours", "7 hours",
|
||||
"55 minutes", NULL
|
||||
};
|
||||
const char * const hours[] = { "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 };
|
||||
@@ -395,6 +429,10 @@ 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));
|
||||
@@ -422,14 +460,25 @@ do_listview_selections (GtkWidget *do_widget)
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
|
||||
/* A dropdown using an expression to obtain strings */
|
||||
button = drop_down_new_from_strings (many_times, NULL, NULL);
|
||||
gtk_drop_down_set_enable_search (GTK_DROP_DOWN (button), TRUE);
|
||||
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));
|
||||
expression = gtk_cclosure_expression_new (G_TYPE_STRING, NULL,
|
||||
0, NULL,
|
||||
(GCallback)get_title,
|
||||
NULL, NULL);
|
||||
gtk_drop_down_set_expression (GTK_DROP_DOWN (button), expression);
|
||||
gtk_expression_unref (expression);
|
||||
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_box_append (GTK_BOX (box), button);
|
||||
|
||||
button = gtk_drop_down_new (NULL, NULL);
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
<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>
|
||||
|
||||
+38
-24
@@ -18,7 +18,6 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
@@ -268,9 +267,9 @@ activate_run (GSimpleAction *action,
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
display_image (const char *format,
|
||||
const char *resource,
|
||||
char **label)
|
||||
display_image (const char *format,
|
||||
const char *resource,
|
||||
GtkWidget *label)
|
||||
{
|
||||
GtkWidget *sw, *image;
|
||||
|
||||
@@ -280,13 +279,17 @@ 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,
|
||||
char **label)
|
||||
display_images (const char *format,
|
||||
const char *resource_dir,
|
||||
GtkWidget *label)
|
||||
{
|
||||
char **resources;
|
||||
GtkWidget *grid;
|
||||
@@ -311,13 +314,15 @@ display_images (const char *format,
|
||||
{
|
||||
char *resource_name;
|
||||
GtkWidget *box;
|
||||
GtkWidget *image_label;
|
||||
|
||||
resource_name = g_strconcat (resource_dir, "/", resources[i], NULL);
|
||||
|
||||
widget = display_image (NULL, resource_name, NULL);
|
||||
image_label = gtk_label_new (resources[i]);
|
||||
widget = display_image (NULL, resource_name, image_label);
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_box_append (GTK_BOX (box), widget);
|
||||
gtk_box_append (GTK_BOX (box), gtk_label_new (resources[i]));
|
||||
gtk_box_append (GTK_BOX (box), image_label);
|
||||
gtk_flow_box_insert (GTK_FLOW_BOX (grid), box, -1);
|
||||
|
||||
g_free (resource_name);
|
||||
@@ -325,15 +330,19 @@ display_images (const char *format,
|
||||
|
||||
g_strfreev (resources);
|
||||
|
||||
*label = g_strdup ("Images");
|
||||
gtk_label_set_label (GTK_LABEL (label), "Images");
|
||||
|
||||
gtk_accessible_update_relation (GTK_ACCESSIBLE (grid),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY, label, NULL,
|
||||
-1);
|
||||
|
||||
return sw;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
display_text (const char *format,
|
||||
const char *resource,
|
||||
char **label)
|
||||
display_text (const char *format,
|
||||
const char *resource,
|
||||
GtkWidget *label)
|
||||
{
|
||||
GtkTextBuffer *buffer;
|
||||
GtkWidget *textview, *sw;
|
||||
@@ -368,6 +377,10 @@ 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,
|
||||
@@ -378,15 +391,19 @@ display_text (const char *format,
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
display_video (const char *format,
|
||||
const char *resource,
|
||||
char **label)
|
||||
display_video (const char *format,
|
||||
const char *resource,
|
||||
GtkWidget *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;
|
||||
}
|
||||
|
||||
@@ -408,9 +425,9 @@ display_nothing (const char *resource)
|
||||
static struct {
|
||||
const char *extension;
|
||||
const char *format;
|
||||
GtkWidget * (* display_func) (const char *format,
|
||||
const char *resource,
|
||||
char **label);
|
||||
GtkWidget * (* display_func) (const char *format,
|
||||
const char *resource,
|
||||
GtkWidget *label);
|
||||
} display_funcs[] = {
|
||||
{ ".gif", NULL, display_image },
|
||||
{ ".jpg", NULL, display_image },
|
||||
@@ -433,7 +450,6 @@ 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);
|
||||
@@ -453,23 +469,21 @@ add_data_tab (const char *demoname)
|
||||
break;
|
||||
}
|
||||
|
||||
label_string = NULL;
|
||||
label = gtk_label_new (resources[i]);
|
||||
|
||||
if (j < G_N_ELEMENTS (display_funcs))
|
||||
widget = display_funcs[j].display_func (display_funcs[j].format,
|
||||
resource_name,
|
||||
&label_string);
|
||||
label);
|
||||
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,14 +57,17 @@
|
||||
<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>
|
||||
@@ -76,15 +79,15 @@
|
||||
<style>
|
||||
<class name="sidebar"/>
|
||||
</style>
|
||||
<property name="width-request">120</property>
|
||||
<property name="hscrollbar-policy">never</property>
|
||||
<property name="min-content-width">150</property>
|
||||
<property name="propagate-natural-width">1</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,6 +68,9 @@ 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);
|
||||
|
||||
@@ -77,6 +80,9 @@ 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,6 +189,7 @@ 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:");
|
||||
@@ -198,6 +199,7 @@ 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:");
|
||||
@@ -208,6 +210,9 @@ 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");
|
||||
|
||||
@@ -223,6 +228,9 @@ 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 widgets [vfunc@Gtk.Widget.measure]
|
||||
is determined by GTKs layout algorithm using each widget’s [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 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]
|
||||
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]
|
||||
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 widgets coordinate system to another one can be obtained
|
||||
The transform to go from one widget’s 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 widgets **_bounds_**, which is the area
|
||||
that a widgets rendering is typically confined to (technically, widgets can draw outside
|
||||
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
|
||||
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,6 +208,9 @@ 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,19 +204,17 @@ 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 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.
|
||||
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.
|
||||
|
||||
Application developers using GTK **should** ensure that their UI controls
|
||||
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.
|
||||
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.
|
||||
|
||||
## Implementations
|
||||
|
||||
|
||||
@@ -645,6 +645,9 @@ 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,6 +383,9 @@ 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <gdk/version/gdkversionmacros.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
@@ -306,6 +308,20 @@ typedef enum
|
||||
* the alpha value. Since: 4.6
|
||||
* @GDK_MEMORY_R32G32B32A32_FLOAT: 4 float values; for red, green, blue and
|
||||
* alpha. Since: 4.6
|
||||
* @GDK_MEMORY_G8A8_PREMULTIPLIED: 2 bytes; for grayscale, alpha. The color
|
||||
* values are premultiplied with the alpha value. Since: 4.12
|
||||
* @GDK_MEMORY_G8A8: 2 bytes; for grayscale, alpha. Since: 4.12
|
||||
* @GDK_MEMORY_G8: One byte; for grayscale. The data is opaque.
|
||||
* Since: 4.12
|
||||
* @GDK_MEMORY_G16A16_PREMULTIPLIED: 2 guint16 values; for grayscale, alpha.
|
||||
* The color values are premultiplied with the alpha value. Since: 4.12
|
||||
* @GDK_MEMORY_G16A16: 2 guint16 values; for grayscale, alpha. Since: 4.12
|
||||
* @GDK_MEMORY_G16: One guint16 value; for grayscale. The data is opaque.
|
||||
* Since: 4.12
|
||||
* @GDK_MEMORY_A8: One byte; for alpha.
|
||||
* Since: 4.12
|
||||
* @GDK_MEMORY_A16: One guint16 value; for alpha.
|
||||
* Since: 4.12
|
||||
* @GDK_MEMORY_N_FORMATS: The number of formats. This value will change as
|
||||
* more formats get added, so do not rely on its concrete integer.
|
||||
*
|
||||
@@ -340,6 +356,14 @@ typedef enum {
|
||||
GDK_MEMORY_R32G32B32_FLOAT,
|
||||
GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED,
|
||||
GDK_MEMORY_R32G32B32A32_FLOAT,
|
||||
GDK_MEMORY_G8A8_PREMULTIPLIED GDK_AVAILABLE_ENUMERATOR_IN_4_12,
|
||||
GDK_MEMORY_G8A8 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
|
||||
GDK_MEMORY_G8 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
|
||||
GDK_MEMORY_G16A16_PREMULTIPLIED GDK_AVAILABLE_ENUMERATOR_IN_4_12,
|
||||
GDK_MEMORY_G16A16 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
|
||||
GDK_MEMORY_G16 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
|
||||
GDK_MEMORY_A8 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
|
||||
GDK_MEMORY_A16 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
|
||||
|
||||
GDK_MEMORY_N_FORMATS
|
||||
} GdkMemoryFormat;
|
||||
|
||||
+2
-6
@@ -173,12 +173,8 @@ static GPrivate thread_current_context = G_PRIVATE_INIT (unref_unmasked);
|
||||
static void
|
||||
gdk_gl_context_clear_old_updated_area (GdkGLContext *context)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
g_clear_pointer (&context->old_updated_area[i], cairo_region_destroy);
|
||||
}
|
||||
for (unsigned int i = 0; i < GDK_GL_MAX_TRACKED_BUFFERS; i++)
|
||||
g_clear_pointer (&context->old_updated_area[i], cairo_region_destroy);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
+139
-23
@@ -138,6 +138,7 @@ static gboolean
|
||||
gdk_gl_texture_find_format (gboolean use_es,
|
||||
guint gl_major,
|
||||
guint gl_minor,
|
||||
GdkMemoryAlpha alpha,
|
||||
GLint gl_format,
|
||||
GLint gl_type,
|
||||
GdkMemoryFormat *out_format)
|
||||
@@ -147,8 +148,12 @@ gdk_gl_texture_find_format (gboolean use_es,
|
||||
for (format = 0; format < GDK_MEMORY_N_FORMATS; format++)
|
||||
{
|
||||
GLenum q_internal_format, q_format, q_type;
|
||||
GLint q_swizzle[4];
|
||||
|
||||
if (!gdk_memory_format_gl_format (format, use_es, gl_major, gl_minor, &q_internal_format, &q_format, &q_type))
|
||||
if (gdk_memory_format_alpha (format) != alpha)
|
||||
continue;
|
||||
|
||||
if (!gdk_memory_format_gl_format (format, use_es, gl_major, gl_minor, &q_internal_format, &q_format, &q_type, &q_swizzle))
|
||||
continue;
|
||||
|
||||
if (q_format != gl_format || q_type != gl_type)
|
||||
@@ -167,31 +172,57 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
|
||||
gpointer download_)
|
||||
{
|
||||
GdkTexture *texture = GDK_TEXTURE (self);
|
||||
GdkMemoryFormat format;
|
||||
gsize expected_stride;
|
||||
Download *download = download_;
|
||||
GLenum gl_internal_format, gl_format, gl_type;
|
||||
GLint gl_swizzle[4];
|
||||
int major, minor;
|
||||
unsigned int internal_texture_format, dummy;
|
||||
|
||||
format = gdk_texture_get_format (texture),
|
||||
expected_stride = texture->width * gdk_memory_format_bytes_per_pixel (download->format);
|
||||
gdk_gl_context_get_version (context, &major, &minor);
|
||||
|
||||
gdk_memory_format_gl_format (gdk_texture_get_format (texture),
|
||||
FALSE,
|
||||
major, minor,
|
||||
&internal_texture_format,
|
||||
&dummy, &dummy);
|
||||
|
||||
if (download->stride == expected_stride &&
|
||||
!gdk_gl_context_get_use_es (context) &&
|
||||
gdk_memory_format_gl_format (download->format, FALSE, major, minor, &gl_internal_format, &gl_format, &gl_type) &&
|
||||
gl_internal_format == internal_texture_format)
|
||||
if (!gdk_gl_context_get_use_es (context) &&
|
||||
gdk_memory_format_gl_format (format,
|
||||
FALSE,
|
||||
major, minor,
|
||||
&gl_internal_format,
|
||||
&gl_format, &gl_type, &gl_swizzle))
|
||||
{
|
||||
glGetTexImage (GL_TEXTURE_2D,
|
||||
0,
|
||||
gl_format,
|
||||
gl_type,
|
||||
download->data);
|
||||
if (download->stride == expected_stride &&
|
||||
download->format == format)
|
||||
{
|
||||
glGetTexImage (GL_TEXTURE_2D,
|
||||
0,
|
||||
gl_format,
|
||||
gl_type,
|
||||
download->data);
|
||||
}
|
||||
else
|
||||
{
|
||||
gsize stride = texture->width * gdk_memory_format_bytes_per_pixel (format);
|
||||
guchar *pixels = g_malloc_n (stride, texture->height);
|
||||
|
||||
glPixelStorei (GL_PACK_ALIGNMENT, 1);
|
||||
glGetTexImage (GL_TEXTURE_2D,
|
||||
0,
|
||||
gl_format,
|
||||
gl_type,
|
||||
pixels);
|
||||
|
||||
gdk_memory_convert (download->data,
|
||||
download->stride,
|
||||
download->format,
|
||||
pixels,
|
||||
stride,
|
||||
format,
|
||||
texture->width,
|
||||
texture->height);
|
||||
|
||||
g_free (pixels);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -204,17 +235,26 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
|
||||
glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, self->id, 0);
|
||||
if (gdk_gl_context_check_version (context, "4.3", "3.1"))
|
||||
{
|
||||
gdk_gl_context_get_version (context, &major, &minor);
|
||||
glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_FORMAT, &gl_read_format);
|
||||
glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_TYPE, &gl_read_type);
|
||||
if (!gdk_gl_texture_find_format (gdk_gl_context_get_use_es (context), major, minor, gl_read_format, gl_read_type, &actual_format))
|
||||
actual_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED; /* pray */
|
||||
if (!gdk_gl_texture_find_format (TRUE, major, minor, gdk_memory_format_alpha (format), gl_read_format, gl_read_type, &actual_format))
|
||||
{
|
||||
gl_read_format = GL_RGBA;
|
||||
gl_read_type = GL_UNSIGNED_BYTE;
|
||||
if (gdk_memory_format_alpha (format) == GDK_MEMORY_ALPHA_PREMULTIPLIED)
|
||||
actual_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED; /* pray */
|
||||
else
|
||||
actual_format = GDK_MEMORY_R8G8B8A8;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gl_read_format = GL_RGBA;
|
||||
gl_read_type = GL_UNSIGNED_BYTE;
|
||||
actual_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
|
||||
if (gdk_memory_format_alpha (format) == GDK_MEMORY_ALPHA_PREMULTIPLIED)
|
||||
actual_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED; /* pray */
|
||||
else
|
||||
actual_format = GDK_MEMORY_R8G8B8A8;
|
||||
}
|
||||
|
||||
if (download->format == actual_format &&
|
||||
@@ -229,19 +269,95 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
|
||||
else
|
||||
{
|
||||
gsize actual_bpp = gdk_memory_format_bytes_per_pixel (actual_format);
|
||||
guchar *pixels = g_malloc_n (texture->width * actual_bpp, texture->height);
|
||||
gsize stride = actual_bpp * texture->width;
|
||||
guchar *pixels = g_malloc_n (stride, texture->height);
|
||||
|
||||
glPixelStorei (GL_PACK_ALIGNMENT, 1);
|
||||
glReadPixels (0, 0,
|
||||
texture->width, texture->height,
|
||||
gl_read_format,
|
||||
gl_read_type,
|
||||
pixels);
|
||||
|
||||
/* Fix up gles inadequacies */
|
||||
|
||||
if (gl_read_format == GL_RGBA &&
|
||||
gl_read_type == GL_UNSIGNED_BYTE &&
|
||||
(format == GDK_MEMORY_G8A8 ||
|
||||
format == GDK_MEMORY_G8A8_PREMULTIPLIED ||
|
||||
format == GDK_MEMORY_G8 ||
|
||||
format == GDK_MEMORY_A8))
|
||||
{
|
||||
for (unsigned int y = 0; y < texture->height; y++)
|
||||
{
|
||||
for (unsigned int x = 0; x < texture->width; x++)
|
||||
{
|
||||
guchar *data = &pixels[y * stride + x * actual_bpp];
|
||||
if (format == GDK_MEMORY_G8A8 ||
|
||||
format == GDK_MEMORY_G8A8_PREMULTIPLIED)
|
||||
{
|
||||
data[3] = data[1];
|
||||
data[1] = data[0];
|
||||
data[2] = data[0];
|
||||
}
|
||||
else if (format == GDK_MEMORY_G8)
|
||||
{
|
||||
data[1] = data[0];
|
||||
data[2] = data[0];
|
||||
data[3] = 0xff;
|
||||
}
|
||||
else if (format == GDK_MEMORY_A8)
|
||||
{
|
||||
data[3] = data[0];
|
||||
data[0] = 0;
|
||||
data[1] = 0;
|
||||
data[2] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (gl_read_format == GL_RGBA &&
|
||||
gl_read_type == GL_UNSIGNED_SHORT &&
|
||||
(format == GDK_MEMORY_G16A16 ||
|
||||
format == GDK_MEMORY_G16A16_PREMULTIPLIED ||
|
||||
format == GDK_MEMORY_G16 ||
|
||||
format == GDK_MEMORY_A16))
|
||||
{
|
||||
for (unsigned int y = 0; y < texture->height; y++)
|
||||
{
|
||||
for (unsigned int x = 0; x < texture->width; x++)
|
||||
{
|
||||
guint16 *data = (guint16 *) &pixels[y * stride + x * actual_bpp];
|
||||
if (format == GDK_MEMORY_G16A16 ||
|
||||
format == GDK_MEMORY_G16A16_PREMULTIPLIED)
|
||||
{
|
||||
data[3] = data[1];
|
||||
data[1] = data[0];
|
||||
data[2] = data[0];
|
||||
}
|
||||
else if (format == GDK_MEMORY_G16)
|
||||
{
|
||||
data[1] = data[0];
|
||||
data[2] = data[0];
|
||||
data[3] = 0xffff;
|
||||
}
|
||||
else if (format == GDK_MEMORY_A16)
|
||||
{
|
||||
data[3] = data[0];
|
||||
data[0] = 0;
|
||||
data[1] = 0;
|
||||
data[2] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gdk_memory_convert (download->data,
|
||||
download->stride,
|
||||
download->format,
|
||||
pixels,
|
||||
texture->width * actual_bpp,
|
||||
stride,
|
||||
actual_format,
|
||||
texture->width,
|
||||
texture->height);
|
||||
|
||||
@@ -644,10 +644,18 @@ gdk_gl_texture_builder_get_format (GdkGLTextureBuilder *self)
|
||||
* The format is the preferred format the texture data should be downloaded to. The
|
||||
* format must be supported by the GL version of [property@Gdk.GLTextureBuilder:context].
|
||||
*
|
||||
* GDK's texture download code assumes that the format corresponds to the storage
|
||||
* parameters of the GL texture in an obvious way. For example, a format of
|
||||
* `GDK_MEMORY_R16G16B16A16_PREMULTIPLIED` is expected to be stored as `GL_RGBA16`
|
||||
* texture, and `GDK_MEMORY_G8A8` is expected to be stored as `GL_RG8` texture.
|
||||
*
|
||||
* Setting the right format is particularly useful when using high bit depth textures
|
||||
* to preserve the bit depth, to set the correct value for unpremultiplied textures
|
||||
* and to make sure opaque textures are treated as such.
|
||||
*
|
||||
* Non-RGBA textures need to have swizzling parameters set up properly to be usable
|
||||
* in GSK's shaders.
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
void
|
||||
|
||||
+141
-27
@@ -60,6 +60,36 @@ name ## _from_float (guchar *dest_data, \
|
||||
} \
|
||||
}
|
||||
|
||||
#define TYPED_GRAY_FUNCS(name, T, G, A, bpp, scale) \
|
||||
static void \
|
||||
name ## _to_float (float *dest, \
|
||||
const guchar *src_data, \
|
||||
gsize n) \
|
||||
{ \
|
||||
for (gsize i = 0; i < n; i++) \
|
||||
{ \
|
||||
T *src = (T *) (src_data + i * bpp); \
|
||||
if (G >= 0) dest[0] = (float) src[G] / scale; else dest[0] = 1.0; \
|
||||
dest[1] = dest[2] = dest[0]; \
|
||||
if (A >= 0) dest[3] = (float) src[A] / scale; else dest[3] = 1.0; \
|
||||
dest += 4; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
static void \
|
||||
name ## _from_float (guchar *dest_data, \
|
||||
const float *src, \
|
||||
gsize n) \
|
||||
{ \
|
||||
for (gsize i = 0; i < n; i++) \
|
||||
{ \
|
||||
T *dest = (T *) (dest_data + i * bpp); \
|
||||
if (G >= 0) dest[G] = CLAMP ((src[0] + src[1] + src[2]) * scale / 3.f + 0.5, 0, scale); \
|
||||
if (A >= 0) dest[A] = CLAMP (src[3] * scale + 0.5, 0, scale); \
|
||||
src += 4; \
|
||||
} \
|
||||
}
|
||||
|
||||
TYPED_FUNCS (b8g8r8a8_premultiplied, guchar, 2, 1, 0, 3, 4, 255)
|
||||
TYPED_FUNCS (a8r8g8b8_premultiplied, guchar, 1, 2, 3, 0, 4, 255)
|
||||
TYPED_FUNCS (r8g8b8a8_premultiplied, guchar, 0, 1, 2, 3, 4, 255)
|
||||
@@ -72,6 +102,15 @@ TYPED_FUNCS (b8g8r8, guchar, 2, 1, 0, -1, 3, 255)
|
||||
TYPED_FUNCS (r16g16b16, guint16, 0, 1, 2, -1, 6, 65535)
|
||||
TYPED_FUNCS (r16g16b16a16, guint16, 0, 1, 2, 3, 8, 65535)
|
||||
|
||||
TYPED_GRAY_FUNCS (g8a8_premultiplied, guchar, 0, 1, 2, 255)
|
||||
TYPED_GRAY_FUNCS (g8a8, guchar, 0, 1, 2, 255)
|
||||
TYPED_GRAY_FUNCS (g8, guchar, 0, -1, 1, 255)
|
||||
TYPED_GRAY_FUNCS (a8, guchar, -1, 0, 1, 255)
|
||||
TYPED_GRAY_FUNCS (g16a16_premultiplied, guint16, 0, 1, 4, 65535)
|
||||
TYPED_GRAY_FUNCS (g16a16, guint16, 0, 1, 4, 65535)
|
||||
TYPED_GRAY_FUNCS (g16, guint16, 0, -1, 2, 65535)
|
||||
TYPED_GRAY_FUNCS (a16, guint16, -1, 0, 2, 65535)
|
||||
|
||||
static void
|
||||
r16g16b16_float_to_float (float *dest,
|
||||
const guchar *src_data,
|
||||
@@ -230,6 +269,7 @@ struct _GdkMemoryFormatDescription
|
||||
guint internal_format;
|
||||
guint format;
|
||||
guint type;
|
||||
GLint swizzle[4];
|
||||
} gl;
|
||||
/* no premultiplication going on here */
|
||||
void (* to_float) (float *, const guchar*, gsize);
|
||||
@@ -251,7 +291,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
{ 0, 0, G_MAXUINT, G_MAXUINT },
|
||||
{ GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE },
|
||||
{ GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
|
||||
b8g8r8a8_premultiplied_to_float,
|
||||
b8g8r8a8_premultiplied_from_float,
|
||||
},
|
||||
@@ -261,7 +301,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
{ 0, 0, G_MAXUINT, G_MAXUINT },
|
||||
{ GL_RGBA8, GL_BGRA, GDK_GL_UNSIGNED_BYTE_FLIPPED },
|
||||
{ GL_RGBA8, GL_BGRA, GDK_GL_UNSIGNED_BYTE_FLIPPED, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
|
||||
a8r8g8b8_premultiplied_to_float,
|
||||
a8r8g8b8_premultiplied_from_float,
|
||||
},
|
||||
@@ -271,7 +311,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
{ 0, 0, 0, 0 },
|
||||
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE },
|
||||
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
|
||||
r8g8b8a8_premultiplied_to_float,
|
||||
r8g8b8a8_premultiplied_from_float,
|
||||
},
|
||||
@@ -281,7 +321,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
{ 0, 0, G_MAXUINT, G_MAXUINT },
|
||||
{ GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE },
|
||||
{ GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
|
||||
b8g8r8a8_to_float,
|
||||
b8g8r8a8_from_float,
|
||||
},
|
||||
@@ -291,7 +331,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
{ 0, 0, G_MAXUINT, G_MAXUINT },
|
||||
{ GL_RGBA8, GL_RGBA, GDK_GL_UNSIGNED_BYTE_FLIPPED },
|
||||
{ GL_RGBA8, GL_RGBA, GDK_GL_UNSIGNED_BYTE_FLIPPED, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
|
||||
a8r8g8b8_to_float,
|
||||
a8r8g8b8_from_float,
|
||||
},
|
||||
@@ -301,7 +341,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
{ 0, 0, 0, 0 },
|
||||
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE },
|
||||
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
|
||||
r8g8b8a8_to_float,
|
||||
r8g8b8a8_from_float,
|
||||
},
|
||||
@@ -311,7 +351,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
{ 0, 0, G_MAXUINT, G_MAXUINT },
|
||||
{ GL_RGBA8, GL_BGRA, GDK_GL_UNSIGNED_BYTE_FLIPPED },
|
||||
{ GL_RGBA8, GL_BGRA, GDK_GL_UNSIGNED_BYTE_FLIPPED, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
|
||||
a8b8g8r8_to_float,
|
||||
a8b8g8r8_from_float,
|
||||
},
|
||||
@@ -321,7 +361,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
{ 0, 0, 0, 0 },
|
||||
{ GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE },
|
||||
{ GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } },
|
||||
r8g8b8_to_float,
|
||||
r8g8b8_from_float,
|
||||
},
|
||||
@@ -331,7 +371,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
{ 0, 0, G_MAXUINT, G_MAXUINT },
|
||||
{ GL_RGB8, GL_BGR, GL_UNSIGNED_BYTE },
|
||||
{ GL_RGB8, GL_BGR, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } },
|
||||
b8g8r8_to_float,
|
||||
b8g8r8_from_float,
|
||||
},
|
||||
@@ -341,7 +381,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
G_ALIGNOF (guint16),
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RGB16, GL_RGB, GL_UNSIGNED_SHORT },
|
||||
{ GL_RGB16, GL_RGB, GL_UNSIGNED_SHORT, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } },
|
||||
r16g16b16_to_float,
|
||||
r16g16b16_from_float,
|
||||
},
|
||||
@@ -351,7 +391,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
G_ALIGNOF (guint16),
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT },
|
||||
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
|
||||
r16g16b16a16_to_float,
|
||||
r16g16b16a16_from_float,
|
||||
},
|
||||
@@ -361,7 +401,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
G_ALIGNOF (guint16),
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT },
|
||||
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
|
||||
r16g16b16a16_to_float,
|
||||
r16g16b16a16_from_float,
|
||||
},
|
||||
@@ -371,7 +411,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
G_ALIGNOF (guint16),
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RGB16F, GL_RGB, GL_HALF_FLOAT },
|
||||
{ GL_RGB16F, GL_RGB, GL_HALF_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } },
|
||||
r16g16b16_float_to_float,
|
||||
r16g16b16_float_from_float,
|
||||
},
|
||||
@@ -381,7 +421,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
G_ALIGNOF (guint16),
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT },
|
||||
{ GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
|
||||
r16g16b16a16_float_to_float,
|
||||
r16g16b16a16_float_from_float,
|
||||
},
|
||||
@@ -391,7 +431,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
G_ALIGNOF (guint16),
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT },
|
||||
{ GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
|
||||
r16g16b16a16_float_to_float,
|
||||
r16g16b16a16_float_from_float,
|
||||
},
|
||||
@@ -401,7 +441,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
G_ALIGNOF (float),
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RGB32F, GL_RGB, GL_FLOAT },
|
||||
{ GL_RGB32F, GL_RGB, GL_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } },
|
||||
r32g32b32_float_to_float,
|
||||
r32g32b32_float_from_float,
|
||||
},
|
||||
@@ -411,7 +451,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
G_ALIGNOF (float),
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RGBA32F, GL_RGBA, GL_FLOAT },
|
||||
{ GL_RGBA32F, GL_RGBA, GL_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
|
||||
r32g32b32a32_float_to_float,
|
||||
r32g32b32a32_float_from_float,
|
||||
},
|
||||
@@ -421,9 +461,89 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
G_ALIGNOF (float),
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RGBA32F, GL_RGBA, GL_FLOAT },
|
||||
{ GL_RGBA32F, GL_RGBA, GL_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
|
||||
r32g32b32a32_float_to_float,
|
||||
r32g32b32a32_float_from_float,
|
||||
},
|
||||
[GDK_MEMORY_G8A8_PREMULTIPLIED] = {
|
||||
GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
2,
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RG8, GL_RG, GL_UNSIGNED_BYTE, { GL_RED, GL_RED, GL_RED, GL_GREEN } },
|
||||
g8a8_premultiplied_to_float,
|
||||
g8a8_premultiplied_from_float,
|
||||
},
|
||||
[GDK_MEMORY_G8A8] = {
|
||||
GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
2,
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RG8, GL_RG, GL_UNSIGNED_BYTE, { GL_RED, GL_RED, GL_RED, GL_GREEN } },
|
||||
g8a8_to_float,
|
||||
g8a8_from_float,
|
||||
},
|
||||
[GDK_MEMORY_G8] = {
|
||||
GDK_MEMORY_ALPHA_OPAQUE,
|
||||
1,
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_R8, GL_RED, GL_UNSIGNED_BYTE, { GL_RED, GL_RED, GL_RED, GL_ONE } },
|
||||
g8_to_float,
|
||||
g8_from_float,
|
||||
},
|
||||
[GDK_MEMORY_G16A16_PREMULTIPLIED] = {
|
||||
GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
4,
|
||||
G_ALIGNOF (guint16),
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RG16, GL_RG, GL_UNSIGNED_SHORT, { GL_RED, GL_RED, GL_RED, GL_GREEN } },
|
||||
g16a16_premultiplied_to_float,
|
||||
g16a16_premultiplied_from_float,
|
||||
},
|
||||
[GDK_MEMORY_G16A16] = {
|
||||
GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
4,
|
||||
G_ALIGNOF (guint16),
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RG16, GL_RG, GL_UNSIGNED_SHORT, { GL_RED, GL_RED, GL_RED, GL_GREEN } },
|
||||
g16a16_to_float,
|
||||
g16a16_from_float,
|
||||
},
|
||||
[GDK_MEMORY_G16] = {
|
||||
GDK_MEMORY_ALPHA_OPAQUE,
|
||||
2,
|
||||
G_ALIGNOF (guint16),
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_R16, GL_RED, GL_UNSIGNED_SHORT, { GL_RED, GL_RED, GL_RED, GL_ONE } },
|
||||
g16_to_float,
|
||||
g16_from_float,
|
||||
},
|
||||
[GDK_MEMORY_A8] = {
|
||||
GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
1,
|
||||
G_ALIGNOF (guchar),
|
||||
FALSE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_R8, GL_RED, GL_UNSIGNED_BYTE, { GL_ONE, GL_ONE, GL_ONE, GL_RED } },
|
||||
a8_to_float,
|
||||
a8_from_float,
|
||||
},
|
||||
[GDK_MEMORY_A16] = {
|
||||
GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
2,
|
||||
G_ALIGNOF (guint16),
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_R16, GL_RED, GL_UNSIGNED_SHORT, { GL_ONE, GL_ONE, GL_ONE, GL_RED } },
|
||||
a16_to_float,
|
||||
a16_from_float,
|
||||
}
|
||||
};
|
||||
|
||||
@@ -472,14 +592,13 @@ gdk_memory_format_gl_format (GdkMemoryFormat format,
|
||||
guint gl_minor,
|
||||
guint *out_internal_format,
|
||||
guint *out_format,
|
||||
guint *out_type)
|
||||
guint *out_type,
|
||||
GLint (*out_swizzle)[4])
|
||||
{
|
||||
*out_internal_format = memory_formats[format].gl.internal_format;
|
||||
*out_format = memory_formats[format].gl.format;
|
||||
*out_type = memory_formats[format].gl.type;
|
||||
|
||||
if (memory_formats[format].alpha == GDK_MEMORY_ALPHA_STRAIGHT)
|
||||
return FALSE;
|
||||
memcpy (out_swizzle, &memory_formats[format].gl.swizzle, sizeof(GLint) * 4);
|
||||
|
||||
if (gles)
|
||||
{
|
||||
@@ -600,11 +719,6 @@ gdk_memory_convert (guchar *dest_data,
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
src_desc->to_float (tmp, src_data, width);
|
||||
|
||||
/* Note: Converting from a premultiplied format to an opaque format is defined
|
||||
* to yield the same result as compositing over black, which works out to
|
||||
* using the premultiplied values, and just dropping alpha.
|
||||
*/
|
||||
if (src_desc->alpha == GDK_MEMORY_ALPHA_PREMULTIPLIED && dest_desc->alpha == GDK_MEMORY_ALPHA_STRAIGHT)
|
||||
unpremultiply (tmp, width);
|
||||
else if (src_desc->alpha == GDK_MEMORY_ALPHA_STRAIGHT && dest_desc->alpha != GDK_MEMORY_ALPHA_STRAIGHT)
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
#include "gdkenums.h"
|
||||
|
||||
#include <epoxy/gl.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef enum {
|
||||
@@ -39,7 +41,8 @@ gboolean gdk_memory_format_gl_format (GdkMemoryFormat
|
||||
guint gl_minor,
|
||||
guint *out_internal_format,
|
||||
guint *out_format,
|
||||
guint *out_type);
|
||||
guint *out_type,
|
||||
GLint (*out_gizzle)[4]);
|
||||
|
||||
void gdk_memory_convert (guchar *dest_data,
|
||||
gsize dest_stride,
|
||||
|
||||
+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_ALL = (GDK_SEAT_CAPABILITY_ALL_POINTING | GDK_SEAT_CAPABILITY_KEYBOARD | GDK_SEAT_CAPABILITY_TABLET_PAD)
|
||||
} GdkSeatCapabilities;
|
||||
|
||||
struct _GdkSeat
|
||||
|
||||
+15
-10
@@ -1053,26 +1053,30 @@ 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) {
|
||||
VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
|
||||
NULL,
|
||||
0,
|
||||
1,
|
||||
&(VkDeviceQueueCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
|
||||
.queueCreateInfoCount = 1,
|
||||
.pQueueCreateInfos = &(VkDeviceQueueCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,
|
||||
.queueFamilyIndex = j,
|
||||
.queueCount = 1,
|
||||
.pQueuePriorities = (float []) { 1.0f },
|
||||
},
|
||||
0,
|
||||
NULL,
|
||||
device_extensions->len,
|
||||
(const char * const *) device_extensions->pdata
|
||||
.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,
|
||||
}
|
||||
},
|
||||
NULL,
|
||||
&display->vk_device) != VK_SUCCESS)
|
||||
@@ -1144,6 +1148,7 @@ 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++)
|
||||
@@ -1215,7 +1220,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);
|
||||
|
||||
+49
-6
@@ -183,8 +183,7 @@ gdk_load_png (GBytes *bytes,
|
||||
if (color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
png_set_palette_to_rgb (png);
|
||||
|
||||
if (color_type == PNG_COLOR_TYPE_GRAY ||
|
||||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
if (color_type == PNG_COLOR_TYPE_GRAY)
|
||||
png_set_expand_gray_1_2_4_to_8 (png);
|
||||
|
||||
if (png_get_valid (png, info, PNG_INFO_tRNS))
|
||||
@@ -193,10 +192,6 @@ gdk_load_png (GBytes *bytes,
|
||||
if (depth < 8)
|
||||
png_set_packing (png);
|
||||
|
||||
if (color_type == PNG_COLOR_TYPE_GRAY ||
|
||||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
png_set_gray_to_rgb (png);
|
||||
|
||||
if (interlace != PNG_INTERLACE_NONE)
|
||||
png_set_interlace_handling (png);
|
||||
|
||||
@@ -239,6 +234,26 @@ gdk_load_png (GBytes *bytes,
|
||||
format = GDK_MEMORY_R16G16B16;
|
||||
}
|
||||
break;
|
||||
case PNG_COLOR_TYPE_GRAY:
|
||||
if (depth == 8)
|
||||
{
|
||||
format = GDK_MEMORY_G8;
|
||||
}
|
||||
else if (depth == 16)
|
||||
{
|
||||
format = GDK_MEMORY_G16;
|
||||
}
|
||||
break;
|
||||
case PNG_COLOR_TYPE_GRAY_ALPHA:
|
||||
if (depth == 8)
|
||||
{
|
||||
format = GDK_MEMORY_G8A8;
|
||||
}
|
||||
else if (depth == 16)
|
||||
{
|
||||
format = GDK_MEMORY_G16A16;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
png_destroy_read_struct (&png, &info, NULL);
|
||||
g_set_error (error,
|
||||
@@ -349,6 +364,34 @@ gdk_save_png (GdkTexture *texture)
|
||||
depth = 16;
|
||||
break;
|
||||
|
||||
case GDK_MEMORY_G8:
|
||||
format = GDK_MEMORY_G8;
|
||||
png_format = PNG_COLOR_TYPE_GRAY;
|
||||
depth = 8;
|
||||
break;
|
||||
|
||||
case GDK_MEMORY_G8A8_PREMULTIPLIED:
|
||||
case GDK_MEMORY_G8A8:
|
||||
case GDK_MEMORY_A8:
|
||||
format = GDK_MEMORY_G8A8;
|
||||
png_format = PNG_COLOR_TYPE_GRAY_ALPHA;
|
||||
depth = 8;
|
||||
break;
|
||||
|
||||
case GDK_MEMORY_G16:
|
||||
format = GDK_MEMORY_G16;
|
||||
png_format = PNG_COLOR_TYPE_GRAY;
|
||||
depth = 16;
|
||||
break;
|
||||
|
||||
case GDK_MEMORY_G16A16_PREMULTIPLIED:
|
||||
case GDK_MEMORY_G16A16:
|
||||
case GDK_MEMORY_A16:
|
||||
format = GDK_MEMORY_G16A16;
|
||||
png_format = PNG_COLOR_TYPE_GRAY_ALPHA;
|
||||
depth = 16;
|
||||
break;
|
||||
|
||||
case GDK_MEMORY_N_FORMATS:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
|
||||
+32
-22
@@ -229,27 +229,36 @@ struct _FormatData {
|
||||
guint16 samples_per_pixel;
|
||||
guint16 sample_format;
|
||||
guint16 alpha_samples;
|
||||
guint16 photometric;
|
||||
};
|
||||
|
||||
static const FormatData format_data[] = {
|
||||
[GDK_MEMORY_B8G8R8A8_PREMULTIPLIED] = { GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA },
|
||||
[GDK_MEMORY_A8R8G8B8_PREMULTIPLIED] = { GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA },
|
||||
[GDK_MEMORY_R8G8B8A8_PREMULTIPLIED] = { GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA },
|
||||
[GDK_MEMORY_B8G8R8A8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA },
|
||||
[GDK_MEMORY_A8R8G8B8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA },
|
||||
[GDK_MEMORY_R8G8B8A8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA },
|
||||
[GDK_MEMORY_A8B8G8R8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA },
|
||||
[GDK_MEMORY_R8G8B8] = { GDK_MEMORY_R8G8B8, 8, 3, SAMPLEFORMAT_UINT, 0 },
|
||||
[GDK_MEMORY_B8G8R8] = { GDK_MEMORY_R8G8B8, 8, 3, SAMPLEFORMAT_UINT, 0 },
|
||||
[GDK_MEMORY_R16G16B16] = { GDK_MEMORY_R16G16B16, 16, 3, SAMPLEFORMAT_UINT, 0 },
|
||||
[GDK_MEMORY_R16G16B16A16_PREMULTIPLIED] = { GDK_MEMORY_R16G16B16A16_PREMULTIPLIED, 16, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA },
|
||||
[GDK_MEMORY_R16G16B16A16] = { GDK_MEMORY_R16G16B16A16, 16, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA },
|
||||
[GDK_MEMORY_R16G16B16_FLOAT] = { GDK_MEMORY_R16G16B16_FLOAT, 16, 3, SAMPLEFORMAT_IEEEFP, 0 },
|
||||
[GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED] = { GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED, 16, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_ASSOCALPHA },
|
||||
[GDK_MEMORY_R16G16B16A16_FLOAT] = { GDK_MEMORY_R16G16B16A16_FLOAT, 16, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_UNASSALPHA },
|
||||
[GDK_MEMORY_R32G32B32_FLOAT] = { GDK_MEMORY_R32G32B32_FLOAT, 32, 3, SAMPLEFORMAT_IEEEFP, 0 },
|
||||
[GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED] = { GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED, 32, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_ASSOCALPHA },
|
||||
[GDK_MEMORY_R32G32B32A32_FLOAT] = { GDK_MEMORY_R32G32B32A32_FLOAT, 32, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_UNASSALPHA },
|
||||
[GDK_MEMORY_B8G8R8A8_PREMULTIPLIED] = { GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_A8R8G8B8_PREMULTIPLIED] = { GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_R8G8B8A8_PREMULTIPLIED] = { GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_B8G8R8A8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_A8R8G8B8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_R8G8B8A8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_A8B8G8R8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_R8G8B8] = { GDK_MEMORY_R8G8B8, 8, 3, SAMPLEFORMAT_UINT, 0, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_B8G8R8] = { GDK_MEMORY_R8G8B8, 8, 3, SAMPLEFORMAT_UINT, 0, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_R16G16B16] = { GDK_MEMORY_R16G16B16, 16, 3, SAMPLEFORMAT_UINT, 0, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_R16G16B16A16_PREMULTIPLIED] = { GDK_MEMORY_R16G16B16A16_PREMULTIPLIED, 16, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_R16G16B16A16] = { GDK_MEMORY_R16G16B16A16, 16, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_R16G16B16_FLOAT] = { GDK_MEMORY_R16G16B16_FLOAT, 16, 3, SAMPLEFORMAT_IEEEFP, 0, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED] = { GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED, 16, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_R16G16B16A16_FLOAT] = { GDK_MEMORY_R16G16B16A16_FLOAT, 16, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_R32G32B32_FLOAT] = { GDK_MEMORY_R32G32B32_FLOAT, 32, 3, SAMPLEFORMAT_IEEEFP, 0, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED] = { GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED, 32, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_R32G32B32A32_FLOAT] = { GDK_MEMORY_R32G32B32A32_FLOAT, 32, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_G8A8_PREMULTIPLIED] = { GDK_MEMORY_G8A8_PREMULTIPLIED, 8, 2, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_MINISBLACK },
|
||||
[GDK_MEMORY_G8A8] = { GDK_MEMORY_G8A8, 8, 2, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_MINISBLACK },
|
||||
[GDK_MEMORY_G8] = { GDK_MEMORY_G8, 8, 1, SAMPLEFORMAT_UINT, 0, PHOTOMETRIC_MINISBLACK },
|
||||
[GDK_MEMORY_G16A16_PREMULTIPLIED] = { GDK_MEMORY_G16A16_PREMULTIPLIED, 16, 2, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_MINISBLACK },
|
||||
[GDK_MEMORY_G16A16] = { GDK_MEMORY_G16A16, 16, 2, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_MINISBLACK },
|
||||
[GDK_MEMORY_G16] = { GDK_MEMORY_G16, 16, 1, SAMPLEFORMAT_UINT, 0, PHOTOMETRIC_MINISBLACK },
|
||||
[GDK_MEMORY_A8] = { GDK_MEMORY_G8A8, 8, 2, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_MINISBLACK },
|
||||
[GDK_MEMORY_A16] = { GDK_MEMORY_G16A16, 16, 2, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_MINISBLACK },
|
||||
};
|
||||
|
||||
/* if this fails, somebody forgot to add formats above */
|
||||
@@ -289,7 +298,7 @@ gdk_save_tiff (GdkTexture *texture)
|
||||
if (fdata->alpha_samples)
|
||||
TIFFSetField (tif, TIFFTAG_EXTRASAMPLES, 1, &fdata->alpha_samples);
|
||||
|
||||
TIFFSetField (tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
|
||||
TIFFSetField (tif, TIFFTAG_PHOTOMETRIC, fdata->photometric);
|
||||
TIFFSetField (tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
|
||||
|
||||
gdk_texture_downloader_init (&downloader, texture);
|
||||
@@ -397,7 +406,7 @@ gdk_load_tiff (GBytes *input_bytes,
|
||||
TIFFGetFieldDefaulted (tif, TIFFTAG_IMAGEWIDTH, &width);
|
||||
TIFFGetFieldDefaulted (tif, TIFFTAG_IMAGELENGTH, &height);
|
||||
|
||||
if (samples_per_pixel == 4)
|
||||
if (samples_per_pixel == 2 || samples_per_pixel == 4)
|
||||
{
|
||||
guint16 extra;
|
||||
guint16 *extra_types;
|
||||
@@ -426,14 +435,15 @@ gdk_load_tiff (GBytes *input_bytes,
|
||||
if (format_data[format].sample_format == sample_format &&
|
||||
format_data[format].bits_per_sample == bits_per_sample &&
|
||||
format_data[format].samples_per_pixel == samples_per_pixel &&
|
||||
format_data[format].alpha_samples == alpha_samples)
|
||||
format_data[format].alpha_samples == alpha_samples &&
|
||||
format_data[format].photometric == photometric)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (format == G_N_ELEMENTS(format_data) ||
|
||||
photometric != PHOTOMETRIC_RGB ||
|
||||
(photometric != PHOTOMETRIC_RGB && photometric != PHOTOMETRIC_MINISBLACK) ||
|
||||
planarconfig != PLANARCONFIG_CONTIG ||
|
||||
TIFFIsTiled (tif) ||
|
||||
orientation != ORIENTATION_TOPLEFT)
|
||||
|
||||
@@ -344,14 +344,14 @@ create_pixel_format (GdkGLVersion *version,
|
||||
if (gdk_gl_version_get_major (version) >= 4)
|
||||
{
|
||||
attrs[1] = (CGLPixelFormatAttribute)kCGLOGLPVersion_GL4_Core;
|
||||
if (CGLChoosePixelFormat (attrs, &format, &n_format))
|
||||
if (CHECK (error, CGLChoosePixelFormat (attrs, &format, &n_format)))
|
||||
return g_steal_pointer (&format);
|
||||
}
|
||||
|
||||
if (gdk_gl_version_greater_equal (version, &GDK_GL_MIN_GL_VERSION))
|
||||
{
|
||||
attrs[1] = (CGLPixelFormatAttribute)kCGLOGLPVersion_GL3_Core;
|
||||
if (CGLChoosePixelFormat (attrs, &format, &n_format))
|
||||
if (CHECK (error, CGLChoosePixelFormat (attrs, &format, &n_format)))
|
||||
return g_steal_pointer (&format);
|
||||
}
|
||||
|
||||
@@ -396,7 +396,7 @@ gdk_macos_gl_context_real_realize (GdkGLContext *context,
|
||||
gdk_gl_context_get_matching_version (context,
|
||||
GDK_GL_API_GL,
|
||||
FALSE,
|
||||
&version);
|
||||
&min_version);
|
||||
|
||||
display = gdk_gl_context_get_display (context);
|
||||
shared = gdk_display_get_gl_context (display);
|
||||
|
||||
@@ -207,7 +207,7 @@ wl_cursor_create_from_xcursor_images(struct wl_cursor_theme *theme,
|
||||
{
|
||||
char *path;
|
||||
XcursorImages *images;
|
||||
struct cursor *cursor;
|
||||
struct wl_cursor *cursor;
|
||||
struct cursor_image *image;
|
||||
int i, nbytes;
|
||||
unsigned int load_size;
|
||||
@@ -240,17 +240,16 @@ wl_cursor_create_from_xcursor_images(struct wl_cursor_theme *theme,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cursor->cursor.images =
|
||||
malloc(images->nimage * sizeof cursor->cursor.images[0]);
|
||||
if (!cursor->cursor.images) {
|
||||
cursor->images =
|
||||
malloc(images->nimage * sizeof cursor->images[0]);
|
||||
if (!cursor->images) {
|
||||
free(cursor);
|
||||
xcursor_images_destroy (images);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cursor->cursor.name = strdup(name);
|
||||
cursor->cursor.size = load_size;
|
||||
cursor->total_delay = 0;
|
||||
cursor->name = strdup(name);
|
||||
cursor->size = load_size;
|
||||
|
||||
for (i = 0; i < images->nimage; i++) {
|
||||
image = malloc(sizeof *image);
|
||||
@@ -291,14 +290,13 @@ wl_cursor_create_from_xcursor_images(struct wl_cursor_theme *theme,
|
||||
}
|
||||
}
|
||||
}
|
||||
cursor->total_delay += image->image.delay;
|
||||
cursor->cursor.images[i] = (struct wl_cursor_image *) image;
|
||||
cursor->images[i] = (struct wl_cursor_image *) image;
|
||||
}
|
||||
cursor->cursor.image_count = i;
|
||||
cursor->image_count = i;
|
||||
|
||||
if (cursor->cursor.image_count == 0) {
|
||||
free(cursor->cursor.name);
|
||||
free(cursor->cursor.images);
|
||||
if (cursor->image_count == 0) {
|
||||
free(cursor->name);
|
||||
free(cursor->images);
|
||||
free(cursor);
|
||||
xcursor_images_destroy (images);
|
||||
return NULL;
|
||||
@@ -306,7 +304,7 @@ wl_cursor_create_from_xcursor_images(struct wl_cursor_theme *theme,
|
||||
|
||||
xcursor_images_destroy (images);
|
||||
|
||||
return &cursor->cursor;
|
||||
return cursor;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -698,7 +698,36 @@ 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
|
||||
@@ -708,22 +737,17 @@ 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,7 +98,6 @@ 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,10 +2143,13 @@ _gdk_wayland_seat_remove_tablet_pad (GdkWaylandSeat *seat,
|
||||
{
|
||||
seat->tablet_pads = g_list_remove (seat->tablet_pads, pad);
|
||||
|
||||
gdk_seat_device_removed (GDK_SEAT (seat), pad->device);
|
||||
_gdk_device_set_associated_device (pad->device, NULL);
|
||||
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);
|
||||
}
|
||||
|
||||
g_object_unref (pad->device);
|
||||
g_free (pad);
|
||||
}
|
||||
|
||||
@@ -3535,21 +3538,10 @@ static void
|
||||
tablet_pad_handle_done (void *data,
|
||||
struct zwp_tablet_pad_v2 *wp_tablet_pad)
|
||||
{
|
||||
GdkWaylandTabletPadData *pad = data;
|
||||
G_GNUC_UNUSED 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
|
||||
@@ -3606,9 +3598,44 @@ 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
|
||||
@@ -3624,10 +3651,7 @@ 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 = NULL;
|
||||
}
|
||||
pad->current_tablet->pads = g_list_remove (pad->current_tablet->pads, pad);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -3875,6 +3899,23 @@ 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)
|
||||
{
|
||||
@@ -4189,6 +4230,7 @@ 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;
|
||||
|
||||
@@ -1436,7 +1436,7 @@ register_clipboard_notification ()
|
||||
|
||||
wclass.lpszClassName = "GdkClipboardNotification";
|
||||
wclass.lpfnWndProc = _clipboard_window_procedure;
|
||||
wclass.hInstance = _gdk_dll_hinstance;
|
||||
wclass.hInstance = this_module ();
|
||||
wclass.cbWndExtra = sizeof (GdkWin32ClipboardThread *);
|
||||
|
||||
klass = RegisterClass (&wclass);
|
||||
@@ -1446,7 +1446,7 @@ register_clipboard_notification ()
|
||||
clipboard_thread_data->clipboard_window = CreateWindow (MAKEINTRESOURCE (klass),
|
||||
NULL, WS_POPUP,
|
||||
0, 0, 0, 0, NULL, NULL,
|
||||
_gdk_dll_hinstance, NULL);
|
||||
this_module (), NULL);
|
||||
|
||||
if (clipboard_thread_data->clipboard_window == NULL)
|
||||
goto failed;
|
||||
@@ -1471,7 +1471,7 @@ register_clipboard_notification ()
|
||||
|
||||
failed:
|
||||
g_critical ("Failed to install clipboard viewer");
|
||||
UnregisterClass (MAKEINTRESOURCE (klass), _gdk_dll_hinstance);
|
||||
UnregisterClass (MAKEINTRESOURCE (klass), this_module ());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -417,13 +417,12 @@ hcursor_from_x_cursor (int i,
|
||||
#undef SET_BIT
|
||||
#undef RESET_BIT
|
||||
|
||||
rv = CreateCursor (_gdk_app_hmodule, cursors[i].hotx, cursors[i].hoty,
|
||||
rv = CreateCursor (NULL, cursors[i].hotx, cursors[i].hoty,
|
||||
w, h, and_plane, xor_plane);
|
||||
}
|
||||
else
|
||||
{
|
||||
rv = CreateCursor (_gdk_app_hmodule, 0, 0,
|
||||
w, h, and_plane, xor_plane);
|
||||
rv = CreateCursor (NULL, 0, 0, w, h, and_plane, xor_plane);
|
||||
}
|
||||
|
||||
if (rv == NULL)
|
||||
@@ -466,7 +465,7 @@ win32_cursor_create_win32hcursor (GdkWin32Display *display,
|
||||
break;
|
||||
case GDK_WIN32_CURSOR_LOAD_FROM_RESOURCE_THIS:
|
||||
result = gdk_win32_hcursor_new (display,
|
||||
LoadImageA (_gdk_app_hmodule,
|
||||
LoadImageA (GetModuleHandle (NULL),
|
||||
(const char *) cursor->resource_name,
|
||||
IMAGE_CURSOR,
|
||||
cursor->width,
|
||||
@@ -476,7 +475,7 @@ win32_cursor_create_win32hcursor (GdkWin32Display *display,
|
||||
break;
|
||||
case GDK_WIN32_CURSOR_LOAD_FROM_RESOURCE_GTK:
|
||||
result = gdk_win32_hcursor_new (display,
|
||||
LoadImageA (_gdk_dll_hinstance,
|
||||
LoadImageA (this_module (),
|
||||
(const char *) cursor->resource_name,
|
||||
IMAGE_CURSOR,
|
||||
cursor->width,
|
||||
@@ -858,9 +857,7 @@ create_blank_win32hcursor (GdkWin32Display *display)
|
||||
xor_plane = g_malloc ((w/8) * h);
|
||||
memset (xor_plane, 0, (w/8) * h);
|
||||
|
||||
rv = CreateCursor (_gdk_app_hmodule, 0, 0,
|
||||
w, h, and_plane, xor_plane);
|
||||
|
||||
rv = CreateCursor (NULL, 0, 0, w, h, and_plane, xor_plane);
|
||||
if (rv == NULL)
|
||||
WIN32_API_FAILED ("CreateCursor");
|
||||
|
||||
@@ -871,6 +868,7 @@ static GdkWin32HCursor *
|
||||
gdk_win32hcursor_create_for_name (GdkWin32Display *display,
|
||||
const char *name)
|
||||
{
|
||||
const HINSTANCE hinstance = GetModuleHandle (NULL);
|
||||
GdkWin32HCursor *win32hcursor = NULL;
|
||||
|
||||
/* Blank cursor case */
|
||||
@@ -885,7 +883,7 @@ gdk_win32hcursor_create_for_name (GdkWin32Display *display,
|
||||
/* Allow to load named cursor resources linked into the executable.
|
||||
* Cursors obtained with LoadCursor() cannot be destroyed.
|
||||
*/
|
||||
return gdk_win32_hcursor_new (display, LoadCursor (_gdk_app_hmodule, name), FALSE);
|
||||
return gdk_win32_hcursor_new (display, LoadCursor (hinstance, name), FALSE);
|
||||
}
|
||||
|
||||
static HICON
|
||||
@@ -1452,27 +1450,6 @@ pixbuf_to_hicon (GdkPixbuf *pixbuf,
|
||||
return icon;
|
||||
}
|
||||
|
||||
HICON
|
||||
_gdk_win32_texture_to_hicon (GdkTexture *texture)
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
GdkPixbuf *pixbuf;
|
||||
int width, height;
|
||||
HICON icon;
|
||||
|
||||
surface = gdk_texture_download_surface (texture);
|
||||
width = cairo_image_surface_get_width (surface);
|
||||
height = cairo_image_surface_get_height (surface);
|
||||
|
||||
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, width, height);
|
||||
|
||||
icon = pixbuf_to_hicon (pixbuf, TRUE, 0, 0);
|
||||
|
||||
g_object_unref (pixbuf);
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_win32_display_get_win32hcursor:
|
||||
* @display: (type GdkWin32Display): a `GdkDisplay`
|
||||
|
||||
@@ -481,7 +481,7 @@ register_display_change_notification (GdkDisplay *display)
|
||||
|
||||
wclass.lpszClassName = "GdkDisplayChange";
|
||||
wclass.lpfnWndProc = display_change_window_procedure;
|
||||
wclass.hInstance = _gdk_app_hmodule;
|
||||
wclass.hInstance = this_module ();
|
||||
wclass.style = CS_OWNDC;
|
||||
|
||||
klass = RegisterClass (&wclass);
|
||||
@@ -490,10 +490,10 @@ register_display_change_notification (GdkDisplay *display)
|
||||
display_win32->hwnd = CreateWindow (MAKEINTRESOURCE (klass),
|
||||
NULL, WS_POPUP,
|
||||
0, 0, 0, 0, NULL, NULL,
|
||||
_gdk_app_hmodule, NULL);
|
||||
this_module (), NULL);
|
||||
if (!display_win32->hwnd)
|
||||
{
|
||||
UnregisterClass (MAKEINTRESOURCE (klass), _gdk_app_hmodule);
|
||||
UnregisterClass (MAKEINTRESOURCE (klass), this_module ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,8 +413,7 @@ set_up_low_level_keyboard_hook (void)
|
||||
|
||||
hook_handle = SetWindowsHookEx (WH_KEYBOARD_LL,
|
||||
(HOOKPROC) low_level_keyboard_proc,
|
||||
_gdk_dll_hinstance,
|
||||
0);
|
||||
this_module (), 0);
|
||||
|
||||
if (hook_handle != NULL)
|
||||
keyboard_hook = hook_handle;
|
||||
@@ -2735,6 +2734,10 @@ 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;
|
||||
}
|
||||
@@ -2745,6 +2748,10 @@ 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;
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ create_dummy_gl_window (void)
|
||||
|
||||
wclass.lpszClassName = "GdkGLDummyWindow";
|
||||
wclass.lpfnWndProc = DefWindowProc;
|
||||
wclass.hInstance = _gdk_app_hmodule;
|
||||
wclass.hInstance = this_module ();
|
||||
wclass.style = CS_OWNDC;
|
||||
|
||||
klass = RegisterClass (&wclass);
|
||||
@@ -270,10 +270,10 @@ create_dummy_gl_window (void)
|
||||
hwnd = CreateWindow (MAKEINTRESOURCE (klass),
|
||||
NULL, WS_POPUP,
|
||||
0, 0, 0, 0, NULL, NULL,
|
||||
_gdk_app_hmodule, NULL);
|
||||
this_module (), NULL);
|
||||
if (!hwnd)
|
||||
{
|
||||
UnregisterClass (MAKEINTRESOURCE (klass), _gdk_app_hmodule);
|
||||
UnregisterClass (MAKEINTRESOURCE (klass), this_module ());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,10 +30,6 @@
|
||||
GdkDisplay *_gdk_display = NULL;
|
||||
GdkDeviceManagerWin32 *_gdk_device_manager = NULL;
|
||||
|
||||
HDC _gdk_display_hdc;
|
||||
HINSTANCE _gdk_dll_hinstance;
|
||||
HINSTANCE _gdk_app_hmodule;
|
||||
|
||||
int _gdk_input_ignore_core;
|
||||
|
||||
HKL _gdk_input_locale;
|
||||
|
||||
@@ -1003,7 +1003,7 @@ winpointer_notif_window_create (void)
|
||||
wndclassex.cbSize = sizeof (wndclassex);
|
||||
wndclassex.lpszClassName = L"GdkWin32WinpointerNotificationsWindowClass";
|
||||
wndclassex.lpfnWndProc = winpointer_notifications_window_procedure;
|
||||
wndclassex.hInstance = _gdk_dll_hinstance;
|
||||
wndclassex.hInstance = this_module ();
|
||||
|
||||
if ((notifications_window_class = RegisterClassExW (&wndclassex)) == 0)
|
||||
{
|
||||
@@ -1018,7 +1018,7 @@ winpointer_notif_window_create (void)
|
||||
0, 0, 0, 0,
|
||||
HWND_MESSAGE,
|
||||
NULL,
|
||||
_gdk_dll_hinstance,
|
||||
this_module (),
|
||||
NULL)))
|
||||
{
|
||||
WIN32_API_FAILED ("CreateWindowExW");
|
||||
|
||||
@@ -576,19 +576,6 @@ gdk_mod_mask_to_mod_bits (GdkModifierType mod_mask)
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* keypad decimal mark depends on active keyboard layout
|
||||
* return current decimal mark as unicode character
|
||||
*/
|
||||
guint32
|
||||
_gdk_win32_keymap_get_decimal_mark (GdkWin32Keymap *keymap)
|
||||
{
|
||||
guint32 c = MapVirtualKeyW (VK_DECIMAL, MAPVK_VK_TO_CHAR);
|
||||
if (!c)
|
||||
c = (guint32) '.';
|
||||
return c;
|
||||
}
|
||||
|
||||
static void
|
||||
update_keymap (GdkWin32Keymap *keymap)
|
||||
{
|
||||
|
||||
+56
-190
@@ -45,9 +45,6 @@
|
||||
#include <wintab.h>
|
||||
#include <imm.h>
|
||||
|
||||
/* for CFSTR_SHELLIDLIST */
|
||||
#include <shlobj.h>
|
||||
|
||||
static gboolean gdk_synchronize = FALSE;
|
||||
|
||||
/* Whether GDK initialized COM */
|
||||
@@ -66,8 +63,6 @@ _gdk_win32_surfaceing_init (void)
|
||||
if (gdk_synchronize)
|
||||
GdiSetBatchLimit (1);
|
||||
|
||||
_gdk_app_hmodule = GetModuleHandle (NULL);
|
||||
_gdk_display_hdc = CreateDC ("DISPLAY", NULL, NULL, NULL);
|
||||
_gdk_input_locale = GetKeyboardLayout (0);
|
||||
_gdk_win32_keymap_set_active_layout (win32_keymap, _gdk_input_locale);
|
||||
|
||||
@@ -187,135 +182,6 @@ static_printf (const char *format,
|
||||
return retval;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_win32_print_paletteentries (const PALETTEENTRY *pep,
|
||||
const int nentries)
|
||||
{
|
||||
char buf[20];
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nentries; i++)
|
||||
g_print (" %3d %02x: %02x %02x %02x%s\n",
|
||||
i, i,
|
||||
pep[i].peRed, pep[i].peGreen, pep[i].peBlue,
|
||||
(pep[i].peFlags == 0 ? "" :
|
||||
(pep[i].peFlags == PC_EXPLICIT ? " PC_EXPLICIT" :
|
||||
(pep[i].peFlags == PC_NOCOLLAPSE ? " PC_NOCOLLAPSE" :
|
||||
(pep[i].peFlags == PC_RESERVED ? " PC_RESERVED" :
|
||||
(g_sprintf (buf, " %d", pep[i].peFlags), buf))))));
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_win32_print_system_palette (void)
|
||||
{
|
||||
PALETTEENTRY *pe;
|
||||
int k;
|
||||
|
||||
k = GetSystemPaletteEntries (_gdk_display_hdc, 0, 0, NULL);
|
||||
pe = g_new (PALETTEENTRY, k);
|
||||
k = GetSystemPaletteEntries (_gdk_display_hdc, 0, k, pe);
|
||||
|
||||
if (!k)
|
||||
g_print ("GetSystemPaletteEntries failed: %s\n",
|
||||
g_win32_error_message (GetLastError ()));
|
||||
else
|
||||
{
|
||||
g_print ("System palette: %d entries\n", k);
|
||||
_gdk_win32_print_paletteentries (pe, k);
|
||||
}
|
||||
g_free (pe);
|
||||
}
|
||||
|
||||
static int
|
||||
palette_size (HPALETTE hpal)
|
||||
{
|
||||
WORD npal = 0;
|
||||
|
||||
if (!GetObject (hpal, sizeof (npal), &npal))
|
||||
WIN32_GDI_FAILED ("GetObject (HPALETTE)");
|
||||
|
||||
return npal;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_win32_print_hpalette (HPALETTE hpal)
|
||||
{
|
||||
PALETTEENTRY *pe;
|
||||
int n, npal;
|
||||
|
||||
npal = palette_size (hpal);
|
||||
pe = g_new (PALETTEENTRY, npal);
|
||||
n = GetPaletteEntries (hpal, 0, npal, pe);
|
||||
|
||||
if (!n)
|
||||
g_print ("HPALETTE %p: GetPaletteEntries failed: %s\n",
|
||||
hpal, g_win32_error_message (GetLastError ()));
|
||||
else
|
||||
{
|
||||
g_print ("HPALETTE %p: %d (%d) entries\n", hpal, n, npal);
|
||||
_gdk_win32_print_paletteentries (pe, n);
|
||||
}
|
||||
g_free (pe);
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_win32_print_dc (HDC hdc)
|
||||
{
|
||||
HGDIOBJ obj;
|
||||
LOGBRUSH logbrush;
|
||||
EXTLOGPEN extlogpen;
|
||||
HRGN hrgn;
|
||||
RECT rect;
|
||||
int flag;
|
||||
|
||||
g_print ("%p:\n", hdc);
|
||||
obj = GetCurrentObject (hdc, OBJ_BRUSH);
|
||||
GetObject (obj, sizeof (LOGBRUSH), &logbrush);
|
||||
g_print ("brush: %s color=%06lx hatch=%p\n",
|
||||
_gdk_win32_lbstyle_to_string (logbrush.lbStyle),
|
||||
logbrush.lbColor, (gpointer) logbrush.lbHatch);
|
||||
obj = GetCurrentObject (hdc, OBJ_PEN);
|
||||
GetObject (obj, sizeof (EXTLOGPEN), &extlogpen);
|
||||
g_print ("pen: %s %s %s %s w=%d %s\n",
|
||||
_gdk_win32_pstype_to_string (extlogpen.elpPenStyle),
|
||||
_gdk_win32_psstyle_to_string (extlogpen.elpPenStyle),
|
||||
_gdk_win32_psendcap_to_string (extlogpen.elpPenStyle),
|
||||
_gdk_win32_psjoin_to_string (extlogpen.elpPenStyle),
|
||||
(int) extlogpen.elpWidth,
|
||||
_gdk_win32_lbstyle_to_string (extlogpen.elpBrushStyle));
|
||||
g_print ("rop2: %s textcolor=%06lx\n",
|
||||
_gdk_win32_rop2_to_string (GetROP2 (hdc)),
|
||||
GetTextColor (hdc));
|
||||
hrgn = CreateRectRgn (0, 0, 0, 0);
|
||||
if ((flag = GetClipRgn (hdc, hrgn)) == -1)
|
||||
WIN32_API_FAILED ("GetClipRgn");
|
||||
else if (flag == 0)
|
||||
g_print ("no clip region\n");
|
||||
else if (flag == 1)
|
||||
{
|
||||
GetRgnBox (hrgn, &rect);
|
||||
g_print ("clip region: %p bbox: %s\n",
|
||||
hrgn, _gdk_win32_rect_to_string (&rect));
|
||||
}
|
||||
DeleteObject (hrgn);
|
||||
}
|
||||
|
||||
char *
|
||||
_gdk_win32_drag_protocol_to_string (GdkDragProtocol protocol)
|
||||
{
|
||||
switch (protocol)
|
||||
{
|
||||
#define CASE(x) case GDK_DRAG_PROTO_##x: return #x
|
||||
CASE (NONE);
|
||||
CASE (WIN32_DROPFILES);
|
||||
CASE (OLE2);
|
||||
#undef CASE
|
||||
default: return static_printf ("illegal_%d", protocol);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
_gdk_win32_surface_state_to_string (GdkToplevelState state)
|
||||
{
|
||||
@@ -478,7 +344,7 @@ _gdk_win32_drag_action_to_string (GdkDragAction actions)
|
||||
return static_printf ("%s", buf);
|
||||
}
|
||||
|
||||
char *
|
||||
static char *
|
||||
_gdk_win32_rop2_to_string (int rop2)
|
||||
{
|
||||
switch (rop2)
|
||||
@@ -507,7 +373,7 @@ _gdk_win32_rop2_to_string (int rop2)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
static char *
|
||||
_gdk_win32_lbstyle_to_string (UINT brush_style)
|
||||
{
|
||||
switch (brush_style)
|
||||
@@ -526,7 +392,7 @@ _gdk_win32_lbstyle_to_string (UINT brush_style)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
static char *
|
||||
_gdk_win32_pstype_to_string (DWORD pen_style)
|
||||
{
|
||||
switch (pen_style & PS_TYPE_MASK)
|
||||
@@ -539,7 +405,7 @@ _gdk_win32_pstype_to_string (DWORD pen_style)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
static char *
|
||||
_gdk_win32_psstyle_to_string (DWORD pen_style)
|
||||
{
|
||||
switch (pen_style & PS_STYLE_MASK)
|
||||
@@ -561,7 +427,7 @@ _gdk_win32_psstyle_to_string (DWORD pen_style)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
static char *
|
||||
_gdk_win32_psendcap_to_string (DWORD pen_style)
|
||||
{
|
||||
switch (pen_style & PS_ENDCAP_MASK)
|
||||
@@ -577,7 +443,7 @@ _gdk_win32_psendcap_to_string (DWORD pen_style)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
static char *
|
||||
_gdk_win32_psjoin_to_string (DWORD pen_style)
|
||||
{
|
||||
switch (pen_style & PS_JOIN_MASK)
|
||||
@@ -593,6 +459,56 @@ _gdk_win32_psjoin_to_string (DWORD pen_style)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_win32_print_dc (HDC hdc)
|
||||
{
|
||||
HGDIOBJ obj;
|
||||
LOGBRUSH logbrush;
|
||||
EXTLOGPEN extlogpen;
|
||||
HRGN hrgn;
|
||||
RECT rect;
|
||||
int flag;
|
||||
|
||||
g_print ("%p:\n", hdc);
|
||||
|
||||
obj = GetCurrentObject (hdc, OBJ_BRUSH);
|
||||
GetObject (obj, sizeof (LOGBRUSH), &logbrush);
|
||||
|
||||
g_print ("brush: %s color=%06lx hatch=%p\n",
|
||||
_gdk_win32_lbstyle_to_string (logbrush.lbStyle),
|
||||
logbrush.lbColor, (gpointer) logbrush.lbHatch);
|
||||
|
||||
obj = GetCurrentObject (hdc, OBJ_PEN);
|
||||
GetObject (obj, sizeof (EXTLOGPEN), &extlogpen);
|
||||
|
||||
g_print ("pen: %s %s %s %s w=%d %s\n",
|
||||
_gdk_win32_pstype_to_string (extlogpen.elpPenStyle),
|
||||
_gdk_win32_psstyle_to_string (extlogpen.elpPenStyle),
|
||||
_gdk_win32_psendcap_to_string (extlogpen.elpPenStyle),
|
||||
_gdk_win32_psjoin_to_string (extlogpen.elpPenStyle),
|
||||
(int) extlogpen.elpWidth,
|
||||
_gdk_win32_lbstyle_to_string (extlogpen.elpBrushStyle));
|
||||
|
||||
g_print ("rop2: %s textcolor=%06lx\n",
|
||||
_gdk_win32_rop2_to_string (GetROP2 (hdc)),
|
||||
GetTextColor (hdc));
|
||||
|
||||
hrgn = CreateRectRgn (0, 0, 0, 0);
|
||||
|
||||
if ((flag = GetClipRgn (hdc, hrgn)) == -1)
|
||||
WIN32_API_FAILED ("GetClipRgn");
|
||||
else if (flag == 0)
|
||||
g_print ("no clip region\n");
|
||||
else if (flag == 1)
|
||||
{
|
||||
GetRgnBox (hrgn, &rect);
|
||||
g_print ("clip region: %p bbox: %s\n",
|
||||
hrgn, _gdk_win32_rect_to_string (&rect));
|
||||
}
|
||||
|
||||
DeleteObject (hrgn);
|
||||
}
|
||||
|
||||
char *
|
||||
_gdk_win32_message_to_string (UINT msg)
|
||||
{
|
||||
@@ -893,26 +809,6 @@ _gdk_win32_cf_to_string (UINT format)
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
_gdk_win32_data_to_string (const guchar *data,
|
||||
int nbytes)
|
||||
{
|
||||
GString *s = g_string_new ("");
|
||||
int i;
|
||||
char *retval;
|
||||
|
||||
for (i = 0; i < nbytes; i++)
|
||||
if (data[i] >=' ' && data[i] <= '~')
|
||||
g_string_append_printf (s, "%c ", data[i]);
|
||||
else
|
||||
g_string_append_printf (s, "%02X ", data[i]);
|
||||
|
||||
retval = static_printf ("%s", s->str);
|
||||
g_string_free (s, TRUE);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
char *
|
||||
_gdk_win32_rect_to_string (const RECT *rect)
|
||||
{
|
||||
@@ -921,34 +817,4 @@ _gdk_win32_rect_to_string (const RECT *rect)
|
||||
rect->left, rect->top);
|
||||
}
|
||||
|
||||
char *
|
||||
_gdk_win32_gdkrectangle_to_string (const GdkRectangle *rect)
|
||||
{
|
||||
return static_printf ("%dx%d@%+d%+d",
|
||||
rect->width, rect->height,
|
||||
rect->x, rect->y);
|
||||
}
|
||||
|
||||
char *
|
||||
_gdk_win32_cairo_region_to_string (const cairo_region_t *rgn)
|
||||
{
|
||||
cairo_rectangle_int_t extents;
|
||||
cairo_region_get_extents (rgn, &extents);
|
||||
return static_printf ("%dx%d@%+d%+d",
|
||||
extents.width, extents.height,
|
||||
extents.x, extents.y);
|
||||
}
|
||||
|
||||
char *
|
||||
_gdk_win32_surface_description (GdkSurface *d)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_SURFACE (d), NULL);
|
||||
|
||||
return static_printf ("%s:%p:%dx%d",
|
||||
G_OBJECT_TYPE_NAME (d),
|
||||
GDK_SURFACE_HWND (d),
|
||||
gdk_surface_get_width (GDK_SURFACE (d)),
|
||||
gdk_surface_get_height (GDK_SURFACE (d)));
|
||||
}
|
||||
|
||||
#endif /* G_ENABLE_DEBUG */
|
||||
|
||||
+10
-157
@@ -15,15 +15,10 @@
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
||||
* file for a list of people on the GTK+ Team. See the ChangeLog
|
||||
* files for a list of changes. These files are distributed with
|
||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gdk/gdkcursorprivate.h>
|
||||
#include <gdk/gdkdebugprivate.h>
|
||||
#include <gdk/win32/gdksurface-win32.h>
|
||||
@@ -32,10 +27,6 @@
|
||||
#include <gdk/win32/gdkwin32keys.h>
|
||||
#include <gdk/win32/gdkdevicemanager-win32.h>
|
||||
#include <gdk/win32/gdkclipdrop-win32.h>
|
||||
//#include <gdk/win32/gdkselection-win32.h>
|
||||
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
||||
/* Old debug macros */
|
||||
@@ -54,62 +45,6 @@
|
||||
|
||||
#endif
|
||||
|
||||
/* Make up for some minor w32api or MSVC6 header lossage */
|
||||
|
||||
#ifndef PS_JOIN_MASK
|
||||
#define PS_JOIN_MASK (PS_JOIN_BEVEL|PS_JOIN_MITER|PS_JOIN_ROUND)
|
||||
#endif
|
||||
|
||||
#ifndef FS_VIETNAMESE
|
||||
#define FS_VIETNAMESE 0x100
|
||||
#endif
|
||||
|
||||
#ifndef WM_GETOBJECT
|
||||
#define WM_GETOBJECT 0x3D
|
||||
#endif
|
||||
#ifndef WM_NCXBUTTONDOWN
|
||||
#define WM_NCXBUTTONDOWN 0xAB
|
||||
#endif
|
||||
#ifndef WM_NCXBUTTONUP
|
||||
#define WM_NCXBUTTONUP 0xAC
|
||||
#endif
|
||||
#ifndef WM_NCXBUTTONDBLCLK
|
||||
#define WM_NCXBUTTONDBLCLK 0xAD
|
||||
#endif
|
||||
#ifndef WM_CHANGEUISTATE
|
||||
#define WM_CHANGEUISTATE 0x127
|
||||
#endif
|
||||
#ifndef WM_UPDATEUISTATE
|
||||
#define WM_UPDATEUISTATE 0x128
|
||||
#endif
|
||||
#ifndef WM_QUERYUISTATE
|
||||
#define WM_QUERYUISTATE 0x129
|
||||
#endif
|
||||
#ifndef WM_XBUTTONDOWN
|
||||
#define WM_XBUTTONDOWN 0x20B
|
||||
#endif
|
||||
#ifndef WM_XBUTTONUP
|
||||
#define WM_XBUTTONUP 0x20C
|
||||
#endif
|
||||
#ifndef WM_XBUTTONDBLCLK
|
||||
#define WM_XBUTTONDBLCLK 0x20D
|
||||
#endif
|
||||
#ifndef WM_NCMOUSEHOVER
|
||||
#define WM_NCMOUSEHOVER 0x2A0
|
||||
#endif
|
||||
#ifndef WM_NCMOUSELEAVE
|
||||
#define WM_NCMOUSELEAVE 0x2A2
|
||||
#endif
|
||||
#ifndef WM_APPCOMMAND
|
||||
#define WM_APPCOMMAND 0x319
|
||||
#endif
|
||||
#ifndef WM_MOUSEHWHEEL
|
||||
#define WM_MOUSEHWHEEL 0x20E
|
||||
#endif
|
||||
#ifndef WM_DPICHANGED
|
||||
#define WM_DPICHANGED 0x02E0
|
||||
#endif
|
||||
|
||||
/* According to
|
||||
* http://blog.airesoft.co.uk/2009/11/wm_messages/
|
||||
* this is the actual internal name MS uses for this undocumented message.
|
||||
@@ -122,11 +57,6 @@
|
||||
#define WM_SYSMENU 0x313
|
||||
#endif
|
||||
|
||||
#ifndef CF_DIBV5
|
||||
#define CF_DIBV5 17
|
||||
#endif
|
||||
|
||||
|
||||
/* Define some combinations of GdkDebugFlags */
|
||||
#define GDK_DEBUG_EVENTS_OR_INPUT (GDK_DEBUG_EVENTS|GDK_DEBUG_INPUT)
|
||||
#define GDK_DEBUG_MISC_OR_EVENTS (GDK_DEBUG_MISC|GDK_DEBUG_EVENTS)
|
||||
@@ -140,22 +70,6 @@ GdkWin32Screen *GDK_SURFACE_SCREEN(GObject *win);
|
||||
*/
|
||||
#define SWP_NOZORDER_SPECIFIED HWND_TOP
|
||||
|
||||
typedef struct _GdkWin32SingleFont GdkWin32SingleFont;
|
||||
|
||||
struct _GdkWin32SingleFont
|
||||
{
|
||||
HFONT hfont;
|
||||
UINT charset;
|
||||
UINT codepage;
|
||||
FONTSIGNATURE fs;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
GDK_WIN32_PE_STATIC,
|
||||
GDK_WIN32_PE_AVAILABLE,
|
||||
GDK_WIN32_PE_INUSE
|
||||
} GdkWin32PalEntryState;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GDK_DRAG_PROTO_NONE = 0,
|
||||
@@ -163,51 +77,23 @@ typedef enum
|
||||
GDK_DRAG_PROTO_OLE2,
|
||||
} GdkDragProtocol;
|
||||
|
||||
GType _gdk_gc_win32_get_type (void);
|
||||
|
||||
gulong _gdk_win32_get_next_tick (gulong suggested_tick);
|
||||
|
||||
BOOL _gdk_win32_get_cursor_pos (LPPOINT lpPoint);
|
||||
|
||||
void _gdk_surface_init_position (GdkSurface *window);
|
||||
void _gdk_surface_move_resize_child (GdkSurface *window,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
gboolean _gdk_win32_surface_enable_transparency (GdkSurface *window);
|
||||
|
||||
|
||||
/* GdkSurfaceImpl methods */
|
||||
void _gdk_win32_surface_scroll (GdkSurface *window,
|
||||
int dx,
|
||||
int dy);
|
||||
void _gdk_win32_surface_move_region (GdkSurface *window,
|
||||
const cairo_region_t *region,
|
||||
int dx,
|
||||
int dy);
|
||||
|
||||
|
||||
void _gdk_win32_selection_init (void);
|
||||
void _gdk_win32_dnd_exit (void);
|
||||
|
||||
void gdk_win32_handle_table_insert (HANDLE *handle,
|
||||
gpointer data);
|
||||
void gdk_win32_handle_table_remove (HANDLE handle);
|
||||
|
||||
HRGN _gdk_win32_cairo_region_to_hrgn (const cairo_region_t *region,
|
||||
int x_origin,
|
||||
int y_origin);
|
||||
|
||||
cairo_region_t *_gdk_win32_hrgn_to_region (HRGN hrgn,
|
||||
guint scale);
|
||||
|
||||
void _gdk_win32_adjust_client_rect (GdkSurface *window,
|
||||
RECT *RECT);
|
||||
|
||||
void _gdk_selection_property_delete (GdkSurface *);
|
||||
|
||||
void _gdk_push_modal_window (GdkSurface *window);
|
||||
void _gdk_remove_modal_window (GdkSurface *window);
|
||||
GdkSurface *_gdk_modal_current (void);
|
||||
@@ -217,41 +103,22 @@ gboolean gdk_win32_ensure_com (void);
|
||||
gboolean gdk_win32_ensure_ole (void);
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
void _gdk_win32_print_paletteentries (const PALETTEENTRY *pep,
|
||||
const int nentries);
|
||||
void _gdk_win32_print_system_palette (void);
|
||||
void _gdk_win32_print_hpalette (HPALETTE hpal);
|
||||
void _gdk_win32_print_dc (HDC hdc);
|
||||
|
||||
char *_gdk_win32_drag_protocol_to_string (GdkDragProtocol protocol);
|
||||
char *_gdk_win32_surface_state_to_string (GdkToplevelState state);
|
||||
char *_gdk_win32_surface_style_to_string (LONG style);
|
||||
char *_gdk_win32_surface_exstyle_to_string (LONG style);
|
||||
char *_gdk_win32_surface_pos_bits_to_string (UINT flags);
|
||||
char *_gdk_win32_drag_action_to_string (GdkDragAction actions);
|
||||
char *_gdk_win32_surface_description (GdkSurface *d);
|
||||
|
||||
char *_gdk_win32_rop2_to_string (int rop2);
|
||||
char *_gdk_win32_lbstyle_to_string (UINT brush_style);
|
||||
char *_gdk_win32_pstype_to_string (DWORD pen_style);
|
||||
char *_gdk_win32_psstyle_to_string (DWORD pen_style);
|
||||
char *_gdk_win32_psendcap_to_string (DWORD pen_style);
|
||||
char *_gdk_win32_psjoin_to_string (DWORD pen_style);
|
||||
char *_gdk_win32_message_to_string (UINT msg);
|
||||
char *_gdk_win32_key_to_string (LONG lParam);
|
||||
char *_gdk_win32_cf_to_string (UINT format);
|
||||
char *_gdk_win32_data_to_string (const guchar*data,
|
||||
int nbytes);
|
||||
char *_gdk_win32_rect_to_string (const RECT *rect);
|
||||
|
||||
char *_gdk_win32_gdkrectangle_to_string (const GdkRectangle *rect);
|
||||
char *_gdk_win32_cairo_region_to_string (const cairo_region_t *box);
|
||||
|
||||
void _gdk_win32_print_event (GdkEvent *event);
|
||||
|
||||
#endif
|
||||
|
||||
char *_gdk_win32_last_error_string (void);
|
||||
void _gdk_win32_api_failed (const char *where,
|
||||
const char *api);
|
||||
void _gdk_other_api_failed (const char *where,
|
||||
@@ -284,10 +151,6 @@ extern GdkDisplay *_gdk_display;
|
||||
|
||||
extern GdkDeviceManagerWin32 *_gdk_device_manager;
|
||||
|
||||
extern HDC _gdk_display_hdc;
|
||||
extern HINSTANCE _gdk_dll_hinstance;
|
||||
extern HINSTANCE _gdk_app_hmodule;
|
||||
|
||||
extern int _gdk_input_ignore_core;
|
||||
|
||||
/* These are thread specific, but GDK/win32 works OK only when invoked
|
||||
@@ -304,8 +167,6 @@ extern GdkWin32Clipdrop *_win32_clipdrop;
|
||||
/* Used to identify the main thread */
|
||||
extern GThread *_win32_main_thread;
|
||||
|
||||
void _gdk_win32_dnd_do_dragdrop (void);
|
||||
|
||||
typedef enum {
|
||||
GDK_WIN32_MODAL_OP_NONE = 0x0,
|
||||
GDK_WIN32_MODAL_OP_SIZE = 0x1 << 0,
|
||||
@@ -324,16 +185,9 @@ extern HWND _modal_move_resize_window;
|
||||
void _gdk_win32_begin_modal_call (GdkWin32ModalOpKind kind);
|
||||
void _gdk_win32_end_modal_call (GdkWin32ModalOpKind kind);
|
||||
|
||||
/* Convert a pixbuf to an HICON (or HCURSOR). Supports alpha under
|
||||
* Windows XP, thresholds alpha otherwise.
|
||||
*/
|
||||
HICON _gdk_win32_texture_to_hicon (GdkTexture *texture);
|
||||
|
||||
void _gdk_win32_display_init_cursors (GdkWin32Display *display);
|
||||
void _gdk_win32_display_finalize_cursors (GdkWin32Display *display);
|
||||
void _gdk_win32_display_update_cursors (GdkWin32Display *display);
|
||||
GdkCursor *_gdk_win32_display_get_cursor_for_name (GdkDisplay *display, const char * cursor_name);
|
||||
GdkCursor *gdk_win32_display_cursor_from_hcursor (GdkDisplay *display, HCURSOR hcursor);
|
||||
|
||||
typedef struct _Win32CursorTheme Win32CursorTheme;
|
||||
|
||||
@@ -367,9 +221,6 @@ Win32Cursor * win32_cursor_theme_get_cursor (Win32CursorTheme *theme,
|
||||
void win32_cursor_theme_destroy (Win32CursorTheme *theme);
|
||||
Win32CursorTheme *_gdk_win32_display_get_cursor_theme (GdkWin32Display *win32_display);
|
||||
|
||||
/* GdkDisplay member functions */
|
||||
GList *_gdk_win32_display_list_devices (GdkDisplay *dpy);
|
||||
|
||||
gboolean _gdk_win32_display_has_pending (GdkDisplay *display);
|
||||
void _gdk_win32_display_queue_events (GdkDisplay *display);
|
||||
|
||||
@@ -395,16 +246,11 @@ GdkDrag *_gdk_win32_surface_drag_begin (GdkSurface *window,
|
||||
/* Stray GdkWin32Screen members */
|
||||
gboolean _gdk_win32_get_setting (const char *name, GValue *value);
|
||||
void _gdk_win32_screen_on_displaychange_event (GdkWin32Screen *screen);
|
||||
GdkSurface *gdk_win32_screen_get_root_window (GdkWin32Screen *screen);
|
||||
GdkSurface *gdk_win32_display_get_root_window (GdkDisplay *display);
|
||||
|
||||
/* Distributed display manager implementation */
|
||||
GdkDisplay *_gdk_win32_display_open (const char *display_name);
|
||||
void _gdk_win32_append_event (GdkEvent *event);
|
||||
|
||||
|
||||
guint32 _gdk_win32_keymap_get_decimal_mark (GdkWin32Keymap *keymap);
|
||||
|
||||
void _gdk_win32_surface_handle_aerosnap (GdkSurface *window,
|
||||
GdkWin32AeroSnapCombo combo);
|
||||
|
||||
@@ -449,8 +295,15 @@ gboolean _gdk_win32_check_processor (GdkWin32ProcessorCheckType check_type);
|
||||
GdkPixbuf *gdk_win32_icon_to_pixbuf_libgtk_only (HICON hicon,
|
||||
double *x_hot,
|
||||
double *y_hot);
|
||||
HICON gdk_win32_pixbuf_to_hicon_libgtk_only (GdkPixbuf *pixbuf);
|
||||
void gdk_win32_set_modal_dialog_libgtk_only (HWND window);
|
||||
|
||||
gpointer gdk_win32_handle_table_lookup_ (HWND handle);
|
||||
|
||||
extern IMAGE_DOS_HEADER __ImageBase;
|
||||
|
||||
static inline HMODULE
|
||||
this_module (void)
|
||||
{
|
||||
return (HMODULE) &__ImageBase;
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,15 @@ _gdk_win32_get_setting (const char *name,
|
||||
}
|
||||
else if (strcmp ("gtk-font-name", name) == 0)
|
||||
{
|
||||
char *font_name = _get_system_font_name (_gdk_display_hdc);
|
||||
char *font_name = NULL;
|
||||
HDC hdc = NULL;
|
||||
|
||||
if ((hdc = GetDC (HWND_DESKTOP)) != NULL)
|
||||
{
|
||||
font_name = _get_system_font_name (hdc);
|
||||
ReleaseDC (HWND_DESKTOP, hdc);
|
||||
hdc = NULL;
|
||||
}
|
||||
|
||||
if (font_name)
|
||||
{
|
||||
|
||||
@@ -339,7 +339,7 @@ RegisterGdkClass (GType wtype)
|
||||
wcl.lpfnWndProc = _gdk_win32_surface_procedure;
|
||||
wcl.cbClsExtra = 0;
|
||||
wcl.cbWndExtra = 0;
|
||||
wcl.hInstance = _gdk_dll_hinstance;
|
||||
wcl.hInstance = this_module ();
|
||||
wcl.hIcon = 0;
|
||||
wcl.hIconSm = 0;
|
||||
|
||||
@@ -356,7 +356,7 @@ RegisterGdkClass (GType wtype)
|
||||
if (0 == hAppIcon && 0 == hAppIconSm)
|
||||
{
|
||||
// fallback : load icon from GTK DLL
|
||||
if (0 != GetModuleFileName (_gdk_dll_hinstance, sLoc, MAX_PATH))
|
||||
if (0 != GetModuleFileName (this_module (), sLoc, MAX_PATH))
|
||||
{
|
||||
ExtractIconEx (sLoc, 0, &hAppIcon, &hAppIconSm, 1);
|
||||
}
|
||||
@@ -493,7 +493,7 @@ gdk_win32_surface_constructed (GObject *object)
|
||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
owner,
|
||||
NULL,
|
||||
_gdk_dll_hinstance,
|
||||
this_module (),
|
||||
surface);
|
||||
if (impl->handle == NULL)
|
||||
{
|
||||
@@ -725,11 +725,7 @@ show_window_internal (GdkSurface *window,
|
||||
|
||||
if (center)
|
||||
{
|
||||
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);
|
||||
GetWindowRect (GDK_SURFACE_HWND (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;
|
||||
@@ -2404,7 +2400,7 @@ RegisterGdkDumbClass ()
|
||||
wcl.lpfnWndProc = DefWindowProcW;
|
||||
wcl.cbClsExtra = 0;
|
||||
wcl.cbWndExtra = 0;
|
||||
wcl.hInstance = _gdk_dll_hinstance;
|
||||
wcl.hInstance = this_module ();
|
||||
wcl.hIcon = 0;
|
||||
wcl.hIconSm = 0;
|
||||
wcl.lpszMenuName = NULL;
|
||||
@@ -2445,7 +2441,7 @@ ensure_snap_indicator_exists (GdkW32DragMoveResizeContext *context)
|
||||
0, 0,
|
||||
NULL,
|
||||
NULL,
|
||||
_gdk_dll_hinstance,
|
||||
this_module (),
|
||||
NULL);
|
||||
|
||||
context->shape_indicator = handle;
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
#include "gdkprivate-win32.h"
|
||||
#include "gdkwin32misc.h"
|
||||
|
||||
extern HINSTANCE _gdk_dll_hinstance;
|
||||
|
||||
G_DEFINE_TYPE (GdkWin32VulkanContext, gdk_win32_vulkan_context, GDK_TYPE_VULKAN_CONTEXT)
|
||||
|
||||
static VkResult
|
||||
@@ -47,7 +45,7 @@ gdk_win32_vulkan_context_create_surface (GdkVulkanContext *context,
|
||||
info.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
|
||||
info.pNext = NULL;
|
||||
info.flags = 0;
|
||||
info.hinstance = _gdk_dll_hinstance;
|
||||
info.hinstance = this_module ();
|
||||
info.hwnd = GDK_SURFACE_HWND (window);
|
||||
|
||||
/* This is necessary so that Vulkan sees the Window.
|
||||
|
||||
+1
-204
@@ -134,35 +134,6 @@ struct _GdkX11DragClass
|
||||
GdkDragClass parent_class;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int keysym;
|
||||
int modifiers;
|
||||
} GrabKey;
|
||||
|
||||
static GrabKey grab_keys[] = {
|
||||
{ XK_Escape, 0 },
|
||||
{ XK_space, 0 },
|
||||
{ XK_KP_Space, 0 },
|
||||
{ XK_Return, 0 },
|
||||
{ XK_KP_Enter, 0 },
|
||||
{ XK_Up, 0 },
|
||||
{ XK_Up, Mod1Mask },
|
||||
{ XK_Down, 0 },
|
||||
{ XK_Down, Mod1Mask },
|
||||
{ XK_Left, 0 },
|
||||
{ XK_Left, Mod1Mask },
|
||||
{ XK_Right, 0 },
|
||||
{ XK_Right, Mod1Mask },
|
||||
{ XK_KP_Up, 0 },
|
||||
{ XK_KP_Up, Mod1Mask },
|
||||
{ XK_KP_Down, 0 },
|
||||
{ XK_KP_Down, Mod1Mask },
|
||||
{ XK_KP_Left, 0 },
|
||||
{ XK_KP_Left, Mod1Mask },
|
||||
{ XK_KP_Right, 0 },
|
||||
{ XK_KP_Right, Mod1Mask }
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
|
||||
static GdkSurfaceCache *gdk_surface_cache_ref (GdkSurfaceCache *cache);
|
||||
@@ -1861,20 +1832,15 @@ drag_grab (GdkDrag *drag)
|
||||
{
|
||||
GdkX11Drag *x11_drag = GDK_X11_DRAG (drag);
|
||||
GdkSeatCapabilities capabilities;
|
||||
GdkDisplay *display;
|
||||
Window root;
|
||||
GdkSeat *seat;
|
||||
int keycode, i;
|
||||
GdkCursor *cursor;
|
||||
|
||||
if (!x11_drag->ipc_surface)
|
||||
return FALSE;
|
||||
|
||||
display = gdk_drag_get_display (drag);
|
||||
root = GDK_DISPLAY_XROOTWIN (display);
|
||||
seat = gdk_device_get_seat (gdk_drag_get_device (drag));
|
||||
|
||||
capabilities = GDK_SEAT_CAPABILITY_ALL_POINTING | GDK_SEAT_CAPABILITY_KEYBOARD;
|
||||
capabilities = GDK_SEAT_CAPABILITY_ALL_POINTING;
|
||||
|
||||
cursor = gdk_drag_get_cursor (drag, x11_drag->current_action);
|
||||
g_set_object (&x11_drag->cursor, cursor);
|
||||
@@ -1886,46 +1852,6 @@ drag_grab (GdkDrag *drag)
|
||||
|
||||
g_set_object (&x11_drag->grab_seat, seat);
|
||||
|
||||
gdk_x11_display_error_trap_push (display);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (grab_keys); ++i)
|
||||
{
|
||||
int deviceid = gdk_x11_device_get_id (gdk_seat_get_keyboard (seat));
|
||||
unsigned char mask[XIMaskLen(XI_LASTEVENT)];
|
||||
XIGrabModifiers mods;
|
||||
XIEventMask evmask;
|
||||
int num_mods;
|
||||
|
||||
keycode = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY (display),
|
||||
grab_keys[i].keysym);
|
||||
if (keycode == NoSymbol)
|
||||
continue;
|
||||
|
||||
memset (mask, 0, sizeof (mask));
|
||||
XISetMask (mask, XI_KeyPress);
|
||||
XISetMask (mask, XI_KeyRelease);
|
||||
|
||||
evmask.deviceid = deviceid;
|
||||
evmask.mask_len = sizeof (mask);
|
||||
evmask.mask = mask;
|
||||
|
||||
num_mods = 1;
|
||||
mods.modifiers = grab_keys[i].modifiers;
|
||||
|
||||
XIGrabKeycode (GDK_DISPLAY_XDISPLAY (display),
|
||||
deviceid,
|
||||
keycode,
|
||||
root,
|
||||
GrabModeAsync,
|
||||
GrabModeAsync,
|
||||
False,
|
||||
&evmask,
|
||||
num_mods,
|
||||
&mods);
|
||||
}
|
||||
|
||||
gdk_x11_display_error_trap_pop_ignored (display);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1933,41 +1859,13 @@ static void
|
||||
drag_ungrab (GdkDrag *drag)
|
||||
{
|
||||
GdkX11Drag *x11_drag = GDK_X11_DRAG (drag);
|
||||
GdkDisplay *display;
|
||||
GdkDevice *keyboard;
|
||||
Window root;
|
||||
int keycode, i;
|
||||
|
||||
if (!x11_drag->grab_seat)
|
||||
return;
|
||||
|
||||
gdk_seat_ungrab (x11_drag->grab_seat);
|
||||
|
||||
display = gdk_drag_get_display (drag);
|
||||
keyboard = gdk_seat_get_keyboard (x11_drag->grab_seat);
|
||||
root = GDK_DISPLAY_XROOTWIN (display);
|
||||
g_clear_object (&x11_drag->grab_seat);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (grab_keys); ++i)
|
||||
{
|
||||
XIGrabModifiers mods;
|
||||
int num_mods;
|
||||
|
||||
keycode = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY (display),
|
||||
grab_keys[i].keysym);
|
||||
if (keycode == NoSymbol)
|
||||
continue;
|
||||
|
||||
num_mods = 1;
|
||||
mods.modifiers = grab_keys[i].modifiers;
|
||||
|
||||
XIUngrabKeycode (GDK_DISPLAY_XDISPLAY (display),
|
||||
gdk_x11_device_get_id (keyboard),
|
||||
keycode,
|
||||
root,
|
||||
num_mods,
|
||||
&mods);
|
||||
}
|
||||
}
|
||||
|
||||
GdkDrag *
|
||||
@@ -2191,103 +2089,6 @@ gdk_dnd_handle_motion_event (GdkDrag *drag,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_dnd_handle_key_event (GdkDrag *drag,
|
||||
GdkEvent *event)
|
||||
{
|
||||
GdkX11Drag *x11_drag = GDK_X11_DRAG (drag);
|
||||
GdkModifierType state;
|
||||
GdkDevice *pointer;
|
||||
GdkSeat *seat;
|
||||
int dx, dy;
|
||||
|
||||
dx = dy = 0;
|
||||
state = gdk_event_get_modifier_state (event);
|
||||
seat = gdk_event_get_seat (event);
|
||||
pointer = gdk_seat_get_pointer (seat);
|
||||
|
||||
if (event->event_type == GDK_KEY_PRESS)
|
||||
{
|
||||
guint keyval = gdk_key_event_get_keyval (event);
|
||||
|
||||
switch (keyval)
|
||||
{
|
||||
case GDK_KEY_Escape:
|
||||
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_USER_CANCELLED);
|
||||
return TRUE;
|
||||
|
||||
case GDK_KEY_space:
|
||||
case GDK_KEY_Return:
|
||||
case GDK_KEY_ISO_Enter:
|
||||
case GDK_KEY_KP_Enter:
|
||||
case GDK_KEY_KP_Space:
|
||||
if ((gdk_drag_get_selected_action (drag) != 0) &&
|
||||
(x11_drag->proxy_xid != None))
|
||||
{
|
||||
g_signal_emit_by_name (drag, "drop-performed");
|
||||
}
|
||||
else
|
||||
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_NO_TARGET);
|
||||
|
||||
return TRUE;
|
||||
|
||||
case GDK_KEY_Up:
|
||||
case GDK_KEY_KP_Up:
|
||||
dy = (state & GDK_ALT_MASK) ? -BIG_STEP : -SMALL_STEP;
|
||||
break;
|
||||
|
||||
case GDK_KEY_Down:
|
||||
case GDK_KEY_KP_Down:
|
||||
dy = (state & GDK_ALT_MASK) ? BIG_STEP : SMALL_STEP;
|
||||
break;
|
||||
|
||||
case GDK_KEY_Left:
|
||||
case GDK_KEY_KP_Left:
|
||||
dx = (state & GDK_ALT_MASK) ? -BIG_STEP : -SMALL_STEP;
|
||||
break;
|
||||
|
||||
case GDK_KEY_Right:
|
||||
case GDK_KEY_KP_Right:
|
||||
dx = (state & GDK_ALT_MASK) ? BIG_STEP : SMALL_STEP;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* The state is not yet updated in the event, so we need
|
||||
* to query it here. We could use XGetModifierMapping, but
|
||||
* that would be overkill.
|
||||
*/
|
||||
gdk_x11_device_xi2_query_state (pointer, NULL, NULL, NULL, &state);
|
||||
|
||||
if (dx != 0 || dy != 0)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
Display *xdisplay;
|
||||
GdkX11Screen *screen;
|
||||
Window dest;
|
||||
|
||||
x11_drag->last_x += dx;
|
||||
x11_drag->last_y += dy;
|
||||
|
||||
display = gdk_event_get_display ((GdkEvent *)event);
|
||||
xdisplay = GDK_DISPLAY_XDISPLAY (display);
|
||||
screen = GDK_X11_DISPLAY (display)->screen;
|
||||
dest = GDK_SCREEN_XROOTWIN (screen);
|
||||
|
||||
XWarpPointer (xdisplay, None, dest, 0, 0, 0, 0,
|
||||
round (x11_drag->last_x * screen->surface_scale),
|
||||
round (x11_drag->last_y * screen->surface_scale));
|
||||
}
|
||||
|
||||
gdk_drag_update (drag, x11_drag->last_x, x11_drag->last_y, state,
|
||||
gdk_event_get_time (event));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_dnd_handle_grab_broken_event (GdkDrag *drag,
|
||||
GdkEvent *event)
|
||||
@@ -2354,10 +2155,6 @@ gdk_x11_drag_handle_event (GdkDrag *drag,
|
||||
case GDK_BUTTON_RELEASE:
|
||||
return gdk_dnd_handle_button_event (drag, event);
|
||||
|
||||
case GDK_KEY_PRESS:
|
||||
case GDK_KEY_RELEASE:
|
||||
return gdk_dnd_handle_key_event (drag, event);
|
||||
|
||||
case GDK_GRAB_BROKEN:
|
||||
return gdk_dnd_handle_grab_broken_event (drag, event);
|
||||
|
||||
|
||||
+31
-22
@@ -543,8 +543,6 @@ gdk_x11_context_create_glx_context (GdkGLContext *context,
|
||||
if (share != NULL)
|
||||
share_glx = GDK_X11_GL_CONTEXT_GLX (share);
|
||||
|
||||
gdk_x11_display_error_trap_push (display);
|
||||
|
||||
supported_versions = gdk_gl_versions_get_for_api (api);
|
||||
for (j = 0; gdk_gl_version_greater_equal (&supported_versions[j], &version); j++)
|
||||
{
|
||||
@@ -568,19 +566,13 @@ gdk_x11_context_create_glx_context (GdkGLContext *context,
|
||||
True,
|
||||
context_attribs);
|
||||
|
||||
if (ctx)
|
||||
if (ctx != NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
if (ctx == NULL)
|
||||
{
|
||||
gdk_x11_display_error_trap_pop_ignored (display);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (gdk_x11_display_error_trap_pop (display))
|
||||
{
|
||||
glXDestroyContext (dpy, ctx);
|
||||
GDK_DISPLAY_DEBUG (display, OPENGL, "Failed to create a GLX context");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -664,25 +656,42 @@ 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)
|
||||
{
|
||||
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;
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
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;
|
||||
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);
|
||||
}
|
||||
|
||||
g_set_error_literal (error, GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||
_("Unable to create a GL context"));
|
||||
return 0;
|
||||
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;
|
||||
}
|
||||
|
||||
#undef N_GLX_ATTRS
|
||||
|
||||
+19
-3
@@ -685,8 +685,13 @@ init_randr13 (GdkX11Screen *x11_screen)
|
||||
for (i = 0; i < resources->noutput; ++i)
|
||||
{
|
||||
RROutput output = resources->outputs[i];
|
||||
XRROutputInfo *output_info =
|
||||
XRRGetOutputInfo (x11_screen->xdisplay, resources, output);
|
||||
XRROutputInfo *output_info;
|
||||
|
||||
gdk_x11_display_error_trap_push (display);
|
||||
output_info = XRRGetOutputInfo (x11_screen->xdisplay, resources, output);
|
||||
|
||||
if (gdk_x11_display_error_trap_pop (display))
|
||||
continue;
|
||||
|
||||
if (output_info->connection == RR_Disconnected)
|
||||
{
|
||||
@@ -697,13 +702,22 @@ init_randr13 (GdkX11Screen *x11_screen)
|
||||
if (output_info->crtc)
|
||||
{
|
||||
GdkX11Monitor *monitor;
|
||||
XRRCrtcInfo *crtc = XRRGetCrtcInfo (x11_screen->xdisplay, resources, output_info->crtc);
|
||||
XRRCrtcInfo *crtc;
|
||||
char *name;
|
||||
GdkRectangle geometry;
|
||||
GdkRectangle newgeo;
|
||||
int j;
|
||||
int refresh_rate = 0;
|
||||
|
||||
gdk_x11_display_error_trap_push (display);
|
||||
crtc = XRRGetCrtcInfo (x11_screen->xdisplay, resources, output_info->crtc);
|
||||
|
||||
if (gdk_x11_display_error_trap_pop (display))
|
||||
{
|
||||
XRRFreeOutputInfo (output_info);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (j = 0; j < resources->nmode; j++)
|
||||
{
|
||||
XRRModeInfo *xmode = &resources->modes[j];
|
||||
@@ -775,8 +789,10 @@ init_randr13 (GdkX11Screen *x11_screen)
|
||||
}
|
||||
|
||||
x11_display->primary_monitor = 0;
|
||||
gdk_x11_display_error_trap_push (display);
|
||||
primary_output = XRRGetOutputPrimary (x11_screen->xdisplay,
|
||||
x11_screen->xroot_window);
|
||||
gdk_x11_display_error_trap_pop_ignored (display);
|
||||
|
||||
for (i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (x11_display->monitors)); i++)
|
||||
{
|
||||
|
||||
@@ -89,7 +89,7 @@ gdk_x11_selection_input_stream_fill_buffer (GdkX11SelectionInputStream *stream,
|
||||
if (size == 0)
|
||||
{
|
||||
/* EOF marker, put it back */
|
||||
g_async_queue_push_front_unlocked (priv->chunks, bytes);
|
||||
g_async_queue_push_front_unlocked (priv->chunks, g_steal_pointer (&bytes));
|
||||
break;
|
||||
}
|
||||
else if (size > count)
|
||||
@@ -107,7 +107,7 @@ gdk_x11_selection_input_stream_fill_buffer (GdkX11SelectionInputStream *stream,
|
||||
memcpy (buffer, g_bytes_get_data (bytes, NULL), size);
|
||||
}
|
||||
|
||||
g_bytes_unref (bytes);
|
||||
g_bytes_unref (g_steal_pointer (&bytes));
|
||||
result += size;
|
||||
if (buffer)
|
||||
buffer += size;
|
||||
@@ -165,9 +165,7 @@ gdk_x11_selection_input_stream_complete (GdkX11SelectionInputStream *stream)
|
||||
GDK_X11_DISPLAY (priv->display)->streams = g_slist_remove (GDK_X11_DISPLAY (priv->display)->streams, stream);
|
||||
g_signal_handlers_disconnect_by_func (priv->display,
|
||||
gdk_x11_selection_input_stream_xevent,
|
||||
stream);
|
||||
|
||||
g_object_unref (stream);
|
||||
g_steal_pointer (&stream));
|
||||
}
|
||||
|
||||
static gssize
|
||||
@@ -416,7 +414,7 @@ gdk_x11_selection_input_stream_xevent (GdkDisplay *display,
|
||||
"%s:%s: got PropertyNotify erroring out of INCR",
|
||||
priv->selection, priv->target);
|
||||
/* error, should we signal one? */
|
||||
gdk_x11_selection_input_stream_complete (stream);
|
||||
g_clear_pointer (&stream, gdk_x11_selection_input_stream_complete);
|
||||
}
|
||||
else if (g_bytes_get_size (bytes) == 0 || type == None)
|
||||
{
|
||||
@@ -424,7 +422,7 @@ gdk_x11_selection_input_stream_xevent (GdkDisplay *display,
|
||||
"%s:%s: got PropertyNotify ending INCR",
|
||||
priv->selection, priv->target);
|
||||
g_bytes_unref (bytes);
|
||||
gdk_x11_selection_input_stream_complete (stream);
|
||||
g_clear_pointer (&stream, gdk_x11_selection_input_stream_complete);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -467,7 +465,7 @@ gdk_x11_selection_input_stream_xevent (GdkDisplay *display,
|
||||
G_IO_ERROR,
|
||||
G_IO_ERROR_NOT_FOUND,
|
||||
_("Format %s not supported"), priv->target);
|
||||
gdk_x11_selection_input_stream_complete (stream);
|
||||
g_clear_pointer (&stream, gdk_x11_selection_input_stream_complete);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -478,7 +476,7 @@ gdk_x11_selection_input_stream_xevent (GdkDisplay *display,
|
||||
|
||||
if (bytes == NULL)
|
||||
{
|
||||
gdk_x11_selection_input_stream_complete (stream);
|
||||
g_clear_pointer (&stream, gdk_x11_selection_input_stream_complete);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -500,7 +498,7 @@ gdk_x11_selection_input_stream_xevent (GdkDisplay *display,
|
||||
g_bytes_get_size (bytes));
|
||||
g_async_queue_push (priv->chunks, bytes);
|
||||
|
||||
gdk_x11_selection_input_stream_complete (stream);
|
||||
g_clear_pointer (&stream, gdk_x11_selection_input_stream_complete);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -541,7 +539,10 @@ gdk_x11_selection_input_stream_new_async (GdkDisplay *display,
|
||||
priv->property = g_strdup_printf ("GDK_SELECTION_%p", stream);
|
||||
priv->xproperty = gdk_x11_get_xatom_by_name_for_display (display, priv->property);
|
||||
|
||||
g_signal_connect (display, "xevent", G_CALLBACK (gdk_x11_selection_input_stream_xevent), stream);
|
||||
g_signal_connect_data (display, "xevent",
|
||||
G_CALLBACK (gdk_x11_selection_input_stream_xevent),
|
||||
g_steal_pointer (&stream),
|
||||
(GClosureNotify) g_object_unref, 0);
|
||||
|
||||
XConvertSelection (GDK_DISPLAY_XDISPLAY (display),
|
||||
priv->xselection,
|
||||
@@ -577,7 +578,6 @@ gdk_x11_selection_input_stream_new_finish (GAsyncResult *result,
|
||||
*type = priv->type;
|
||||
if (format)
|
||||
*format = priv->format;
|
||||
g_object_ref (stream);
|
||||
}
|
||||
|
||||
return G_INPUT_STREAM (stream);
|
||||
|
||||
@@ -1455,7 +1455,8 @@ memory_format_gl_format (GdkMemoryFormat data_format,
|
||||
guint minor,
|
||||
guint *gl_internalformat,
|
||||
guint *gl_format,
|
||||
guint *gl_type)
|
||||
guint *gl_type,
|
||||
GLint (*gl_swizzle)[4])
|
||||
{
|
||||
if (gdk_memory_format_gl_format (data_format,
|
||||
use_es,
|
||||
@@ -1463,7 +1464,9 @@ memory_format_gl_format (GdkMemoryFormat data_format,
|
||||
minor,
|
||||
gl_internalformat,
|
||||
gl_format,
|
||||
gl_type))
|
||||
gl_type,
|
||||
gl_swizzle) &&
|
||||
gdk_memory_format_alpha (data_format) != GDK_MEMORY_ALPHA_STRAIGHT)
|
||||
return data_format;
|
||||
|
||||
if (gdk_memory_format_prefers_high_depth (data_format))
|
||||
@@ -1475,7 +1478,8 @@ memory_format_gl_format (GdkMemoryFormat data_format,
|
||||
minor,
|
||||
gl_internalformat,
|
||||
gl_format,
|
||||
gl_type))
|
||||
gl_type,
|
||||
gl_swizzle))
|
||||
return data_format;
|
||||
}
|
||||
|
||||
@@ -1486,7 +1490,8 @@ memory_format_gl_format (GdkMemoryFormat data_format,
|
||||
minor,
|
||||
gl_internalformat,
|
||||
gl_format,
|
||||
gl_type))
|
||||
gl_type,
|
||||
gl_swizzle))
|
||||
{
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
@@ -1509,6 +1514,7 @@ gsk_gl_command_queue_do_upload_texture_chunk (GskGLCommandQueue *self,
|
||||
GLenum gl_internalformat;
|
||||
GLenum gl_format;
|
||||
GLenum gl_type;
|
||||
GLint gl_swizzle[4];
|
||||
gsize bpp;
|
||||
gboolean use_es;
|
||||
int major, minor;
|
||||
@@ -1525,7 +1531,8 @@ gsk_gl_command_queue_do_upload_texture_chunk (GskGLCommandQueue *self,
|
||||
minor,
|
||||
&gl_internalformat,
|
||||
&gl_format,
|
||||
&gl_type);
|
||||
&gl_type,
|
||||
&gl_swizzle);
|
||||
|
||||
gdk_texture_downloader_init (&downloader, texture);
|
||||
gdk_texture_downloader_set_format (&downloader, data_format);
|
||||
@@ -1560,6 +1567,18 @@ gsk_gl_command_queue_do_upload_texture_chunk (GskGLCommandQueue *self,
|
||||
|
||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
||||
|
||||
/* Only apply swizzle if really needed, might not even be
|
||||
* supported if default values are set
|
||||
*/
|
||||
if (gl_swizzle[0] != GL_RED || gl_swizzle[1] != GL_GREEN || gl_swizzle[2] != GL_BLUE)
|
||||
{
|
||||
/* Set each channel independently since GLES 3.0 doesn't support the iv method */
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, gl_swizzle[0]);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, gl_swizzle[1]);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, gl_swizzle[2]);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, gl_swizzle[3]);
|
||||
}
|
||||
|
||||
g_bytes_unref (bytes);
|
||||
}
|
||||
|
||||
@@ -1574,6 +1593,7 @@ gsk_gl_command_queue_upload_texture_chunks (GskGLCommandQueue *self,
|
||||
GLenum gl_internalformat;
|
||||
GLenum gl_format;
|
||||
GLenum gl_type;
|
||||
GLint gl_swizzle[4];
|
||||
gboolean use_es;
|
||||
int texture_id;
|
||||
int major, minor;
|
||||
@@ -1618,7 +1638,8 @@ gsk_gl_command_queue_upload_texture_chunks (GskGLCommandQueue *self,
|
||||
minor,
|
||||
&gl_internalformat,
|
||||
&gl_format,
|
||||
&gl_type);
|
||||
&gl_type,
|
||||
&gl_swizzle);
|
||||
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, gl_internalformat, width, height, 0, gl_format, gl_type, NULL);
|
||||
|
||||
|
||||
@@ -761,7 +761,8 @@ gsk_gl_driver_load_texture (GskGLDriver *self,
|
||||
GdkGLContext *texture_context = gdk_gl_texture_get_context (gl_texture);
|
||||
|
||||
if (gdk_gl_context_is_shared (context, texture_context) &&
|
||||
(!ensure_mipmap || gdk_gl_texture_has_mipmap (gl_texture)))
|
||||
(!ensure_mipmap || gdk_gl_texture_has_mipmap (gl_texture)) &&
|
||||
gdk_memory_format_alpha (gdk_texture_get_format (texture)) != GDK_MEMORY_ALPHA_STRAIGHT)
|
||||
{
|
||||
/* A GL texture from the same GL context is a simple task... */
|
||||
return gdk_gl_texture_get_id (gl_texture);
|
||||
|
||||
@@ -204,6 +204,7 @@ 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);
|
||||
}
|
||||
|
||||
+1
-2
@@ -15,8 +15,7 @@ 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" },
|
||||
{ "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" }
|
||||
{ "staging", GSK_DEBUG_STAGING, "Use a staging image for texture upload (Vulkan only)" },
|
||||
};
|
||||
|
||||
static guint gsk_debug_flags;
|
||||
|
||||
@@ -18,8 +18,7 @@ typedef enum {
|
||||
GSK_DEBUG_GEOMETRY = 1 << 9,
|
||||
GSK_DEBUG_FULL_REDRAW = 1 << 10,
|
||||
GSK_DEBUG_SYNC = 1 << 11,
|
||||
GSK_DEBUG_VULKAN_STAGING_IMAGE = 1 << 12,
|
||||
GSK_DEBUG_VULKAN_STAGING_BUFFER = 1 << 13
|
||||
GSK_DEBUG_STAGING = 1 << 12
|
||||
} GskDebugFlags;
|
||||
|
||||
#define GSK_DEBUG_ANY ((1 << 13) - 1)
|
||||
|
||||
@@ -372,6 +372,8 @@ 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);
|
||||
|
||||
|
||||
+17
-12
@@ -3956,27 +3956,29 @@ 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,
|
||||
ceilf (self->child_bounds.size.width),
|
||||
ceilf (self->child_bounds.size.height));
|
||||
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);
|
||||
|
||||
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);
|
||||
@@ -5636,9 +5638,12 @@ 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
|
||||
|
||||
@@ -2892,6 +2892,14 @@ append_texture_param (Printer *p,
|
||||
case GDK_MEMORY_R16G16B16:
|
||||
case GDK_MEMORY_R16G16B16A16_PREMULTIPLIED:
|
||||
case GDK_MEMORY_R16G16B16A16:
|
||||
case GDK_MEMORY_G8A8_PREMULTIPLIED:
|
||||
case GDK_MEMORY_G8A8:
|
||||
case GDK_MEMORY_G8:
|
||||
case GDK_MEMORY_G16A16_PREMULTIPLIED:
|
||||
case GDK_MEMORY_G16A16:
|
||||
case GDK_MEMORY_G16:
|
||||
case GDK_MEMORY_A8:
|
||||
case GDK_MEMORY_A16:
|
||||
bytes = gdk_texture_save_to_png_bytes (texture);
|
||||
g_string_append (p->str, "url(\"data:image/png;base64,");
|
||||
break;
|
||||
|
||||
+133
-4
@@ -689,6 +689,134 @@ 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)
|
||||
{
|
||||
@@ -766,13 +894,14 @@ 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,
|
||||
float rect[12])
|
||||
gsk_rounded_rect_to_float (const GskRoundedRect *self,
|
||||
const graphene_point_t *offset,
|
||||
float rect[12])
|
||||
{
|
||||
guint i;
|
||||
|
||||
rect[0] = self->bounds.origin.x;
|
||||
rect[1] = self->bounds.origin.y;
|
||||
rect[0] = self->bounds.origin.x + offset->x;
|
||||
rect[1] = self->bounds.origin.y + offset->y;
|
||||
rect[2] = self->bounds.size.width;
|
||||
rect[3] = self->bounds.size.height;
|
||||
|
||||
|
||||
@@ -6,6 +6,24 @@
|
||||
|
||||
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 = { \
|
||||
@@ -28,6 +46,7 @@ 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,
|
||||
@@ -43,6 +62,9 @@ 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,8 +12,12 @@ typedef struct _GskVulkanBlendModeInstance GskVulkanBlendModeInstance;
|
||||
struct _GskVulkanBlendModeInstance
|
||||
{
|
||||
float rect[4];
|
||||
float start_tex_rect[4];
|
||||
float end_tex_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];
|
||||
guint32 blend_mode;
|
||||
};
|
||||
|
||||
@@ -40,18 +44,42 @@ 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, start_tex_rect),
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanBlendModeInstance, top_rect),
|
||||
},
|
||||
{
|
||||
.location = 2,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanBlendModeInstance, end_tex_rect),
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanBlendModeInstance, bottom_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),
|
||||
}
|
||||
};
|
||||
@@ -98,37 +126,50 @@ 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,
|
||||
const graphene_rect_t *bounds,
|
||||
const graphene_rect_t *start_tex_rect,
|
||||
const graphene_rect_t *end_tex_rect,
|
||||
GskBlendMode blend_mode)
|
||||
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)
|
||||
{
|
||||
GskVulkanBlendModeInstance *instance = (GskVulkanBlendModeInstance *) data;
|
||||
|
||||
instance->rect[0] = bounds->origin.x;
|
||||
instance->rect[1] = bounds->origin.y;
|
||||
instance->rect[0] = bounds->origin.x + offset->x;
|
||||
instance->rect[1] = bounds->origin.y + offset->y;
|
||||
instance->rect[2] = bounds->size.width;
|
||||
instance->rect[3] = 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->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->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->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->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,12 +18,16 @@ 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 *start_bounds,
|
||||
const graphene_rect_t *end_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);
|
||||
gsize gsk_vulkan_blend_mode_pipeline_draw (GskVulkanBlendModePipeline *pipeline,
|
||||
VkCommandBuffer command_buffer,
|
||||
|
||||
@@ -14,6 +14,7 @@ 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)
|
||||
@@ -46,6 +47,12 @@ 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 = {
|
||||
@@ -91,23 +98,19 @@ 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,
|
||||
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,
|
||||
guint32 tex_id[2],
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *rect,
|
||||
const graphene_rect_t *tex_rect,
|
||||
double blur_radius)
|
||||
{
|
||||
GskVulkanBlurInstance *instance = (GskVulkanBlurInstance *) data;
|
||||
|
||||
instance->rect[0] = rect->origin.x;
|
||||
instance->rect[1] = rect->origin.y;
|
||||
instance->rect[0] = rect->origin.x + offset->x;
|
||||
instance->rect[1] = rect->origin.y + offset->y;
|
||||
instance->rect[2] = rect->size.width;
|
||||
instance->rect[3] = rect->size.height;
|
||||
instance->tex_rect[0] = tex_rect->origin.x;
|
||||
@@ -115,6 +118,8 @@ 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,9 +17,10 @@ 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,15 +123,10 @@ 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])
|
||||
@@ -139,7 +134,7 @@ gsk_vulkan_border_pipeline_collect_vertex_data (GskVulkanBorderPipeline *pipelin
|
||||
GskVulkanBorderInstance *instance = (GskVulkanBorderInstance *) data;
|
||||
guint i;
|
||||
|
||||
gsk_rounded_rect_to_float (rect, instance->rect);
|
||||
gsk_rounded_rect_to_float (rect, offset, 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,15 +119,10 @@ 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,
|
||||
@@ -137,7 +132,7 @@ gsk_vulkan_box_shadow_pipeline_collect_vertex_data (GskVulkanBoxShadowPipeline *
|
||||
{
|
||||
GskVulkanBoxShadowInstance *instance = (GskVulkanBoxShadowInstance *) data;
|
||||
|
||||
gsk_rounded_rect_to_float (outline, instance->outline);
|
||||
gsk_rounded_rect_to_float (outline, offset, 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,6 +64,13 @@ 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,6 +8,8 @@ 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,
|
||||
|
||||
+91
-44
@@ -13,7 +13,15 @@ gsk_vulkan_clip_init_empty (GskVulkanClip *clip,
|
||||
gsk_rounded_rect_init_from_rect (&clip->rect, rect, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
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
|
||||
gsk_vulkan_clip_init_copy (GskVulkanClip *self,
|
||||
const GskVulkanClip *src)
|
||||
{
|
||||
@@ -21,11 +29,30 @@ 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);
|
||||
@@ -57,22 +84,10 @@ 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:
|
||||
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;
|
||||
}
|
||||
res = gsk_rounded_rect_intersect_with_rect (&src->rect, rect, &dest->rect);
|
||||
if (!gsk_vulkan_clip_init_after_intersection (dest, res))
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -88,6 +103,8 @@ 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);
|
||||
@@ -106,34 +123,21 @@ gsk_vulkan_clip_intersect_rounded_rect (GskVulkanClip *dest,
|
||||
break;
|
||||
|
||||
case GSK_VULKAN_CLIP_NONE:
|
||||
dest->type = gsk_rounded_rect_is_circular (rounded) ? GSK_VULKAN_CLIP_ROUNDED_CIRCULAR : GSK_VULKAN_CLIP_ROUNDED;
|
||||
dest->type = GSK_VULKAN_CLIP_ROUNDED;
|
||||
gsk_rounded_rect_init_copy (&dest->rect, rounded);
|
||||
break;
|
||||
|
||||
case GSK_VULKAN_CLIP_RECT:
|
||||
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;
|
||||
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;
|
||||
|
||||
case GSK_VULKAN_CLIP_ROUNDED_CIRCULAR:
|
||||
case GSK_VULKAN_CLIP_ROUNDED:
|
||||
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;
|
||||
res = gsk_rounded_rect_intersection (&src->rect, rounded, &dest->rect);
|
||||
if (!gsk_vulkan_clip_init_after_intersection (dest, res))
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
@@ -143,6 +147,19 @@ 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,
|
||||
@@ -164,7 +181,6 @@ 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))
|
||||
{
|
||||
@@ -220,9 +236,41 @@ gsk_vulkan_clip_transform (GskVulkanClip *dest,
|
||||
}
|
||||
|
||||
gboolean
|
||||
gsk_vulkan_clip_contains_rect (const GskVulkanClip *self,
|
||||
const graphene_rect_t *rect)
|
||||
gsk_vulkan_clip_intersects_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:
|
||||
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:
|
||||
@@ -234,10 +282,9 @@ gsk_vulkan_clip_contains_rect (const GskVulkanClip *self,
|
||||
return TRUE;
|
||||
|
||||
case GSK_VULKAN_CLIP_RECT:
|
||||
return graphene_rect_contains_rect (&self->rect.bounds, rect);
|
||||
return graphene_rect_contains_rect (&self->rect.bounds, &r);
|
||||
|
||||
case GSK_VULKAN_CLIP_ROUNDED_CIRCULAR:
|
||||
case GSK_VULKAN_CLIP_ROUNDED:
|
||||
return gsk_rounded_rect_contains_rect (&self->rect, rect);
|
||||
return gsk_rounded_rect_contains_rect (&self->rect, &r);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,6 @@ 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;
|
||||
@@ -36,6 +32,10 @@ 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,12 +43,20 @@ 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,22 +84,17 @@ 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;
|
||||
instance->rect[1] = rect->origin.y;
|
||||
instance->rect[0] = rect->origin.x + offset->x;
|
||||
instance->rect[1] = rect->origin.y + offset->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,6 +13,7 @@ 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)
|
||||
@@ -40,6 +41,12 @@ 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,
|
||||
@@ -84,18 +91,12 @@ 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,
|
||||
@@ -140,6 +141,9 @@ 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,12 +18,11 @@ 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,8 +12,12 @@ 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;
|
||||
};
|
||||
|
||||
@@ -40,17 +44,41 @@ 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_tex_rect),
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, start_rect),
|
||||
},
|
||||
{
|
||||
.location = 2,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, end_tex_rect),
|
||||
.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,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32_SFLOAT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, progress),
|
||||
}
|
||||
@@ -98,27 +126,36 @@ 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,
|
||||
const graphene_rect_t *bounds,
|
||||
const graphene_rect_t *start_tex_rect,
|
||||
const graphene_rect_t *end_tex_rect,
|
||||
double progress)
|
||||
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)
|
||||
{
|
||||
GskVulkanCrossFadeInstance *instance = (GskVulkanCrossFadeInstance *) data;
|
||||
|
||||
instance->rect[0] = bounds->origin.x;
|
||||
instance->rect[1] = bounds->origin.y;
|
||||
instance->rect[0] = bounds->origin.x + offset->x;
|
||||
instance->rect[1] = bounds->origin.y + offset->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;
|
||||
@@ -129,6 +166,10 @@ 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,12 +17,16 @@ 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,6 +15,7 @@ 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)
|
||||
@@ -71,6 +72,12 @@ 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 = {
|
||||
@@ -116,15 +123,11 @@ 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,
|
||||
@@ -132,8 +135,8 @@ gsk_vulkan_effect_pipeline_collect_vertex_data (GskVulkanEffectPipeline *pipelin
|
||||
{
|
||||
GskVulkanEffectInstance *instance = (GskVulkanEffectInstance *) data;
|
||||
|
||||
instance->rect[0] = rect->origin.x;
|
||||
instance->rect[1] = rect->origin.y;
|
||||
instance->rect[0] = rect->origin.x + offset->x;
|
||||
instance->rect[1] = rect->origin.y + offset->y;
|
||||
instance->rect[2] = rect->size.width;
|
||||
instance->rect[3] = rect->size.height;
|
||||
instance->tex_rect[0] = tex_rect->origin.x;
|
||||
@@ -142,6 +145,8 @@ 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,9 +17,10 @@ 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,
|
||||
|
||||
+121
-209
@@ -209,6 +209,8 @@ 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);
|
||||
@@ -252,43 +254,6 @@ 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)
|
||||
@@ -318,34 +283,99 @@ gsk_vulkan_image_ensure_view (GskVulkanImage *self,
|
||||
&self->vk_image_view);
|
||||
}
|
||||
|
||||
static GskVulkanImage *
|
||||
gsk_vulkan_image_new_from_data_via_staging_buffer (GskVulkanUploader *uploader,
|
||||
guchar *data,
|
||||
gsize width,
|
||||
gsize height,
|
||||
gsize stride)
|
||||
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)
|
||||
{
|
||||
GskVulkanImage *self;
|
||||
GskVulkanBuffer *staging;
|
||||
gsize buffer_size = width * height * 4;
|
||||
guchar *mem;
|
||||
|
||||
staging = gsk_vulkan_buffer_new_staging (uploader->vulkan, buffer_size);
|
||||
mem = gsk_vulkan_buffer_map (staging);
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
gsk_vulkan_image_ensure_view (self, VK_FORMAT_B8G8R8A8_UNORM);
|
||||
|
||||
gsk_vulkan_buffer_unmap (staging);
|
||||
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_uploader_add_buffer_barrier (uploader,
|
||||
FALSE,
|
||||
@@ -355,21 +385,11 @@ gsk_vulkan_image_new_from_data_via_staging_buffer (GskVulkanUploader *uploader,
|
||||
.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT,
|
||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.buffer = gsk_vulkan_buffer_get_buffer (staging),
|
||||
.buffer = gsk_vulkan_buffer_get_buffer (map->staging_buffer),
|
||||
.offset = 0,
|
||||
.size = buffer_size,
|
||||
.size = VK_WHOLE_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,
|
||||
@@ -377,7 +397,7 @@ gsk_vulkan_image_new_from_data_via_staging_buffer (GskVulkanUploader *uploader,
|
||||
VK_ACCESS_TRANSFER_WRITE_BIT);
|
||||
|
||||
vkCmdCopyBufferToImage (gsk_vulkan_uploader_get_copy_buffer (uploader),
|
||||
gsk_vulkan_buffer_get_buffer (staging),
|
||||
gsk_vulkan_buffer_get_buffer (map->staging_buffer),
|
||||
self->vk_image,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
1,
|
||||
@@ -392,8 +412,8 @@ gsk_vulkan_image_new_from_data_via_staging_buffer (GskVulkanUploader *uploader,
|
||||
},
|
||||
.imageOffset = { 0, 0, 0 },
|
||||
.imageExtent = {
|
||||
.width = width,
|
||||
.height = height,
|
||||
.width = self->width,
|
||||
.height = self->height,
|
||||
.depth = 1
|
||||
}
|
||||
}
|
||||
@@ -405,141 +425,33 @@ gsk_vulkan_image_new_from_data_via_staging_buffer (GskVulkanUploader *uploader,
|
||||
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, staging);
|
||||
|
||||
gsk_vulkan_image_ensure_view (self, VK_FORMAT_B8G8R8A8_UNORM);
|
||||
|
||||
return self;
|
||||
uploader->staging_buffer_free_list = g_slist_prepend (uploader->staging_buffer_free_list,
|
||||
map->staging_buffer);
|
||||
}
|
||||
|
||||
static GskVulkanImage *
|
||||
gsk_vulkan_image_new_from_data_via_staging_image (GskVulkanUploader *uploader,
|
||||
guchar *data,
|
||||
gsize width,
|
||||
gsize height,
|
||||
gsize stride)
|
||||
void
|
||||
gsk_vulkan_image_map_memory (GskVulkanImage *self,
|
||||
GskVulkanUploader *uploader,
|
||||
GskVulkanImageMap *map)
|
||||
{
|
||||
GskVulkanImage *self, *staging;
|
||||
g_assert (self->vk_image_layout == VK_IMAGE_LAYOUT_UNDEFINED ||
|
||||
self->vk_image_layout == VK_IMAGE_LAYOUT_PREINITIALIZED);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
static GskVulkanImage *
|
||||
gsk_vulkan_image_new_from_data_directly (GskVulkanUploader *uploader,
|
||||
guchar *data,
|
||||
gsize width,
|
||||
gsize height,
|
||||
gsize stride)
|
||||
{
|
||||
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);
|
||||
if (!GSK_DEBUG_CHECK (STAGING) && gsk_vulkan_memory_can_map (self->memory, TRUE))
|
||||
gsk_vulkan_image_map_memory_direct (self, uploader, map);
|
||||
else
|
||||
return gsk_vulkan_image_new_from_data_directly (uploader, data, width, height, stride);
|
||||
gsk_vulkan_image_map_memory_indirect (self, uploader, map);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_vulkan_image_unmap_memory (GskVulkanImage *self,
|
||||
GskVulkanUploader *uploader,
|
||||
GskVulkanImageMap *map)
|
||||
{
|
||||
if (map->staging_buffer)
|
||||
gsk_vulkan_image_unmap_memory_indirect (self, uploader, map);
|
||||
else
|
||||
gsk_vulkan_image_unmap_memory_direct (self, uploader, map);
|
||||
}
|
||||
|
||||
GskVulkanImage *
|
||||
@@ -606,9 +518,9 @@ gsk_vulkan_image_new_for_atlas (GdkVulkanContext *context,
|
||||
}
|
||||
|
||||
GskVulkanImage *
|
||||
gsk_vulkan_image_new_for_texture (GdkVulkanContext *context,
|
||||
gsize width,
|
||||
gsize height)
|
||||
gsk_vulkan_image_new_for_offscreen (GdkVulkanContext *context,
|
||||
gsize width,
|
||||
gsize height)
|
||||
{
|
||||
GskVulkanImage *self;
|
||||
|
||||
@@ -620,7 +532,7 @@ gsk_vulkan_image_new_for_texture (GdkVulkanContext *context,
|
||||
VK_IMAGE_USAGE_SAMPLED_BIT |
|
||||
VK_IMAGE_USAGE_TRANSFER_SRC_BIT,
|
||||
VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
0,
|
||||
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
||||
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||
|
||||
gsk_vulkan_image_ensure_view (self, VK_FORMAT_B8G8R8A8_UNORM);
|
||||
|
||||
@@ -24,11 +24,8 @@ GskVulkanImage * gsk_vulkan_image_new_for_swapchain (GdkVulk
|
||||
VkFormat format,
|
||||
gsize width,
|
||||
gsize height);
|
||||
GskVulkanImage * gsk_vulkan_image_new_from_data (GskVulkanUploader *uploader,
|
||||
guchar *data,
|
||||
gsize width,
|
||||
gsize height,
|
||||
gsize stride);
|
||||
GskVulkanImage * gsk_vulkan_image_new_from_texture (GskVulkanUploader *uploader,
|
||||
GdkTexture *texture);
|
||||
|
||||
typedef struct {
|
||||
guchar *data;
|
||||
@@ -49,13 +46,34 @@ 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_texture (GdkVulkanContext *context,
|
||||
GskVulkanImage * gsk_vulkan_image_new_for_offscreen (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,9 +15,8 @@ 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)
|
||||
@@ -61,67 +60,13 @@ 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, stop_count),
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanLinearGradientInstance, offset),
|
||||
},
|
||||
{
|
||||
.location = 5,
|
||||
.binding = 0,
|
||||
.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]),
|
||||
.format = VK_FORMAT_R32_SINT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanLinearGradientInstance, stop_count),
|
||||
}
|
||||
};
|
||||
static const VkPipelineVertexInputStateCreateInfo info = {
|
||||
@@ -167,48 +112,30 @@ 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_rect_t *rect,
|
||||
const graphene_point_t *start,
|
||||
const graphene_point_t *end,
|
||||
gboolean repeating,
|
||||
gsize n_stops,
|
||||
const GskColorStop *stops)
|
||||
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)
|
||||
{
|
||||
GskVulkanLinearGradientInstance *instance = (GskVulkanLinearGradientInstance *) data;
|
||||
gsize i;
|
||||
|
||||
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[0] = rect->origin.x + offset->x;
|
||||
instance->rect[1] = rect->origin.y + offset->y;
|
||||
instance->rect[2] = rect->size.width;
|
||||
instance->rect[3] = rect->size.height;
|
||||
instance->start[0] = start->x;
|
||||
instance->start[1] = start->y;
|
||||
instance->end[0] = end->x;
|
||||
instance->end[1] = end->y;
|
||||
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->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,17 +20,16 @@ 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 n_stops,
|
||||
const GskColorStop *stops);
|
||||
gsize gradient_offset,
|
||||
gsize n_stops);
|
||||
gsize gsk_vulkan_linear_gradient_pipeline_draw (GskVulkanLinearGradientPipeline*pipeline,
|
||||
VkCommandBuffer command_buffer,
|
||||
gsize offset,
|
||||
|
||||
@@ -9,6 +9,7 @@ struct _GskVulkanMemory
|
||||
|
||||
gsize size;
|
||||
|
||||
VkMemoryType vk_memory_type;
|
||||
VkDeviceMemory vk_memory;
|
||||
};
|
||||
|
||||
@@ -41,6 +42,7 @@ 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,
|
||||
@@ -71,11 +73,33 @@ 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,6 +14,8 @@ 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,10 +16,11 @@ 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)
|
||||
@@ -54,12 +55,13 @@ 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;
|
||||
@@ -76,11 +78,14 @@ 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,
|
||||
@@ -91,7 +96,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 = GSK_VULKAN_PIPELINE_GET_CLASS (self)->get_input_state_create_info (self),
|
||||
.pVertexInputState = vertex_input_state,
|
||||
.pInputAssemblyState = &(VkPipelineInputAssemblyStateCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
|
||||
.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
|
||||
@@ -108,7 +113,7 @@ gsk_vulkan_pipeline_new (GType pipeline_type,
|
||||
.depthClampEnable = VK_FALSE,
|
||||
.rasterizerDiscardEnable = VK_FALSE,
|
||||
.polygonMode = VK_POLYGON_MODE_FILL,
|
||||
.cullMode = VK_CULL_MODE_BACK_BIT,
|
||||
.cullMode = VK_CULL_MODE_NONE,
|
||||
.frontFace = VK_FRONT_FACE_CLOCKWISE,
|
||||
.lineWidth = 1.0f,
|
||||
},
|
||||
@@ -146,7 +151,7 @@ gsk_vulkan_pipeline_new (GType pipeline_type,
|
||||
VK_DYNAMIC_STATE_SCISSOR
|
||||
},
|
||||
},
|
||||
.layout = priv->layout,
|
||||
.layout = layout,
|
||||
.renderPass = render_pass,
|
||||
.subpass = 0,
|
||||
.basePipelineHandle = VK_NULL_HANDLE,
|
||||
@@ -166,10 +171,10 @@ gsk_vulkan_pipeline_get_pipeline (GskVulkanPipeline *self)
|
||||
return priv->pipeline;
|
||||
}
|
||||
|
||||
VkPipelineLayout
|
||||
gsk_vulkan_pipeline_get_pipeline_layout (GskVulkanPipeline *self)
|
||||
gsize
|
||||
gsk_vulkan_pipeline_get_vertex_stride (GskVulkanPipeline *self)
|
||||
{
|
||||
GskVulkanPipelinePrivate *priv = gsk_vulkan_pipeline_get_instance_private (self);
|
||||
|
||||
return priv->layout;
|
||||
return priv->vertex_stride;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
VkPipelineLayout gsk_vulkan_pipeline_get_pipeline_layout (GskVulkanPipeline *self);
|
||||
gsize gsk_vulkan_pipeline_get_vertex_stride (GskVulkanPipeline *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -12,83 +12,37 @@ struct _GskVulkanPushConstantsWire
|
||||
struct {
|
||||
float mvp[16];
|
||||
float clip[12];
|
||||
float scale[2];
|
||||
} common;
|
||||
};
|
||||
|
||||
void
|
||||
gsk_vulkan_push_constants_init (GskVulkanPushConstants *constants,
|
||||
const graphene_matrix_t *mvp,
|
||||
const graphene_rect_t *viewport)
|
||||
{
|
||||
graphene_matrix_init_from_matrix (&constants->mvp, mvp);
|
||||
gsk_vulkan_clip_init_empty (&constants->clip, viewport);
|
||||
}
|
||||
|
||||
void
|
||||
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;
|
||||
}
|
||||
/* 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 GskVulkanPushConstants *self)
|
||||
gsk_vulkan_push_constants_wire_init (GskVulkanPushConstantsWire *wire,
|
||||
const graphene_vec2_t *scale,
|
||||
const graphene_matrix_t *mvp,
|
||||
const GskRoundedRect *clip)
|
||||
{
|
||||
graphene_matrix_to_float (&self->mvp, wire->common.mvp);
|
||||
gsk_rounded_rect_to_float (&self->clip.rect, wire->common.clip);
|
||||
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);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_vulkan_push_constants_push (const GskVulkanPushConstants *self,
|
||||
VkCommandBuffer command_buffer,
|
||||
VkPipelineLayout pipeline_layout)
|
||||
gsk_vulkan_push_constants_push (VkCommandBuffer command_buffer,
|
||||
VkPipelineLayout pipeline_layout,
|
||||
const graphene_vec2_t *scale,
|
||||
const graphene_matrix_t *mvp,
|
||||
const GskRoundedRect *clip)
|
||||
{
|
||||
GskVulkanPushConstantsWire wire;
|
||||
|
||||
gsk_vulkan_push_constants_wire_init (&wire, self);
|
||||
gsk_vulkan_push_constants_wire_init (&wire, scale, mvp, clip);
|
||||
|
||||
vkCmdPushConstants (command_buffer,
|
||||
pipeline_layout,
|
||||
|
||||
@@ -6,38 +6,15 @@
|
||||
|
||||
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_init (GskVulkanPushConstants *constants,
|
||||
void gsk_vulkan_push_constants_push (VkCommandBuffer command_buffer,
|
||||
VkPipelineLayout pipeline_layout,
|
||||
const graphene_vec2_t *scale,
|
||||
const graphene_matrix_t *mvp,
|
||||
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);
|
||||
const GskRoundedRect *clip);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
+301
-183
@@ -23,8 +23,23 @@
|
||||
#include "gskvulkantexturepipelineprivate.h"
|
||||
#include "gskvulkanpushconstantsprivate.h"
|
||||
|
||||
#define DESCRIPTOR_POOL_MAXSETS 128
|
||||
#define DESCRIPTOR_POOL_MAXSETS_INCREASE 128
|
||||
#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"
|
||||
|
||||
struct _GskVulkanRender
|
||||
{
|
||||
@@ -40,20 +55,22 @@ struct _GskVulkanRender
|
||||
VkFence fence;
|
||||
VkRenderPass render_pass;
|
||||
VkDescriptorSetLayout descriptor_set_layout;
|
||||
VkPipelineLayout pipeline_layout[3]; /* indexed by number of textures */
|
||||
VkPipelineLayout pipeline_layout;
|
||||
GskVulkanUploader *uploader;
|
||||
|
||||
GHashTable *descriptor_set_indexes;
|
||||
GskDescriptorImageInfos descriptor_images;
|
||||
GskDescriptorImageInfos descriptor_samplers;
|
||||
GskDescriptorBufferInfos descriptor_buffers;
|
||||
VkDescriptorPool descriptor_pool;
|
||||
uint32_t descriptor_pool_maxsets;
|
||||
VkDescriptorSet *descriptor_sets;
|
||||
gsize n_descriptor_sets;
|
||||
VkDescriptorSet descriptor_set;
|
||||
GskVulkanPipeline *pipelines[GSK_VULKAN_N_PIPELINES];
|
||||
|
||||
GskVulkanImage *target;
|
||||
|
||||
VkSampler sampler;
|
||||
VkSampler repeating_sampler;
|
||||
VkSampler samplers[3];
|
||||
GskVulkanBuffer *storage_buffer;
|
||||
guchar *storage_buffer_memory;
|
||||
gsize storage_buffer_used;
|
||||
|
||||
GList *render_passes;
|
||||
GSList *cleanup_images;
|
||||
@@ -103,9 +120,6 @@ 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)
|
||||
@@ -118,7 +132,9 @@ gsk_vulkan_render_new (GskRenderer *renderer,
|
||||
self->vulkan = context;
|
||||
self->renderer = renderer;
|
||||
self->framebuffers = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
self->descriptor_set_indexes = g_hash_table_new_full (desc_set_index_hash, desc_set_index_equal, NULL, g_free);
|
||||
gsk_descriptor_image_infos_init (&self->descriptor_images);
|
||||
gsk_descriptor_image_infos_init (&self->descriptor_samplers);
|
||||
gsk_descriptor_buffer_infos_init (&self->descriptor_buffers);
|
||||
|
||||
device = gdk_vulkan_context_get_device (self->vulkan);
|
||||
|
||||
@@ -131,16 +147,24 @@ 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,
|
||||
.maxSets = self->descriptor_pool_maxsets,
|
||||
.poolSizeCount = 1,
|
||||
.pPoolSizes = (VkDescriptorPoolSize[1]) {
|
||||
.flags = VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT,
|
||||
.maxSets = 1,
|
||||
.poolSizeCount = 3,
|
||||
.pPoolSizes = (VkDescriptorPoolSize[3]) {
|
||||
{
|
||||
.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||
.descriptorCount = self->descriptor_pool_maxsets
|
||||
.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
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -190,53 +214,74 @@ gsk_vulkan_render_new (GskRenderer *renderer,
|
||||
GSK_VK_CHECK (vkCreateDescriptorSetLayout, device,
|
||||
&(VkDescriptorSetLayoutCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
|
||||
.bindingCount = 1,
|
||||
.pBindings = (VkDescriptorSetLayoutBinding[1]) {
|
||||
.bindingCount = 3,
|
||||
.flags = VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT,
|
||||
.pBindings = (VkDescriptorSetLayoutBinding[3]) {
|
||||
{
|
||||
.binding = 0,
|
||||
.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||
.descriptorCount = 1,
|
||||
.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
|
||||
.descriptorCount = DESCRIPTOR_POOL_MAXITEMS,
|
||||
.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);
|
||||
|
||||
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 ()
|
||||
GSK_VK_CHECK (vkCreatePipelineLayout, device,
|
||||
&(VkPipelineLayoutCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
|
||||
.setLayoutCount = 1,
|
||||
.pSetLayouts = (VkDescriptorSetLayout[1]) {
|
||||
self->descriptor_set_layout
|
||||
},
|
||||
NULL,
|
||||
&self->pipeline_layout[i]);
|
||||
}
|
||||
.pushConstantRangeCount = gsk_vulkan_push_constants_get_range_count (),
|
||||
.pPushConstantRanges = gsk_vulkan_push_constants_get_ranges ()
|
||||
},
|
||||
NULL,
|
||||
&self->pipeline_layout);
|
||||
|
||||
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_BORDER,
|
||||
.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,
|
||||
.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->sampler);
|
||||
&self->samplers[GSK_VULKAN_SAMPLER_DEFAULT]);
|
||||
|
||||
GSK_VK_CHECK (vkCreateSampler, device,
|
||||
&(VkSamplerCreateInfo) {
|
||||
@@ -251,7 +296,23 @@ gsk_vulkan_render_new (GskRenderer *renderer,
|
||||
.maxAnisotropy = 1.0,
|
||||
},
|
||||
NULL,
|
||||
&self->repeating_sampler);
|
||||
&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->uploader = gsk_vulkan_uploader_new (self->vulkan, self->command_pool);
|
||||
|
||||
@@ -315,6 +376,12 @@ 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)
|
||||
@@ -338,15 +405,13 @@ gsk_vulkan_render_add_node (GskVulkanRender *self,
|
||||
GskRenderNode *node)
|
||||
{
|
||||
GskVulkanRenderPass *pass;
|
||||
graphene_matrix_t mv;
|
||||
graphene_vec2_t scale;
|
||||
|
||||
graphene_matrix_init_scale (&mv, self->scale, self->scale, 1.0);
|
||||
graphene_vec2_init (&scale, self->scale, self->scale);
|
||||
|
||||
pass = gsk_vulkan_render_pass_new (self->vulkan,
|
||||
self->target,
|
||||
self->scale,
|
||||
self->scale,
|
||||
&mv,
|
||||
&scale,
|
||||
&self->viewport,
|
||||
self->clip,
|
||||
VK_NULL_HANDLE);
|
||||
@@ -425,7 +490,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[pipeline_info[type].num_textures],
|
||||
self->pipeline_layout,
|
||||
pipeline_info[type].name,
|
||||
self->render_pass);
|
||||
|
||||
@@ -433,71 +498,130 @@ gsk_vulkan_render_get_pipeline (GskVulkanRender *self,
|
||||
}
|
||||
|
||||
VkDescriptorSet
|
||||
gsk_vulkan_render_get_descriptor_set (GskVulkanRender *self,
|
||||
gsize id)
|
||||
gsk_vulkan_render_get_descriptor_set (GskVulkanRender *self)
|
||||
{
|
||||
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;
|
||||
return self->descriptor_set;
|
||||
}
|
||||
|
||||
gsize
|
||||
gsk_vulkan_render_reserve_descriptor_set (GskVulkanRender *self,
|
||||
GskVulkanImage *source,
|
||||
gboolean repeat)
|
||||
gsk_vulkan_render_get_sampler_descriptor (GskVulkanRender *self,
|
||||
GskVulkanRenderSampler render_sampler)
|
||||
{
|
||||
HashDescriptorSetIndexEntry lookup;
|
||||
HashDescriptorSetIndexEntry *entry;
|
||||
VkSampler sampler = self->samplers[render_sampler];
|
||||
gsize i;
|
||||
|
||||
g_assert (source != NULL);
|
||||
/* 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;
|
||||
}
|
||||
|
||||
lookup.image = source;
|
||||
lookup.repeat = repeat;
|
||||
g_assert (i < DESCRIPTOR_POOL_MAXITEMS);
|
||||
|
||||
entry = g_hash_table_lookup (self->descriptor_set_indexes, &lookup);
|
||||
if (entry)
|
||||
return entry->index;
|
||||
gsk_descriptor_image_infos_append (&self->descriptor_samplers,
|
||||
&(VkDescriptorImageInfo) {
|
||||
.sampler = sampler,
|
||||
});
|
||||
|
||||
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);
|
||||
return i;
|
||||
}
|
||||
|
||||
return entry->index;
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -507,85 +631,77 @@ gsk_vulkan_render_prepare_descriptor_sets (GskVulkanRender *self)
|
||||
gsk_vulkan_render_pass_reserve_descriptor_sets (pass, self);
|
||||
}
|
||||
|
||||
needed_sets = g_hash_table_size (self->descriptor_set_indexes);
|
||||
if (needed_sets > self->n_descriptor_sets)
|
||||
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)
|
||||
{
|
||||
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);
|
||||
gsk_vulkan_buffer_unmap (self->storage_buffer);
|
||||
self->storage_buffer_memory = NULL;
|
||||
}
|
||||
|
||||
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 = needed_sets,
|
||||
.pSetLayouts = layouts
|
||||
.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)
|
||||
}
|
||||
}
|
||||
},
|
||||
self->descriptor_sets);
|
||||
&self->descriptor_set);
|
||||
|
||||
g_hash_table_iter_init (&iter, self->descriptor_set_indexes);
|
||||
while (g_hash_table_iter_next (&iter, &key, NULL))
|
||||
n_descriptor_sets = 0;
|
||||
if (gsk_descriptor_image_infos_get_size (&self->descriptor_images) > 0)
|
||||
{
|
||||
HashDescriptorSetIndexEntry *entry = key;
|
||||
GskVulkanImage *image = entry->image;
|
||||
gsize id = entry->index;
|
||||
gboolean repeat = entry->repeat;
|
||||
|
||||
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);
|
||||
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)
|
||||
};
|
||||
}
|
||||
|
||||
vkUpdateDescriptorSets (device,
|
||||
n_descriptor_sets,
|
||||
descriptor_sets,
|
||||
0, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -614,7 +730,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, 3, self->pipeline_layout, command_buffer);
|
||||
gsk_vulkan_render_pass_draw (pass, self, self->pipeline_layout, command_buffer);
|
||||
|
||||
gsk_vulkan_command_pool_submit_buffer (self->command_pool,
|
||||
command_buffer,
|
||||
@@ -675,10 +791,12 @@ 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;
|
||||
@@ -720,10 +838,10 @@ gsk_vulkan_render_free (GskVulkanRender *self)
|
||||
|
||||
g_clear_pointer (&self->uploader, gsk_vulkan_uploader_free);
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
vkDestroyPipelineLayout (device,
|
||||
self->pipeline_layout[i],
|
||||
NULL);
|
||||
|
||||
vkDestroyPipelineLayout (device,
|
||||
self->pipeline_layout,
|
||||
NULL);
|
||||
|
||||
vkDestroyRenderPass (device,
|
||||
self->render_pass,
|
||||
@@ -732,8 +850,9 @@ gsk_vulkan_render_free (GskVulkanRender *self)
|
||||
vkDestroyDescriptorPool (device,
|
||||
self->descriptor_pool,
|
||||
NULL);
|
||||
g_free (self->descriptor_sets);
|
||||
g_hash_table_unref (self->descriptor_set_indexes);
|
||||
gsk_descriptor_image_infos_clear (&self->descriptor_images);
|
||||
gsk_descriptor_image_infos_clear (&self->descriptor_samplers);
|
||||
gsk_descriptor_buffer_infos_clear (&self->descriptor_buffers);
|
||||
|
||||
vkDestroyDescriptorSetLayout (device,
|
||||
self->descriptor_set_layout,
|
||||
@@ -743,13 +862,12 @@ gsk_vulkan_render_free (GskVulkanRender *self)
|
||||
self->fence,
|
||||
NULL);
|
||||
|
||||
vkDestroySampler (device,
|
||||
self->sampler,
|
||||
NULL);
|
||||
|
||||
vkDestroySampler (device,
|
||||
self->repeating_sampler,
|
||||
NULL);
|
||||
for (i = 0; i < G_N_ELEMENTS (self->samplers); i++)
|
||||
{
|
||||
vkDestroySampler (device,
|
||||
self->samplers[i],
|
||||
NULL);
|
||||
}
|
||||
|
||||
gsk_vulkan_command_pool_free (self->command_pool);
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
#include <graphene.h>
|
||||
|
||||
#define GSK_VULKAN_MAX_RENDERS 4
|
||||
|
||||
typedef struct _GskVulkanTextureData GskVulkanTextureData;
|
||||
|
||||
struct _GskVulkanTextureData {
|
||||
@@ -51,7 +53,7 @@ struct _GskVulkanRenderer
|
||||
guint n_targets;
|
||||
GskVulkanImage **targets;
|
||||
|
||||
GskVulkanRender *render;
|
||||
GskVulkanRender *renders[GSK_VULKAN_MAX_RENDERS];
|
||||
|
||||
GSList *textures;
|
||||
|
||||
@@ -161,6 +163,38 @@ 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,
|
||||
@@ -185,8 +219,6 @@ 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;
|
||||
@@ -197,6 +229,7 @@ gsk_vulkan_renderer_unrealize (GskRenderer *renderer)
|
||||
{
|
||||
GskVulkanRenderer *self = GSK_VULKAN_RENDERER (renderer);
|
||||
GSList *l;
|
||||
guint i;
|
||||
|
||||
g_clear_object (&self->glyph_cache);
|
||||
|
||||
@@ -209,7 +242,8 @@ gsk_vulkan_renderer_unrealize (GskRenderer *renderer)
|
||||
}
|
||||
g_clear_pointer (&self->textures, g_slist_free);
|
||||
|
||||
g_clear_pointer (&self->render, gsk_vulkan_render_free);
|
||||
for (i = 0; i < G_N_ELEMENTS (self->renders); i++)
|
||||
g_clear_pointer (&self->renders[i], gsk_vulkan_render_free);
|
||||
|
||||
gsk_vulkan_renderer_free_targets (self);
|
||||
g_signal_handlers_disconnect_by_func(self->vulkan,
|
||||
@@ -228,6 +262,7 @@ 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;
|
||||
@@ -244,11 +279,15 @@ 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,
|
||||
ceil (viewport->size.width),
|
||||
ceil (viewport->size.height));
|
||||
rounded_viewport.size.width,
|
||||
rounded_viewport.size.height);
|
||||
|
||||
gsk_vulkan_render_reset (render, image, viewport, NULL);
|
||||
gsk_vulkan_render_reset (render, image, &rounded_viewport, NULL);
|
||||
gsk_vulkan_render_add_node (render, root);
|
||||
gsk_vulkan_render_upload (render);
|
||||
gsk_vulkan_render_draw (render);
|
||||
@@ -301,7 +340,7 @@ gsk_vulkan_renderer_render (GskRenderer *renderer,
|
||||
#endif
|
||||
|
||||
gdk_draw_context_begin_frame (GDK_DRAW_CONTEXT (self->vulkan), region);
|
||||
render = self->render;
|
||||
render = gsk_vulkan_renderer_get_render (self);
|
||||
|
||||
render_region = get_render_region (self);
|
||||
draw_index = gdk_vulkan_context_get_draw_index (self->vulkan);
|
||||
@@ -383,20 +422,13 @@ 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);
|
||||
|
||||
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);
|
||||
image = gsk_vulkan_image_new_from_texture (uploader, texture);
|
||||
|
||||
data = g_new0 (GskVulkanTextureData, 1);
|
||||
data->image = image;
|
||||
|
||||
+1071
-880
File diff suppressed because it is too large
Load Diff
@@ -12,10 +12,8 @@ G_BEGIN_DECLS
|
||||
|
||||
GskVulkanRenderPass * gsk_vulkan_render_pass_new (GdkVulkanContext *context,
|
||||
GskVulkanImage *target,
|
||||
float scale_x,
|
||||
float scale_y,
|
||||
graphene_matrix_t *mv,
|
||||
graphene_rect_t *viewport,
|
||||
const graphene_vec2_t *scale,
|
||||
const graphene_rect_t *viewport,
|
||||
cairo_region_t *clip,
|
||||
VkSemaphore signal_semaphore);
|
||||
|
||||
@@ -32,8 +30,7 @@ void gsk_vulkan_render_pass_reserve_descriptor_sets (GskVulk
|
||||
GskVulkanRender *render);
|
||||
void gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self,
|
||||
GskVulkanRender *render,
|
||||
guint layout_count,
|
||||
VkPipelineLayout *pipeline_layout,
|
||||
VkPipelineLayout pipeline_layout,
|
||||
VkCommandBuffer command_buffer);
|
||||
gsize gsk_vulkan_render_pass_get_wait_semaphores (GskVulkanRenderPass *self,
|
||||
VkSemaphore **semaphores);
|
||||
|
||||
@@ -51,6 +51,12 @@ 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);
|
||||
@@ -76,11 +82,18 @@ void gsk_vulkan_render_upload (GskVulk
|
||||
|
||||
GskVulkanPipeline * gsk_vulkan_render_get_pipeline (GskVulkanRender *self,
|
||||
GskVulkanPipelineType pipeline_type);
|
||||
VkDescriptorSet gsk_vulkan_render_get_descriptor_set (GskVulkanRender *self,
|
||||
gsize id);
|
||||
gsize gsk_vulkan_render_reserve_descriptor_set (GskVulkanRender *self,
|
||||
GskVulkanImage *source,
|
||||
gboolean repeat);
|
||||
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);
|
||||
|
||||
void gsk_vulkan_render_draw (GskVulkanRender *self);
|
||||
|
||||
void gsk_vulkan_render_submit (GskVulkanRender *self);
|
||||
@@ -88,6 +101,7 @@ 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,6 +14,7 @@ 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)
|
||||
@@ -46,6 +47,12 @@ 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 = {
|
||||
@@ -91,18 +98,12 @@ 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,
|
||||
@@ -153,6 +154,9 @@ 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,24 +18,23 @@ 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,
|
||||
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,
|
||||
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);
|
||||
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,6 +13,7 @@ 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)
|
||||
@@ -39,6 +40,12 @@ 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 = {
|
||||
@@ -84,28 +91,26 @@ 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;
|
||||
instance->rect[1] = rect->origin.y;
|
||||
instance->rect[0] = rect->origin.x + offset->x;
|
||||
instance->rect[1] = rect->origin.y + offset->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,9 +17,10 @@ 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,16 +1,19 @@
|
||||
#version 420 core
|
||||
#version 450
|
||||
|
||||
#include "common.frag.glsl"
|
||||
#include "clip.frag.glsl"
|
||||
#include "rect.frag.glsl"
|
||||
|
||||
layout(location = 0) in vec2 inPos;
|
||||
layout(location = 1) in vec2 inStartTexCoord;
|
||||
layout(location = 2) in vec2 inEndTexCoord;
|
||||
layout(location = 3) flat in uint inBlendMode;
|
||||
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(set = 0, binding = 0) uniform sampler2D startTexture;
|
||||
layout(set = 1, binding = 0) uniform sampler2D endTexture;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
float
|
||||
combine (float source, float backdrop)
|
||||
@@ -242,7 +245,7 @@ set_sat (vec3 c, float s)
|
||||
}
|
||||
|
||||
vec4
|
||||
color (vec4 Cs, vec4 Cb)
|
||||
colorize (vec4 Cs, vec4 Cb)
|
||||
{
|
||||
vec3 B = set_lum (Cs.rgb, lum (Cb.rgb));
|
||||
return composite (Cs, Cb, B);
|
||||
@@ -271,8 +274,10 @@ luminosity (vec4 Cs, vec4 Cb)
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 source = texture (startTexture, inStartTexCoord);
|
||||
vec4 backdrop = texture (endTexture, inEndTexCoord);
|
||||
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 result;
|
||||
|
||||
if (inBlendMode == 0)
|
||||
@@ -300,7 +305,7 @@ void main()
|
||||
else if (inBlendMode == 11)
|
||||
result = exclusion (source, backdrop);
|
||||
else if (inBlendMode == 12)
|
||||
result = color (source, backdrop);
|
||||
result = colorize (source, backdrop);
|
||||
else if (inBlendMode == 13)
|
||||
result = hue (source, backdrop);
|
||||
else if (inBlendMode == 14)
|
||||
@@ -310,5 +315,5 @@ void main()
|
||||
else
|
||||
discard;
|
||||
|
||||
outColor = clip (inPos, result);
|
||||
color = clip_scaled (inPos, result);
|
||||
}
|
||||
|
||||
@@ -1,40 +1,36 @@
|
||||
#version 420 core
|
||||
#version 450
|
||||
|
||||
#include "clip.vert.glsl"
|
||||
#include "common.vert.glsl"
|
||||
#include "rect.vert.glsl"
|
||||
|
||||
layout(location = 0) in vec4 inRect;
|
||||
layout(location = 1) in vec4 inStartTexRect;
|
||||
layout(location = 2) in vec4 inEndTexRect;
|
||||
layout(location = 3) in uint inBlendMode;
|
||||
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 = 0) out vec2 outPos;
|
||||
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) };
|
||||
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;
|
||||
|
||||
void main() {
|
||||
vec4 rect = clip (inRect);
|
||||
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
|
||||
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
|
||||
Rect r = rect_from_gsk (inRect);
|
||||
vec2 pos = set_position_from_rect (r);
|
||||
|
||||
outPos = pos;
|
||||
|
||||
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];
|
||||
|
||||
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;
|
||||
outBlendMode = inBlendMode;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#version 420 core
|
||||
#version 450
|
||||
|
||||
#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(set = 0, binding = 0) uniform sampler2D inTexture;
|
||||
layout(location = 4) in flat uvec2 inTexId;
|
||||
|
||||
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(inTexture, uv + vec2(offset_x, offset_y)) * fx * fy;
|
||||
ret += texture(get_sampler (inTexId), uv + vec2(offset_x, offset_y)) * fx * fy;
|
||||
}
|
||||
}
|
||||
return ret / total;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user