Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a72f1efc63 | |||
| c1872f2e96 | |||
| fb2da8786c | |||
| 8bf037a864 | |||
| 82361cfd6f | |||
| 3f065539f5 | |||
| 1dd0ceb854 | |||
| cf9fab57cc | |||
| 07d7ebbf84 | |||
| fd5c1f403f | |||
| c9aafbc940 | |||
| cc08634511 | |||
| e2e6e8df6e | |||
| 4bbb723012 | |||
| 0c2f6c9ac8 | |||
| 233f6fec3a | |||
| d9437da8dd | |||
| 7922aeff74 | |||
| d143858abc | |||
| 08c987975b | |||
| bb7df35bfe | |||
| 5b18315e87 | |||
| fc9f73926f | |||
| 0224e940a0 | |||
| 4503f3e916 | |||
| 9edcc1e497 | |||
| fe1839c6a0 | |||
| 6fb0bdd501 | |||
| fd6f1f3cf1 | |||
| 6e6bfd0a5e | |||
| 77c70dc65a | |||
| 149c5b7f0f | |||
| a44a145186 | |||
| ffd1f32d7a | |||
| becbc4b24e | |||
| 0d1743b105 | |||
| e27528f38b | |||
| 9b568b689f | |||
| 4e6e22b57c | |||
| 9efadc7e36 | |||
| 92ae960572 | |||
| 12ed8713a6 | |||
| 003f2d55e6 | |||
| 3c7a39dbcf | |||
| f212ed3dbc | |||
| af5fd539a8 | |||
| f668d15ceb | |||
| 5b5d73d1b6 | |||
| 6f9bcbb93f | |||
| 80f23332f9 | |||
| e21c09de7e | |||
| 24d295ac7d | |||
| b03929ed60 | |||
| 33979d7381 | |||
| 7834820bdf | |||
| 35002f3a70 | |||
| 5b17dd6811 | |||
| 8ecaf25352 | |||
| f84842b2b8 | |||
| 334e6eed44 | |||
| 32cbd190c2 | |||
| bce01889c6 | |||
| 2d9df97e69 | |||
| 46475cf89b | |||
| 03a627d8e1 | |||
| 07976be6d1 | |||
| 490e2823ef | |||
| 9fb7bc2940 | |||
| 122fc23214 | |||
| 6d333d5a32 | |||
| 41200466c0 | |||
| a009f8f759 | |||
| ddab0eedd9 | |||
| b086e1f775 | |||
| 0c96353c22 | |||
| 50eaf35f3d | |||
| 51b9e7bb06 | |||
| 3e735a77ef | |||
| 6b45510503 | |||
| 6eeaa39c8b | |||
| 4707adff3b | |||
| 28bd68db15 | |||
| a52972c7b7 | |||
| 48e5d50e3b | |||
| 6d3cf209af | |||
| 67ee22f8fa | |||
| b1af3691cf | |||
| 341a3d0029 | |||
| 691f296b3f | |||
| 36f6cabbf7 | |||
| 0bd37ed232 | |||
| 62a17ef3cb | |||
| e3ed9e0c2a | |||
| 1a30d253f5 | |||
| 876be6d47b | |||
| 38ee32db64 | |||
| dece7d509a | |||
| 8dc64fe904 | |||
| e8f7b336e1 | |||
| d580303374 | |||
| 80e308944a | |||
| 7c2bf89fd5 | |||
| 726e282cff | |||
| bd3df5bec1 | |||
| b413703921 | |||
| b7f819f037 | |||
| 62deba5c41 | |||
| d82c6516ae | |||
| de123d8ed5 | |||
| 6eedf81e1e | |||
| a1dec5205d | |||
| 9caeed54ad | |||
| d83328cd72 | |||
| ace34b5212 | |||
| 11b04da889 | |||
| cd6e01acde | |||
| aaccf7898a | |||
| 7511c8ec00 | |||
| 4623eaed8e | |||
| 02596a975f | |||
| 25d594e965 | |||
| bb636048f2 | |||
| 8b50a92bbd | |||
| 1ee8565630 | |||
| 8ea216978b | |||
| 0ff855d560 | |||
| fafda6f9bf | |||
| ff6019ff8d | |||
| aa1a304fe9 | |||
| 62cba3edca | |||
| ac42292095 | |||
| 94bf53e488 | |||
| fdf1b58816 | |||
| c475fe052f | |||
| c717e77123 | |||
| 57b1fcdede | |||
| 58a9c7bf63 | |||
| 743c7a7e33 | |||
| fd7f7b780f | |||
| d4c2a29d9e | |||
| 3ac60bfbcf | |||
| 63aeeb1e37 | |||
| c33a268060 | |||
| d298391bc9 | |||
| 6acf191fb0 | |||
| a518603f75 | |||
| 7e94e1c08e | |||
| 77f8b18155 | |||
| 467338d01b | |||
| 8c3130add7 | |||
| eb7eee49be | |||
| 35b734b1a5 | |||
| 661814faf0 | |||
| fa5c4defa2 | |||
| 9cdebc8291 | |||
| 8c3081232b | |||
| b31c0210e0 | |||
| f04fe55bac | |||
| ce7f86f05e | |||
| 8e91be460f | |||
| 8a1c1fe8bf | |||
| e349c1b111 | |||
| d86aabf1f6 | |||
| 46e9e4d823 | |||
| 76e2e9392d | |||
| 22e603ee99 | |||
| 407a31fc72 | |||
| 944e7d9ffe | |||
| f73ca30823 | |||
| 935817582d | |||
| b582666b63 | |||
| 237736fad9 | |||
| cf19f77699 | |||
| 93cd95b174 | |||
| 58851eea33 | |||
| a47206e0a6 | |||
| 326f4a3085 | |||
| aa9939264e | |||
| 92c6e6abf8 | |||
| 90df8be3fa | |||
| 6db19d9277 | |||
| a38351545b | |||
| 91efbe0977 | |||
| 7cf2cc660b | |||
| 42ee594e3c | |||
| 82d570154a | |||
| b8726b4f53 | |||
| 5c1b2333ff | |||
| 42424722a5 | |||
| c5e9ecb8e4 | |||
| aa55defff0 | |||
| bb97d1cfd6 | |||
| 6de2f8c5d3 | |||
| 6949ae7256 | |||
| 9f4d03fc9c | |||
| d89ff56eed | |||
| 592c2ed435 | |||
| aded12b225 | |||
| 86aee38b99 | |||
| f69a1fd9d4 | |||
| dc3a6c9f82 | |||
| 9b1ee6de31 | |||
| 95c0df3897 | |||
| de8315084b | |||
| d674c58f74 | |||
| 1a4b43b331 | |||
| f8b91f36dc | |||
| c38cf39264 | |||
| 37d5c049a0 | |||
| 6c5e5f3ee6 | |||
| 75e3c0e379 | |||
| 75aabbc59f | |||
| 744d62b4c5 | |||
| cb3cd96555 | |||
| 84c775f015 | |||
| de659462a0 | |||
| 5e9f1cd453 | |||
| 39335a1e12 | |||
| daf7c22489 | |||
| 27eec123f8 | |||
| 242681544a | |||
| f47437b814 | |||
| a04ddf45a8 | |||
| f9c6999ef1 | |||
| 0ac6256f25 | |||
| aae13dbac4 | |||
| 2dbbb46066 | |||
| 0abd3735b2 | |||
| 6b3e8b172f | |||
| a8774c33db | |||
| ae1b4dab44 | |||
| 15f0bcb27a | |||
| 7c91040408 | |||
| 488ec64633 | |||
| 4455848b3b | |||
| 526d720ec5 | |||
| 15bba9319b | |||
| c906ea3279 | |||
| 8e7fc8d68c | |||
| 97e25f736e | |||
| e26541b6f8 | |||
| 62da54e328 | |||
| 97f0af7784 | |||
| 86349ccf5b | |||
| 5ebfb141db | |||
| ae550e943b | |||
| c37868f626 | |||
| 493bd64a93 | |||
| ae4f961eed | |||
| f3e908344c | |||
| 143e6fcc8e | |||
| df74bd0d5f | |||
| 0cad3c0215 | |||
| 081f1247f9 | |||
| c4a50d5e03 | |||
| ae970f1a79 | |||
| 0d6e5533c2 | |||
| ae9bfb033f | |||
| 75afe829b2 | |||
| 411be011b9 | |||
| dacd7b2ed3 | |||
| c086f9c11e | |||
| 9c25fb8a86 | |||
| 4bcdc2eed2 | |||
| c43ae2f944 | |||
| a73f195c16 | |||
| 0b4c964f4a | |||
| 02a610f008 | |||
| b1f2512b67 | |||
| a4bb92e839 | |||
| 03f9a1911e | |||
| 82baa569a2 | |||
| 827d0f156b | |||
| ebfeda01cc | |||
| 01375ea50b | |||
| 3b469092e7 | |||
| 68b05b152e | |||
| e9799be573 | |||
| 0efdcf98dc | |||
| d1bf2a34db | |||
| 7eaf29379f | |||
| 8a4c99379b | |||
| b1fba59e39 | |||
| 9c1537b0ec | |||
| 90d9446ea2 | |||
| 8deebb25ac | |||
| d909571975 | |||
| 7559ae288f | |||
| 6fc7829b6c | |||
| 720b691102 | |||
| 383f88a9d0 | |||
| 3beab3b115 | |||
| c98c537dbc | |||
| 15ef87a7b6 | |||
| 9dc515c29c | |||
| 64d849f8f0 | |||
| e1a840186f | |||
| 88c1c434cd | |||
| 7dd2375e9f | |||
| 6dff9147fb | |||
| 7b28df566f | |||
| 686fff335d | |||
| 24a2f6dad4 | |||
| 869ad66e19 | |||
| c5f7672ee1 | |||
| aecee2b1ac | |||
| 20bdcce69b | |||
| 8c73c33ef3 | |||
| c9c7a294c1 | |||
| d1ad63a098 | |||
| 13a6a8be1c | |||
| adea3e34af | |||
| b422502d7a | |||
| 8c1c905be0 | |||
| 4851a82452 |
1213 changed files with 71336 additions and 13030 deletions
207
ABOUT-NLS
207
ABOUT-NLS
|
|
@ -1,206 +1 @@
|
|||
1 Notes on the Free Translation Project
|
||||
***************************************
|
||||
|
||||
Free software is going international! The Free Translation Project is
|
||||
a way to get maintainers of free software, translators, and users all
|
||||
together, so that free software will gradually become able to speak many
|
||||
languages. A few packages already provide translations for their
|
||||
messages.
|
||||
|
||||
If you found this `ABOUT-NLS' file inside a distribution, you may
|
||||
assume that the distributed package does use GNU `gettext' internally,
|
||||
itself available at your nearest GNU archive site. But you do _not_
|
||||
need to install GNU `gettext' prior to configuring, installing or using
|
||||
this package with messages translated.
|
||||
|
||||
Installers will find here some useful hints. These notes also
|
||||
explain how users should proceed for getting the programs to use the
|
||||
available translations. They tell how people wanting to contribute and
|
||||
work on translations can contact the appropriate team.
|
||||
|
||||
When reporting bugs in the `intl/' directory or bugs which may be
|
||||
related to internationalization, you should tell about the version of
|
||||
`gettext' which is used. The information can be found in the
|
||||
`intl/VERSION' file, in internationalized packages.
|
||||
|
||||
1.1 Quick configuration advice
|
||||
==============================
|
||||
|
||||
If you want to exploit the full power of internationalization, you
|
||||
should configure it using
|
||||
|
||||
./configure --with-included-gettext
|
||||
|
||||
to force usage of internationalizing routines provided within this
|
||||
package, despite the existence of internationalizing capabilities in the
|
||||
operating system where this package is being installed. So far, only
|
||||
the `gettext' implementation in the GNU C library version 2 provides as
|
||||
many features (such as locale alias, message inheritance, automatic
|
||||
charset conversion or plural form handling) as the implementation here.
|
||||
It is also not possible to offer this additional functionality on top
|
||||
of a `catgets' implementation. Future versions of GNU `gettext' will
|
||||
very likely convey even more functionality. So it might be a good idea
|
||||
to change to GNU `gettext' as soon as possible.
|
||||
|
||||
So you need _not_ provide this option if you are using GNU libc 2 or
|
||||
you have installed a recent copy of the GNU gettext package with the
|
||||
included `libintl'.
|
||||
|
||||
1.2 INSTALL Matters
|
||||
===================
|
||||
|
||||
Some packages are "localizable" when properly installed; the programs
|
||||
they contain can be made to speak your own native language. Most such
|
||||
packages use GNU `gettext'. Other packages have their own ways to
|
||||
internationalization, predating GNU `gettext'.
|
||||
|
||||
By default, this package will be installed to allow translation of
|
||||
messages. It will automatically detect whether the system already
|
||||
provides the GNU `gettext' functions. If not, the included GNU
|
||||
`gettext' library will be used. This library is wholly contained
|
||||
within this package, usually in the `intl/' subdirectory, so prior
|
||||
installation of the GNU `gettext' package is _not_ required.
|
||||
Installers may use special options at configuration time for changing
|
||||
the default behaviour. The commands:
|
||||
|
||||
./configure --with-included-gettext
|
||||
./configure --disable-nls
|
||||
|
||||
will, respectively, bypass any pre-existing `gettext' to use the
|
||||
internationalizing routines provided within this package, or else,
|
||||
_totally_ disable translation of messages.
|
||||
|
||||
When you already have GNU `gettext' installed on your system and run
|
||||
configure without an option for your new package, `configure' will
|
||||
probably detect the previously built and installed `libintl.a' file and
|
||||
will decide to use this. This might not be desirable. You should use
|
||||
the more recent version of the GNU `gettext' library. I.e. if the file
|
||||
`intl/VERSION' shows that the library which comes with this package is
|
||||
more recent, you should use
|
||||
|
||||
./configure --with-included-gettext
|
||||
|
||||
to prevent auto-detection.
|
||||
|
||||
The configuration process will not test for the `catgets' function
|
||||
and therefore it will not be used. The reason is that even an
|
||||
emulation of `gettext' on top of `catgets' could not provide all the
|
||||
extensions of the GNU `gettext' library.
|
||||
|
||||
Internationalized packages usually have many `po/LL.po' files, where
|
||||
LL gives an ISO 639 two-letter code identifying the language. Unless
|
||||
translations have been forbidden at `configure' time by using the
|
||||
`--disable-nls' switch, all available translations are installed
|
||||
together with the package. However, the environment variable `LINGUAS'
|
||||
may be set, prior to configuration, to limit the installed set.
|
||||
`LINGUAS' should then contain a space separated list of two-letter
|
||||
codes, stating which languages are allowed.
|
||||
|
||||
1.3 Using This Package
|
||||
======================
|
||||
|
||||
As a user, if your language has been installed for this package, you
|
||||
only have to set the `LANG' environment variable to the appropriate
|
||||
`LL_CC' combination. If you happen to have the `LC_ALL' or some other
|
||||
`LC_xxx' environment variables set, you should unset them before
|
||||
setting `LANG', otherwise the setting of `LANG' will not have the
|
||||
desired effect. Here `LL' is an ISO 639 two-letter language code, and
|
||||
`CC' is an ISO 3166 two-letter country code. For example, let's
|
||||
suppose that you speak German and live in Germany. At the shell
|
||||
prompt, merely execute `setenv LANG de_DE' (in `csh'),
|
||||
`export LANG; LANG=de_DE' (in `sh') or `export LANG=de_DE' (in `bash').
|
||||
This can be done from your `.login' or `.profile' file, once and for
|
||||
all.
|
||||
|
||||
You might think that the country code specification is redundant.
|
||||
But in fact, some languages have dialects in different countries. For
|
||||
example, `de_AT' is used for Austria, and `pt_BR' for Brazil. The
|
||||
country code serves to distinguish the dialects.
|
||||
|
||||
The locale naming convention of `LL_CC', with `LL' denoting the
|
||||
language and `CC' denoting the country, is the one use on systems based
|
||||
on GNU libc. On other systems, some variations of this scheme are
|
||||
used, such as `LL' or `LL_CC.ENCODING'. You can get the list of
|
||||
locales supported by your system for your language by running the
|
||||
command `locale -a | grep '^LL''.
|
||||
|
||||
Not all programs have translations for all languages. By default, an
|
||||
English message is shown in place of a nonexistent translation. If you
|
||||
understand other languages, you can set up a priority list of languages.
|
||||
This is done through a different environment variable, called
|
||||
`LANGUAGE'. GNU `gettext' gives preference to `LANGUAGE' over `LANG'
|
||||
for the purpose of message handling, but you still need to have `LANG'
|
||||
set to the primary language; this is required by other parts of the
|
||||
system libraries. For example, some Swedish users who would rather
|
||||
read translations in German than English for when Swedish is not
|
||||
available, set `LANGUAGE' to `sv:de' while leaving `LANG' to `sv_SE'.
|
||||
|
||||
Special advice for Norwegian users: The language code for Norwegian
|
||||
bokma*l changed from `no' to `nb' recently (in 2003). During the
|
||||
transition period, while some message catalogs for this language are
|
||||
installed under `nb' and some older ones under `no', it's recommended
|
||||
for Norwegian users to set `LANGUAGE' to `nb:no' so that both newer and
|
||||
older translations are used.
|
||||
|
||||
In the `LANGUAGE' environment variable, but not in the `LANG'
|
||||
environment variable, `LL_CC' combinations can be abbreviated as `LL'
|
||||
to denote the language's main dialect. For example, `de' is equivalent
|
||||
to `de_DE' (German as spoken in Germany), and `pt' to `pt_PT'
|
||||
(Portuguese as spoken in Portugal) in this context.
|
||||
|
||||
1.4 Translating Teams
|
||||
=====================
|
||||
|
||||
For the Free Translation Project to be a success, we need interested
|
||||
people who like their own language and write it well, and who are also
|
||||
able to synergize with other translators speaking the same language.
|
||||
Each translation team has its own mailing list. The up-to-date list of
|
||||
teams can be found at the Free Translation Project's homepage,
|
||||
`https://translationproject.org/', in the "Teams" area.
|
||||
|
||||
If you'd like to volunteer to _work_ at translating messages, you
|
||||
should become a member of the translating team for your own language.
|
||||
The subscribing address is _not_ the same as the list itself, it has
|
||||
`-request' appended. For example, speakers of Swedish can send a
|
||||
message to `sv-request@li.org', having this message body:
|
||||
|
||||
subscribe
|
||||
|
||||
Keep in mind that team members are expected to participate
|
||||
_actively_ in translations, or at solving translational difficulties,
|
||||
rather than merely lurking around. If your team does not exist yet and
|
||||
you want to start one, or if you are unsure about what to do or how to
|
||||
get started, please write to `coordinator@translationproject.org' to
|
||||
reach the coordinator for all translator teams.
|
||||
|
||||
The English team is special. It works at improving and uniformizing
|
||||
the terminology in use. Proven linguistic skills are praised more than
|
||||
programming skills, here.
|
||||
|
||||
1.5 Available Packages
|
||||
======================
|
||||
The translation matrix previously here was badly outdated and has been removed.
|
||||
The most up-to-date matrix with full percentage details can be found at:
|
||||
`https://translationproject.org/extra/matrix.html'
|
||||
The translation project homepage:
|
||||
`https://translationproject.org/html/welcome.html'
|
||||
|
||||
1.6 Using `gettext' in new packages
|
||||
===================================
|
||||
|
||||
If you are writing a freely available program and want to
|
||||
internationalize it you are welcome to use GNU `gettext' in your
|
||||
package. Of course you have to respect the GNU Library General Public
|
||||
License which covers the use of the GNU `gettext' library. This means
|
||||
in particular that even non-free programs can use `libintl' as a shared
|
||||
library, whereas only free software can use `libintl' as a static
|
||||
library or use modified versions of `libintl'.
|
||||
|
||||
Once the sources are changed appropriately and the setup can handle
|
||||
the use of `gettext' the only thing missing are the translations. The
|
||||
Free Translation Project is also available for packages which are not
|
||||
developed inside the GNU project. Therefore the information given above
|
||||
applies also for every other Free Software Project. Contact
|
||||
`coordinator@translationproject.org' to make the `.pot' files available
|
||||
to the translation teams.
|
||||
|
||||
<https://www.gnu.org/software/gettext/manual/html_node/Users.html>
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ Prerequisites
|
|||
GTK+ requires the following packages:
|
||||
|
||||
- The GLib, Pango, GdkPixbuf, ATK and cairo libraries, available at the same
|
||||
location as GTK+. GTK+ @GTK_VERSION@ requires at least GLib 2.28.0,
|
||||
Pango 1.20, GdkPixbuf 2.21.0, ATK 1.29.2 and cairo 1.6.0.
|
||||
location as GTK+. GTK+ @GTK_VERSION@ requires at least GLib 2.38.0,
|
||||
Pango 1.22, GdkPixbuf 2.21.0, ATK 1.29.2, cairo 1.6 and FriBidi 0.19.2.
|
||||
|
||||
- gobject-introspection 0.9.3 or newer.
|
||||
|
||||
|
|
|
|||
|
|
@ -31,10 +31,17 @@ XVFB_START = \
|
|||
|
||||
# test: run all tests in cwd and subdirs
|
||||
test: test-cwd test-recurse
|
||||
# test-cwd: run tests in cwd
|
||||
# test-cwd: run tests in cwd, each one itself with TAP output, as
|
||||
# gtester is deprecated since GLib 2.62 (the reports below still use it)
|
||||
test-cwd: ${TEST_PROGS}
|
||||
@$(SKIP_GDKTARGET) || test -z "${TEST_PROGS}" || { \
|
||||
$(XVFB_START) && { set -e; $(TESTS_ENVIRONMENT) ${GTESTER} --verbose ${TEST_PROGS}; }; \
|
||||
$(XVFB_START) && { \
|
||||
failed= ; \
|
||||
for prog in ${TEST_PROGS} ; do \
|
||||
$(TESTS_ENVIRONMENT) ./$$prog --tap || failed="$$failed $$prog" ; \
|
||||
done ; \
|
||||
test -z "$$failed" || { echo "Gtk+Tests:ERROR: failed:$$failed" ; exit 1 ; } ; \
|
||||
}; \
|
||||
}
|
||||
# test-recurse: run tests in subdirs
|
||||
test-recurse:
|
||||
|
|
|
|||
|
|
@ -150,12 +150,6 @@
|
|||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if sys/sysinfo.h is available */
|
||||
/* #undef HAVE_SYS_SYSINFO_H */
|
||||
|
||||
/* Define to 1 if sys/systeminfo.h is available */
|
||||
/* #undef HAVE_SYS_SYSTEMINFO_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#ifndef _MSC_VER
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
|
|
@ -280,12 +274,6 @@
|
|||
/* Whether to load modules via .la files rather than directly */
|
||||
/* #undef USE_LA_MODULES */
|
||||
|
||||
/* Define to 1 if medialib is available and should be used */
|
||||
/* #undef USE_MEDIALIB */
|
||||
|
||||
/* Define to 1 if medialib 2.5 is available */
|
||||
/* #undef USE_MEDIALIB25 */
|
||||
|
||||
/* Define to 1 if XXM is available and should be used */
|
||||
#ifndef _MSC_VER
|
||||
# define USE_MMX 1
|
||||
|
|
|
|||
124
config.rpath
124
config.rpath
|
|
@ -2,7 +2,7 @@
|
|||
# Output a system dependent set of variables, describing how to set the
|
||||
# run time search path of shared libraries in an executable.
|
||||
#
|
||||
# Copyright 1996-2010 Free Software Foundation, Inc.
|
||||
# Copyright 1996-2024 Free Software Foundation, Inc.
|
||||
# Taken from GNU libtool, 2001
|
||||
# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
|
||||
#
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
# known workaround is to choose shorter directory names for the build
|
||||
# directory and/or the installation directory.
|
||||
|
||||
# All known linkers require a `.a' archive for static linking (except MSVC,
|
||||
# All known linkers require a '.a' archive for static linking (except MSVC,
|
||||
# which needs '.lib').
|
||||
libext=a
|
||||
shrext=.so
|
||||
|
|
@ -57,13 +57,6 @@ else
|
|||
aix*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
darwin*)
|
||||
case $cc_basename in
|
||||
xlc*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
mingw* | cygwin* | pw32* | os2* | cegcc*)
|
||||
;;
|
||||
hpux9* | hpux10* | hpux11*)
|
||||
|
|
@ -72,9 +65,7 @@ else
|
|||
irix5* | irix6* | nonstopux*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
newsos6)
|
||||
;;
|
||||
linux* | k*bsd*-gnu)
|
||||
linux* | k*bsd*-gnu | kopensolaris*-gnu)
|
||||
case $cc_basename in
|
||||
ecc*)
|
||||
wl='-Wl,'
|
||||
|
|
@ -85,17 +76,26 @@ else
|
|||
lf95*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
pgcc | pgf77 | pgf90)
|
||||
nagfor*)
|
||||
wl='-Wl,-Wl,,'
|
||||
;;
|
||||
pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
ccc*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
xl* | bgxl* | bgf* | mpixl*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
como)
|
||||
wl='-lopt='
|
||||
;;
|
||||
*)
|
||||
case `$CC -V 2>&1 | sed 5q` in
|
||||
*Sun\ F* | *Sun*Fortran*)
|
||||
wl=
|
||||
;;
|
||||
*Sun\ C*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
|
|
@ -103,13 +103,24 @@ else
|
|||
;;
|
||||
esac
|
||||
;;
|
||||
newsos6)
|
||||
;;
|
||||
*nto* | *qnx*)
|
||||
;;
|
||||
osf3* | osf4* | osf5*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
rdos*)
|
||||
;;
|
||||
solaris*)
|
||||
wl='-Wl,'
|
||||
case $cc_basename in
|
||||
f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
|
||||
wl='-Qoption ld '
|
||||
;;
|
||||
*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
sunos4*)
|
||||
wl='-Qoption ld '
|
||||
|
|
@ -171,15 +182,14 @@ if test "$with_gnu_ld" = yes; then
|
|||
fi
|
||||
;;
|
||||
amigaos*)
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
hardcode_minus_L=yes
|
||||
# Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
|
||||
# that the semantics of dynamic libraries on AmigaOS, at least up
|
||||
# to version 4, is to share data among multiple programs linked
|
||||
# with the same dynamic library. Since this doesn't match the
|
||||
# behavior of shared libraries on other platforms, we cannot use
|
||||
# them.
|
||||
ld_shlibs=no
|
||||
case "$host_cpu" in
|
||||
powerpc)
|
||||
;;
|
||||
m68k)
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
hardcode_minus_L=yes
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
beos*)
|
||||
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
|
||||
|
|
@ -198,11 +208,13 @@ if test "$with_gnu_ld" = yes; then
|
|||
ld_shlibs=no
|
||||
fi
|
||||
;;
|
||||
haiku*)
|
||||
;;
|
||||
interix[3-9]*)
|
||||
hardcode_direct=no
|
||||
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
|
||||
;;
|
||||
gnu* | linux* | k*bsd*-gnu)
|
||||
gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
|
||||
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
|
||||
:
|
||||
else
|
||||
|
|
@ -325,10 +337,14 @@ else
|
|||
fi
|
||||
;;
|
||||
amigaos*)
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
hardcode_minus_L=yes
|
||||
# see comment about different semantics on the GNU ld section
|
||||
ld_shlibs=no
|
||||
case "$host_cpu" in
|
||||
powerpc)
|
||||
;;
|
||||
m68k)
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
hardcode_minus_L=yes
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
bsdi[45]*)
|
||||
;;
|
||||
|
|
@ -342,33 +358,20 @@ else
|
|||
;;
|
||||
darwin* | rhapsody*)
|
||||
hardcode_direct=no
|
||||
if test "$GCC" = yes ; then
|
||||
if { case $cc_basename in ifort*) true;; *) test "$GCC" = yes;; esac; }; then
|
||||
:
|
||||
else
|
||||
case $cc_basename in
|
||||
xlc*)
|
||||
;;
|
||||
*)
|
||||
ld_shlibs=no
|
||||
;;
|
||||
esac
|
||||
ld_shlibs=no
|
||||
fi
|
||||
;;
|
||||
dgux*)
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
;;
|
||||
freebsd1*)
|
||||
ld_shlibs=no
|
||||
;;
|
||||
freebsd2.2*)
|
||||
hardcode_libdir_flag_spec='-R$libdir'
|
||||
hardcode_direct=yes
|
||||
;;
|
||||
freebsd2*)
|
||||
freebsd2.[01]*)
|
||||
hardcode_direct=yes
|
||||
hardcode_minus_L=yes
|
||||
;;
|
||||
freebsd* | dragonfly*)
|
||||
freebsd* | dragonfly* | midnightbsd*)
|
||||
hardcode_libdir_flag_spec='-R$libdir'
|
||||
hardcode_direct=yes
|
||||
;;
|
||||
|
|
@ -420,6 +423,8 @@ else
|
|||
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
|
||||
hardcode_libdir_separator=:
|
||||
;;
|
||||
*nto* | *qnx*)
|
||||
;;
|
||||
openbsd*)
|
||||
if test -f /usr/libexec/ld.so; then
|
||||
hardcode_direct=yes
|
||||
|
|
@ -515,7 +520,12 @@ case "$host_os" in
|
|||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
amigaos*)
|
||||
library_names_spec='$libname.a'
|
||||
case "$host_cpu" in
|
||||
powerpc*)
|
||||
library_names_spec='$libname$shrext' ;;
|
||||
m68k)
|
||||
library_names_spec='$libname.a' ;;
|
||||
esac
|
||||
;;
|
||||
beos*)
|
||||
library_names_spec='$libname$shrext'
|
||||
|
|
@ -534,19 +544,18 @@ case "$host_os" in
|
|||
dgux*)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
freebsd1*)
|
||||
freebsd[23].*)
|
||||
library_names_spec='$libname$shrext$versuffix'
|
||||
;;
|
||||
freebsd* | dragonfly*)
|
||||
case "$host_os" in
|
||||
freebsd[123]*)
|
||||
library_names_spec='$libname$shrext$versuffix' ;;
|
||||
*)
|
||||
library_names_spec='$libname$shrext' ;;
|
||||
esac
|
||||
freebsd* | dragonfly* | midnightbsd*)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
gnu*)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
haiku*)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
hpux9* | hpux10* | hpux11*)
|
||||
case $host_cpu in
|
||||
ia64*)
|
||||
|
|
@ -582,7 +591,7 @@ case "$host_os" in
|
|||
;;
|
||||
linux*oldld* | linux*aout* | linux*coff*)
|
||||
;;
|
||||
linux* | k*bsd*-gnu)
|
||||
linux* | k*bsd*-gnu | kopensolaris*-gnu)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
knetbsd*-gnu)
|
||||
|
|
@ -594,7 +603,7 @@ case "$host_os" in
|
|||
newsos6)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
nto-qnx*)
|
||||
*nto* | *qnx*)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
openbsd*)
|
||||
|
|
@ -625,6 +634,9 @@ case "$host_os" in
|
|||
sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
tpf*)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
uts4*)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
|
|
|
|||
250
configure.ac
250
configure.ac
|
|
@ -13,8 +13,8 @@ AC_PREREQ(2.62)
|
|||
|
||||
m4_define([gtk_major_version], [2])
|
||||
m4_define([gtk_minor_version], [24])
|
||||
m4_define([gtk_micro_version], [33])
|
||||
m4_define([gtk_interface_age], [33])
|
||||
m4_define([gtk_micro_version], [34])
|
||||
m4_define([gtk_interface_age], [34])
|
||||
m4_define([gtk_binary_age],
|
||||
[m4_eval(100 * gtk_minor_version + gtk_micro_version)])
|
||||
m4_define([gtk_version],
|
||||
|
|
@ -32,6 +32,8 @@ m4_define([gtk_api_version], [2.0])
|
|||
m4_define([gtk_binary_version], [2.10.0])
|
||||
|
||||
# required versions of other packages
|
||||
# What the code needs, no more: newer API is used only where a version
|
||||
# check allows it (GLib 2.38 for g_file_trash_async)
|
||||
m4_define([glib_required_version], [2.38.0])
|
||||
m4_define([pango_required_version], [1.22])
|
||||
m4_define([atk_required_version], [1.29.2])
|
||||
|
|
@ -250,6 +252,10 @@ AC_ARG_ENABLE(xrandr,
|
|||
[AS_HELP_STRING([--enable-xrandr],
|
||||
[support XRandR extension if available [default=yes]])],,
|
||||
[enable_xrandr="yes"])
|
||||
AC_ARG_ENABLE(xinput2,
|
||||
[AS_HELP_STRING([--enable-xinput2],
|
||||
[smooth scrolling with XInput 2.1 if available [default=yes]])],,
|
||||
[enable_xinput2="yes"])
|
||||
AC_ARG_ENABLE(xfixes,
|
||||
[AS_HELP_STRING([--enable-xfixes],
|
||||
[support XFixes extension if available [default=yes]])],,
|
||||
|
|
@ -347,6 +353,25 @@ changequote([,])dnl
|
|||
|
||||
CPPFLAGS="$CPPFLAGS -DG_DISABLE_SINGLE_INCLUDES -DATK_DISABLE_SINGLE_INCLUDES -DGDK_PIXBUF_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_SINGLE_INCLUDES"
|
||||
|
||||
# A 64-bit time_t on 32-bit Windows: msvcrt.dll has had the 64-bit time
|
||||
# functions since Windows 2000 (so XP and ReactOS have them), but MinGW
|
||||
# keeps time_t at 32 bits there unless asked. It changes the ABI of the
|
||||
# time_t functions of GtkRecentInfo, so programs must be built the same
|
||||
# way; gtk+-2.0.pc passes the flag on. The _unix functions of
|
||||
# GtkRecentInfo give 64-bit times either way.
|
||||
AC_ARG_ENABLE(win32-time64,
|
||||
[AS_HELP_STRING([--enable-win32-time64],
|
||||
[on 32-bit Windows, build with a 64-bit time_t (changes the ABI of the time_t functions of GtkRecentInfo) [default=no]])],,
|
||||
[enable_win32_time64=no])
|
||||
win32_time64_cflags=
|
||||
if test x"$os_win32" = xyes && test x"$enable_win32_time64" = xyes; then
|
||||
case "$host" in
|
||||
x86_64-*|aarch64-*) ;;
|
||||
*) win32_time64_cflags='-D__MINGW_USE_VC2005_COMPAT'
|
||||
CFLAGS="$CFLAGS $win32_time64_cflags" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Ensure MSVC-compatible struct packing convention is used when
|
||||
# compiling for Win32 with gcc.
|
||||
# What flag to depends on gcc version: gcc3 uses "-mms-bitfields", while
|
||||
|
|
@ -477,6 +502,162 @@ AC_SUBST(REBUILD)
|
|||
AC_CHECK_FUNCS(lstat mkstemp flockfile getc_unlocked _getc_nolock)
|
||||
AC_CHECK_FUNCS(localtime_r)
|
||||
|
||||
#
|
||||
# Vector instructions for GdkRGB. Each instruction set has a file of its
|
||||
# own, compiled with the flags found here; CPUs without it are told apart
|
||||
# at run time (getauxval() or elf_aux_info() where cpuid doesn't). Only
|
||||
# the sets of the CPU family built for are built, and not those a set
|
||||
# the build may take for granted does entirely: no MMX where SSE2 is
|
||||
# there anyway (x86-64, or -msse2 and later in CFLAGS), no ARMv6 where
|
||||
# NEON is (AArch64, or -mfpu=neon).
|
||||
#
|
||||
AC_CHECK_FUNCS(getauxval elf_aux_info)
|
||||
|
||||
dnl GTK_CHECK_SIMD_FLAGS(NAME, FLAGS|OTHER FLAGS, PROLOGUE, BODY):
|
||||
dnl sets NAME_CFLAGS to the first flags the test compiles with (which may
|
||||
dnl be none), and gtk_have_NAME to yes if there are such flags
|
||||
AC_DEFUN([GTK_CHECK_SIMD_FLAGS],
|
||||
[AC_MSG_CHECKING([for flags to compile $1 code])
|
||||
$1_CFLAGS=
|
||||
gtk_have_$1=no
|
||||
gtk_save_CFLAGS="$CFLAGS"
|
||||
gtk_simd_list='$2'
|
||||
gtk_save_IFS="$IFS"
|
||||
IFS='|'
|
||||
for gtk_simd_flags in $gtk_simd_list; do
|
||||
IFS="$gtk_save_IFS"
|
||||
CFLAGS="$gtk_save_CFLAGS $gtk_simd_flags"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$3]], [[$4]])],
|
||||
[$1_CFLAGS="$gtk_simd_flags"
|
||||
gtk_have_$1=yes
|
||||
break])
|
||||
done
|
||||
IFS="$gtk_save_IFS"
|
||||
CFLAGS="$gtk_save_CFLAGS"
|
||||
if test "x$gtk_have_$1" = xyes; then
|
||||
AC_MSG_RESULT([${$1_CFLAGS:-none needed}])
|
||||
else
|
||||
AC_MSG_RESULT([not possible])
|
||||
fi
|
||||
AC_SUBST($1_CFLAGS)])
|
||||
|
||||
MMX_CFLAGS=
|
||||
SSE2_CFLAGS=
|
||||
SSSE3_CFLAGS=
|
||||
AVX2_CFLAGS=
|
||||
ALTIVEC_CFLAGS=
|
||||
ARMV6_CFLAGS=
|
||||
NEON_CFLAGS=
|
||||
for gtk_set in MMX SSE2 SSSE3 AVX2 ALTIVEC ARMV6 NEON; do
|
||||
eval gtk_have_$gtk_set=no
|
||||
done
|
||||
case "$host_cpu" in
|
||||
i?86|x86_64|amd64)
|
||||
AC_MSG_CHECKING([whether the build may take SSE2 for granted])
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if !defined(__SSE2__) && !defined(__x86_64__)
|
||||
#error not for granted
|
||||
#endif]], [])],
|
||||
[gtk_base_sse2=yes], [gtk_base_sse2=no])
|
||||
AC_MSG_RESULT([$gtk_base_sse2])
|
||||
if test "x$gtk_base_sse2" = xno; then
|
||||
GTK_CHECK_SIMD_FLAGS([MMX], [-mmmx],
|
||||
[#include <mmintrin.h>
|
||||
#ifndef __MMX__
|
||||
#error no MMX
|
||||
#endif],
|
||||
[__m64 v = _mm_setzero_si64 (); v = _mm_mullo_pi16 (v, v); _mm_empty ();])
|
||||
fi
|
||||
GTK_CHECK_SIMD_FLAGS([SSE2], [-msse2],
|
||||
[#include <emmintrin.h>
|
||||
#ifndef __SSE2__
|
||||
#error no SSE2
|
||||
#endif],
|
||||
[__m128i v = _mm_setzero_si128 (); v = _mm_mullo_epi16 (v, v); (void) v;])
|
||||
GTK_CHECK_SIMD_FLAGS([SSSE3], [-mssse3],
|
||||
[#include <tmmintrin.h>
|
||||
#ifndef __SSSE3__
|
||||
#error no SSSE3
|
||||
#endif],
|
||||
[__m128i v = _mm_setzero_si128 (); v = _mm_shuffle_epi8 (v, v); (void) v;])
|
||||
dnl not with MinGW: GCC does not align its stack for AVX there (GCC
|
||||
dnl bug 54412), and unoptimized builds would crash on spills
|
||||
case "$host_os" in
|
||||
mingw*|cygwin*) ;;
|
||||
*)
|
||||
GTK_CHECK_SIMD_FLAGS([AVX2], [-mavx2],
|
||||
[#include <immintrin.h>
|
||||
#ifndef __AVX2__
|
||||
#error no AVX2
|
||||
#endif],
|
||||
[__m256i v = _mm256_setzero_si256 (); v = _mm256_shuffle_epi8 (v, v); (void) v;])
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
powerpc*|ppc*)
|
||||
GTK_CHECK_SIMD_FLAGS([ALTIVEC], [-maltivec],
|
||||
[#include <altivec.h>
|
||||
#if !defined(__ALTIVEC__) || !defined(__BIG_ENDIAN__)
|
||||
#error no big endian AltiVec
|
||||
#endif],
|
||||
[vector unsigned short v = vec_splats ((unsigned short) 1); v = vec_mladd (v, v, v); (void) v;])
|
||||
;;
|
||||
arm*)
|
||||
AC_MSG_CHECKING([whether the build may take NEON for granted])
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if !defined(__ARM_NEON) && !defined(__ARM_NEON__)
|
||||
#error not for granted
|
||||
#endif]], [])],
|
||||
[gtk_base_neon=yes], [gtk_base_neon=no])
|
||||
AC_MSG_RESULT([$gtk_base_neon])
|
||||
dnl the media instructions of ARMv6, for builds for older ARMs too
|
||||
if test "x$gtk_base_neon" = xno; then
|
||||
GTK_CHECK_SIMD_FLAGS([ARMV6], [|-march=armv6],
|
||||
[#if !defined(__ARM_ARCH_6__) && !(defined(__ARM_ARCH) && __ARM_ARCH >= 6)
|
||||
#error no ARMv6
|
||||
#endif
|
||||
#if defined(__ARMEB__) || (defined(__thumb__) && !defined(__thumb2__))
|
||||
#error no little endian ARM code
|
||||
#endif],
|
||||
[unsigned int r, x = 1; __asm__ ("uxtab16 %0, %1, %2, ror #8" : "=r" (r) : "r" (x), "r" (x)); (void) r;])
|
||||
fi
|
||||
dnl toolchains for the Raspberry Pi 1 default to ARMv6, which has no NEON
|
||||
GTK_CHECK_SIMD_FLAGS([NEON], [-mfpu=neon|-march=armv7-a -mfpu=neon],
|
||||
[#include <arm_neon.h>
|
||||
#if (!defined(__ARM_NEON) && !defined(__ARM_NEON__)) || defined(__ARM_BIG_ENDIAN)
|
||||
#error no little endian NEON
|
||||
#endif],
|
||||
[uint8x8x4_t v = vld4_u8 ((const unsigned char *) 0); (void) v;])
|
||||
;;
|
||||
aarch64*|arm64*)
|
||||
dnl always there
|
||||
GTK_CHECK_SIMD_FLAGS([NEON], [],
|
||||
[#include <arm_neon.h>
|
||||
#if !defined(__ARM_NEON) || defined(__ARM_BIG_ENDIAN)
|
||||
#error no little endian NEON
|
||||
#endif],
|
||||
[uint8x8x4_t v = vld4_u8 ((const unsigned char *) 0); (void) v;])
|
||||
;;
|
||||
esac
|
||||
|
||||
for gtk_set in MMX SSE2 SSSE3 AVX2 ALTIVEC ARMV6 NEON; do
|
||||
if eval test "x\$gtk_have_$gtk_set" = xyes; then
|
||||
AC_DEFINE_UNQUOTED([GDK_RGB_SIMD_$gtk_set], [1])
|
||||
fi
|
||||
done
|
||||
AH_TEMPLATE([GDK_RGB_SIMD_MMX], [Define to build the MMX code of GdkRGB])
|
||||
AH_TEMPLATE([GDK_RGB_SIMD_SSE2], [Define to build the SSE2 code of GdkRGB])
|
||||
AH_TEMPLATE([GDK_RGB_SIMD_SSSE3], [Define to build the SSSE3 code of GdkRGB])
|
||||
AH_TEMPLATE([GDK_RGB_SIMD_AVX2], [Define to build the AVX2 code of GdkRGB])
|
||||
AH_TEMPLATE([GDK_RGB_SIMD_ALTIVEC], [Define to build the AltiVec code of GdkRGB])
|
||||
AH_TEMPLATE([GDK_RGB_SIMD_ARMV6], [Define to build the ARMv6 code of GdkRGB])
|
||||
AH_TEMPLATE([GDK_RGB_SIMD_NEON], [Define to build the NEON code of GdkRGB])
|
||||
AM_CONDITIONAL(GDK_RGB_SIMD_MMX, test "x$gtk_have_MMX" = xyes)
|
||||
AM_CONDITIONAL(GDK_RGB_SIMD_SSE2, test "x$gtk_have_SSE2" = xyes)
|
||||
AM_CONDITIONAL(GDK_RGB_SIMD_SSSE3, test "x$gtk_have_SSSE3" = xyes)
|
||||
AM_CONDITIONAL(GDK_RGB_SIMD_AVX2, test "x$gtk_have_AVX2" = xyes)
|
||||
AM_CONDITIONAL(GDK_RGB_SIMD_ALTIVEC, test "x$gtk_have_ALTIVEC" = xyes)
|
||||
AM_CONDITIONAL(GDK_RGB_SIMD_ARMV6, test "x$gtk_have_ARMV6" = xyes)
|
||||
AM_CONDITIONAL(GDK_RGB_SIMD_NEON, test "x$gtk_have_NEON" = xyes)
|
||||
|
||||
# _NL_TIME_FIRST_WEEKDAY is an enum and not a define
|
||||
AC_MSG_CHECKING([for _NL_TIME_FIRST_WEEKDAY])
|
||||
AC_LINK_IFELSE(
|
||||
|
|
@ -552,8 +733,11 @@ if test "$gtk_ok" = "yes"; then
|
|||
[Define to 1 if sigsetjmp is available])
|
||||
fi
|
||||
|
||||
# i18n stuff
|
||||
AM_GNU_GETTEXT_VERSION([0.19.3])
|
||||
# i18n stuff: the macros in m4/ and the po/ Makefiles are from gettext
|
||||
# 0.22.5; autopoint 0.19.6 and later brings those of the gettext that
|
||||
# is installed, older ones those of the version given here
|
||||
AM_GNU_GETTEXT_VERSION([0.20])
|
||||
AM_GNU_GETTEXT_REQUIRE_VERSION([0.20])
|
||||
AM_GNU_GETTEXT([external])
|
||||
LIBS="$LIBS $LIBINTL"
|
||||
|
||||
|
|
@ -958,38 +1142,6 @@ AM_CONDITIONAL(INCLUDE_IM_XIM, [test x"$INCLUDE_xim" = xyes])
|
|||
|
||||
AC_HEADER_SYS_WAIT
|
||||
|
||||
# Checks to see whether we should include mediaLib
|
||||
# support.
|
||||
#
|
||||
AC_CHECK_HEADER(sys/systeminfo.h,
|
||||
AC_DEFINE(HAVE_SYS_SYSTEMINFO_H, 1,
|
||||
[Define to 1 if sys/systeminfo.h is available]))
|
||||
AC_CHECK_HEADER(sys/sysinfo.h,
|
||||
AC_DEFINE(HAVE_SYS_SYSINFO_H, 1,
|
||||
[Define to 1 if sys/sysinfo.h is available]))
|
||||
|
||||
AC_MSG_CHECKING(for mediaLib 2.3)
|
||||
use_mlib25=no
|
||||
# Check for a mediaLib 2.3 function since that is what the GTK+ mediaLib
|
||||
# patch requires.
|
||||
AC_CHECK_LIB(mlib, mlib_ImageSetStruct, use_mlib=yes, use_mlib=no)
|
||||
if test $use_mlib = yes; then
|
||||
AC_DEFINE(USE_MEDIALIB, 1,
|
||||
[Define to 1 if medialib is available and should be used])
|
||||
MEDIA_LIB=-lmlib
|
||||
|
||||
AC_MSG_CHECKING(for mediaLib 2.5)
|
||||
# Check for a mediaLib 2.5 function since that is what is needed for
|
||||
# gdk_rgb_convert integration.
|
||||
AC_CHECK_LIB(mlib, mlib_VideoColorRGBint_to_BGRAint, use_mlib25=yes, use_mlib25=no)
|
||||
if test $use_mlib25 = yes; then
|
||||
AC_DEFINE(USE_MEDIALIB25, 1,
|
||||
[Define to 1 if medialib 2.5 is available])
|
||||
fi
|
||||
fi
|
||||
AM_CONDITIONAL(USE_MEDIALIB, test $use_mlib = yes)
|
||||
AM_CONDITIONAL(USE_MEDIALIB25, test $use_mlib25 = yes)
|
||||
|
||||
dnl Look for a host system's gdk-pixbuf-csource if we are cross-compiling
|
||||
|
||||
AM_CONDITIONAL(CROSS_COMPILING, test $cross_compiling = yes)
|
||||
|
|
@ -1001,7 +1153,11 @@ if test $cross_compiling = yes; then
|
|||
fi
|
||||
fi
|
||||
|
||||
AC_PATH_PROG(GDK_PIXBUF_CSOURCE, gdk-pixbuf-csource, no)
|
||||
dnl the one of the build system, for the resources of demos/testpixbuf
|
||||
AC_PATH_PROG(GLIB_COMPILE_RESOURCES_FOR_BUILD, glib-compile-resources, no)
|
||||
if test x$GLIB_COMPILE_RESOURCES_FOR_BUILD = xno; then
|
||||
AC_MSG_ERROR([glib-compile-resources of GLib is needed])
|
||||
fi
|
||||
|
||||
if test ! -f $srcdir/gtk/gtkbuiltincache.h &&
|
||||
test "x$REBUILD_PNGS" = "x#" ; then
|
||||
|
|
@ -1274,6 +1430,24 @@ if test "x$gdktarget" = "xx11"; then
|
|||
|
||||
AM_CONDITIONAL(XINPUT_XFREE, test x$with_xinput = xxfree || test x$with_xinput = xyes)
|
||||
|
||||
# XInput 2.1 has the scroll valuators of high resolution wheels and
|
||||
# touchpads; it is independent of the XInput 1 devices above
|
||||
|
||||
if test "x$enable_xinput2" != "xno" && $PKG_CONFIG --exists "xi >= 1.5" ; then
|
||||
AC_DEFINE(HAVE_XINPUT2, 1, [Have XInput 2.1 for smooth scrolling])
|
||||
|
||||
# libXi 1.8 knows the touchpad gestures of XInput 2.4; whether the
|
||||
# X server has them is asked at run time
|
||||
if $PKG_CONFIG --exists "xi >= 1.8" ; then
|
||||
AC_DEFINE(HAVE_XINPUT2_GESTURES, 1, [Have libXi 1.8 for the touchpad gestures of XInput 2.4])
|
||||
fi
|
||||
|
||||
case " $X_PACKAGES " in
|
||||
*" xi "*) ;;
|
||||
*) X_PACKAGES="$X_PACKAGES xi" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Check for the RANDR extension
|
||||
if test "x$enable_xrandr" != "xno" && $PKG_CONFIG --exists "xrandr >= 1.2.99" ; then
|
||||
AC_DEFINE(HAVE_RANDR, 1, [Have the Xrandr extension library])
|
||||
|
|
@ -1478,7 +1652,7 @@ GTK_DEP_LIBS="$GDK_EXTRA_LIBS $GTK_DEP_LIBS_FOR_X `$PKG_CONFIG --libs $PANGO_PAC
|
|||
GTK_DEP_CFLAGS="`$PKG_CONFIG --cflags gthread-2.0 $GDK_PACKAGES $GTK_PACKAGES` $GDK_EXTRA_CFLAGS $GTK_EXTRA_CFLAGS"
|
||||
|
||||
if test x"$os_win32" = xyes; then
|
||||
GTK_EXTRA_CFLAGS="$msnative_struct"
|
||||
GTK_EXTRA_CFLAGS="$msnative_struct $win32_time64_cflags"
|
||||
fi
|
||||
|
||||
GLIB_PREFIX="`$PKG_CONFIG --variable=prefix glib-2.0`"
|
||||
|
|
|
|||
|
|
@ -29,16 +29,13 @@ noinst_PROGRAMS = \
|
|||
testpixbuf-scale \
|
||||
pixbuf-demo
|
||||
|
||||
# Need to build test-inline-pixbufs.h for testpixbuf
|
||||
# testpixbuf has two of the images inlined, as resources
|
||||
noinst_PROGRAMS += testpixbuf
|
||||
BUILT_SOURCES = test-inline-pixbufs.h
|
||||
BUILT_SOURCES = testpixbuf-resources.c
|
||||
|
||||
test-inline-pixbufs.h: apple-red.png gnome-foot.png
|
||||
$(GDK_PIXBUF_CSOURCE) --raw --build-list \
|
||||
apple_red $(srcdir)/apple-red.png \
|
||||
gnome_foot $(srcdir)/gnome-foot.png \
|
||||
> test-inline-pixbufs.h \
|
||||
|| (rm -f test-inline-pixbufs.h && false)
|
||||
testpixbuf-resources.c: testpixbuf.gresource.xml apple-red.png gnome-foot.png
|
||||
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES_FOR_BUILD) --target=$@ --sourcedir=$(srcdir) \
|
||||
--generate-source --c-name testpixbuf $(srcdir)/testpixbuf.gresource.xml
|
||||
|
||||
testpixbuf_DEPENDENCIES = $(DEPS)
|
||||
testpixbuf_drawable_DEPENDENCIES = $(DEPS)
|
||||
|
|
@ -57,6 +54,7 @@ testanimation_LDADD = $(LDADDS)
|
|||
pixbuf_demo_LDADD = $(LDADDS)
|
||||
|
||||
testpixbuf_SOURCES = testpixbuf.c pixbuf-init.c
|
||||
nodist_testpixbuf_SOURCES = testpixbuf-resources.c
|
||||
testpixbuf_drawable_SOURCES = testpixbuf-drawable.c pixbuf-init.c
|
||||
testpixbuf_save_SOURCES = testpixbuf-save.c
|
||||
testpixbuf_color_SOURCES = testpixbuf-color.c
|
||||
|
|
@ -73,8 +71,9 @@ EXTRA_DIST += \
|
|||
gnome-gimp.png \
|
||||
gnome-gmush.png \
|
||||
gnome-gsame.png \
|
||||
gnu-keys.png
|
||||
gnu-keys.png \
|
||||
testpixbuf.gresource.xml
|
||||
|
||||
DISTCLEANFILES = test-inline-pixbufs.h
|
||||
DISTCLEANFILES = testpixbuf-resources.c
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
||||
|
|
|
|||
|
|
@ -466,6 +466,7 @@ do_appwindow (GtkWidget *do_widget)
|
|||
g_object_set_data_full (G_OBJECT (window), "ui-manager", merge,
|
||||
g_object_unref);
|
||||
gtk_ui_manager_insert_action_group (merge, action_group, 0);
|
||||
g_object_unref (action_group);
|
||||
gtk_window_add_accel_group (GTK_WINDOW (window),
|
||||
gtk_ui_manager_get_accel_group (merge));
|
||||
|
||||
|
|
|
|||
|
|
@ -194,6 +194,8 @@ do_assistant (GtkWidget *do_widget)
|
|||
create_page3 (assistant);
|
||||
create_page4 (assistant);
|
||||
|
||||
g_signal_connect (assistant, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed), &assistant);
|
||||
g_signal_connect (G_OBJECT (assistant), "cancel",
|
||||
G_CALLBACK (on_assistant_close_cancel), &assistant);
|
||||
g_signal_connect (G_OBJECT (assistant), "close",
|
||||
|
|
|
|||
|
|
@ -27,6 +27,19 @@ about_activate (GtkAction *action)
|
|||
gtk_widget_hide (about_dlg);
|
||||
}
|
||||
|
||||
/* the about dialog and the builder go with the window */
|
||||
static void
|
||||
window_destroyed (GtkWidget *window,
|
||||
gpointer user_data)
|
||||
{
|
||||
GObject *about_dlg = gtk_builder_get_object (builder, "aboutdialog1");
|
||||
|
||||
if (about_dlg)
|
||||
gtk_widget_destroy (GTK_WIDGET (about_dlg));
|
||||
g_object_unref (builder);
|
||||
builder = NULL;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_builder (GtkWidget *do_widget)
|
||||
{
|
||||
|
|
@ -51,6 +64,8 @@ do_builder (GtkWidget *do_widget)
|
|||
gtk_widget_get_screen (do_widget));
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed), &window);
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (window_destroyed), NULL);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
|
|
|
|||
|
|
@ -389,6 +389,8 @@ do_images (GtkWidget *do_widget)
|
|||
}
|
||||
|
||||
image = gtk_image_new_from_pixbuf (pixbuf);
|
||||
if (pixbuf)
|
||||
g_object_unref (pixbuf);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (frame), image);
|
||||
|
||||
|
|
|
|||
|
|
@ -216,6 +216,14 @@ window_closed (GtkWidget *widget,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/* destroyed without being closed, the spinner must stop all the same */
|
||||
static void
|
||||
window_destroyed (GtkWidget *widget,
|
||||
gpointer user_data)
|
||||
{
|
||||
window_closed (widget, NULL, user_data);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_list_store (GtkWidget *do_widget)
|
||||
{
|
||||
|
|
@ -233,7 +241,7 @@ do_list_store (GtkWidget *do_widget)
|
|||
gtk_window_set_title (GTK_WINDOW (window), "GtkListStore demo");
|
||||
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed), &window);
|
||||
G_CALLBACK (window_destroyed), NULL);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (window), 8);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 8);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
#include <gtk/gtk.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
|
||||
#include "test-inline-pixbufs.h"
|
||||
|
||||
typedef struct {
|
||||
FILE *imagefile;
|
||||
|
|
@ -518,6 +517,37 @@ void size_func (GdkPixbufLoader *loader, gint width, gint height, gpointer data)
|
|||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
have_format (const gchar *name)
|
||||
{
|
||||
GSList *formats = gdk_pixbuf_get_formats (), *l;
|
||||
gboolean found = FALSE;
|
||||
|
||||
for (l = formats; l && !found; l = l->next)
|
||||
found = strcmp (gdk_pixbuf_format_get_name (l->data), name) == 0;
|
||||
g_slist_free (formats);
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
/* one of the images inlined in testpixbuf-resources.c */
|
||||
static GdkPixbuf *
|
||||
pixbuf_from_resource (const char *name, GError **error)
|
||||
{
|
||||
gchar *path = g_strconcat ("/org/gtk/testpixbuf/", name, NULL);
|
||||
GInputStream *stream = g_resources_open_stream (path, 0, error);
|
||||
GdkPixbuf *pixbuf = NULL;
|
||||
|
||||
if (stream)
|
||||
{
|
||||
pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, error);
|
||||
g_object_unref (stream);
|
||||
}
|
||||
g_free (path);
|
||||
|
||||
return pixbuf;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
|
|
@ -561,7 +591,8 @@ main (int argc, char **argv)
|
|||
NULL, NULL);
|
||||
new_testrgb_window (pixbuf, NULL);
|
||||
|
||||
xpmp = xpms;
|
||||
/* newer gdk-pixbuf may come without the XPM loader */
|
||||
xpmp = have_format ("xpm") ? xpms : xpms + G_N_ELEMENTS (xpms) - 1;
|
||||
while (*xpmp) {
|
||||
pixbuf = gdk_pixbuf_new_from_xpm_data (*xpmp);
|
||||
new_testrgb_window (pixbuf, NULL);
|
||||
|
|
@ -569,7 +600,7 @@ main (int argc, char **argv)
|
|||
}
|
||||
|
||||
/* Test loading from inline data. */
|
||||
pixbuf = gdk_pixbuf_new_from_inline (-1, apple_red, FALSE, &error);
|
||||
pixbuf = pixbuf_from_resource ("apple-red.png", &error);
|
||||
if (!pixbuf)
|
||||
{
|
||||
fprintf (stderr, "failed to construct \"red apple\" pixbuf: %s\n",
|
||||
|
|
@ -577,10 +608,11 @@ main (int argc, char **argv)
|
|||
g_error_free (error);
|
||||
}
|
||||
else
|
||||
new_testrgb_window (pixbuf, "Red apple from inlined RLE data");
|
||||
new_testrgb_window (pixbuf, "Red apple from inlined PNG data");
|
||||
|
||||
pixbuf = gdk_pixbuf_new_from_inline (sizeof (gnome_foot), gnome_foot, TRUE, NULL);
|
||||
new_testrgb_window (pixbuf, "GNOME Foot from inlined RLE data");
|
||||
pixbuf = pixbuf_from_resource ("gnome-foot.png", NULL);
|
||||
if (pixbuf)
|
||||
new_testrgb_window (pixbuf, "GNOME Foot from inlined PNG data");
|
||||
|
||||
found_valid = TRUE;
|
||||
} else {
|
||||
|
|
|
|||
7
demos/testpixbuf.gresource.xml
Normal file
7
demos/testpixbuf.gresource.xml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gresources>
|
||||
<gresource prefix="/org/gtk/testpixbuf">
|
||||
<file>apple-red.png</file>
|
||||
<file>gnome-foot.png</file>
|
||||
</gresource>
|
||||
</gresources>
|
||||
|
|
@ -1174,6 +1174,8 @@ gdk_get_show_events
|
|||
gdk_set_show_events
|
||||
gdk_event_set_screen
|
||||
gdk_event_get_screen
|
||||
gdk_event_get_scroll_deltas
|
||||
gdk_event_get_pointer_emulated
|
||||
|
||||
<SUBSECTION>
|
||||
gdk_setting_get
|
||||
|
|
|
|||
|
|
@ -34,13 +34,6 @@ created in grayscale and direct color modes, and the visual is changed
|
|||
in cases where a "better" visual than the default is available.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
If GDK is built with the Sun mediaLib library, the GdkRGB functions are
|
||||
accelerated using mediaLib, which provides hardware acceleration on Intel,
|
||||
AMD, and Sparc chipsets. If desired, mediaLib support can be turned off
|
||||
by setting the GDK_DISABLE_MEDIALIB environment variable.
|
||||
</para>
|
||||
|
||||
<example>
|
||||
<title>A simple example program using GdkRGB</title>
|
||||
<programlisting>
|
||||
|
|
|
|||
|
|
@ -407,6 +407,33 @@ nevertheless.
|
|||
</para>
|
||||
</formalpara>
|
||||
|
||||
<formalpara>
|
||||
<title><envar>GDK_CORE_DEVICE_EVENTS</envar></title>
|
||||
|
||||
<para>
|
||||
If set, GDK does not use XInput 2.1 and scrolls only by whole
|
||||
wheel steps, as before smooth scrolling.
|
||||
</para>
|
||||
</formalpara>
|
||||
|
||||
<formalpara>
|
||||
<title><envar>GDK_DISABLE_SIMD</envar>, <envar>GDK_RGB_SIMD</envar></title>
|
||||
|
||||
<para>
|
||||
GDK converts and blends pixels with the vector instructions of the
|
||||
CPU where it has them (MMX, the integer part of SSE, 3DNow!, SSE2, SSSE3,
|
||||
AltiVec, NEON), with the same results as its C code. If
|
||||
<envar>GDK_DISABLE_SIMD</envar> is set to anything but 0, only the
|
||||
C code is used. <envar>GDK_RGB_SIMD</envar> chooses by hand, to
|
||||
compare: <literal>c</literal> for none, the name of an instruction
|
||||
set for that one, or <literal>kernel=set</literal> for a single
|
||||
kernel, several separated by commas. The program
|
||||
<command>rgbsimdbench</command> in the <filename>gdk</filename>
|
||||
directory of the sources (<literal>make rgbsimdbench</literal>)
|
||||
lists the kernels and sets and times them on the machine.
|
||||
</para>
|
||||
</formalpara>
|
||||
|
||||
<formalpara>
|
||||
<title><envar>XDG_DATA_HOME</envar>, <envar>XDG_DATA_DIRS</envar></title>
|
||||
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ create_shadow (GdkPixbuf *src)
|
|||
{
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
int sumr = 0, sumg = 0, sumb = 0, suma = 0;
|
||||
int suma = 0;
|
||||
|
||||
for (i = 0; i < filter->size; i++)
|
||||
{
|
||||
|
|
@ -106,17 +106,7 @@ create_shadow (GdkPixbuf *src)
|
|||
src_x < 0 || src_x > gdk_pixbuf_get_width (src))
|
||||
continue;
|
||||
|
||||
sumr += src_pixels [src_y * src_rowstride +
|
||||
src_x * src_bpp + 0] *
|
||||
filter->data [i * filter->size + j];
|
||||
sumg += src_pixels [src_y * src_rowstride +
|
||||
src_x * src_bpp + 1] *
|
||||
filter->data [i * filter->size + j];
|
||||
|
||||
sumb += src_pixels [src_y * src_rowstride +
|
||||
src_x * src_bpp + 2] *
|
||||
filter->data [i * filter->size + j];
|
||||
|
||||
/* only the alpha makes the shadow */
|
||||
if (src_bpp == 4)
|
||||
suma += src_pixels [src_y * src_rowstride +
|
||||
src_x * src_bpp + 3] *
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ EXTRA_DIST += \
|
|||
gdkkeysyms-update.pl \
|
||||
gdk.def \
|
||||
gdkmarshalers.list \
|
||||
gdkmedialib.h \
|
||||
gdkwindowimpl.h \
|
||||
makeenums.pl \
|
||||
makefile.msc \
|
||||
|
|
@ -51,7 +50,7 @@ endif
|
|||
# libtool stuff: set version and export symbols for resolving
|
||||
# since automake doesn't support conditionalized libsomething_la_LDFLAGS
|
||||
# we use the general approach here
|
||||
LDADD = \
|
||||
gdk_ldflags = \
|
||||
$(GTK_LINK_FLAGS) \
|
||||
-version-info $(LT_VERSION_INFO) \
|
||||
-export-dynamic \
|
||||
|
|
@ -59,13 +58,6 @@ LDADD = \
|
|||
$(no_undefined) \
|
||||
$(LIBTOOL_EXPORT_OPTIONS)
|
||||
|
||||
if USE_MEDIALIB
|
||||
medialib_sources = \
|
||||
gdkmedialib.c
|
||||
else
|
||||
medialib_sources =
|
||||
endif
|
||||
|
||||
#
|
||||
# setup source file variables
|
||||
#
|
||||
|
|
@ -115,11 +107,11 @@ gdk_built_private_headers = \
|
|||
gdk_private_headers = \
|
||||
gdkinternals.h \
|
||||
gdkintl.h \
|
||||
gdkrgbsimd.h \
|
||||
gdkpoly-generic.h \
|
||||
gdkregion-generic.h
|
||||
|
||||
gdk_c_sources = \
|
||||
$(medialib_sources) \
|
||||
gdk.c \
|
||||
gdkapplaunchcontext.c \
|
||||
gdkcairo.c \
|
||||
|
|
@ -145,7 +137,7 @@ gdk_c_sources = \
|
|||
gdkrectangle.c \
|
||||
gdkregion-generic.c \
|
||||
gdkrgb.c \
|
||||
gdkrgb16.c \
|
||||
gdkrgbsimd.c \
|
||||
gdkscreen.c \
|
||||
gdkselection.c \
|
||||
gdkvisual.c \
|
||||
|
|
@ -174,22 +166,80 @@ common_sources = \
|
|||
gdkmarshalers.c \
|
||||
gdkmarshalers.h
|
||||
|
||||
# Vector versions of GdkRGB loops, each built with the flags of its
|
||||
# instruction set; only those configure found useful for the CPU family
|
||||
# built for.
|
||||
gdk_rgb_simd_libs =
|
||||
if GDK_RGB_SIMD_MMX
|
||||
gdk_rgb_simd_libs += libgdk-rgb-mmx.la
|
||||
endif
|
||||
if GDK_RGB_SIMD_SSE2
|
||||
gdk_rgb_simd_libs += libgdk-rgb-sse2.la
|
||||
endif
|
||||
if GDK_RGB_SIMD_SSSE3
|
||||
gdk_rgb_simd_libs += libgdk-rgb-ssse3.la
|
||||
endif
|
||||
if GDK_RGB_SIMD_AVX2
|
||||
gdk_rgb_simd_libs += libgdk-rgb-avx2.la
|
||||
endif
|
||||
if GDK_RGB_SIMD_ALTIVEC
|
||||
gdk_rgb_simd_libs += libgdk-rgb-altivec.la
|
||||
endif
|
||||
if GDK_RGB_SIMD_ARMV6
|
||||
gdk_rgb_simd_libs += libgdk-rgb-armv6.la
|
||||
endif
|
||||
if GDK_RGB_SIMD_NEON
|
||||
gdk_rgb_simd_libs += libgdk-rgb-neon.la
|
||||
endif
|
||||
noinst_LTLIBRARIES = $(gdk_rgb_simd_libs)
|
||||
EXTRA_LTLIBRARIES = \
|
||||
libgdk-rgb-mmx.la \
|
||||
libgdk-rgb-sse2.la \
|
||||
libgdk-rgb-ssse3.la \
|
||||
libgdk-rgb-avx2.la \
|
||||
libgdk-rgb-altivec.la \
|
||||
libgdk-rgb-armv6.la \
|
||||
libgdk-rgb-neon.la
|
||||
|
||||
libgdk_rgb_mmx_la_SOURCES = gdkrgb-mmx.c
|
||||
libgdk_rgb_mmx_la_CFLAGS = $(MMX_CFLAGS)
|
||||
libgdk_rgb_sse2_la_SOURCES = gdkrgb-sse2.c
|
||||
libgdk_rgb_sse2_la_CFLAGS = $(SSE2_CFLAGS)
|
||||
libgdk_rgb_ssse3_la_SOURCES = gdkrgb-ssse3.c
|
||||
libgdk_rgb_ssse3_la_CFLAGS = $(SSSE3_CFLAGS)
|
||||
libgdk_rgb_avx2_la_SOURCES = gdkrgb-avx2.c
|
||||
libgdk_rgb_avx2_la_CFLAGS = $(AVX2_CFLAGS)
|
||||
libgdk_rgb_altivec_la_SOURCES = gdkrgb-altivec.c
|
||||
libgdk_rgb_altivec_la_CFLAGS = $(ALTIVEC_CFLAGS)
|
||||
libgdk_rgb_armv6_la_SOURCES = gdkrgb-armv6.c
|
||||
libgdk_rgb_armv6_la_CFLAGS = $(ARMV6_CFLAGS)
|
||||
libgdk_rgb_neon_la_SOURCES = gdkrgb-neon.c
|
||||
libgdk_rgb_neon_la_CFLAGS = $(NEON_CFLAGS)
|
||||
|
||||
# Checks and times the kernels on this machine against the C code:
|
||||
# make rgbsimdbench && ./rgbsimdbench
|
||||
EXTRA_PROGRAMS = rgbsimdbench
|
||||
rgbsimdbench_SOURCES = rgbsimdbench.c gdkrgbsimd.c
|
||||
rgbsimdbench_CFLAGS = $(AM_CFLAGS)
|
||||
rgbsimdbench_LDADD = $(gdk_rgb_simd_libs) $(GDK_DEP_LIBS)
|
||||
CLEANFILES += rgbsimdbench
|
||||
|
||||
libgdk_directfb_2_0_la_SOURCES = $(common_sources)
|
||||
libgdk_directfb_2_0_la_LIBADD = directfb/libgdk-directfb.la $(GDK_DEP_LIBS)
|
||||
libgdk_directfb_2_0_la_LDFLAGS = $(LDADD)
|
||||
libgdk_directfb_2_0_la_LIBADD = directfb/libgdk-directfb.la $(gdk_rgb_simd_libs) $(GDK_DEP_LIBS)
|
||||
libgdk_directfb_2_0_la_LDFLAGS = $(gdk_ldflags)
|
||||
|
||||
libgdk_x11_2_0_la_SOURCES = $(common_sources)
|
||||
libgdk_x11_2_0_la_LIBADD = x11/libgdk-x11.la $(GDK_DEP_LIBS)
|
||||
libgdk_x11_2_0_la_LDFLAGS = $(LDADD)
|
||||
libgdk_x11_2_0_la_LIBADD = x11/libgdk-x11.la $(gdk_rgb_simd_libs) $(GDK_DEP_LIBS)
|
||||
libgdk_x11_2_0_la_LDFLAGS = $(gdk_ldflags)
|
||||
|
||||
libgdk_quartz_2_0_la_SOURCES = $(common_sources) gdkkeynames.c
|
||||
libgdk_quartz_2_0_la_LIBADD = quartz/libgdk-quartz.la $(GDK_DEP_LIBS)
|
||||
libgdk_quartz_2_0_la_LDFLAGS = $(LDADD)
|
||||
libgdk_quartz_2_0_la_LIBADD = quartz/libgdk-quartz.la $(gdk_rgb_simd_libs) $(GDK_DEP_LIBS)
|
||||
libgdk_quartz_2_0_la_LDFLAGS = $(gdk_ldflags)
|
||||
|
||||
libgdk_win32_2_0_la_SOURCES = $(common_sources) gdkkeynames.c
|
||||
libgdk_win32_2_0_la_LIBADD = win32/libgdk-win32.la $(GDK_DEP_LIBS)
|
||||
libgdk_win32_2_0_la_DEPENDENCIES = win32/libgdk-win32.la win32/rc/gdk-win32-res.o gdk.def
|
||||
libgdk_win32_2_0_la_LDFLAGS = -Wl,win32/rc/gdk-win32-res.o -export-symbols $(srcdir)/gdk.def $(LDADD)
|
||||
libgdk_win32_2_0_la_LIBADD = win32/libgdk-win32.la $(gdk_rgb_simd_libs) $(GDK_DEP_LIBS)
|
||||
libgdk_win32_2_0_la_DEPENDENCIES = win32/libgdk-win32.la $(gdk_rgb_simd_libs) win32/rc/gdk-win32-res.o gdk.def
|
||||
libgdk_win32_2_0_la_LDFLAGS = -Wl,win32/rc/gdk-win32-res.o -export-symbols $(srcdir)/gdk.def $(gdk_ldflags)
|
||||
|
||||
if HAVE_INTROSPECTION
|
||||
|
||||
|
|
@ -213,7 +263,7 @@ Gdk_2_0_gir_CFLAGS = \
|
|||
-I$(top_srcdir) \
|
||||
-I$(top_builddir) \
|
||||
-I$(top_builddir)/gdk \
|
||||
$(INCLUDES)
|
||||
$(AM_CPPFLAGS)
|
||||
|
||||
if OS_WIN32
|
||||
Gdk_2_0_gir_CFLAGS += -I$(srcdir)/win32 -I$(srcdir)
|
||||
|
|
@ -266,7 +316,7 @@ GdkX11_2_0_gir_CFLAGS = \
|
|||
-I$(top_srcdir) \
|
||||
-I$(top_builddir) \
|
||||
-I$(top_builddir)/gdk \
|
||||
$(INCLUDES) \
|
||||
$(AM_CPPFLAGS) \
|
||||
-L$(top_builddir)/gdk
|
||||
INTROSPECTION_GIRS += GdkX11-2.0.gir
|
||||
|
||||
|
|
@ -329,7 +379,7 @@ GdkWin32_2_0_gir_CFLAGS = \
|
|||
-I$(top_builddir)/gdk \
|
||||
-I$(srcdir)/win32 \
|
||||
-I$(srcdir) \
|
||||
$(INCLUDES) \
|
||||
$(AM_CPPFLAGS) \
|
||||
-L$(top_builddir)/gdk
|
||||
INTROSPECTION_GIRS += GdkWin32-2.0.gir
|
||||
|
||||
|
|
@ -478,7 +528,7 @@ INTROSPECTION_INTERMEDIATE_ITEMS = \
|
|||
$(top_builddir)/build/win32/Gdk-2.0.gir.msvc.introspect \
|
||||
$(top_builddir)/build/win32/Gdk_2_0_gir_list
|
||||
|
||||
Gdk_2_0_gir_MSVC_FILES = $(filter-out gdkmedialib.c, $(base_introspection_files))
|
||||
Gdk_2_0_gir_MSVC_FILES = $(base_introspection_files)
|
||||
Gdk_2_0_gir_MSVC_EXPORT_PACKAGES = $(Gdk_2_0_gir_EXPORT_PACKAGES)
|
||||
Gdk_2_0_gir_MSVC_INCLUDE_GIRS = $(Gdk_2_0_gir_INCLUDES)
|
||||
Gdk_2_0_gir_MSVC_LIBS = gdk-win32-2.0
|
||||
|
|
|
|||
|
|
@ -366,11 +366,9 @@ gdk_event_send_client_message_for_display (GdkDisplay *display,
|
|||
guint32
|
||||
gdk_directfb_get_time (void)
|
||||
{
|
||||
GTimeVal tv;
|
||||
|
||||
g_get_current_time (&tv);
|
||||
|
||||
return (guint32) tv.tv_sec * 1000 + tv.tv_usec / 1000;
|
||||
/* milliseconds of the wall clock, as before, from the 64-bit time
|
||||
* instead of the GTimeVal whose glong ends in 2038 on 32-bit systems */
|
||||
return (guint32) (g_get_real_time () / 1000);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -250,5 +250,20 @@ gdk_screen_is_composited (GdkScreen *screen)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/* HiDPI: not scaled by this backend (yet) */
|
||||
gint
|
||||
_gdk_windowing_drawable_get_scale (GdkDrawable *drawable)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
gint
|
||||
_gdk_windowing_screen_get_monitor_scale (GdkScreen *screen,
|
||||
gint monitor_num)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define __GDK_SCREEN_X11_C__
|
||||
#include "gdkaliasdef.c"
|
||||
|
|
|
|||
|
|
@ -265,7 +265,7 @@ gdk_parse_args (int *argc,
|
|||
}
|
||||
g_option_context_free (option_context);
|
||||
|
||||
if (_gdk_debug_flags && GDK_DEBUG_GDKRGB)
|
||||
if (_gdk_debug_flags & GDK_DEBUG_GDKRGB)
|
||||
gdk_rgb_set_verbose (TRUE);
|
||||
|
||||
GDK_NOTE (MISC, g_message ("progname: \"%s\"", g_get_prgname ()));
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ void gdk_rectangle_union (const GdkRectangle *src1,
|
|||
const GdkRectangle *src2,
|
||||
GdkRectangle *dest);
|
||||
|
||||
GType gdk_rectangle_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_rectangle_get_type (void);
|
||||
|
||||
#define GDK_TYPE_RECTANGLE (gdk_rectangle_get_type ())
|
||||
|
||||
|
|
|
|||
154
gdk/gdk.symbols
154
gdk/gdk.symbols
|
|
@ -44,11 +44,15 @@ gdk_event_free
|
|||
gdk_event_get
|
||||
gdk_event_get_axis
|
||||
gdk_event_get_coords
|
||||
gdk_event_get_event_sequence
|
||||
gdk_event_get_root_coords
|
||||
gdk_event_get_pointer_emulated
|
||||
gdk_event_get_touchpad_emulated
|
||||
gdk_event_get_screen
|
||||
gdk_event_get_scroll_deltas
|
||||
gdk_event_get_state
|
||||
gdk_event_get_time
|
||||
gdk_event_get_type G_GNUC_CONST
|
||||
gdk_event_get_type
|
||||
gdk_event_handler_set
|
||||
gdk_event_new
|
||||
gdk_event_peek
|
||||
|
|
@ -186,7 +190,7 @@ gdk_utf8_to_compound_text
|
|||
|
||||
#if IN_HEADER(__GDK_PROPERTY_H__)
|
||||
#if IN_FILE(__GDK_C__)
|
||||
gdk_atom_get_type G_GNUC_CONST
|
||||
gdk_atom_get_type
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
@ -229,54 +233,54 @@ gdk_x11_free_text_list
|
|||
|
||||
#if IN_HEADER(__GDK_ENUM_TYPES_H__)
|
||||
#if IN_FILE(__GDK_ENUM_TYPES_C__)
|
||||
gdk_rgb_dither_get_type G_GNUC_CONST
|
||||
gdk_drag_protocol_get_type G_GNUC_CONST
|
||||
gdk_input_source_get_type G_GNUC_CONST
|
||||
gdk_input_condition_get_type G_GNUC_CONST
|
||||
gdk_input_mode_get_type G_GNUC_CONST
|
||||
gdk_axis_use_get_type G_GNUC_CONST
|
||||
gdk_byte_order_get_type G_GNUC_CONST
|
||||
gdk_cap_style_get_type G_GNUC_CONST
|
||||
gdk_crossing_mode_get_type G_GNUC_CONST
|
||||
gdk_extension_mode_get_type G_GNUC_CONST
|
||||
gdk_event_mask_get_type G_GNUC_CONST
|
||||
gdk_event_type_get_type G_GNUC_CONST
|
||||
gdk_fill_get_type G_GNUC_CONST
|
||||
gdk_rgb_dither_get_type
|
||||
gdk_drag_protocol_get_type
|
||||
gdk_input_source_get_type
|
||||
gdk_input_condition_get_type
|
||||
gdk_input_mode_get_type
|
||||
gdk_axis_use_get_type
|
||||
gdk_byte_order_get_type
|
||||
gdk_cap_style_get_type
|
||||
gdk_crossing_mode_get_type
|
||||
gdk_extension_mode_get_type
|
||||
gdk_event_mask_get_type
|
||||
gdk_event_type_get_type
|
||||
gdk_fill_get_type
|
||||
#ifndef GDK_DISABLE_DEPRECATED
|
||||
gdk_fill_rule_get_type G_GNUC_CONST
|
||||
gdk_fill_rule_get_type
|
||||
#endif
|
||||
gdk_filter_return_get_type G_GNUC_CONST
|
||||
gdk_function_get_type G_GNUC_CONST
|
||||
gdk_grab_status_get_type G_GNUC_CONST
|
||||
gdk_gravity_get_type G_GNUC_CONST
|
||||
gdk_join_style_get_type G_GNUC_CONST
|
||||
gdk_line_style_get_type G_GNUC_CONST
|
||||
gdk_modifier_type_get_type G_GNUC_CONST
|
||||
gdk_notify_type_get_type G_GNUC_CONST
|
||||
gdk_overlap_type_get_type G_GNUC_CONST
|
||||
gdk_owner_change_get_type G_GNUC_CONST
|
||||
gdk_property_state_get_type G_GNUC_CONST
|
||||
gdk_prop_mode_get_type G_GNUC_CONST
|
||||
gdk_scroll_direction_get_type G_GNUC_CONST
|
||||
gdk_setting_action_get_type G_GNUC_CONST
|
||||
gdk_status_get_type G_GNUC_CONST
|
||||
gdk_subwindow_mode_get_type G_GNUC_CONST
|
||||
gdk_visibility_state_get_type G_GNUC_CONST
|
||||
gdk_wm_decoration_get_type G_GNUC_CONST
|
||||
gdk_wm_function_get_type G_GNUC_CONST
|
||||
gdk_font_type_get_type G_GNUC_CONST
|
||||
gdk_cursor_type_get_type G_GNUC_CONST
|
||||
gdk_drag_action_get_type G_GNUC_CONST
|
||||
gdk_gc_values_mask_get_type G_GNUC_CONST
|
||||
gdk_window_attributes_type_get_type G_GNUC_CONST
|
||||
gdk_window_class_get_type G_GNUC_CONST
|
||||
gdk_window_edge_get_type G_GNUC_CONST
|
||||
gdk_window_hints_get_type G_GNUC_CONST
|
||||
gdk_window_state_get_type G_GNUC_CONST
|
||||
gdk_window_type_get_type G_GNUC_CONST
|
||||
gdk_window_type_hint_get_type G_GNUC_CONST
|
||||
gdk_image_type_get_type G_GNUC_CONST
|
||||
gdk_visual_type_get_type G_GNUC_CONST
|
||||
gdk_filter_return_get_type
|
||||
gdk_function_get_type
|
||||
gdk_grab_status_get_type
|
||||
gdk_gravity_get_type
|
||||
gdk_join_style_get_type
|
||||
gdk_line_style_get_type
|
||||
gdk_modifier_type_get_type
|
||||
gdk_notify_type_get_type
|
||||
gdk_overlap_type_get_type
|
||||
gdk_owner_change_get_type
|
||||
gdk_property_state_get_type
|
||||
gdk_prop_mode_get_type
|
||||
gdk_scroll_direction_get_type
|
||||
gdk_setting_action_get_type
|
||||
gdk_status_get_type
|
||||
gdk_subwindow_mode_get_type
|
||||
gdk_visibility_state_get_type
|
||||
gdk_wm_decoration_get_type
|
||||
gdk_wm_function_get_type
|
||||
gdk_font_type_get_type
|
||||
gdk_cursor_type_get_type
|
||||
gdk_drag_action_get_type
|
||||
gdk_gc_values_mask_get_type
|
||||
gdk_window_attributes_type_get_type
|
||||
gdk_window_class_get_type
|
||||
gdk_window_edge_get_type
|
||||
gdk_window_hints_get_type
|
||||
gdk_window_state_get_type
|
||||
gdk_window_type_get_type
|
||||
gdk_window_type_hint_get_type
|
||||
gdk_image_type_get_type
|
||||
gdk_visual_type_get_type
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
@ -285,7 +289,7 @@ gdk_visual_type_get_type G_GNUC_CONST
|
|||
#ifndef GDK_DISABLE_DEPRECATED
|
||||
gdk_font_from_description
|
||||
#endif
|
||||
gdk_font_get_type G_GNUC_CONST
|
||||
gdk_font_get_type
|
||||
gdk_font_ref
|
||||
gdk_font_unref
|
||||
#ifndef GDK_DISABLE_DEPRECATED
|
||||
|
|
@ -325,6 +329,7 @@ gdk_fontset_load_for_display
|
|||
#if IN_HEADER(__GDK_CAIRO_H__)
|
||||
#if IN_FILE(__GDK_CAIRO_C__)
|
||||
gdk_cairo_create
|
||||
gdk_cairo_create_in_area_libgtk_only
|
||||
gdk_cairo_reset_clip
|
||||
gdk_cairo_set_source_color
|
||||
gdk_cairo_set_source_pixbuf
|
||||
|
|
@ -346,7 +351,7 @@ gdk_color_alloc
|
|||
gdk_color_copy
|
||||
gdk_color_equal
|
||||
gdk_color_free
|
||||
gdk_color_get_type G_GNUC_CONST
|
||||
gdk_color_get_type
|
||||
gdk_color_hash
|
||||
gdk_colormap_alloc_color
|
||||
gdk_colormap_get_system
|
||||
|
|
@ -363,7 +368,7 @@ gdk_color_to_string
|
|||
#if IN_HEADER(__GDK_COLOR_H__)
|
||||
#if IN_FILE(__GDK_COLOR_X11_C__)
|
||||
gdk_colormap_new
|
||||
gdk_colormap_get_type G_GNUC_CONST
|
||||
gdk_colormap_get_type
|
||||
#ifndef GDK_DISABLE_DEPRECATED
|
||||
gdk_colormap_change
|
||||
gdk_colors_alloc
|
||||
|
|
@ -380,7 +385,7 @@ gdk_colormap_get_screen
|
|||
|
||||
#if IN_HEADER(__GDK_CURSOR_H__)
|
||||
#if IN_FILE(__GDK_CURSOR_C__)
|
||||
gdk_cursor_get_type G_GNUC_CONST
|
||||
gdk_cursor_get_type
|
||||
gdk_cursor_get_cursor_type
|
||||
gdk_cursor_new
|
||||
gdk_cursor_ref
|
||||
|
|
@ -412,7 +417,7 @@ gdk_device_get_name
|
|||
gdk_device_get_n_axes
|
||||
gdk_device_get_n_keys
|
||||
gdk_device_get_source
|
||||
gdk_device_get_type G_GNUC_CONST
|
||||
gdk_device_get_type
|
||||
gdk_device_set_axis_use
|
||||
gdk_device_set_key
|
||||
gdk_device_set_source
|
||||
|
|
@ -458,7 +463,7 @@ gdk_display_close
|
|||
gdk_display_get_core_pointer
|
||||
gdk_display_get_event
|
||||
gdk_display_get_pointer
|
||||
gdk_display_get_type G_GNUC_CONST
|
||||
gdk_display_get_type
|
||||
gdk_display_get_window_at_pointer
|
||||
gdk_display_is_closed
|
||||
gdk_display_peek_event
|
||||
|
|
@ -533,7 +538,7 @@ gdk_display_set_double_click_time
|
|||
#if IN_HEADER(__GDK_DISPLAY_MANAGER_H__)
|
||||
#if IN_FILE(__GDK_DISPLAY_MANAGER_C__)
|
||||
gdk_display_manager_get
|
||||
gdk_display_manager_get_type G_GNUC_CONST
|
||||
gdk_display_manager_get_type
|
||||
gdk_display_manager_list_displays
|
||||
gdk_display_manager_set_default_display
|
||||
gdk_display_manager_get_default_display
|
||||
|
|
@ -544,7 +549,7 @@ gdk_display_manager_get_default_display
|
|||
#if IN_FILE(__GDK_DND_X11_C__)
|
||||
gdk_drag_abort
|
||||
gdk_drag_begin
|
||||
gdk_drag_context_get_type G_GNUC_CONST
|
||||
gdk_drag_context_get_type
|
||||
#ifndef GDK_DISABLE_DEPRECATED
|
||||
gdk_drag_context_new
|
||||
gdk_drag_context_ref
|
||||
|
|
@ -598,7 +603,7 @@ gdk_drawable_get_visual
|
|||
#endif
|
||||
gdk_drawable_get_depth
|
||||
gdk_drawable_get_image
|
||||
gdk_drawable_get_type G_GNUC_CONST
|
||||
gdk_drawable_get_type
|
||||
gdk_drawable_get_visible_region
|
||||
gdk_drawable_set_colormap
|
||||
gdk_draw_arc
|
||||
|
|
@ -630,7 +635,7 @@ gdk_draw_layout_with_colors
|
|||
#if IN_HEADER(__GDK_GC_H__)
|
||||
#if IN_FILE(__GDK_GC_C__)
|
||||
gdk_gc_new
|
||||
gdk_gc_get_type G_GNUC_CONST
|
||||
gdk_gc_get_type
|
||||
gdk_gc_new_with_values
|
||||
#ifndef GDK_DISABLE_DEPRECATED
|
||||
gdk_gc_ref
|
||||
|
|
@ -672,7 +677,7 @@ gdk_gc_get_screen
|
|||
#if IN_HEADER(__GDK_PIXMAP_X11_H__)
|
||||
#if IN_FILE(__GDK_PIXMAP_X11_C__)
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
gdk_pixmap_impl_x11_get_type G_GNUC_CONST
|
||||
gdk_pixmap_impl_x11_get_type
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -680,7 +685,7 @@ gdk_pixmap_impl_x11_get_type G_GNUC_CONST
|
|||
#if IN_HEADER(__GDK_WINDOW_X11_H__)
|
||||
#if IN_FILE(__GDK_WINDOW_X11_C__)
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
gdk_window_impl_x11_get_type G_GNUC_CONST
|
||||
gdk_window_impl_x11_get_type
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -767,7 +772,7 @@ gdk_window_is_input_only
|
|||
gdk_window_is_shaped
|
||||
gdk_window_is_viewable
|
||||
gdk_window_is_visible
|
||||
gdk_window_object_get_type G_GNUC_CONST
|
||||
gdk_window_object_get_type
|
||||
gdk_window_peek_children
|
||||
gdk_window_process_all_updates
|
||||
gdk_window_process_updates
|
||||
|
|
@ -777,6 +782,7 @@ gdk_window_remove_redirection
|
|||
gdk_window_set_debug_updates
|
||||
gdk_window_set_user_data
|
||||
gdk_window_thaw_toplevel_updates_libgtk_only
|
||||
gdk_window_set_touch_emulation_libgtk_only
|
||||
gdk_window_thaw_updates
|
||||
gdk_window_set_composited
|
||||
gdk_pointer_grab
|
||||
|
|
@ -788,6 +794,7 @@ gdk_window_get_display
|
|||
gdk_window_get_visual
|
||||
gdk_window_get_width
|
||||
gdk_window_get_height
|
||||
gdk_window_get_scale_factor
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
@ -801,7 +808,7 @@ gdk_offscreen_window_get_embedder
|
|||
|
||||
#if IN_HEADER(__GDK_INTERNALS_H__)
|
||||
#if IN_FILE(__GDK_OFFSCREEN_WINDOW_C__)
|
||||
gdk_offscreen_window_get_type G_GNUC_CONST
|
||||
gdk_offscreen_window_get_type
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
@ -892,14 +899,14 @@ gdk_image_new_bitmap
|
|||
#endif
|
||||
gdk_image_get_pixel
|
||||
gdk_image_put_pixel
|
||||
gdk_image_get_type G_GNUC_CONST
|
||||
gdk_image_get_type
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__GDK_KEYS_H__)
|
||||
#if IN_FILE(__GDK_KEYS_C__)
|
||||
gdk_keymap_get_default
|
||||
gdk_keymap_get_type G_GNUC_CONST
|
||||
gdk_keymap_get_type
|
||||
gdk_keyval_is_lower G_GNUC_CONST
|
||||
gdk_keyval_is_upper G_GNUC_CONST
|
||||
gdk_keyval_to_lower G_GNUC_CONST
|
||||
|
|
@ -974,7 +981,7 @@ gdk_visual_get_best_with_both
|
|||
gdk_visual_get_best_with_depth
|
||||
gdk_visual_get_best_with_type
|
||||
gdk_visual_get_screen
|
||||
gdk_visual_get_type G_GNUC_CONST
|
||||
gdk_visual_get_type
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
@ -999,7 +1006,7 @@ gdk_pango_context_set_colormap
|
|||
gdk_pango_layout_get_clip_region
|
||||
gdk_pango_layout_line_get_clip_region
|
||||
gdk_pango_renderer_get_default
|
||||
gdk_pango_renderer_get_type G_GNUC_CONST
|
||||
gdk_pango_renderer_get_type
|
||||
gdk_pango_renderer_new
|
||||
gdk_pango_renderer_set_drawable
|
||||
gdk_pango_renderer_set_gc
|
||||
|
|
@ -1036,7 +1043,7 @@ gdk_pixmap_create_from_xpm
|
|||
gdk_pixmap_colormap_create_from_xpm_d
|
||||
gdk_pixmap_create_from_xpm_d
|
||||
gdk_pixmap_get_size
|
||||
gdk_pixmap_get_type G_GNUC_CONST
|
||||
gdk_pixmap_get_type
|
||||
gdk_pixmap_new
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -1093,7 +1100,7 @@ gdk_region_polygon
|
|||
#if IN_FILE(__GDK_RGB_C__)
|
||||
gdk_rgb_cmap_free
|
||||
gdk_rgb_cmap_copy
|
||||
gdk_rgb_cmap_get_type G_GNUC_CONST
|
||||
gdk_rgb_cmap_get_type
|
||||
gdk_rgb_cmap_new
|
||||
gdk_rgb_colormap_ditherable
|
||||
gdk_rgb_ditherable
|
||||
|
|
@ -1119,7 +1126,7 @@ gdk_draw_rgb_image_dithalign
|
|||
#endif
|
||||
|
||||
#if IN_HEADER(__GDK_RGB_H__)
|
||||
#if IN_FILE(__GDK_RGB16_C__)
|
||||
#if IN_FILE(__GDK_RGB_C__)
|
||||
gdk_draw_rgb_48_image
|
||||
gdk_draw_rgb_48_image_dithalign
|
||||
gdk_draw_rgbx_64_image
|
||||
|
|
@ -1129,13 +1136,14 @@ gdk_draw_rgbx_64_image_dithalign
|
|||
|
||||
#if IN_HEADER(__GDK_SCREEN_H__)
|
||||
#if IN_FILE(__GDK_SCREEN_C__)
|
||||
gdk_screen_get_type G_GNUC_CONST
|
||||
gdk_screen_get_type
|
||||
gdk_screen_get_monitor_at_point
|
||||
gdk_screen_get_monitor_at_window
|
||||
gdk_screen_set_font_options
|
||||
gdk_screen_get_font_options
|
||||
gdk_screen_set_resolution
|
||||
gdk_screen_get_resolution
|
||||
gdk_screen_get_monitor_scale_factor
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
@ -1302,7 +1310,7 @@ gdk_win32_selection_add_targets
|
|||
|
||||
#if IN_HEADER(__GDK_WIN32_H__)
|
||||
#if IN_FILE(__GDK_KEYS_WIN32_C__)
|
||||
gdk_win32_keymap_get_type G_GNUC_CONST
|
||||
gdk_win32_keymap_get_type
|
||||
gdk_win32_keymap_check_compose
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -1417,7 +1425,7 @@ gdk_xid_table_lookup_for_display
|
|||
|
||||
#if IN_HEADER(__GDK_APP_LAUNCH_CONTEXT_H__)
|
||||
#if IN_FILE(__GDK_APP_LAUNCH_CONTEXT_C__)
|
||||
gdk_app_launch_context_get_type G_GNUC_CONST
|
||||
gdk_app_launch_context_get_type
|
||||
gdk_app_launch_context_new
|
||||
gdk_app_launch_context_set_display
|
||||
gdk_app_launch_context_set_screen
|
||||
|
|
@ -1430,7 +1438,7 @@ gdk_app_launch_context_set_icon_name
|
|||
|
||||
#if IN_HEADER(__GDK_WINDOW_IMPL_H__)
|
||||
#if IN_FILE(__GDK_WINDOW_IMPL_C__)
|
||||
gdk_window_impl_get_type G_GNUC_CONST
|
||||
gdk_window_impl_get_type
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
|
|||
250
gdk/gdkcairo.c
250
gdk/gdkcairo.c
|
|
@ -17,7 +17,10 @@
|
|||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "gdkcairo.h"
|
||||
#include "gdkrgbsimd.h"
|
||||
#include "gdkdrawable.h"
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkregion-generic.h"
|
||||
|
|
@ -30,6 +33,8 @@ gdk_ensure_surface_flush (gpointer surface)
|
|||
cairo_surface_destroy (surface);
|
||||
}
|
||||
|
||||
static const cairo_user_data_key_t surface_flush_key;
|
||||
|
||||
/**
|
||||
* gdk_cairo_create:
|
||||
* @drawable: a #GdkDrawable
|
||||
|
|
@ -50,7 +55,6 @@ gdk_ensure_surface_flush (gpointer surface)
|
|||
cairo_t *
|
||||
gdk_cairo_create (GdkDrawable *drawable)
|
||||
{
|
||||
static const cairo_user_data_key_t key;
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
|
||||
|
|
@ -67,11 +71,60 @@ gdk_cairo_create (GdkDrawable *drawable)
|
|||
* on X11 (where flushing is a no-op). For details, see
|
||||
* https://bugzilla.gnome.org/show_bug.cgi?id=628291
|
||||
*/
|
||||
cairo_set_user_data (cr, &key, surface, gdk_ensure_surface_flush);
|
||||
cairo_set_user_data (cr, &surface_flush_key, surface, gdk_ensure_surface_flush);
|
||||
|
||||
return cr;
|
||||
}
|
||||
|
||||
/* gdk_cairo_create() for drawing that stays within @area (in the
|
||||
* coordinates of @drawable): for a window whose clip has many
|
||||
* rectangles, only those parts of it within @area make the clip */
|
||||
cairo_t *
|
||||
_gdk_cairo_create_in_area (GdkDrawable *drawable,
|
||||
const GdkRectangle *area)
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
|
||||
if (!GDK_IS_WINDOW (drawable) ||
|
||||
_gdk_window_get_cairo_clip_n_rects ((GdkWindow *) drawable) <= 2)
|
||||
return gdk_cairo_create (drawable);
|
||||
|
||||
surface = _gdk_drawable_ref_cairo_surface (drawable);
|
||||
cr = cairo_create (surface);
|
||||
_gdk_window_set_cairo_clip_in_area ((GdkWindow *) drawable, cr, area);
|
||||
cairo_set_user_data (cr, &surface_flush_key, surface, gdk_ensure_surface_flush);
|
||||
|
||||
return cr;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_cairo_create_in_area_libgtk_only:
|
||||
* @drawable: a #GdkDrawable
|
||||
* @area: the area that will be drawn
|
||||
*
|
||||
* Like gdk_cairo_create(), for drawing that stays inside @area: of the
|
||||
* clip of a window only the rectangles meeting @area are given to cairo,
|
||||
* which within @area is the same clip. Theme engines that clip to the
|
||||
* area they are given anyway spare cairo the whole clip of the window,
|
||||
* which during an expose can be many rectangles, for each part they
|
||||
* draw. Private to GTK+ and its modules.
|
||||
*
|
||||
* Return value: A newly created Cairo context. Free with
|
||||
* cairo_destroy() when you are done drawing.
|
||||
**/
|
||||
cairo_t *
|
||||
gdk_cairo_create_in_area_libgtk_only (GdkDrawable *drawable,
|
||||
const GdkRectangle *area)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
|
||||
|
||||
if (!area)
|
||||
return gdk_cairo_create (drawable);
|
||||
|
||||
return _gdk_cairo_create_in_area (drawable, area);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_cairo_reset_clip:
|
||||
* @cr: a #cairo_t
|
||||
|
|
@ -173,24 +226,8 @@ gdk_cairo_region (cairo_t *cr,
|
|||
boxes[i].y2 - boxes[i].y1);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_cairo_set_source_pixbuf:
|
||||
* @cr: a #Cairo context
|
||||
* @pixbuf: a #GdkPixbuf
|
||||
* @pixbuf_x: X coordinate of location to place upper left corner of @pixbuf
|
||||
* @pixbuf_y: Y coordinate of location to place upper left corner of @pixbuf
|
||||
*
|
||||
* Sets the given pixbuf as the source pattern for the Cairo context.
|
||||
* The pattern has an extend mode of %CAIRO_EXTEND_NONE and is aligned
|
||||
* so that the origin of @pixbuf is @pixbuf_x, @pixbuf_y
|
||||
*
|
||||
* Since: 2.8
|
||||
**/
|
||||
void
|
||||
gdk_cairo_set_source_pixbuf (cairo_t *cr,
|
||||
const GdkPixbuf *pixbuf,
|
||||
double pixbuf_x,
|
||||
double pixbuf_y)
|
||||
static cairo_surface_t *
|
||||
gdk_cairo_surface_from_pixbuf (const GdkPixbuf *pixbuf)
|
||||
{
|
||||
gint width = gdk_pixbuf_get_width (pixbuf);
|
||||
gint height = gdk_pixbuf_get_height (pixbuf);
|
||||
|
|
@ -202,6 +239,7 @@ gdk_cairo_set_source_pixbuf (cairo_t *cr,
|
|||
cairo_format_t format;
|
||||
cairo_surface_t *surface;
|
||||
static const cairo_user_data_key_t key;
|
||||
const GdkRgbSimd *simd = _gdk_rgb_simd_get ();
|
||||
cairo_status_t status;
|
||||
int j;
|
||||
|
||||
|
|
@ -228,52 +266,60 @@ gdk_cairo_set_source_pixbuf (cairo_t *cr,
|
|||
{
|
||||
guchar *p = gdk_pixels;
|
||||
guchar *q = cairo_pixels;
|
||||
gint done = 0;
|
||||
|
||||
/* vector code where there is some, C for the rest of the row */
|
||||
if (n_channels == 3 && simd->rgb_to_x888)
|
||||
done = simd->rgb_to_x888 ((guint32 *) q, p, width);
|
||||
else if (n_channels == 4 && simd->rgba_to_argb)
|
||||
done = simd->rgba_to_argb ((guint32 *) q, p, width);
|
||||
p += done * n_channels;
|
||||
q += done * 4;
|
||||
|
||||
/* One word out for each pixel, so that machines without vector
|
||||
* units, the PowerPC G3 or ARMv5, store once, not three or four
|
||||
* times; and the unused byte of RGB24 gets a value */
|
||||
if (n_channels == 3)
|
||||
{
|
||||
guchar *end = p + 3 * width;
|
||||
guchar *end = gdk_pixels + 3 * width;
|
||||
guint32 *q32 = (guint32 *) q;
|
||||
|
||||
while (p < end)
|
||||
{
|
||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||
q[0] = p[2];
|
||||
q[1] = p[1];
|
||||
q[2] = p[0];
|
||||
#else
|
||||
q[1] = p[0];
|
||||
q[2] = p[1];
|
||||
q[3] = p[2];
|
||||
#endif
|
||||
p += 3;
|
||||
q += 4;
|
||||
}
|
||||
for (; p < end; p += 3)
|
||||
*q32++ = 0xff000000 | ((guint32) p[0] << 16) | (p[1] << 8) | p[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
guchar *end = p + 4 * width;
|
||||
guint t1,t2,t3;
|
||||
guchar *end = gdk_pixels + 4 * width;
|
||||
guint32 *q32 = (guint32 *) q;
|
||||
|
||||
#define MULT(d,c,a,t) G_STMT_START { t = c * a + 0x80; d = ((t >> 8) + t) >> 8; } G_STMT_END
|
||||
|
||||
while (p < end)
|
||||
/* Red and blue 16 bits apart in one register, multiplied by
|
||||
* alpha at once: c * a / 255 to the nearest, as
|
||||
* ((t >> 8) + t) >> 8 with t = c * a + 0x80, which does not
|
||||
* carry from one into the other. The pixel is read as one word
|
||||
* as well. */
|
||||
for (; p < end; p += 4)
|
||||
{
|
||||
guint32 w, a, rb, g;
|
||||
|
||||
memcpy (&w, p, 4);
|
||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||
MULT(q[0], p[2], p[3], t1);
|
||||
MULT(q[1], p[1], p[3], t2);
|
||||
MULT(q[2], p[0], p[3], t3);
|
||||
q[3] = p[3];
|
||||
a = w >> 24;
|
||||
rb = w & 0x00ff00ff; /* B << 16 | R */
|
||||
g = (w >> 8) & 0xff;
|
||||
#else
|
||||
q[0] = p[3];
|
||||
MULT(q[1], p[0], p[3], t1);
|
||||
MULT(q[2], p[1], p[3], t2);
|
||||
MULT(q[3], p[2], p[3], t3);
|
||||
a = w & 0xff;
|
||||
rb = (w >> 8) & 0x00ff00ff; /* R << 16 | B */
|
||||
g = (w >> 16) & 0xff;
|
||||
#endif
|
||||
|
||||
p += 4;
|
||||
q += 4;
|
||||
rb = rb * a + 0x00800080;
|
||||
rb = ((((rb >> 8) & 0x00ff00ff) + rb) >> 8) & 0x00ff00ff;
|
||||
g = g * a + 0x80;
|
||||
g = ((g >> 8) + g) >> 8;
|
||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||
rb = (rb << 16) | (rb >> 16); /* R << 16 | B */
|
||||
#endif
|
||||
*q32++ = (a << 24) | rb | (g << 8);
|
||||
}
|
||||
|
||||
#undef MULT
|
||||
}
|
||||
|
||||
gdk_pixels += gdk_rowstride;
|
||||
|
|
@ -281,6 +327,104 @@ gdk_cairo_set_source_pixbuf (cairo_t *cr,
|
|||
}
|
||||
|
||||
out:
|
||||
return surface;
|
||||
}
|
||||
|
||||
/* GTK marks the pixbufs it renders for its icon caches with this,
|
||||
* as no one may change them; their cairo surface is kept with them,
|
||||
* so that a cached icon is neither converted nor uploaded again. */
|
||||
#define PIXBUF_SHARED_KEY "gdk-pixbuf-shared"
|
||||
|
||||
static const cairo_user_data_key_t gdk_cairo_hidpi_key;
|
||||
|
||||
void
|
||||
_gdk_cairo_surface_set_hidpi_scale (cairo_surface_t *surface,
|
||||
gint scale)
|
||||
{
|
||||
cairo_surface_set_user_data (surface, &gdk_cairo_hidpi_key,
|
||||
GINT_TO_POINTER (scale > 1 ? scale : 0), NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_cairo_set_source_pixbuf:
|
||||
* @cr: a #Cairo context
|
||||
* @pixbuf: a #GdkPixbuf
|
||||
* @pixbuf_x: X coordinate of location to place upper left corner of @pixbuf
|
||||
* @pixbuf_y: Y coordinate of location to place upper left corner of @pixbuf
|
||||
*
|
||||
* Sets the given pixbuf as the source pattern for the Cairo context.
|
||||
* The pattern has an extend mode of %CAIRO_EXTEND_NONE and is aligned
|
||||
* so that the origin of @pixbuf is @pixbuf_x, @pixbuf_y
|
||||
*
|
||||
* Since: 2.8
|
||||
**/
|
||||
void
|
||||
gdk_cairo_set_source_pixbuf (cairo_t *cr,
|
||||
const GdkPixbuf *pixbuf,
|
||||
double pixbuf_x,
|
||||
double pixbuf_y)
|
||||
{
|
||||
static GQuark quark_shared, quark_surface;
|
||||
cairo_surface_t *surface;
|
||||
|
||||
if (!quark_shared)
|
||||
{
|
||||
quark_shared = g_quark_from_static_string (PIXBUF_SHARED_KEY);
|
||||
quark_surface = g_quark_from_static_string ("gdk-cairo-surface");
|
||||
}
|
||||
|
||||
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE (1, 14, 0)
|
||||
{
|
||||
/* HiDPI: on a surface of the window system with more pixels than
|
||||
* GDK's, the pixbuf's own picture of that resolution, if it has
|
||||
* one, else its pixels as sharp blocks (where it is not scaled) */
|
||||
gdouble sx = 1, sy = 1;
|
||||
cairo_matrix_t m;
|
||||
GdkPixbuf *hires;
|
||||
|
||||
cairo_surface_get_device_scale (cairo_get_target (cr), &sx, &sy);
|
||||
if (sx == 1 && sy == 1)
|
||||
sx = sy = GPOINTER_TO_INT (cairo_surface_get_user_data (cairo_get_target (cr),
|
||||
&gdk_cairo_hidpi_key));
|
||||
if (sx > 1 && sx == sy && sx == (gint) sx)
|
||||
{
|
||||
hires = _gdk_pixbuf_get_hires ((GdkPixbuf *) pixbuf, (gint) sx);
|
||||
if (hires)
|
||||
{
|
||||
surface = gdk_cairo_surface_from_pixbuf (hires);
|
||||
cairo_surface_set_device_scale (surface, sx, sy);
|
||||
cairo_set_source_surface (cr, surface, pixbuf_x, pixbuf_y);
|
||||
cairo_surface_destroy (surface);
|
||||
return;
|
||||
}
|
||||
|
||||
cairo_get_matrix (cr, &m);
|
||||
if (m.xx == 1 && m.yy == 1 && m.xy == 0 && m.yx == 0)
|
||||
{
|
||||
surface = gdk_cairo_surface_from_pixbuf (pixbuf);
|
||||
cairo_set_source_surface (cr, surface, pixbuf_x, pixbuf_y);
|
||||
cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_NEAREST);
|
||||
cairo_surface_destroy (surface);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (g_object_get_qdata (G_OBJECT (pixbuf), quark_shared))
|
||||
{
|
||||
surface = g_object_get_qdata (G_OBJECT (pixbuf), quark_surface);
|
||||
if (!surface)
|
||||
{
|
||||
surface = gdk_cairo_surface_from_pixbuf (pixbuf);
|
||||
g_object_set_qdata_full (G_OBJECT (pixbuf), quark_surface, surface,
|
||||
(GDestroyNotify) cairo_surface_destroy);
|
||||
}
|
||||
cairo_set_source_surface (cr, surface, pixbuf_x, pixbuf_y);
|
||||
return;
|
||||
}
|
||||
|
||||
surface = gdk_cairo_surface_from_pixbuf (pixbuf);
|
||||
cairo_set_source_surface (cr, surface, pixbuf_x, pixbuf_y);
|
||||
cairo_surface_destroy (surface);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,10 @@
|
|||
G_BEGIN_DECLS
|
||||
|
||||
cairo_t *gdk_cairo_create (GdkDrawable *drawable);
|
||||
|
||||
/* private, for the theme engines of GTK+ */
|
||||
cairo_t *gdk_cairo_create_in_area_libgtk_only (GdkDrawable *drawable,
|
||||
const GdkRectangle *area);
|
||||
void gdk_cairo_reset_clip (cairo_t *cr,
|
||||
GdkDrawable *drawable);
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ struct _GdkColormapClass
|
|||
|
||||
};
|
||||
|
||||
GType gdk_colormap_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_colormap_get_type (void);
|
||||
|
||||
GdkColormap* gdk_colormap_new (GdkVisual *visual,
|
||||
gboolean allocate);
|
||||
|
|
@ -140,7 +140,7 @@ gboolean gdk_color_equal (const GdkColor *colora,
|
|||
const GdkColor *colorb);
|
||||
gchar * gdk_color_to_string (const GdkColor *color);
|
||||
|
||||
GType gdk_color_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_color_get_type (void);
|
||||
|
||||
/* The following functions are deprecated */
|
||||
#ifndef GDK_DISABLE_DEPRECATED
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ struct _GdkCursor
|
|||
/* Cursors
|
||||
*/
|
||||
|
||||
GType gdk_cursor_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_cursor_get_type (void);
|
||||
|
||||
GdkCursor* gdk_cursor_new_for_display (GdkDisplay *display,
|
||||
GdkCursorType cursor_type);
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ struct _GdkDisplayPointerHooks
|
|||
gint *win_y);
|
||||
};
|
||||
|
||||
GType gdk_display_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_display_get_type (void);
|
||||
GdkDisplay *gdk_display_open (const gchar *display_name);
|
||||
|
||||
const gchar * gdk_display_get_name (GdkDisplay *display);
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ struct _GdkDisplayManagerClass
|
|||
GdkDisplay *display);
|
||||
};
|
||||
|
||||
GType gdk_display_manager_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_display_manager_get_type (void);
|
||||
|
||||
GdkDisplayManager *gdk_display_manager_get (void);
|
||||
GdkDisplay * gdk_display_manager_get_default_display (GdkDisplayManager *display_manager);
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ struct _GdkDragContextClass {
|
|||
|
||||
/* Drag and Drop */
|
||||
|
||||
GType gdk_drag_context_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_drag_context_get_type (void);
|
||||
#if !defined (GDK_DISABLE_DEPRECATED) || defined (GDK_COMPILATION)
|
||||
GdkDragContext * gdk_drag_context_new (void);
|
||||
#endif
|
||||
|
|
|
|||
358
gdk/gdkdraw.c
358
gdk/gdkdraw.c
|
|
@ -84,6 +84,13 @@ gdk_drawable_class_init (GdkDrawableClass *klass)
|
|||
klass->get_visible_region = gdk_drawable_real_get_visible_region;
|
||||
klass->draw_pixbuf = gdk_drawable_real_draw_pixbuf;
|
||||
klass->draw_drawable = gdk_drawable_real_draw_drawable;
|
||||
|
||||
/* how theme engines built outside GTK+, which must load into other
|
||||
* builds of GTK+ 2 too, find gdk_cairo_create_in_area_libgtk_only():
|
||||
* where this is not set they use gdk_cairo_create() */
|
||||
g_type_set_qdata (G_TYPE_FROM_CLASS (klass),
|
||||
g_quark_from_static_string ("gdk-cairo-create-in-area"),
|
||||
(gpointer) gdk_cairo_create_in_area_libgtk_only);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -794,12 +801,6 @@ gdk_draw_image (GdkDrawable *drawable,
|
|||
* On older X servers, rendering pixbufs with an alpha channel involves round
|
||||
* trips to the X server, and may be somewhat slow.
|
||||
*
|
||||
* If GDK is built with the Sun mediaLib library, the gdk_draw_pixbuf
|
||||
* function is accelerated using mediaLib, which provides hardware
|
||||
* acceleration on Intel, AMD, and Sparc chipsets. If desired, mediaLib
|
||||
* support can be turned off by setting the GDK_DISABLE_MEDIALIB environment
|
||||
* variable.
|
||||
*
|
||||
* Since: 2.2
|
||||
*
|
||||
* Deprecated: 2.22: Use gdk_cairo_set_source_pixbuf() and cairo_paint() or
|
||||
|
|
@ -948,7 +949,7 @@ real_draw_glyphs (GdkDrawable *drawable,
|
|||
cairo_t *cr;
|
||||
|
||||
cr = gdk_cairo_create (drawable);
|
||||
_gdk_gc_update_context (gc, cr, NULL, NULL, TRUE, drawable);
|
||||
_gdk_gc_update_context (gc, cr, NULL, NULL, TRUE, drawable, TRUE);
|
||||
|
||||
if (matrix)
|
||||
{
|
||||
|
|
@ -1078,7 +1079,7 @@ gdk_draw_trapezoids (GdkDrawable *drawable,
|
|||
g_return_if_fail (n_trapezoids == 0 || trapezoids != NULL);
|
||||
|
||||
cr = gdk_cairo_create (drawable);
|
||||
_gdk_gc_update_context (gc, cr, NULL, NULL, TRUE, drawable);
|
||||
_gdk_gc_update_context (gc, cr, NULL, NULL, TRUE, drawable, TRUE);
|
||||
|
||||
for (i = 0; i < n_trapezoids; i++)
|
||||
{
|
||||
|
|
@ -1403,174 +1404,62 @@ composite (guchar *src_buf,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
composite_0888 (guchar *src_buf,
|
||||
gint src_rowstride,
|
||||
guchar *dest_buf,
|
||||
gint dest_rowstride,
|
||||
GdkByteOrder dest_byte_order,
|
||||
gint width,
|
||||
gint height)
|
||||
/* Blends @pixbuf over the drawable piece by piece, in the drawable's
|
||||
* own pixel format. Returns FALSE, having drawn nothing, where GdkRGB
|
||||
* can't do that (palettes, gray levels, dithering). */
|
||||
static gboolean
|
||||
composite_on_images (GdkDrawable *drawable,
|
||||
GdkDrawable *real_drawable,
|
||||
GdkGC *gc,
|
||||
GdkPixbuf *pixbuf,
|
||||
gint src_x,
|
||||
gint src_y,
|
||||
gint dest_x,
|
||||
gint dest_y,
|
||||
gint width,
|
||||
gint height,
|
||||
GdkRgbDither dither)
|
||||
{
|
||||
guchar *src = src_buf;
|
||||
guchar *dest = dest_buf;
|
||||
GdkColormap *colormap = gdk_drawable_get_colormap (drawable);
|
||||
guchar *pixels = gdk_pixbuf_get_pixels (pixbuf);
|
||||
gint rowstride = gdk_pixbuf_get_rowstride (pixbuf);
|
||||
gint x0, y0;
|
||||
|
||||
while (height--)
|
||||
if (!colormap)
|
||||
return FALSE;
|
||||
|
||||
for (y0 = 0; y0 < height; y0 += GDK_SCRATCH_IMAGE_HEIGHT)
|
||||
{
|
||||
gint twidth = width;
|
||||
guchar *p = src;
|
||||
guchar *q = dest;
|
||||
gint height1 = MIN (height - y0, GDK_SCRATCH_IMAGE_HEIGHT);
|
||||
|
||||
if (dest_byte_order == GDK_LSB_FIRST)
|
||||
for (x0 = 0; x0 < width; x0 += GDK_SCRATCH_IMAGE_WIDTH)
|
||||
{
|
||||
while (twidth--)
|
||||
{
|
||||
guint t;
|
||||
gint width1 = MIN (width - x0, GDK_SCRATCH_IMAGE_WIDTH);
|
||||
gint xs0, ys0;
|
||||
GdkImage *image;
|
||||
|
||||
t = p[3] * p[2] + (255 - p[3]) * q[0] + 0x80;
|
||||
q[0] = (t + (t >> 8)) >> 8;
|
||||
t = p[3] * p[1] + (255 - p[3]) * q[1] + 0x80;
|
||||
q[1] = (t + (t >> 8)) >> 8;
|
||||
t = p[3] * p[0] + (255 - p[3]) * q[2] + 0x80;
|
||||
q[2] = (t + (t >> 8)) >> 8;
|
||||
p += 4;
|
||||
q += 4;
|
||||
}
|
||||
image = _gdk_image_get_scratch (gdk_drawable_get_screen (drawable),
|
||||
width1, height1,
|
||||
gdk_drawable_get_depth (drawable), &xs0, &ys0);
|
||||
gdk_drawable_copy_to_image (drawable, image,
|
||||
dest_x + x0, dest_y + y0,
|
||||
xs0, ys0,
|
||||
width1, height1);
|
||||
|
||||
/* this fails for the first piece or for none */
|
||||
if (!_gdk_rgb_composite (colormap, image, xs0, ys0, width1, height1,
|
||||
pixels + (src_y + y0) * rowstride + (src_x + x0) * 4,
|
||||
rowstride, dither))
|
||||
return FALSE;
|
||||
|
||||
gdk_draw_image (real_drawable, gc, image,
|
||||
xs0, ys0,
|
||||
dest_x + x0, dest_y + y0,
|
||||
width1, height1);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (twidth--)
|
||||
{
|
||||
guint t;
|
||||
|
||||
t = p[3] * p[0] + (255 - p[3]) * q[1] + 0x80;
|
||||
q[1] = (t + (t >> 8)) >> 8;
|
||||
t = p[3] * p[1] + (255 - p[3]) * q[2] + 0x80;
|
||||
q[2] = (t + (t >> 8)) >> 8;
|
||||
t = p[3] * p[2] + (255 - p[3]) * q[3] + 0x80;
|
||||
q[3] = (t + (t >> 8)) >> 8;
|
||||
p += 4;
|
||||
q += 4;
|
||||
}
|
||||
}
|
||||
|
||||
src += src_rowstride;
|
||||
dest += dest_rowstride;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_MEDIALIB
|
||||
static void
|
||||
composite_0888_medialib (guchar *src_buf,
|
||||
gint src_rowstride,
|
||||
guchar *dest_buf,
|
||||
gint dest_rowstride,
|
||||
GdkByteOrder dest_byte_order,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
guchar *src = src_buf;
|
||||
guchar *dest = dest_buf;
|
||||
|
||||
mlib_image img_src, img_dst;
|
||||
|
||||
mlib_ImageSetStruct (&img_dst,
|
||||
MLIB_BYTE,
|
||||
4,
|
||||
width,
|
||||
height,
|
||||
dest_rowstride,
|
||||
dest_buf);
|
||||
|
||||
mlib_ImageSetStruct (&img_src,
|
||||
MLIB_BYTE,
|
||||
4,
|
||||
width,
|
||||
height,
|
||||
src_rowstride,
|
||||
src_buf);
|
||||
|
||||
if (dest_byte_order == GDK_LSB_FIRST)
|
||||
mlib_ImageBlendRGBA2BGRA (&img_dst, &img_src);
|
||||
else
|
||||
mlib_ImageBlendRGBA2ARGB (&img_dst, &img_src);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
composite_565 (guchar *src_buf,
|
||||
gint src_rowstride,
|
||||
guchar *dest_buf,
|
||||
gint dest_rowstride,
|
||||
GdkByteOrder dest_byte_order,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
guchar *src = src_buf;
|
||||
guchar *dest = dest_buf;
|
||||
|
||||
while (height--)
|
||||
{
|
||||
gint twidth = width;
|
||||
guchar *p = src;
|
||||
gushort *q = (gushort *)dest;
|
||||
|
||||
while (twidth--)
|
||||
{
|
||||
guchar a = p[3];
|
||||
guint tr, tg, tb;
|
||||
guint tr1, tg1, tb1;
|
||||
guint tmp = *q;
|
||||
|
||||
#if 1
|
||||
/* This is fast, and corresponds to what composite() above does
|
||||
* if we converted to 8-bit first.
|
||||
*/
|
||||
tr = (tmp & 0xf800);
|
||||
tr1 = a * p[0] + (255 - a) * ((tr >> 8) + (tr >> 13)) + 0x80;
|
||||
tg = (tmp & 0x07e0);
|
||||
tg1 = a * p[1] + (255 - a) * ((tg >> 3) + (tg >> 9)) + 0x80;
|
||||
tb = (tmp & 0x001f);
|
||||
tb1 = a * p[2] + (255 - a) * ((tb << 3) + (tb >> 2)) + 0x80;
|
||||
|
||||
*q = (((tr1 + (tr1 >> 8)) & 0xf800) |
|
||||
(((tg1 + (tg1 >> 8)) & 0xfc00) >> 5) |
|
||||
((tb1 + (tb1 >> 8)) >> 11));
|
||||
#else
|
||||
/* This version correspond to the result we get with XRENDER -
|
||||
* a bit of precision is lost since we convert to 8 bit after premultiplying
|
||||
* instead of at the end
|
||||
*/
|
||||
guint tr2, tg2, tb2;
|
||||
guint tr3, tg3, tb3;
|
||||
|
||||
tr = (tmp & 0xf800);
|
||||
tr1 = (255 - a) * ((tr >> 8) + (tr >> 13)) + 0x80;
|
||||
tr2 = a * p[0] + 0x80;
|
||||
tr3 = ((tr1 + (tr1 >> 8)) >> 8) + ((tr2 + (tr2 >> 8)) >> 8);
|
||||
|
||||
tg = (tmp & 0x07e0);
|
||||
tg1 = (255 - a) * ((tg >> 3) + (tg >> 9)) + 0x80;
|
||||
tg2 = a * p[0] + 0x80;
|
||||
tg3 = ((tg1 + (tg1 >> 8)) >> 8) + ((tg2 + (tg2 >> 8)) >> 8);
|
||||
|
||||
tb = (tmp & 0x001f);
|
||||
tb1 = (255 - a) * ((tb << 3) + (tb >> 2)) + 0x80;
|
||||
tb2 = a * p[0] + 0x80;
|
||||
tb3 = ((tb1 + (tb1 >> 8)) >> 8) + ((tb2 + (tb2 >> 8)) >> 8);
|
||||
|
||||
*q = (((tr3 & 0xf8) << 8) |
|
||||
((tg3 & 0xfc) << 3) |
|
||||
((tb3 >> 3)));
|
||||
#endif
|
||||
|
||||
p += 4;
|
||||
q++;
|
||||
}
|
||||
|
||||
src += src_rowstride;
|
||||
dest += dest_rowstride;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Implementation of the old vfunc in terms of the new one
|
||||
|
|
@ -1706,101 +1595,26 @@ gdk_drawable_real_draw_pixbuf (GdkDrawable *drawable,
|
|||
|
||||
if (gdk_pixbuf_get_has_alpha (pixbuf))
|
||||
{
|
||||
GdkVisual *visual = gdk_drawable_get_visual (drawable);
|
||||
void (*composite_func) (guchar *src_buf,
|
||||
gint src_rowstride,
|
||||
guchar *dest_buf,
|
||||
gint dest_rowstride,
|
||||
GdkByteOrder dest_byte_order,
|
||||
gint width,
|
||||
gint height) = NULL;
|
||||
if (composite_on_images (drawable, real_drawable, gc, pixbuf,
|
||||
src_x, src_y, dest_x, dest_y, width, height, dither))
|
||||
return;
|
||||
|
||||
/* First we see if we have a visual-specific composition function that can composite
|
||||
* the pixbuf data directly onto the image
|
||||
/* Palettes, gray levels, dithering: composite against the
|
||||
* drawable as 24-bit RGB, and convert back.
|
||||
*/
|
||||
if (visual)
|
||||
{
|
||||
gint bits_per_pixel = _gdk_windowing_get_bits_for_depth (gdk_drawable_get_display (drawable),
|
||||
visual->depth);
|
||||
composited = gdk_pixbuf_get_from_drawable (NULL,
|
||||
drawable,
|
||||
NULL,
|
||||
dest_x, dest_y,
|
||||
0, 0,
|
||||
width, height);
|
||||
|
||||
if (visual->byte_order == (G_BYTE_ORDER == G_BIG_ENDIAN ? GDK_MSB_FIRST : GDK_LSB_FIRST) &&
|
||||
visual->depth == 16 &&
|
||||
visual->red_mask == 0xf800 &&
|
||||
visual->green_mask == 0x07e0 &&
|
||||
visual->blue_mask == 0x001f)
|
||||
composite_func = composite_565;
|
||||
else if (visual->depth == 24 && bits_per_pixel == 32 &&
|
||||
visual->red_mask == 0xff0000 &&
|
||||
visual->green_mask == 0x00ff00 &&
|
||||
visual->blue_mask == 0x0000ff)
|
||||
{
|
||||
#ifdef USE_MEDIALIB
|
||||
if (_gdk_use_medialib ())
|
||||
composite_func = composite_0888_medialib;
|
||||
else
|
||||
composite_func = composite_0888;
|
||||
#else
|
||||
composite_func = composite_0888;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/* We can't use our composite func if we are required to dither
|
||||
*/
|
||||
if (composite_func && !(dither == GDK_RGB_DITHER_MAX && visual->depth != 24))
|
||||
{
|
||||
gint x0, y0;
|
||||
for (y0 = 0; y0 < height; y0 += GDK_SCRATCH_IMAGE_HEIGHT)
|
||||
{
|
||||
gint height1 = MIN (height - y0, GDK_SCRATCH_IMAGE_HEIGHT);
|
||||
for (x0 = 0; x0 < width; x0 += GDK_SCRATCH_IMAGE_WIDTH)
|
||||
{
|
||||
gint xs0, ys0;
|
||||
|
||||
gint width1 = MIN (width - x0, GDK_SCRATCH_IMAGE_WIDTH);
|
||||
|
||||
GdkImage *image = _gdk_image_get_scratch (gdk_drawable_get_screen (drawable),
|
||||
width1, height1,
|
||||
gdk_drawable_get_depth (drawable), &xs0, &ys0);
|
||||
|
||||
gdk_drawable_copy_to_image (drawable, image,
|
||||
dest_x + x0, dest_y + y0,
|
||||
xs0, ys0,
|
||||
width1, height1);
|
||||
(*composite_func) (gdk_pixbuf_get_pixels (pixbuf) + (src_y + y0) * gdk_pixbuf_get_rowstride (pixbuf) + (src_x + x0) * 4,
|
||||
gdk_pixbuf_get_rowstride (pixbuf),
|
||||
(guchar*)image->mem + ys0 * image->bpl + xs0 * image->bpp,
|
||||
image->bpl,
|
||||
visual->byte_order,
|
||||
width1, height1);
|
||||
gdk_draw_image (real_drawable, gc, image,
|
||||
xs0, ys0,
|
||||
dest_x + x0, dest_y + y0,
|
||||
width1, height1);
|
||||
}
|
||||
}
|
||||
|
||||
goto out;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* No special composition func, convert dest to 24 bit RGB data, composite against
|
||||
* that, and convert back.
|
||||
*/
|
||||
composited = gdk_pixbuf_get_from_drawable (NULL,
|
||||
drawable,
|
||||
NULL,
|
||||
dest_x, dest_y,
|
||||
0, 0,
|
||||
width, height);
|
||||
|
||||
if (composited)
|
||||
composite (gdk_pixbuf_get_pixels (pixbuf) + src_y * gdk_pixbuf_get_rowstride (pixbuf) + src_x * 4,
|
||||
gdk_pixbuf_get_rowstride (pixbuf),
|
||||
gdk_pixbuf_get_pixels (composited),
|
||||
gdk_pixbuf_get_rowstride (composited),
|
||||
width, height);
|
||||
}
|
||||
if (composited)
|
||||
composite (gdk_pixbuf_get_pixels (pixbuf) + src_y * gdk_pixbuf_get_rowstride (pixbuf) + src_x * 4,
|
||||
gdk_pixbuf_get_rowstride (pixbuf),
|
||||
gdk_pixbuf_get_pixels (composited),
|
||||
gdk_pixbuf_get_rowstride (composited),
|
||||
width, height);
|
||||
}
|
||||
|
||||
if (composited)
|
||||
|
|
@ -1833,7 +1647,6 @@ gdk_drawable_real_draw_pixbuf (GdkDrawable *drawable,
|
|||
x_dither, y_dither);
|
||||
}
|
||||
|
||||
out:
|
||||
if (composited)
|
||||
g_object_unref (composited);
|
||||
}
|
||||
|
|
@ -1975,5 +1788,30 @@ _gdk_drawable_create_cairo_surface (GdkDrawable *drawable,
|
|||
}
|
||||
|
||||
|
||||
/* HiDPI: a pixbuf of GTK+ can carry one with as many more pixels as a
|
||||
* scale (icons of the icon theme and the stock icons do); drawn on a
|
||||
* drawable of that scale, its pixels are those of the X server */
|
||||
GdkPixbuf *
|
||||
_gdk_pixbuf_get_hires (GdkPixbuf *pixbuf,
|
||||
gint scale)
|
||||
{
|
||||
gchar key[32];
|
||||
GdkPixbuf *hires;
|
||||
|
||||
if (scale <= 1)
|
||||
return NULL;
|
||||
|
||||
g_snprintf (key, sizeof key, "gdk-pixbuf-hires-%d", scale);
|
||||
hires = g_object_get_data (G_OBJECT (pixbuf), key);
|
||||
if (hires &&
|
||||
gdk_pixbuf_get_width (hires) == gdk_pixbuf_get_width (pixbuf) * scale &&
|
||||
gdk_pixbuf_get_height (hires) == gdk_pixbuf_get_height (pixbuf) * scale &&
|
||||
gdk_pixbuf_get_n_channels (hires) == gdk_pixbuf_get_n_channels (pixbuf) &&
|
||||
gdk_pixbuf_get_has_alpha (hires) == gdk_pixbuf_get_has_alpha (pixbuf))
|
||||
return hires;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#define __GDK_DRAW_C__
|
||||
#include "gdkaliasdef.c"
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ struct _GdkTrapezoid
|
|||
double y1, x11, x21, y2, x12, x22;
|
||||
};
|
||||
|
||||
GType gdk_drawable_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_drawable_get_type (void);
|
||||
|
||||
/* Manipulation of drawables
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ G_BEGIN_DECLS
|
|||
/*** END file-production ***/
|
||||
|
||||
/*** BEGIN value-header ***/
|
||||
GType @enum_name@_get_type (void) G_GNUC_CONST;
|
||||
GType @enum_name@_get_type (void);
|
||||
#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
|
||||
/*** END value-header ***/
|
||||
|
||||
|
|
|
|||
400
gdk/gdkevents.c
400
gdk/gdkevents.c
|
|
@ -32,6 +32,10 @@
|
|||
#include "gdkprivate.h"
|
||||
#include "gdkalias.h"
|
||||
|
||||
/* the touch event of GTK+ 3 fits in the GdkEvent of GTK+ 2, whose size
|
||||
* is ABI: on LP64 88 bytes, on i386 68, on 32-bit Windows 72 */
|
||||
G_STATIC_ASSERT (sizeof (GdkEventTouch) <= sizeof (GdkEventCrossing));
|
||||
|
||||
/* See gdkprivate.h for why this avoids g_memdup(). */
|
||||
#if !GLIB_CHECK_VERSION (2, 68, 0)
|
||||
gpointer
|
||||
|
|
@ -412,6 +416,15 @@ gdk_event_new (GdkEventType type)
|
|||
new_event->scroll.x_root = 0.;
|
||||
new_event->scroll.y_root = 0.;
|
||||
break;
|
||||
case GDK_TOUCH_BEGIN:
|
||||
case GDK_TOUCH_UPDATE:
|
||||
case GDK_TOUCH_END:
|
||||
case GDK_TOUCH_CANCEL:
|
||||
new_event->touch.x = 0.;
|
||||
new_event->touch.y = 0.;
|
||||
new_event->touch.x_root = 0.;
|
||||
new_event->touch.y_root = 0.;
|
||||
break;
|
||||
case GDK_ENTER_NOTIFY:
|
||||
case GDK_LEAVE_NOTIFY:
|
||||
new_event->crossing.x = 0.;
|
||||
|
|
@ -465,6 +478,11 @@ gdk_event_copy (const GdkEvent *event)
|
|||
GdkEventPrivate *private = (GdkEventPrivate *)event;
|
||||
|
||||
new_private->screen = private->screen;
|
||||
new_private->flags |= private->flags & (GDK_EVENT_POINTER_EMULATED |
|
||||
GDK_EVENT_TOUCHPAD_EMULATED);
|
||||
if (event->any.type == GDK_SCROLL &&
|
||||
event->scroll.direction == GDK_SCROLL_SMOOTH)
|
||||
new_private->delta = private->delta;
|
||||
}
|
||||
|
||||
switch (event->any.type)
|
||||
|
|
@ -500,6 +518,8 @@ gdk_event_copy (const GdkEvent *event)
|
|||
break;
|
||||
|
||||
case GDK_BUTTON_PRESS:
|
||||
case GDK_2BUTTON_PRESS:
|
||||
case GDK_3BUTTON_PRESS:
|
||||
case GDK_BUTTON_RELEASE:
|
||||
if (event->button.axes)
|
||||
new_event->button.axes = _gdk_memdup2 (event->button.axes,
|
||||
|
|
@ -559,10 +579,13 @@ gdk_event_free (GdkEvent *event)
|
|||
case GDK_DRAG_STATUS:
|
||||
case GDK_DROP_START:
|
||||
case GDK_DROP_FINISHED:
|
||||
g_object_unref (event->dnd.context);
|
||||
if (event->dnd.context != NULL)
|
||||
g_object_unref (event->dnd.context);
|
||||
break;
|
||||
|
||||
case GDK_BUTTON_PRESS:
|
||||
case GDK_2BUTTON_PRESS:
|
||||
case GDK_3BUTTON_PRESS:
|
||||
case GDK_BUTTON_RELEASE:
|
||||
g_free (event->button.axes);
|
||||
break;
|
||||
|
|
@ -615,6 +638,11 @@ gdk_event_get_time (const GdkEvent *event)
|
|||
return event->button.time;
|
||||
case GDK_SCROLL:
|
||||
return event->scroll.time;
|
||||
case GDK_TOUCH_BEGIN:
|
||||
case GDK_TOUCH_UPDATE:
|
||||
case GDK_TOUCH_END:
|
||||
case GDK_TOUCH_CANCEL:
|
||||
return event->touch.time;
|
||||
case GDK_KEY_PRESS:
|
||||
case GDK_KEY_RELEASE:
|
||||
return event->key.time;
|
||||
|
|
@ -694,6 +722,12 @@ gdk_event_get_state (const GdkEvent *event,
|
|||
case GDK_SCROLL:
|
||||
*state = event->scroll.state;
|
||||
return TRUE;
|
||||
case GDK_TOUCH_BEGIN:
|
||||
case GDK_TOUCH_UPDATE:
|
||||
case GDK_TOUCH_END:
|
||||
case GDK_TOUCH_CANCEL:
|
||||
*state = event->touch.state;
|
||||
return TRUE;
|
||||
case GDK_KEY_PRESS:
|
||||
case GDK_KEY_RELEASE:
|
||||
*state = event->key.state;
|
||||
|
|
@ -703,8 +737,6 @@ gdk_event_get_state (const GdkEvent *event,
|
|||
*state = event->crossing.state;
|
||||
return TRUE;
|
||||
case GDK_PROPERTY_NOTIFY:
|
||||
*state = event->property.state;
|
||||
return TRUE;
|
||||
case GDK_VISIBILITY_NOTIFY:
|
||||
case GDK_CLIENT_EVENT:
|
||||
case GDK_NO_EXPOSE:
|
||||
|
|
@ -776,6 +808,13 @@ gdk_event_get_coords (const GdkEvent *event,
|
|||
x = event->scroll.x;
|
||||
y = event->scroll.y;
|
||||
break;
|
||||
case GDK_TOUCH_BEGIN:
|
||||
case GDK_TOUCH_UPDATE:
|
||||
case GDK_TOUCH_END:
|
||||
case GDK_TOUCH_CANCEL:
|
||||
x = event->touch.x;
|
||||
y = event->touch.y;
|
||||
break;
|
||||
case GDK_BUTTON_PRESS:
|
||||
case GDK_2BUTTON_PRESS:
|
||||
case GDK_3BUTTON_PRESS:
|
||||
|
|
@ -830,6 +869,13 @@ gdk_event_get_root_coords (const GdkEvent *event,
|
|||
x = event->scroll.x_root;
|
||||
y = event->scroll.y_root;
|
||||
break;
|
||||
case GDK_TOUCH_BEGIN:
|
||||
case GDK_TOUCH_UPDATE:
|
||||
case GDK_TOUCH_END:
|
||||
case GDK_TOUCH_CANCEL:
|
||||
x = event->touch.x_root;
|
||||
y = event->touch.y_root;
|
||||
break;
|
||||
case GDK_BUTTON_PRESS:
|
||||
case GDK_2BUTTON_PRESS:
|
||||
case GDK_3BUTTON_PRESS:
|
||||
|
|
@ -1034,6 +1080,354 @@ gdk_event_get_screen (const GdkEvent *event)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_event_get_scroll_deltas:
|
||||
* @event: a #GdkEvent
|
||||
* @delta_x: (out): return location for the steps to the right
|
||||
* @delta_y: (out): return location for the steps down
|
||||
*
|
||||
* Gets how far a %GDK_SCROLL_SMOOTH event scrolls, in steps of a
|
||||
* mouse wheel: high resolution wheels and touchpads give fractions.
|
||||
* On Quartz, trackpads give pixels, as in GTK+ 3.
|
||||
* The same movement also arrives as ordinary scroll events, one per
|
||||
* whole step, which gdk_event_get_pointer_emulated() tells apart.
|
||||
*
|
||||
* Return value: %TRUE if @event is a smooth scroll event
|
||||
*
|
||||
* Since: 2.24
|
||||
**/
|
||||
gboolean
|
||||
gdk_event_get_scroll_deltas (const GdkEvent *event,
|
||||
gdouble *delta_x,
|
||||
gdouble *delta_y)
|
||||
{
|
||||
const GdkEventPrivate *private = (const GdkEventPrivate *) event;
|
||||
|
||||
if (!event || event->type != GDK_SCROLL ||
|
||||
event->scroll.direction != GDK_SCROLL_SMOOTH ||
|
||||
!gdk_event_is_allocated (event))
|
||||
return FALSE;
|
||||
|
||||
if (delta_x)
|
||||
*delta_x = private->delta.x;
|
||||
if (delta_y)
|
||||
*delta_y = private->delta.y;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_event_get_event_sequence:
|
||||
* @event: a #GdkEvent
|
||||
*
|
||||
* If @event is a touch event, returns the #GdkEventSequence to which
|
||||
* the event belongs, as in GTK+ 3.4. Otherwise, return %NULL.
|
||||
*
|
||||
* Returns: (transfer none): the event sequence that the event belongs to
|
||||
*
|
||||
* Since: 2.24
|
||||
**/
|
||||
GdkEventSequence *
|
||||
gdk_event_get_event_sequence (const GdkEvent *event)
|
||||
{
|
||||
if (!event)
|
||||
return NULL;
|
||||
|
||||
if (event->type == GDK_TOUCH_BEGIN ||
|
||||
event->type == GDK_TOUCH_UPDATE ||
|
||||
event->type == GDK_TOUCH_END ||
|
||||
event->type == GDK_TOUCH_CANCEL)
|
||||
return event->touch.sequence;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_event_get_pointer_emulated:
|
||||
* @event: a #GdkEvent
|
||||
*
|
||||
* Tells whether a scroll event of a whole wheel step repeats what a
|
||||
* %GDK_SCROLL_SMOOTH event has already given; whoever handles the
|
||||
* smooth events ignores these.
|
||||
*
|
||||
* Return value: %TRUE if the event is emulated
|
||||
*
|
||||
* Since: 2.24
|
||||
**/
|
||||
gboolean
|
||||
gdk_event_get_pointer_emulated (GdkEvent *event)
|
||||
{
|
||||
return event && gdk_event_is_allocated (event) &&
|
||||
(((GdkEventPrivate *) event)->flags & GDK_EVENT_POINTER_EMULATED) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_event_get_touchpad_emulated:
|
||||
* @event: a #GdkEvent
|
||||
*
|
||||
* Tells whether @event was made of a gesture on a touchpad, for
|
||||
* programs that know nothing of those: a pinch arrives as scroll
|
||||
* events up (larger) and down (smaller) with %GDK_CONTROL_MASK, which
|
||||
* most programs that zoom take for zooming; a swipe sideways arrives
|
||||
* as a press and release of button 8 (back, swiping to the right) or
|
||||
* 9 (forward). GTK+'s own widgets do not scroll on such a pinch.
|
||||
*
|
||||
* Return value: %TRUE if the event was made of a touchpad gesture
|
||||
*
|
||||
* Since: 2.24
|
||||
**/
|
||||
gboolean
|
||||
gdk_event_get_touchpad_emulated (GdkEvent *event)
|
||||
{
|
||||
return event && gdk_event_is_allocated (event) &&
|
||||
(((GdkEventPrivate *) event)->flags & GDK_EVENT_TOUCHPAD_EMULATED) != 0;
|
||||
}
|
||||
|
||||
/* Touchpad gestures, as Windows hands them to its old programs: a
|
||||
* pinch is the wheel with Ctrl, one step for each 15 % the fingers
|
||||
* spread or close (up for larger, as browsers and image programs zoom
|
||||
* in then); a swipe sideways is the back or forward button. Nothing
|
||||
* is made unless a gesture comes. */
|
||||
#define TOUCHPAD_PINCH_STEP 0.14 /* ln 1.15 */
|
||||
|
||||
static GdkEvent *
|
||||
touchpad_event (const GdkEvent *template_event,
|
||||
GdkEventType type)
|
||||
{
|
||||
GdkEvent *event = gdk_event_new (type);
|
||||
GdkEventPrivate *private = (GdkEventPrivate *) event;
|
||||
|
||||
if (type == GDK_SCROLL)
|
||||
{
|
||||
event->scroll = template_event->scroll;
|
||||
event->scroll.type = GDK_SCROLL;
|
||||
event->scroll.state |= GDK_CONTROL_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
event->button.type = type;
|
||||
event->button.send_event = template_event->scroll.send_event;
|
||||
event->button.time = template_event->scroll.time;
|
||||
event->button.x = template_event->scroll.x;
|
||||
event->button.y = template_event->scroll.y;
|
||||
event->button.x_root = template_event->scroll.x_root;
|
||||
event->button.y_root = template_event->scroll.y_root;
|
||||
event->button.state = template_event->scroll.state;
|
||||
event->button.device = template_event->scroll.device;
|
||||
event->button.axes = NULL;
|
||||
}
|
||||
|
||||
event->any.window = template_event->any.window;
|
||||
if (event->any.window)
|
||||
g_object_ref (event->any.window);
|
||||
if (gdk_event_is_allocated (template_event))
|
||||
gdk_event_set_screen (event, ((GdkEventPrivate *) template_event)->screen);
|
||||
private->flags |= GDK_EVENT_TOUCHPAD_EMULATED;
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
/* The scroll steps of a pinch whose scale changed by @log_scale (its
|
||||
* logarithm) since the last call; @rest keeps what makes no whole step
|
||||
* yet, 0 when a pinch begins. @template_event is a scroll event with
|
||||
* window, time, place, state and device. */
|
||||
GList *
|
||||
_gdk_event_touchpad_pinch (const GdkEvent *template_event,
|
||||
gdouble log_scale,
|
||||
gdouble *rest)
|
||||
{
|
||||
GList *events = NULL;
|
||||
gint n;
|
||||
|
||||
/* turning the other way starts afresh */
|
||||
if (log_scale * *rest < 0)
|
||||
*rest = 0;
|
||||
*rest += log_scale;
|
||||
|
||||
n = (gint) CLAMP (*rest / TOUCHPAD_PINCH_STEP, -16, 16);
|
||||
*rest -= n * TOUCHPAD_PINCH_STEP;
|
||||
|
||||
for (; n != 0; n += n > 0 ? -1 : 1)
|
||||
{
|
||||
GdkEvent *event = touchpad_event (template_event, GDK_SCROLL);
|
||||
|
||||
event->scroll.direction = n > 0 ? GDK_SCROLL_UP : GDK_SCROLL_DOWN;
|
||||
events = g_list_prepend (events, event);
|
||||
}
|
||||
|
||||
return g_list_reverse (events);
|
||||
}
|
||||
|
||||
/* The press and release of the back button (8) for a swipe of @dx > 0
|
||||
* (to the right) or the forward button (9) for @dx < 0 */
|
||||
GList *
|
||||
_gdk_event_touchpad_swipe (const GdkEvent *template_event,
|
||||
gdouble dx)
|
||||
{
|
||||
GdkEvent *press, *release;
|
||||
guint button = dx > 0 ? 8 : 9;
|
||||
|
||||
if (dx == 0)
|
||||
return NULL;
|
||||
|
||||
press = touchpad_event (template_event, GDK_BUTTON_PRESS);
|
||||
press->button.button = button;
|
||||
release = touchpad_event (template_event, GDK_BUTTON_RELEASE);
|
||||
release->button.button = button;
|
||||
/* buttons past 5 have no bit in the state */
|
||||
|
||||
return g_list_append (g_list_append (NULL, press), release);
|
||||
}
|
||||
|
||||
/* GDK makes smooth scroll events only for GTK+'s event handler, which
|
||||
* knows who can take them; libgtk leaves it here when it sets it. A
|
||||
* program with a handler of its own sees what it always saw. */
|
||||
gboolean
|
||||
_gdk_event_handler_takes_smooth (void)
|
||||
{
|
||||
static GQuark quark;
|
||||
|
||||
if (!quark)
|
||||
quark = g_quark_from_static_string ("gdk-smooth-scroll-handler");
|
||||
|
||||
return _gdk_event_func != NULL &&
|
||||
(gpointer) _gdk_event_func == g_object_get_qdata (G_OBJECT (gdk_display_manager_get ()), quark);
|
||||
}
|
||||
|
||||
/* Whether any window has asked for GDK_SMOOTH_SCROLL_MASK: then smooth
|
||||
* scroll events are made for other event handlers than that of GTK+
|
||||
* as well, and gdk_window's event routing gives them only to those
|
||||
* windows (see _gdk_event_scroll_for_window()) */
|
||||
static gboolean smooth_scroll_wanted;
|
||||
|
||||
void
|
||||
_gdk_event_note_event_mask (GdkEventMask mask)
|
||||
{
|
||||
if (mask & GDK_SMOOTH_SCROLL_MASK)
|
||||
smooth_scroll_wanted = TRUE;
|
||||
}
|
||||
|
||||
/* Whether smooth scroll events are to be made at all */
|
||||
gboolean
|
||||
_gdk_event_smooth_scroll_wanted (void)
|
||||
{
|
||||
return smooth_scroll_wanted || _gdk_event_handler_takes_smooth ();
|
||||
}
|
||||
|
||||
/* Whether the scroll event @event goes to @window: a window with
|
||||
* GDK_SMOOTH_SCROLL_MASK takes the smooth events and not the whole
|
||||
* steps made of them, others the other way round. The event handler
|
||||
* of GTK+ gets them all and sorts them out per widget (gtkmain.c),
|
||||
* as GTK+'s own scrolled windows take smooth events too. */
|
||||
gboolean
|
||||
_gdk_event_scroll_for_window (GdkEvent *event,
|
||||
GdkWindow *window)
|
||||
{
|
||||
gboolean smooth_window;
|
||||
|
||||
if (event->type != GDK_SCROLL || _gdk_event_handler_takes_smooth ())
|
||||
return TRUE;
|
||||
|
||||
smooth_window = (gdk_window_get_events (window) & GDK_SMOOTH_SCROLL_MASK) != 0;
|
||||
if (event->scroll.direction == GDK_SCROLL_SMOOTH)
|
||||
return smooth_window;
|
||||
return !(smooth_window && gdk_event_get_pointer_emulated (event));
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_event_set_scroll_deltas (GdkEvent *event,
|
||||
gdouble delta_x,
|
||||
gdouble delta_y)
|
||||
{
|
||||
GdkEventPrivate *private = (GdkEventPrivate *) event;
|
||||
|
||||
event->scroll.direction = GDK_SCROLL_SMOOTH;
|
||||
private->delta.x = delta_x;
|
||||
private->delta.y = delta_y;
|
||||
}
|
||||
|
||||
static GdkEvent *
|
||||
scroll_event_from (GdkEvent **first,
|
||||
const GdkEvent *template_event)
|
||||
{
|
||||
GdkEvent *event = *first ? *first : gdk_event_new (GDK_SCROLL);
|
||||
|
||||
*first = NULL;
|
||||
event->scroll = template_event->scroll;
|
||||
event->scroll.type = GDK_SCROLL;
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
/* For backends whose system tells how far to scroll: makes of
|
||||
* @template_event (a scroll event but for the direction) a smooth
|
||||
* event of @delta_x, @delta_y if asked and GTK+ takes those, and the
|
||||
* whole steps of the wheel that @steps_x, @steps_y complete in @rest,
|
||||
* marked as emulated when the smooth event goes out as well. The
|
||||
* first event made goes into @first if there is one, the others to
|
||||
* @append, which takes their references. Returns whether any event
|
||||
* was made. */
|
||||
gboolean
|
||||
_gdk_event_emit_scroll (GdkEvent *first,
|
||||
const GdkEvent *template_event,
|
||||
gboolean smooth,
|
||||
gdouble delta_x,
|
||||
gdouble delta_y,
|
||||
gdouble steps_x,
|
||||
gdouble steps_y,
|
||||
gdouble rest[2],
|
||||
void (*append) (GdkEvent *event))
|
||||
{
|
||||
static const GdkScrollDirection direction[2][2] = {
|
||||
{ GDK_SCROLL_LEFT, GDK_SCROLL_RIGHT },
|
||||
{ GDK_SCROLL_UP, GDK_SCROLL_DOWN }
|
||||
};
|
||||
gdouble steps[2];
|
||||
gboolean made = FALSE;
|
||||
gint a, n;
|
||||
|
||||
steps[0] = steps_x;
|
||||
steps[1] = steps_y;
|
||||
|
||||
if (smooth && (delta_x != 0 || delta_y != 0) && _gdk_event_smooth_scroll_wanted ())
|
||||
{
|
||||
gboolean into_first = first != NULL;
|
||||
GdkEvent *event = scroll_event_from (&first, template_event);
|
||||
|
||||
_gdk_event_set_scroll_deltas (event, delta_x, delta_y);
|
||||
if (!into_first)
|
||||
append (event);
|
||||
made = TRUE;
|
||||
}
|
||||
else
|
||||
smooth = FALSE;
|
||||
|
||||
for (a = 0; a < 2; a++)
|
||||
{
|
||||
/* turning the other way starts afresh */
|
||||
if (steps[a] * rest[a] < 0)
|
||||
rest[a] = 0;
|
||||
rest[a] += steps[a];
|
||||
n = (gint) CLAMP (rest[a] + (rest[a] > 0 ? 1e-9 : -1e-9), -64, 64);
|
||||
rest[a] -= n;
|
||||
|
||||
for (; n != 0; n += n > 0 ? -1 : 1)
|
||||
{
|
||||
gboolean into_first = first != NULL;
|
||||
GdkEvent *event = scroll_event_from (&first, template_event);
|
||||
|
||||
event->scroll.direction = direction[a][n > 0];
|
||||
if (smooth)
|
||||
((GdkEventPrivate *) event)->flags |= GDK_EVENT_POINTER_EMULATED;
|
||||
if (!into_first)
|
||||
append (event);
|
||||
made = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return made;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_set_show_events:
|
||||
* @show_events: %TRUE to output event debugging information.
|
||||
|
|
|
|||
|
|
@ -64,6 +64,8 @@ typedef struct _GdkEventDND GdkEventDND;
|
|||
typedef struct _GdkEventWindowState GdkEventWindowState;
|
||||
typedef struct _GdkEventSetting GdkEventSetting;
|
||||
typedef struct _GdkEventGrabBroken GdkEventGrabBroken;
|
||||
typedef struct _GdkEventTouch GdkEventTouch;
|
||||
typedef struct _GdkEventSequence GdkEventSequence;
|
||||
|
||||
typedef union _GdkEvent GdkEvent;
|
||||
|
||||
|
|
@ -152,6 +154,11 @@ typedef enum
|
|||
GDK_OWNER_CHANGE = 34,
|
||||
GDK_GRAB_BROKEN = 35,
|
||||
GDK_DAMAGE = 36,
|
||||
/* as in GTK+ 3.4, for windows with GDK_TOUCH_MASK */
|
||||
GDK_TOUCH_BEGIN = 37,
|
||||
GDK_TOUCH_UPDATE = 38,
|
||||
GDK_TOUCH_END = 39,
|
||||
GDK_TOUCH_CANCEL = 40,
|
||||
GDK_EVENT_LAST /* helper variable for decls */
|
||||
} GdkEventType;
|
||||
|
||||
|
|
@ -181,9 +188,25 @@ typedef enum
|
|||
GDK_PROXIMITY_OUT_MASK = 1 << 19,
|
||||
GDK_SUBSTRUCTURE_MASK = 1 << 20,
|
||||
GDK_SCROLL_MASK = 1 << 21,
|
||||
/* as in GTK+ 3.4: the events of the fingers on a touch screen,
|
||||
* GDK_TOUCH_BEGIN to GDK_TOUCH_CANCEL; GDK makes pointer events of
|
||||
* the first finger for the windows that did not ask (see
|
||||
* gdk_event_get_pointer_emulated()). Not in GDK_ALL_EVENTS_MASK: a
|
||||
* program that does not ask keeps getting a touch as the pointer. */
|
||||
GDK_TOUCH_MASK = 1 << 22,
|
||||
/* as in GTK+ 3.4: %GDK_SCROLL_SMOOTH events with the distance (see
|
||||
* gdk_event_get_scroll_deltas()), and none of the whole wheel steps
|
||||
* made of them; not part of GDK_ALL_EVENTS_MASK, which old programs
|
||||
* use and which keeps the steps for them */
|
||||
GDK_SMOOTH_SCROLL_MASK = 1 << 23,
|
||||
GDK_ALL_EVENTS_MASK = 0x3FFFFE
|
||||
} GdkEventMask;
|
||||
|
||||
/* so that programs can ask with #ifdef whether GDK has it (GTK+ 2 from
|
||||
* gtk2-ng; GTK+ 3 has it from 3.4 on) */
|
||||
#define GDK_SMOOTH_SCROLL_MASK GDK_SMOOTH_SCROLL_MASK
|
||||
#define GDK_TOUCH_MASK GDK_TOUCH_MASK
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GDK_VISIBILITY_UNOBSCURED,
|
||||
|
|
@ -196,7 +219,8 @@ typedef enum
|
|||
GDK_SCROLL_UP,
|
||||
GDK_SCROLL_DOWN,
|
||||
GDK_SCROLL_LEFT,
|
||||
GDK_SCROLL_RIGHT
|
||||
GDK_SCROLL_RIGHT,
|
||||
GDK_SCROLL_SMOOTH
|
||||
} GdkScrollDirection;
|
||||
|
||||
/* Types of enter/leave notifications.
|
||||
|
|
@ -488,6 +512,47 @@ struct _GdkEventDND {
|
|||
gshort x_root, y_root;
|
||||
};
|
||||
|
||||
/**
|
||||
* GdkEventTouch:
|
||||
* @type: the type of the event (%GDK_TOUCH_BEGIN, %GDK_TOUCH_UPDATE,
|
||||
* %GDK_TOUCH_END, %GDK_TOUCH_CANCEL)
|
||||
* @window: the window which received the event
|
||||
* @send_event: %TRUE if the event was sent explicitly
|
||||
* @time: the time of the event in milliseconds
|
||||
* @x: the x coordinate of the touch relative to the window
|
||||
* @y: the y coordinate of the touch relative to the window
|
||||
* @axes: %NULL
|
||||
* @state: the modifier keys
|
||||
* @emulating_pointer: whether the event is the one of the finger that
|
||||
* also moves the pointer (the first one)
|
||||
* @sequence: what tells the touches of the fingers apart; the same
|
||||
* for all events of one finger, from begin to end
|
||||
* @device: the device where the event originated
|
||||
* @x_root: the x coordinate of the touch relative to the root of the screen
|
||||
* @y_root: the y coordinate of the touch relative to the root of the screen
|
||||
*
|
||||
* A touch on a touch screen, as in GTK+ 3.4, with the same fields;
|
||||
* @emulating_pointer comes before @sequence here, so that the event
|
||||
* fits in the GdkEvent of GTK+ 2.
|
||||
*
|
||||
* Since: 2.24
|
||||
*/
|
||||
struct _GdkEventTouch
|
||||
{
|
||||
GdkEventType type;
|
||||
GdkWindow *window;
|
||||
gint8 send_event;
|
||||
guint32 time;
|
||||
gdouble x;
|
||||
gdouble y;
|
||||
gdouble *axes;
|
||||
guint state;
|
||||
gboolean emulating_pointer;
|
||||
GdkEventSequence *sequence;
|
||||
GdkDevice *device;
|
||||
gdouble x_root, y_root;
|
||||
};
|
||||
|
||||
union _GdkEvent
|
||||
{
|
||||
GdkEventType type;
|
||||
|
|
@ -511,9 +576,10 @@ union _GdkEvent
|
|||
GdkEventWindowState window_state;
|
||||
GdkEventSetting setting;
|
||||
GdkEventGrabBroken grab_broken;
|
||||
GdkEventTouch touch;
|
||||
};
|
||||
|
||||
GType gdk_event_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_event_get_type (void);
|
||||
|
||||
gboolean gdk_events_pending (void);
|
||||
GdkEvent* gdk_event_get (void);
|
||||
|
|
@ -549,6 +615,13 @@ void gdk_event_set_screen (GdkEvent *event,
|
|||
GdkScreen *screen);
|
||||
GdkScreen *gdk_event_get_screen (const GdkEvent *event);
|
||||
|
||||
gboolean gdk_event_get_scroll_deltas (const GdkEvent *event,
|
||||
gdouble *delta_x,
|
||||
gdouble *delta_y);
|
||||
gboolean gdk_event_get_pointer_emulated (GdkEvent *event);
|
||||
gboolean gdk_event_get_touchpad_emulated (GdkEvent *event);
|
||||
GdkEventSequence *gdk_event_get_event_sequence (const GdkEvent *event);
|
||||
|
||||
void gdk_set_show_events (gboolean show_events);
|
||||
gboolean gdk_get_show_events (void);
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ struct _GdkFont
|
|||
gint descent;
|
||||
};
|
||||
|
||||
GType gdk_font_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_font_get_type (void);
|
||||
|
||||
GdkFont* gdk_font_ref (GdkFont *font);
|
||||
void gdk_font_unref (GdkFont *font);
|
||||
|
|
|
|||
77
gdk/gdkgc.c
77
gdk/gdkgc.c
|
|
@ -61,6 +61,9 @@ struct _GdkGCPrivate
|
|||
guint subwindow_mode : 1;
|
||||
guint fill : 2;
|
||||
guint exposures : 2;
|
||||
/* the clip of a window stays on after a drawing, see
|
||||
* _gdk_gc_set_draw_origins() */
|
||||
guint drawable_clip_kept : 1;
|
||||
};
|
||||
|
||||
#define GDK_GC_GET_PRIVATE(o) ((GdkGCPrivate *) gdk_gc_get_instance_private (GDK_GC (o)))
|
||||
|
|
@ -758,11 +761,66 @@ _gdk_gc_add_drawable_clip (GdkGC *gc,
|
|||
priv->region_tag_offset_y = offset_y;
|
||||
}
|
||||
|
||||
/* For drawing to a window inside the paint of a parent: moves the clip
|
||||
* and tile origins of @gc there for the drawing, and back after it
|
||||
* (@drawing_done), without taking off the clip of the window that
|
||||
* _gdk_gc_add_drawable_clip() puts on, as setting the clip origin does.
|
||||
* That clip is relative to the clip origin of the caller, which these
|
||||
* moves keep, so the next drawing to the window finds it still in
|
||||
* place, instead of making it anew and sending it to the X server.
|
||||
*
|
||||
* Where a GC is used for drawing directly by the caller, with
|
||||
* gdk_x11_gc_get_xgc(), the clip of the window is taken off first, as
|
||||
* it was before. Other backends set the clip of a GC for each drawing
|
||||
* themselves, from the same region the raw drawing functions use, so
|
||||
* the clip of the window is taken off after a drawing there. */
|
||||
void
|
||||
_gdk_gc_set_draw_origins (GdkGC *gc,
|
||||
gint clip_x,
|
||||
gint clip_y,
|
||||
gint ts_x,
|
||||
gint ts_y,
|
||||
gboolean drawing_done)
|
||||
{
|
||||
GdkGCPrivate *priv = GDK_GC_GET_PRIVATE (gc);
|
||||
GdkGCValues values;
|
||||
|
||||
#ifndef GDK_WINDOWING_X11
|
||||
if (drawing_done)
|
||||
{
|
||||
gdk_gc_set_clip_origin (gc, clip_x, clip_y);
|
||||
gdk_gc_set_ts_origin (gc, ts_x, ts_y);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
priv->drawable_clip_kept = drawing_done && priv->region_tag_applied != 0;
|
||||
|
||||
gc->clip_x_origin = values.clip_x_origin = clip_x;
|
||||
gc->clip_y_origin = values.clip_y_origin = clip_y;
|
||||
gc->ts_x_origin = values.ts_x_origin = ts_x;
|
||||
gc->ts_y_origin = values.ts_y_origin = ts_y;
|
||||
|
||||
GDK_GC_GET_CLASS (gc)->set_values (gc, &values,
|
||||
GDK_GC_CLIP_X_ORIGIN | GDK_GC_CLIP_Y_ORIGIN |
|
||||
GDK_GC_TS_X_ORIGIN | GDK_GC_TS_Y_ORIGIN);
|
||||
}
|
||||
|
||||
/* Takes off a clip of a window that _gdk_gc_set_draw_origins() left on */
|
||||
void
|
||||
_gdk_gc_remove_kept_drawable_clip (GdkGC *gc)
|
||||
{
|
||||
if (GDK_GC_GET_PRIVATE (gc)->drawable_clip_kept)
|
||||
_gdk_gc_remove_drawable_clip (gc);
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_gc_remove_drawable_clip (GdkGC *gc)
|
||||
{
|
||||
GdkGCPrivate *priv = GDK_GC_GET_PRIVATE (gc);
|
||||
|
||||
priv->drawable_clip_kept = FALSE;
|
||||
|
||||
if (priv->region_tag_applied)
|
||||
{
|
||||
priv->region_tag_applied = 0;
|
||||
|
|
@ -1194,6 +1252,7 @@ gdk_gc_copy (GdkGC *dst_gc,
|
|||
dst_priv->clip_region = NULL;
|
||||
|
||||
dst_priv->region_tag_applied = src_priv->region_tag_applied;
|
||||
dst_priv->drawable_clip_kept = src_priv->drawable_clip_kept;
|
||||
|
||||
if (dst_priv->old_clip_region)
|
||||
gdk_region_destroy (dst_priv->old_clip_region);
|
||||
|
|
@ -1453,6 +1512,8 @@ gc_get_background (GdkGC *gc,
|
|||
* last call to this function
|
||||
* @target_drawable: The drawable you're drawing in. If passed in
|
||||
* this is used for client side window clip emulation.
|
||||
* @cr_is_new: %TRUE if @cr comes straight from gdk_cairo_create()
|
||||
* on @target_drawable, which has set the window clip already
|
||||
*
|
||||
* Set the attributes of a cairo context to match those of a #GdkGC
|
||||
* as far as possible. Some aspects of a #GdkGC, such as clip masks
|
||||
|
|
@ -1464,7 +1525,8 @@ _gdk_gc_update_context (GdkGC *gc,
|
|||
const GdkColor *override_foreground,
|
||||
GdkBitmap *override_stipple,
|
||||
gboolean gc_changed,
|
||||
GdkDrawable *target_drawable)
|
||||
GdkDrawable *target_drawable,
|
||||
gboolean cr_is_new)
|
||||
{
|
||||
GdkGCPrivate *priv;
|
||||
GdkFill fill;
|
||||
|
|
@ -1570,10 +1632,15 @@ _gdk_gc_update_context (GdkGC *gc,
|
|||
if (!gc_changed)
|
||||
return;
|
||||
|
||||
cairo_reset_clip (cr);
|
||||
/* The reset above resets the window clip rect, so we want to re-set that */
|
||||
if (target_drawable && GDK_DRAWABLE_GET_CLASS (target_drawable)->set_cairo_clip)
|
||||
GDK_DRAWABLE_GET_CLASS (target_drawable)->set_cairo_clip (target_drawable, cr);
|
||||
/* a new context has the window clip and no other: building the
|
||||
* window clip again from its region is work for nothing */
|
||||
if (!cr_is_new)
|
||||
{
|
||||
cairo_reset_clip (cr);
|
||||
/* The reset above resets the window clip rect, so we want to re-set that */
|
||||
if (target_drawable && GDK_DRAWABLE_GET_CLASS (target_drawable)->set_cairo_clip)
|
||||
GDK_DRAWABLE_GET_CLASS (target_drawable)->set_cairo_clip (target_drawable, cr);
|
||||
}
|
||||
|
||||
if (priv->clip_region)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ struct _GdkGCClass
|
|||
|
||||
|
||||
#ifndef GDK_DISABLE_DEPRECATED
|
||||
GType gdk_gc_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_gc_get_type (void);
|
||||
GdkGC *gdk_gc_new (GdkDrawable *drawable);
|
||||
GdkGC *gdk_gc_new_with_values (GdkDrawable *drawable,
|
||||
GdkGCValues *values,
|
||||
|
|
|
|||
|
|
@ -655,5 +655,66 @@ gdk_image_new (GdkImageType type,
|
|||
visual, width, height, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* _gdk_image_read_row:
|
||||
* @image: a #GdkImage
|
||||
* @x: the first pixel
|
||||
* @y: the row
|
||||
* @width: how many pixels
|
||||
* @pixels: where to put the pixel values
|
||||
*
|
||||
* Reads pixel values of any number of bits per pixel and either byte
|
||||
* order; for less than 8 bits, the byte order is the order of the
|
||||
* pixels in a byte, too.
|
||||
*/
|
||||
void
|
||||
_gdk_image_read_row (GdkImage *image,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
guint32 *pixels)
|
||||
{
|
||||
const guchar *in = (const guchar *) image->mem + y * image->bpl;
|
||||
const gboolean msb = image->byte_order == GDK_MSB_FIRST;
|
||||
const gint bits = image->bits_per_pixel;
|
||||
gint i;
|
||||
|
||||
if (bits < 8)
|
||||
{
|
||||
const guint mask = (1 << bits) - 1;
|
||||
|
||||
for (i = 0; i < width; i++)
|
||||
{
|
||||
const gint bit = (x + i) * bits;
|
||||
|
||||
pixels[i] = (in[bit >> 3] >> (msb ? 8 - bits - (bit & 7) : bit & 7)) & mask;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
in += x * (bits / 8);
|
||||
switch (bits)
|
||||
{
|
||||
case 8:
|
||||
for (i = 0; i < width; i++)
|
||||
pixels[i] = in[i];
|
||||
break;
|
||||
case 16:
|
||||
for (i = 0; i < width; i++, in += 2)
|
||||
pixels[i] = msb ? (in[0] << 8) | in[1] : in[0] | (in[1] << 8);
|
||||
break;
|
||||
case 24:
|
||||
for (i = 0; i < width; i++, in += 3)
|
||||
pixels[i] = msb ? (in[0] << 16) | (in[1] << 8) | in[2]
|
||||
: in[0] | (in[1] << 8) | (in[2] << 16);
|
||||
break;
|
||||
case 32:
|
||||
for (i = 0; i < width; i++, in += 4)
|
||||
pixels[i] = msb ? ((guint32) in[0] << 24) | (in[1] << 16) | (in[2] << 8) | in[3]
|
||||
: in[0] | (in[1] << 8) | (in[2] << 16) | ((guint32) in[3] << 24);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#define __GDK_IMAGE_C__
|
||||
#include "gdkaliasdef.c"
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ struct _GdkImageClass
|
|||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
GType gdk_image_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_image_get_type (void);
|
||||
|
||||
#ifndef GDK_DISABLE_DEPRECATED
|
||||
GdkImage* gdk_image_new (GdkImageType type,
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ struct _GdkTimeCoord
|
|||
gdouble axes[GDK_MAX_TIMECOORD_AXES];
|
||||
};
|
||||
|
||||
GType gdk_device_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_device_get_type (void);
|
||||
|
||||
#ifndef GDK_MULTIHEAD_SAFE
|
||||
/* Returns a list of GdkDevice * */
|
||||
|
|
|
|||
|
|
@ -33,9 +33,6 @@
|
|||
#include <gdk/gdktypes.h>
|
||||
#include <gdk/gdkwindow.h>
|
||||
#include <gdk/gdkprivate.h>
|
||||
#ifdef USE_MEDIALIB
|
||||
#include <gdk/gdkmedialib.h>
|
||||
#endif
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
|
@ -166,7 +163,19 @@ typedef enum
|
|||
/* Following flag is set for events on the event queue during
|
||||
* translation and cleared afterwards.
|
||||
*/
|
||||
GDK_EVENT_PENDING = 1 << 0
|
||||
GDK_EVENT_PENDING = 1 << 0,
|
||||
|
||||
/* A scroll event from a wheel step that a smooth scroll event with
|
||||
* the same time has already given */
|
||||
GDK_EVENT_POINTER_EMULATED = 1 << 1,
|
||||
|
||||
/* A touch for which the window system sends the pointer events of
|
||||
* the first finger itself (Windows), so GDK need not make them */
|
||||
GDK_EVENT_TOUCH_SYSTEM_POINTER = 1 << 2,
|
||||
|
||||
/* A scroll or button event made of a touchpad gesture for programs
|
||||
* that know nothing of those (gdk_event_get_touchpad_emulated()) */
|
||||
GDK_EVENT_TOUCHPAD_EMULATED = 1 << 3
|
||||
} GdkEventFlags;
|
||||
|
||||
struct _GdkEventPrivate
|
||||
|
|
@ -174,7 +183,16 @@ struct _GdkEventPrivate
|
|||
GdkEvent event;
|
||||
guint flags;
|
||||
GdkScreen *screen;
|
||||
gpointer windowing_data;
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
gpointer windowing_data; /* the NSEvent */
|
||||
#endif
|
||||
/* the steps of a GDK_SCROLL_SMOOTH event, where elsewhere a
|
||||
* windowing_data pointer nobody used was */
|
||||
struct
|
||||
{
|
||||
gfloat x;
|
||||
gfloat y;
|
||||
} delta;
|
||||
};
|
||||
|
||||
/* Tracks information about the pointer grab on this display */
|
||||
|
|
@ -291,6 +309,30 @@ extern GdkEventFunc _gdk_event_func; /* Callback for events */
|
|||
extern gpointer _gdk_event_data;
|
||||
extern GDestroyNotify _gdk_event_notify;
|
||||
|
||||
gboolean _gdk_event_handler_takes_smooth (void);
|
||||
gboolean _gdk_event_smooth_scroll_wanted (void);
|
||||
|
||||
GList *_gdk_event_touchpad_pinch (const GdkEvent *template_event,
|
||||
gdouble log_scale,
|
||||
gdouble *rest);
|
||||
GList *_gdk_event_touchpad_swipe (const GdkEvent *template_event,
|
||||
gdouble dx);
|
||||
void _gdk_event_note_event_mask (GdkEventMask mask);
|
||||
gboolean _gdk_event_scroll_for_window (GdkEvent *event,
|
||||
GdkWindow *window);
|
||||
void _gdk_event_set_scroll_deltas (GdkEvent *event,
|
||||
gdouble delta_x,
|
||||
gdouble delta_y);
|
||||
gboolean _gdk_event_emit_scroll (GdkEvent *first,
|
||||
const GdkEvent *template_event,
|
||||
gboolean smooth,
|
||||
gdouble delta_x,
|
||||
gdouble delta_y,
|
||||
gdouble steps_x,
|
||||
gdouble steps_y,
|
||||
gdouble rest[2],
|
||||
void (*append) (GdkEvent *event));
|
||||
|
||||
extern GSList *_gdk_displays;
|
||||
extern gchar *_gdk_display_name;
|
||||
extern gint _gdk_screen_number;
|
||||
|
|
@ -335,6 +377,11 @@ GdkImage* _gdk_image_new_for_depth (GdkScreen *screen,
|
|||
gint width,
|
||||
gint height,
|
||||
gint depth);
|
||||
void _gdk_image_read_row (GdkImage *image,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
guint32 *pixels);
|
||||
GdkImage *_gdk_image_get_scratch (GdkScreen *screen,
|
||||
gint width,
|
||||
gint height,
|
||||
|
|
@ -361,14 +408,36 @@ cairo_surface_t * _gdk_drawable_create_cairo_surface (GdkDrawable *drawable,
|
|||
/* GC caching */
|
||||
GdkGC *_gdk_drawable_get_scratch_gc (GdkDrawable *drawable,
|
||||
gboolean graphics_exposures);
|
||||
|
||||
GdkGC *_gdk_drawable_get_subwindow_scratch_gc (GdkDrawable *drawable);
|
||||
|
||||
/* GdkRGB */
|
||||
gboolean _gdk_rgb_composite (GdkColormap *colormap,
|
||||
GdkImage *image,
|
||||
gint x0,
|
||||
gint y0,
|
||||
gint width,
|
||||
gint height,
|
||||
const guchar *rgba,
|
||||
gint rowstride,
|
||||
GdkRgbDither dither);
|
||||
gboolean _gdk_rgb_prefers_own_blending (GdkColormap *colormap,
|
||||
GdkRgbDither dither);
|
||||
|
||||
gint _gdk_window_get_cairo_clip_n_rects (GdkWindow *window);
|
||||
void _gdk_window_set_cairo_clip_in_area (GdkWindow *window,
|
||||
cairo_t *cr,
|
||||
const GdkRectangle *area);
|
||||
cairo_t *_gdk_cairo_create_in_area (GdkDrawable *drawable,
|
||||
const GdkRectangle *area);
|
||||
|
||||
void _gdk_gc_update_context (GdkGC *gc,
|
||||
cairo_t *cr,
|
||||
const GdkColor *override_foreground,
|
||||
GdkBitmap *override_stipple,
|
||||
gboolean gc_changed,
|
||||
GdkDrawable *target_drawable);
|
||||
GdkDrawable *target_drawable,
|
||||
gboolean cr_is_new);
|
||||
|
||||
/*************************************
|
||||
* Interfaces used by windowing code *
|
||||
|
|
@ -429,6 +498,13 @@ void _gdk_gc_add_drawable_clip (GdkGC *gc,
|
|||
int offset_x,
|
||||
int offset_y);
|
||||
void _gdk_gc_remove_drawable_clip (GdkGC *gc);
|
||||
void _gdk_gc_set_draw_origins (GdkGC *gc,
|
||||
gint clip_x,
|
||||
gint clip_y,
|
||||
gint ts_x,
|
||||
gint ts_y,
|
||||
gboolean drawing_done);
|
||||
void _gdk_gc_remove_kept_drawable_clip (GdkGC *gc);
|
||||
void _gdk_gc_set_clip_region_internal (GdkGC *gc,
|
||||
GdkRegion *region,
|
||||
gboolean reset_origin);
|
||||
|
|
@ -538,11 +614,11 @@ struct _GdkPaintableIface
|
|||
void (* end_paint) (GdkPaintable *paintable);
|
||||
};
|
||||
|
||||
GType _gdk_paintable_get_type (void) G_GNUC_CONST;
|
||||
GType _gdk_paintable_get_type (void);
|
||||
|
||||
/* Implementation types */
|
||||
GType _gdk_window_impl_get_type (void) G_GNUC_CONST;
|
||||
GType _gdk_pixmap_impl_get_type (void) G_GNUC_CONST;
|
||||
GType _gdk_window_impl_get_type (void);
|
||||
GType _gdk_pixmap_impl_get_type (void);
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -630,6 +706,24 @@ void _gdk_display_enable_motion_hints (GdkDisplay *display);
|
|||
|
||||
void _gdk_window_invalidate_for_expose (GdkWindow *window,
|
||||
GdkRegion *region);
|
||||
void _gdk_window_reapply_shapes (GdkWindow *window);
|
||||
|
||||
/* HiDPI: how many pixels of the window system make one of GDK in each
|
||||
* direction, for a drawable (window, pixmap or their implementation) and
|
||||
* for a monitor (-1: the screen's default); 1 where the backend does not
|
||||
* scale */
|
||||
gint _gdk_windowing_drawable_get_scale (GdkDrawable *drawable);
|
||||
GdkPixbuf *_gdk_pixbuf_get_hires (GdkPixbuf *pixbuf,
|
||||
gint scale);
|
||||
gint _gdk_windowing_screen_get_monitor_scale (GdkScreen *screen,
|
||||
gint monitor_num);
|
||||
void _gdk_cairo_surface_set_device_offset (cairo_surface_t *surface,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
/* HiDPI: for surfaces whose window system scales by itself, without a
|
||||
* device scale of cairo (Quartz): its pixels per pixel of GDK */
|
||||
void _gdk_cairo_surface_set_hidpi_scale (cairo_surface_t *surface,
|
||||
gint scale);
|
||||
|
||||
void _gdk_windowing_set_cairo_surface_size (cairo_surface_t *surface,
|
||||
int width,
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ struct _GdkKeymapClass
|
|||
void (*state_changed) (GdkKeymap *keymap);
|
||||
};
|
||||
|
||||
GType gdk_keymap_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_keymap_get_type (void);
|
||||
|
||||
#ifndef GDK_MULTIHEAD_SAFE
|
||||
GdkKeymap* gdk_keymap_get_default (void);
|
||||
|
|
|
|||
|
|
@ -1,120 +0,0 @@
|
|||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 2001-2007 Sun Microsystems, Inc. All rights reserved.
|
||||
* (Brian Cameron, Dmitriy Demin, James Cheng, Padraig O'Briain)
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modified by the GTK+ Team and others 1997-2007. 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/.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_SYS_SYSTEMINFO_H)
|
||||
#include <sys/systeminfo.h>
|
||||
#elif defined(HAVE_SYS_SYSINFO_H)
|
||||
#include <sys/sysinfo.h>
|
||||
#endif
|
||||
|
||||
#include "gdkmedialib.h"
|
||||
|
||||
typedef char * (*ml_version) (void);
|
||||
|
||||
static ml_version medialib_version = mlib_version;
|
||||
|
||||
gboolean
|
||||
_gdk_use_medialib (void)
|
||||
{
|
||||
char *mlib_version_string;
|
||||
char sys_info[257];
|
||||
long count;
|
||||
|
||||
/*
|
||||
* Sun mediaLib(tm) support.
|
||||
*
|
||||
* http://www.sun.com/processors/vis/mlib.html
|
||||
*
|
||||
*/
|
||||
if (getenv ("GDK_DISABLE_MEDIALIB"))
|
||||
return FALSE;
|
||||
|
||||
/*
|
||||
* The imaging functions we want to use were added in mediaLib version 2.
|
||||
* So turn off mediaLib support if the user has an older version.
|
||||
* mlib_version returns a string in this format:
|
||||
*
|
||||
* mediaLib:0210:20011101:v8plusa
|
||||
* ^^^^^^^^ ^^^^ ^^^^^^^^ ^^^^^^^
|
||||
* libname vers build ISALIST identifier
|
||||
* date (in this case sparcv8plus+vis)
|
||||
*
|
||||
* The first 2 digits of the version are the major version. The 3rd digit
|
||||
* is the minor version, and the 4th digit is the micro version. So the
|
||||
* above string corresponds to version 2.1.0.In the following test we only
|
||||
* care about the major version.
|
||||
*/
|
||||
mlib_version_string = medialib_version ();
|
||||
|
||||
count = sysinfo (SI_ARCHITECTURE, &sys_info[0], 257);
|
||||
|
||||
if (count != -1)
|
||||
{
|
||||
if (strcmp (sys_info, "i386") == 0)
|
||||
{
|
||||
char *mlib_target_isa = &mlib_version_string[23];
|
||||
|
||||
/*
|
||||
* For x86 processors mediaLib generic C implementation
|
||||
* does not give any performance advantage so disable it.
|
||||
*/
|
||||
if (strncmp (mlib_target_isa, "sse", 3) != 0)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* For x86 processors use of libumem conflicts with
|
||||
* mediaLib, so avoid using it.
|
||||
*/
|
||||
if (dlsym (RTLD_PROBE, "umem_alloc") != NULL)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Failed to get system architecture, disable mediaLib */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -59,6 +59,12 @@ struct _GdkPangoRendererPrivate
|
|||
GdkGC *base_gc;
|
||||
|
||||
gboolean gc_changed;
|
||||
|
||||
/* what gdk_draw_layout[_line]_with_colors() draws, where, for the
|
||||
* clip (see get_cairo_context()) */
|
||||
PangoLayout *area_layout;
|
||||
PangoLayoutLine *area_line;
|
||||
gint area_x, area_y;
|
||||
};
|
||||
|
||||
static PangoAttrType gdk_pango_attr_stipple_type;
|
||||
|
|
@ -155,18 +161,62 @@ color_equal (const PangoColor *c1, const PangoColor *c2)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/* Where gdk_draw_layout[_line]_with_colors() draws: the ink and the
|
||||
* logical extents, with room around for the emboss and for pixels of
|
||||
* glyphs that antialiasing puts a little outside their ink. Only asked
|
||||
* for when the clip of the window has more than a few rectangles. */
|
||||
#define DRAW_AREA_MARGIN 4
|
||||
|
||||
static gboolean
|
||||
get_draw_area (GdkPangoRendererPrivate *priv,
|
||||
GdkRectangle *area)
|
||||
{
|
||||
PangoRectangle ink, logical;
|
||||
|
||||
if (priv->area_layout)
|
||||
pango_layout_get_pixel_extents (priv->area_layout, &ink, &logical);
|
||||
else if (priv->area_line)
|
||||
pango_layout_line_get_pixel_extents (priv->area_line, &ink, &logical);
|
||||
else
|
||||
return FALSE;
|
||||
|
||||
if (ink.width <= 0 || ink.height <= 0)
|
||||
ink = logical;
|
||||
|
||||
area->x = MIN (ink.x, logical.x);
|
||||
area->y = MIN (ink.y, logical.y);
|
||||
area->width = MAX (ink.x + ink.width, logical.x + logical.width) - area->x;
|
||||
area->height = MAX (ink.y + ink.height, logical.y + logical.height) - area->y;
|
||||
|
||||
area->x += priv->area_x - DRAW_AREA_MARGIN;
|
||||
area->y += priv->area_y - DRAW_AREA_MARGIN;
|
||||
area->width += 2 * DRAW_AREA_MARGIN;
|
||||
area->height += 2 * DRAW_AREA_MARGIN;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static cairo_t *
|
||||
get_cairo_context (GdkPangoRenderer *gdk_renderer,
|
||||
PangoRenderPart part)
|
||||
{
|
||||
PangoRenderer *renderer = PANGO_RENDERER (gdk_renderer);
|
||||
GdkPangoRendererPrivate *priv = gdk_renderer->priv;
|
||||
gboolean cr_is_new = FALSE;
|
||||
|
||||
if (!priv->cr)
|
||||
{
|
||||
const PangoMatrix *matrix;
|
||||
GdkRectangle area;
|
||||
|
||||
priv->cr = gdk_cairo_create (priv->drawable);
|
||||
if ((priv->area_layout || priv->area_line) &&
|
||||
GDK_IS_WINDOW (priv->drawable) &&
|
||||
_gdk_window_get_cairo_clip_n_rects ((GdkWindow *) priv->drawable) > 2 &&
|
||||
get_draw_area (priv, &area))
|
||||
priv->cr = _gdk_cairo_create_in_area (priv->drawable, &area);
|
||||
else
|
||||
priv->cr = gdk_cairo_create (priv->drawable);
|
||||
cr_is_new = TRUE;
|
||||
|
||||
matrix = pango_renderer_get_matrix (renderer);
|
||||
if (matrix)
|
||||
|
|
@ -216,7 +266,8 @@ get_cairo_context (GdkPangoRenderer *gdk_renderer,
|
|||
color,
|
||||
priv->stipple[part],
|
||||
priv->gc_changed,
|
||||
priv->drawable);
|
||||
priv->drawable,
|
||||
cr_is_new);
|
||||
}
|
||||
|
||||
priv->last_part = part;
|
||||
|
|
@ -839,6 +890,9 @@ release_renderer (PangoRenderer *renderer)
|
|||
|
||||
gdk_pango_renderer_set_drawable (gdk_renderer, NULL);
|
||||
gdk_pango_renderer_set_gc (gdk_renderer, NULL);
|
||||
|
||||
gdk_renderer->priv->area_layout = NULL;
|
||||
gdk_renderer->priv->area_line = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -911,7 +965,16 @@ gdk_draw_layout_line_with_colors (GdkDrawable *drawable,
|
|||
y = 0;
|
||||
}
|
||||
else
|
||||
pango_renderer_set_matrix (renderer, NULL);
|
||||
{
|
||||
GdkPangoRendererPrivate *priv = GDK_PANGO_RENDERER (renderer)->priv;
|
||||
|
||||
pango_renderer_set_matrix (renderer, NULL);
|
||||
|
||||
/* without a matrix, the extents of the line say where it goes */
|
||||
priv->area_line = line;
|
||||
priv->area_x = x;
|
||||
priv->area_y = y;
|
||||
}
|
||||
|
||||
pango_renderer_draw_layout_line (renderer, line, x * PANGO_SCALE, y * PANGO_SCALE);
|
||||
|
||||
|
|
@ -991,7 +1054,16 @@ gdk_draw_layout_with_colors (GdkDrawable *drawable,
|
|||
y = 0;
|
||||
}
|
||||
else
|
||||
pango_renderer_set_matrix (renderer, NULL);
|
||||
{
|
||||
GdkPangoRendererPrivate *priv = GDK_PANGO_RENDERER (renderer)->priv;
|
||||
|
||||
pango_renderer_set_matrix (renderer, NULL);
|
||||
|
||||
/* without a matrix, the extents of the layout say where it goes */
|
||||
priv->area_layout = layout;
|
||||
priv->area_x = x;
|
||||
priv->area_y = y;
|
||||
}
|
||||
|
||||
pango_renderer_draw_layout (renderer, layout, x * PANGO_SCALE, y * PANGO_SCALE);
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ struct _GdkPangoRendererClass
|
|||
PangoRendererClass parent_class;
|
||||
};
|
||||
|
||||
GType gdk_pango_renderer_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_pango_renderer_get_type (void);
|
||||
|
||||
PangoRenderer *gdk_pango_renderer_new (GdkScreen *screen);
|
||||
PangoRenderer *gdk_pango_renderer_get_default (GdkScreen *screen);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -740,6 +740,12 @@ gdk_pixmap_colormap_create_from_xpm (GdkDrawable *drawable,
|
|||
if (colormap == NULL)
|
||||
colormap = gdk_drawable_get_colormap (drawable);
|
||||
|
||||
/* no mask either if the image cannot be read (gdk-pixbuf may come
|
||||
* without its XPM loader): callers use it without looking at the
|
||||
* pixmap first */
|
||||
if (mask)
|
||||
*mask = NULL;
|
||||
|
||||
pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
|
||||
if (!pixbuf)
|
||||
return NULL;
|
||||
|
|
@ -823,6 +829,12 @@ gdk_pixmap_colormap_create_from_xpm_d (GdkDrawable *drawable,
|
|||
if (colormap == NULL)
|
||||
colormap = gdk_drawable_get_colormap (drawable);
|
||||
|
||||
/* no mask either if the image cannot be read (gdk-pixbuf may come
|
||||
* without its XPM loader): callers use it without looking at the
|
||||
* pixmap first */
|
||||
if (mask)
|
||||
*mask = NULL;
|
||||
|
||||
pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **)data);
|
||||
if (!pixbuf)
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ struct _GdkPixmapObjectClass
|
|||
|
||||
};
|
||||
|
||||
GType gdk_pixmap_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_pixmap_get_type (void);
|
||||
|
||||
/* Pixmaps
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ typedef enum
|
|||
GDK_PROP_MODE_APPEND
|
||||
} GdkPropMode;
|
||||
|
||||
GType gdk_atom_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_atom_get_type (void);
|
||||
GdkAtom gdk_atom_intern (const gchar *atom_name,
|
||||
gboolean only_if_exists);
|
||||
GdkAtom gdk_atom_intern_static_string (const gchar *atom_name);
|
||||
|
|
|
|||
|
|
@ -611,6 +611,36 @@ gdk_region_intersect (GdkRegion *source1,
|
|||
if ((!(source1->numRects)) || (!(source2->numRects)) ||
|
||||
(!EXTENTCHECK(&source1->extents, &source2->extents)))
|
||||
source1->numRects = 0;
|
||||
/* Mostly one of the two is a rectangle: an expose area, a window,
|
||||
* a clip rectangle. Then a rectangle around the other is the other,
|
||||
* and two rectangles meet in one. */
|
||||
else if (source2->numRects == 1 &&
|
||||
source2->extents.x1 <= source1->extents.x1 &&
|
||||
source2->extents.y1 <= source1->extents.y1 &&
|
||||
source2->extents.x2 >= source1->extents.x2 &&
|
||||
source2->extents.y2 >= source1->extents.y2)
|
||||
return;
|
||||
else if (source1->numRects == 1 &&
|
||||
source1->extents.x1 <= source2->extents.x1 &&
|
||||
source1->extents.y1 <= source2->extents.y1 &&
|
||||
source1->extents.x2 >= source2->extents.x2 &&
|
||||
source1->extents.y2 >= source2->extents.y2)
|
||||
{
|
||||
miRegionCopy (source1, source2);
|
||||
return;
|
||||
}
|
||||
else if (source1->numRects == 1 && source2->numRects == 1)
|
||||
{
|
||||
GdkRegionBox box;
|
||||
|
||||
box.x1 = MAX (source1->extents.x1, source2->extents.x1);
|
||||
box.y1 = MAX (source1->extents.y1, source2->extents.y1);
|
||||
box.x2 = MIN (source1->extents.x2, source2->extents.x2);
|
||||
box.y2 = MIN (source1->extents.y2, source2->extents.y2);
|
||||
source1->rects[0] = box;
|
||||
source1->extents = box;
|
||||
return;
|
||||
}
|
||||
else
|
||||
miRegionOp (source1, source1, source2,
|
||||
miIntersectO, (nonOverlapFunc) NULL, (nonOverlapFunc) NULL);
|
||||
|
|
|
|||
426
gdk/gdkrgb-altivec.c
Normal file
426
gdk/gdkrgb-altivec.c
Normal file
|
|
@ -0,0 +1,426 @@
|
|||
/* GDK - The GIMP Drawing Kit
|
||||
* GdkRGB loops for AltiVec (PowerPC G4 and G5)
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkrgbsimd.h"
|
||||
|
||||
#if defined(__ALTIVEC__) && defined(__BIG_ENDIAN__)
|
||||
|
||||
#include <altivec.h>
|
||||
|
||||
/* An x888 pixel is the bytes 0xff, R, G, B; a 565 pixel is a big
|
||||
* endian 16-bit word. Vector loads and stores need 16-byte aligned
|
||||
* addresses: loads are put together from two, and each loop starts
|
||||
* with single pixels until the output is aligned. */
|
||||
|
||||
typedef vector unsigned char vu8;
|
||||
typedef vector unsigned short vu16;
|
||||
typedef vector unsigned int vu32;
|
||||
|
||||
#define VU8(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \
|
||||
((vu8) { a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p })
|
||||
|
||||
/* Reads 16 bytes after 16 bytes from any address, one aligned load
|
||||
* each; never reads a block that holds none of the bytes asked for.
|
||||
* Set up only when at least 16 bytes will be read. */
|
||||
typedef struct
|
||||
{
|
||||
const guchar *p;
|
||||
vu8 perm, last;
|
||||
gboolean aligned;
|
||||
} Reader;
|
||||
|
||||
static inline void
|
||||
reader_init (Reader *r, const guchar *p)
|
||||
{
|
||||
r->p = p;
|
||||
r->aligned = ((gsize) p & 15) == 0;
|
||||
r->perm = vec_lvsl (0, p);
|
||||
r->last = vec_ld (0, p);
|
||||
}
|
||||
|
||||
static inline vu8
|
||||
reader_next (Reader *r)
|
||||
{
|
||||
vu8 v;
|
||||
|
||||
if (r->aligned)
|
||||
v = vec_ld (0, r->p);
|
||||
else
|
||||
{
|
||||
/* the block of the 16th byte follows the block of the first */
|
||||
vu8 next = vec_ld (15, r->p);
|
||||
|
||||
v = vec_perm (r->last, next, r->perm);
|
||||
r->last = next;
|
||||
}
|
||||
r->p += 16;
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
aligned (const void *p)
|
||||
{
|
||||
return ((gsize) p & 15) == 0;
|
||||
}
|
||||
|
||||
static inline guint32
|
||||
x888 (const guchar *p)
|
||||
{
|
||||
return 0xff000000 | (p[0] << 16) | (p[1] << 8) | p[2];
|
||||
}
|
||||
|
||||
static inline guint16
|
||||
rgb565 (const guchar *p)
|
||||
{
|
||||
return ((p[0] & 0xf8) << 8) | ((p[1] & 0xfc) << 3) | (p[2] >> 3);
|
||||
}
|
||||
|
||||
/* with the unused bit set, as all of GdkRGB does */
|
||||
static inline guint16
|
||||
rgb555 (const guchar *p)
|
||||
{
|
||||
return 0x8000 | ((p[0] & 0xf8) << 7) | ((p[1] & 0xf8) << 2) | (p[2] >> 3);
|
||||
}
|
||||
|
||||
static inline guint
|
||||
blend8 (guint a, guint s, guint d)
|
||||
{
|
||||
guint t = a * s + (255 - a) * d + 0x80;
|
||||
|
||||
return (t + (t >> 8)) >> 8;
|
||||
}
|
||||
|
||||
static inline void
|
||||
composite1_x888 (guint32 *pixel, const guchar *s)
|
||||
{
|
||||
guint32 d = *pixel;
|
||||
|
||||
if (s[3] != 0)
|
||||
*pixel = 0xff000000 |
|
||||
(blend8 (s[3], s[0], (d >> 16) & 0xff) << 16) |
|
||||
(blend8 (s[3], s[1], (d >> 8) & 0xff) << 8) |
|
||||
blend8 (s[3], s[2], d & 0xff);
|
||||
}
|
||||
|
||||
static inline void
|
||||
composite1_565 (guint16 *pixel, const guchar *s)
|
||||
{
|
||||
guint d = *pixel, r = d >> 11, g = (d >> 5) & 0x3f, b = d & 0x1f;
|
||||
|
||||
r = blend8 (s[3], s[0], (r << 3) | (r >> 2));
|
||||
g = blend8 (s[3], s[1], (g << 2) | (g >> 4));
|
||||
b = blend8 (s[3], s[2], (b << 3) | (b >> 2));
|
||||
*pixel = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3);
|
||||
}
|
||||
|
||||
static inline void
|
||||
composite1_555 (guint16 *pixel, const guchar *s)
|
||||
{
|
||||
guint d = *pixel, r = (d >> 10) & 0x1f, g = (d >> 5) & 0x1f, b = d & 0x1f;
|
||||
|
||||
r = blend8 (s[3], s[0], (r << 3) | (r >> 2));
|
||||
g = blend8 (s[3], s[1], (g << 3) | (g >> 2));
|
||||
b = blend8 (s[3], s[2], (b << 3) | (b >> 2));
|
||||
*pixel = 0x8000 | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
|
||||
}
|
||||
|
||||
/* 0xff in the first byte of each pixel */
|
||||
static inline vu8
|
||||
fill_x888 (void)
|
||||
{
|
||||
/* -8 shifts by 24 */
|
||||
return (vu8) vec_sl (vec_splat_u32 (-1), vec_splat_u32 (-8));
|
||||
}
|
||||
|
||||
static gint
|
||||
rgb_to_x888 (guint32 *out, const guchar *rgb, gint n)
|
||||
{
|
||||
const vu8 fill = fill_x888 ();
|
||||
const vu8 p0 = VU8 (0, 0, 1, 2, 0, 3, 4, 5, 0, 6, 7, 8, 0, 9, 10, 11);
|
||||
const vu8 p1 = VU8 (0, 12, 13, 14, 0, 15, 16, 17, 0, 18, 19, 20, 0, 21, 22, 23);
|
||||
const vu8 p2 = VU8 (0, 8, 9, 10, 0, 11, 12, 13, 0, 14, 15, 16, 0, 17, 18, 19);
|
||||
const vu8 p3 = VU8 (0, 4, 5, 6, 0, 7, 8, 9, 0, 10, 11, 12, 0, 13, 14, 15);
|
||||
Reader r;
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < n && !aligned (out + i); i++, rgb += 3)
|
||||
out[i] = x888 (rgb);
|
||||
|
||||
if (i + 16 <= n)
|
||||
reader_init (&r, rgb);
|
||||
for (; i + 16 <= n; i += 16)
|
||||
{
|
||||
vu8 a = reader_next (&r), b = reader_next (&r), c = reader_next (&r);
|
||||
|
||||
vec_st (vec_or (vec_perm (a, a, p0), fill), 0, (guchar *) (out + i));
|
||||
vec_st (vec_or (vec_perm (a, b, p1), fill), 16, (guchar *) (out + i));
|
||||
vec_st (vec_or (vec_perm (b, c, p2), fill), 32, (guchar *) (out + i));
|
||||
vec_st (vec_or (vec_perm (c, c, p3), fill), 48, (guchar *) (out + i));
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static gint
|
||||
rgbx_to_x888 (guint32 *out, const guchar *rgbx, gint n)
|
||||
{
|
||||
const vu8 fill = fill_x888 ();
|
||||
const vu8 p = VU8 (0, 0, 1, 2, 0, 4, 5, 6, 0, 8, 9, 10, 0, 12, 13, 14);
|
||||
Reader r;
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < n && !aligned (out + i); i++, rgbx += 4)
|
||||
out[i] = x888 (rgbx);
|
||||
|
||||
if (i + 4 <= n)
|
||||
reader_init (&r, rgbx);
|
||||
for (; i + 4 <= n; i += 4)
|
||||
{
|
||||
vu8 a = reader_next (&r);
|
||||
|
||||
vec_st (vec_or (vec_perm (a, a, p), fill), 0, (guchar *) (out + i));
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/* Bytes of eight RGB pixels as 16-bit lanes, for one channel */
|
||||
static inline vu16
|
||||
channel (vu8 a, vu8 b, vu8 p)
|
||||
{
|
||||
return vec_and ((vu16) vec_perm (a, b, p), vec_splats ((unsigned short) 0xff));
|
||||
}
|
||||
|
||||
static inline vu16
|
||||
pack565 (vu16 r, vu16 g, vu16 b)
|
||||
{
|
||||
return vec_or (vec_or (vec_sl (vec_and (r, vec_splats ((unsigned short) 0xf8)), vec_splats ((unsigned short) 8)),
|
||||
vec_sl (vec_and (g, vec_splats ((unsigned short) 0xfc)), vec_splats ((unsigned short) 3))),
|
||||
vec_sr (b, vec_splats ((unsigned short) 3)));
|
||||
}
|
||||
|
||||
static inline vu16
|
||||
pack555 (vu16 r, vu16 g, vu16 b)
|
||||
{
|
||||
return vec_or (vec_or (vec_sl (vec_and (r, vec_splats ((unsigned short) 0xf8)), vec_splats ((unsigned short) 7)),
|
||||
vec_sl (vec_and (g, vec_splats ((unsigned short) 0xf8)), vec_splats ((unsigned short) 2))),
|
||||
vec_or (vec_sr (b, vec_splats ((unsigned short) 3)), vec_splats ((unsigned short) 0x8000)));
|
||||
}
|
||||
|
||||
static inline vu16
|
||||
pack16 (vu16 r, vu16 g, vu16 b, const gint green_bits)
|
||||
{
|
||||
return green_bits == 6 ? pack565 (r, g, b) : pack555 (r, g, b);
|
||||
}
|
||||
|
||||
static inline gint
|
||||
rgb_to_16 (guint16 *out, const guchar *rgb, gint n, const gint green_bits)
|
||||
{
|
||||
/* the channel byte of pixel k in both bytes of lane k */
|
||||
const vu8 r0 = VU8 (0, 0, 3, 3, 6, 6, 9, 9, 12, 12, 15, 15, 18, 18, 21, 21);
|
||||
const vu8 g0 = VU8 (1, 1, 4, 4, 7, 7, 10, 10, 13, 13, 16, 16, 19, 19, 22, 22);
|
||||
const vu8 b0 = VU8 (2, 2, 5, 5, 8, 8, 11, 11, 14, 14, 17, 17, 20, 20, 23, 23);
|
||||
const vu8 r1 = VU8 (8, 8, 11, 11, 14, 14, 17, 17, 20, 20, 23, 23, 26, 26, 29, 29);
|
||||
const vu8 g1 = VU8 (9, 9, 12, 12, 15, 15, 18, 18, 21, 21, 24, 24, 27, 27, 30, 30);
|
||||
const vu8 b1 = VU8 (10, 10, 13, 13, 16, 16, 19, 19, 22, 22, 25, 25, 28, 28, 31, 31);
|
||||
Reader r;
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < n && !aligned (out + i); i++, rgb += 3)
|
||||
out[i] = green_bits == 6 ? rgb565 (rgb) : rgb555 (rgb);
|
||||
|
||||
if (i + 16 <= n)
|
||||
reader_init (&r, rgb);
|
||||
for (; i + 16 <= n; i += 16)
|
||||
{
|
||||
vu8 a = reader_next (&r), b = reader_next (&r), c = reader_next (&r);
|
||||
|
||||
vec_st (pack16 (channel (a, b, r0), channel (a, b, g0), channel (a, b, b0), green_bits), 0, out + i);
|
||||
vec_st (pack16 (channel (b, c, r1), channel (b, c, g1), channel (b, c, b1), green_bits), 0, out + i + 8);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static gint
|
||||
rgb_to_565 (guint16 *out, const guchar *rgb, gint n)
|
||||
{
|
||||
return rgb_to_16 (out, rgb, n, 6);
|
||||
}
|
||||
|
||||
static gint
|
||||
rgb_to_555 (guint16 *out, const guchar *rgb, gint n)
|
||||
{
|
||||
return rgb_to_16 (out, rgb, n, 5);
|
||||
}
|
||||
|
||||
/* (a * s + (255 - a) * d) / 255, rounded, in 16-bit lanes */
|
||||
static inline vu16
|
||||
blend (vu16 t)
|
||||
{
|
||||
t = vec_add (t, vec_splats ((unsigned short) 0x80));
|
||||
|
||||
return vec_sr (vec_add (t, vec_sr (t, vec_splats ((unsigned short) 8))),
|
||||
vec_splats ((unsigned short) 8));
|
||||
}
|
||||
|
||||
static gint
|
||||
composite_x888 (guint32 *pixels, const guchar *rgba, gint n)
|
||||
{
|
||||
const vu8 fill = fill_x888 ();
|
||||
const vu8 argb = VU8 (3, 0, 1, 2, 7, 4, 5, 6, 11, 8, 9, 10, 15, 12, 13, 14);
|
||||
const vu8 alpha = VU8 (3, 3, 3, 3, 7, 7, 7, 7, 11, 11, 11, 11, 15, 15, 15, 15);
|
||||
const vu8 merge = VU8 (1, 17, 3, 19, 5, 21, 7, 23, 9, 25, 11, 27, 13, 29, 15, 31);
|
||||
Reader r;
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < n && !aligned (pixels + i); i++, rgba += 4)
|
||||
composite1_x888 (pixels + i, rgba);
|
||||
|
||||
if (i + 4 <= n)
|
||||
reader_init (&r, rgba);
|
||||
for (; i + 4 <= n; i += 4)
|
||||
{
|
||||
vu8 s = reader_next (&r);
|
||||
vu8 d = vec_ld (0, (guchar *) (pixels + i));
|
||||
vu8 a = vec_perm (s, s, alpha);
|
||||
vu8 inv = vec_nor (a, a);
|
||||
vu16 even, odd;
|
||||
vu8 v;
|
||||
|
||||
s = vec_perm (s, s, argb);
|
||||
even = blend (vec_add (vec_mule (s, a), vec_mule (d, inv)));
|
||||
odd = blend (vec_add (vec_mulo (s, a), vec_mulo (d, inv)));
|
||||
v = vec_or (vec_perm ((vu8) even, (vu8) odd, merge), fill);
|
||||
|
||||
/* fully transparent pixels stay as they are */
|
||||
vec_st (vec_sel (v, d, vec_cmpeq (a, vec_splat_u8 (0))), 0, (guchar *) (pixels + i));
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static inline gint
|
||||
composite_16 (guint16 *pixels, const guchar *rgba, gint n, const gint green_bits)
|
||||
{
|
||||
const vu8 pr = VU8 (0, 0, 4, 4, 8, 8, 12, 12, 16, 16, 20, 20, 24, 24, 28, 28);
|
||||
const vu8 pg = VU8 (1, 1, 5, 5, 9, 9, 13, 13, 17, 17, 21, 21, 25, 25, 29, 29);
|
||||
const vu8 pb = VU8 (2, 2, 6, 6, 10, 10, 14, 14, 18, 18, 22, 22, 26, 26, 30, 30);
|
||||
const vu8 pa = VU8 (3, 3, 7, 7, 11, 11, 15, 15, 19, 19, 23, 23, 27, 27, 31, 31);
|
||||
const vu16 c255 = vec_splats ((unsigned short) 255);
|
||||
Reader r;
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < n && !aligned (pixels + i); i++, rgba += 4)
|
||||
if (rgba[3] != 0)
|
||||
{
|
||||
if (green_bits == 6)
|
||||
composite1_565 (pixels + i, rgba);
|
||||
else
|
||||
composite1_555 (pixels + i, rgba);
|
||||
}
|
||||
|
||||
if (i + 8 <= n)
|
||||
reader_init (&r, rgba);
|
||||
for (; i + 8 <= n; i += 8)
|
||||
{
|
||||
vu8 s0 = reader_next (&r), s1 = reader_next (&r);
|
||||
vu16 d = vec_ld (0, pixels + i);
|
||||
vu16 a = channel (s0, s1, pa), inv = vec_sub (c255, a);
|
||||
vu16 dr = vec_and (vec_sr (d, vec_splats ((unsigned short) (5 + green_bits))), vec_splats ((unsigned short) 0x1f));
|
||||
vu16 dg = vec_and (vec_sr (d, vec_splats ((unsigned short) 5)), vec_splats ((unsigned short) ((1 << green_bits) - 1)));
|
||||
vu16 db = vec_and (d, vec_splats ((unsigned short) 0x1f));
|
||||
vu16 v;
|
||||
|
||||
/* the bits of the pixel repeated up to 8 */
|
||||
dr = vec_or (vec_sl (dr, vec_splats ((unsigned short) 3)), vec_sr (dr, vec_splats ((unsigned short) 2)));
|
||||
if (green_bits == 6)
|
||||
dg = vec_or (vec_sl (dg, vec_splats ((unsigned short) 2)), vec_sr (dg, vec_splats ((unsigned short) 4)));
|
||||
else
|
||||
dg = vec_or (vec_sl (dg, vec_splats ((unsigned short) 3)), vec_sr (dg, vec_splats ((unsigned short) 2)));
|
||||
db = vec_or (vec_sl (db, vec_splats ((unsigned short) 3)), vec_sr (db, vec_splats ((unsigned short) 2)));
|
||||
|
||||
v = pack16 (blend (vec_mladd (channel (s0, s1, pr), a, vec_mladd (dr, inv, vec_splats ((unsigned short) 0)))),
|
||||
blend (vec_mladd (channel (s0, s1, pg), a, vec_mladd (dg, inv, vec_splats ((unsigned short) 0)))),
|
||||
blend (vec_mladd (channel (s0, s1, pb), a, vec_mladd (db, inv, vec_splats ((unsigned short) 0)))),
|
||||
green_bits);
|
||||
|
||||
/* where nothing is drawn the unused bit of 555 stays as it was */
|
||||
if (green_bits == 5)
|
||||
v = vec_sel (v, d, vec_cmpeq (a, vec_splats ((unsigned short) 0)));
|
||||
vec_st (v, 0, pixels + i);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static gint
|
||||
rgba_to_argb (guint32 *out, const guchar *rgba, gint n)
|
||||
{
|
||||
const vu8 argb = VU8 (3, 0, 1, 2, 7, 4, 5, 6, 11, 8, 9, 10, 15, 12, 13, 14);
|
||||
/* a for R, G and B; 255 for the alpha, which a * 255 / 255 keeps */
|
||||
const vu8 factors = VU8 (16, 3, 3, 3, 16, 7, 7, 7, 16, 11, 11, 11, 16, 15, 15, 15);
|
||||
const vu8 merge = VU8 (1, 17, 3, 19, 5, 21, 7, 23, 9, 25, 11, 27, 13, 29, 15, 31);
|
||||
const vu8 ones = vec_splat_u8 (-1);
|
||||
Reader r;
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < n && !aligned (out + i); i++, rgba += 4)
|
||||
{
|
||||
guint a = rgba[3];
|
||||
|
||||
out[i] = (a << 24) | (blend8 (a, rgba[0], 0) << 16) |
|
||||
(blend8 (a, rgba[1], 0) << 8) | blend8 (a, rgba[2], 0);
|
||||
}
|
||||
|
||||
if (i + 4 <= n)
|
||||
reader_init (&r, rgba);
|
||||
for (; i + 4 <= n; i += 4)
|
||||
{
|
||||
vu8 s = reader_next (&r);
|
||||
vu8 m = vec_perm (s, ones, factors);
|
||||
|
||||
s = vec_perm (s, s, argb);
|
||||
vec_st (vec_perm ((vu8) blend (vec_mule (s, m)), (vu8) blend (vec_mulo (s, m)), merge),
|
||||
0, (guchar *) (out + i));
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static gint
|
||||
composite_565 (guint16 *pixels, const guchar *rgba, gint n)
|
||||
{
|
||||
return composite_16 (pixels, rgba, n, 6);
|
||||
}
|
||||
|
||||
static gint
|
||||
composite_555 (guint16 *pixels, const guchar *rgba, gint n)
|
||||
{
|
||||
return composite_16 (pixels, rgba, n, 5);
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_rgb_simd_init_altivec (GdkRgbSimd *simd)
|
||||
{
|
||||
simd->name = "altivec";
|
||||
simd->rgb_to_x888 = rgb_to_x888;
|
||||
simd->rgbx_to_x888 = rgbx_to_x888;
|
||||
simd->rgb_to_565 = rgb_to_565;
|
||||
simd->rgb_to_555 = rgb_to_555;
|
||||
simd->composite_x888 = composite_x888;
|
||||
simd->composite_565 = composite_565;
|
||||
simd->composite_555 = composite_555;
|
||||
simd->rgba_to_argb = rgba_to_argb;
|
||||
}
|
||||
|
||||
#endif
|
||||
311
gdk/gdkrgb-armv6.c
Normal file
311
gdk/gdkrgb-armv6.c
Normal file
|
|
@ -0,0 +1,311 @@
|
|||
/* GDK - The GIMP Drawing Kit
|
||||
* GdkRGB loops for the media instructions of ARMv6 (the ARM11 of the
|
||||
* Raspberry Pi 1 and Zero), which has no NEON: two channels of a pixel
|
||||
* 16 bits apart in one register, multiplied at once, with UXTB16 and
|
||||
* UXTAB16 taking bytes apart and adding them in both halves; REV puts
|
||||
* the bytes of a pixel in the other order. A pixel goes in and out as
|
||||
* one word, not byte by byte.
|
||||
*
|
||||
* GDK_RGB_ARMV6_C builds the same loops with C for the instructions,
|
||||
* to check them on other machines.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkrgbsimd.h"
|
||||
|
||||
/* ARMv6 or later in ARM or Thumb-2 code, little endian */
|
||||
#if defined(__arm__) && !defined(__ARMEB__) && \
|
||||
(!defined(__thumb__) || defined(__thumb2__)) && \
|
||||
(defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || \
|
||||
defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) || \
|
||||
(defined(__ARM_ARCH) && __ARM_ARCH >= 6))
|
||||
#define ARMV6_ASM 1
|
||||
#endif
|
||||
|
||||
#if defined(ARMV6_ASM) || defined(GDK_RGB_ARMV6_C)
|
||||
|
||||
#ifdef ARMV6_ASM
|
||||
|
||||
/* bytes 0 and 2 in the two halves */
|
||||
static inline guint32
|
||||
uxtb16 (guint32 x)
|
||||
{
|
||||
guint32 r;
|
||||
__asm__ ("uxtb16 %0, %1" : "=r" (r) : "r" (x));
|
||||
return r;
|
||||
}
|
||||
|
||||
/* bytes 1 and 3 */
|
||||
static inline guint32
|
||||
uxtb16_ror8 (guint32 x)
|
||||
{
|
||||
guint32 r;
|
||||
__asm__ ("uxtb16 %0, %1, ror #8" : "=r" (r) : "r" (x));
|
||||
return r;
|
||||
}
|
||||
|
||||
/* @acc plus bytes 1 and 3 of @x, in each half */
|
||||
static inline guint32
|
||||
uxtab16_ror8 (guint32 acc, guint32 x)
|
||||
{
|
||||
guint32 r;
|
||||
__asm__ ("uxtab16 %0, %1, %2, ror #8" : "=r" (r) : "r" (acc), "r" (x));
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline guint32
|
||||
rev (guint32 x)
|
||||
{
|
||||
guint32 r;
|
||||
__asm__ ("rev %0, %1" : "=r" (r) : "r" (x));
|
||||
return r;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static inline guint32 uxtb16 (guint32 x) { return x & 0x00ff00ff; }
|
||||
static inline guint32 uxtb16_ror8 (guint32 x) { return (x >> 8 | x << 24) & 0x00ff00ff; }
|
||||
static inline guint32
|
||||
uxtab16_ror8 (guint32 acc, guint32 x)
|
||||
{
|
||||
guint32 b = uxtb16_ror8 (x);
|
||||
|
||||
return ((acc + b) & 0xffff) | ((acc & 0xffff0000) + (b & 0xffff0000));
|
||||
}
|
||||
static inline guint32
|
||||
rev (guint32 x)
|
||||
{
|
||||
return x >> 24 | (x >> 8 & 0xff00) | (x << 8 & 0xff0000) | x << 24;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* A word of pixels, at an address of a whole word: rows of pixbufs
|
||||
* start there, and the loops take words from the start. Rows that do
|
||||
* not are left to the C code, as ARMv6 compilers read words byte by
|
||||
* byte where they are not sure. */
|
||||
typedef guint32 __attribute__ ((may_alias)) word;
|
||||
|
||||
#define ALIGNED(p) (((gsize) (p) & 3) == 0)
|
||||
|
||||
static inline guint32
|
||||
load32 (const guchar *p)
|
||||
{
|
||||
return *(const word *) p;
|
||||
}
|
||||
|
||||
/* t / 255 rounded, in both halves, for t = c * a + 0x80 (no carries
|
||||
* between the halves: t stays below 65536) */
|
||||
static inline guint32
|
||||
div255 (guint32 t)
|
||||
{
|
||||
return uxtb16_ror8 (uxtab16_ror8 (t, t));
|
||||
}
|
||||
|
||||
/* Of each three RGB pixels: R G B R | G B R G | B R G B in three words */
|
||||
|
||||
static gint
|
||||
rgb_to_x888 (guint32 *out, const guchar *rgb, gint n)
|
||||
{
|
||||
gint i;
|
||||
|
||||
if (!ALIGNED (rgb))
|
||||
return 0;
|
||||
|
||||
for (i = 0; i + 4 <= n; i += 4, rgb += 12)
|
||||
{
|
||||
guint32 w0 = load32 (rgb), w1 = load32 (rgb + 4), w2 = load32 (rgb + 8);
|
||||
|
||||
/* B G R x, reversed and moved down, is R << 16 | G << 8 | B */
|
||||
out[i] = (rev (w0) >> 8) | 0xff000000;
|
||||
out[i + 1] = (rev ((w0 >> 24) | (w1 << 8)) >> 8) | 0xff000000;
|
||||
out[i + 2] = (rev ((w1 >> 16) | (w2 << 16)) >> 8) | 0xff000000;
|
||||
out[i + 3] = (rev (w2) & 0xffffff) | 0xff000000;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/* Lanes R | G << 8 | B << 16 to 565 or 555 */
|
||||
static inline guint32
|
||||
rgb16_of (guint32 v, const gint green_bits)
|
||||
{
|
||||
if (green_bits == 6)
|
||||
return ((v & 0xf8) << 8) | ((v >> 5) & 0x7e0) | ((v >> 19) & 0x1f);
|
||||
else
|
||||
return ((v & 0xf8) << 7) | ((v >> 6) & 0x3e0) | ((v >> 19) & 0x1f) | 0x8000;
|
||||
}
|
||||
|
||||
static inline gint
|
||||
rgb_to_16 (guint16 *out, const guchar *rgb, gint n, const gint green_bits)
|
||||
{
|
||||
guint32 *out32 = (guint32 *) out;
|
||||
gint i;
|
||||
|
||||
/* two pixels to a word of the output; the words of both at their
|
||||
* places, or the C code does the row */
|
||||
if (!ALIGNED (rgb) || !ALIGNED (out))
|
||||
return 0;
|
||||
|
||||
for (i = 0; i + 4 <= n; i += 4, rgb += 12, out32 += 2)
|
||||
{
|
||||
guint32 w0 = load32 (rgb), w1 = load32 (rgb + 4), w2 = load32 (rgb + 8);
|
||||
|
||||
out32[0] = rgb16_of (w0, green_bits) |
|
||||
(rgb16_of ((w0 >> 24) | (w1 << 8), green_bits) << 16);
|
||||
out32[1] = rgb16_of ((w1 >> 16) | (w2 << 16), green_bits) |
|
||||
(rgb16_of (w2 >> 8, green_bits) << 16);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static gint
|
||||
rgb_to_565 (guint16 *out, const guchar *rgb, gint n)
|
||||
{
|
||||
return rgb_to_16 (out, rgb, n, 6);
|
||||
}
|
||||
|
||||
static gint
|
||||
rgb_to_555 (guint16 *out, const guchar *rgb, gint n)
|
||||
{
|
||||
return rgb_to_16 (out, rgb, n, 5);
|
||||
}
|
||||
|
||||
/* c * a / 255 to the nearest for the channels of the RGBA word @w:
|
||||
* red and blue together, green and alpha together */
|
||||
static gint
|
||||
rgba_to_argb (guint32 *out, const guchar *rgba, gint n)
|
||||
{
|
||||
gint i;
|
||||
|
||||
if (!ALIGNED (rgba))
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < n; i++, rgba += 4)
|
||||
{
|
||||
guint32 w = load32 (rgba);
|
||||
guint32 a = w >> 24;
|
||||
guint32 rb = div255 (uxtb16 (w) * a + 0x00800080); /* R | B << 16 */
|
||||
guint32 g = div255 (uxtb16_ror8 (w) * a + 0x80) & 0xff;
|
||||
|
||||
/* B | R << 16, which a rotation is */
|
||||
out[i] = (a << 24) | (g << 8) | (rb >> 16) | (rb << 16);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/* a * s + (255 - a) * d, rounded, for two channels at once */
|
||||
static inline guint32
|
||||
blend2 (guint32 s, guint32 d, guint32 a)
|
||||
{
|
||||
return div255 (s * a + d * (255 - a) + 0x00800080);
|
||||
}
|
||||
|
||||
static gint
|
||||
composite_x888 (guint32 *pixels, const guchar *rgba, gint n)
|
||||
{
|
||||
gint i;
|
||||
|
||||
if (!ALIGNED (rgba))
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < n; i++, rgba += 4)
|
||||
{
|
||||
guint32 w = load32 (rgba);
|
||||
guint32 a = w >> 24;
|
||||
guint32 d, rb, g;
|
||||
|
||||
if (a == 0)
|
||||
continue;
|
||||
if (a == 255)
|
||||
{
|
||||
pixels[i] = (rev (w) >> 8) | 0xff000000;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* the pixel is B | G << 8 | R << 16: blue and red as in @w swapped */
|
||||
d = pixels[i];
|
||||
rb = blend2 (uxtb16 (w), ((d >> 16) & 0xff) | ((d & 0xff) << 16), a);
|
||||
g = blend2 ((w >> 8) & 0xff, (d >> 8) & 0xff, a) & 0xff;
|
||||
pixels[i] = 0xff000000 | ((rb & 0xff) << 16) | (g << 8) | (rb >> 16);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/* The bits of a channel repeated up to 8, as GdkRGB unpacks them */
|
||||
#define WIDEN5(c) (((c) << 3) | ((c) >> 2))
|
||||
#define WIDEN6(c) (((c) << 2) | ((c) >> 4))
|
||||
|
||||
static inline gint
|
||||
composite_16 (guint16 *pixels, const guchar *rgba, gint n, const gint green_bits)
|
||||
{
|
||||
const gint red_shift = 5 + green_bits;
|
||||
gint i;
|
||||
|
||||
if (!ALIGNED (rgba))
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < n; i++, rgba += 4)
|
||||
{
|
||||
guint32 w = load32 (rgba);
|
||||
guint32 a = w >> 24;
|
||||
guint32 d, dr, dg, db, rb, g, v;
|
||||
|
||||
if (a == 0)
|
||||
continue;
|
||||
|
||||
d = pixels[i];
|
||||
dr = (d >> red_shift) & 0x1f;
|
||||
dg = (d >> 5) & ((1 << green_bits) - 1);
|
||||
db = d & 0x1f;
|
||||
dr = WIDEN5 (dr);
|
||||
dg = green_bits == 6 ? WIDEN6 (dg) : WIDEN5 (dg);
|
||||
db = WIDEN5 (db);
|
||||
|
||||
rb = blend2 (uxtb16 (w), dr | (db << 16), a); /* R | B << 16 */
|
||||
g = blend2 ((w >> 8) & 0xff, dg, a) & 0xff;
|
||||
|
||||
v = (((rb & 0xff) >> 3) << red_shift) | ((g >> (8 - green_bits)) << 5) | (rb >> 19);
|
||||
if (green_bits == 5)
|
||||
v |= 0x8000;
|
||||
pixels[i] = v;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static gint
|
||||
composite_565 (guint16 *pixels, const guchar *rgba, gint n)
|
||||
{
|
||||
return composite_16 (pixels, rgba, n, 6);
|
||||
}
|
||||
|
||||
static gint
|
||||
composite_555 (guint16 *pixels, const guchar *rgba, gint n)
|
||||
{
|
||||
return composite_16 (pixels, rgba, n, 5);
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_rgb_simd_init_armv6 (GdkRgbSimd *simd)
|
||||
{
|
||||
simd->name = "armv6";
|
||||
simd->rgb_to_x888 = rgb_to_x888;
|
||||
simd->rgb_to_565 = rgb_to_565;
|
||||
simd->rgb_to_555 = rgb_to_555;
|
||||
simd->composite_x888 = composite_x888;
|
||||
simd->composite_565 = composite_565;
|
||||
simd->composite_555 = composite_555;
|
||||
simd->rgba_to_argb = rgba_to_argb;
|
||||
}
|
||||
|
||||
#endif
|
||||
129
gdk/gdkrgb-avx2.c
Normal file
129
gdk/gdkrgb-avx2.c
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
/* GDK - The GIMP Drawing Kit
|
||||
* GdkRGB loops for AVX2 (Haswell, Zen and later): the SSSE3 loops eight
|
||||
* pixels at a time, for the pixels of four bytes, where the lanes of 128
|
||||
* bits do not mix. Pixels of three bytes would cross the two halves of
|
||||
* a register and need permutes; those stay with SSSE3.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkrgbsimd.h"
|
||||
|
||||
#if defined(__AVX2__)
|
||||
|
||||
#include <immintrin.h>
|
||||
|
||||
/* x86 is little endian: an x888 pixel is the bytes B, G, R, 0xff */
|
||||
|
||||
#define SPLAT(v) _mm256_set1_epi32 ((gint) (v))
|
||||
|
||||
/* the same order of bytes in both halves */
|
||||
#define BYTES(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \
|
||||
_mm256_setr_epi8 (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, \
|
||||
a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)
|
||||
|
||||
static gint
|
||||
rgbx_to_x888 (guint32 *out, const guchar *rgbx, gint n)
|
||||
{
|
||||
const __m256i order = BYTES (2, 1, 0, -1, 6, 5, 4, -1, 10, 9, 8, -1, 14, 13, 12, -1);
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 8 <= n; i += 8, rgbx += 32)
|
||||
_mm256_storeu_si256 ((__m256i *) (out + i),
|
||||
_mm256_or_si256 (_mm256_shuffle_epi8 (_mm256_loadu_si256 ((const __m256i *) rgbx), order),
|
||||
SPLAT (0xff000000)));
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/* The alpha of each pixel in its four 16-bit lanes */
|
||||
static inline __m256i
|
||||
alpha_of (__m256i v)
|
||||
{
|
||||
return _mm256_shuffle_epi8 (v, BYTES (6, 7, 6, 7, 6, 7, 6, 7, 14, 15, 14, 15, 14, 15, 14, 15));
|
||||
}
|
||||
|
||||
/* (a * s + (255 - a) * d) / 255, rounded as GdkRGB's C code does */
|
||||
static inline __m256i
|
||||
blend (__m256i s, __m256i d, __m256i a)
|
||||
{
|
||||
__m256i t = _mm256_add_epi16 (_mm256_add_epi16 (_mm256_mullo_epi16 (s, a),
|
||||
_mm256_mullo_epi16 (d, _mm256_sub_epi16 (_mm256_set1_epi16 (255), a))),
|
||||
_mm256_set1_epi16 (0x80));
|
||||
|
||||
return _mm256_mulhi_epu16 (t, _mm256_set1_epi16 (257));
|
||||
}
|
||||
|
||||
static gint
|
||||
composite_x888 (guint32 *pixels, const guchar *rgba, gint n)
|
||||
{
|
||||
const __m256i zero = _mm256_setzero_si256 ();
|
||||
const __m256i order = BYTES (2, 1, 0, 3, 6, 5, 4, 7, 10, 9, 8, 11, 14, 13, 12, 15);
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 8 <= n; i += 8, rgba += 32)
|
||||
{
|
||||
__m256i s = _mm256_loadu_si256 ((const __m256i *) rgba);
|
||||
__m256i d = _mm256_loadu_si256 ((const __m256i *) (pixels + i));
|
||||
__m256i transparent = _mm256_cmpeq_epi32 (_mm256_srli_epi32 (s, 24), zero);
|
||||
__m256i lo, hi, v;
|
||||
|
||||
/* RGBA to BGRA, the order of the pixels */
|
||||
s = _mm256_shuffle_epi8 (s, order);
|
||||
lo = _mm256_unpacklo_epi8 (s, zero);
|
||||
hi = _mm256_unpackhi_epi8 (s, zero);
|
||||
lo = blend (lo, _mm256_unpacklo_epi8 (d, zero), alpha_of (lo));
|
||||
hi = blend (hi, _mm256_unpackhi_epi8 (d, zero), alpha_of (hi));
|
||||
v = _mm256_or_si256 (_mm256_packus_epi16 (lo, hi), SPLAT (0xff000000));
|
||||
|
||||
/* fully transparent pixels stay as they are */
|
||||
v = _mm256_blendv_epi8 (v, d, transparent);
|
||||
_mm256_storeu_si256 ((__m256i *) (pixels + i), v);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/* c * a / 255 to the nearest, which (c * a + 0x80) * 257 >> 16 is */
|
||||
static gint
|
||||
rgba_to_argb (guint32 *out, const guchar *rgba, gint n)
|
||||
{
|
||||
const __m256i zero = _mm256_setzero_si256 ();
|
||||
const __m256i order = BYTES (2, 1, 0, -1, 6, 5, 4, -1, 10, 9, 8, -1, 14, 13, 12, -1);
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 8 <= n; i += 8, rgba += 32)
|
||||
{
|
||||
__m256i s = _mm256_loadu_si256 ((const __m256i *) rgba);
|
||||
__m256i lo = _mm256_unpacklo_epi8 (s, zero);
|
||||
__m256i hi = _mm256_unpackhi_epi8 (s, zero);
|
||||
|
||||
lo = _mm256_mulhi_epu16 (_mm256_add_epi16 (_mm256_mullo_epi16 (lo, alpha_of (lo)), _mm256_set1_epi16 (0x80)),
|
||||
_mm256_set1_epi16 (257));
|
||||
hi = _mm256_mulhi_epu16 (_mm256_add_epi16 (_mm256_mullo_epi16 (hi, alpha_of (hi)), _mm256_set1_epi16 (0x80)),
|
||||
_mm256_set1_epi16 (257));
|
||||
|
||||
/* R, G, B to B, G, R, and the alpha byte as it was */
|
||||
_mm256_storeu_si256 ((__m256i *) (out + i),
|
||||
_mm256_or_si256 (_mm256_shuffle_epi8 (_mm256_packus_epi16 (lo, hi), order),
|
||||
_mm256_and_si256 (s, SPLAT (0xff000000))));
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_rgb_simd_init_avx2 (GdkRgbSimd *simd)
|
||||
{
|
||||
simd->name = "avx2";
|
||||
simd->rgbx_to_x888 = rgbx_to_x888;
|
||||
simd->composite_x888 = composite_x888;
|
||||
simd->rgba_to_argb = rgba_to_argb;
|
||||
}
|
||||
|
||||
#endif
|
||||
473
gdk/gdkrgb-mmx.c
Normal file
473
gdk/gdkrgb-mmx.c
Normal file
|
|
@ -0,0 +1,473 @@
|
|||
/* GDK - The GIMP Drawing Kit
|
||||
* GdkRGB loops for MMX, and for what came later on the same registers:
|
||||
* the integer SSE instructions of the Pentium III and Athlon (pshufw,
|
||||
* pmulhuw), and 3DNow! of the K6-2, Athlon and Geode LX (pmulhrw)
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "gdkrgbsimd.h"
|
||||
|
||||
/* x86-64 always has SSE2, which does all of this better */
|
||||
#if defined(__MMX__) && !defined(__x86_64__)
|
||||
|
||||
#include <mmintrin.h>
|
||||
|
||||
/* The file is compiled for plain MMX. The later instructions are
|
||||
* written as assembler, so the compiler uses them nowhere else, and
|
||||
* the kernels with them are only called on CPUs that have them. */
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define KERNEL static inline __attribute__ ((always_inline))
|
||||
#else
|
||||
#define KERNEL static inline
|
||||
#endif
|
||||
|
||||
/* How a kernel does what MMX has no instruction for */
|
||||
enum
|
||||
{
|
||||
PLAIN, /* MMX only */
|
||||
EXT, /* pshufw and pmulhuw */
|
||||
AMD3D, /* pmulhrw */
|
||||
AMD3D_EXT /* all three */
|
||||
};
|
||||
|
||||
#define SPLAT(v) _mm_set1_pi32 ((gint) (v))
|
||||
|
||||
static inline __m64
|
||||
load8 (const void *p)
|
||||
{
|
||||
__m64 v;
|
||||
|
||||
memcpy (&v, p, 8);
|
||||
return v;
|
||||
}
|
||||
|
||||
static inline void
|
||||
store8 (void *p, __m64 v)
|
||||
{
|
||||
memcpy (p, &v, 8);
|
||||
}
|
||||
|
||||
static inline __m64
|
||||
load4 (const void *p)
|
||||
{
|
||||
gint32 v;
|
||||
|
||||
memcpy (&v, p, 4);
|
||||
return _mm_cvtsi32_si64 (v);
|
||||
}
|
||||
|
||||
#if defined(__i386__) && defined(__GNUC__)
|
||||
|
||||
#define HAVE_LATER_MMX 1
|
||||
|
||||
#define PSHUFW(v, imm) G_STMT_START { \
|
||||
__asm__ ("pshufw $" #imm ", %0, %0" : "+y" (v)); \
|
||||
} G_STMT_END
|
||||
|
||||
static inline __m64
|
||||
pmulhuw (__m64 a, __m64 b)
|
||||
{
|
||||
__asm__ ("pmulhuw %1, %0" : "+y" (a) : "y" (b));
|
||||
return a;
|
||||
}
|
||||
|
||||
static inline __m64
|
||||
pmulhrw (__m64 a, __m64 b)
|
||||
{
|
||||
__asm__ ("pmulhrw %1, %0" : "+y" (a) : "y" (b));
|
||||
return a;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* never used: only plain kernels are made here */
|
||||
#define PSHUFW(v, imm) G_STMT_START { } G_STMT_END
|
||||
#define pmulhuw(a, b) ((void) (b), (a))
|
||||
#define pmulhrw(a, b) ((void) (b), (a))
|
||||
|
||||
#endif
|
||||
|
||||
/* The 6 bytes of two RGB pixels as lanes R | G << 8 | B << 16 */
|
||||
static inline __m64
|
||||
rgb_lanes (__m64 v)
|
||||
{
|
||||
return _mm_unpacklo_pi32 (v, _mm_srli_si64 (v, 24));
|
||||
}
|
||||
|
||||
static inline __m64
|
||||
x888_of (__m64 v)
|
||||
{
|
||||
return _mm_or_si64 (_mm_or_si64 (_mm_slli_pi32 (_mm_and_si64 (v, SPLAT (0xff)), 16),
|
||||
_mm_and_si64 (v, SPLAT (0xff00))),
|
||||
_mm_or_si64 (_mm_and_si64 (_mm_srli_pi32 (v, 16), SPLAT (0xff)),
|
||||
SPLAT (0xff000000)));
|
||||
}
|
||||
|
||||
/* Lanes R | G << 8 | B << 16 to 565 or 555, sign extended for packing.
|
||||
* The bit 555 has no use for is set, as in all of GdkRGB's pixels. */
|
||||
static inline __m64
|
||||
rgb565_of (__m64 v)
|
||||
{
|
||||
v = _mm_or_si64 (_mm_or_si64 (_mm_slli_pi32 (_mm_and_si64 (v, SPLAT (0xf8)), 8),
|
||||
_mm_srli_pi32 (_mm_and_si64 (v, SPLAT (0xfc00)), 5)),
|
||||
_mm_and_si64 (_mm_srli_pi32 (v, 19), SPLAT (0x1f)));
|
||||
|
||||
return _mm_srai_pi32 (_mm_slli_pi32 (v, 16), 16);
|
||||
}
|
||||
|
||||
static inline __m64
|
||||
rgb555_of (__m64 v)
|
||||
{
|
||||
v = _mm_or_si64 (_mm_or_si64 (_mm_slli_pi32 (_mm_and_si64 (v, SPLAT (0xf8)), 7),
|
||||
_mm_srli_pi32 (_mm_and_si64 (v, SPLAT (0xf800)), 6)),
|
||||
_mm_or_si64 (_mm_and_si64 (_mm_srli_pi32 (v, 19), SPLAT (0x1f)),
|
||||
SPLAT (0x8000)));
|
||||
|
||||
return _mm_srai_pi32 (_mm_slli_pi32 (v, 16), 16);
|
||||
}
|
||||
|
||||
static gint
|
||||
rgb_to_x888 (guint32 *out, const guchar *rgb, gint n)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 4 <= n; i += 4, rgb += 12)
|
||||
{
|
||||
__m64 a = load8 (rgb);
|
||||
__m64 b = _mm_or_si64 (_mm_srli_si64 (a, 48), _mm_slli_si64 (load4 (rgb + 8), 16));
|
||||
|
||||
store8 (out + i, x888_of (rgb_lanes (a)));
|
||||
store8 (out + i + 2, x888_of (rgb_lanes (b)));
|
||||
}
|
||||
_mm_empty ();
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static gint
|
||||
rgbx_to_x888 (guint32 *out, const guchar *rgbx, gint n)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 2 <= n; i += 2, rgbx += 8)
|
||||
store8 (out + i, x888_of (load8 (rgbx)));
|
||||
_mm_empty ();
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static gint
|
||||
rgb_to_565 (guint16 *out, const guchar *rgb, gint n)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 4 <= n; i += 4, rgb += 12)
|
||||
{
|
||||
__m64 a = load8 (rgb);
|
||||
__m64 b = _mm_or_si64 (_mm_srli_si64 (a, 48), _mm_slli_si64 (load4 (rgb + 8), 16));
|
||||
|
||||
store8 (out + i, _mm_packs_pi32 (rgb565_of (rgb_lanes (a)), rgb565_of (rgb_lanes (b))));
|
||||
}
|
||||
_mm_empty ();
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static gint
|
||||
rgb_to_555 (guint16 *out, const guchar *rgb, gint n)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 4 <= n; i += 4, rgb += 12)
|
||||
{
|
||||
__m64 a = load8 (rgb);
|
||||
__m64 b = _mm_or_si64 (_mm_srli_si64 (a, 48), _mm_slli_si64 (load4 (rgb + 8), 16));
|
||||
|
||||
store8 (out + i, _mm_packs_pi32 (rgb555_of (rgb_lanes (a)), rgb555_of (rgb_lanes (b))));
|
||||
}
|
||||
_mm_empty ();
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/* (a * s + (255 - a) * d) / 255, rounded as GdkRGB's C code does, in
|
||||
* 16-bit lanes. 3DNow! does it as d + (s - d) * a / 255: pmulhrw
|
||||
* rounds the signed difference times a * 257, a correction makes up
|
||||
* for a * 257 not fitting a signed lane from a = 128 on. That is the
|
||||
* same in all 16777216 cases. */
|
||||
KERNEL __m64
|
||||
blend (__m64 s, __m64 d, __m64 a, const gint how)
|
||||
{
|
||||
if (how == AMD3D || how == AMD3D_EXT)
|
||||
{
|
||||
__m64 scaled = _mm_slli_pi16 (a, 8);
|
||||
__m64 mask = _mm_srai_pi16 (scaled, 15);
|
||||
__m64 coeff = _mm_sub_pi16 (_mm_add_pi16 (a, scaled), mask);
|
||||
__m64 delta = _mm_sub_pi16 (s, d);
|
||||
|
||||
return _mm_add_pi16 (_mm_add_pi16 (pmulhrw (delta, coeff), _mm_and_si64 (delta, mask)), d);
|
||||
}
|
||||
else
|
||||
{
|
||||
__m64 t = _mm_add_pi16 (_mm_add_pi16 (_mm_mullo_pi16 (s, a),
|
||||
_mm_mullo_pi16 (d, _mm_sub_pi16 (_mm_set1_pi16 (255), a))),
|
||||
_mm_set1_pi16 (0x80));
|
||||
|
||||
/* t * 257 >> 16 is (t + (t >> 8)) >> 8 */
|
||||
if (how == EXT)
|
||||
return pmulhuw (t, _mm_set1_pi16 (257));
|
||||
return _mm_srli_pi16 (_mm_add_pi16 (t, _mm_srli_pi16 (t, 8)), 8);
|
||||
}
|
||||
}
|
||||
|
||||
/* c * a / 255, rounded the same way */
|
||||
KERNEL __m64
|
||||
premultiply (__m64 c, __m64 a, const gint how)
|
||||
{
|
||||
if (how == AMD3D || how == AMD3D_EXT)
|
||||
return blend (c, _mm_setzero_si64 (), a, how);
|
||||
else
|
||||
{
|
||||
__m64 t = _mm_add_pi16 (_mm_mullo_pi16 (c, a), _mm_set1_pi16 (0x80));
|
||||
|
||||
if (how == EXT)
|
||||
return pmulhuw (t, _mm_set1_pi16 (257));
|
||||
return _mm_srli_pi16 (_mm_add_pi16 (t, _mm_srli_pi16 (t, 8)), 8);
|
||||
}
|
||||
}
|
||||
|
||||
/* The alpha of a pixel in 16-bit lanes in all four lanes */
|
||||
KERNEL __m64
|
||||
alpha_of (__m64 v, const gint how)
|
||||
{
|
||||
if (how == EXT || how == AMD3D_EXT)
|
||||
{
|
||||
PSHUFW (v, 0xff);
|
||||
return v;
|
||||
}
|
||||
v = _mm_srli_si64 (v, 48);
|
||||
v = _mm_unpacklo_pi16 (v, v);
|
||||
|
||||
return _mm_unpacklo_pi32 (v, v);
|
||||
}
|
||||
|
||||
/* Two RGBA pixels as 16-bit lanes B, G, R, A each: the order of the
|
||||
* bytes of 0xAARRGGBB */
|
||||
KERNEL void
|
||||
unpack_bgra (__m64 s, __m64 *lo, __m64 *hi, const gint how)
|
||||
{
|
||||
const __m64 zero = _mm_setzero_si64 ();
|
||||
|
||||
if (how == EXT || how == AMD3D_EXT)
|
||||
{
|
||||
__m64 l = _mm_unpacklo_pi8 (s, zero);
|
||||
__m64 h = _mm_unpackhi_pi8 (s, zero);
|
||||
|
||||
PSHUFW (l, 0xc6);
|
||||
PSHUFW (h, 0xc6);
|
||||
*lo = l;
|
||||
*hi = h;
|
||||
}
|
||||
else
|
||||
{
|
||||
s = _mm_or_si64 (_mm_and_si64 (s, SPLAT (0xff00ff00)),
|
||||
_mm_or_si64 (_mm_slli_pi32 (_mm_and_si64 (s, SPLAT (0xff)), 16),
|
||||
_mm_and_si64 (_mm_srli_pi32 (s, 16), SPLAT (0xff))));
|
||||
*lo = _mm_unpacklo_pi8 (s, zero);
|
||||
*hi = _mm_unpackhi_pi8 (s, zero);
|
||||
}
|
||||
}
|
||||
|
||||
KERNEL gint
|
||||
composite_x888_k (guint32 *pixels, const guchar *rgba, gint n, const gint how)
|
||||
{
|
||||
const __m64 zero = _mm_setzero_si64 ();
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 2 <= n; i += 2, rgba += 8)
|
||||
{
|
||||
__m64 s = load8 (rgba);
|
||||
__m64 d = load8 (pixels + i);
|
||||
__m64 transparent = _mm_cmpeq_pi32 (_mm_srli_pi32 (s, 24), zero);
|
||||
__m64 lo, hi, v;
|
||||
|
||||
unpack_bgra (s, &lo, &hi, how);
|
||||
lo = blend (lo, _mm_unpacklo_pi8 (d, zero), alpha_of (lo, how), how);
|
||||
hi = blend (hi, _mm_unpackhi_pi8 (d, zero), alpha_of (hi, how), how);
|
||||
v = _mm_or_si64 (_mm_packs_pu16 (lo, hi), SPLAT (0xff000000));
|
||||
|
||||
/* fully transparent pixels stay as they are */
|
||||
store8 (pixels + i, _mm_or_si64 (_mm_and_si64 (transparent, d),
|
||||
_mm_andnot_si64 (transparent, v)));
|
||||
}
|
||||
_mm_empty ();
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/* Four 565 or 555 pixels at a time, each channel in a register */
|
||||
KERNEL gint
|
||||
composite_16_k (guint16 *pixels, const guchar *rgba, gint n, const gint green_bits, const gint how)
|
||||
{
|
||||
const gint red_shift = 5 + green_bits;
|
||||
const __m64 zero = _mm_setzero_si64 ();
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 4 <= n; i += 4, rgba += 16)
|
||||
{
|
||||
__m64 s0 = load8 (rgba);
|
||||
__m64 s1 = load8 (rgba + 8);
|
||||
__m64 d = load8 (pixels + i);
|
||||
__m64 r = _mm_packs_pi32 (_mm_and_si64 (s0, SPLAT (0xff)), _mm_and_si64 (s1, SPLAT (0xff)));
|
||||
__m64 g = _mm_packs_pi32 (_mm_and_si64 (_mm_srli_pi32 (s0, 8), SPLAT (0xff)),
|
||||
_mm_and_si64 (_mm_srli_pi32 (s1, 8), SPLAT (0xff)));
|
||||
__m64 b = _mm_packs_pi32 (_mm_and_si64 (_mm_srli_pi32 (s0, 16), SPLAT (0xff)),
|
||||
_mm_and_si64 (_mm_srli_pi32 (s1, 16), SPLAT (0xff)));
|
||||
__m64 a = _mm_packs_pi32 (_mm_srli_pi32 (s0, 24), _mm_srli_pi32 (s1, 24));
|
||||
__m64 dr = _mm_and_si64 (_mm_srli_pi16 (d, red_shift), _mm_set1_pi16 (0x1f));
|
||||
__m64 dg = _mm_and_si64 (_mm_srli_pi16 (d, 5), _mm_set1_pi16 ((1 << green_bits) - 1));
|
||||
__m64 db = _mm_and_si64 (d, _mm_set1_pi16 (0x1f));
|
||||
__m64 v;
|
||||
|
||||
/* the bits of the pixel repeated up to 8 */
|
||||
dr = _mm_or_si64 (_mm_slli_pi16 (dr, 3), _mm_srli_pi16 (dr, 2));
|
||||
if (green_bits == 6)
|
||||
dg = _mm_or_si64 (_mm_slli_pi16 (dg, 2), _mm_srli_pi16 (dg, 4));
|
||||
else
|
||||
dg = _mm_or_si64 (_mm_slli_pi16 (dg, 3), _mm_srli_pi16 (dg, 2));
|
||||
db = _mm_or_si64 (_mm_slli_pi16 (db, 3), _mm_srli_pi16 (db, 2));
|
||||
|
||||
r = blend (r, dr, a, how);
|
||||
g = blend (g, dg, a, how);
|
||||
b = blend (b, db, a, how);
|
||||
v = _mm_or_si64 (_mm_or_si64 (_mm_slli_pi16 (_mm_srli_pi16 (r, 3), red_shift),
|
||||
_mm_slli_pi16 (_mm_srli_pi16 (g, 8 - green_bits), 5)),
|
||||
_mm_srli_pi16 (b, 3));
|
||||
|
||||
if (green_bits == 5)
|
||||
{
|
||||
/* the unused bit is set, except where nothing is drawn */
|
||||
__m64 transparent = _mm_cmpeq_pi16 (a, zero);
|
||||
|
||||
v = _mm_or_si64 (_mm_and_si64 (transparent, d),
|
||||
_mm_andnot_si64 (transparent, _mm_or_si64 (v, _mm_set1_pi16 ((gshort) 0x8000))));
|
||||
}
|
||||
store8 (pixels + i, v);
|
||||
}
|
||||
_mm_empty ();
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
KERNEL gint
|
||||
rgba_to_argb_k (guint32 *out, const guchar *rgba, gint n, const gint how)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 2 <= n; i += 2, rgba += 8)
|
||||
{
|
||||
__m64 s = load8 (rgba);
|
||||
__m64 lo, hi;
|
||||
|
||||
unpack_bgra (s, &lo, &hi, how);
|
||||
lo = premultiply (lo, alpha_of (lo, how), how);
|
||||
hi = premultiply (hi, alpha_of (hi, how), how);
|
||||
|
||||
/* the alpha byte as it was */
|
||||
store8 (out + i, _mm_or_si64 (_mm_and_si64 (_mm_packs_pu16 (lo, hi), SPLAT (0x00ffffff)),
|
||||
_mm_and_si64 (s, SPLAT (0xff000000))));
|
||||
}
|
||||
_mm_empty ();
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
#define DEFINE_KERNELS(suffix, how) \
|
||||
static gint \
|
||||
composite_x888_##suffix (guint32 *pixels, const guchar *rgba, gint n) \
|
||||
{ \
|
||||
return composite_x888_k (pixels, rgba, n, how); \
|
||||
} \
|
||||
\
|
||||
static gint \
|
||||
composite_565_##suffix (guint16 *pixels, const guchar *rgba, gint n) \
|
||||
{ \
|
||||
return composite_16_k (pixels, rgba, n, 6, how); \
|
||||
} \
|
||||
\
|
||||
static gint \
|
||||
composite_555_##suffix (guint16 *pixels, const guchar *rgba, gint n) \
|
||||
{ \
|
||||
return composite_16_k (pixels, rgba, n, 5, how); \
|
||||
} \
|
||||
\
|
||||
static gint \
|
||||
rgba_to_argb_##suffix (guint32 *out, const guchar *rgba, gint n) \
|
||||
{ \
|
||||
return rgba_to_argb_k (out, rgba, n, how); \
|
||||
} \
|
||||
\
|
||||
static void \
|
||||
init_##suffix (GdkRgbSimd *simd, const gchar *name) \
|
||||
{ \
|
||||
simd->name = name; \
|
||||
simd->rgb_to_x888 = rgb_to_x888; \
|
||||
simd->rgbx_to_x888 = rgbx_to_x888; \
|
||||
simd->rgb_to_565 = rgb_to_565; \
|
||||
simd->rgb_to_555 = rgb_to_555; \
|
||||
simd->composite_x888 = composite_x888_##suffix; \
|
||||
simd->composite_565 = composite_565_##suffix; \
|
||||
simd->composite_555 = composite_555_##suffix; \
|
||||
simd->rgba_to_argb = rgba_to_argb_##suffix; \
|
||||
}
|
||||
|
||||
DEFINE_KERNELS (mmx, PLAIN)
|
||||
|
||||
void
|
||||
_gdk_rgb_simd_init_mmx (GdkRgbSimd *simd)
|
||||
{
|
||||
init_mmx (simd, "mmx");
|
||||
}
|
||||
|
||||
#if defined(HAVE_LATER_MMX)
|
||||
|
||||
DEFINE_KERNELS (ext, EXT)
|
||||
DEFINE_KERNELS (3dnow, AMD3D)
|
||||
DEFINE_KERNELS (3dnowext, AMD3D_EXT)
|
||||
|
||||
void
|
||||
_gdk_rgb_simd_init_mmxext (GdkRgbSimd *simd)
|
||||
{
|
||||
init_ext (simd, "mmxext");
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_rgb_simd_init_3dnow (GdkRgbSimd *simd)
|
||||
{
|
||||
init_3dnow (simd, "3dnow");
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_rgb_simd_init_3dnowext (GdkRgbSimd *simd)
|
||||
{
|
||||
init_3dnowext (simd, "3dnowext");
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void _gdk_rgb_simd_init_mmxext (GdkRgbSimd *simd) { }
|
||||
void _gdk_rgb_simd_init_3dnow (GdkRgbSimd *simd) { }
|
||||
void _gdk_rgb_simd_init_3dnowext (GdkRgbSimd *simd) { }
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
244
gdk/gdkrgb-neon.c
Normal file
244
gdk/gdkrgb-neon.c
Normal file
|
|
@ -0,0 +1,244 @@
|
|||
/* GDK - The GIMP Drawing Kit
|
||||
* GdkRGB loops for NEON (ARMv7 with NEON, AArch64)
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkrgbsimd.h"
|
||||
|
||||
#if (defined(__ARM_NEON) || defined(__ARM_NEON__)) && !defined(__ARM_BIG_ENDIAN)
|
||||
|
||||
#include <arm_neon.h>
|
||||
|
||||
/* An x888 pixel is the bytes B, G, R, 0xff. The structure loads and
|
||||
* stores take the channels apart and put them together. */
|
||||
|
||||
/* (a * s + (255 - a) * d) / 255, rounded */
|
||||
static inline uint8x8_t
|
||||
blend (uint8x8_t s, uint8x8_t d, uint8x8_t a, uint8x8_t inv)
|
||||
{
|
||||
uint16x8_t t = vmlal_u8 (vmull_u8 (s, a), d, inv);
|
||||
|
||||
return vrshrn_n_u16 (vrsraq_n_u16 (t, t, 8), 8);
|
||||
}
|
||||
|
||||
static inline uint16x8_t
|
||||
pack565 (uint8x8_t r, uint8x8_t g, uint8x8_t b)
|
||||
{
|
||||
uint16x8_t v = vshll_n_u8 (r, 8);
|
||||
|
||||
v = vsriq_n_u16 (v, vshll_n_u8 (g, 8), 5);
|
||||
|
||||
return vsriq_n_u16 (v, vshll_n_u8 (b, 8), 11);
|
||||
}
|
||||
|
||||
/* with the unused bit set, as all of GdkRGB does */
|
||||
static inline uint16x8_t
|
||||
pack555 (uint8x8_t r, uint8x8_t g, uint8x8_t b)
|
||||
{
|
||||
uint16x8_t v = vshll_n_u8 (r, 7);
|
||||
|
||||
v = vsriq_n_u16 (v, vshll_n_u8 (g, 8), 6);
|
||||
v = vsriq_n_u16 (v, vshll_n_u8 (b, 8), 11);
|
||||
|
||||
return vorrq_u16 (v, vdupq_n_u16 (0x8000));
|
||||
}
|
||||
|
||||
static gint
|
||||
rgb_to_x888 (guint32 *out, const guchar *rgb, gint n)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 16 <= n; i += 16, rgb += 48)
|
||||
{
|
||||
uint8x16x3_t s = vld3q_u8 (rgb);
|
||||
uint8x16x4_t d;
|
||||
|
||||
d.val[0] = s.val[2];
|
||||
d.val[1] = s.val[1];
|
||||
d.val[2] = s.val[0];
|
||||
d.val[3] = vdupq_n_u8 (0xff);
|
||||
vst4q_u8 ((guchar *) (out + i), d);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static gint
|
||||
rgbx_to_x888 (guint32 *out, const guchar *rgbx, gint n)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 16 <= n; i += 16, rgbx += 64)
|
||||
{
|
||||
uint8x16x4_t s = vld4q_u8 (rgbx);
|
||||
uint8x16x4_t d;
|
||||
|
||||
d.val[0] = s.val[2];
|
||||
d.val[1] = s.val[1];
|
||||
d.val[2] = s.val[0];
|
||||
d.val[3] = vdupq_n_u8 (0xff);
|
||||
vst4q_u8 ((guchar *) (out + i), d);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static gint
|
||||
rgb_to_565 (guint16 *out, const guchar *rgb, gint n)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 8 <= n; i += 8, rgb += 24)
|
||||
{
|
||||
uint8x8x3_t s = vld3_u8 (rgb);
|
||||
|
||||
vst1q_u16 (out + i, pack565 (s.val[0], s.val[1], s.val[2]));
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static gint
|
||||
rgb_to_555 (guint16 *out, const guchar *rgb, gint n)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 8 <= n; i += 8, rgb += 24)
|
||||
{
|
||||
uint8x8x3_t s = vld3_u8 (rgb);
|
||||
|
||||
vst1q_u16 (out + i, pack555 (s.val[0], s.val[1], s.val[2]));
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static gint
|
||||
composite_x888 (guint32 *pixels, const guchar *rgba, gint n)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 8 <= n; i += 8, rgba += 32)
|
||||
{
|
||||
uint8x8x4_t s = vld4_u8 (rgba);
|
||||
uint8x8x4_t d = vld4_u8 ((const guchar *) (pixels + i));
|
||||
uint8x8_t a = s.val[3], inv = vmvn_u8 (a);
|
||||
uint8x8_t transparent = vceq_u8 (a, vdup_n_u8 (0));
|
||||
uint8x8x4_t v;
|
||||
|
||||
v.val[0] = vbsl_u8 (transparent, d.val[0], blend (s.val[2], d.val[0], a, inv));
|
||||
v.val[1] = vbsl_u8 (transparent, d.val[1], blend (s.val[1], d.val[1], a, inv));
|
||||
v.val[2] = vbsl_u8 (transparent, d.val[2], blend (s.val[0], d.val[2], a, inv));
|
||||
v.val[3] = vbsl_u8 (transparent, d.val[3], vdup_n_u8 (0xff));
|
||||
vst4_u8 ((guchar *) (pixels + i), v);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static gint
|
||||
composite_565 (guint16 *pixels, const guchar *rgba, gint n)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 8 <= n; i += 8, rgba += 32)
|
||||
{
|
||||
uint8x8x4_t s = vld4_u8 (rgba);
|
||||
uint16x8_t d = vld1q_u16 (pixels + i);
|
||||
uint8x8_t a = s.val[3], inv = vmvn_u8 (a);
|
||||
uint8x8_t r = vmovn_u16 (vshrq_n_u16 (d, 8));
|
||||
uint8x8_t g = vmovn_u16 (vshrq_n_u16 (d, 3));
|
||||
uint8x8_t b = vmovn_u16 (vshlq_n_u16 (d, 3));
|
||||
|
||||
/* the bits of the pixel repeated up to 8 */
|
||||
r = vsri_n_u8 (r, r, 5);
|
||||
g = vsri_n_u8 (vand_u8 (g, vdup_n_u8 (0xfc)), g, 6);
|
||||
b = vsri_n_u8 (b, b, 5);
|
||||
|
||||
vst1q_u16 (pixels + i, pack565 (blend (s.val[0], r, a, inv),
|
||||
blend (s.val[1], g, a, inv),
|
||||
blend (s.val[2], b, a, inv)));
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/* c * a / 255 to the nearest */
|
||||
static gint
|
||||
rgba_to_argb (guint32 *out, const guchar *rgba, gint n)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 8 <= n; i += 8, rgba += 32)
|
||||
{
|
||||
uint8x8x4_t s = vld4_u8 (rgba);
|
||||
uint8x8x4_t v;
|
||||
uint16x8_t t;
|
||||
|
||||
t = vmull_u8 (s.val[2], s.val[3]);
|
||||
v.val[0] = vrshrn_n_u16 (vrsraq_n_u16 (t, t, 8), 8);
|
||||
t = vmull_u8 (s.val[1], s.val[3]);
|
||||
v.val[1] = vrshrn_n_u16 (vrsraq_n_u16 (t, t, 8), 8);
|
||||
t = vmull_u8 (s.val[0], s.val[3]);
|
||||
v.val[2] = vrshrn_n_u16 (vrsraq_n_u16 (t, t, 8), 8);
|
||||
v.val[3] = s.val[3];
|
||||
vst4_u8 ((guchar *) (out + i), v);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static gint
|
||||
composite_555 (guint16 *pixels, const guchar *rgba, gint n)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 8 <= n; i += 8, rgba += 32)
|
||||
{
|
||||
uint8x8x4_t s = vld4_u8 (rgba);
|
||||
uint16x8_t d = vld1q_u16 (pixels + i);
|
||||
uint8x8_t a = s.val[3], inv = vmvn_u8 (a);
|
||||
uint8x8_t r = vmovn_u16 (vshrq_n_u16 (d, 7));
|
||||
uint8x8_t g = vmovn_u16 (vshrq_n_u16 (d, 2));
|
||||
uint8x8_t b = vmovn_u16 (vshlq_n_u16 (d, 3));
|
||||
uint16x8_t v;
|
||||
|
||||
/* the bits of the pixel repeated up to 8 */
|
||||
r = vsri_n_u8 (r, r, 5);
|
||||
g = vsri_n_u8 (g, g, 5);
|
||||
b = vsri_n_u8 (b, b, 5);
|
||||
|
||||
v = pack555 (blend (s.val[0], r, a, inv),
|
||||
blend (s.val[1], g, a, inv),
|
||||
blend (s.val[2], b, a, inv));
|
||||
|
||||
/* where nothing is drawn the unused bit stays as it was */
|
||||
vst1q_u16 (pixels + i,
|
||||
vbslq_u16 (vreinterpretq_u16_s16 (vmovl_s8 (vreinterpret_s8_u8 (vceq_u8 (a, vdup_n_u8 (0))))),
|
||||
d, v));
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_rgb_simd_init_neon (GdkRgbSimd *simd)
|
||||
{
|
||||
simd->name = "neon";
|
||||
simd->rgb_to_x888 = rgb_to_x888;
|
||||
simd->rgbx_to_x888 = rgbx_to_x888;
|
||||
simd->rgb_to_565 = rgb_to_565;
|
||||
simd->rgb_to_555 = rgb_to_555;
|
||||
simd->composite_x888 = composite_x888;
|
||||
simd->composite_565 = composite_565;
|
||||
simd->composite_555 = composite_555;
|
||||
simd->rgba_to_argb = rgba_to_argb;
|
||||
}
|
||||
|
||||
#endif
|
||||
293
gdk/gdkrgb-sse2.c
Normal file
293
gdk/gdkrgb-sse2.c
Normal file
|
|
@ -0,0 +1,293 @@
|
|||
/* GDK - The GIMP Drawing Kit
|
||||
* GdkRGB loops for SSE2
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkrgbsimd.h"
|
||||
|
||||
#if defined(__SSE2__)
|
||||
|
||||
#include <emmintrin.h>
|
||||
|
||||
/* x86 is little endian: an x888 pixel is the bytes B, G, R, 0xff */
|
||||
|
||||
#define SPLAT(v) _mm_set1_epi32 ((gint) (v))
|
||||
|
||||
/* The 12 bytes of four RGB pixels as lanes R | G << 8 | B << 16 */
|
||||
static inline __m128i
|
||||
rgb_lanes (__m128i v)
|
||||
{
|
||||
__m128i lo = _mm_unpacklo_epi32 (v, _mm_srli_si128 (v, 3));
|
||||
__m128i hi = _mm_unpacklo_epi32 (_mm_srli_si128 (v, 6), _mm_srli_si128 (v, 9));
|
||||
|
||||
return _mm_unpacklo_epi64 (lo, hi);
|
||||
}
|
||||
|
||||
/* Lanes R | G << 8 | B << 16 to x888 */
|
||||
static inline __m128i
|
||||
x888_of (__m128i v)
|
||||
{
|
||||
return _mm_or_si128 (_mm_or_si128 (_mm_slli_epi32 (_mm_and_si128 (v, SPLAT (0xff)), 16),
|
||||
_mm_and_si128 (v, SPLAT (0xff00))),
|
||||
_mm_or_si128 (_mm_and_si128 (_mm_srli_epi32 (v, 16), SPLAT (0xff)),
|
||||
SPLAT (0xff000000)));
|
||||
}
|
||||
|
||||
/* Lanes R | G << 8 | B << 16 to 565, sign extended for packing */
|
||||
static inline __m128i
|
||||
rgb565_of (__m128i v)
|
||||
{
|
||||
v = _mm_or_si128 (_mm_or_si128 (_mm_slli_epi32 (_mm_and_si128 (v, SPLAT (0xf8)), 8),
|
||||
_mm_srli_epi32 (_mm_and_si128 (v, SPLAT (0xfc00)), 5)),
|
||||
_mm_and_si128 (_mm_srli_epi32 (v, 19), SPLAT (0x1f)));
|
||||
|
||||
return _mm_srai_epi32 (_mm_slli_epi32 (v, 16), 16);
|
||||
}
|
||||
|
||||
/* The same to 555, with the unused bit set as all of GdkRGB does */
|
||||
static inline __m128i
|
||||
rgb555_of (__m128i v)
|
||||
{
|
||||
v = _mm_or_si128 (_mm_or_si128 (_mm_slli_epi32 (_mm_and_si128 (v, SPLAT (0xf8)), 7),
|
||||
_mm_srli_epi32 (_mm_and_si128 (v, SPLAT (0xf800)), 6)),
|
||||
_mm_or_si128 (_mm_and_si128 (_mm_srli_epi32 (v, 19), SPLAT (0x1f)),
|
||||
SPLAT (0x8000)));
|
||||
|
||||
return _mm_srai_epi32 (_mm_slli_epi32 (v, 16), 16);
|
||||
}
|
||||
|
||||
static gint
|
||||
rgb_to_x888 (guint32 *out, const guchar *rgb, gint n)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 8 <= n; i += 8, rgb += 24)
|
||||
{
|
||||
__m128i a = _mm_loadu_si128 ((const __m128i *) rgb);
|
||||
__m128i b = _mm_loadl_epi64 ((const __m128i *) (rgb + 16));
|
||||
__m128i c = _mm_or_si128 (_mm_srli_si128 (a, 12), _mm_slli_si128 (b, 4));
|
||||
|
||||
_mm_storeu_si128 ((__m128i *) (out + i), x888_of (rgb_lanes (a)));
|
||||
_mm_storeu_si128 ((__m128i *) (out + i + 4), x888_of (rgb_lanes (c)));
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static gint
|
||||
rgbx_to_x888 (guint32 *out, const guchar *rgbx, gint n)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 4 <= n; i += 4, rgbx += 16)
|
||||
_mm_storeu_si128 ((__m128i *) (out + i),
|
||||
x888_of (_mm_loadu_si128 ((const __m128i *) rgbx)));
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static gint
|
||||
rgb_to_565 (guint16 *out, const guchar *rgb, gint n)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 8 <= n; i += 8, rgb += 24)
|
||||
{
|
||||
__m128i a = _mm_loadu_si128 ((const __m128i *) rgb);
|
||||
__m128i b = _mm_loadl_epi64 ((const __m128i *) (rgb + 16));
|
||||
__m128i c = _mm_or_si128 (_mm_srli_si128 (a, 12), _mm_slli_si128 (b, 4));
|
||||
|
||||
_mm_storeu_si128 ((__m128i *) (out + i),
|
||||
_mm_packs_epi32 (rgb565_of (rgb_lanes (a)),
|
||||
rgb565_of (rgb_lanes (c))));
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static gint
|
||||
rgb_to_555 (guint16 *out, const guchar *rgb, gint n)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 8 <= n; i += 8, rgb += 24)
|
||||
{
|
||||
__m128i a = _mm_loadu_si128 ((const __m128i *) rgb);
|
||||
__m128i b = _mm_loadl_epi64 ((const __m128i *) (rgb + 16));
|
||||
__m128i c = _mm_or_si128 (_mm_srli_si128 (a, 12), _mm_slli_si128 (b, 4));
|
||||
|
||||
_mm_storeu_si128 ((__m128i *) (out + i),
|
||||
_mm_packs_epi32 (rgb555_of (rgb_lanes (a)),
|
||||
rgb555_of (rgb_lanes (c))));
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/* (a * s + (255 - a) * d) / 255, rounded, in 16-bit lanes */
|
||||
static inline __m128i
|
||||
blend (__m128i s, __m128i d, __m128i a)
|
||||
{
|
||||
__m128i t = _mm_add_epi16 (_mm_add_epi16 (_mm_mullo_epi16 (s, a),
|
||||
_mm_mullo_epi16 (d, _mm_sub_epi16 (_mm_set1_epi16 (255), a))),
|
||||
_mm_set1_epi16 (0x80));
|
||||
|
||||
return _mm_srli_epi16 (_mm_add_epi16 (t, _mm_srli_epi16 (t, 8)), 8);
|
||||
}
|
||||
|
||||
/* Alpha of each pixel in all four 16-bit lanes of the pixel */
|
||||
static inline __m128i
|
||||
alpha_of (__m128i v)
|
||||
{
|
||||
return _mm_shufflehi_epi16 (_mm_shufflelo_epi16 (v, 0xff), 0xff);
|
||||
}
|
||||
|
||||
static gint
|
||||
composite_x888 (guint32 *pixels, const guchar *rgba, gint n)
|
||||
{
|
||||
const __m128i zero = _mm_setzero_si128 ();
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 4 <= n; i += 4, rgba += 16)
|
||||
{
|
||||
__m128i s = _mm_loadu_si128 ((const __m128i *) rgba);
|
||||
__m128i d = _mm_loadu_si128 ((const __m128i *) (pixels + i));
|
||||
__m128i transparent = _mm_cmpeq_epi32 (_mm_srli_epi32 (s, 24), zero);
|
||||
__m128i lo, hi, v;
|
||||
|
||||
/* RGBA to BGRA, the order of the pixels */
|
||||
s = _mm_or_si128 (_mm_and_si128 (s, SPLAT (0xff00ff00)),
|
||||
_mm_or_si128 (_mm_slli_epi32 (_mm_and_si128 (s, SPLAT (0xff)), 16),
|
||||
_mm_and_si128 (_mm_srli_epi32 (s, 16), SPLAT (0xff))));
|
||||
|
||||
lo = _mm_unpacklo_epi8 (s, zero);
|
||||
hi = _mm_unpackhi_epi8 (s, zero);
|
||||
lo = blend (lo, _mm_unpacklo_epi8 (d, zero), alpha_of (lo));
|
||||
hi = blend (hi, _mm_unpackhi_epi8 (d, zero), alpha_of (hi));
|
||||
v = _mm_or_si128 (_mm_packus_epi16 (lo, hi), SPLAT (0xff000000));
|
||||
|
||||
/* fully transparent pixels stay as they are */
|
||||
v = _mm_or_si128 (_mm_and_si128 (transparent, d), _mm_andnot_si128 (transparent, v));
|
||||
_mm_storeu_si128 ((__m128i *) (pixels + i), v);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/* Eight 565 or 555 pixels at a time, each channel in a register */
|
||||
static inline gint
|
||||
composite_16 (guint16 *pixels, const guchar *rgba, gint n, const gint green_bits)
|
||||
{
|
||||
const gint red_shift = 5 + green_bits;
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 8 <= n; i += 8, rgba += 32)
|
||||
{
|
||||
__m128i s0 = _mm_loadu_si128 ((const __m128i *) rgba);
|
||||
__m128i s1 = _mm_loadu_si128 ((const __m128i *) (rgba + 16));
|
||||
__m128i d = _mm_loadu_si128 ((const __m128i *) (pixels + i));
|
||||
__m128i r = _mm_packs_epi32 (_mm_and_si128 (s0, SPLAT (0xff)),
|
||||
_mm_and_si128 (s1, SPLAT (0xff)));
|
||||
__m128i g = _mm_packs_epi32 (_mm_and_si128 (_mm_srli_epi32 (s0, 8), SPLAT (0xff)),
|
||||
_mm_and_si128 (_mm_srli_epi32 (s1, 8), SPLAT (0xff)));
|
||||
__m128i b = _mm_packs_epi32 (_mm_and_si128 (_mm_srli_epi32 (s0, 16), SPLAT (0xff)),
|
||||
_mm_and_si128 (_mm_srli_epi32 (s1, 16), SPLAT (0xff)));
|
||||
__m128i a = _mm_packs_epi32 (_mm_srli_epi32 (s0, 24), _mm_srli_epi32 (s1, 24));
|
||||
__m128i dr = _mm_and_si128 (_mm_srli_epi16 (d, red_shift), _mm_set1_epi16 (0x1f));
|
||||
__m128i dg = _mm_and_si128 (_mm_srli_epi16 (d, 5), _mm_set1_epi16 ((1 << green_bits) - 1));
|
||||
__m128i db = _mm_and_si128 (d, _mm_set1_epi16 (0x1f));
|
||||
__m128i v;
|
||||
|
||||
/* the bits of the pixel repeated up to 8 */
|
||||
dr = _mm_or_si128 (_mm_slli_epi16 (dr, 3), _mm_srli_epi16 (dr, 2));
|
||||
if (green_bits == 6)
|
||||
dg = _mm_or_si128 (_mm_slli_epi16 (dg, 2), _mm_srli_epi16 (dg, 4));
|
||||
else
|
||||
dg = _mm_or_si128 (_mm_slli_epi16 (dg, 3), _mm_srli_epi16 (dg, 2));
|
||||
db = _mm_or_si128 (_mm_slli_epi16 (db, 3), _mm_srli_epi16 (db, 2));
|
||||
|
||||
r = blend (r, dr, a);
|
||||
g = blend (g, dg, a);
|
||||
b = blend (b, db, a);
|
||||
v = _mm_or_si128 (_mm_or_si128 (_mm_slli_epi16 (_mm_srli_epi16 (r, 3), red_shift),
|
||||
_mm_slli_epi16 (_mm_srli_epi16 (g, 8 - green_bits), 5)),
|
||||
_mm_srli_epi16 (b, 3));
|
||||
|
||||
if (green_bits == 5)
|
||||
{
|
||||
/* the unused bit is set, except where nothing is drawn */
|
||||
__m128i transparent = _mm_cmpeq_epi16 (a, _mm_setzero_si128 ());
|
||||
|
||||
v = _mm_or_si128 (_mm_and_si128 (transparent, d),
|
||||
_mm_andnot_si128 (transparent, _mm_or_si128 (v, _mm_set1_epi16 ((gshort) 0x8000))));
|
||||
}
|
||||
_mm_storeu_si128 ((__m128i *) (pixels + i), v);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static gint
|
||||
composite_565 (guint16 *pixels, const guchar *rgba, gint n)
|
||||
{
|
||||
return composite_16 (pixels, rgba, n, 6);
|
||||
}
|
||||
|
||||
static gint
|
||||
composite_555 (guint16 *pixels, const guchar *rgba, gint n)
|
||||
{
|
||||
return composite_16 (pixels, rgba, n, 5);
|
||||
}
|
||||
|
||||
/* c * a / 255 to the nearest, which (c * a + 0x80) * 257 >> 16 is */
|
||||
static gint
|
||||
rgba_to_argb (guint32 *out, const guchar *rgba, gint n)
|
||||
{
|
||||
const __m128i zero = _mm_setzero_si128 ();
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 4 <= n; i += 4, rgba += 16)
|
||||
{
|
||||
__m128i s = _mm_loadu_si128 ((const __m128i *) rgba);
|
||||
__m128i lo = _mm_unpacklo_epi8 (s, zero);
|
||||
__m128i hi = _mm_unpackhi_epi8 (s, zero);
|
||||
|
||||
lo = _mm_mulhi_epu16 (_mm_add_epi16 (_mm_mullo_epi16 (lo, alpha_of (lo)), _mm_set1_epi16 (0x80)),
|
||||
_mm_set1_epi16 (257));
|
||||
hi = _mm_mulhi_epu16 (_mm_add_epi16 (_mm_mullo_epi16 (hi, alpha_of (hi)), _mm_set1_epi16 (0x80)),
|
||||
_mm_set1_epi16 (257));
|
||||
|
||||
/* R, G, B to B, G, R: the bytes of 0xAARRGGBB */
|
||||
lo = _mm_shufflehi_epi16 (_mm_shufflelo_epi16 (lo, 0xc6), 0xc6);
|
||||
hi = _mm_shufflehi_epi16 (_mm_shufflelo_epi16 (hi, 0xc6), 0xc6);
|
||||
|
||||
/* the alpha byte as it was */
|
||||
_mm_storeu_si128 ((__m128i *) (out + i),
|
||||
_mm_or_si128 (_mm_and_si128 (_mm_packus_epi16 (lo, hi), SPLAT (0x00ffffff)),
|
||||
_mm_and_si128 (s, SPLAT (0xff000000))));
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_rgb_simd_init_sse2 (GdkRgbSimd *simd)
|
||||
{
|
||||
simd->name = "sse2";
|
||||
simd->rgb_to_x888 = rgb_to_x888;
|
||||
simd->rgbx_to_x888 = rgbx_to_x888;
|
||||
simd->rgb_to_565 = rgb_to_565;
|
||||
simd->rgb_to_555 = rgb_to_555;
|
||||
simd->composite_x888 = composite_x888;
|
||||
simd->composite_565 = composite_565;
|
||||
simd->composite_555 = composite_555;
|
||||
simd->rgba_to_argb = rgba_to_argb;
|
||||
}
|
||||
|
||||
#endif
|
||||
217
gdk/gdkrgb-ssse3.c
Normal file
217
gdk/gdkrgb-ssse3.c
Normal file
|
|
@ -0,0 +1,217 @@
|
|||
/* GDK - The GIMP Drawing Kit
|
||||
* GdkRGB loops for SSSE3 (Atom, Core 2 and later): pshufb moves the
|
||||
* bytes of pixels where SSE2 takes a row of shifts and masks
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkrgbsimd.h"
|
||||
|
||||
#if defined(__SSSE3__)
|
||||
|
||||
#include <tmmintrin.h>
|
||||
|
||||
/* x86 is little endian: an x888 pixel is the bytes B, G, R, 0xff */
|
||||
|
||||
#define SPLAT(v) _mm_set1_epi32 ((gint) (v))
|
||||
#define BYTES(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \
|
||||
_mm_setr_epi8 (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)
|
||||
|
||||
/* The first 12 bytes of four RGB pixels to B, G, R, 0 each */
|
||||
static inline __m128i
|
||||
bgr0_of_rgb (__m128i v)
|
||||
{
|
||||
return _mm_shuffle_epi8 (v, BYTES (2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1));
|
||||
}
|
||||
|
||||
/* ... and to lanes R | G << 8 | B << 16, which SSE2 calls them */
|
||||
static inline __m128i
|
||||
rgb0_of_rgb (__m128i v)
|
||||
{
|
||||
return _mm_shuffle_epi8 (v, BYTES (0, 1, 2, -1, 3, 4, 5, -1, 6, 7, 8, -1, 9, 10, 11, -1));
|
||||
}
|
||||
|
||||
static gint
|
||||
rgb_to_x888 (guint32 *out, const guchar *rgb, gint n)
|
||||
{
|
||||
const __m128i fill = SPLAT (0xff000000);
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 16 <= n; i += 16, rgb += 48)
|
||||
{
|
||||
__m128i a = _mm_loadu_si128 ((const __m128i *) rgb);
|
||||
__m128i b = _mm_loadu_si128 ((const __m128i *) (rgb + 16));
|
||||
__m128i c = _mm_loadu_si128 ((const __m128i *) (rgb + 32));
|
||||
|
||||
_mm_storeu_si128 ((__m128i *) (out + i), _mm_or_si128 (bgr0_of_rgb (a), fill));
|
||||
_mm_storeu_si128 ((__m128i *) (out + i + 4),
|
||||
_mm_or_si128 (bgr0_of_rgb (_mm_alignr_epi8 (b, a, 12)), fill));
|
||||
_mm_storeu_si128 ((__m128i *) (out + i + 8),
|
||||
_mm_or_si128 (bgr0_of_rgb (_mm_alignr_epi8 (c, b, 8)), fill));
|
||||
_mm_storeu_si128 ((__m128i *) (out + i + 12),
|
||||
_mm_or_si128 (bgr0_of_rgb (_mm_srli_si128 (c, 4)), fill));
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static gint
|
||||
rgbx_to_x888 (guint32 *out, const guchar *rgbx, gint n)
|
||||
{
|
||||
const __m128i order = BYTES (2, 1, 0, -1, 6, 5, 4, -1, 10, 9, 8, -1, 14, 13, 12, -1);
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 4 <= n; i += 4, rgbx += 16)
|
||||
_mm_storeu_si128 ((__m128i *) (out + i),
|
||||
_mm_or_si128 (_mm_shuffle_epi8 (_mm_loadu_si128 ((const __m128i *) rgbx), order),
|
||||
SPLAT (0xff000000)));
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/* Lanes R | G << 8 | B << 16 to 565 or 555, sign extended for packing.
|
||||
* The bit 555 has no use for is set, as in all of GdkRGB's pixels. */
|
||||
static inline __m128i
|
||||
rgb16_of (__m128i v, const gint green_bits)
|
||||
{
|
||||
if (green_bits == 6)
|
||||
v = _mm_or_si128 (_mm_or_si128 (_mm_slli_epi32 (_mm_and_si128 (v, SPLAT (0xf8)), 8),
|
||||
_mm_srli_epi32 (_mm_and_si128 (v, SPLAT (0xfc00)), 5)),
|
||||
_mm_and_si128 (_mm_srli_epi32 (v, 19), SPLAT (0x1f)));
|
||||
else
|
||||
v = _mm_or_si128 (_mm_or_si128 (_mm_slli_epi32 (_mm_and_si128 (v, SPLAT (0xf8)), 7),
|
||||
_mm_srli_epi32 (_mm_and_si128 (v, SPLAT (0xf800)), 6)),
|
||||
_mm_or_si128 (_mm_and_si128 (_mm_srli_epi32 (v, 19), SPLAT (0x1f)),
|
||||
SPLAT (0x8000)));
|
||||
|
||||
return _mm_srai_epi32 (_mm_slli_epi32 (v, 16), 16);
|
||||
}
|
||||
|
||||
static inline gint
|
||||
rgb_to_16 (guint16 *out, const guchar *rgb, gint n, const gint green_bits)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 16 <= n; i += 16, rgb += 48)
|
||||
{
|
||||
__m128i a = _mm_loadu_si128 ((const __m128i *) rgb);
|
||||
__m128i b = _mm_loadu_si128 ((const __m128i *) (rgb + 16));
|
||||
__m128i c = _mm_loadu_si128 ((const __m128i *) (rgb + 32));
|
||||
|
||||
_mm_storeu_si128 ((__m128i *) (out + i),
|
||||
_mm_packs_epi32 (rgb16_of (rgb0_of_rgb (a), green_bits),
|
||||
rgb16_of (rgb0_of_rgb (_mm_alignr_epi8 (b, a, 12)), green_bits)));
|
||||
_mm_storeu_si128 ((__m128i *) (out + i + 8),
|
||||
_mm_packs_epi32 (rgb16_of (rgb0_of_rgb (_mm_alignr_epi8 (c, b, 8)), green_bits),
|
||||
rgb16_of (rgb0_of_rgb (_mm_srli_si128 (c, 4)), green_bits)));
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static gint
|
||||
rgb_to_565 (guint16 *out, const guchar *rgb, gint n)
|
||||
{
|
||||
return rgb_to_16 (out, rgb, n, 6);
|
||||
}
|
||||
|
||||
static gint
|
||||
rgb_to_555 (guint16 *out, const guchar *rgb, gint n)
|
||||
{
|
||||
return rgb_to_16 (out, rgb, n, 5);
|
||||
}
|
||||
|
||||
/* The alpha of each pixel in its four 16-bit lanes */
|
||||
static inline __m128i
|
||||
alpha_of (__m128i v)
|
||||
{
|
||||
return _mm_shuffle_epi8 (v, BYTES (6, 7, 6, 7, 6, 7, 6, 7, 14, 15, 14, 15, 14, 15, 14, 15));
|
||||
}
|
||||
|
||||
/* (a * s + (255 - a) * d) / 255, rounded as GdkRGB's C code does */
|
||||
static inline __m128i
|
||||
blend (__m128i s, __m128i d, __m128i a)
|
||||
{
|
||||
__m128i t = _mm_add_epi16 (_mm_add_epi16 (_mm_mullo_epi16 (s, a),
|
||||
_mm_mullo_epi16 (d, _mm_sub_epi16 (_mm_set1_epi16 (255), a))),
|
||||
_mm_set1_epi16 (0x80));
|
||||
|
||||
return _mm_mulhi_epu16 (t, _mm_set1_epi16 (257));
|
||||
}
|
||||
|
||||
static gint
|
||||
composite_x888 (guint32 *pixels, const guchar *rgba, gint n)
|
||||
{
|
||||
const __m128i zero = _mm_setzero_si128 ();
|
||||
const __m128i order = BYTES (2, 1, 0, 3, 6, 5, 4, 7, 10, 9, 8, 11, 14, 13, 12, 15);
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 4 <= n; i += 4, rgba += 16)
|
||||
{
|
||||
__m128i s = _mm_loadu_si128 ((const __m128i *) rgba);
|
||||
__m128i d = _mm_loadu_si128 ((const __m128i *) (pixels + i));
|
||||
__m128i transparent = _mm_cmpeq_epi32 (_mm_srli_epi32 (s, 24), zero);
|
||||
__m128i lo, hi, v;
|
||||
|
||||
/* RGBA to BGRA, the order of the pixels */
|
||||
s = _mm_shuffle_epi8 (s, order);
|
||||
lo = _mm_unpacklo_epi8 (s, zero);
|
||||
hi = _mm_unpackhi_epi8 (s, zero);
|
||||
lo = blend (lo, _mm_unpacklo_epi8 (d, zero), alpha_of (lo));
|
||||
hi = blend (hi, _mm_unpackhi_epi8 (d, zero), alpha_of (hi));
|
||||
v = _mm_or_si128 (_mm_packus_epi16 (lo, hi), SPLAT (0xff000000));
|
||||
|
||||
/* fully transparent pixels stay as they are */
|
||||
v = _mm_or_si128 (_mm_and_si128 (transparent, d), _mm_andnot_si128 (transparent, v));
|
||||
_mm_storeu_si128 ((__m128i *) (pixels + i), v);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/* c * a / 255 to the nearest, which (c * a + 0x80) * 257 >> 16 is */
|
||||
static gint
|
||||
rgba_to_argb (guint32 *out, const guchar *rgba, gint n)
|
||||
{
|
||||
const __m128i zero = _mm_setzero_si128 ();
|
||||
const __m128i order = BYTES (2, 1, 0, -1, 6, 5, 4, -1, 10, 9, 8, -1, 14, 13, 12, -1);
|
||||
gint i;
|
||||
|
||||
for (i = 0; i + 4 <= n; i += 4, rgba += 16)
|
||||
{
|
||||
__m128i s = _mm_loadu_si128 ((const __m128i *) rgba);
|
||||
__m128i lo = _mm_unpacklo_epi8 (s, zero);
|
||||
__m128i hi = _mm_unpackhi_epi8 (s, zero);
|
||||
|
||||
lo = _mm_mulhi_epu16 (_mm_add_epi16 (_mm_mullo_epi16 (lo, alpha_of (lo)), _mm_set1_epi16 (0x80)),
|
||||
_mm_set1_epi16 (257));
|
||||
hi = _mm_mulhi_epu16 (_mm_add_epi16 (_mm_mullo_epi16 (hi, alpha_of (hi)), _mm_set1_epi16 (0x80)),
|
||||
_mm_set1_epi16 (257));
|
||||
|
||||
/* R, G, B to B, G, R, and the alpha byte as it was */
|
||||
_mm_storeu_si128 ((__m128i *) (out + i),
|
||||
_mm_or_si128 (_mm_shuffle_epi8 (_mm_packus_epi16 (lo, hi), order),
|
||||
_mm_and_si128 (s, SPLAT (0xff000000))));
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_rgb_simd_init_ssse3 (GdkRgbSimd *simd)
|
||||
{
|
||||
simd->name = "ssse3";
|
||||
simd->rgb_to_x888 = rgb_to_x888;
|
||||
simd->rgbx_to_x888 = rgbx_to_x888;
|
||||
simd->rgb_to_565 = rgb_to_565;
|
||||
simd->rgb_to_555 = rgb_to_555;
|
||||
simd->composite_x888 = composite_x888;
|
||||
simd->rgba_to_argb = rgba_to_argb;
|
||||
}
|
||||
|
||||
#endif
|
||||
3791
gdk/gdkrgb.c
3791
gdk/gdkrgb.c
File diff suppressed because it is too large
Load diff
|
|
@ -127,7 +127,7 @@ void gdk_draw_indexed_image (GdkDrawable *drawable,
|
|||
const guchar *buf,
|
||||
gint rowstride,
|
||||
GdkRgbCmap *cmap);
|
||||
GType gdk_rgb_cmap_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_rgb_cmap_get_type (void);
|
||||
GdkRgbCmap *gdk_rgb_cmap_copy (const GdkRgbCmap *cmap);
|
||||
GdkRgbCmap *gdk_rgb_cmap_new (guint32 *colors,
|
||||
gint n_colors);
|
||||
|
|
|
|||
742
gdk/gdkrgb16.c
742
gdk/gdkrgb16.c
|
|
@ -1,742 +0,0 @@
|
|||
/* GTK - The GIMP Toolkit
|
||||
* High-precision GdkRGB image conversion
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkrgb.h"
|
||||
#include "gdkscreen.h"
|
||||
#include "gdkalias.h"
|
||||
|
||||
typedef void (*GdkRgb16ConvFunc) (GdkImage *image,
|
||||
gint x0,
|
||||
gint y0,
|
||||
gint width,
|
||||
gint height,
|
||||
const guint16 *buf,
|
||||
gint rowstride);
|
||||
|
||||
#define GDK_RGB16_STORE_RGB(p, r, g, b, a) G_STMT_START { \
|
||||
(p)[0] = (r) >> 8; \
|
||||
(p)[1] = (g) >> 8; \
|
||||
(p)[2] = (b) >> 8; \
|
||||
(p) += 3; \
|
||||
} G_STMT_END
|
||||
|
||||
#define GDK_RGB16_STORE_BGR(p, r, g, b, a) G_STMT_START { \
|
||||
(p)[0] = (b) >> 8; \
|
||||
(p)[1] = (g) >> 8; \
|
||||
(p)[2] = (r) >> 8; \
|
||||
(p) += 3; \
|
||||
} G_STMT_END
|
||||
|
||||
#define GDK_RGB16_STORE_BGRA(p, r, g, b, a) G_STMT_START { \
|
||||
(p)[0] = (b) >> 8; \
|
||||
(p)[1] = (g) >> 8; \
|
||||
(p)[2] = (r) >> 8; \
|
||||
(p)[3] = 0xff; \
|
||||
(p) += 4; \
|
||||
} G_STMT_END
|
||||
|
||||
#define GDK_RGB16_STORE_ARGB(p, r, g, b, a) G_STMT_START { \
|
||||
(p)[0] = 0xff; \
|
||||
(p)[1] = (r) >> 8; \
|
||||
(p)[2] = (g) >> 8; \
|
||||
(p)[3] = (b) >> 8; \
|
||||
(p) += 4; \
|
||||
} G_STMT_END
|
||||
|
||||
#define GDK_RGB16_STORE_RGB0_NATIVE(p, r, g, b, a) G_STMT_START { \
|
||||
guint32 pixel__ = (((b) >> 8) << 16) | \
|
||||
(((g) >> 8) << 8) | \
|
||||
((r) >> 8); \
|
||||
memcpy ((p), &pixel__, sizeof (pixel__)); \
|
||||
(p) += 4; \
|
||||
} G_STMT_END
|
||||
|
||||
#define GDK_RGB16_STORE_565(p, r, g, b, a) G_STMT_START { \
|
||||
guint16 pixel__ = ((r) & 0xf800) | \
|
||||
(((g) & 0xfc00) >> 5) | \
|
||||
((b) >> 11); \
|
||||
memcpy ((p), &pixel__, sizeof (pixel__)); \
|
||||
(p) += 2; \
|
||||
} G_STMT_END
|
||||
|
||||
#define GDK_RGB16_STORE_565_BR(p, r, g, b, a) G_STMT_START { \
|
||||
guint16 pixel__ = ((r) & 0xf800) | \
|
||||
(((g) & 0xfc00) >> 5) | \
|
||||
((b) >> 11); \
|
||||
pixel__ = (pixel__ >> 8) | (pixel__ << 8); \
|
||||
memcpy ((p), &pixel__, sizeof (pixel__)); \
|
||||
(p) += 2; \
|
||||
} G_STMT_END
|
||||
|
||||
#define GDK_RGB16_STORE_555(p, r, g, b, a) G_STMT_START { \
|
||||
guint16 pixel__ = (((r) & 0xf800) >> 1) | \
|
||||
(((g) & 0xf800) >> 6) | \
|
||||
((b) >> 11); \
|
||||
memcpy ((p), &pixel__, sizeof (pixel__)); \
|
||||
(p) += 2; \
|
||||
} G_STMT_END
|
||||
|
||||
#define GDK_RGB16_STORE_555_BR(p, r, g, b, a) G_STMT_START { \
|
||||
guint16 pixel__ = (((r) & 0xf800) >> 1) | \
|
||||
(((g) & 0xf800) >> 6) | \
|
||||
((b) >> 11); \
|
||||
pixel__ = (pixel__ >> 8) | (pixel__ << 8); \
|
||||
memcpy ((p), &pixel__, sizeof (pixel__)); \
|
||||
(p) += 2; \
|
||||
} G_STMT_END
|
||||
|
||||
#define GDK_RGB16_STORE_101010_R_LOW_LE(p, r, g, b, a) \
|
||||
G_STMT_START { \
|
||||
guint32 pixel__ = (a) | \
|
||||
(((b) >> 6) << 20) | \
|
||||
(((g) >> 6) << 10) | \
|
||||
((r) >> 6); \
|
||||
pixel__ = GUINT32_TO_LE (pixel__); \
|
||||
memcpy ((p), &pixel__, sizeof (pixel__)); \
|
||||
(p) += 4; \
|
||||
} G_STMT_END
|
||||
|
||||
#define GDK_RGB16_STORE_101010_B_LOW_LE(p, r, g, b, a) \
|
||||
G_STMT_START { \
|
||||
guint32 pixel__ = (a) | \
|
||||
(((r) >> 6) << 20) | \
|
||||
(((g) >> 6) << 10) | \
|
||||
((b) >> 6); \
|
||||
pixel__ = GUINT32_TO_LE (pixel__); \
|
||||
memcpy ((p), &pixel__, sizeof (pixel__)); \
|
||||
(p) += 4; \
|
||||
} G_STMT_END
|
||||
|
||||
#define GDK_RGB16_STORE_101010_R_LOW_BE(p, r, g, b, a) \
|
||||
G_STMT_START { \
|
||||
guint32 pixel__ = (a) | \
|
||||
(((b) >> 6) << 20) | \
|
||||
(((g) >> 6) << 10) | \
|
||||
((r) >> 6); \
|
||||
pixel__ = GUINT32_TO_BE (pixel__); \
|
||||
memcpy ((p), &pixel__, sizeof (pixel__)); \
|
||||
(p) += 4; \
|
||||
} G_STMT_END
|
||||
|
||||
#define GDK_RGB16_STORE_101010_B_LOW_BE(p, r, g, b, a) \
|
||||
G_STMT_START { \
|
||||
guint32 pixel__ = (a) | \
|
||||
(((r) >> 6) << 20) | \
|
||||
(((g) >> 6) << 10) | \
|
||||
((b) >> 6); \
|
||||
pixel__ = GUINT32_TO_BE (pixel__); \
|
||||
memcpy ((p), &pixel__, sizeof (pixel__)); \
|
||||
(p) += 4; \
|
||||
} G_STMT_END
|
||||
|
||||
#define DEFINE_GDK_RGB16_CONVERTER(name, words, pixel_bytes, store) \
|
||||
static void \
|
||||
name (GdkImage *image, \
|
||||
gint x0, \
|
||||
gint y0, \
|
||||
gint width, \
|
||||
gint height, \
|
||||
const guint16 *buf, \
|
||||
gint rowstride) \
|
||||
{ \
|
||||
const guchar *row; \
|
||||
const guint16 *src; \
|
||||
guchar *dst_row; \
|
||||
guchar *dst; \
|
||||
guint32 r, g, b; \
|
||||
guint32 alpha_mask; \
|
||||
gint x, y; \
|
||||
\
|
||||
row = (const guchar *) buf; \
|
||||
dst_row = ((guchar *) image->mem) + \
|
||||
y0 * image->bpl + x0 * (pixel_bytes); \
|
||||
alpha_mask = image->depth == 32 ? 0xc0000000U : 0; \
|
||||
(void) alpha_mask; \
|
||||
\
|
||||
for (y = 0; y < height; y++) \
|
||||
{ \
|
||||
src = (const guint16 *) row; \
|
||||
dst = dst_row; \
|
||||
\
|
||||
for (x = 0; x < width; x++) \
|
||||
{ \
|
||||
r = src[0]; \
|
||||
g = src[1]; \
|
||||
b = src[2]; \
|
||||
src += (words); \
|
||||
store (dst, r, g, b, alpha_mask); \
|
||||
} \
|
||||
\
|
||||
row += rowstride; \
|
||||
dst_row += image->bpl; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define DEFINE_GDK_RGB16_PAIR(suffix, pixel_bytes, store) \
|
||||
DEFINE_GDK_RGB16_CONVERTER (gdk_rgb48_convert_ ## suffix, \
|
||||
3, pixel_bytes, store) \
|
||||
DEFINE_GDK_RGB16_CONVERTER (gdk_rgbx64_convert_ ## suffix, \
|
||||
4, pixel_bytes, store)
|
||||
|
||||
DEFINE_GDK_RGB16_PAIR (rgb, 3, GDK_RGB16_STORE_RGB)
|
||||
DEFINE_GDK_RGB16_PAIR (bgr, 3, GDK_RGB16_STORE_BGR)
|
||||
DEFINE_GDK_RGB16_PAIR (bgra, 4, GDK_RGB16_STORE_BGRA)
|
||||
DEFINE_GDK_RGB16_PAIR (argb, 4, GDK_RGB16_STORE_ARGB)
|
||||
DEFINE_GDK_RGB16_PAIR (rgb0_native, 4, GDK_RGB16_STORE_RGB0_NATIVE)
|
||||
DEFINE_GDK_RGB16_PAIR (565, 2, GDK_RGB16_STORE_565)
|
||||
DEFINE_GDK_RGB16_PAIR (565_br, 2, GDK_RGB16_STORE_565_BR)
|
||||
DEFINE_GDK_RGB16_PAIR (555, 2, GDK_RGB16_STORE_555)
|
||||
DEFINE_GDK_RGB16_PAIR (555_br, 2, GDK_RGB16_STORE_555_BR)
|
||||
DEFINE_GDK_RGB16_PAIR (101010_r_low_le, 4,
|
||||
GDK_RGB16_STORE_101010_R_LOW_LE)
|
||||
DEFINE_GDK_RGB16_PAIR (101010_b_low_le, 4,
|
||||
GDK_RGB16_STORE_101010_B_LOW_LE)
|
||||
DEFINE_GDK_RGB16_PAIR (101010_r_low_be, 4,
|
||||
GDK_RGB16_STORE_101010_R_LOW_BE)
|
||||
DEFINE_GDK_RGB16_PAIR (101010_b_low_be, 4,
|
||||
GDK_RGB16_STORE_101010_B_LOW_BE)
|
||||
|
||||
#undef DEFINE_GDK_RGB16_PAIR
|
||||
#undef DEFINE_GDK_RGB16_CONVERTER
|
||||
|
||||
#undef GDK_RGB16_STORE_RGB
|
||||
#undef GDK_RGB16_STORE_BGR
|
||||
#undef GDK_RGB16_STORE_BGRA
|
||||
#undef GDK_RGB16_STORE_ARGB
|
||||
#undef GDK_RGB16_STORE_RGB0_NATIVE
|
||||
#undef GDK_RGB16_STORE_565
|
||||
#undef GDK_RGB16_STORE_565_BR
|
||||
#undef GDK_RGB16_STORE_555
|
||||
#undef GDK_RGB16_STORE_555_BR
|
||||
#undef GDK_RGB16_STORE_101010_R_LOW_LE
|
||||
#undef GDK_RGB16_STORE_101010_B_LOW_LE
|
||||
#undef GDK_RGB16_STORE_101010_R_LOW_BE
|
||||
#undef GDK_RGB16_STORE_101010_B_LOW_BE
|
||||
|
||||
static GdkRgb16ConvFunc
|
||||
gdk_rgb16_select_converter (GdkDrawable *drawable,
|
||||
gboolean is_rgbx,
|
||||
GdkRgbDither dith)
|
||||
{
|
||||
GdkVisual *visual;
|
||||
GdkByteOrder byte_order;
|
||||
GdkScreen *screen;
|
||||
guint32 red_mask, green_mask, blue_mask;
|
||||
gint depth;
|
||||
gint bits_per_pixel;
|
||||
gboolean byte_reversed;
|
||||
gboolean mask_rgb;
|
||||
gboolean mask_bgr;
|
||||
|
||||
#define SELECT_PAIR(suffix) \
|
||||
return is_rgbx ? gdk_rgbx64_convert_ ## suffix \
|
||||
: gdk_rgb48_convert_ ## suffix
|
||||
|
||||
/*
|
||||
* Preserve the existing GdkRGB dither path for maximum dithering
|
||||
* and for unknown future values.
|
||||
*/
|
||||
if (dith != GDK_RGB_DITHER_NONE &&
|
||||
dith != GDK_RGB_DITHER_NORMAL)
|
||||
return NULL;
|
||||
|
||||
visual = gdk_drawable_get_visual (drawable);
|
||||
if (visual == NULL)
|
||||
return NULL;
|
||||
|
||||
if (gdk_visual_get_visual_type (visual) != GDK_VISUAL_TRUE_COLOR)
|
||||
return NULL;
|
||||
|
||||
screen = gdk_visual_get_screen (visual);
|
||||
depth = gdk_visual_get_depth (visual);
|
||||
byte_order = gdk_visual_get_byte_order (visual);
|
||||
|
||||
gdk_visual_get_red_pixel_details (visual, &red_mask, NULL, NULL);
|
||||
gdk_visual_get_green_pixel_details (visual, &green_mask, NULL, NULL);
|
||||
gdk_visual_get_blue_pixel_details (visual, &blue_mask, NULL, NULL);
|
||||
|
||||
bits_per_pixel = _gdk_windowing_get_bits_for_depth
|
||||
(gdk_screen_get_display (screen), depth);
|
||||
|
||||
#if G_BYTE_ORDER == G_BIG_ENDIAN
|
||||
byte_reversed = byte_order == GDK_LSB_FIRST;
|
||||
#else
|
||||
byte_reversed = byte_order == GDK_MSB_FIRST;
|
||||
#endif
|
||||
|
||||
mask_rgb = red_mask == 0xff0000 &&
|
||||
green_mask == 0x00ff00 &&
|
||||
blue_mask == 0x0000ff;
|
||||
|
||||
mask_bgr = red_mask == 0x0000ff &&
|
||||
green_mask == 0x00ff00 &&
|
||||
blue_mask == 0xff0000;
|
||||
|
||||
if (bits_per_pixel == 16 &&
|
||||
depth == 16 &&
|
||||
red_mask == 0xf800 &&
|
||||
green_mask == 0x07e0 &&
|
||||
blue_mask == 0x001f)
|
||||
{
|
||||
if (byte_reversed)
|
||||
SELECT_PAIR (565_br);
|
||||
|
||||
SELECT_PAIR (565);
|
||||
}
|
||||
|
||||
if (bits_per_pixel == 16 &&
|
||||
depth == 15 &&
|
||||
red_mask == 0x7c00 &&
|
||||
green_mask == 0x03e0 &&
|
||||
blue_mask == 0x001f)
|
||||
{
|
||||
if (byte_reversed)
|
||||
SELECT_PAIR (555_br);
|
||||
|
||||
SELECT_PAIR (555);
|
||||
}
|
||||
|
||||
if (bits_per_pixel == 24 &&
|
||||
depth == 24 &&
|
||||
((mask_rgb && byte_order == GDK_LSB_FIRST) ||
|
||||
(mask_bgr && byte_order == GDK_MSB_FIRST)))
|
||||
SELECT_PAIR (bgr);
|
||||
|
||||
if (bits_per_pixel == 24 &&
|
||||
depth == 24 &&
|
||||
((mask_rgb && byte_order == GDK_MSB_FIRST) ||
|
||||
(mask_bgr && byte_order == GDK_LSB_FIRST)))
|
||||
SELECT_PAIR (rgb);
|
||||
|
||||
if (bits_per_pixel == 32 &&
|
||||
(depth == 24 || depth == 32) &&
|
||||
mask_rgb &&
|
||||
byte_order == GDK_MSB_FIRST)
|
||||
SELECT_PAIR (argb);
|
||||
|
||||
if (bits_per_pixel == 32 &&
|
||||
(depth == 24 || depth == 32) &&
|
||||
mask_rgb &&
|
||||
byte_order == GDK_LSB_FIRST)
|
||||
SELECT_PAIR (bgra);
|
||||
|
||||
#if G_BYTE_ORDER == G_BIG_ENDIAN
|
||||
if (bits_per_pixel == 32 &&
|
||||
depth == 24 &&
|
||||
mask_bgr &&
|
||||
byte_order == GDK_MSB_FIRST)
|
||||
SELECT_PAIR (rgb0_native);
|
||||
#else
|
||||
if (bits_per_pixel == 32 &&
|
||||
depth == 24 &&
|
||||
mask_bgr &&
|
||||
byte_order == GDK_LSB_FIRST)
|
||||
SELECT_PAIR (rgb0_native);
|
||||
#endif
|
||||
|
||||
if (bits_per_pixel == 32 &&
|
||||
(depth == 30 || depth == 32) &&
|
||||
byte_order == GDK_LSB_FIRST &&
|
||||
red_mask == 0x000003ff &&
|
||||
green_mask == 0x000ffc00 &&
|
||||
blue_mask == 0x3ff00000)
|
||||
SELECT_PAIR (101010_r_low_le);
|
||||
|
||||
if (bits_per_pixel == 32 &&
|
||||
(depth == 30 || depth == 32) &&
|
||||
byte_order == GDK_LSB_FIRST &&
|
||||
red_mask == 0x3ff00000 &&
|
||||
green_mask == 0x000ffc00 &&
|
||||
blue_mask == 0x000003ff)
|
||||
SELECT_PAIR (101010_b_low_le);
|
||||
|
||||
if (bits_per_pixel == 32 &&
|
||||
(depth == 30 || depth == 32) &&
|
||||
byte_order == GDK_MSB_FIRST &&
|
||||
red_mask == 0x000003ff &&
|
||||
green_mask == 0x000ffc00 &&
|
||||
blue_mask == 0x3ff00000)
|
||||
SELECT_PAIR (101010_r_low_be);
|
||||
|
||||
if (bits_per_pixel == 32 &&
|
||||
(depth == 30 || depth == 32) &&
|
||||
byte_order == GDK_MSB_FIRST &&
|
||||
red_mask == 0x3ff00000 &&
|
||||
green_mask == 0x000ffc00 &&
|
||||
blue_mask == 0x000003ff)
|
||||
SELECT_PAIR (101010_b_low_be);
|
||||
|
||||
#undef SELECT_PAIR
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_rgb16_draw_direct (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
const guint16 *buf,
|
||||
gint pixel_words,
|
||||
gint rowstride,
|
||||
GdkRgb16ConvFunc converter)
|
||||
{
|
||||
GdkScreen *screen;
|
||||
GdkImage *image;
|
||||
const guint16 *tile;
|
||||
gint depth;
|
||||
gint x0, y0;
|
||||
gint xs0, ys0;
|
||||
gint width1, height1;
|
||||
|
||||
screen = gdk_drawable_get_screen (drawable);
|
||||
depth = gdk_drawable_get_depth (drawable);
|
||||
|
||||
for (y0 = 0; y0 < height; y0 += GDK_SCRATCH_IMAGE_HEIGHT)
|
||||
{
|
||||
height1 = MIN (height - y0, GDK_SCRATCH_IMAGE_HEIGHT);
|
||||
|
||||
for (x0 = 0; x0 < width; x0 += GDK_SCRATCH_IMAGE_WIDTH)
|
||||
{
|
||||
width1 = MIN (width - x0, GDK_SCRATCH_IMAGE_WIDTH);
|
||||
|
||||
tile = (const guint16 *)
|
||||
((const guchar *) buf +
|
||||
y0 * rowstride +
|
||||
x0 * pixel_words * sizeof (guint16));
|
||||
|
||||
image = _gdk_image_get_scratch (screen,
|
||||
width1,
|
||||
height1,
|
||||
depth,
|
||||
&xs0,
|
||||
&ys0);
|
||||
|
||||
converter (image,
|
||||
xs0,
|
||||
ys0,
|
||||
width1,
|
||||
height1,
|
||||
tile,
|
||||
rowstride);
|
||||
|
||||
gdk_draw_image (drawable,
|
||||
gc,
|
||||
image,
|
||||
xs0,
|
||||
ys0,
|
||||
x + x0,
|
||||
y + y0,
|
||||
width1,
|
||||
height1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_rgb16_draw_fallback (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
GdkRgbDither dith,
|
||||
const guint16 *buf,
|
||||
gint pixel_words,
|
||||
gint rowstride,
|
||||
gint xdith,
|
||||
gint ydith)
|
||||
{
|
||||
const guchar *input_row;
|
||||
const guint16 *input;
|
||||
guchar *stage;
|
||||
guchar *output;
|
||||
gint stage_rowstride;
|
||||
gint x0, y0;
|
||||
gint x1, y1;
|
||||
gint width1, height1;
|
||||
|
||||
stage = g_malloc (MIN (width, GDK_SCRATCH_IMAGE_WIDTH) *
|
||||
MIN (height, GDK_SCRATCH_IMAGE_HEIGHT) * 3);
|
||||
|
||||
for (y0 = 0; y0 < height; y0 += GDK_SCRATCH_IMAGE_HEIGHT)
|
||||
{
|
||||
height1 = MIN (height - y0, GDK_SCRATCH_IMAGE_HEIGHT);
|
||||
|
||||
for (x0 = 0; x0 < width; x0 += GDK_SCRATCH_IMAGE_WIDTH)
|
||||
{
|
||||
width1 = MIN (width - x0, GDK_SCRATCH_IMAGE_WIDTH);
|
||||
stage_rowstride = width1 * 3;
|
||||
|
||||
input_row = (const guchar *) buf +
|
||||
y0 * rowstride +
|
||||
x0 * pixel_words * sizeof (guint16);
|
||||
output = stage;
|
||||
|
||||
for (y1 = 0; y1 < height1; y1++)
|
||||
{
|
||||
input = (const guint16 *) input_row;
|
||||
|
||||
for (x1 = 0; x1 < width1; x1++)
|
||||
{
|
||||
*output++ = input[0] >> 8;
|
||||
*output++ = input[1] >> 8;
|
||||
*output++ = input[2] >> 8;
|
||||
input += pixel_words;
|
||||
}
|
||||
|
||||
input_row += rowstride;
|
||||
}
|
||||
|
||||
gdk_draw_rgb_image_dithalign (drawable,
|
||||
gc,
|
||||
x + x0,
|
||||
y + y0,
|
||||
width1,
|
||||
height1,
|
||||
dith,
|
||||
stage,
|
||||
stage_rowstride,
|
||||
xdith,
|
||||
ydith);
|
||||
}
|
||||
}
|
||||
|
||||
g_free (stage);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_draw_rgb16_image (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
GdkRgbDither dith,
|
||||
const guint16 *buf,
|
||||
gint rowstride,
|
||||
gint xdith,
|
||||
gint ydith,
|
||||
gboolean is_rgbx)
|
||||
{
|
||||
GdkRgb16ConvFunc converter;
|
||||
gint pixel_words;
|
||||
|
||||
g_return_if_fail (GDK_IS_DRAWABLE (drawable));
|
||||
g_return_if_fail (GDK_IS_GC (gc));
|
||||
g_return_if_fail (buf != NULL);
|
||||
g_return_if_fail ((((guintptr) buf) & 1) == 0);
|
||||
g_return_if_fail ((rowstride & 1) == 0);
|
||||
|
||||
if (width <= 0 || height <= 0)
|
||||
return;
|
||||
|
||||
pixel_words = is_rgbx ? 4 : 3;
|
||||
converter = gdk_rgb16_select_converter (drawable, is_rgbx, dith);
|
||||
|
||||
if (converter != NULL)
|
||||
gdk_rgb16_draw_direct (drawable,
|
||||
gc,
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
buf,
|
||||
pixel_words,
|
||||
rowstride,
|
||||
converter);
|
||||
else
|
||||
gdk_rgb16_draw_fallback (drawable,
|
||||
gc,
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
dith,
|
||||
buf,
|
||||
pixel_words,
|
||||
rowstride,
|
||||
xdith,
|
||||
ydith);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_draw_rgb_48_image:
|
||||
* @drawable: a #GdkDrawable
|
||||
* @gc: a #GdkGC
|
||||
* @x: destination X coordinate
|
||||
* @y: destination Y coordinate
|
||||
* @width: image width
|
||||
* @height: image height
|
||||
* @dith: dithering mode
|
||||
* @rgb_buf: host-endian RGB data with three 16-bit channels per pixel
|
||||
* @rowstride: number of bytes between consecutive rows
|
||||
*
|
||||
* Draws 48-bit RGB image data.
|
||||
**/
|
||||
void
|
||||
gdk_draw_rgb_48_image (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
GdkRgbDither dith,
|
||||
const guint16 *rgb_buf,
|
||||
gint rowstride)
|
||||
{
|
||||
gdk_draw_rgb16_image (drawable,
|
||||
gc,
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
dith,
|
||||
rgb_buf,
|
||||
rowstride,
|
||||
0,
|
||||
0,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_draw_rgb_48_image_dithalign:
|
||||
* @drawable: a #GdkDrawable
|
||||
* @gc: a #GdkGC
|
||||
* @x: destination X coordinate
|
||||
* @y: destination Y coordinate
|
||||
* @width: image width
|
||||
* @height: image height
|
||||
* @dith: dithering mode
|
||||
* @rgb_buf: host-endian RGB data with three 16-bit channels per pixel
|
||||
* @rowstride: number of bytes between consecutive rows
|
||||
* @xdith: X dither offset
|
||||
* @ydith: Y dither offset
|
||||
*
|
||||
* Draws 48-bit RGB image data with explicit dither alignment.
|
||||
**/
|
||||
void
|
||||
gdk_draw_rgb_48_image_dithalign (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
GdkRgbDither dith,
|
||||
const guint16 *rgb_buf,
|
||||
gint rowstride,
|
||||
gint xdith,
|
||||
gint ydith)
|
||||
{
|
||||
gdk_draw_rgb16_image (drawable,
|
||||
gc,
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
dith,
|
||||
rgb_buf,
|
||||
rowstride,
|
||||
xdith,
|
||||
ydith,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_draw_rgbx_64_image:
|
||||
* @drawable: a #GdkDrawable
|
||||
* @gc: a #GdkGC
|
||||
* @x: destination X coordinate
|
||||
* @y: destination Y coordinate
|
||||
* @width: image width
|
||||
* @height: image height
|
||||
* @dith: dithering mode
|
||||
* @rgbx_buf: host-endian RGBX data with four 16-bit channels per pixel
|
||||
* @rowstride: number of bytes between consecutive rows
|
||||
*
|
||||
* Draws 64-bit RGBX image data. The X channel is ignored.
|
||||
**/
|
||||
void
|
||||
gdk_draw_rgbx_64_image (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
GdkRgbDither dith,
|
||||
const guint16 *rgbx_buf,
|
||||
gint rowstride)
|
||||
{
|
||||
gdk_draw_rgb16_image (drawable,
|
||||
gc,
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
dith,
|
||||
rgbx_buf,
|
||||
rowstride,
|
||||
0,
|
||||
0,
|
||||
TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_draw_rgbx_64_image_dithalign:
|
||||
* @drawable: a #GdkDrawable
|
||||
* @gc: a #GdkGC
|
||||
* @x: destination X coordinate
|
||||
* @y: destination Y coordinate
|
||||
* @width: image width
|
||||
* @height: image height
|
||||
* @dith: dithering mode
|
||||
* @rgbx_buf: host-endian RGBX data with four 16-bit channels per pixel
|
||||
* @rowstride: number of bytes between consecutive rows
|
||||
* @xdith: X dither offset
|
||||
* @ydith: Y dither offset
|
||||
*
|
||||
* Draws 64-bit RGBX image data with explicit dither alignment.
|
||||
* The X channel is ignored.
|
||||
**/
|
||||
void
|
||||
gdk_draw_rgbx_64_image_dithalign (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
GdkRgbDither dith,
|
||||
const guint16 *rgbx_buf,
|
||||
gint rowstride,
|
||||
gint xdith,
|
||||
gint ydith)
|
||||
{
|
||||
gdk_draw_rgb16_image (drawable,
|
||||
gc,
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
dith,
|
||||
rgbx_buf,
|
||||
rowstride,
|
||||
xdith,
|
||||
ydith,
|
||||
TRUE);
|
||||
}
|
||||
|
||||
#define __GDK_RGB16_C__
|
||||
#include "gdkaliasdef.c"
|
||||
319
gdk/gdkrgbsimd.c
Normal file
319
gdk/gdkrgbsimd.c
Normal file
|
|
@ -0,0 +1,319 @@
|
|||
/* GDK - The GIMP Drawing Kit
|
||||
* Choosing the vector versions of GdkRGB loops for this CPU
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gdkrgbsimd.h"
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
#if defined(__GNUC__)
|
||||
#include <cpuid.h>
|
||||
#endif
|
||||
#elif defined(__powerpc__) || defined(__ppc__) || defined(__arm__)
|
||||
#if defined(HAVE_GETAUXVAL) || defined(HAVE_ELF_AUX_INFO)
|
||||
#include <sys/auxv.h>
|
||||
#elif defined(__APPLE__)
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* All instruction sets, from the least to the most preferred: each
|
||||
* kernel comes from the last set that has it and the CPU can run */
|
||||
static const GdkRgbSimdSet all_sets[] =
|
||||
{
|
||||
#ifdef GDK_RGB_SIMD_MMX
|
||||
{ "mmx", _gdk_rgb_simd_init_mmx },
|
||||
{ "mmxext", _gdk_rgb_simd_init_mmxext },
|
||||
{ "3dnow", _gdk_rgb_simd_init_3dnow },
|
||||
{ "3dnowext", _gdk_rgb_simd_init_3dnowext },
|
||||
#endif
|
||||
#ifdef GDK_RGB_SIMD_SSE2
|
||||
{ "sse2", _gdk_rgb_simd_init_sse2 },
|
||||
#endif
|
||||
#ifdef GDK_RGB_SIMD_SSSE3
|
||||
{ "ssse3", _gdk_rgb_simd_init_ssse3 },
|
||||
#endif
|
||||
#ifdef GDK_RGB_SIMD_AVX2
|
||||
{ "avx2", _gdk_rgb_simd_init_avx2 },
|
||||
#endif
|
||||
#ifdef GDK_RGB_SIMD_ALTIVEC
|
||||
{ "altivec", _gdk_rgb_simd_init_altivec },
|
||||
#endif
|
||||
#ifdef GDK_RGB_SIMD_ARMV6
|
||||
{ "armv6", _gdk_rgb_simd_init_armv6 },
|
||||
#endif
|
||||
#ifdef GDK_RGB_SIMD_NEON
|
||||
{ "neon", _gdk_rgb_simd_init_neon },
|
||||
#endif
|
||||
{ NULL, NULL } /* not every build has any */
|
||||
};
|
||||
|
||||
static const GdkRgbSimdOp all_ops[] =
|
||||
{
|
||||
{ "rgb_to_x888", G_STRUCT_OFFSET (GdkRgbSimd, rgb_to_x888) },
|
||||
{ "rgbx_to_x888", G_STRUCT_OFFSET (GdkRgbSimd, rgbx_to_x888) },
|
||||
{ "rgb_to_565", G_STRUCT_OFFSET (GdkRgbSimd, rgb_to_565) },
|
||||
{ "rgb_to_555", G_STRUCT_OFFSET (GdkRgbSimd, rgb_to_555) },
|
||||
{ "composite_x888", G_STRUCT_OFFSET (GdkRgbSimd, composite_x888) },
|
||||
{ "composite_565", G_STRUCT_OFFSET (GdkRgbSimd, composite_565) },
|
||||
{ "composite_555", G_STRUCT_OFFSET (GdkRgbSimd, composite_555) },
|
||||
{ "rgba_to_argb", G_STRUCT_OFFSET (GdkRgbSimd, rgba_to_argb) },
|
||||
};
|
||||
|
||||
#define OP(simd, i) G_STRUCT_MEMBER (gpointer, (simd), all_ops[i].offset)
|
||||
|
||||
/* The CPU's hardware capabilities word, as the kernel tells them */
|
||||
#if (defined(__powerpc__) || defined(__arm__)) && \
|
||||
(defined(HAVE_GETAUXVAL) || defined(HAVE_ELF_AUX_INFO))
|
||||
static unsigned long
|
||||
hwcap (void)
|
||||
{
|
||||
#if defined(HAVE_GETAUXVAL)
|
||||
return getauxval (AT_HWCAP);
|
||||
#else
|
||||
unsigned long caps = 0;
|
||||
|
||||
if (elf_aux_info (AT_HWCAP, &caps, sizeof (caps)) != 0)
|
||||
return 0;
|
||||
return caps;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (defined(__x86_64__) || defined(__i386__)) && defined(__GNUC__)
|
||||
/* AVX2: the CPU has it, and the system saves the wide registers
|
||||
* (OSXSAVE, then XCR0 says SSE and AVX state) */
|
||||
static gboolean
|
||||
cpu_has_avx2 (unsigned int ecx)
|
||||
{
|
||||
unsigned int eax, ebx, ecx7, edx, xcr0_low, xcr0_high;
|
||||
|
||||
if ((ecx & (1 << 27)) == 0 || (ecx & (1 << 28)) == 0 ||
|
||||
__get_cpuid_max (0, NULL) < 7)
|
||||
return FALSE;
|
||||
__cpuid_count (7, 0, eax, ebx, ecx7, edx);
|
||||
if ((ebx & (1 << 5)) == 0)
|
||||
return FALSE;
|
||||
__asm__ (".byte 0x0f, 0x01, 0xd0" /* xgetbv, which old assemblers do not know */
|
||||
: "=a" (xcr0_low), "=d" (xcr0_high) : "c" (0));
|
||||
|
||||
return (xcr0_low & 6) == 6;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Whether this CPU can run the set */
|
||||
static gboolean
|
||||
cpu_has (const gchar *set)
|
||||
{
|
||||
#if defined(__x86_64__)
|
||||
unsigned int eax, ebx, ecx, edx;
|
||||
|
||||
/* every x86-64 CPU has SSE2, which beats the older sets */
|
||||
if (strcmp (set, "sse2") == 0)
|
||||
return TRUE;
|
||||
if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
|
||||
return FALSE;
|
||||
if (strcmp (set, "ssse3") == 0)
|
||||
return (ecx & (1 << 9)) != 0;
|
||||
if (strcmp (set, "avx2") == 0)
|
||||
return cpu_has_avx2 (ecx);
|
||||
return FALSE;
|
||||
|
||||
#elif defined(__i386__) && defined(__GNUC__)
|
||||
unsigned int eax, ebx, ecx, edx, ext = 0, max_ext;
|
||||
|
||||
if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
|
||||
return FALSE;
|
||||
/* CPUs without the extended leaves answer with something else */
|
||||
max_ext = __get_cpuid_max (0x80000000, NULL);
|
||||
if ((max_ext & 0xffff0000) == 0x80000000 && max_ext >= 0x80000001)
|
||||
{
|
||||
unsigned int a, b, c;
|
||||
|
||||
__cpuid (0x80000001, a, b, c, ext);
|
||||
}
|
||||
|
||||
if (strcmp (set, "mmx") == 0)
|
||||
return (edx & (1 << 23)) != 0;
|
||||
/* the integer part of SSE, or AMD's extensions to MMX */
|
||||
if (strcmp (set, "mmxext") == 0)
|
||||
return (edx & (1 << 25)) != 0 || (ext & (1 << 22)) != 0;
|
||||
if (strcmp (set, "3dnow") == 0)
|
||||
return (ext & (1u << 31)) != 0;
|
||||
if (strcmp (set, "3dnowext") == 0)
|
||||
return (ext & (1 << 30)) != 0 && (ext & (1u << 31)) != 0 && (ext & (1 << 22)) != 0;
|
||||
if (strcmp (set, "sse2") == 0)
|
||||
return (edx & (1 << 26)) != 0;
|
||||
if (strcmp (set, "ssse3") == 0)
|
||||
return (ecx & (1 << 9)) != 0;
|
||||
if (strcmp (set, "avx2") == 0)
|
||||
return cpu_has_avx2 (ecx);
|
||||
return FALSE;
|
||||
|
||||
#elif defined(__aarch64__)
|
||||
return strcmp (set, "neon") == 0;
|
||||
|
||||
#elif defined(__arm__) && (defined(HAVE_GETAUXVAL) || defined(HAVE_ELF_AUX_INFO))
|
||||
if (strcmp (set, "armv6") == 0)
|
||||
{
|
||||
#if defined(__ARM_ARCH) && __ARM_ARCH >= 6
|
||||
return TRUE; /* what all of this is built for */
|
||||
#elif defined(HAVE_GETAUXVAL)
|
||||
/* "v6l", "v7l", "v8l" */
|
||||
const gchar *platform = (const gchar *) getauxval (AT_PLATFORM);
|
||||
|
||||
return platform && platform[0] == 'v' && atoi (platform + 1) >= 6;
|
||||
#else
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
return strcmp (set, "neon") == 0 && (hwcap () & (1 << 12)) != 0; /* HWCAP_NEON */
|
||||
|
||||
#elif defined(__powerpc__) && (defined(HAVE_GETAUXVAL) || defined(HAVE_ELF_AUX_INFO))
|
||||
return strcmp (set, "altivec") == 0 && (hwcap () & 0x10000000) != 0; /* PPC_FEATURE_HAS_ALTIVEC */
|
||||
|
||||
#elif defined(__ppc__) && defined(__APPLE__)
|
||||
int vector_unit = 0;
|
||||
size_t size = sizeof (vector_unit);
|
||||
|
||||
return strcmp (set, "altivec") == 0 &&
|
||||
sysctlbyname ("hw.vectorunit", &vector_unit, &size, NULL, 0) == 0 && vector_unit;
|
||||
#else
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* _gdk_rgb_simd_sets:
|
||||
* @n_sets: the number of sets
|
||||
*
|
||||
* The instruction sets this CPU can run, least preferred first. The
|
||||
* init function of a set fills in only what is in it.
|
||||
*/
|
||||
const GdkRgbSimdSet *
|
||||
_gdk_rgb_simd_sets (gint *n_sets)
|
||||
{
|
||||
static GdkRgbSimdSet sets[G_N_ELEMENTS (all_sets)];
|
||||
static gint n = -1;
|
||||
guint i;
|
||||
|
||||
if (n < 0)
|
||||
{
|
||||
n = 0;
|
||||
for (i = 0; all_sets[i].name; i++)
|
||||
if (cpu_has (all_sets[i].name))
|
||||
{
|
||||
GdkRgbSimd probe = { NULL, };
|
||||
|
||||
/* a set the compiler couldn't build fills in nothing */
|
||||
all_sets[i].init (&probe);
|
||||
if (probe.name)
|
||||
sets[n++] = all_sets[i];
|
||||
}
|
||||
}
|
||||
|
||||
*n_sets = n;
|
||||
return sets;
|
||||
}
|
||||
|
||||
/**
|
||||
* _gdk_rgb_simd_ops:
|
||||
* @n_ops: the number of operations
|
||||
*
|
||||
* The names of the kernels and where they are in a #GdkRgbSimd.
|
||||
*/
|
||||
const GdkRgbSimdOp *
|
||||
_gdk_rgb_simd_ops (gint *n_ops)
|
||||
{
|
||||
*n_ops = G_N_ELEMENTS (all_ops);
|
||||
return all_ops;
|
||||
}
|
||||
|
||||
/* GDK_RGB_SIMD picks sets by hand, to try them: "c" for none, a set
|
||||
* for that one wherever it has a kernel, "op=set" or "op=c" for one
|
||||
* kernel; several of these separated by commas, applied in order. */
|
||||
static void
|
||||
choose_by_hand (GdkRgbSimd *simd,
|
||||
const gchar *spec,
|
||||
const GdkRgbSimdSet *sets,
|
||||
gint n_sets)
|
||||
{
|
||||
gchar **items = g_strsplit (spec, ",", -1);
|
||||
gint i, k, s;
|
||||
|
||||
for (i = 0; items[i]; i++)
|
||||
{
|
||||
gchar *item = g_strstrip (items[i]);
|
||||
gchar *eq = strchr (item, '=');
|
||||
const gchar *set = eq ? eq + 1 : item;
|
||||
GdkRgbSimd from = { NULL, };
|
||||
|
||||
if (eq)
|
||||
*eq = '\0';
|
||||
|
||||
for (s = 0; s < n_sets; s++)
|
||||
if (strcmp (sets[s].name, set) == 0)
|
||||
{
|
||||
sets[s].init (&from);
|
||||
break;
|
||||
}
|
||||
if (s == n_sets && strcmp (set, "c") != 0)
|
||||
{
|
||||
g_warning ("GDK_RGB_SIMD: %s is not an instruction set this CPU has", set);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (k = 0; k < (gint) G_N_ELEMENTS (all_ops); k++)
|
||||
if (!eq || strcmp (item, all_ops[k].name) == 0)
|
||||
OP (simd, k) = OP (&from, k);
|
||||
}
|
||||
|
||||
simd->name = "by hand";
|
||||
g_strfreev (items);
|
||||
}
|
||||
|
||||
const GdkRgbSimd *
|
||||
_gdk_rgb_simd_get (void)
|
||||
{
|
||||
static GdkRgbSimd simd = { "none", };
|
||||
static gboolean done = FALSE;
|
||||
|
||||
if (!done)
|
||||
{
|
||||
const gchar *disable = g_getenv ("GDK_DISABLE_SIMD");
|
||||
const gchar *spec = g_getenv ("GDK_RGB_SIMD");
|
||||
const GdkRgbSimdSet *sets;
|
||||
gint n_sets, s, k;
|
||||
|
||||
done = TRUE;
|
||||
if (disable && *disable && *disable != '0')
|
||||
return &simd;
|
||||
|
||||
sets = _gdk_rgb_simd_sets (&n_sets);
|
||||
for (s = 0; s < n_sets; s++)
|
||||
{
|
||||
GdkRgbSimd set = { NULL, };
|
||||
|
||||
sets[s].init (&set);
|
||||
for (k = 0; k < (gint) G_N_ELEMENTS (all_ops); k++)
|
||||
if (OP (&set, k))
|
||||
OP (&simd, k) = OP (&set, k);
|
||||
simd.name = set.name;
|
||||
}
|
||||
|
||||
if (spec && *spec)
|
||||
choose_by_hand (&simd, spec, sets, n_sets);
|
||||
}
|
||||
|
||||
return &simd;
|
||||
}
|
||||
84
gdk/gdkrgbsimd.h
Normal file
84
gdk/gdkrgbsimd.h
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
/* GDK - The GIMP Drawing Kit
|
||||
* Vector versions of GdkRGB loops
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
/* Vector versions of the busiest GdkRGB loops.
|
||||
*
|
||||
* Each converts pixels from the start of a row, as many as it likes, and
|
||||
* returns how many; the C code does the rest. Pixels are words in the
|
||||
* byte order of the machine:
|
||||
*
|
||||
* x888 0xffRRGGBB, 32 bits
|
||||
* 565 RRRRRGGG GGGBBBBB, 16 bits
|
||||
* 555 1RRRRRGG GGGBBBBB, 16 bits, with the unused bit set
|
||||
* argb 0xAARRGGBB, 32 bits, R, G and B multiplied by A / 255,
|
||||
* rounded to the nearest: cairo's ARGB32
|
||||
*
|
||||
* RGB and RGBA are bytes in that order; RGBA is not premultiplied.
|
||||
* Blending rounds as GdkRGB's C code does, so the results are the same.
|
||||
* No alignment is required of any pointer.
|
||||
*/
|
||||
|
||||
#ifndef __GDK_RGB_SIMD_H__
|
||||
#define __GDK_RGB_SIMD_H__
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GdkRgbSimd GdkRgbSimd;
|
||||
|
||||
struct _GdkRgbSimd
|
||||
{
|
||||
const gchar *name;
|
||||
|
||||
gint (*rgb_to_x888) (guint32 *out, const guchar *rgb, gint n);
|
||||
gint (*rgbx_to_x888) (guint32 *out, const guchar *rgbx, gint n);
|
||||
gint (*rgb_to_565) (guint16 *out, const guchar *rgb, gint n);
|
||||
gint (*rgb_to_555) (guint16 *out, const guchar *rgb, gint n);
|
||||
gint (*composite_x888) (guint32 *pixels, const guchar *rgba, gint n);
|
||||
gint (*composite_565) (guint16 *pixels, const guchar *rgba, gint n);
|
||||
gint (*composite_555) (guint16 *pixels, const guchar *rgba, gint n);
|
||||
gint (*rgba_to_argb) (guint32 *out, const guchar *rgba, gint n);
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const gchar *name;
|
||||
void (*init) (GdkRgbSimd *simd);
|
||||
} GdkRgbSimdSet;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const gchar *name;
|
||||
glong offset;
|
||||
} GdkRgbSimdOp;
|
||||
|
||||
/* Each fills in what its instruction set does better than C; they are
|
||||
* only called when the CPU has it. */
|
||||
void _gdk_rgb_simd_init_mmx (GdkRgbSimd *simd);
|
||||
void _gdk_rgb_simd_init_mmxext (GdkRgbSimd *simd);
|
||||
void _gdk_rgb_simd_init_3dnow (GdkRgbSimd *simd);
|
||||
void _gdk_rgb_simd_init_3dnowext (GdkRgbSimd *simd);
|
||||
void _gdk_rgb_simd_init_sse2 (GdkRgbSimd *simd);
|
||||
void _gdk_rgb_simd_init_ssse3 (GdkRgbSimd *simd);
|
||||
void _gdk_rgb_simd_init_avx2 (GdkRgbSimd *simd);
|
||||
void _gdk_rgb_simd_init_altivec (GdkRgbSimd *simd);
|
||||
void _gdk_rgb_simd_init_armv6 (GdkRgbSimd *simd);
|
||||
void _gdk_rgb_simd_init_neon (GdkRgbSimd *simd);
|
||||
|
||||
/* The kernels for this CPU, or none with GDK_DISABLE_SIMD set */
|
||||
const GdkRgbSimd *_gdk_rgb_simd_get (void);
|
||||
|
||||
/* For trying them: the sets this CPU has and the kernels by name */
|
||||
const GdkRgbSimdSet *_gdk_rgb_simd_sets (gint *n_sets);
|
||||
const GdkRgbSimdOp *_gdk_rgb_simd_ops (gint *n_ops);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GDK_RGB_SIMD_H__ */
|
||||
|
|
@ -27,6 +27,7 @@
|
|||
#include "gdkwindow.h"
|
||||
#include "gdkscreen.h"
|
||||
#include "gdkintl.h"
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkalias.h"
|
||||
|
||||
static void gdk_screen_dispose (GObject *object);
|
||||
|
|
@ -541,5 +542,30 @@ gdk_screen_set_property (GObject *object,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_screen_get_monitor_scale_factor:
|
||||
* @screen: a #GdkScreen
|
||||
* @monitor_num: number of the monitor, between 0 and gdk_screen_get_n_monitors (screen)
|
||||
*
|
||||
* Returns the internal scale factor that maps from monitor coordinates
|
||||
* to the actual device pixels, as in GTK+ 3: on traditional systems
|
||||
* this is 1, on high density outputs it can be higher (typically 2).
|
||||
* The coordinates of GDK and GTK+ stay in units of the scale 1.
|
||||
*
|
||||
* Returns: the scale factor
|
||||
*
|
||||
* Since: 2.24
|
||||
*/
|
||||
gint
|
||||
gdk_screen_get_monitor_scale_factor (GdkScreen *screen,
|
||||
gint monitor_num)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_SCREEN (screen), 1);
|
||||
g_return_val_if_fail (monitor_num >= 0, 1);
|
||||
g_return_val_if_fail (monitor_num < gdk_screen_get_n_monitors (screen), 1);
|
||||
|
||||
return _gdk_windowing_screen_get_monitor_scale (screen, monitor_num);
|
||||
}
|
||||
|
||||
#define __GDK_SCREEN_C__
|
||||
#include "gdkaliasdef.c"
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ struct _GdkScreenClass
|
|||
void (*monitors_changed) (GdkScreen *screen);
|
||||
};
|
||||
|
||||
GType gdk_screen_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_screen_get_type (void);
|
||||
GdkColormap *gdk_screen_get_default_colormap (GdkScreen *screen);
|
||||
void gdk_screen_set_default_colormap (GdkScreen *screen,
|
||||
GdkColormap *colormap);
|
||||
|
|
@ -106,6 +106,8 @@ gint gdk_screen_get_monitor_height_mm (GdkScreen *screen,
|
|||
gint monitor_num);
|
||||
gchar * gdk_screen_get_monitor_plug_name (GdkScreen *screen,
|
||||
gint monitor_num);
|
||||
gint gdk_screen_get_monitor_scale_factor (GdkScreen *screen,
|
||||
gint monitor_num);
|
||||
|
||||
void gdk_screen_broadcast_client_message (GdkScreen *screen,
|
||||
GdkEvent *event);
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ struct _GdkVisual
|
|||
gint GSEAL (blue_prec);
|
||||
};
|
||||
|
||||
GType gdk_visual_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_visual_get_type (void);
|
||||
|
||||
#ifndef GDK_MULTIHEAD_SAFE
|
||||
gint gdk_visual_get_best_depth (void);
|
||||
|
|
|
|||
688
gdk/gdkwindow.c
688
gdk/gdkwindow.c
File diff suppressed because it is too large
Load diff
|
|
@ -328,7 +328,7 @@ struct _GdkWindowObjectClass
|
|||
|
||||
/* Windows
|
||||
*/
|
||||
GType gdk_window_object_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_window_object_get_type (void);
|
||||
GdkWindow* gdk_window_new (GdkWindow *parent,
|
||||
GdkWindowAttr *attributes,
|
||||
gint attributes_mask);
|
||||
|
|
@ -341,6 +341,7 @@ GdkDisplay* gdk_window_get_display (GdkWindow *window);
|
|||
GdkVisual* gdk_window_get_visual (GdkWindow *window);
|
||||
int gdk_window_get_width (GdkWindow *window);
|
||||
int gdk_window_get_height (GdkWindow *window);
|
||||
gint gdk_window_get_scale_factor (GdkWindow *window);
|
||||
|
||||
GdkWindow* gdk_window_at_pointer (gint *win_x,
|
||||
gint *win_y);
|
||||
|
|
@ -679,6 +680,7 @@ void gdk_window_thaw_updates (GdkWindow *window);
|
|||
|
||||
void gdk_window_freeze_toplevel_updates_libgtk_only (GdkWindow *window);
|
||||
void gdk_window_thaw_toplevel_updates_libgtk_only (GdkWindow *window);
|
||||
void gdk_window_set_touch_emulation_libgtk_only (GdkWindow *window);
|
||||
|
||||
void gdk_window_process_all_updates (void);
|
||||
void gdk_window_process_updates (GdkWindow *window,
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ struct _GdkWindowImplIface
|
|||
};
|
||||
|
||||
/* Interface Functions */
|
||||
GType gdk_window_impl_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_window_impl_get_type (void);
|
||||
|
||||
/* private definitions from gdkwindow.h */
|
||||
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ gdk_OBJECTS = \
|
|||
gdkrectangle.obj \
|
||||
gdkregion-generic.obj \
|
||||
gdkrgb.obj \
|
||||
gdkrgb16.obj \
|
||||
gdkrgbsimd.obj \
|
||||
gdkscreen.obj \
|
||||
gdkselection.obj \
|
||||
gdkvisual.obj \
|
||||
|
|
|
|||
|
|
@ -14,26 +14,27 @@ print <<EOF;
|
|||
|
||||
#include <glib.h>
|
||||
|
||||
#if defined(G_HAVE_GNUC_VISIBILITY) && !defined(__APPLE__)
|
||||
#if defined(G_HAVE_GNUC_VISIBILITY) && !defined(__APPLE__) && !defined(G_OS_WIN32)
|
||||
|
||||
EOF
|
||||
|
||||
if ($do_def) {
|
||||
print <<EOF
|
||||
#undef IN_FILE
|
||||
#define IN_FILE defined
|
||||
# The sections of the .symbols file become plain tests here: a macro
|
||||
# that expands to "defined" is undefined behaviour, which clang warns of.
|
||||
# Aliases (the -def file) are made for the file being compiled, the
|
||||
# renaming (the header) for the headers it included.
|
||||
sub section_test {
|
||||
my ($line) = @_;
|
||||
|
||||
#undef IN_HEADER
|
||||
#define IN_HEADER(x) 1
|
||||
if ($do_def) {
|
||||
$line =~ s/IN_FILE\(([^)]*)\)/defined($1)/g;
|
||||
$line =~ s/IN_HEADER\([^)]*\)/1/g;
|
||||
}
|
||||
else {
|
||||
$line =~ s/IN_FILE\([^)]*\)/1/g;
|
||||
$line =~ s/IN_HEADER\(([^)]*)\)/defined($1)/g;
|
||||
}
|
||||
|
||||
EOF
|
||||
}
|
||||
else {
|
||||
print <<EOF
|
||||
#define IN_FILE(x) 1
|
||||
#define IN_HEADER defined
|
||||
|
||||
EOF
|
||||
return $line;
|
||||
}
|
||||
|
||||
my $in_comment = 0;
|
||||
|
|
@ -92,7 +93,7 @@ while (<>) {
|
|||
|
||||
if ($_ =~ /^\#if.*(IN_FILE|IN_HEADER)/)
|
||||
{
|
||||
print $_;
|
||||
print section_test ($_);
|
||||
|
||||
next;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,9 @@
|
|||
if ((self = [super initWithFrame: frameRect]))
|
||||
{
|
||||
markedRange = NSMakeRange (NSNotFound, 0);
|
||||
selectedRange = NSMakeRange (NSNotFound, 0);
|
||||
/* the caret, not NSNotFound: without a location, macOS shows no
|
||||
* window of accented characters when a key is held down */
|
||||
selectedRange = NSMakeRange (0, 0);
|
||||
}
|
||||
|
||||
return self;
|
||||
|
|
@ -59,6 +61,14 @@
|
|||
-(void) keyDown: (NSEvent *) theEvent
|
||||
{
|
||||
GDK_NOTE (EVENTS, g_print ("keyDown\n"));
|
||||
|
||||
/* A key held down for the window of accented characters (10.7 and
|
||||
* later) calls none of the methods below while it repeats: the key is
|
||||
* the input method's then. Any text, marked text or command clears
|
||||
* or replaces this. */
|
||||
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
||||
GUINT_TO_POINTER (GIC_FILTER_FILTERED));
|
||||
|
||||
[self interpretKeyEvents: [NSArray arrayWithObject: theEvent]];
|
||||
}
|
||||
|
||||
|
|
@ -126,7 +136,8 @@
|
|||
{
|
||||
GDK_NOTE (EVENTS, g_print ("unmarkText\n"));
|
||||
gchar *prev_str;
|
||||
markedRange = selectedRange = NSMakeRange (NSNotFound, 0);
|
||||
selectedRange = NSMakeRange (0, 0);
|
||||
markedRange = NSMakeRange (NSNotFound, 0);
|
||||
|
||||
prev_str = g_object_get_data (G_OBJECT (gdk_window), TIC_MARKED_TEXT);
|
||||
if (prev_str)
|
||||
|
|
@ -184,11 +195,21 @@
|
|||
GDK_NOTE (EVENTS, g_print ("doCommandBySelector\n"));
|
||||
if ([self respondsToSelector: aSelector])
|
||||
[self performSelector: aSelector];
|
||||
|
||||
/* whatever the command, GTK+ handles the key itself (as in GTK+ 3.24) */
|
||||
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
||||
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
||||
}
|
||||
|
||||
/* This gets called on OS X 10.6 and upwards from interpretKeyEvents */
|
||||
-(void)insertText: (id)aString replacementRange: (NSRange)replacementRange
|
||||
{
|
||||
/* the window of accented characters replaces the character typed
|
||||
* before it: the input method deletes it around the cursor */
|
||||
if (replacementRange.location != NSNotFound && replacementRange.length > 0)
|
||||
g_object_set_data (G_OBJECT (gdk_window), TIC_INSERT_TEXT_REPLACE_LEN,
|
||||
GINT_TO_POINTER (replacementRange.length));
|
||||
|
||||
[self insertText:aString];
|
||||
}
|
||||
|
||||
|
|
@ -223,6 +244,7 @@
|
|||
else
|
||||
{
|
||||
str = [string UTF8String];
|
||||
selectedRange = NSMakeRange ([string length], 0);
|
||||
}
|
||||
|
||||
prev_str = g_object_get_data (G_OBJECT (gdk_window), TIC_INSERT_TEXT);
|
||||
|
|
@ -530,6 +552,20 @@
|
|||
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
||||
}
|
||||
|
||||
-(void)scrollPageDown: (id)sender
|
||||
{
|
||||
GDK_NOTE (EVENTS, g_message ("scrollPageDown"));
|
||||
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
||||
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
||||
}
|
||||
|
||||
-(void)scrollPageUp: (id)sender
|
||||
{
|
||||
GDK_NOTE (EVENTS, g_message ("scrollPageUp"));
|
||||
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
||||
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
||||
}
|
||||
|
||||
-(void)selectAll: (id)sender
|
||||
{
|
||||
GDK_NOTE (EVENTS, g_print ("selectAll\n"));
|
||||
|
|
@ -618,6 +654,45 @@
|
|||
[super viewWillDraw];
|
||||
}
|
||||
|
||||
/* What AppKit invalidates goes into GDK's bookkeeping too, so that
|
||||
* drawRect: knows all of it (see _gdk_quartz_use_gdk_invalidation()) */
|
||||
-(void)noteNeedsDisplayInRect: (NSRect)rect
|
||||
{
|
||||
GdkWindowImplQuartz *impl;
|
||||
GdkRectangle gdk_rect;
|
||||
NSRect bounds = [self bounds];
|
||||
|
||||
if (!gdk_window || GDK_WINDOW_DESTROYED (gdk_window) ||
|
||||
!_gdk_quartz_use_gdk_invalidation ())
|
||||
return;
|
||||
|
||||
impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (gdk_window)->impl);
|
||||
rect = NSIntersectionRect (rect, bounds);
|
||||
if (NSIsEmptyRect (rect))
|
||||
return;
|
||||
|
||||
gdk_rect.x = floor (rect.origin.x);
|
||||
gdk_rect.y = floor (rect.origin.y);
|
||||
gdk_rect.width = ceil (rect.origin.x + rect.size.width) - gdk_rect.x;
|
||||
gdk_rect.height = ceil (rect.origin.y + rect.size.height) - gdk_rect.y;
|
||||
if (!impl->needs_display_region)
|
||||
impl->needs_display_region = gdk_region_new ();
|
||||
gdk_region_union_with_rect (impl->needs_display_region, &gdk_rect);
|
||||
}
|
||||
|
||||
-(void)setNeedsDisplayInRect: (NSRect)rect
|
||||
{
|
||||
[self noteNeedsDisplayInRect: rect];
|
||||
[super setNeedsDisplayInRect: rect];
|
||||
}
|
||||
|
||||
-(void)setNeedsDisplay: (BOOL)flag
|
||||
{
|
||||
if (flag)
|
||||
[self noteNeedsDisplayInRect: [self bounds]];
|
||||
[super setNeedsDisplay: flag];
|
||||
}
|
||||
|
||||
-(void)drawRect: (NSRect)rect
|
||||
{
|
||||
GdkRectangle gdk_rect;
|
||||
|
|
@ -626,7 +701,7 @@
|
|||
const NSRect *drawn_rects;
|
||||
NSInteger count;
|
||||
int i;
|
||||
GdkRegion *region;
|
||||
GdkRegion *region, *needs;
|
||||
|
||||
if (GDK_WINDOW_DESTROYED (gdk_window))
|
||||
return;
|
||||
|
|
@ -648,7 +723,13 @@
|
|||
*/
|
||||
[NSGraphicsContext saveGraphicsState];
|
||||
|
||||
[[NSColor windowBackgroundColor] setFill];
|
||||
if (impl->background_color_set)
|
||||
[[NSColor colorWithCalibratedRed: impl->background_color.red / 65535.0
|
||||
green: impl->background_color.green / 65535.0
|
||||
blue: impl->background_color.blue / 65535.0
|
||||
alpha: 1.0] setFill];
|
||||
else
|
||||
[[NSColor windowBackgroundColor] setFill];
|
||||
[NSBezierPath fillRect: rect];
|
||||
|
||||
[NSGraphicsContext restoreGraphicsState];
|
||||
|
|
@ -656,25 +737,49 @@
|
|||
return;
|
||||
}
|
||||
|
||||
/* Clear our own bookkeeping of regions that need display */
|
||||
if (impl->needs_display_region)
|
||||
/* Our own bookkeeping of what needs display; taken here, as an
|
||||
* expose may invalidate again */
|
||||
needs = impl->needs_display_region;
|
||||
impl->needs_display_region = NULL;
|
||||
|
||||
if (needs && _gdk_quartz_use_gdk_invalidation () &&
|
||||
!NSContainsRect (rect, [self bounds]))
|
||||
{
|
||||
gdk_region_destroy (impl->needs_display_region);
|
||||
impl->needs_display_region = NULL;
|
||||
/* Layer-backed views (10.14 and newer) merge the invalidated
|
||||
* rects into one, or give the whole view: the windows of two
|
||||
* small meters in opposite corners would expose all between.
|
||||
* What GDK and AppKit invalidated is known here exactly (from
|
||||
* Ardour's YTK). */
|
||||
GdkRegion *drawing;
|
||||
|
||||
gdk_rect.x = rect.origin.x;
|
||||
gdk_rect.y = rect.origin.y;
|
||||
gdk_rect.width = rect.size.width;
|
||||
gdk_rect.height = rect.size.height;
|
||||
drawing = gdk_region_rectangle (&gdk_rect);
|
||||
region = needs;
|
||||
needs = NULL;
|
||||
gdk_region_intersect (region, drawing);
|
||||
gdk_region_destroy (drawing);
|
||||
}
|
||||
else
|
||||
{
|
||||
[self getRectsBeingDrawn: &drawn_rects count: &count];
|
||||
region = gdk_region_new ();
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
gdk_rect.x = drawn_rects[i].origin.x;
|
||||
gdk_rect.y = drawn_rects[i].origin.y;
|
||||
gdk_rect.width = drawn_rects[i].size.width;
|
||||
gdk_rect.height = drawn_rects[i].size.height;
|
||||
|
||||
gdk_region_union_with_rect (region, &gdk_rect);
|
||||
}
|
||||
}
|
||||
|
||||
[self getRectsBeingDrawn: &drawn_rects count: &count];
|
||||
region = gdk_region_new ();
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
gdk_rect.x = drawn_rects[i].origin.x;
|
||||
gdk_rect.y = drawn_rects[i].origin.y;
|
||||
gdk_rect.width = drawn_rects[i].size.width;
|
||||
gdk_rect.height = drawn_rects[i].size.height;
|
||||
|
||||
gdk_region_union_with_rect (region, &gdk_rect);
|
||||
}
|
||||
if (needs)
|
||||
gdk_region_destroy (needs);
|
||||
|
||||
impl->in_paint_rect_count++;
|
||||
_gdk_window_process_updates_recurse (gdk_window, region);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#define TIC_SELECTED_POS "tic-selected-pos"
|
||||
#define TIC_SELECTED_LEN "tic-selected-len"
|
||||
#define TIC_INSERT_TEXT "tic-insert-text"
|
||||
#define TIC_INSERT_TEXT_REPLACE_LEN "tic-insert-text-replace-len"
|
||||
#define TIC_IN_KEY_DOWN "tic-in-key-down"
|
||||
|
||||
/* GtkIMContext */
|
||||
|
|
|
|||
|
|
@ -69,6 +69,9 @@
|
|||
_gdk_quartz_window_attach_to_parent (window);
|
||||
|
||||
gdk_synthesize_window_state (window, GDK_WINDOW_STATE_ICONIFIED, 0);
|
||||
|
||||
/* newer systems may come back with stale contents (Ardour) */
|
||||
[[self contentView] setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
-(void)windowDidBecomeKey:(NSNotification *)aNotification
|
||||
|
|
@ -429,9 +432,13 @@
|
|||
return YES;
|
||||
}
|
||||
|
||||
-(BOOL)isInManualResize
|
||||
/* Used by gdkevents-quartz.c to decide if our sendEvent() handler above
|
||||
* will see the event or if it will be subjected to standard processing
|
||||
* by GDK.
|
||||
*/
|
||||
-(BOOL)isInManualResizeOrMove
|
||||
{
|
||||
return inManualResize;
|
||||
return inManualResize || inManualMove;
|
||||
}
|
||||
|
||||
-(void)beginManualResize
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
-(BOOL)isInMove;
|
||||
-(void)beginManualMove;
|
||||
-(BOOL)trackManualMove;
|
||||
-(BOOL)isInManualResize;
|
||||
-(BOOL)isInManualResizeOrMove;
|
||||
-(void)beginManualResize;
|
||||
-(BOOL)trackManualResize;
|
||||
-(void)showAndMakeKey:(BOOL)makeKey;
|
||||
|
|
|
|||
|
|
@ -79,6 +79,11 @@ _gdk_windowing_create_cairo_surface (GdkDrawable *drawable,
|
|||
surface_data,
|
||||
gdk_quartz_cairo_surface_destroy);
|
||||
|
||||
/* HiDPI: AppKit puts the points on the pixels of a Retina screen;
|
||||
* pixbufs with a picture of those pixels use it */
|
||||
if (cg_context && GDK_IS_WINDOW_IMPL_QUARTZ (drawable))
|
||||
_gdk_cairo_surface_set_hidpi_scale (surface, _gdk_windowing_drawable_get_scale (drawable));
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +105,13 @@ gdk_quartz_ref_cairo_surface (GdkDrawable *drawable)
|
|||
width, height);
|
||||
}
|
||||
else
|
||||
cairo_surface_reference (impl->cairo_surface);
|
||||
{
|
||||
cairo_surface_reference (impl->cairo_surface);
|
||||
/* HiDPI: the window may be on a screen of another scale by now */
|
||||
if (GDK_IS_WINDOW_IMPL_QUARTZ (drawable))
|
||||
_gdk_cairo_surface_set_hidpi_scale (impl->cairo_surface,
|
||||
_gdk_windowing_drawable_get_scale (drawable));
|
||||
}
|
||||
|
||||
return impl->cairo_surface;
|
||||
}
|
||||
|
|
@ -652,21 +663,34 @@ gdk_quartz_draw_pixbuf (GdkDrawable *drawable,
|
|||
void *data;
|
||||
int rowstride, pixbuf_width, pixbuf_height;
|
||||
gboolean has_alpha;
|
||||
GdkPixbuf *picture = pixbuf;
|
||||
|
||||
if (!context)
|
||||
return;
|
||||
|
||||
pixbuf_width = gdk_pixbuf_get_width (pixbuf);
|
||||
pixbuf_height = gdk_pixbuf_get_height (pixbuf);
|
||||
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
|
||||
has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
|
||||
|
||||
data = gdk_pixbuf_get_pixels (pixbuf);
|
||||
/* HiDPI: on a Retina screen the picture made for it, drawn into the
|
||||
* same points */
|
||||
if (GDK_IS_WINDOW_IMPL_QUARTZ (drawable))
|
||||
{
|
||||
GdkPixbuf *hires = _gdk_pixbuf_get_hires (pixbuf, _gdk_windowing_drawable_get_scale (drawable));
|
||||
|
||||
if (hires)
|
||||
picture = hires;
|
||||
}
|
||||
|
||||
rowstride = gdk_pixbuf_get_rowstride (picture);
|
||||
has_alpha = gdk_pixbuf_get_has_alpha (picture);
|
||||
|
||||
data = gdk_pixbuf_get_pixels (picture);
|
||||
|
||||
colorspace = CGColorSpaceCreateDeviceRGB ();
|
||||
data_provider = CGDataProviderCreateWithData (NULL, data, pixbuf_height * rowstride, NULL);
|
||||
data_provider = CGDataProviderCreateWithData (NULL, data,
|
||||
gdk_pixbuf_get_height (picture) * rowstride, NULL);
|
||||
|
||||
image = CGImageCreate (pixbuf_width, pixbuf_height, 8,
|
||||
image = CGImageCreate (gdk_pixbuf_get_width (picture), gdk_pixbuf_get_height (picture), 8,
|
||||
has_alpha ? 32 : 24, rowstride,
|
||||
colorspace,
|
||||
has_alpha ? kCGImageAlphaLast : 0,
|
||||
|
|
@ -844,14 +868,16 @@ gdk_quartz_drawable_get_context (GdkDrawable *drawable,
|
|||
void
|
||||
_gdk_quartz_drawable_flush (GdkDrawable *drawable)
|
||||
{
|
||||
static struct timeval prev_tv;
|
||||
/* intervals on the monotonic clock: setting the clock, or a 32-bit
|
||||
* time_t after 2038, does not stop the flushing */
|
||||
static gint64 prev_time;
|
||||
static gint intervals[4];
|
||||
static gint index;
|
||||
struct timeval tv;
|
||||
gint64 now;
|
||||
gint ms;
|
||||
|
||||
gettimeofday (&tv, NULL);
|
||||
ms = (tv.tv_sec - prev_tv.tv_sec) * 1000 + (tv.tv_usec - prev_tv.tv_usec) / 1000;
|
||||
now = g_get_monotonic_time ();
|
||||
ms = (gint) MIN ((now - prev_time) / 1000, G_MAXINT / 8);
|
||||
intervals[index++ % 4] = ms;
|
||||
|
||||
if (drawable)
|
||||
|
|
@ -868,11 +894,11 @@ _gdk_quartz_drawable_flush (GdkDrawable *drawable)
|
|||
[window_impl->toplevel flushWindow];
|
||||
}
|
||||
|
||||
prev_tv = tv;
|
||||
prev_time = now;
|
||||
}
|
||||
}
|
||||
else
|
||||
prev_tv = tv;
|
||||
prev_time = now;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#include <sys/sysctl.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#include <Carbon/Carbon.h>
|
||||
|
|
@ -225,6 +226,19 @@ _gdk_quartz_events_break_all_grabs (guint32 time)
|
|||
_gdk_display_pointer_grab_update (_gdk_display, 0);
|
||||
}
|
||||
|
||||
|
||||
/* The touchpad gestures of Mac OS X 10.5.2 and later: a pinch
|
||||
* (magnify) and a swipe with three fingers. Older SDKs do not know
|
||||
* them; Mac OS X before 10.5.2 never sends them. */
|
||||
#define GDK_QUARTZ_EVENT_MAGNIFY 30
|
||||
#define GDK_QUARTZ_EVENT_SWIPE 31
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
|
||||
@interface NSEvent (GdkTouchpadGestures)
|
||||
- (CGFloat)magnification;
|
||||
@end
|
||||
#endif
|
||||
|
||||
static void
|
||||
fixup_event (GdkEvent *event)
|
||||
{
|
||||
|
|
@ -250,6 +264,12 @@ append_event (GdkEvent *event,
|
|||
_gdk_windowing_got_event (_gdk_display, node, event, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
append_scroll_event (GdkEvent *event)
|
||||
{
|
||||
append_event (event, TRUE);
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_event_apply_filters (NSEvent *nsevent,
|
||||
GdkEvent *event,
|
||||
|
|
@ -400,11 +420,14 @@ get_event_mask_from_ns_event (NSEvent *nsevent)
|
|||
case NSMouseMoved:
|
||||
return GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK;
|
||||
case NSScrollWheel:
|
||||
case GDK_QUARTZ_EVENT_MAGNIFY: /* scroll steps with Ctrl */
|
||||
/* Since applications that want button press events can get
|
||||
* scroll events on X11 (since scroll wheel events are really
|
||||
* button press events there), we need to use GDK_BUTTON_PRESS_MASK too.
|
||||
*/
|
||||
return GDK_SCROLL_MASK | GDK_BUTTON_PRESS_MASK;
|
||||
case GDK_QUARTZ_EVENT_SWIPE: /* the back and forward buttons */
|
||||
return GDK_BUTTON_PRESS_MASK;
|
||||
case NSLeftMouseDragged:
|
||||
return (GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
|
||||
GDK_BUTTON_MOTION_MASK | GDK_BUTTON1_MOTION_MASK |
|
||||
|
|
@ -545,6 +568,29 @@ get_toplevel_from_ns_event (NSEvent *nsevent,
|
|||
* here, not very nice.
|
||||
*/
|
||||
_gdk_quartz_events_break_all_grabs (get_time_from_ns_event (nsevent));
|
||||
|
||||
/* Check if the event occurred on the titlebar. If it did,
|
||||
* explicitly return NULL to prevent going through the
|
||||
* fallback path, which could match the window that is
|
||||
* directly under the titlebar.
|
||||
*/
|
||||
if (view_point.y < 0 &&
|
||||
view_point.x >= view_frame.origin.x &&
|
||||
view_point.x < view_frame.origin.x + view_frame.size.width)
|
||||
{
|
||||
NSView *superview = [view superview];
|
||||
if (superview)
|
||||
{
|
||||
NSRect superview_frame = [superview frame];
|
||||
int titlebar_height = superview_frame.size.height -
|
||||
view_frame.size.height;
|
||||
|
||||
if (titlebar_height > 0 && view_point.y >= -titlebar_height)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -714,6 +760,48 @@ find_toplevel_under_pointer (GdkDisplay *display,
|
|||
/* This function finds the correct window to send an event to, taking
|
||||
* into account grabs, event propagation, and event masks.
|
||||
*/
|
||||
/* A native view of the program inside a GDK window (a plugin's interface,
|
||||
* video, a web view) that took a mouse button; the pointer events stay
|
||||
* with Cocoa until the button is up (from Ardour's YTK) */
|
||||
static NSView *foreign_mouse_down_view;
|
||||
|
||||
/* whether the pointer is over a view of the program's own, not GDK's,
|
||||
* inside @toplevel; a press there keeps the following events for it */
|
||||
static gboolean
|
||||
pointer_on_foreign_view (NSEvent *nsevent,
|
||||
GdkWindow *toplevel)
|
||||
{
|
||||
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (toplevel)->impl);
|
||||
NSView *content, *hit;
|
||||
NSPoint point;
|
||||
|
||||
if (!impl || !impl->view || [nsevent window] != impl->toplevel)
|
||||
return FALSE;
|
||||
|
||||
content = impl->view;
|
||||
if ([[content subviews] count] == 0)
|
||||
return FALSE;
|
||||
|
||||
point = [nsevent locationInWindow];
|
||||
if ([content superview])
|
||||
point = [[content superview] convertPoint:point fromView:nil];
|
||||
hit = [content hitTest:point];
|
||||
if (hit == nil || [hit isKindOfClass:[GdkQuartzView class]])
|
||||
return FALSE;
|
||||
|
||||
switch ([nsevent type])
|
||||
{
|
||||
case NSLeftMouseDown:
|
||||
case NSRightMouseDown:
|
||||
case NSOtherMouseDown:
|
||||
foreign_mouse_down_view = hit;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GdkWindow *
|
||||
find_window_for_ns_event (NSEvent *nsevent,
|
||||
gint *x,
|
||||
|
|
@ -745,6 +833,8 @@ find_window_for_ns_event (NSEvent *nsevent,
|
|||
case NSOtherMouseUp:
|
||||
case NSMouseMoved:
|
||||
case NSScrollWheel:
|
||||
case GDK_QUARTZ_EVENT_MAGNIFY:
|
||||
case GDK_QUARTZ_EVENT_SWIPE:
|
||||
case NSLeftMouseDragged:
|
||||
case NSRightMouseDragged:
|
||||
case NSOtherMouseDragged:
|
||||
|
|
@ -752,6 +842,14 @@ find_window_for_ns_event (NSEvent *nsevent,
|
|||
GdkDisplay *display;
|
||||
GdkPointerGrabInfo *grab;
|
||||
|
||||
if (foreign_mouse_down_view)
|
||||
{
|
||||
if (event_type == NSLeftMouseUp || event_type == NSRightMouseUp ||
|
||||
event_type == NSOtherMouseUp)
|
||||
foreign_mouse_down_view = nil;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
display = gdk_drawable_get_display (toplevel);
|
||||
|
||||
/* From the docs for XGrabPointer:
|
||||
|
|
@ -845,6 +943,9 @@ find_window_for_ns_event (NSEvent *nsevent,
|
|||
*y = y_tmp;
|
||||
}
|
||||
|
||||
if (pointer_on_foreign_view (nsevent, toplevel))
|
||||
return NULL;
|
||||
|
||||
return toplevel;
|
||||
}
|
||||
}
|
||||
|
|
@ -857,8 +958,36 @@ find_window_for_ns_event (NSEvent *nsevent,
|
|||
*/
|
||||
if ([view trackingRect] == [nsevent trackingNumber])
|
||||
return toplevel;
|
||||
else
|
||||
return NULL;
|
||||
|
||||
/* macOS 13 no longer sends the events of the tracking rect, but
|
||||
* those of the cursor rects, which earlier ones were left out:
|
||||
* they come 4 pixels outside the frame of the window (the same
|
||||
* fix as GTK+ 3 and Ardour's YTK) */
|
||||
if (gdk_quartz_osx_version () >= GDK_OSX_VENTURA &&
|
||||
(![nsevent respondsToSelector:@selector(trackingArea)] ||
|
||||
[(id) nsevent trackingArea] == nil))
|
||||
{
|
||||
const CGFloat border_width = 4;
|
||||
NSRect frame = [[nsevent window] frame];
|
||||
gboolean inside, at_edge;
|
||||
|
||||
frame.origin.x -= border_width;
|
||||
frame.origin.y -= border_width;
|
||||
frame.size.width += 2 * border_width;
|
||||
frame.size.height += 2 * border_width;
|
||||
inside = (screen_point.x >= frame.origin.x &&
|
||||
screen_point.x <= frame.origin.x + frame.size.width &&
|
||||
screen_point.y >= frame.origin.y &&
|
||||
screen_point.y <= frame.origin.y + frame.size.height);
|
||||
at_edge = (screen_point.x >= frame.origin.x - 1 &&
|
||||
screen_point.x <= frame.origin.x + frame.size.width + 1 &&
|
||||
screen_point.y >= frame.origin.y - 1 &&
|
||||
screen_point.y <= frame.origin.y + frame.size.height + 1);
|
||||
|
||||
if ((event_type == NSMouseEntered && inside) || at_edge)
|
||||
return toplevel;
|
||||
}
|
||||
return NULL;
|
||||
|
||||
case NSKeyDown:
|
||||
case NSKeyUp:
|
||||
|
|
@ -1004,6 +1133,72 @@ fill_scroll_event (GdkWindow *window,
|
|||
event->scroll.device = _gdk_display->core_pointer;
|
||||
}
|
||||
|
||||
/* A pinch becomes scroll steps with Ctrl and a swipe the back or
|
||||
* forward button, for programs that know nothing of gestures
|
||||
* (gdkevents.c); the first event goes into @event */
|
||||
static gboolean
|
||||
touchpad_gesture_event (GdkWindow *window,
|
||||
GdkEvent *event,
|
||||
NSEvent *nsevent,
|
||||
gint x,
|
||||
gint y,
|
||||
gint x_root,
|
||||
gint y_root)
|
||||
{
|
||||
static gdouble pinch_rest;
|
||||
static NSTimeInterval pinch_time;
|
||||
GdkEvent template_event;
|
||||
GList *events, *l;
|
||||
|
||||
memset (&template_event, 0, sizeof template_event);
|
||||
fill_scroll_event (window, &template_event, nsevent, x, y, x_root, y_root, GDK_SCROLL_UP);
|
||||
|
||||
if ([nsevent type] == GDK_QUARTZ_EVENT_MAGNIFY)
|
||||
{
|
||||
CGFloat magnification;
|
||||
|
||||
if (![nsevent respondsToSelector:@selector(magnification)])
|
||||
return FALSE;
|
||||
|
||||
magnification = [nsevent magnification];
|
||||
if (magnification <= -1)
|
||||
return FALSE;
|
||||
|
||||
/* a pause starts a new pinch */
|
||||
if ([nsevent timestamp] - pinch_time > 0.3)
|
||||
pinch_rest = 0;
|
||||
pinch_time = [nsevent timestamp];
|
||||
|
||||
events = _gdk_event_touchpad_pinch (&template_event, log1p (magnification), &pinch_rest);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* deltaX is 1 for a swipe to the left: forward, as on X11 */
|
||||
events = _gdk_event_touchpad_swipe (&template_event, - [nsevent deltaX]);
|
||||
}
|
||||
|
||||
if (!events)
|
||||
return FALSE;
|
||||
|
||||
/* the first one is @event, the window of which gets its reference
|
||||
* from the caller */
|
||||
*event = *(GdkEvent *) events->data;
|
||||
((GdkEventPrivate *) event)->flags |= GDK_EVENT_TOUCHPAD_EMULATED;
|
||||
gdk_event_free (events->data);
|
||||
|
||||
for (l = events->next; l; l = l->next)
|
||||
{
|
||||
GdkEvent *other = l->data;
|
||||
|
||||
/* append_event() takes a reference of its own */
|
||||
g_object_unref (other->any.window);
|
||||
append_event (other, TRUE);
|
||||
}
|
||||
g_list_free (events);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
fill_key_event (GdkWindow *window,
|
||||
GdkEvent *event,
|
||||
|
|
@ -1387,10 +1582,10 @@ gdk_event_translate (GdkEvent *event,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/* Also when in a manual resize, we ignore events so that these are
|
||||
* pushed to GdkQuartzWindow's sendEvent handler.
|
||||
/* Also when in a manual resize or move, we ignore events so that
|
||||
* these are pushed to GdkQuartzWindow's sendEvent handler.
|
||||
*/
|
||||
if ([(GdkQuartzWindow *)nswindow isInManualResize])
|
||||
if ([(GdkQuartzWindow *)nswindow isInManualResizeOrMove])
|
||||
return FALSE;
|
||||
|
||||
/* Find the right GDK window to send the event to, taking grabs and
|
||||
|
|
@ -1489,32 +1684,46 @@ gdk_event_translate (GdkEvent *event,
|
|||
|
||||
case NSScrollWheel:
|
||||
{
|
||||
float dx = [nsevent deltaX];
|
||||
float dy = [nsevent deltaY];
|
||||
GdkScrollDirection direction;
|
||||
/* Trackpads and the Magic Mouse tell how far to scroll in
|
||||
* pixels, as GTK+ 3 takes them, and in lines, which make up
|
||||
* whole steps of the wheel; a plain wheel just turns, a step
|
||||
* each time, as before */
|
||||
static gdouble rest[2];
|
||||
GdkEvent scroll;
|
||||
gdouble dx = [nsevent deltaX];
|
||||
gdouble dy = [nsevent deltaY];
|
||||
gdouble px = 0, py = 0;
|
||||
gboolean precise = FALSE;
|
||||
|
||||
if (dy != 0)
|
||||
/* from 10.7; older SDKs do not know these */
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
||||
precise = [nsevent respondsToSelector:@selector(hasPreciseScrollingDeltas)] &&
|
||||
[nsevent hasPreciseScrollingDeltas];
|
||||
if (precise)
|
||||
{
|
||||
if (dy < 0.0)
|
||||
direction = GDK_SCROLL_DOWN;
|
||||
else
|
||||
direction = GDK_SCROLL_UP;
|
||||
|
||||
fill_scroll_event (window, event, nsevent, x, y, x_root, y_root, direction);
|
||||
px = - [nsevent scrollingDeltaX];
|
||||
py = - [nsevent scrollingDeltaY];
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
dx = dx > 0 ? 1 : dx < 0 ? -1 : 0;
|
||||
dy = dy > 0 ? 1 : dy < 0 ? -1 : 0;
|
||||
rest[0] = rest[1] = 0;
|
||||
}
|
||||
|
||||
if (dx != 0)
|
||||
{
|
||||
if (dx < 0.0)
|
||||
direction = GDK_SCROLL_RIGHT;
|
||||
else
|
||||
direction = GDK_SCROLL_LEFT;
|
||||
|
||||
fill_scroll_event (window, event, nsevent, x, y, x_root, y_root, direction);
|
||||
}
|
||||
memset (&scroll, 0, sizeof scroll);
|
||||
fill_scroll_event (window, &scroll, nsevent, x, y, x_root, y_root, GDK_SCROLL_SMOOTH);
|
||||
_gdk_event_emit_scroll (event, &scroll, precise, px, py, - dx, - dy, rest,
|
||||
append_scroll_event);
|
||||
}
|
||||
break;
|
||||
|
||||
case GDK_QUARTZ_EVENT_MAGNIFY:
|
||||
case GDK_QUARTZ_EVENT_SWIPE:
|
||||
return_val = touchpad_gesture_event (window, event, nsevent, x, y, x_root, y_root);
|
||||
break;
|
||||
|
||||
case NSMouseExited:
|
||||
if (WINDOW_IS_TOPLEVEL (window))
|
||||
[[NSCursor arrowCursor] set];
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@
|
|||
#include "gdktypes.h"
|
||||
#include "gdkprivate.h"
|
||||
#include "gdkquartz.h"
|
||||
#include "gdkprivate-quartz.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
GdkDisplay *_gdk_display = NULL;
|
||||
GdkScreen *_gdk_screen = NULL;
|
||||
|
|
@ -57,3 +59,43 @@ gdk_quartz_osx_version (void)
|
|||
else
|
||||
return minor;
|
||||
}
|
||||
|
||||
/* -1: not set, GDK_QUARTZ_COCOA_INVALIDATION or the version decide */
|
||||
static gint use_cocoa_invalidation = -1;
|
||||
|
||||
/**
|
||||
* gdk_quartz_set_use_cocoa_invalidation:
|
||||
* @use: %TRUE to expose what AppKit says is being drawn
|
||||
*
|
||||
* From macOS 10.14 GDK exposes exactly what it and AppKit invalidated,
|
||||
* not the merged rectangles of the layer-backed views; %TRUE goes back
|
||||
* to those (as in Ardour's YTK). The environment variable
|
||||
* GDK_QUARTZ_COCOA_INVALIDATION=1 does the same.
|
||||
*/
|
||||
void
|
||||
gdk_quartz_set_use_cocoa_invalidation (gboolean use)
|
||||
{
|
||||
use_cocoa_invalidation = use != FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_quartz_get_use_cocoa_invalidation (void)
|
||||
{
|
||||
return !_gdk_quartz_use_gdk_invalidation ();
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gdk_quartz_use_gdk_invalidation (void)
|
||||
{
|
||||
if (use_cocoa_invalidation < 0)
|
||||
{
|
||||
const gchar *env = g_getenv ("GDK_QUARTZ_COCOA_INVALIDATION");
|
||||
|
||||
if (env && *env)
|
||||
use_cocoa_invalidation = atoi (env) != 0;
|
||||
else
|
||||
use_cocoa_invalidation = gdk_quartz_osx_version () < GDK_OSX_MOJAVE;
|
||||
}
|
||||
|
||||
return !use_cocoa_invalidation;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,9 +145,19 @@ _gdk_quartz_image_copy_to_image (GdkDrawable *drawable,
|
|||
|
||||
if (GDK_WINDOW_IMPL_QUARTZ (drawable) == GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (_gdk_root)->impl))
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050
|
||||
/* the screen cannot be read before 10.5 (CGWindowListCreateImage) */
|
||||
return image;
|
||||
#else
|
||||
/* Special case for the root window. */
|
||||
CGRect rect = CGRectMake (src_x, src_y, width, height);
|
||||
CGImageRef root_image_ref = CGWindowListCreateImage (rect,
|
||||
CGImageRef root_image_ref;
|
||||
|
||||
/* weakly linked where 10.4 is the oldest system */
|
||||
if (CGWindowListCreateImage == NULL)
|
||||
return image;
|
||||
|
||||
root_image_ref = CGWindowListCreateImage (rect,
|
||||
kCGWindowListOptionOnScreenOnly,
|
||||
kCGNullWindowID,
|
||||
kCGWindowImageDefault);
|
||||
|
|
@ -170,6 +180,7 @@ _gdk_quartz_image_copy_to_image (GdkDrawable *drawable,
|
|||
|
||||
rep = [[NSBitmapImageRep alloc] initWithCGImage: root_image_ref];
|
||||
CGImageRelease (root_image_ref);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -470,7 +470,8 @@ update_keymap (void)
|
|||
p[0] = known_numeric_keys[i].keypad_keyval;
|
||||
}
|
||||
|
||||
g_signal_emit_by_name (default_keymap, "keys-changed");
|
||||
if (default_keymap != NULL)
|
||||
g_signal_emit_by_name (default_keymap, "keys-changed");
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -696,7 +697,6 @@ gdk_keymap_translate_keyboard_state (GdkKeymap *keymap,
|
|||
{
|
||||
guint tmp_keyval;
|
||||
GdkModifierType bit;
|
||||
guint tmp_modifiers = 0;
|
||||
|
||||
g_return_val_if_fail (keymap == NULL || GDK_IS_KEYMAP (keymap), FALSE);
|
||||
g_return_val_if_fail (group >= 0 && group <= 1, FALSE);
|
||||
|
|
@ -716,24 +716,23 @@ gdk_keymap_translate_keyboard_state (GdkKeymap *keymap,
|
|||
if (hardware_keycode < 0 || hardware_keycode >= NUM_KEYCODES)
|
||||
return FALSE;
|
||||
|
||||
/* Check if modifiers modify the keyval */
|
||||
for (bit = GDK_SHIFT_MASK; bit < GDK_BUTTON1_MASK; bit <<= 1)
|
||||
{
|
||||
if (translate_keysym (hardware_keycode,
|
||||
(bit == GDK_MOD1_MASK) ? 0 : group,
|
||||
state & ~bit,
|
||||
NULL, NULL) !=
|
||||
translate_keysym (hardware_keycode,
|
||||
(bit == GDK_MOD1_MASK) ? 1 : group,
|
||||
state | bit,
|
||||
NULL, NULL))
|
||||
tmp_modifiers |= bit;
|
||||
}
|
||||
|
||||
tmp_keyval = translate_keysym (hardware_keycode, group, state, level, effective_group);
|
||||
|
||||
/* Check if modifiers modify the keyval */
|
||||
if (consumed_modifiers)
|
||||
*consumed_modifiers = tmp_modifiers;
|
||||
{
|
||||
guint tmp_modifiers = (state & GDK_MODIFIER_MASK);
|
||||
|
||||
for (bit = 1; bit <= tmp_modifiers; bit <<= 1)
|
||||
{
|
||||
if ((bit & tmp_modifiers) &&
|
||||
translate_keysym (hardware_keycode, group, state & ~bit,
|
||||
NULL, NULL) == tmp_keyval)
|
||||
tmp_modifiers &= ~bit;
|
||||
}
|
||||
|
||||
*consumed_modifiers = tmp_modifiers;
|
||||
}
|
||||
|
||||
if (keyval)
|
||||
*keyval = tmp_keyval;
|
||||
|
|
|
|||
|
|
@ -219,4 +219,6 @@ gboolean _gdk_quartz_window_queue_antiexpose (GdkWindow *window,
|
|||
/* Pixmap */
|
||||
CGImageRef _gdk_pixmap_get_cgimage (GdkPixmap *pixmap);
|
||||
|
||||
gboolean _gdk_quartz_use_gdk_invalidation (void);
|
||||
|
||||
#endif /* __GDK_PRIVATE_QUARTZ_H__ */
|
||||
|
|
|
|||
|
|
@ -71,6 +71,8 @@ NSImage *gdk_quartz_pixbuf_to_ns_image_libgtk_only (GdkPixbuf
|
|||
id gdk_quartz_drag_context_get_dragging_info_libgtk_only (GdkDragContext *context);
|
||||
NSEvent *gdk_quartz_event_get_nsevent (GdkEvent *event);
|
||||
GdkOSXVersion gdk_quartz_osx_version (void);
|
||||
void gdk_quartz_set_use_cocoa_invalidation (gboolean use);
|
||||
gboolean gdk_quartz_get_use_cocoa_invalidation (void);
|
||||
|
||||
GdkAtom gdk_quartz_pasteboard_type_to_atom_libgtk_only (NSString *type);
|
||||
NSString *gdk_quartz_target_to_pasteboard_type_libgtk_only (const gchar *target);
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@
|
|||
static void gdk_screen_quartz_dispose (GObject *object);
|
||||
static void gdk_screen_quartz_finalize (GObject *object);
|
||||
static void gdk_screen_quartz_calculate_layout (GdkScreenQuartz *screen);
|
||||
static CGFloat gdk_quartz_screen_user_space_scale (NSScreen *screen);
|
||||
|
||||
static void display_reconfiguration_callback (CGDirectDisplayID display,
|
||||
CGDisplayChangeSummaryFlags flags,
|
||||
|
|
@ -89,7 +90,7 @@ _gdk_screen_quartz_init (GdkScreenQuartz *screen_quartz)
|
|||
|
||||
nsscreen = [[NSScreen screens] objectAtIndex:0];
|
||||
gdk_screen_set_resolution (screen,
|
||||
72.0 * [nsscreen userSpaceScaleFactor]);
|
||||
72.0 * gdk_quartz_screen_user_space_scale (nsscreen));
|
||||
|
||||
gdk_screen_quartz_calculate_layout (screen_quartz);
|
||||
|
||||
|
|
@ -354,6 +355,17 @@ gdk_screen_get_height (GdkScreen *screen)
|
|||
return GDK_SCREEN_QUARTZ (screen)->height;
|
||||
}
|
||||
|
||||
/* -userSpaceScaleFactor is the scale of the resolution independence of
|
||||
* 10.4 to 10.6; newer systems no longer have the message, and sending
|
||||
* it there throws (as Ardour found) */
|
||||
static CGFloat
|
||||
gdk_quartz_screen_user_space_scale (NSScreen *screen)
|
||||
{
|
||||
if ([screen respondsToSelector:@selector(userSpaceScaleFactor)])
|
||||
return (CGFloat) [(id) screen userSpaceScaleFactor];
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
static gint
|
||||
get_mm_from_pixels (NSScreen *screen, int pixels)
|
||||
{
|
||||
|
|
@ -362,7 +374,7 @@ get_mm_from_pixels (NSScreen *screen, int pixels)
|
|||
* and 25.4 is the number of millimeters per inch.
|
||||
*/
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_3
|
||||
float dpi = [screen userSpaceScaleFactor] * 72.0;
|
||||
float dpi = gdk_quartz_screen_user_space_scale (screen) * 72.0;
|
||||
#else
|
||||
float dpi = 96.0 / 72.0;
|
||||
#endif
|
||||
|
|
@ -493,3 +505,58 @@ gdk_screen_is_composited (GdkScreen *screen)
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* HiDPI: AppKit already draws GDK's points in the pixels of Retina
|
||||
* screens (10.7 and later), sharp for paths and text; GDK coordinates
|
||||
* stay the points. These scales only let pictures of more pixels be
|
||||
* used (icons, see gdk_quartz_draw_pixbuf () and
|
||||
* gdk_cairo_set_source_pixbuf ()); pixmaps stay at one pixel per point. */
|
||||
static gint
|
||||
gdk_quartz_nsscreen_get_scale (NSScreen *nsscreen)
|
||||
{
|
||||
CGFloat scale = 1.0;
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
||||
if (nsscreen && [nsscreen respondsToSelector:@selector(backingScaleFactor)])
|
||||
scale = [nsscreen backingScaleFactor];
|
||||
#endif
|
||||
|
||||
return MAX ((gint) (scale + 0.5), 1);
|
||||
}
|
||||
|
||||
gint
|
||||
_gdk_windowing_drawable_get_scale (GdkDrawable *drawable)
|
||||
{
|
||||
CGFloat scale = 1.0;
|
||||
|
||||
if (GDK_IS_WINDOW (drawable))
|
||||
drawable = GDK_WINDOW_OBJECT (drawable)->impl;
|
||||
if (!GDK_IS_WINDOW_IMPL_QUARTZ (drawable))
|
||||
return 1;
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
||||
{
|
||||
GdkWindow *toplevel = gdk_window_get_toplevel (GDK_DRAWABLE_IMPL_QUARTZ (drawable)->wrapper);
|
||||
NSWindow *nswindow = toplevel ? GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (toplevel)->impl)->toplevel : nil;
|
||||
|
||||
if (nswindow && [nswindow respondsToSelector:@selector(backingScaleFactor)])
|
||||
scale = [nswindow backingScaleFactor];
|
||||
}
|
||||
#endif
|
||||
|
||||
return MAX ((gint) (scale + 0.5), 1);
|
||||
}
|
||||
|
||||
gint
|
||||
_gdk_windowing_screen_get_monitor_scale (GdkScreen *screen,
|
||||
gint monitor_num)
|
||||
{
|
||||
gint scale;
|
||||
|
||||
GDK_QUARTZ_ALLOC_POOL;
|
||||
scale = gdk_quartz_nsscreen_get_scale (get_nsscreen_for_monitor (monitor_num));
|
||||
GDK_QUARTZ_RELEASE_POOL;
|
||||
|
||||
return scale;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -207,6 +207,7 @@ gdk_window_impl_quartz_finalize (GObject *object)
|
|||
|
||||
if (impl->transient_for)
|
||||
g_object_unref (impl->transient_for);
|
||||
impl->transient_for = NULL;
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
|
@ -1130,7 +1131,13 @@ _gdk_windowing_update_window_sizes (GdkScreen *screen)
|
|||
windows = gdk_screen_get_toplevel_windows (screen);
|
||||
|
||||
for (list = windows; list; list = list->next)
|
||||
_gdk_quartz_window_update_position (list->data);
|
||||
{
|
||||
/* Offscreen windows have no NSWindow to take the position from */
|
||||
if (GDK_WINDOW_TYPE (list->data) == GDK_WINDOW_OFFSCREEN)
|
||||
continue;
|
||||
|
||||
_gdk_quartz_window_update_position (list->data);
|
||||
}
|
||||
|
||||
g_list_free (windows);
|
||||
}
|
||||
|
|
@ -1202,6 +1209,12 @@ _gdk_quartz_window_destroy (GdkWindow *window,
|
|||
else if (impl->view)
|
||||
[impl->view removeFromSuperview];
|
||||
|
||||
/* The window is released when closed (and with it its view), a
|
||||
* view removed from its superview is released; don't keep
|
||||
* dangling pointers to them. */
|
||||
impl->view = NULL;
|
||||
impl->toplevel = NULL;
|
||||
|
||||
GDK_QUARTZ_RELEASE_POOL;
|
||||
}
|
||||
}
|
||||
|
|
@ -1749,9 +1762,16 @@ static void
|
|||
gdk_window_quartz_set_background (GdkWindow *window,
|
||||
const GdkColor *color)
|
||||
{
|
||||
/* FIXME: We could theoretically set the background color for toplevels
|
||||
* here. (Currently we draw the background before emitting expose events)
|
||||
*/
|
||||
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
|
||||
|
||||
/* The background is drawn before the expose events; this colour is
|
||||
* only for a view that is drawn before its window is mapped, so that
|
||||
* a dark theme does not flash light first */
|
||||
if (color)
|
||||
{
|
||||
impl->background_color = *color;
|
||||
impl->background_color_set = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1941,11 +1961,29 @@ gdk_window_get_root_origin (GdkWindow *window,
|
|||
gint *y)
|
||||
{
|
||||
GdkRectangle rect;
|
||||
GdkWindow *toplevel;
|
||||
GdkWindowImplQuartz *impl;
|
||||
|
||||
rect.x = 0;
|
||||
rect.y = 0;
|
||||
|
||||
gdk_window_get_frame_extents (window, &rect);
|
||||
/* Where gdk_window_move() puts a toplevel is the top left of its
|
||||
* content (Quartz places the content rect), so that is what this
|
||||
* gives, for gtk_window_get_position(): with the frame, a window
|
||||
* that a program puts back where it was went up by the height of
|
||||
* the title bar each time (as Ardour found) */
|
||||
toplevel = gdk_window_get_effective_toplevel (window);
|
||||
impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (toplevel)->impl);
|
||||
if (impl->toplevel)
|
||||
{
|
||||
NSRect ns_rect = [impl->toplevel contentRectForFrameRect:[impl->toplevel frame]];
|
||||
|
||||
_gdk_quartz_window_xy_to_gdk_xy (ns_rect.origin.x,
|
||||
ns_rect.origin.y + ns_rect.size.height,
|
||||
&rect.x, &rect.y);
|
||||
}
|
||||
else
|
||||
gdk_window_get_frame_extents (window, &rect);
|
||||
|
||||
if (x)
|
||||
*x = rect.x;
|
||||
|
|
@ -2271,8 +2309,11 @@ gdk_window_set_transient_for (GdkWindow *window,
|
|||
GdkWindowImplQuartz *window_impl;
|
||||
GdkWindowImplQuartz *parent_impl;
|
||||
|
||||
/* an offscreen window, or a child of one, has no NSWindow to be
|
||||
* transient for */
|
||||
if (GDK_WINDOW_DESTROYED (window) || GDK_WINDOW_DESTROYED (parent) ||
|
||||
!WINDOW_IS_TOPLEVEL (window))
|
||||
!WINDOW_IS_TOPLEVEL (window) ||
|
||||
!GDK_IS_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (parent)->impl))
|
||||
return;
|
||||
|
||||
window_impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
|
||||
|
|
@ -2559,7 +2600,8 @@ gdk_window_set_modal_hint (GdkWindow *window,
|
|||
!WINDOW_IS_TOPLEVEL (window))
|
||||
return;
|
||||
|
||||
/* FIXME: Implement */
|
||||
/* kept, so that gdk_window_get_modal_hint() is right (Ardour) */
|
||||
((GdkWindowObject *) window)->modal_hint = modal;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -2842,9 +2884,45 @@ void
|
|||
gdk_window_set_functions (GdkWindow *window,
|
||||
GdkWMFunction functions)
|
||||
{
|
||||
GdkWindowImplQuartz *impl;
|
||||
gboolean close, minimize, maximize;
|
||||
|
||||
g_return_if_fail (GDK_IS_WINDOW (window));
|
||||
|
||||
/* FIXME: Implement */
|
||||
if (GDK_WINDOW_DESTROYED (window) ||
|
||||
!WINDOW_IS_TOPLEVEL (window))
|
||||
return;
|
||||
|
||||
impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
|
||||
if (!impl->toplevel)
|
||||
return;
|
||||
|
||||
/* GDK_FUNC_ALL turns the meaning of the other bits around, as on X11 */
|
||||
if (functions & GDK_FUNC_ALL)
|
||||
{
|
||||
close = !(functions & GDK_FUNC_CLOSE);
|
||||
minimize = !(functions & GDK_FUNC_MINIMIZE);
|
||||
maximize = !(functions & GDK_FUNC_MAXIMIZE);
|
||||
}
|
||||
else
|
||||
{
|
||||
close = (functions & GDK_FUNC_CLOSE) != 0;
|
||||
minimize = (functions & GDK_FUNC_MINIMIZE) != 0;
|
||||
maximize = (functions & GDK_FUNC_MAXIMIZE) != 0;
|
||||
}
|
||||
|
||||
/* The buttons of the title bar, so that gtk_window_set_deletable()
|
||||
* works. Enabling and disabling them works from Mac OS X 10.2 on and
|
||||
* leaves the style of the window (and whether it can be resized, which
|
||||
* the geometry hints decide) alone; a window without a title bar has
|
||||
* no buttons, so nothing happens there. */
|
||||
GDK_QUARTZ_ALLOC_POOL;
|
||||
|
||||
[[impl->toplevel standardWindowButton:NSWindowCloseButton] setEnabled:close];
|
||||
[[impl->toplevel standardWindowButton:NSWindowMiniaturizeButton] setEnabled:minimize];
|
||||
[[impl->toplevel standardWindowButton:NSWindowZoomButton] setEnabled:maximize];
|
||||
|
||||
GDK_QUARTZ_RELEASE_POOL;
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
@ -3000,6 +3078,12 @@ gdk_window_fullscreen (GdkWindow *window)
|
|||
!WINDOW_IS_TOPLEVEL (window))
|
||||
return;
|
||||
|
||||
/* In the full screen of the system already (the green button, 10.7
|
||||
* and newer): changing the decorations there throws (as Ardour
|
||||
* found). The bit of NSFullScreenWindowMask, for older SDKs. */
|
||||
if ([impl->toplevel styleMask] & (1 << 14))
|
||||
return;
|
||||
|
||||
geometry = get_fullscreen_geometry (window);
|
||||
if (!geometry)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -60,6 +60,10 @@ struct _GdkWindowImplQuartz
|
|||
GList *sorted_children;
|
||||
|
||||
GdkRegion *needs_display_region;
|
||||
|
||||
/* drawn before the first expose (from Ardour's YTK) */
|
||||
GdkColor background_color;
|
||||
gboolean background_color_set;
|
||||
};
|
||||
|
||||
struct _GdkWindowImplQuartzClass
|
||||
|
|
|
|||
310
gdk/rgbsimdbench.c
Normal file
310
gdk/rgbsimdbench.c
Normal file
|
|
@ -0,0 +1,310 @@
|
|||
/* rgbsimdbench: checks and times GdkRGB's vector kernels on this machine
|
||||
*
|
||||
* Every kernel of every instruction set the CPU has is run against the
|
||||
* C code it stands in for: first on random data, which must come out
|
||||
* the same, then for speed. The table at the end shows millions of
|
||||
* pixels per second; the fastest of each row is marked.
|
||||
*
|
||||
* make -C gdk rgbsimdbench && gdk/rgbsimdbench
|
||||
*
|
||||
* GDK_RGB_SIMD="op=set,..." tries a choice in a running program.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "gdkrgbsimd.h"
|
||||
|
||||
#define WIDTH 256
|
||||
#define ROWS 64
|
||||
|
||||
typedef gint (*Kernel) (gpointer out, gconstpointer in, gint n);
|
||||
|
||||
static guint32 seed = 1;
|
||||
|
||||
static guint
|
||||
rnd (void)
|
||||
{
|
||||
seed = seed * 1103515245 + 12345;
|
||||
return seed >> 8;
|
||||
}
|
||||
|
||||
static inline guint
|
||||
blend8 (guint a, guint s, guint d)
|
||||
{
|
||||
guint t = a * s + (255 - a) * d + 0x80;
|
||||
|
||||
return (t + (t >> 8)) >> 8;
|
||||
}
|
||||
|
||||
/* The C code of GdkRGB and gdk_cairo_set_source_pixbuf(), as plain as
|
||||
* there, for one pixel at position i */
|
||||
static void
|
||||
c_pixel (gint op, gpointer out, const guchar *s, gint i)
|
||||
{
|
||||
guint32 *o32 = (guint32 *) out + i;
|
||||
guint16 *o16 = (guint16 *) out + i;
|
||||
guint r, g, b;
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case 0: /* rgb_to_x888 */
|
||||
case 1: /* rgbx_to_x888 */
|
||||
*o32 = 0xff000000 | (s[0] << 16) | (s[1] << 8) | s[2];
|
||||
break;
|
||||
case 2: /* rgb_to_565 */
|
||||
*o16 = ((s[0] & 0xf8) << 8) | ((s[1] & 0xfc) << 3) | (s[2] >> 3);
|
||||
break;
|
||||
case 3: /* rgb_to_555 */
|
||||
*o16 = 0x8000 | ((s[0] & 0xf8) << 7) | ((s[1] & 0xf8) << 2) | (s[2] >> 3);
|
||||
break;
|
||||
case 4: /* composite_x888 */
|
||||
if (s[3] == 0)
|
||||
break;
|
||||
if (s[3] == 255)
|
||||
*o32 = 0xff000000 | (s[0] << 16) | (s[1] << 8) | s[2];
|
||||
else
|
||||
*o32 = 0xff000000 | (blend8 (s[3], s[0], (*o32 >> 16) & 0xff) << 16) |
|
||||
(blend8 (s[3], s[1], (*o32 >> 8) & 0xff) << 8) | blend8 (s[3], s[2], *o32 & 0xff);
|
||||
break;
|
||||
case 5: /* composite_565 */
|
||||
if (s[3] == 0)
|
||||
break;
|
||||
r = *o16 >> 11, g = (*o16 >> 5) & 0x3f, b = *o16 & 0x1f;
|
||||
r = blend8 (s[3], s[0], (r << 3) | (r >> 2));
|
||||
g = blend8 (s[3], s[1], (g << 2) | (g >> 4));
|
||||
b = blend8 (s[3], s[2], (b << 3) | (b >> 2));
|
||||
*o16 = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3);
|
||||
break;
|
||||
case 6: /* composite_555 */
|
||||
if (s[3] == 0)
|
||||
break;
|
||||
r = (*o16 >> 10) & 0x1f, g = (*o16 >> 5) & 0x1f, b = *o16 & 0x1f;
|
||||
r = blend8 (s[3], s[0], (r << 3) | (r >> 2));
|
||||
g = blend8 (s[3], s[1], (g << 3) | (g >> 2));
|
||||
b = blend8 (s[3], s[2], (b << 3) | (b >> 2));
|
||||
*o16 = 0x8000 | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
|
||||
break;
|
||||
case 7: /* rgba_to_argb */
|
||||
*o32 = ((guint32) s[3] << 24) | (blend8 (s[3], s[0], 0) << 16) |
|
||||
(blend8 (s[3], s[1], 0) << 8) | blend8 (s[3], s[2], 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
in_bytes (gint op)
|
||||
{
|
||||
return op == 0 || op == 2 || op == 3 ? 3 : 4;
|
||||
}
|
||||
|
||||
static gint
|
||||
out_bytes (gint op)
|
||||
{
|
||||
return op == 2 || op == 3 || op == 5 || op == 6 ? 2 : 4;
|
||||
}
|
||||
|
||||
static void
|
||||
run_c (gint op, gpointer out, const guchar *in, gint n)
|
||||
{
|
||||
gint i, step = in_bytes (op);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
c_pixel (op, out, in + i * step, i);
|
||||
}
|
||||
|
||||
static void
|
||||
run (gint op, Kernel kernel, gpointer out, const guchar *in, gint n)
|
||||
{
|
||||
gint done = kernel ? kernel (out, in, n) : 0, i, step = in_bytes (op);
|
||||
|
||||
/* the C code does the rest of the row */
|
||||
for (i = done; i < n; i++)
|
||||
c_pixel (op, out, in + i * step, i);
|
||||
}
|
||||
|
||||
/* Source rows: for the alpha either like icons, mostly nothing or
|
||||
* everything, or like soft shadows, everything in between */
|
||||
static void
|
||||
fill_source (guchar *in, gint op, gboolean icons)
|
||||
{
|
||||
gint i, n = ROWS * WIDTH * in_bytes (op);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
in[i] = rnd ();
|
||||
if (in_bytes (op) == 4)
|
||||
for (i = 3; i < n; i += 4)
|
||||
{
|
||||
guint k = rnd () % 10;
|
||||
|
||||
if (icons && k < 4)
|
||||
in[i] = 0;
|
||||
else if (icons && k < 8)
|
||||
in[i] = 255;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
check (gint op, Kernel kernel)
|
||||
{
|
||||
static guchar in[WIDTH * 4 + 16], a[WIDTH * 4 + 16], b[WIDTH * 4 + 16];
|
||||
gint t, i;
|
||||
|
||||
for (t = 0; t < 2000; t++)
|
||||
{
|
||||
gint n = rnd () % WIDTH, ia = rnd () % 16, oa = (rnd () % 8) * 2;
|
||||
|
||||
for (i = 0; i < (gint) sizeof in; i++)
|
||||
in[i] = rnd ();
|
||||
for (i = 3; i < (gint) sizeof in; i += 4)
|
||||
if (rnd () % 3 == 0)
|
||||
in[i] = rnd () % 2 ? 0 : 255;
|
||||
for (i = 0; i < (gint) sizeof a; i++)
|
||||
a[i] = b[i] = rnd ();
|
||||
run_c (op, a + oa, in + ia, n);
|
||||
run (op, kernel, b + oa, in + ia, n);
|
||||
if (memcmp (a, b, sizeof a) != 0)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Millions of pixels per second */
|
||||
static gdouble
|
||||
measure (gint op, Kernel kernel, gboolean c_only, gboolean icons)
|
||||
{
|
||||
static guchar in[ROWS * WIDTH * 4], out[ROWS * WIDTH * 4];
|
||||
gint64 start, elapsed;
|
||||
gint rounds = 0, y;
|
||||
|
||||
seed = 7;
|
||||
fill_source (in, op, icons);
|
||||
for (y = 0; y < (gint) sizeof out; y++)
|
||||
out[y] = rnd ();
|
||||
|
||||
start = g_get_monotonic_time ();
|
||||
do
|
||||
{
|
||||
for (y = 0; y < ROWS; y++)
|
||||
{
|
||||
const guchar *src = in + y * WIDTH * in_bytes (op);
|
||||
guchar *dst = out + y * WIDTH * out_bytes (op);
|
||||
|
||||
if (c_only)
|
||||
run_c (op, dst, src, WIDTH);
|
||||
else
|
||||
run (op, kernel, dst, src, WIDTH);
|
||||
}
|
||||
rounds++;
|
||||
elapsed = g_get_monotonic_time () - start;
|
||||
}
|
||||
while (elapsed < 300000);
|
||||
|
||||
return (gdouble) rounds * ROWS * WIDTH / elapsed;
|
||||
}
|
||||
|
||||
static void
|
||||
print_cpu (void)
|
||||
{
|
||||
gchar *info = NULL, **lines;
|
||||
gint i, shown = 0;
|
||||
|
||||
if (!g_file_get_contents ("/proc/cpuinfo", &info, NULL, NULL))
|
||||
return;
|
||||
lines = g_strsplit (info, "\n", -1);
|
||||
for (i = 0; lines[i] && shown < 4; i++)
|
||||
if (g_str_has_prefix (lines[i], "model name") || g_str_has_prefix (lines[i], "cpu\t") ||
|
||||
g_str_has_prefix (lines[i], "vendor_id") || g_str_has_prefix (lines[i], "flags") ||
|
||||
g_str_has_prefix (lines[i], "Features") || g_str_has_prefix (lines[i], "CPU part") ||
|
||||
g_str_has_prefix (lines[i], "Hardware"))
|
||||
{
|
||||
printf ("%.150s\n", lines[i]);
|
||||
shown++;
|
||||
}
|
||||
g_strfreev (lines);
|
||||
g_free (info);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
const GdkRgbSimdSet *sets;
|
||||
const GdkRgbSimdOp *ops;
|
||||
const GdkRgbSimd *chosen;
|
||||
gint n_sets, n_ops, s, k, pass;
|
||||
gboolean all_good = TRUE;
|
||||
|
||||
print_cpu ();
|
||||
sets = _gdk_rgb_simd_sets (&n_sets);
|
||||
ops = _gdk_rgb_simd_ops (&n_ops);
|
||||
chosen = _gdk_rgb_simd_get ();
|
||||
|
||||
printf ("\nMillions of pixels per second, * the fastest, < what GDK takes now\n\n");
|
||||
printf ("%-22s %8s", "", "c");
|
||||
for (s = 0; s < n_sets; s++)
|
||||
printf (" %9s", sets[s].name);
|
||||
printf ("\n");
|
||||
|
||||
for (k = 0; k < n_ops; k++)
|
||||
for (pass = 0; pass < (in_bytes (k) == 4 && k != 1 ? 2 : 1); pass++)
|
||||
{
|
||||
gdouble speed[16], best = 0;
|
||||
const gchar *mark[16];
|
||||
gchar label[64];
|
||||
Kernel now = G_STRUCT_MEMBER (Kernel, chosen, ops[k].offset);
|
||||
|
||||
g_snprintf (label, sizeof label, "%s%s", ops[k].name,
|
||||
in_bytes (k) == 4 && k != 1 ? (pass ? " soft" : " icons") : "");
|
||||
speed[0] = measure (k, NULL, TRUE, !pass);
|
||||
best = speed[0];
|
||||
for (s = 0; s < n_sets; s++)
|
||||
{
|
||||
GdkRgbSimd set;
|
||||
Kernel kernel;
|
||||
|
||||
memset (&set, 0, sizeof set);
|
||||
sets[s].init (&set);
|
||||
kernel = G_STRUCT_MEMBER (Kernel, &set, ops[k].offset);
|
||||
speed[s + 1] = -1;
|
||||
mark[s + 1] = " ";
|
||||
if (!kernel)
|
||||
continue;
|
||||
if (!check (k, kernel))
|
||||
{
|
||||
printf ("%s of %s does not give what the C code does!\n", ops[k].name, sets[s].name);
|
||||
all_good = FALSE;
|
||||
continue;
|
||||
}
|
||||
speed[s + 1] = measure (k, kernel, FALSE, !pass);
|
||||
if (speed[s + 1] > best)
|
||||
best = speed[s + 1];
|
||||
if (kernel == now)
|
||||
mark[s + 1] = "<";
|
||||
}
|
||||
|
||||
printf ("%-22s %7.1f%s", label, speed[0], speed[0] == best ? "*" : (now ? " " : "<"));
|
||||
for (s = 0; s < n_sets; s++)
|
||||
{
|
||||
if (speed[s + 1] < 0)
|
||||
printf (" %9s", "-");
|
||||
else
|
||||
printf (" %8.1f%s", speed[s + 1], speed[s + 1] == best ? "*" : mark[s + 1]);
|
||||
}
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
if (!all_good)
|
||||
printf ("\nSome kernels are wrong on this machine; please send this output.\n");
|
||||
|
||||
return all_good ? 0 : 1;
|
||||
}
|
||||
|
|
@ -1137,7 +1137,6 @@ gdk_colormap_alloc_colors (GdkColormap *colormap,
|
|||
gboolean best_match,
|
||||
gboolean *success)
|
||||
{
|
||||
GdkColormapPrivateWin32 *private;
|
||||
GdkVisual *visual;
|
||||
gint i;
|
||||
gint nremaining = 0;
|
||||
|
|
@ -1147,8 +1146,6 @@ gdk_colormap_alloc_colors (GdkColormap *colormap,
|
|||
g_return_val_if_fail (colors != NULL, FALSE);
|
||||
g_return_val_if_fail (success != NULL, ncolors);
|
||||
|
||||
private = GDK_WIN32_COLORMAP_DATA (colormap);
|
||||
|
||||
for (i = 0; i < ncolors; i++)
|
||||
success[i] = FALSE;
|
||||
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ hcursor_from_type (GdkCursorType cursor_type)
|
|||
gint i, j, x, y, ofs;
|
||||
HCURSOR rv;
|
||||
gint w, h;
|
||||
gint s = _gdk_win32_scale;
|
||||
guchar *and_plane, *xor_plane;
|
||||
|
||||
if (cursor_type != GDK_BLANK_CURSOR)
|
||||
|
|
@ -84,6 +85,12 @@ hcursor_from_type (GdkCursorType cursor_type)
|
|||
|
||||
w = GetSystemMetrics (SM_CXCURSOR);
|
||||
h = GetSystemMetrics (SM_CYCURSOR);
|
||||
/* HiDPI: each pixel of the X cursor as s x s pixels of Windows */
|
||||
if (cursor_type != GDK_BLANK_CURSOR && s > 1)
|
||||
{
|
||||
w = MAX (w, (cursors[i].width * s + 31) / 32 * 32);
|
||||
h = MAX (h, cursors[i].height * s);
|
||||
}
|
||||
|
||||
and_plane = g_malloc ((w/8) * h);
|
||||
memset (and_plane, 0xff, (w/8) * h);
|
||||
|
|
@ -96,16 +103,18 @@ hcursor_from_type (GdkCursorType cursor_type)
|
|||
#define SET_BIT(v,b) (v |= (1 << b))
|
||||
#define RESET_BIT(v,b) (v &= ~(1 << b))
|
||||
|
||||
for (j = 0, y = 0; y < cursors[i].height && y < h ; y++)
|
||||
for (y = 0; y < cursors[i].height * s && y < h ; y++)
|
||||
{
|
||||
ofs = (y * w) / 8;
|
||||
j = y * cursors[i].width;
|
||||
|
||||
for (x = 0; x < cursors[i].width && x < w ; x++, j++)
|
||||
for (x = 0; x < cursors[i].width * s && x < w ; x++)
|
||||
{
|
||||
gint pofs = ofs + x / 8;
|
||||
guchar data = (cursors[i].data[j/4] & (0xc0 >> (2 * (j%4)))) >> (2 * (3 - (j%4)));
|
||||
gint bit = 7 - (j % cursors[i].width) % 8;
|
||||
guchar data;
|
||||
gint bit = 7 - x % 8;
|
||||
|
||||
j = (y / s) * cursors[i].width + x / s;
|
||||
data = (cursors[i].data[j/4] & (0xc0 >> (2 * (j%4)))) >> (2 * (3 - (j%4)));
|
||||
|
||||
if (data)
|
||||
{
|
||||
|
|
@ -119,7 +128,9 @@ hcursor_from_type (GdkCursorType cursor_type)
|
|||
#undef SET_BIT
|
||||
#undef RESET_BIT
|
||||
|
||||
rv = CreateCursor (_gdk_app_hmodule, cursors[i].hotx, cursors[i].hoty,
|
||||
rv = CreateCursor (_gdk_app_hmodule,
|
||||
cursors[i].hotx * s + s / 2,
|
||||
cursors[i].hoty * s + s / 2,
|
||||
w, h, and_plane, xor_plane);
|
||||
}
|
||||
else
|
||||
|
|
@ -210,14 +221,24 @@ gdk_cursor_new_from_pixmap (GdkPixmap *source,
|
|||
g_return_val_if_fail (source_impl->width == mask_impl->width
|
||||
&& source_impl->height == mask_impl->height,
|
||||
NULL);
|
||||
width = source_impl->width;
|
||||
height = source_impl->height;
|
||||
g_return_val_if_fail (source_impl->scale == mask_impl->scale, NULL);
|
||||
|
||||
/* HiDPI: the bits are in pixels of Windows, and so is the cursor */
|
||||
width = source_impl->width * MAX (source_impl->scale, 1);
|
||||
height = source_impl->height * MAX (source_impl->scale, 1);
|
||||
x = x * MAX (source_impl->scale, 1) + MAX (source_impl->scale, 1) / 2;
|
||||
y = y * MAX (source_impl->scale, 1) + MAX (source_impl->scale, 1) / 2;
|
||||
cursor_width = GetSystemMetrics (SM_CXCURSOR);
|
||||
cursor_height = GetSystemMetrics (SM_CYCURSOR);
|
||||
|
||||
g_return_val_if_fail (width <= cursor_width && height <= cursor_height,
|
||||
g_return_val_if_fail (source_impl->width <= cursor_width / _gdk_win32_scale &&
|
||||
source_impl->height <= cursor_height / _gdk_win32_scale,
|
||||
NULL);
|
||||
|
||||
/* a cursor as large as the scaled bits when Windows' size is not */
|
||||
cursor_width = MAX (cursor_width, (width + 31) / 32 * 32);
|
||||
cursor_height = MAX (cursor_height, height);
|
||||
|
||||
residue = (1 << ((8-(width%8))%8)) - 1;
|
||||
|
||||
source_bits = source_impl->bits;
|
||||
|
|
@ -228,7 +249,7 @@ gdk_cursor_new_from_pixmap (GdkPixmap *source,
|
|||
NULL);
|
||||
|
||||
source_bpl = ((width - 1)/32 + 1)*4;
|
||||
mask_bpl = ((mask_impl->width - 1)/32 + 1)*4;
|
||||
mask_bpl = source_bpl;
|
||||
|
||||
GDK_NOTE (CURSOR, {
|
||||
g_print ("gdk_cursor_new_from_pixmap: source=%p:\n",
|
||||
|
|
@ -626,7 +647,27 @@ gdk_cursor_new_from_pixbuf (GdkDisplay *display,
|
|||
g_return_val_if_fail (0 <= x && x < gdk_pixbuf_get_width (pixbuf), NULL);
|
||||
g_return_val_if_fail (0 <= y && y < gdk_pixbuf_get_height (pixbuf), NULL);
|
||||
|
||||
hcursor = _gdk_win32_pixbuf_to_hcursor (pixbuf, x, y);
|
||||
if (_gdk_win32_scale > 1)
|
||||
{
|
||||
/* HiDPI: the cursor in pixels of Windows, from the picture made
|
||||
* for it if there is one */
|
||||
GdkPixbuf *hires = _gdk_pixbuf_get_hires (pixbuf, _gdk_win32_scale);
|
||||
gint s = _gdk_win32_scale;
|
||||
|
||||
if (hires)
|
||||
g_object_ref (hires);
|
||||
else
|
||||
hires = gdk_pixbuf_scale_simple (pixbuf,
|
||||
gdk_pixbuf_get_width (pixbuf) * s,
|
||||
gdk_pixbuf_get_height (pixbuf) * s,
|
||||
GDK_INTERP_NEAREST);
|
||||
if (!hires)
|
||||
return NULL;
|
||||
hcursor = _gdk_win32_pixbuf_to_hcursor (hires, x * s + s / 2, y * s + s / 2);
|
||||
g_object_unref (hires);
|
||||
}
|
||||
else
|
||||
hcursor = _gdk_win32_pixbuf_to_hcursor (pixbuf, x, y);
|
||||
if (!hcursor)
|
||||
return NULL;
|
||||
return cursor_new_from_hcursor (hcursor, GDK_CURSOR_IS_PIXMAP);
|
||||
|
|
@ -653,7 +694,8 @@ gdk_display_get_default_cursor_size (GdkDisplay *display)
|
|||
{
|
||||
g_return_val_if_fail (display == _gdk_display, 0);
|
||||
|
||||
return MIN (GetSystemMetrics (SM_CXCURSOR), GetSystemMetrics (SM_CYCURSOR));
|
||||
/* in pixels of GDK (HiDPI) */
|
||||
return MAX (MIN (GetSystemMetrics (SM_CXCURSOR), GetSystemMetrics (SM_CYCURSOR)) / _gdk_win32_scale, 1);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -663,10 +705,11 @@ gdk_display_get_maximal_cursor_size (GdkDisplay *display,
|
|||
{
|
||||
g_return_if_fail (display == _gdk_display);
|
||||
|
||||
/* in pixels of GDK (HiDPI) */
|
||||
if (width)
|
||||
*width = GetSystemMetrics (SM_CXCURSOR);
|
||||
*width = MAX (GetSystemMetrics (SM_CXCURSOR) / _gdk_win32_scale, 1);
|
||||
if (height)
|
||||
*height = GetSystemMetrics (SM_CYCURSOR);
|
||||
*height = MAX (GetSystemMetrics (SM_CYCURSOR) / _gdk_win32_scale, 1);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ enum_monitor (HMONITOR hmonitor,
|
|||
|
||||
monitor = _gdk_monitors + *index;
|
||||
|
||||
monitor_info.cbSize = sizeof (MONITORINFOEX);
|
||||
monitor_info.cbSize = sizeof (MONITORINFOEXA2);
|
||||
GetMonitorInfoA (hmonitor, (MONITORINFO *) &monitor_info);
|
||||
|
||||
#ifndef MONITORINFOF_PRIMARY
|
||||
|
|
@ -159,11 +159,17 @@ _gdk_monitor_init (void)
|
|||
GDK_NOTE (MISC, g_print ("Multi-monitor offset: (%d,%d)\n",
|
||||
_gdk_offset_x, _gdk_offset_y));
|
||||
|
||||
/* Translate monitor coords into GDK coordinate space */
|
||||
/* Translate monitor coords into GDK coordinate space, also in its
|
||||
* pixels (HiDPI) */
|
||||
for (i = 0; i < _gdk_num_monitors; i++)
|
||||
{
|
||||
_gdk_monitors[i].rect.x += _gdk_offset_x;
|
||||
_gdk_monitors[i].rect.y += _gdk_offset_y;
|
||||
GdkRectangle *r = &_gdk_monitors[i].rect;
|
||||
gint x2 = r->x + r->width + _gdk_offset_x, y2 = r->y + r->height + _gdk_offset_y;
|
||||
|
||||
r->x = _gdk_win32_unscale (r->x + _gdk_offset_x);
|
||||
r->y = _gdk_win32_unscale (r->y + _gdk_offset_y);
|
||||
r->width = _gdk_win32_unscale (x2) - r->x;
|
||||
r->height = _gdk_win32_unscale (y2) - r->y;
|
||||
GDK_NOTE (MISC, g_print ("Monitor %d: %dx%d@%+d%+d\n",
|
||||
i, _gdk_monitors[i].rect.width,
|
||||
_gdk_monitors[i].rect.height,
|
||||
|
|
@ -183,8 +189,8 @@ _gdk_monitor_init (void)
|
|||
ReleaseDC (NULL, hDC);
|
||||
_gdk_monitors[0].rect.x = 0;
|
||||
_gdk_monitors[0].rect.y = 0;
|
||||
_gdk_monitors[0].rect.width = GetSystemMetrics (SM_CXSCREEN);
|
||||
_gdk_monitors[0].rect.height = GetSystemMetrics (SM_CYSCREEN);
|
||||
_gdk_monitors[0].rect.width = _gdk_win32_unscale (GetSystemMetrics (SM_CXSCREEN));
|
||||
_gdk_monitors[0].rect.height = _gdk_win32_unscale (GetSystemMetrics (SM_CYSCREEN));
|
||||
_gdk_offset_x = 0;
|
||||
_gdk_offset_y = 0;
|
||||
#endif
|
||||
|
|
@ -216,6 +222,24 @@ gdk_display_open (const gchar *display_name)
|
|||
|
||||
_gdk_monitor_init ();
|
||||
_gdk_visual_init ();
|
||||
|
||||
/* HiDPI: fonts are laid out in pixels of GDK and drawn in those of
|
||||
* Windows; widths rounded to GDK's pixels would space the letters
|
||||
* unevenly */
|
||||
if (_gdk_win32_scale > 1)
|
||||
{
|
||||
cairo_font_options_t *options = cairo_font_options_create ();
|
||||
|
||||
cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_OFF);
|
||||
gdk_screen_set_font_options (_gdk_screen, options);
|
||||
cairo_font_options_destroy (options);
|
||||
}
|
||||
|
||||
/* HiDPI: the resolution of fonts in pixels of GDK; Pango would take
|
||||
* that of Windows, in its pixels (GTK+ sets it from gtk-xft-dpi only
|
||||
* on X11) */
|
||||
if (_gdk_win32_font_dpi () > 0)
|
||||
gdk_screen_set_resolution (_gdk_screen, _gdk_win32_font_dpi ());
|
||||
gdk_screen_set_default_colormap (_gdk_screen,
|
||||
gdk_screen_get_system_colormap (_gdk_screen));
|
||||
_gdk_windowing_window_init (_gdk_screen);
|
||||
|
|
@ -505,10 +529,11 @@ gdk_display_request_selection_notification (GdkDisplay *display,
|
|||
{
|
||||
static HWND hwndViewer = NULL;
|
||||
gboolean ret = FALSE;
|
||||
gchar *selection_name = gdk_atom_name (selection);
|
||||
|
||||
GDK_NOTE (DND,
|
||||
g_print ("gdk_display_request_selection_notification (..., %s)",
|
||||
gdk_atom_name (selection)));
|
||||
selection_name));
|
||||
|
||||
if (selection == GDK_SELECTION_CLIPBOARD ||
|
||||
selection == GDK_SELECTION_PRIMARY)
|
||||
|
|
@ -526,6 +551,8 @@ gdk_display_request_selection_notification (GdkDisplay *display,
|
|||
ret = FALSE;
|
||||
}
|
||||
|
||||
g_free (selection_name);
|
||||
|
||||
GDK_NOTE (DND, g_print (" -> %s\n", ret ? "TRUE" : "FALSE"));
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,16 +124,17 @@ static gpointer parent_class = NULL;
|
|||
|
||||
static gboolean use_ole2_dnd = FALSE;
|
||||
|
||||
G_DEFINE_TYPE (GdkDragContext, gdk_drag_context, G_TYPE_OBJECT)
|
||||
/* the name G_DEFINE_TYPE_WITH_PRIVATE looks for */
|
||||
typedef GdkDragContextPrivateWin32 GdkDragContextPrivate;
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GdkDragContext, gdk_drag_context, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
gdk_drag_context_init (GdkDragContext *dragcontext)
|
||||
{
|
||||
GdkDragContextPrivateWin32 *private;
|
||||
|
||||
private = G_TYPE_INSTANCE_GET_PRIVATE (dragcontext,
|
||||
GDK_TYPE_DRAG_CONTEXT,
|
||||
GdkDragContextPrivateWin32);
|
||||
private = gdk_drag_context_get_instance_private (dragcontext);
|
||||
|
||||
dragcontext->windowing_data = private;
|
||||
|
||||
|
|
@ -159,8 +160,6 @@ gdk_drag_context_class_init (GdkDragContextClass *klass)
|
|||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gdk_drag_context_finalize;
|
||||
|
||||
g_type_class_add_private (object_class, sizeof (GdkDragContextPrivateWin32));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -230,12 +229,10 @@ gdk_drag_context_find (gboolean is_source,
|
|||
{
|
||||
GList *tmp_list = contexts;
|
||||
GdkDragContext *context;
|
||||
GdkDragContextPrivateWin32 *private;
|
||||
|
||||
while (tmp_list)
|
||||
{
|
||||
context = (GdkDragContext *)tmp_list->data;
|
||||
private = PRIVATE_DATA (context);
|
||||
|
||||
if ((!context->is_source == !is_source) &&
|
||||
((source == NULL) || (context->source_window && (context->source_window == source))) &&
|
||||
|
|
@ -454,8 +451,8 @@ dnd_event_put (GdkEventType type,
|
|||
e.dnd.send_event = FALSE;
|
||||
e.dnd.context = context;
|
||||
e.dnd.time = GDK_CURRENT_TIME;
|
||||
e.dnd.x_root = pt.x + _gdk_offset_x;
|
||||
e.dnd.y_root = pt.x + _gdk_offset_y;
|
||||
e.dnd.x_root = GDK_WIN32_SCREEN_TO_ROOT_X (pt.x);
|
||||
e.dnd.y_root = GDK_WIN32_SCREEN_TO_ROOT_Y (pt.y);
|
||||
|
||||
g_object_ref (e.dnd.context);
|
||||
if (e.dnd.window != NULL)
|
||||
|
|
@ -856,7 +853,6 @@ idataobject_getdata (LPDATAOBJECT This,
|
|||
LPSTGMEDIUM pMedium)
|
||||
{
|
||||
data_object *ctx = (data_object *) This;
|
||||
GdkAtom target;
|
||||
HRESULT hr;
|
||||
GdkEvent e;
|
||||
|
||||
|
|
@ -875,7 +871,6 @@ idataobject_getdata (LPDATAOBJECT This,
|
|||
active_pFormatEtc = pFormatEtc;
|
||||
active_pMedium = pMedium;
|
||||
|
||||
target = GDK_TARGET_STRING;
|
||||
|
||||
e.type = GDK_SELECTION_REQUEST;
|
||||
e.selection.window = ctx->context->source_window;
|
||||
|
|
@ -1477,8 +1472,8 @@ gdk_dropfiles_filter (GdkXEvent *xev,
|
|||
DragQueryPoint (hdrop, &pt);
|
||||
ClientToScreen (msg->hwnd, &pt);
|
||||
|
||||
event->dnd.x_root = pt.x + _gdk_offset_x;
|
||||
event->dnd.y_root = pt.y + _gdk_offset_y;
|
||||
event->dnd.x_root = GDK_WIN32_SCREEN_TO_ROOT_X (pt.x);
|
||||
event->dnd.y_root = GDK_WIN32_SCREEN_TO_ROOT_Y (pt.y);
|
||||
event->dnd.time = _gdk_win32_get_next_tick (msg->time);
|
||||
|
||||
nfiles = DragQueryFile (hdrop, 0xFFFFFFFF, NULL, 0);
|
||||
|
|
@ -1551,8 +1546,7 @@ gdk_dropfiles_filter (GdkXEvent *xev,
|
|||
g_free (fileName);
|
||||
g_string_append (result, "\015\012");
|
||||
}
|
||||
_gdk_dropfiles_store (result->str);
|
||||
g_string_free (result, FALSE);
|
||||
_gdk_dropfiles_store (g_string_free (result, FALSE));
|
||||
|
||||
DragFinish (hdrop);
|
||||
|
||||
|
|
@ -1664,14 +1658,12 @@ local_send_enter (GdkDragContext *context,
|
|||
guint32 time)
|
||||
{
|
||||
GdkEvent tmp_event;
|
||||
GdkDragContextPrivateWin32 *private;
|
||||
GdkDragContext *new_context;
|
||||
|
||||
GDK_NOTE (DND, g_print ("local_send_enter: context=%p current_dest_drag=%p\n",
|
||||
context,
|
||||
current_dest_drag));
|
||||
|
||||
private = PRIVATE_DATA (context);
|
||||
|
||||
if (current_dest_drag != NULL)
|
||||
{
|
||||
|
|
@ -1736,8 +1728,8 @@ local_send_motion (GdkDragContext *context,
|
|||
tmp_event.dnd.x_root = x_root;
|
||||
tmp_event.dnd.y_root = y_root;
|
||||
|
||||
PRIVATE_DATA (current_dest_drag)->last_pt.x = x_root - _gdk_offset_x;
|
||||
PRIVATE_DATA (current_dest_drag)->last_pt.y = y_root - _gdk_offset_y;
|
||||
PRIVATE_DATA (current_dest_drag)->last_pt.x = GDK_WIN32_ROOT_TO_SCREEN_X (x_root);
|
||||
PRIVATE_DATA (current_dest_drag)->last_pt.y = GDK_WIN32_ROOT_TO_SCREEN_Y (y_root);
|
||||
|
||||
PRIVATE_DATA (context)->drag_status = GDK_DRAG_STATUS_MOTION_WAIT;
|
||||
|
||||
|
|
@ -1770,8 +1762,8 @@ local_send_drop (GdkDragContext *context,
|
|||
tmp_event.dnd.context = current_dest_drag;
|
||||
tmp_event.dnd.time = GDK_CURRENT_TIME;
|
||||
|
||||
tmp_event.dnd.x_root = private->last_pt.x + _gdk_offset_x;
|
||||
tmp_event.dnd.y_root = private->last_pt.y + _gdk_offset_y;
|
||||
tmp_event.dnd.x_root = GDK_WIN32_SCREEN_TO_ROOT_X (private->last_pt.x);
|
||||
tmp_event.dnd.y_root = GDK_WIN32_SCREEN_TO_ROOT_Y (private->last_pt.y);
|
||||
|
||||
current_dest_drag = NULL;
|
||||
|
||||
|
|
@ -2023,8 +2015,8 @@ gdk_drag_find_window_for_screen (GdkDragContext *context,
|
|||
GdkWindow *dw;
|
||||
find_window_enum_arg a;
|
||||
|
||||
a.x = x_root - _gdk_offset_x;
|
||||
a.y = y_root - _gdk_offset_y;
|
||||
a.x = GDK_WIN32_ROOT_TO_SCREEN_X (x_root);
|
||||
a.y = GDK_WIN32_ROOT_TO_SCREEN_Y (y_root);
|
||||
a.ignore = drag_window ? GDK_WINDOW_HWND (drag_window) : NULL;
|
||||
a.result = NULL;
|
||||
|
||||
|
|
@ -2154,8 +2146,8 @@ gdk_drag_motion (GdkDragContext *context,
|
|||
|
||||
/* Send a drag-motion event */
|
||||
|
||||
private->last_pt.x = x_root - _gdk_offset_x;
|
||||
private->last_pt.y = y_root - _gdk_offset_y;
|
||||
private->last_pt.x = GDK_WIN32_ROOT_TO_SCREEN_X (x_root);
|
||||
private->last_pt.y = GDK_WIN32_ROOT_TO_SCREEN_Y (y_root);
|
||||
|
||||
if (context->dest_window)
|
||||
{
|
||||
|
|
@ -2236,13 +2228,11 @@ gdk_drag_status (GdkDragContext *context,
|
|||
GdkDragAction action,
|
||||
guint32 time)
|
||||
{
|
||||
GdkDragContextPrivateWin32 *private;
|
||||
GdkDragContext *src_context;
|
||||
GdkEvent tmp_event;
|
||||
|
||||
g_return_if_fail (context != NULL);
|
||||
|
||||
private = PRIVATE_DATA (context);
|
||||
|
||||
GDK_NOTE (DND, g_print ("gdk_drag_status: %s\n"
|
||||
" context=%p:{actions=%s,suggested=%s,action=%s}\n",
|
||||
|
|
@ -2306,7 +2296,6 @@ gdk_drop_finish (GdkDragContext *context,
|
|||
gboolean success,
|
||||
guint32 time)
|
||||
{
|
||||
GdkDragContextPrivateWin32 *private;
|
||||
GdkDragContext *src_context;
|
||||
GdkEvent tmp_event;
|
||||
|
||||
|
|
@ -2314,7 +2303,6 @@ gdk_drop_finish (GdkDragContext *context,
|
|||
|
||||
GDK_NOTE (DND, g_print ("gdk_drop_finish\n"));
|
||||
|
||||
private = PRIVATE_DATA (context);
|
||||
|
||||
if (!use_ole2_dnd)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -689,11 +689,20 @@ generic_draw (GdkDrawable *drawable,
|
|||
* the areas where mask is one. (It is filled with said pattern.)
|
||||
*/
|
||||
|
||||
GDI_CALL (MaskBlt, (hdc, region->extents.x1, region->extents.y1,
|
||||
width, height,
|
||||
tile_hdc, 0, 0,
|
||||
GDK_PIXMAP_HBITMAP (mask_pixmap), 0, 0,
|
||||
MAKEROP4 (rop2_to_rop3 (gcwin32->rop2), ROP3_D)));
|
||||
/* the mask's bits are in pixels of Windows, so all is (HiDPI) */
|
||||
{
|
||||
gint s = _gdk_win32_scale;
|
||||
|
||||
_gdk_win32_dc_set_scale (hdc, 1);
|
||||
_gdk_win32_dc_set_scale (tile_hdc, 1);
|
||||
GDI_CALL (MaskBlt, (hdc, region->extents.x1 * s, region->extents.y1 * s,
|
||||
width * s, height * s,
|
||||
tile_hdc, 0, 0,
|
||||
GDK_PIXMAP_HBITMAP (mask_pixmap), 0, 0,
|
||||
MAKEROP4 (rop2_to_rop3 (gcwin32->rop2), ROP3_D)));
|
||||
_gdk_win32_dc_set_scale (tile_hdc, s);
|
||||
_gdk_win32_dc_set_scale (hdc, _gdk_win32_drawable_scale (drawable));
|
||||
}
|
||||
|
||||
/* Cleanup */
|
||||
gdk_win32_hdc_release (mask_pixmap, mask_gc, blitting_mask);
|
||||
|
|
@ -1386,6 +1395,63 @@ gdk_win32_draw_lines (GdkDrawable *drawable,
|
|||
g_free (pts);
|
||||
}
|
||||
|
||||
/* HiDPI: the scale of a drawable, pixels of its bitmap or window for
|
||||
* one of GDK */
|
||||
gint
|
||||
_gdk_win32_drawable_scale (GdkDrawable *drawable)
|
||||
{
|
||||
if (GDK_IS_PIXMAP (drawable))
|
||||
drawable = GDK_PIXMAP_OBJECT (drawable)->impl;
|
||||
if (GDK_IS_PIXMAP_IMPL_WIN32 (drawable))
|
||||
return MAX (GDK_PIXMAP_IMPL_WIN32 (drawable)->scale, 1);
|
||||
|
||||
return _gdk_win32_scale;
|
||||
}
|
||||
|
||||
/* HiDPI: a BitBlt () in pixels of GDK from a DC of @ss pixels per pixel
|
||||
* of GDK to one with @ds, done in the pixels themselves; the DCs keep
|
||||
* the mapping they had */
|
||||
static BOOL
|
||||
blit_scaled (HDC hdc,
|
||||
gint ds,
|
||||
gint xdest,
|
||||
gint ydest,
|
||||
gint width,
|
||||
gint height,
|
||||
HDC srcdc,
|
||||
gint ss,
|
||||
gint xsrc,
|
||||
gint ysrc,
|
||||
DWORD rop)
|
||||
{
|
||||
BOOL ok;
|
||||
|
||||
if (_gdk_win32_scale <= 1)
|
||||
return BitBlt (hdc, xdest, ydest, width, height, srcdc, xsrc, ysrc, rop);
|
||||
|
||||
_gdk_win32_dc_set_scale (hdc, 1);
|
||||
if (srcdc != hdc)
|
||||
_gdk_win32_dc_set_scale (srcdc, 1);
|
||||
|
||||
if (ds == ss)
|
||||
ok = BitBlt (hdc, xdest * ds, ydest * ds, width * ds, height * ds,
|
||||
srcdc, xsrc * ss, ysrc * ss, rop);
|
||||
else
|
||||
{
|
||||
/* a GdkImage, which has GDK's pixels: the nearest pixel, as
|
||||
* everywhere else in GDK */
|
||||
int old_mode = SetStretchBltMode (hdc, COLORONCOLOR);
|
||||
|
||||
ok = StretchBlt (hdc, xdest * ds, ydest * ds, width * ds, height * ds,
|
||||
srcdc, xsrc * ss, ysrc * ss, width * ss, height * ss, rop);
|
||||
SetStretchBltMode (hdc, old_mode);
|
||||
}
|
||||
|
||||
_gdk_win32_dc_set_scale (hdc, ds);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
static void
|
||||
blit_from_pixmap (gboolean use_fg_bg,
|
||||
GdkDrawableImplWin32 *dest,
|
||||
|
|
@ -1503,8 +1569,10 @@ blit_from_pixmap (gboolean use_fg_bg,
|
|||
}
|
||||
|
||||
if (ok)
|
||||
if (!BitBlt (hdc, xdest, ydest, width, height,
|
||||
srcdc, xsrc, ysrc, rop2_to_rop3 (gcwin32->rop2)) &&
|
||||
if (!blit_scaled (hdc, _gdk_win32_drawable_scale (GDK_DRAWABLE (dest)),
|
||||
xdest, ydest, width, height,
|
||||
srcdc, MAX (src->scale, 1), xsrc, ysrc,
|
||||
rop2_to_rop3 (gcwin32->rop2)) &&
|
||||
GetLastError () != ERROR_INVALID_HANDLE)
|
||||
WIN32_GDI_FAILED ("BitBlt");
|
||||
|
||||
|
|
@ -1549,15 +1617,23 @@ blit_inside_drawable (HDC hdc,
|
|||
HRGN updateRgn;
|
||||
GdkRegion *update_region;
|
||||
|
||||
clipRect.left = xdest;
|
||||
clipRect.top = ydest;
|
||||
clipRect.right = xdest + width;
|
||||
clipRect.bottom = ydest + height;
|
||||
BOOL scrolled;
|
||||
|
||||
/* in pixels of Windows (HiDPI) */
|
||||
clipRect.left = GDK_WIN32_SC (xdest);
|
||||
clipRect.top = GDK_WIN32_SC (ydest);
|
||||
clipRect.right = GDK_WIN32_SC (xdest + width);
|
||||
clipRect.bottom = GDK_WIN32_SC (ydest + height);
|
||||
|
||||
SetRectEmpty (&emptyRect);
|
||||
updateRgn = CreateRectRgnIndirect (&emptyRect);
|
||||
|
||||
if (!ScrollDC (hdc, xdest - xsrc, ydest - ysrc, NULL, &clipRect, updateRgn, NULL))
|
||||
_gdk_win32_dc_set_scale (hdc, 1);
|
||||
scrolled = ScrollDC (hdc, GDK_WIN32_SC (xdest - xsrc), GDK_WIN32_SC (ydest - ysrc),
|
||||
NULL, &clipRect, updateRgn, NULL);
|
||||
_gdk_win32_dc_set_scale (hdc, _gdk_win32_scale);
|
||||
|
||||
if (!scrolled)
|
||||
WIN32_GDI_FAILED ("ScrollDC");
|
||||
else
|
||||
{
|
||||
|
|
@ -1573,13 +1649,17 @@ blit_inside_drawable (HDC hdc,
|
|||
}
|
||||
else
|
||||
{
|
||||
GDI_CALL (BitBlt, (hdc, xdest, ydest, width, height,
|
||||
hdc, xsrc, ysrc, rop2_to_rop3 (gcwin32->rop2)));
|
||||
gint s = _gdk_win32_drawable_scale (GDK_DRAWABLE (src));
|
||||
|
||||
if (!blit_scaled (hdc, s, xdest, ydest, width, height,
|
||||
hdc, s, xsrc, ysrc, rop2_to_rop3 (gcwin32->rop2)))
|
||||
WIN32_GDI_FAILED ("BitBlt");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
blit_from_window (HDC hdc,
|
||||
GdkDrawableImplWin32 *dest,
|
||||
GdkGCWin32 *gcwin32,
|
||||
GdkDrawableImplWin32 *src,
|
||||
gint xsrc,
|
||||
|
|
@ -1615,8 +1695,11 @@ blit_from_window (HDC hdc,
|
|||
g_print ("blit_from_window: realized %d\n", k));
|
||||
}
|
||||
|
||||
GDI_CALL (BitBlt, (hdc, xdest, ydest, width, height,
|
||||
srcdc, xsrc, ysrc, rop2_to_rop3 (gcwin32->rop2)));
|
||||
if (!blit_scaled (hdc, _gdk_win32_drawable_scale (GDK_DRAWABLE (dest)),
|
||||
xdest, ydest, width, height,
|
||||
srcdc, _gdk_win32_scale, xsrc, ysrc,
|
||||
rop2_to_rop3 (gcwin32->rop2)))
|
||||
WIN32_GDI_FAILED ("BitBlt");
|
||||
|
||||
if (holdpal != NULL)
|
||||
GDI_CALL (SelectPalette, (srcdc, holdpal, FALSE));
|
||||
|
|
@ -1656,8 +1739,9 @@ _gdk_win32_blit (gboolean use_fg_bg,
|
|||
if (src == ((GdkWindowObject *)_gdk_root)->impl)
|
||||
{
|
||||
GDK_NOTE (DRAW, g_print ("... offsetting src coords\n"));
|
||||
xsrc -= _gdk_offset_x;
|
||||
ysrc -= _gdk_offset_y;
|
||||
/* in pixels of GDK (HiDPI) */
|
||||
xsrc -= _gdk_win32_unscale (_gdk_offset_x);
|
||||
ysrc -= _gdk_win32_unscale (_gdk_offset_y);
|
||||
}
|
||||
|
||||
if (GDK_IS_DRAWABLE_IMPL_WIN32 (src))
|
||||
|
|
@ -1728,6 +1812,7 @@ _gdk_win32_blit (gboolean use_fg_bg,
|
|||
else if (comb != NULLREGION)
|
||||
{
|
||||
OffsetRgn (outside_rgn, xdest, ydest);
|
||||
outside_rgn = _gdk_win32_hrgn_scale (outside_rgn);
|
||||
GDK_NOTE (DRAW, (GetRgnBox (outside_rgn, &r),
|
||||
g_print ("... InvalidateRgn "
|
||||
"bbox: %ldx%ld@%+ld%+ld\n",
|
||||
|
|
@ -1772,7 +1857,7 @@ _gdk_win32_blit (gboolean use_fg_bg,
|
|||
(GdkPixmapImplWin32 *) src_impl, gc,
|
||||
xsrc, ysrc, xdest, ydest, width, height);
|
||||
else
|
||||
blit_from_window (hdc, GDK_GC_WIN32 (gc), src_impl,
|
||||
blit_from_window (hdc, draw_impl, GDK_GC_WIN32 (gc), src_impl,
|
||||
xsrc, ysrc, xdest, ydest, width, height);
|
||||
|
||||
gdk_win32_hdc_release (&draw_impl->parent_instance, gc, GDK_GC_FOREGROUND);
|
||||
|
|
@ -1931,6 +2016,16 @@ _gdk_windowing_create_cairo_surface (GdkDrawable *drawable,
|
|||
|
||||
surface = cairo_win32_surface_create (hdc);
|
||||
|
||||
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE (1, 14, 0)
|
||||
/* HiDPI: drawn on in pixels of GDK */
|
||||
{
|
||||
gint s = _gdk_win32_drawable_scale (drawable);
|
||||
|
||||
if (s > 1)
|
||||
cairo_surface_set_device_scale (surface, s, s);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Whenever the cairo surface is destroyed, we need to release the
|
||||
* HDC that was acquired */
|
||||
cairo_surface_set_user_data (surface, &gdk_win32_cairo_hdc_key,
|
||||
|
|
|
|||
|
|
@ -87,6 +87,13 @@
|
|||
|
||||
#define SYNAPSIS_ICON_WINDOW_CLASS "SynTrackCursorWindowClass"
|
||||
|
||||
/* The input GDK waits for. Headers for Windows 8 and later add touch
|
||||
* and pointer messages to QS_ALLINPUT: with those GDK keeps waking up
|
||||
* for messages it does not take from the queue, and Windows 7 and
|
||||
* earlier refuse the unknown flags and report nothing at all. */
|
||||
#define GDK_QS_INPUT (QS_KEY | QS_MOUSEMOVE | QS_MOUSEBUTTON | QS_POSTMESSAGE | \
|
||||
QS_TIMER | QS_PAINT | QS_HOTKEY | QS_SENDMESSAGE | 0x0400 /* QS_RAWINPUT */)
|
||||
|
||||
static gboolean gdk_event_translate (MSG *msg,
|
||||
gint *ret_valp);
|
||||
static void handle_wm_paint (MSG *msg,
|
||||
|
|
@ -176,7 +183,9 @@ _gdk_win32_get_next_tick (gulong suggested_tick)
|
|||
|
||||
if (suggested_tick == 0)
|
||||
suggested_tick = GetTickCount ();
|
||||
if (suggested_tick <= cur_tick)
|
||||
/* Ticks eventually wrap around.
|
||||
* This works as long as the interval between ticks is < 2147483648ms */
|
||||
if (suggested_tick <= cur_tick && ((cur_tick - suggested_tick) < 0x7FFFFFFF))
|
||||
return cur_tick;
|
||||
else
|
||||
return cur_tick = suggested_tick;
|
||||
|
|
@ -383,7 +392,7 @@ gdk_events_pending (void)
|
|||
{
|
||||
return (_gdk_event_queue_find_first (_gdk_display) ||
|
||||
(modal_win32_dialog == NULL &&
|
||||
GetQueueStatus (QS_ALLINPUT) != 0));
|
||||
GetQueueStatus (GDK_QS_INPUT) != 0));
|
||||
}
|
||||
|
||||
GdkEvent*
|
||||
|
|
@ -1261,10 +1270,10 @@ send_crossing_event (GdkDisplay *display,
|
|||
event->crossing.window = (GdkWindow *)window;
|
||||
event->crossing.subwindow = subwindow;
|
||||
event->crossing.time = _gdk_win32_get_next_tick (time_);
|
||||
event->crossing.x = pt.x;
|
||||
event->crossing.y = pt.y;
|
||||
event->crossing.x_root = screen_pt->x + _gdk_offset_x;
|
||||
event->crossing.y_root = screen_pt->y + _gdk_offset_y;
|
||||
event->crossing.x = GDK_WIN32_UNSCALE_D (pt.x);
|
||||
event->crossing.y = GDK_WIN32_UNSCALE_D (pt.y);
|
||||
event->crossing.x_root = GDK_WIN32_SCREEN_TO_ROOT_D (screen_pt->x, _gdk_offset_x);
|
||||
event->crossing.y_root = GDK_WIN32_SCREEN_TO_ROOT_D (screen_pt->y, _gdk_offset_y);
|
||||
event->crossing.mode = mode;
|
||||
event->crossing.detail = notify_type;
|
||||
event->crossing.mode = mode;
|
||||
|
|
@ -1482,10 +1491,11 @@ synthesize_expose_events (GdkWindow *window)
|
|||
{
|
||||
event = gdk_event_new (GDK_EXPOSE);
|
||||
event->expose.window = window;
|
||||
event->expose.area.x = r.left;
|
||||
event->expose.area.y = r.top;
|
||||
event->expose.area.width = r.right - r.left;
|
||||
event->expose.area.height = r.bottom - r.top;
|
||||
/* HiDPI: in pixels of GDK, all that is touched */
|
||||
event->expose.area.x = _gdk_win32_unscale (r.left);
|
||||
event->expose.area.y = _gdk_win32_unscale (r.top);
|
||||
event->expose.area.width = _gdk_win32_unscale_up (r.right) - event->expose.area.x;
|
||||
event->expose.area.height = _gdk_win32_unscale_up (r.bottom) - event->expose.area.y;
|
||||
event->expose.region = gdk_region_rectangle (&(event->expose.area));
|
||||
event->expose.count = 0;
|
||||
|
||||
|
|
@ -1669,9 +1679,18 @@ _gdk_win32_emit_configure_event (GdkWindow *window)
|
|||
if (gdk_window_get_parent (window) == _gdk_root)
|
||||
{
|
||||
ClientToScreen (hwnd, &point);
|
||||
point.x += _gdk_offset_x;
|
||||
point.y += _gdk_offset_y;
|
||||
point.x = GDK_WIN32_SCREEN_TO_ROOT_X (point.x);
|
||||
point.y = GDK_WIN32_SCREEN_TO_ROOT_Y (point.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
point.x = _gdk_win32_unscale (point.x);
|
||||
point.y = _gdk_win32_unscale (point.y);
|
||||
}
|
||||
|
||||
/* HiDPI: a size of Windows not divisible by the scale is covered */
|
||||
client_rect.right = client_rect.left + _gdk_win32_unscale_up (client_rect.right - client_rect.left);
|
||||
client_rect.bottom = client_rect.top + _gdk_win32_unscale_up (client_rect.bottom - client_rect.top);
|
||||
|
||||
window_object->width = client_rect.right - client_rect.left;
|
||||
window_object->height = client_rect.bottom - client_rect.top;
|
||||
|
|
@ -1727,10 +1746,11 @@ _gdk_win32_hrgn_to_region (HRGN hrgn)
|
|||
{
|
||||
GdkRectangle r;
|
||||
|
||||
r.x = rects[i].left;
|
||||
r.y = rects[i].top;
|
||||
r.width = rects[i].right - r.x;
|
||||
r.height = rects[i].bottom - r.y;
|
||||
/* in pixels of GDK, all that is partly in it */
|
||||
r.x = _gdk_win32_unscale (rects[i].left);
|
||||
r.y = _gdk_win32_unscale (rects[i].top);
|
||||
r.width = _gdk_win32_unscale_up (rects[i].right) - r.x;
|
||||
r.height = _gdk_win32_unscale_up (rects[i].bottom) - r.y;
|
||||
|
||||
gdk_region_union_with_rect (result, &r);
|
||||
}
|
||||
|
|
@ -1758,7 +1778,6 @@ handle_wm_paint (MSG *msg,
|
|||
GdkEvent **event)
|
||||
{
|
||||
HRGN hrgn = CreateRectRgn (0, 0, 0, 0);
|
||||
HDC hdc;
|
||||
PAINTSTRUCT paintstruct;
|
||||
GdkRegion *update_region;
|
||||
|
||||
|
|
@ -1769,12 +1788,12 @@ handle_wm_paint (MSG *msg,
|
|||
return;
|
||||
}
|
||||
|
||||
hdc = BeginPaint (msg->hwnd, &paintstruct);
|
||||
BeginPaint (msg->hwnd, &paintstruct);
|
||||
|
||||
GDK_NOTE (EVENTS, g_print (" %s %s dc %p%s",
|
||||
_gdk_win32_rect_to_string (&paintstruct.rcPaint),
|
||||
(paintstruct.fErase ? "erase" : ""),
|
||||
hdc,
|
||||
paintstruct.hdc,
|
||||
(return_exposes ? " return_exposes" : "")));
|
||||
|
||||
EndPaint (msg->hwnd, &paintstruct);
|
||||
|
|
@ -1795,11 +1814,9 @@ handle_wm_paint (MSG *msg,
|
|||
|
||||
*event = gdk_event_new (GDK_EXPOSE);
|
||||
(*event)->expose.window = window;
|
||||
(*event)->expose.area.x = paintstruct.rcPaint.left;
|
||||
(*event)->expose.area.y = paintstruct.rcPaint.top;
|
||||
(*event)->expose.area.width = paintstruct.rcPaint.right - paintstruct.rcPaint.left;
|
||||
(*event)->expose.area.height = paintstruct.rcPaint.bottom - paintstruct.rcPaint.top;
|
||||
(*event)->expose.region = _gdk_win32_hrgn_to_region (hrgn);
|
||||
/* in pixels of GDK (HiDPI), as the region */
|
||||
gdk_region_get_clipbox ((*event)->expose.region, &(*event)->expose.area);
|
||||
(*event)->expose.count = 0;
|
||||
|
||||
while (list != NULL)
|
||||
|
|
@ -1892,6 +1909,154 @@ handle_display_change (void)
|
|||
g_signal_emit_by_name (_gdk_screen, "size_changed");
|
||||
}
|
||||
|
||||
/* Touches of Windows 7 and later, from user32 when there: RegisterTouchWindow()
|
||||
* for the windows with GDK_TOUCH_MASK, which then get WM_TOUCH. Windows
|
||||
* keeps sending the mouse messages of the first finger, marked in
|
||||
* GetMessageExtraInfo(), which GDK keeps from the windows that take
|
||||
* touches (gdkwindow.c). Windows XP and Vista: no touches, as before. */
|
||||
#define GDK_WM_TOUCH 0x0240
|
||||
#define GDK_TOUCHEVENTF_MOVE 0x0001
|
||||
#define GDK_TOUCHEVENTF_DOWN 0x0002
|
||||
#define GDK_TOUCHEVENTF_UP 0x0004
|
||||
#define GDK_TOUCHEVENTF_PRIMARY 0x0010
|
||||
#define GDK_MI_WP_SIGNATURE 0xFF515700
|
||||
#define GDK_MI_SIGNATURE_MASK 0xFFFFFF00
|
||||
#define GDK_MI_TOUCH 0x80
|
||||
|
||||
typedef struct
|
||||
{
|
||||
LONG x, y; /* hundredths of a screen pixel */
|
||||
HANDLE hSource;
|
||||
DWORD dwID;
|
||||
DWORD dwFlags;
|
||||
DWORD dwMask;
|
||||
DWORD dwTime;
|
||||
ULONG_PTR dwExtraInfo;
|
||||
DWORD cxContact, cyContact;
|
||||
} GdkTouchInput;
|
||||
|
||||
typedef BOOL (WINAPI *t_RegisterTouchWindow) (HWND, ULONG);
|
||||
typedef BOOL (WINAPI *t_UnregisterTouchWindow) (HWND);
|
||||
typedef BOOL (WINAPI *t_GetTouchInputInfo) (HANDLE, UINT, GdkTouchInput *, int);
|
||||
typedef BOOL (WINAPI *t_CloseTouchInputHandle) (HANDLE);
|
||||
|
||||
static t_RegisterTouchWindow p_RegisterTouchWindow;
|
||||
static t_UnregisterTouchWindow p_UnregisterTouchWindow;
|
||||
static t_GetTouchInputInfo p_GetTouchInputInfo;
|
||||
static t_CloseTouchInputHandle p_CloseTouchInputHandle;
|
||||
|
||||
static gboolean
|
||||
touch_api (void)
|
||||
{
|
||||
static gint state; /* 0 not looked, 1 there, 2 not */
|
||||
|
||||
if (state == 0)
|
||||
{
|
||||
HMODULE user32 = GetModuleHandleW (L"user32.dll");
|
||||
|
||||
p_RegisterTouchWindow = (t_RegisterTouchWindow) GetProcAddress (user32, "RegisterTouchWindow");
|
||||
p_UnregisterTouchWindow = (t_UnregisterTouchWindow) GetProcAddress (user32, "UnregisterTouchWindow");
|
||||
p_GetTouchInputInfo = (t_GetTouchInputInfo) GetProcAddress (user32, "GetTouchInputInfo");
|
||||
p_CloseTouchInputHandle = (t_CloseTouchInputHandle) GetProcAddress (user32, "CloseTouchInputHandle");
|
||||
state = p_RegisterTouchWindow && p_UnregisterTouchWindow &&
|
||||
p_GetTouchInputInfo && p_CloseTouchInputHandle ? 1 : 2;
|
||||
}
|
||||
|
||||
return state == 1;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_win32_window_update_touch (GdkWindow *window,
|
||||
gboolean touch)
|
||||
{
|
||||
HWND hwnd;
|
||||
|
||||
if (GDK_WINDOW_DESTROYED (window) || !touch_api ())
|
||||
return;
|
||||
|
||||
hwnd = GDK_WINDOW_HWND (window);
|
||||
if (hwnd == NULL || GDK_WINDOW_TYPE (window) == GDK_WINDOW_ROOT ||
|
||||
GDK_WINDOW_TYPE (window) == GDK_WINDOW_FOREIGN)
|
||||
return;
|
||||
|
||||
if (touch)
|
||||
p_RegisterTouchWindow (hwnd, 0);
|
||||
else
|
||||
p_UnregisterTouchWindow (hwnd);
|
||||
}
|
||||
|
||||
/* a mouse message that Windows made of a finger */
|
||||
static gboolean
|
||||
mouse_message_from_touch (void)
|
||||
{
|
||||
LPARAM extra = GetMessageExtraInfo ();
|
||||
|
||||
return (extra & GDK_MI_SIGNATURE_MASK) == GDK_MI_WP_SIGNATURE &&
|
||||
(extra & GDK_MI_TOUCH) != 0;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
handle_wm_touch (GdkWindow *window,
|
||||
MSG *msg)
|
||||
{
|
||||
UINT n = LOWORD (msg->wParam), i;
|
||||
GdkTouchInput *inputs;
|
||||
POINT origin = { 0, 0 };
|
||||
guint state;
|
||||
|
||||
if (n == 0 || !touch_api () || GDK_WINDOW_DESTROYED (window))
|
||||
return FALSE;
|
||||
|
||||
inputs = g_new (GdkTouchInput, n);
|
||||
if (!p_GetTouchInputInfo ((HANDLE) msg->lParam, n, inputs, sizeof (GdkTouchInput)))
|
||||
{
|
||||
g_free (inputs);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ClientToScreen (GDK_WINDOW_HWND (window), &origin);
|
||||
state = build_pointer_event_state (msg) &
|
||||
~(GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK | GDK_BUTTON4_MASK | GDK_BUTTON5_MASK);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
GdkEvent *event;
|
||||
GdkEventType type;
|
||||
gdouble sx = inputs[i].x / 100.0, sy = inputs[i].y / 100.0;
|
||||
|
||||
if (inputs[i].dwFlags & GDK_TOUCHEVENTF_DOWN)
|
||||
type = GDK_TOUCH_BEGIN;
|
||||
else if (inputs[i].dwFlags & GDK_TOUCHEVENTF_UP)
|
||||
type = GDK_TOUCH_END;
|
||||
else if (inputs[i].dwFlags & GDK_TOUCHEVENTF_MOVE)
|
||||
type = GDK_TOUCH_UPDATE;
|
||||
else
|
||||
continue;
|
||||
|
||||
event = gdk_event_new (type);
|
||||
event->touch.window = window;
|
||||
event->touch.time = _gdk_win32_get_next_tick (msg->time);
|
||||
event->touch.x = GDK_WIN32_UNSCALE_D (sx - origin.x);
|
||||
event->touch.y = GDK_WIN32_UNSCALE_D (sy - origin.y);
|
||||
event->touch.x_root = GDK_WIN32_SCREEN_TO_ROOT_D (sx, _gdk_offset_x);
|
||||
event->touch.y_root = GDK_WIN32_SCREEN_TO_ROOT_D (sy, _gdk_offset_y);
|
||||
event->touch.axes = NULL;
|
||||
event->touch.state = state;
|
||||
/* the ids of Windows may be 0 */
|
||||
event->touch.sequence = GUINT_TO_POINTER (inputs[i].dwID + 1);
|
||||
event->touch.emulating_pointer = (inputs[i].dwFlags & GDK_TOUCHEVENTF_PRIMARY) != 0;
|
||||
event->touch.device = _gdk_display->core_pointer;
|
||||
((GdkEventPrivate *) event)->flags |= GDK_EVENT_TOUCH_SYSTEM_POINTER;
|
||||
|
||||
_gdk_win32_append_event (event);
|
||||
}
|
||||
|
||||
p_CloseTouchInputHandle ((HANDLE) msg->lParam);
|
||||
g_free (inputs);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
generate_button_event (GdkEventType type,
|
||||
gint button,
|
||||
|
|
@ -1900,12 +2065,17 @@ generate_button_event (GdkEventType type,
|
|||
{
|
||||
GdkEvent *event = gdk_event_new (type);
|
||||
|
||||
if (mouse_message_from_touch ())
|
||||
((GdkEventPrivate *) event)->flags |= GDK_EVENT_POINTER_EMULATED;
|
||||
|
||||
event->button.window = window;
|
||||
event->button.time = _gdk_win32_get_next_tick (msg->time);
|
||||
event->button.x = current_x = (gint16) GET_X_LPARAM (msg->lParam);
|
||||
event->button.y = current_y = (gint16) GET_Y_LPARAM (msg->lParam);
|
||||
event->button.x_root = msg->pt.x + _gdk_offset_x;
|
||||
event->button.y_root = msg->pt.y + _gdk_offset_y;
|
||||
current_x = (gint16) GET_X_LPARAM (msg->lParam);
|
||||
current_y = (gint16) GET_Y_LPARAM (msg->lParam);
|
||||
event->button.x = GDK_WIN32_UNSCALE_D (current_x);
|
||||
event->button.y = GDK_WIN32_UNSCALE_D (current_y);
|
||||
event->button.x_root = GDK_WIN32_SCREEN_TO_ROOT_D (msg->pt.x, _gdk_offset_x);
|
||||
event->button.y_root = GDK_WIN32_SCREEN_TO_ROOT_D (msg->pt.y, _gdk_offset_y);
|
||||
event->button.axes = NULL;
|
||||
event->button.state = build_pointer_event_state (msg);
|
||||
event->button.button = button;
|
||||
|
|
@ -2082,7 +2252,7 @@ gdk_event_translate (MSG *msg,
|
|||
GdkWindow *window = NULL;
|
||||
GdkWindowImplWin32 *impl;
|
||||
|
||||
GdkWindow *orig_window, *new_window;
|
||||
GdkWindow *new_window;
|
||||
|
||||
GdkPointerGrabInfo *grab = NULL;
|
||||
GdkWindow *grab_window = NULL;
|
||||
|
|
@ -2111,7 +2281,6 @@ gdk_event_translate (MSG *msg,
|
|||
}
|
||||
|
||||
window = gdk_win32_handle_table_lookup ((GdkNativeWindow) msg->hwnd);
|
||||
orig_window = window;
|
||||
|
||||
if (window == NULL)
|
||||
{
|
||||
|
|
@ -2352,6 +2521,10 @@ gdk_event_translate (MSG *msg,
|
|||
LOBYTE (HIWORD (msg->lParam)) == _gdk_win32_keymap_get_rshift_scancode (GDK_WIN32_KEYMAP (gdk_keymap_get_default ())))
|
||||
event->key.hardware_keycode = VK_RSHIFT;
|
||||
|
||||
event->key.is_modifier = (msg->wParam == VK_CONTROL ||
|
||||
msg->wParam == VK_SHIFT ||
|
||||
msg->wParam == VK_MENU);
|
||||
|
||||
/* g_print ("ctrl:%02x lctrl:%02x rctrl:%02x alt:%02x lalt:%02x ralt:%02x\n", key_state[VK_CONTROL], key_state[VK_LCONTROL], key_state[VK_RCONTROL], key_state[VK_MENU], key_state[VK_LMENU], key_state[VK_RMENU]); */
|
||||
|
||||
build_key_event_state (event, key_state);
|
||||
|
|
@ -2666,20 +2839,32 @@ gdk_event_translate (MSG *msg,
|
|||
event = gdk_event_new (GDK_MOTION_NOTIFY);
|
||||
event->motion.window = window;
|
||||
event->motion.time = _gdk_win32_get_next_tick (msg->time);
|
||||
event->motion.x = current_x = (gint16) GET_X_LPARAM (msg->lParam);
|
||||
event->motion.y = current_y = (gint16) GET_Y_LPARAM (msg->lParam);
|
||||
event->motion.x_root = current_root_x;
|
||||
event->motion.y_root = current_root_y;
|
||||
current_x = (gint16) GET_X_LPARAM (msg->lParam);
|
||||
current_y = (gint16) GET_Y_LPARAM (msg->lParam);
|
||||
event->motion.x = GDK_WIN32_UNSCALE_D (current_x);
|
||||
event->motion.y = GDK_WIN32_UNSCALE_D (current_y);
|
||||
event->motion.x_root = GDK_WIN32_UNSCALE_D (current_root_x);
|
||||
event->motion.y_root = GDK_WIN32_UNSCALE_D (current_root_y);
|
||||
event->motion.axes = NULL;
|
||||
event->motion.state = build_pointer_event_state (msg);
|
||||
event->motion.is_hint = FALSE;
|
||||
event->motion.device = _gdk_display->core_pointer;
|
||||
if (mouse_message_from_touch ())
|
||||
((GdkEventPrivate *) event)->flags |= GDK_EVENT_POINTER_EMULATED;
|
||||
|
||||
_gdk_win32_append_event (event);
|
||||
|
||||
return_val = TRUE;
|
||||
break;
|
||||
|
||||
case GDK_WM_TOUCH:
|
||||
if (handle_wm_touch (window, msg))
|
||||
{
|
||||
*ret_valp = 0;
|
||||
return_val = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_NCMOUSEMOVE:
|
||||
GDK_NOTE (EVENTS,
|
||||
g_print (" (%d,%d)",
|
||||
|
|
@ -2778,28 +2963,35 @@ gdk_event_translate (MSG *msg,
|
|||
|
||||
ScreenToClient (msg->hwnd, &point);
|
||||
|
||||
event = gdk_event_new (GDK_SCROLL);
|
||||
event->scroll.window = window;
|
||||
{
|
||||
/* What the wheel turned, in steps of WHEEL_DELTA: precision
|
||||
* touchpads and fine wheels send fractions, which become
|
||||
* smooth scroll events and, once they make up a step, the
|
||||
* usual ones as well */
|
||||
static gdouble rest[2];
|
||||
GdkEvent scroll;
|
||||
gdouble delta = (short) HIWORD (msg->wParam) / (gdouble) WHEEL_DELTA;
|
||||
gdouble dx = 0, dy = 0;
|
||||
|
||||
if (msg->message == WM_MOUSEWHEEL)
|
||||
{
|
||||
event->scroll.direction = (((short) HIWORD (msg->wParam)) > 0) ?
|
||||
GDK_SCROLL_UP : GDK_SCROLL_DOWN;
|
||||
}
|
||||
else if (msg->message == WM_MOUSEHWHEEL)
|
||||
{
|
||||
event->scroll.direction = (((short) HIWORD (msg->wParam)) > 0) ?
|
||||
GDK_SCROLL_RIGHT : GDK_SCROLL_LEFT;
|
||||
}
|
||||
event->scroll.time = _gdk_win32_get_next_tick (msg->time);
|
||||
event->scroll.x = (gint16) point.x;
|
||||
event->scroll.y = (gint16) point.y;
|
||||
event->scroll.x_root = (gint16) GET_X_LPARAM (msg->lParam) + _gdk_offset_x;
|
||||
event->scroll.y_root = (gint16) GET_Y_LPARAM (msg->lParam) + _gdk_offset_y;
|
||||
event->scroll.state = build_pointer_event_state (msg);
|
||||
event->scroll.device = _gdk_display->core_pointer;
|
||||
if (msg->message == WM_MOUSEWHEEL)
|
||||
dy = - delta;
|
||||
else
|
||||
dx = delta;
|
||||
|
||||
_gdk_win32_append_event (event);
|
||||
memset (&scroll, 0, sizeof scroll);
|
||||
scroll.scroll.type = GDK_SCROLL;
|
||||
scroll.scroll.window = window;
|
||||
scroll.scroll.time = _gdk_win32_get_next_tick (msg->time);
|
||||
scroll.scroll.x = GDK_WIN32_UNSCALE_D ((gint16) point.x);
|
||||
scroll.scroll.y = GDK_WIN32_UNSCALE_D ((gint16) point.y);
|
||||
scroll.scroll.x_root = GDK_WIN32_SCREEN_TO_ROOT_D ((gint16) GET_X_LPARAM (msg->lParam), _gdk_offset_x);
|
||||
scroll.scroll.y_root = GDK_WIN32_SCREEN_TO_ROOT_D ((gint16) GET_Y_LPARAM (msg->lParam), _gdk_offset_y);
|
||||
scroll.scroll.state = build_pointer_event_state (msg);
|
||||
scroll.scroll.device = _gdk_display->core_pointer;
|
||||
|
||||
_gdk_event_emit_scroll (NULL, &scroll, TRUE, dx, dy, dx, dy, rest,
|
||||
_gdk_win32_append_event);
|
||||
}
|
||||
|
||||
return_val = TRUE;
|
||||
break;
|
||||
|
|
@ -3169,8 +3361,8 @@ gdk_event_translate (MSG *msg,
|
|||
{
|
||||
/* Resize in increments relative to the base size */
|
||||
rect.left = rect.top = 0;
|
||||
rect.right = impl->hints.base_width;
|
||||
rect.bottom = impl->hints.base_height;
|
||||
rect.right = GDK_WIN32_SC (impl->hints.base_width);
|
||||
rect.bottom = GDK_WIN32_SC (impl->hints.base_height);
|
||||
_gdk_win32_adjust_client_rect (window, &rect);
|
||||
point.x = rect.left;
|
||||
point.y = rect.top;
|
||||
|
|
@ -3192,53 +3384,53 @@ gdk_event_translate (MSG *msg,
|
|||
case WMSZ_BOTTOM:
|
||||
if (drag->bottom == rect.bottom)
|
||||
break;
|
||||
adjust_drag (&drag->bottom, rect.bottom, impl->hints.height_inc);
|
||||
adjust_drag (&drag->bottom, rect.bottom, GDK_WIN32_SC (impl->hints.height_inc));
|
||||
break;
|
||||
|
||||
case WMSZ_BOTTOMLEFT:
|
||||
if (drag->bottom == rect.bottom && drag->left == rect.left)
|
||||
break;
|
||||
adjust_drag (&drag->bottom, rect.bottom, impl->hints.height_inc);
|
||||
adjust_drag (&drag->left, rect.left, impl->hints.width_inc);
|
||||
adjust_drag (&drag->bottom, rect.bottom, GDK_WIN32_SC (impl->hints.height_inc));
|
||||
adjust_drag (&drag->left, rect.left, GDK_WIN32_SC (impl->hints.width_inc));
|
||||
break;
|
||||
|
||||
case WMSZ_LEFT:
|
||||
if (drag->left == rect.left)
|
||||
break;
|
||||
adjust_drag (&drag->left, rect.left, impl->hints.width_inc);
|
||||
adjust_drag (&drag->left, rect.left, GDK_WIN32_SC (impl->hints.width_inc));
|
||||
break;
|
||||
|
||||
case WMSZ_TOPLEFT:
|
||||
if (drag->top == rect.top && drag->left == rect.left)
|
||||
break;
|
||||
adjust_drag (&drag->top, rect.top, impl->hints.height_inc);
|
||||
adjust_drag (&drag->left, rect.left, impl->hints.width_inc);
|
||||
adjust_drag (&drag->top, rect.top, GDK_WIN32_SC (impl->hints.height_inc));
|
||||
adjust_drag (&drag->left, rect.left, GDK_WIN32_SC (impl->hints.width_inc));
|
||||
break;
|
||||
|
||||
case WMSZ_TOP:
|
||||
if (drag->top == rect.top)
|
||||
break;
|
||||
adjust_drag (&drag->top, rect.top, impl->hints.height_inc);
|
||||
adjust_drag (&drag->top, rect.top, GDK_WIN32_SC (impl->hints.height_inc));
|
||||
break;
|
||||
|
||||
case WMSZ_TOPRIGHT:
|
||||
if (drag->top == rect.top && drag->right == rect.right)
|
||||
break;
|
||||
adjust_drag (&drag->top, rect.top, impl->hints.height_inc);
|
||||
adjust_drag (&drag->right, rect.right, impl->hints.width_inc);
|
||||
adjust_drag (&drag->top, rect.top, GDK_WIN32_SC (impl->hints.height_inc));
|
||||
adjust_drag (&drag->right, rect.right, GDK_WIN32_SC (impl->hints.width_inc));
|
||||
break;
|
||||
|
||||
case WMSZ_RIGHT:
|
||||
if (drag->right == rect.right)
|
||||
break;
|
||||
adjust_drag (&drag->right, rect.right, impl->hints.width_inc);
|
||||
adjust_drag (&drag->right, rect.right, GDK_WIN32_SC (impl->hints.width_inc));
|
||||
break;
|
||||
|
||||
case WMSZ_BOTTOMRIGHT:
|
||||
if (drag->bottom == rect.bottom && drag->right == rect.right)
|
||||
break;
|
||||
adjust_drag (&drag->bottom, rect.bottom, impl->hints.height_inc);
|
||||
adjust_drag (&drag->right, rect.right, impl->hints.width_inc);
|
||||
adjust_drag (&drag->bottom, rect.bottom, GDK_WIN32_SC (impl->hints.height_inc));
|
||||
adjust_drag (&drag->right, rect.right, GDK_WIN32_SC (impl->hints.width_inc));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -3375,8 +3567,8 @@ gdk_event_translate (MSG *msg,
|
|||
if (impl->hint_flags & GDK_HINT_MIN_SIZE)
|
||||
{
|
||||
rect.left = rect.top = 0;
|
||||
rect.right = impl->hints.min_width;
|
||||
rect.bottom = impl->hints.min_height;
|
||||
rect.right = GDK_WIN32_SC (impl->hints.min_width);
|
||||
rect.bottom = GDK_WIN32_SC (impl->hints.min_height);
|
||||
|
||||
_gdk_win32_adjust_client_rect (window, &rect);
|
||||
|
||||
|
|
@ -3389,8 +3581,8 @@ gdk_event_translate (MSG *msg,
|
|||
int maxw, maxh;
|
||||
|
||||
rect.left = rect.top = 0;
|
||||
rect.right = impl->hints.max_width;
|
||||
rect.bottom = impl->hints.max_height;
|
||||
rect.right = GDK_WIN32_SC (impl->hints.max_width);
|
||||
rect.bottom = GDK_WIN32_SC (impl->hints.max_height);
|
||||
|
||||
_gdk_win32_adjust_client_rect (window, &rect);
|
||||
|
||||
|
|
@ -3402,8 +3594,36 @@ gdk_event_translate (MSG *msg,
|
|||
}
|
||||
else
|
||||
{
|
||||
/* Apparently, this is just a very big number (bigger than any widget
|
||||
* could realistically be) to make sure the window is as big as
|
||||
* possible when maximized.
|
||||
*/
|
||||
mmi->ptMaxTrackSize.x = 30000;
|
||||
mmi->ptMaxTrackSize.y = 30000;
|
||||
|
||||
/* A window without a frame would be maximized over the whole
|
||||
* monitor, taskbar included. Windows wants the maximized position
|
||||
* and size as if the window were on the primary monitor, so only
|
||||
* the taskbar of the nearest monitor is taken into account.
|
||||
*/
|
||||
if ((GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE) &
|
||||
(WS_BORDER | WS_THICKFRAME)) == 0)
|
||||
{
|
||||
HMONITOR nearest_monitor;
|
||||
MONITORINFO nearest_info;
|
||||
|
||||
nearest_monitor = MonitorFromWindow (GDK_WINDOW_HWND (window),
|
||||
MONITOR_DEFAULTTONEAREST);
|
||||
nearest_info.cbSize = sizeof (nearest_info);
|
||||
|
||||
if (GetMonitorInfoA (nearest_monitor, &nearest_info))
|
||||
{
|
||||
mmi->ptMaxPosition.x = nearest_info.rcWork.left - nearest_info.rcMonitor.left;
|
||||
mmi->ptMaxPosition.y = nearest_info.rcWork.top - nearest_info.rcMonitor.top;
|
||||
mmi->ptMaxSize.x = nearest_info.rcWork.right - nearest_info.rcWork.left;
|
||||
mmi->ptMaxSize.y = nearest_info.rcWork.bottom - nearest_info.rcWork.top;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (impl->hint_flags & (GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE))
|
||||
|
|
@ -3533,6 +3753,21 @@ gdk_event_translate (MSG *msg,
|
|||
break;
|
||||
}
|
||||
}
|
||||
else if (msg->wParam == CF_HDROP)
|
||||
{
|
||||
/* the URIs of the clipboard as files for Explorer */
|
||||
_delayed_rendering_data =
|
||||
_gdk_win32_selection_convert_to_hdrop (_delayed_rendering_data);
|
||||
if (!_delayed_rendering_data)
|
||||
break;
|
||||
}
|
||||
else if (msg->wParam == _cf_preferred_drop_effect)
|
||||
{
|
||||
_delayed_rendering_data =
|
||||
_gdk_win32_selection_convert_to_drop_effect (_delayed_rendering_data);
|
||||
if (!_delayed_rendering_data)
|
||||
break;
|
||||
}
|
||||
|
||||
/* The requestor is holding the clipboard, no
|
||||
* OpenClipboard() is required/possible
|
||||
|
|
@ -3654,7 +3889,7 @@ gdk_event_prepare (GSource *source,
|
|||
|
||||
retval = (_gdk_event_queue_find_first (_gdk_display) != NULL ||
|
||||
(modal_win32_dialog == NULL &&
|
||||
GetQueueStatus (QS_ALLINPUT) != 0));
|
||||
GetQueueStatus (GDK_QS_INPUT) != 0));
|
||||
|
||||
GDK_THREADS_LEAVE ();
|
||||
|
||||
|
|
@ -3672,7 +3907,7 @@ gdk_event_check (GSource *source)
|
|||
{
|
||||
retval = (_gdk_event_queue_find_first (_gdk_display) != NULL ||
|
||||
(modal_win32_dialog == NULL &&
|
||||
GetQueueStatus (QS_ALLINPUT) != 0));
|
||||
GetQueueStatus (GDK_QS_INPUT) != 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -887,7 +887,6 @@ gdk_font_load_logfont (LOGFONT *lfp)
|
|||
}
|
||||
else
|
||||
break;
|
||||
tries++;
|
||||
}
|
||||
|
||||
if (!hfont)
|
||||
|
|
|
|||
|
|
@ -173,10 +173,12 @@ fixup_pen (GdkGCWin32 *win32_gc)
|
|||
win32_gc->pen_num_dashes = 1;
|
||||
}
|
||||
|
||||
if (!(win32_gc->pen_style & PS_TYPE_MASK) == PS_GEOMETRIC &&
|
||||
/* single dots of a cosmetic pen: what PS_ALTERNATE is for (the
|
||||
* test said "not geometric" in a way that was never true) */
|
||||
if ((win32_gc->pen_style & PS_TYPE_MASK) == PS_COSMETIC &&
|
||||
win32_gc->pen_dashes[0] == 1 &&
|
||||
(win32_gc->pen_num_dashes == 1 ||
|
||||
(win32_gc->pen_num_dashes == 2 && win32_gc->pen_dashes[0] == 1)))
|
||||
(win32_gc->pen_num_dashes == 2 && win32_gc->pen_dashes[1] == 1)))
|
||||
win32_gc->pen_style |= PS_ALTERNATE;
|
||||
else
|
||||
win32_gc->pen_style |= PS_USERSTYLE;
|
||||
|
|
@ -745,7 +747,7 @@ static GdkDrawableImplWin32 *
|
|||
get_impl_drawable (GdkDrawable *drawable)
|
||||
{
|
||||
if (GDK_IS_OFFSCREEN_WINDOW (drawable))
|
||||
return _gdk_offscreen_window_get_real_drawable (GDK_OFFSCREEN_WINDOW (drawable));
|
||||
return GDK_DRAWABLE_IMPL_WIN32 (_gdk_offscreen_window_get_real_drawable (GDK_OFFSCREEN_WINDOW (drawable)));
|
||||
if (GDK_IS_DRAWABLE_IMPL_WIN32 (drawable))
|
||||
return GDK_DRAWABLE_IMPL_WIN32(drawable);
|
||||
else if (GDK_IS_WINDOW (drawable))
|
||||
|
|
@ -808,6 +810,49 @@ get_impl_drawable (GdkDrawable *drawable)
|
|||
*
|
||||
* Return value: The HDC.
|
||||
**/
|
||||
/* HiDPI: a logical unit of the DC as @scale of its pixels (1 for the
|
||||
* pixels themselves) */
|
||||
void
|
||||
_gdk_win32_dc_set_scale (HDC hdc,
|
||||
gint scale)
|
||||
{
|
||||
if (_gdk_win32_scale <= 1)
|
||||
return;
|
||||
|
||||
if (scale > 1)
|
||||
{
|
||||
SetMapMode (hdc, MM_ANISOTROPIC);
|
||||
SetWindowExtEx (hdc, 1, 1, NULL);
|
||||
SetViewportExtEx (hdc, scale, scale, NULL);
|
||||
}
|
||||
else
|
||||
SetMapMode (hdc, MM_TEXT);
|
||||
}
|
||||
|
||||
/* an HRGN of logical units of GDK as one of Windows */
|
||||
HRGN
|
||||
_gdk_win32_hrgn_scale (HRGN hrgn)
|
||||
{
|
||||
XFORM xform = { 0 };
|
||||
DWORD size;
|
||||
RGNDATA *data;
|
||||
HRGN result;
|
||||
|
||||
if (_gdk_win32_scale <= 1 || (size = GetRegionData (hrgn, 0, NULL)) == 0)
|
||||
return hrgn;
|
||||
|
||||
data = g_malloc (size);
|
||||
GetRegionData (hrgn, size, data);
|
||||
xform.eM11 = xform.eM22 = (FLOAT) _gdk_win32_scale;
|
||||
result = ExtCreateRegion (&xform, size, data);
|
||||
g_free (data);
|
||||
if (!result)
|
||||
return hrgn;
|
||||
|
||||
DeleteObject (hrgn);
|
||||
return result;
|
||||
}
|
||||
|
||||
HDC
|
||||
gdk_win32_hdc_get (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
|
|
@ -830,6 +875,11 @@ gdk_win32_hdc_get (GdkDrawable *drawable,
|
|||
if (ok && (win32_gc->saved_dc = SaveDC (win32_gc->hdc)) == 0)
|
||||
WIN32_GDI_FAILED ("SaveDC"), ok = FALSE;
|
||||
|
||||
/* HiDPI: GDK draws in its pixels, Windows maps them to its own (the
|
||||
* DC goes back to them with RestoreDC in gdk_win32_hdc_release) */
|
||||
if (ok)
|
||||
_gdk_win32_dc_set_scale (win32_gc->hdc, _gdk_win32_drawable_scale (GDK_DRAWABLE (impl)));
|
||||
|
||||
if (ok && (usage & (GDK_GC_FOREGROUND | GDK_GC_BACKGROUND)))
|
||||
ok = predraw (gc, impl->colormap);
|
||||
|
||||
|
|
@ -873,6 +923,23 @@ gdk_win32_hdc_get (GdkDrawable *drawable,
|
|||
style = win32_gc->pen_dashes;
|
||||
}
|
||||
|
||||
/* a cosmetic pen is one pixel of Windows wide, whatever the
|
||||
* mapping; a geometric one gets as wide as GDK's pixel */
|
||||
if (_gdk_win32_scale > 1 &&
|
||||
(win32_gc->pen_style & PS_TYPE_MASK) == PS_COSMETIC)
|
||||
win32_gc->pen_style = (win32_gc->pen_style & ~(PS_TYPE_MASK | PS_STYLE_MASK)) |
|
||||
PS_GEOMETRIC | PS_ENDCAP_FLAT |
|
||||
((win32_gc->pen_style & PS_STYLE_MASK) == PS_ALTERNATE
|
||||
? PS_USERSTYLE : (win32_gc->pen_style & PS_STYLE_MASK));
|
||||
|
||||
if ((win32_gc->pen_style & PS_STYLE_MASK) == PS_USERSTYLE && !style)
|
||||
{
|
||||
static const DWORD dots[2] = { 1, 1 };
|
||||
|
||||
style_count = win32_gc->pen_dashes ? win32_gc->pen_num_dashes : 2;
|
||||
style = win32_gc->pen_dashes ? win32_gc->pen_dashes : dots;
|
||||
}
|
||||
|
||||
if ((hpen = ExtCreatePen (win32_gc->pen_style,
|
||||
MAX (win32_gc->pen_width, 1),
|
||||
&logbrush,
|
||||
|
|
@ -906,6 +973,7 @@ gdk_win32_hdc_get (GdkDrawable *drawable,
|
|||
|
||||
if (ok && win32_gc->values_mask & (GDK_GC_CLIP_X_ORIGIN | GDK_GC_CLIP_Y_ORIGIN) &&
|
||||
OffsetClipRgn (win32_gc->hdc,
|
||||
/* logical units: the mapping scales them */
|
||||
win32_gc->values_mask & GDK_GC_CLIP_X_ORIGIN ? gc->clip_x_origin : 0,
|
||||
win32_gc->values_mask & GDK_GC_CLIP_Y_ORIGIN ? gc->clip_y_origin : 0) == ERROR)
|
||||
WIN32_API_FAILED ("OffsetClipRgn"), ok = FALSE;
|
||||
|
|
@ -1010,8 +1078,11 @@ _gdk_win32_bitmap_to_hrgn (GdkPixmap *pixmap)
|
|||
g_assert (GDK_PIXMAP_OBJECT(pixmap)->depth == 1);
|
||||
|
||||
bits = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl)->bits;
|
||||
/* the bits, so an HRGN in pixels of Windows (HiDPI) */
|
||||
width = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl)->width;
|
||||
height = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl)->height;
|
||||
width *= MAX (GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl)->scale, 1);
|
||||
height *= MAX (GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl)->scale, 1);
|
||||
bpl = ((width - 1)/32 + 1)*4;
|
||||
|
||||
/* For better performances, we will use the ExtCreateRegion()
|
||||
|
|
@ -1104,6 +1175,10 @@ _gdk_win32_bitmap_to_hrgn (GdkPixmap *pixmap)
|
|||
/* Clean up*/
|
||||
g_free (pData);
|
||||
|
||||
/* a bitmap of a GdkImage has GDK's pixels (HiDPI) */
|
||||
if (hRgn && GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl)->scale <= 1)
|
||||
hRgn = _gdk_win32_hrgn_scale (hRgn);
|
||||
|
||||
return hRgn;
|
||||
}
|
||||
|
||||
|
|
@ -1131,10 +1206,11 @@ _gdk_win32_gdkregion_to_hrgn (const GdkRegion *region,
|
|||
{
|
||||
rect = ((RECT *) rgndata->Buffer) + rgndata->rdh.nCount++;
|
||||
|
||||
rect->left = boxes[i].x1 + x_origin;
|
||||
rect->right = boxes[i].x2 + x_origin;
|
||||
rect->top = boxes[i].y1 + y_origin;
|
||||
rect->bottom = boxes[i].y2 + y_origin;
|
||||
/* a region of GDK, an HRGN in pixels of Windows */
|
||||
rect->left = GDK_WIN32_SC (boxes[i].x1 + x_origin);
|
||||
rect->right = GDK_WIN32_SC (boxes[i].x2 + x_origin);
|
||||
rect->top = GDK_WIN32_SC (boxes[i].y1 + y_origin);
|
||||
rect->bottom = GDK_WIN32_SC (boxes[i].y2 + y_origin);
|
||||
|
||||
if (rect->left < rgndata->rdh.rcBound.left)
|
||||
rgndata->rdh.rcBound.left = rect->left;
|
||||
|
|
|
|||
|
|
@ -59,14 +59,12 @@ _gdk_window_move_resize_child (GdkWindow *window,
|
|||
gint width,
|
||||
gint height)
|
||||
{
|
||||
GdkWindowImplWin32 *impl;
|
||||
GdkWindowObject *obj;
|
||||
|
||||
g_return_if_fail (window != NULL);
|
||||
g_return_if_fail (GDK_IS_WINDOW (window));
|
||||
|
||||
obj = GDK_WINDOW_OBJECT (window);
|
||||
impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
|
||||
|
||||
GDK_NOTE (MISC, g_print ("_gdk_window_move_resize_child: %s@%+d%+d %dx%d@%+d%+d\n",
|
||||
_gdk_win32_drawable_description (window),
|
||||
|
|
@ -97,8 +95,9 @@ _gdk_window_move_resize_child (GdkWindow *window,
|
|||
width, height));
|
||||
|
||||
API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), NULL,
|
||||
obj->x + obj->parent->abs_x, obj->y + obj->parent->abs_y,
|
||||
width, height,
|
||||
GDK_WIN32_SC (obj->x + obj->parent->abs_x),
|
||||
GDK_WIN32_SC (obj->y + obj->parent->abs_y),
|
||||
GDK_WIN32_SC (width), GDK_WIN32_SC (height),
|
||||
SWP_NOACTIVATE | SWP_NOZORDER));
|
||||
|
||||
//_gdk_win32_window_tmp_reset_parent_bg (window);
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ gint _gdk_num_monitors;
|
|||
GdkWin32Monitor *_gdk_monitors = NULL;
|
||||
|
||||
gint _gdk_offset_x, _gdk_offset_y;
|
||||
gint _gdk_win32_scale = 1;
|
||||
|
||||
HDC _gdk_display_hdc;
|
||||
HINSTANCE _gdk_dll_hinstance;
|
||||
|
|
@ -69,6 +70,8 @@ UINT _cf_png;
|
|||
UINT _cf_jfif;
|
||||
UINT _cf_gif;
|
||||
UINT _cf_url;
|
||||
UINT _cf_preferred_drop_effect;
|
||||
GdkAtom _gnome_copied_files;
|
||||
UINT _cf_html_format;
|
||||
UINT _cf_text_html;
|
||||
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ gdk_image_new_bitmap (GdkVisual *visual,
|
|||
gint data_bpl = (w-1)/8 + 1;
|
||||
gint i;
|
||||
|
||||
pixmap = gdk_pixmap_new (NULL, w, h, 1);
|
||||
pixmap = _gdk_win32_pixmap_new_unscaled (w, h, 1);
|
||||
|
||||
if (pixmap == NULL)
|
||||
return NULL;
|
||||
|
|
@ -223,7 +223,7 @@ _gdk_image_new_for_depth (GdkScreen *screen,
|
|||
if (visual)
|
||||
depth = visual->depth;
|
||||
|
||||
pixmap = gdk_pixmap_new (NULL, width, height, depth);
|
||||
pixmap = _gdk_win32_pixmap_new_unscaled (width, height, depth);
|
||||
|
||||
if (pixmap == NULL)
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -675,7 +675,6 @@ gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev,
|
|||
gdouble *y_out)
|
||||
{
|
||||
GdkWindowObject *priv, *impl_window;
|
||||
GdkWindowImplWin32 *root_impl;
|
||||
|
||||
int i;
|
||||
int x_axis = 0;
|
||||
|
|
@ -709,7 +708,6 @@ gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev,
|
|||
|
||||
if (gdkdev->info.mode == GDK_MODE_SCREEN)
|
||||
{
|
||||
root_impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (_gdk_root)->impl);
|
||||
x_scale = GDK_WINDOW_OBJECT (_gdk_root)->width / device_width;
|
||||
y_scale = GDK_WINDOW_OBJECT (_gdk_root)->height / device_height;
|
||||
|
||||
|
|
@ -747,12 +745,12 @@ gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev,
|
|||
switch (gdkdev->info.axes[i].use)
|
||||
{
|
||||
case GDK_AXIS_X:
|
||||
axis_out[i] = x_offset + x_scale * axis_data[x_axis];
|
||||
axis_out[i] = x_offset + x_scale * (axis_data[x_axis] - x_min);
|
||||
if (x_out)
|
||||
*x_out = axis_out[i];
|
||||
break;
|
||||
case GDK_AXIS_Y:
|
||||
axis_out[i] = y_offset + y_scale * axis_data[y_axis];
|
||||
axis_out[i] = y_offset + y_scale * (axis_data[y_axis] - y_min);
|
||||
if (y_out)
|
||||
*y_out = axis_out[i];
|
||||
break;
|
||||
|
|
@ -778,9 +776,9 @@ gdk_input_get_root_relative_geometry (HWND w,
|
|||
ClientToScreen (w, &pt);
|
||||
|
||||
if (x_ret)
|
||||
*x_ret = pt.x + _gdk_offset_x;
|
||||
*x_ret = GDK_WIN32_SCREEN_TO_ROOT_X (pt.x);
|
||||
if (y_ret)
|
||||
*y_ret = pt.y + _gdk_offset_y;
|
||||
*y_ret = GDK_WIN32_SCREEN_TO_ROOT_Y (pt.y);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -1289,7 +1289,7 @@ gdk_keymap_get_entries_for_keyval (GdkKeymap *gdk_keymap,
|
|||
else
|
||||
keymap = GDK_WIN32_KEYMAP (gdk_keymap);
|
||||
|
||||
update_keymap (gdk_keymap);
|
||||
update_keymap (GDK_KEYMAP (keymap));
|
||||
|
||||
for (vk = 0; vk < KEY_STATE_SIZE; vk++)
|
||||
{
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue