AC_SUBST(LCMS_CFLAGS)
AC_SUBST(LCMS_LIBS)
+# libjpeg support
+# ----------------------------------------------------------------------
+
+AC_ARG_ENABLE([jpeg],
+ AC_HELP_STRING([--disable-jpeg], [disable direct jpeg support]),
+ [libjpeg=$enableval], [libjpeg=auto])
+
+if test "x${libjpeg}" != "xno"; then
+ AC_CHECK_LIB(jpeg, jpeg_destroy_decompress,
+ HAVE_JPEG=yes
+ JPEG_LIBS=-ljpeg
+ AC_DEFINE(HAVE_JPEG, 1, [define to enable use of custom jpeg loader]),
+ HAVE_JPEG=no)
+else
+ HAVE_JPEG=disabled
+fi
+
+AM_CONDITIONAL(HAVE_JPEG, [test "x$HAVE_JPEG" = xyes])
+AC_SUBST(JPEG_CFLAGS)
+AC_SUBST(JPEG_LIBS)
+
+
+# libtiff support
+# ----------------------------------------------------------------------
+
+AC_ARG_ENABLE([tiff],
+ AC_HELP_STRING([--disable-tiff], [disable direct tiff support]),
+ [libtiff=$enableval], [libtiff=auto])
+
+if test "x${libtiff}" != "xno"; then
+ AC_CHECK_LIB(tiff, TIFFClientOpen,
+ HAVE_TIFF=yes
+ TIFF_LIBS=-ltiff
+ AC_DEFINE(HAVE_TIFF, 1, [define to enable use of custom tiff loader]),
+ HAVE_TIFF=no)
+else
+ HAVE_TIFF=disabled
+fi
+
+AM_CONDITIONAL(HAVE_TIFF, [test "x$HAVE_TIFF" = xyes])
+AC_SUBST(TIFF_CFLAGS)
+AC_SUBST(TIFF_LIBS)
+
# Exiv2 support
# ----------------------------------------------------------------------
Gtk: $GTK_CFLAGS
Glib: $GLIB_CFLAGS
Thread: $GTHREAD_LIBS
- Others: $LCMS_LIBS $EXIV2_LIBS $LIBCHAMPLAIN_LIBS $LIBCHAMPLAIN_GTK_LIBS
+ Others: $JPEG_LIBS $TIFF_LIBS $LCMS_LIBS $EXIV2_LIBS $LIBCHAMPLAIN_LIBS $LIBCHAMPLAIN_GTK_LIBS
Localization:
NLS support: $USE_NLS
-Preamble\r
---------\r
-The intent of this document is to state the conditions under which a\r
-Package may be copied, such that the Copyright Holder maintains some\r
-semblance of artistic control over the development of the package,\r
-while giving the users of the package the right to use and distribute\r
-the Package in a more-or-less customary fashion, plus the right to\r
-make reasonable modifications.\r
-\r
-Definitions\r
------------\r
-"Package" refers to the collection of files distributed by the\r
-Copyright Holder, and derivatives of that collection of files created\r
-through textual modification.\r
-\r
-"Standard Version" refers to such a Package if it has not been\r
-modified, or has been modified in accordance with the wishes of the\r
-Copyright Holder as specified below.\r
-\r
-"Copyright Holder" is whoever is named in the copyright or copyrights\r
-for the package.\r
-\r
-"You" is you, if you're thinking about copying or distributing this\r
-Package.\r
-\r
-"Reasonable copying fee" is whatever you can justify on the basis of\r
-media cost, duplication charges, time of people involved, and so\r
-on. (You will not be required to justify it to the Copyright Holder,\r
-but only to the computing community at large as a market that must\r
-bear the fee.)\r
-\r
-"Freely Available" means that no fee is charged for the item itself,\r
-though there may be fees involved in handling the item. It also means\r
-that recipients of the item may redistribute it under the same\r
-conditions they received it.\r
-\r
-\r
-You may make and give away verbatim copies of the source form of the\r
-Standard Version of this Package without restriction, provided that\r
-you duplicate all of the original copyright notices and associated\r
-disclaimers.\r
-\r
-\r
-You may apply bug fixes, portability fixes and other modifications\r
-derived from the Public Domain or from the Copyright Holder. A Package\r
-modified in such a way shall still be considered the Standard Version.\r
-\r
-\r
-You may otherwise modify your copy of this Package in any way,\r
-provided that you insert a prominent notice in each changed file\r
-stating how and when you changed that file, and provided that you do\r
-at least ONE of the following:\r
-\r
-- place your modifications in the Public Domain or otherwise make them\r
- Freely Available, such as by posting said modifications to Usenet or\r
- an equivalent medium, or placing the modifications on a major\r
- archive site such as uunet.uu.net, or by allowing the Copyright\r
- Holder to include your modifications in the Standard Version of the\r
- Package.\r
-- use the modified Package only within your corporation or\r
- organization. \r
-- rename any non-standard executables so the names do not conflict\r
- with standard executables, which must also be provided, and provide\r
- a separate manual page for each non-standard executable that clearly\r
- documents how it differs from the Standard Version.\r
-- make other distribution arrangements with the Copyright Holder.\r
-\r
-\r
-You may distribute the programs of this Package in object code or\r
-executable form, provided that you do at least ONE of the following:\r
-\r
-- distribute a Standard Version of the executables and library files,\r
- together with instructions (in the manual page or equivalent) on\r
- where to get the Standard Version.\r
-- accompany the distribution with the machine-readable source of the\r
- Package with your modifications.\r
-- give non-standard executables non-standard names, and clearly\r
- document the differences in manual pages (or equivalent), together\r
- with instructions on where to get the Standard Version.\r
-- make other distribution arrangements with the Copyright Holder. \r
-\r
-\r
-You may charge a reasonable copying fee for any distribution of this\r
-Package. You may charge any fee you choose for support of this\r
-Package. You may not charge a fee for this Package itself. However,\r
-you may distribute this Package in aggregate with other (possibly\r
-commercial) programs as part of a larger (possibly commercial)\r
-software distribution provided that you do not advertise this Package\r
-as a product of your own. You may embed this Package's interpreter\r
-within an executable of yours (by linking); this shall be construed as\r
-a mere form of aggregation, provided that the complete Standard\r
-Version of the interpreter is so embedded.\r
-\r
-\r
-The scripts and library files supplied as input to or produced as\r
-output from the programs of this Package do not automatically fall\r
-under the copyright of this Package, but belong to whomever generated\r
-them, and may be sold commercially, and may be aggregated with this\r
-Package. If such scripts or library files are aggregated with this\r
-Package via the so-called "undump" or "unexec" methods of producing a\r
-binary executable image, then distribution of such an image shall\r
-neither be construed as a distribution of this Package nor shall it\r
-fall under the restrictions of Paragraphs 3 and 4, provided that you\r
-do not represent such an executable image as a Standard Version of\r
-this Package.\r
-\r
-\r
-C subroutines (or comparably compiled subroutines in other languages)\r
-supplied by you and linked into this Package in order to emulate\r
-subroutines and variables of the language defined by this Package\r
-shall not be considered part of this Package, but are the equivalent\r
-of input as in Paragraph 6, provided these subroutines do not change\r
-the language in any way that would cause it to fail the regression\r
-tests for the language.\r
-\r
-\r
-Aggregation of this Package with a commercial distribution is always\r
-permitted provided that the use of this Package is embedded; that is,\r
-when no overt attempt is made to make this Package's interfaces\r
-visible to the end user of the commercial distribution. Such use shall\r
-not be construed as a distribution of this Package.\r
-\r
-\r
-The name of the Copyright Holder may not be used to endorse or promote\r
-products derived from this software without specific prior written\r
-permission.\r
-\r
-\r
-THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED\r
-WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF\r
-MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.\r
-\r
-The End\r
+Preamble
+--------
+The intent of this document is to state the conditions under which a
+Package may be copied, such that the Copyright Holder maintains some
+semblance of artistic control over the development of the package,
+while giving the users of the package the right to use and distribute
+the Package in a more-or-less customary fashion, plus the right to
+make reasonable modifications.
+
+Definitions
+-----------
+"Package" refers to the collection of files distributed by the
+Copyright Holder, and derivatives of that collection of files created
+through textual modification.
+
+"Standard Version" refers to such a Package if it has not been
+modified, or has been modified in accordance with the wishes of the
+Copyright Holder as specified below.
+
+"Copyright Holder" is whoever is named in the copyright or copyrights
+for the package.
+
+"You" is you, if you're thinking about copying or distributing this
+Package.
+
+"Reasonable copying fee" is whatever you can justify on the basis of
+media cost, duplication charges, time of people involved, and so
+on. (You will not be required to justify it to the Copyright Holder,
+but only to the computing community at large as a market that must
+bear the fee.)
+
+"Freely Available" means that no fee is charged for the item itself,
+though there may be fees involved in handling the item. It also means
+that recipients of the item may redistribute it under the same
+conditions they received it.
+
+
+You may make and give away verbatim copies of the source form of the
+Standard Version of this Package without restriction, provided that
+you duplicate all of the original copyright notices and associated
+disclaimers.
+
+
+You may apply bug fixes, portability fixes and other modifications
+derived from the Public Domain or from the Copyright Holder. A Package
+modified in such a way shall still be considered the Standard Version.
+
+
+You may otherwise modify your copy of this Package in any way,
+provided that you insert a prominent notice in each changed file
+stating how and when you changed that file, and provided that you do
+at least ONE of the following:
+
+- place your modifications in the Public Domain or otherwise make them
+ Freely Available, such as by posting said modifications to Usenet or
+ an equivalent medium, or placing the modifications on a major
+ archive site such as uunet.uu.net, or by allowing the Copyright
+ Holder to include your modifications in the Standard Version of the
+ Package.
+- use the modified Package only within your corporation or
+ organization.
+- rename any non-standard executables so the names do not conflict
+ with standard executables, which must also be provided, and provide
+ a separate manual page for each non-standard executable that clearly
+ documents how it differs from the Standard Version.
+- make other distribution arrangements with the Copyright Holder.
+
+
+You may distribute the programs of this Package in object code or
+executable form, provided that you do at least ONE of the following:
+
+- distribute a Standard Version of the executables and library files,
+ together with instructions (in the manual page or equivalent) on
+ where to get the Standard Version.
+- accompany the distribution with the machine-readable source of the
+ Package with your modifications.
+- give non-standard executables non-standard names, and clearly
+ document the differences in manual pages (or equivalent), together
+ with instructions on where to get the Standard Version.
+- make other distribution arrangements with the Copyright Holder.
+
+
+You may charge a reasonable copying fee for any distribution of this
+Package. You may charge any fee you choose for support of this
+Package. You may not charge a fee for this Package itself. However,
+you may distribute this Package in aggregate with other (possibly
+commercial) programs as part of a larger (possibly commercial)
+software distribution provided that you do not advertise this Package
+as a product of your own. You may embed this Package's interpreter
+within an executable of yours (by linking); this shall be construed as
+a mere form of aggregation, provided that the complete Standard
+Version of the interpreter is so embedded.
+
+
+The scripts and library files supplied as input to or produced as
+output from the programs of this Package do not automatically fall
+under the copyright of this Package, but belong to whomever generated
+them, and may be sold commercially, and may be aggregated with this
+Package. If such scripts or library files are aggregated with this
+Package via the so-called "undump" or "unexec" methods of producing a
+binary executable image, then distribution of such an image shall
+neither be construed as a distribution of this Package nor shall it
+fall under the restrictions of Paragraphs 3 and 4, provided that you
+do not represent such an executable image as a Standard Version of
+this Package.
+
+
+C subroutines (or comparably compiled subroutines in other languages)
+supplied by you and linked into this Package in order to emulate
+subroutines and variables of the language defined by this Package
+shall not be considered part of this Package, but are the equivalent
+of input as in Paragraph 6, provided these subroutines do not change
+the language in any way that would cause it to fail the regression
+tests for the language.
+
+
+Aggregation of this Package with a commercial distribution is always
+permitted provided that the use of this Package is embedded; that is,
+when no overt attempt is made to make this Package's interfaces
+visible to the end user of the commercial distribution. Such use shall
+not be construed as a distribution of this Package.
+
+
+The name of the Copyright Holder may not be used to endorse or promote
+products derived from this software without specific prior written
+permission.
+
+
+THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+
+The End
src/image.c
src/image-load.c
src/image-overlay.c
+src/image_load_jpeg.c
src/img-view.c
src/layout.c
src/layout_config.c
#: ../src/bar_exif.c:554
msgid "Key:"
-msgstr "Clé:"
+msgstr "Clé :"
#: ../src/bar_exif.c:563
msgid "Title:"
-msgstr "Titre:"
+msgstr "Titre :"
#: ../src/bar_exif.c:572
msgid "Show only if set"
#: ../src/bar_keywords.c:893
msgid "Keyword:"
-msgstr "Mot-clé:"
+msgstr "Mot-clé :"
#: ../src/bar_keywords.c:902
msgid "Keyword type:"
-msgstr "Type de mot-clé:"
+msgstr "Type de mot-clé :"
#: ../src/bar_keywords.c:904
msgid "Active keyword"
"error: %s\n"
msgstr ""
"erreur à la sauvegarde du fichier de cache des similarités : %s\n"
-"erreur: %s\n"
+"erreur : %s\n"
#: ../src/cache_maint.c:129 ../src/cache_maint.c:722 ../src/cache_maint.c:938
#: ../src/editors.c:1133
#: ../src/cache_maint.c:307
msgid "Removing old metadata..."
-msgstr "Suppression des anciennes méta-données ..."
+msgstr "Suppression des anciennes méta-données..."
#: ../src/cache_maint.c:311
msgid "Clearing cached thumbnails..."
-msgstr "Purge des vignettes en cache ..."
+msgstr "Purge des vignettes en cache..."
#: ../src/cache_maint.c:315 ../src/cache_maint.c:1096
msgid "Removing old thumbnails..."
-msgstr "Suppression des anciennes vignettes ..."
+msgstr "Suppression des anciennes vignettes..."
#: ../src/cache_maint.c:318 ../src/cache_maint.c:1099
msgid "Maintenance"
#: ../src/cache_maint.c:1042 ../src/editors.c:1059
msgid "running..."
-msgstr "en cours ..."
+msgstr "en cours..."
#: ../src/cache_maint.c:1091
msgid "Clearing thumbnails..."
-msgstr "Suppression des vignettes ..."
+msgstr "Suppression des vignettes..."
#: ../src/cache_maint.c:1157 ../src/cache_maint.c:1160
#: ../src/cache_maint.c:1253 ../src/cache_maint.c:1270
#: ../src/cache_maint.c:1203
#, c-format
msgid "Location: %s"
-msgstr "Emplacement: %s"
+msgstr "Emplacement : %s"
#: ../src/cache_maint.c:1228
msgid "Cache Maintenance"
#: ../src/cache_maint.c:1256 ../src/cache_maint.c:1273
msgid "Delete all cached thumbnails."
-msgstr "Éffacer toutes les vignettes en cache."
+msgstr "Effacer toutes les vignettes en cache."
#: ../src/cache_maint.c:1259
msgid "Shared thumbnail cache"
#: ../src/collect-dlg.c:127
#, c-format
msgid "No such file '%s'."
-msgstr "Aucun fichier nommé '%s'"
+msgstr "Aucun fichier nommé « %s »."
#: ../src/collect-dlg.c:132
#, c-format
msgid "'%s' is a directory, not a collection file."
-msgstr "'%s' est un répertoire, pas une collection."
+msgstr "« %s » est un répertoire, pas une collection."
#: ../src/collect-dlg.c:137
#, c-format
msgid "You do not have read permissions on the file '%s'."
-msgstr "Vous n'avez pas la permission de lire le fichier '%s'."
+msgstr "Vous n'avez pas la permission de lire le fichier « %s »."
#: ../src/collect-dlg.c:143
msgid "Can not open collection file"
-msgstr "impossible d'ouvrir la collection"
+msgstr "Impossible d'ouvrir la collection"
#: ../src/collect-dlg.c:195
msgid "Save collection"
"error saving collection file: %s\n"
"error: %s\n"
msgstr ""
-"erreur lors de la sauvegarde de la collection: %s\n"
-"erreur: %s\n"
+"erreur lors de la sauvegarde de la collection : %s\n"
+"erreur : %s\n"
#: ../src/collect-table.c:211
#, c-format
#: ../src/collect-table.c:237 ../src/dupe.c:1319 ../src/search.c:320
#: ../src/view_file.c:822 ../src/view_file.c:925
msgid "Loading thumbs..."
-msgstr "Chargement des vignettes ..."
+msgstr "Chargement des vignettes..."
#: ../src/collect-table.c:866 ../src/dupe.c:2242 ../src/dupe.c:2555
#: ../src/layout_util.c:1237 ../src/search.c:996
#: ../src/collect-table.c:876
msgid "Append from collection..."
-msgstr "Ajouter à partir de la collection ..."
+msgstr "Ajouter à partir de la collection..."
#: ../src/collect-table.c:880
msgid "_Selection"
#: ../src/layout_image.c:506 ../src/layout_util.c:1266 ../src/pan-view.c:2829
#: ../src/search.c:1017 ../src/view_file.c:579
msgid "_Copy..."
-msgstr "_Copier ..."
+msgstr "_Copier..."
#: ../src/collect-table.c:900 ../src/dupe.c:2269 ../src/img-view.c:1286
#: ../src/layout_image.c:508 ../src/layout_util.c:1267 ../src/pan-view.c:2831
#: ../src/search.c:1019 ../src/view_file.c:581
msgid "_Move..."
-msgstr "_Déplacer ..."
+msgstr "_Déplacer..."
#: ../src/collect-table.c:902 ../src/dupe.c:2271 ../src/img-view.c:1287
#: ../src/layout_image.c:510 ../src/layout_util.c:1268 ../src/pan-view.c:2833
#: ../src/search.c:1021 ../src/view_dir.c:665 ../src/view_file.c:583
msgid "_Rename..."
-msgstr "_Renommer ..."
+msgstr "_Renommer..."
#: ../src/collect-table.c:904 ../src/dupe.c:2273 ../src/img-view.c:1288
#: ../src/layout_image.c:512 ../src/layout_util.c:1269
#: ../src/layout_util.c:1270 ../src/layout_util.c:1271 ../src/pan-view.c:2835
#: ../src/search.c:1023 ../src/view_dir.c:667 ../src/view_file.c:585
msgid "_Delete..."
-msgstr "_Supprimer ..."
+msgstr "_Supprimer..."
#: ../src/collect-table.c:906 ../src/dupe.c:2275 ../src/img-view.c:1289
#: ../src/layout_image.c:515 ../src/pan-view.c:2837 ../src/search.c:1025
#: ../src/collect-table.c:922
msgid "Save collection _as..."
-msgstr "Enregistrer collection _sous ..."
+msgstr "Enregistrer collection _sous..."
#: ../src/collect-table.c:925 ../src/layout_util.c:1262
msgid "_Find duplicates..."
-msgstr "Rechercher les _doublons ..."
+msgstr "Rechercher les _doublons..."
#: ../src/collect-table.c:927 ../src/dupe.c:2264 ../src/layout_util.c:1264
#: ../src/search.c:1014
msgid "Print..."
-msgstr "Imprimer ..."
+msgstr "Imprimer..."
#: ../src/collect-table.c:2081 ../src/dupe.c:3351 ../src/img-view.c:1443
msgid "Dropped list includes folders."
#: ../src/dupe.c:1445
msgid "Reading checksums..."
-msgstr "Lecture des sommes de contrôle ..."
+msgstr "Lecture des sommes de contrôle..."
#: ../src/dupe.c:1478
msgid "Reading dimensions..."
-msgstr "Lecture des dimensions ..."
+msgstr "Lecture des dimensions..."
#: ../src/dupe.c:1512
msgid "Reading similarity data..."
-msgstr "Lecture des données de similarité ..."
+msgstr "Lecture des données de similarité..."
#: ../src/dupe.c:1548 ../src/dupe.c:1579
msgid "Comparing..."
-msgstr "Comparaison ..."
+msgstr "Comparaison..."
#: ../src/dupe.c:1559 ../src/pan-view.c:1094
msgid "Sorting..."
-msgstr "Tri ..."
+msgstr "Tri..."
#: ../src/dupe.c:2251
msgid "Select group _1 duplicates"
#, c-format
msgid "Desktop file '%s' should not include extension in Icon key: '%s'\n"
msgstr ""
-"Le fichier .desktop '%s' ne devrait pas inclure l'extension dans la clé "
-"Icon: '%s'\n"
+"Le fichier .desktop « %s » ne devrait pas inclure l'extension dans la clé "
+"Icon : « %s »\n"
#: ../src/editors.c:486
msgid "stopping..."
-msgstr "arrêt ..."
+msgstr "arrêt..."
#: ../src/editors.c:507
msgid "Edit command results"
#: ../src/editors.c:1310
msgid "Can't find matching file type."
-msgstr "Ne peut trouver de type de fichier correspondant."
+msgstr "Ne peut trouver le type de fichier correspondant."
#: ../src/editors.c:1311
msgid "Can't execute external editor."
#: ../src/exif.c:343
msgid "Primary chromaticities"
-msgstr "Chromaticitées Primaires"
+msgstr "Chromaticités Primaires"
#: ../src/exif.c:344
msgid "YCbCy coefficients"
#: ../src/exif-common.c:505
msgid "Above Sea Level"
-msgstr "Au dessus du niveau de la mer"
+msgstr "Au-dessus du niveau de la mer"
#: ../src/exif-common.c:505
msgid "Below Sea Level"
-msgstr "En dessous du niveau de la mer"
+msgstr "En-dessous du niveau de la mer"
#: ../src/exif-common.c:513
msgid "Camera"
#: ../src/filedata.c:2109
msgid "destination directory is not writable"
-msgstr "impossible d'écrire dans le dossier destination"
+msgstr "impossible d'écrire dans le dossier de destination"
#: ../src/filedata.c:2115
msgid "destination directory does not exist"
#: ../src/fullscreen.c:638
msgid "Stay above other windows"
-msgstr "Rester au dessus des autres fenêtres"
+msgstr "Rester au-dessus des autres fenêtres"
#: ../src/fullscreen.c:645
msgid "Determined by Window Manager"
#: ../src/layout.c:1931
msgid "Start-up directory:"
-msgstr "Dossier de démarrage:"
+msgstr "Dossier de démarrage :"
#: ../src/layout.c:1933
msgid "No change"
#: ../src/layout_util.c:1259
msgid "_Open collection..."
-msgstr "_Ouvrir collection ..."
+msgstr "_Ouvrir collection..."
#: ../src/layout_util.c:1259
msgid "Open collection..."
-msgstr "Ouvrir collection ..."
+msgstr "Ouvrir collection..."
#: ../src/layout_util.c:1260
msgid "Open recen_t"
#: ../src/layout_util.c:1261
msgid "_Search..."
-msgstr "_Recherche ..."
+msgstr "_Recherche..."
#: ../src/layout_util.c:1261
msgid "Search..."
-msgstr "Recherche ..."
+msgstr "Recherche..."
#: ../src/layout_util.c:1262
msgid "Find duplicates..."
-msgstr "Rechercher les doublons ..."
+msgstr "Rechercher les doublons..."
#: ../src/layout_util.c:1263
msgid "Pa_n view"
#: ../src/layout_util.c:1264
msgid "_Print..."
-msgstr "_Imprimer ..."
+msgstr "_Imprimer..."
#: ../src/layout_util.c:1265
msgid "N_ew folder..."
-msgstr "Nouv_eau dossier ..."
+msgstr "Nouv_eau dossier..."
#: ../src/layout_util.c:1265
msgid "New folder..."
-msgstr "Nouveau dossier ..."
+msgstr "Nouveau dossier..."
#: ../src/layout_util.c:1266
msgid "Copy..."
-msgstr "Copier ..."
+msgstr "Copier..."
#: ../src/layout_util.c:1267
msgid "Move..."
-msgstr "Déplacer ..."
+msgstr "Déplacer..."
#: ../src/layout_util.c:1268
msgid "Rename..."
-msgstr "Renommer ..."
+msgstr "Renommer..."
#: ../src/layout_util.c:1269 ../src/layout_util.c:1270
#: ../src/layout_util.c:1271
msgid "Delete..."
-msgstr "Supprimer ..."
+msgstr "Supprimer..."
#: ../src/layout_util.c:1272 ../src/view_file.c:590
msgid "Enable file _grouping"
#: ../src/layout_util.c:1282 ../src/menu.c:233
msgid "_Original state"
-msgstr "Etat _original"
+msgstr "État _original"
#: ../src/layout_util.c:1282
msgid "Original state"
-msgstr "Etat original"
+msgstr "État original"
#: ../src/layout_util.c:1283
msgid "Select _all"
#: ../src/layout_util.c:1286
msgid "P_references..."
-msgstr "P_références ..."
+msgstr "P_références..."
#: ../src/layout_util.c:1286
msgid "Preferences..."
-msgstr "Préférences ..."
+msgstr "Préférences..."
#: ../src/layout_util.c:1287
msgid "Configure _Editors..."
-msgstr "Configur_er les éditeurs"
+msgstr "Configur_er les éditeurs..."
#: ../src/layout_util.c:1287
msgid "Configure Editors..."
-msgstr "Configurer les éditeurs"
+msgstr "Configurer les éditeurs..."
#: ../src/layout_util.c:1288
msgid "_Configure this window..."
-msgstr "_Configurer cette fenêtre"
+msgstr "_Configurer cette fenêtre..."
#: ../src/layout_util.c:1288
msgid "Configure this window..."
-msgstr "Configurer cette fenêtre"
+msgstr "Configurer cette fenêtre..."
#: ../src/layout_util.c:1289
msgid "_Thumbnail maintenance..."
-msgstr "Maintenance des _vignettes ..."
+msgstr "Maintenance des _vignettes..."
#: ../src/layout_util.c:1289
msgid "Thumbnail maintenance..."
-msgstr "Maintenance des vignettes ..."
+msgstr "Maintenance des vignettes..."
#: ../src/layout_util.c:1290
msgid "Set as wallpaper"
#: ../src/layout_util.c:1324
msgid "_View in new window"
-msgstr "_Voir dans une _nouvelle fenêtre"
+msgstr "_Voir dans une nouvelle fenêtre"
#: ../src/layout_util.c:1324
msgid "View in new window"
#: ../src/layout_util.c:1330
msgid "_Cycle through overlay modes"
-msgstr "Bou_cler à travers les modes de surimpression"
+msgstr "_Passer en revue les modes de surimpression"
#: ../src/layout_util.c:1330
msgid "Cycle through Overlay modes"
-msgstr "Boucler à travers les modes de surimpression"
+msgstr "Passer en revue les modes de surimpression"
#: ../src/layout_util.c:1331
msgid "Cycle through histogram ch_annels"
-msgstr "Boucler sur les c_anaux d'histogramme"
+msgstr "Passer en revue les c_anaux d'histogramme"
#: ../src/layout_util.c:1331
msgid "Cycle through histogram channels"
-msgstr "Boucler sur les canaux d'histogramme"
+msgstr "Passer en revue les canaux d'histogramme"
#: ../src/layout_util.c:1332
msgid "Cycle through histogram mo_des"
-msgstr "Boucler sur les modes d'histogramme"
+msgstr "Passer en revue les mo_des d'histogramme"
#: ../src/layout_util.c:1332
msgid "Cycle through histogram modes"
-msgstr "Boucler à travers les modes d'histogramme"
+msgstr "Passer en revue les modes d'histogramme"
#: ../src/layout_util.c:1333
msgid "_Hide file list"
-msgstr "Masquer la _liste des fichiers"
+msgstr "_Masquer la liste des fichiers"
#: ../src/layout_util.c:1333
msgid "Hide file list"
#: ../src/layout_util.c:1338
msgid "_Release notes"
-msgstr "_Notes pour cette version"
+msgstr "_Notes de version"
#: ../src/layout_util.c:1338
msgid "Release notes"
#: ../src/layout_util.c:1379
msgid "Input _0: sRGB"
-msgstr "Entrée _0: sRGB"
+msgstr "Entrée _0 : sRGB"
#: ../src/layout_util.c:1379
msgid "Input 0: sRGB"
-msgstr "Entrée 0: sRGB"
+msgstr "Entrée 0 : sRGB"
#: ../src/layout_util.c:1380
msgid "Input _1: AdobeRGB compatible"
-msgstr "Entrée _1: compatible AdobeRGB"
+msgstr "Entrée _1 : compatible AdobeRGB"
#: ../src/layout_util.c:1380
msgid "Input 1: AdobeRGB compatible"
-msgstr "Entrée 1: compatible AdobeRGB"
+msgstr "Entrée 1 : compatible AdobeRGB"
#: ../src/layout_util.c:1381
msgid "Input _2"
#: ../src/layout_util.c:2109
#, c-format
msgid "Number of files with unsaved metadata: %d"
-msgstr "Nombre de fichiers avec des méta-données à sauver: %d"
+msgstr "Nombre de fichiers avec des méta-données à sauver : %d"
#: ../src/layout_util.c:2115
msgid "No unsaved metadata"
#: ../src/layout_util.c:2197
#, c-format
msgid "Input _%d: %s"
-msgstr "Entrée _%d: %s"
+msgstr "Entrée _%d : %s"
#. something went badly wrong
#: ../src/lirc.c:193
"Usage: %s [options] [path]\n"
"\n"
msgstr ""
-"Utilisation: %s [options] [chemin]\n"
+"Utilisation : %s [options] [chemin]\n"
"\n"
#: ../src/main.c:314
#: ../src/main.c:320
msgid " --geometry=GEOMETRY set main window location\n"
msgstr ""
-" --geometry=GEOMETRIE détermine la position de la fenêtre principale\n"
+" --geometry=GEOMÉTRIE détermine la position de la fenêtre principale\n"
#: ../src/main.c:321
msgid " -r, --remote send following commands to open window\n"
msgstr ""
-" -r, --remote lance la commande suivante pour ouvrir un "
+" -r, --remote lance la commande suivante pour ouvrir une "
"fenêtre\n"
"de commande\n"
#: ../src/main.c:324
msgid " --debug[=level] turn on debug output\n"
-msgstr " --debug[=niveau] active les sorties de déboguage\n"
+msgstr " --debug[=niveau] active les sorties de débogage\n"
#: ../src/main.c:326
msgid " -v, --version print version info\n"
"Use --help for options\n"
msgstr ""
"invalide ou ignoré : %s\n"
-"Utiliser --help pour connaître les options\n"
+"Utilisez --help pour connaître les options\n"
#: ../src/main.c:368
msgid "Invalid or ignored remote options: "
-msgstr "Options de commande à distance invalides ou ignorées:"
+msgstr "Options de commande à distance invalides ou ignorées :"
#: ../src/main.c:377
msgid ""
"error: %s\n"
msgstr ""
"erreur lors de la sauvegarde du fichier : %s\n"
-"erreur: %s\n"
+"erreur : %s\n"
#: ../src/main.c:659
msgid "exit"
#: ../src/pan-view.c:1084 ../src/pan-view.c:1100
msgid "Reading image data..."
-msgstr "Lecture des données de l'image ..."
+msgstr "Lecture des données de l'image..."
#: ../src/pan-view.c:1159
msgid "Sorting images..."
-msgstr "Tri des images ..."
+msgstr "Tri des images..."
#: ../src/pan-view.c:1546 ../src/print.c:2650
msgid "Filename:"
"performance."
msgstr ""
"Pour améliorer la vitesse de génération des vignettes dans la vue "
-"panoramique les options suivantes peuvent être utilisées. Notez que les deux "
+"panoramique, les options suivantes peuvent être utilisées. Notez que les deux "
"options doivent être validées pour apprécier un changement dans les "
"performances."
#: ../src/preferences.c:792
msgid "This will remove the trash contents."
-msgstr "Ceci va supprimer le contenu de la corbeille"
+msgstr "Ceci va supprimer le contenu de la corbeille."
#: ../src/preferences.c:836 ../src/preferences.c:839
msgid "Reset image overlay template string"
#: ../src/preferences.c:1257
msgid "Limit image size when autofitting (%):"
-msgstr "Limiter la taille de l'image lors de l'auto-dimensionnement (%):"
+msgstr "Limiter la taille de l'image lors de l'auto-dimensionnement (%) :"
#: ../src/preferences.c:1265
msgid "Zoom increment:"
#: ../src/preferences.c:1274
msgid "Zoom to original size"
-msgstr "Zoom à sa taille d'origine"
+msgstr "Zoom à la taille d'origine"
#: ../src/preferences.c:1277
msgid "Fit image to window"
"disappear when no data is available.\n"
msgstr ""
"<i>%name%</i> correspond au nom de l'image.\n"
-"Aussi disponibles: <i>%collection%</i>, <i>%number%</i>, <i>%total%</i>, <i>%"
+"Aussi disponibles : <i>%collection%</i>, <i>%number%</i>, <i>%total%</i>, <i>%"
"date%</i>,\n"
"<i>%size%</i> (taille du fichier), <i>%width%</i> (largeur), <i>%height%</i> "
"(hauteur), <i>%res%</i> (résolution)\n"
"La notation <i>%formatted.Camera:20</i> permet de tronquer l'affichage de "
"cette donnée à 20 caractères, 3 points seront ajoutés à la fin pour "
"l'indiquer.\n"
-"Si deux variables ou plus sont séparés par le caractère |, les variables "
+"Si deux variables ou plus sont séparées par le caractère |, les variables "
"disponibles seront affichées avec un séparateur.\n"
"<i>%formatted.ShutterSpeed%</i>|<i>%formatted.ISOSpeedRating%</i>|<i>%"
"formatted.FocalLength%</i> montrera \"1/20s - 400 - 80 mm\" ou \"1/200 - 80 "
#: ../src/preferences.c:1463
msgid "Grouping sidecar extensions"
-msgstr "Groupage des extensions de fichiers sidecar"
+msgstr "Groupage des extensions de fichiers sidecars"
#: ../src/preferences.c:1470
msgid "File types"
#: ../src/preferences.c:1600
msgid "Warning: Geeqie is built without Exiv2. Some options are disabled."
msgstr ""
-"Attention: Geeqie a été compilé sans Exiv2, quelques options sont donc "
+"Attention : Geeqie a été compilé sans Exiv2, quelques options sont donc "
"inaccessibles."
#: ../src/preferences.c:1602
"1) Save metadata in image files, resp. sidecar files, according to the XMP "
"standard"
msgstr ""
-"1) Sauver les méta-données dans les fichiers images, les fichiers sidecar, "
+"1) Sauver les méta-données dans les fichiers images, les fichiers sidecars, "
"en accord avec le standard XMP"
#: ../src/preferences.c:1611
#: ../src/preferences.c:1614
#, c-format
msgid "3) Save metadata in Geeqie private directory '%s'"
-msgstr "3) Sauver les méta-données dans le répertoire privé de Geeqie '%s'"
+msgstr "3) Sauver les méta-données dans le répertoire privé de Geeqie « %s »"
#: ../src/preferences.c:1619
msgid "Step 1: Write to image files"
#: ../src/preferences.c:1630
msgid "Warn if the image files are unwritable"
-msgstr "Prévenir si les images sont protégés en écriture"
+msgstr "Prévenir si les images sont protégées en écriture"
#: ../src/preferences.c:1633
msgid "Ask before writing to image files"
#: ../src/preferences.c:1636
msgid "Step 2 and 3: write to Geeqie private files"
-msgstr "Étapes 2 et 3: écriture dans les fichiers privés de Geeqie"
+msgstr "Étapes 2 et 3 : écriture dans les fichiers privés de Geeqie"
#: ../src/preferences.c:1641
msgid ""
#: ../src/preferences.c:1666
msgid "Timeout (seconds):"
-msgstr "Délai (secondes):"
+msgstr "Délai (secondes) :"
#: ../src/preferences.c:1669
msgid "Write metadata on image change"
#: ../src/preferences.c:1710
#, c-format
msgid "Input %d:"
-msgstr "Entrée %d:"
+msgstr "Entrée %d :"
#: ../src/preferences.c:1727 ../src/preferences.c:1747
msgid "Select color profile"
#: ../src/preferences.c:1744
msgid "Screen:"
-msgstr "Écran:"
+msgstr "Écran :"
#: ../src/preferences.c:1766 ../src/preferences.c:1809
msgid "Behavior"
#: ../src/preferences.c:1835
msgid "Custom similarity threshold:"
-msgstr "Seuil de similarité personalisé :"
+msgstr "Seuil de similarité personnalisé :"
#: ../src/preferences.c:1840
msgid "Debugging"
-msgstr "Déboguage"
+msgstr "Débogage"
#: ../src/preferences.c:1842
msgid "Debug level:"
-msgstr "Niveau de déboguage:"
+msgstr "Niveau de débogage :"
#: ../src/preferences.c:1861
msgid "Keyboard"
#: ../src/preferences.c:1915
msgid "Tooltip"
-msgstr "Titre"
+msgstr "Infobulle"
#: ../src/preferences.c:1953
msgid "Reset selected"
#: ../src/preferences.c:2144
msgid "Credits..."
-msgstr "Crédits ..."
+msgstr "Crédits..."
#: ../src/print.c:124
msgid "Selection"
#. in 8.5 x 11
#: ../src/print.c:382
msgid "Legal"
-msgstr "Legal"
+msgstr "Légal"
#. in 8.5 x 14
#: ../src/print.c:383
msgid "Executive"
-msgstr "Executive"
+msgstr "Exécutive"
#. in 7.25x 10.5
#. mm 841 x 1189
#: ../src/print.c:1144 ../src/print.c:1181 ../src/print.c:1217
#: ../src/print.c:1334 ../src/print.c:1425 ../src/print.c:1456
msgid "SIGPIPE error writing to printer."
-msgstr "Erreur SIGPIPE à l'écriture vers l'imprimante"
+msgstr "Erreur SIGPIPE à l'écriture vers l'imprimante."
#: ../src/print.c:1991
#, c-format
#: ../src/remote.c:643
msgid "toggle full screen"
-msgstr "bascule le mode plein écran"
+msgstr "bascule en mode plein écran"
#: ../src/remote.c:644
msgid "start full screen"
#: ../src/remote.c:646
msgid "toggle slide show"
-msgstr "bascule le mode diaporama"
+msgstr "bascule en mode diaporama"
#: ../src/remote.c:647
msgid "start slide show"
#: ../src/remote.c:781
#, c-format
msgid "Remote %s not running, starting..."
-msgstr "Pas de %s distant, lancement ..."
+msgstr "Pas de %s distant, lancement..."
#: ../src/remote.c:917
msgid "Remote not available\n"
#: ../src/search.c:318
msgid "Searching..."
-msgstr "Recherche ..."
+msgstr "Recherche..."
#: ../src/search.c:2166
msgid "File not found"
#: ../src/thumb.c:396
msgid "Thumbnail image in cache failed to load, trying to recreate.\n"
-msgstr "Impossible de charger la vignette depuis le cache, regénération.\n"
+msgstr "Impossible de charger la vignette depuis le cache, régénération.\n"
#: ../src/trash.c:80 ../src/utilops.c:2428 ../src/utilops.c:2439
#: ../src/utilops.c:2496
"Safe delete: %s%s\n"
"Trash: %s"
msgstr ""
-"Suppression récupérable: %s%s\n"
-"Poubelle: %s"
+"Suppression récupérable : %s%s\n"
+"Poubelle : %s"
#: ../src/trash.c:210
#, c-format
#: ../src/ui_bookmark.c:403
msgid "_Properties..."
-msgstr "_Propriétés ..."
+msgstr "_Propriétés..."
#: ../src/ui_bookmark.c:409
msgid "_Remove"
-msgstr "Éfface_r"
+msgstr "Efface_r"
#: ../src/ui_fileops.c:94
msgid ""
"Preferred encoding appears to be UTF-8, however the file:\n"
msgstr ""
"\n"
-"L'encodage préféré semble être UTF-8, mais le fichier:\n"
+"L'encodage préféré semble être UTF-8, mais le fichier :\n"
#: ../src/ui_fileops.c:109 ../src/ui_fileops.c:112 ../src/ui_fileops.c:114
msgid "[name not displayable]"
#: ../src/ui_pathsel.c:759
msgid "Error creating folder"
-msgstr "Erreur pendant le création du dossier"
+msgstr "Erreur pendant la création du dossier"
#: ../src/ui_pathsel.c:980
msgid "All Files"
"\n"
"%s"
msgstr ""
-"La suppression du contenu du dossier a échouée lors de ce fichier:\n"
+"La suppression du contenu du dossier a échoué lors de ce fichier :\n"
"\n"
"%s"
#: ../src/utilops.c:988
msgid "This operation can't continue:"
-msgstr "Cette opération ne peut continuer:"
+msgstr "Cette opération ne peut continuer :"
#: ../src/utilops.c:1351 ../src/utilops.c:1464 ../src/utilops.c:1848
msgid "Discard changes"
#: ../src/utilops.c:1757
#, c-format
msgid "File: '%s'\n"
-msgstr "Fichier: « %s »\n"
+msgstr "Fichier : « %s »\n"
#: ../src/utilops.c:1762
msgid "with sidecar files:\n"
-msgstr "avec les fichiers sidecars:\n"
+msgstr "avec les fichiers sidecars :\n"
#: ../src/utilops.c:1768
#, c-format
"Status: "
msgstr ""
"\n"
-"Etat:"
+"État :"
#: ../src/utilops.c:1784
msgid "no problem detected"
"\n"
"This folder contains subfolders which must be moved before it can be deleted."
msgstr ""
-"Impossible de supprimer le dossier:\n"
+"Impossible de supprimer le dossier :\n"
"\n"
"%s\n"
"\n"
#: ../src/utilops.c:2464
msgid "Subfolders:"
-msgstr "Sous-dossiers:"
+msgstr "Sous-dossiers :"
#: ../src/utilops.c:2485
msgid "Delete folder?"
#: ../src/utilops.c:2486
msgid "The folder contains these files:"
-msgstr "Ce dossier contient ces fichiers:"
+msgstr "Ce dossier contient ces fichiers :"
#: ../src/utilops.c:2487
msgid ""
#: ../src/view_dir.c:655
msgid "Find _duplicates..."
-msgstr "Rechercher les _doublons ..."
+msgstr "Rechercher les _doublons..."
#: ../src/view_dir.c:657
msgid "Find duplicates recursive..."
-msgstr "Rechercher récursivement les doublons ..."
+msgstr "Rechercher récursivement les doublons..."
#: ../src/view_dir.c:662
msgid "_New folder..."
-msgstr "_Nouveau dossier ..."
+msgstr "_Nouveau dossier..."
#: ../src/view_dir.c:676 ../src/view_file.c:606
msgid "View as _List"
image.h \
image-load.c \
image-load.h \
+ image_load_gdk.c\
+ image_load_gdk.h\
+ image_load_jpeg.c\
+ image_load_jpeg.h\
+ image_load_tiff.c\
+ image_load_tiff.h\
image-overlay.c \
image-overlay.h \
img-view.c \
img-view.h \
+ jpeg_parser.c \
+ jpeg_parser.h \
layout.c \
layout.h \
layout_config.c \
pan-view.h \
pixbuf-renderer.c \
pixbuf-renderer.h \
+ renderer-tiles.c \
+ renderer-tiles.h \
pixbuf_util.c \
pixbuf_util.h \
preferences.c \
window.c \
window.h
-geeqie_LDADD = $(GTK_LIBS) $(GLIB_LIBS) $(INTLLIBS) $(LCMS_LIBS) $(EXIV2_LIBS) $(LIBCHAMPLAIN_LIBS) $(LIBCHAMPLAIN_GTK_LIBS)
+geeqie_LDADD = $(GTK_LIBS) $(GLIB_LIBS) $(INTLLIBS) $(JPEG_LIBS) $(TIFF_LIBS) $(LCMS_LIBS) $(EXIV2_LIBS) $(LIBCHAMPLAIN_LIBS) $(LIBCHAMPLAIN_GTK_LIBS)
EXTRA_DIST = \
$(extra_SLIK)
history_list_free_key(SORT_KEY_COLLECTIONS);
bookmark_list_set_key(bookmarks, SORT_KEY_COLLECTIONS);
- dir_fd = file_data_new_simple(get_collections_dir());
+ dir_fd = file_data_new_dir(get_collections_dir());
filelist_read(dir_fd, &list, NULL);
file_data_unref(dir_fd);
GList *list;
gchar *src_dir;
- list = g_list_append(NULL, file_data_new_simple(sd->undo_dest));
+ list = g_list_append(NULL, file_data_new_group(sd->undo_dest));
src_dir = remove_level_from_path(sd->undo_src);
file_util_move_simple(list, src_dir, sd->lw->window);
g_free(src_dir);
}
break;
case BAR_SORT_COPY:
- file_util_delete(file_data_new_simple(sd->undo_dest), NULL, button);
+ file_util_delete(file_data_new_group(sd->undo_dest), NULL, button);
break;
default:
/* undo external command */
- file_util_delete(file_data_new_simple(sd->undo_dest), NULL, button);
+ file_util_delete(file_data_new_group(sd->undo_dest), NULL, button);
break;
}
if (isfile(sd->undo_src))
{
- layout_image_set_fd(sd->lw, file_data_new_simple(sd->undo_src));
+ layout_image_set_fd(sd->lw, file_data_new_group(sd->undo_src));
}
bar_sort_undo_set(sd, NULL, NULL, NULL);
source = work->data;
work = work->next;
- collect_manager_remove(file_data_new_simple(source), sd->undo_dest);
+ collect_manager_remove(file_data_new_group(source), sd->undo_dest);
}
bar_sort_undo_set(sd, NULL, NULL, NULL);
cache_folder = get_thumbnails_cache_dir();
}
- dir_fd = file_data_new_simple(cache_folder);
+ dir_fd = file_data_new_dir(cache_folder);
if (!filelist_read(dir_fd, NULL, &dlist))
{
file_data_unref(dir_fd);
base_length = strlen(homedir()) + strlen("/") + strlen(GQ_CACHE_RC_THUMB);
base = g_strconcat(homedir(), "/", GQ_CACHE_RC_THUMB, dir, NULL);
- dir_fd = file_data_new_simple(base);
+ dir_fd = file_data_new_dir(base);
g_free(base);
if (filelist_read(dir_fd, &flist, &dlist))
GList *work;
cachedir = g_build_filename(dir, GQ_CACHE_LOCAL_THUMB, NULL);
- cachedir_fd = file_data_new_simple(cachedir);
+ cachedir_fd = file_data_new_dir(cachedir);
g_free(cachedir);
filelist_read(cachedir_fd, &list, NULL);
spinner_set_interval(cd->spinner, SPINNER_SPEED);
- dir_fd = file_data_new_simple(path);
+ dir_fd = file_data_new_dir(path);
cache_manager_render_folder(cd, dir_fd);
file_data_unref(dir_fd);
while (cache_manager_render_file(cd));
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(cd->progress), _("running..."));
path = g_build_filename(homedir(), THUMB_FOLDER_GLOBAL, THUMB_FOLDER_NORMAL, NULL);
- dir_fd = file_data_new_simple(path);
+ dir_fd = file_data_new_dir(path);
filelist_read(dir_fd, &list, NULL);
cd->list = list;
file_data_unref(dir_fd);
g_free(path);
path = g_build_filename(homedir(), THUMB_FOLDER_GLOBAL, THUMB_FOLDER_LARGE, NULL);
- dir_fd = file_data_new_simple(path);
+ dir_fd = file_data_new_dir(path);
filelist_read(dir_fd, &list, NULL);
cd->list = g_list_concat(cd->list, list);
file_data_unref(dir_fd);
g_free(path);
path = g_build_filename(homedir(), THUMB_FOLDER_GLOBAL, THUMB_FOLDER_FAIL, NULL);
- dir_fd = file_data_new_simple(path);
+ dir_fd = file_data_new_dir(path);
filelist_read(dir_fd, &list, NULL);
cd->list = g_list_concat(cd->list, list);
file_data_unref(dir_fd);
if (!flush)
changed |= collect_manager_process_action(entry, &buf);
- valid = (buf[0] == G_DIR_SEPARATOR && collection_add_check(cd, file_data_new_simple(buf), FALSE, TRUE));
+ valid = (buf[0] == G_DIR_SEPARATOR && collection_add_check(cd, file_data_new_group(buf), FALSE, TRUE));
if (!valid) DEBUG_1("collection invalid file: %s", buf);
total++;
gchar *buf = NULL;
while (collect_manager_process_action(entry, &buf))
{
- collection_add_check(cd, file_data_new_simple(buf), FALSE, TRUE);
+ collection_add_check(cd, file_data_new_group(buf), FALSE, TRUE);
changed = TRUE;
g_free(buf);
buf = NULL;
GList *work;
FileData *dir_fd;
- dir_fd = file_data_new_simple(get_collections_dir());
+ dir_fd = file_data_new_dir(get_collections_dir());
filelist_read(dir_fd, &list, NULL);
file_data_unref(dir_fd);
#include <glib/gprintf.h>
-
/*
* Logging functions
*/
-gint log_domain_printf(const gchar *domain, const gchar *format, ...)
+static gboolean log_msg_cb(gpointer data)
+{
+ gchar *buf = data;
+ log_window_append(buf, LOG_MSG);
+ g_free(buf);
+ return FALSE;
+}
+
+static gboolean log_normal_cb(gpointer data)
+{
+ gchar *buf = data;
+ log_window_append(buf, LOG_NORMAL);
+ g_free(buf);
+ return FALSE;
+}
+
+void log_domain_printf(const gchar *domain, const gchar *format, ...)
{
va_list ap;
- gchar buf[4096];
- gint ret;
+ gchar *buf;
va_start(ap, format);
- ret = g_vsnprintf(buf, sizeof(buf), format, ap);
+ buf = g_strdup_vprintf(format, ap);
va_end(ap);
print_term(buf);
if (strcmp(domain, DOMAIN_INFO) == 0)
- log_window_append(buf, LOG_NORMAL);
+ g_idle_add(log_normal_cb, buf);
else
- log_window_append(buf, LOG_MSG);
+ g_idle_add(log_msg_cb, buf);
- return ret;
}
-
/*
* Debugging only functions
*/
#define DOMAIN_DEBUG "debug"
#define DOMAIN_INFO "info"
-gint log_domain_printf(const gchar *domain, const gchar *format, ...) G_GNUC_PRINTF(2, 3);
+void log_domain_printf(const gchar *domain, const gchar *format, ...) G_GNUC_PRINTF(2, 3);
#define log_printf(...) log_domain_printf(DOMAIN_INFO, __VA_ARGS__)
#ifdef DEBUG
{"image/x-xcf", ".xcf"},
{"image/x-xpixmap", ".xpm"},
{"image/x-x3f", ".x3f"},
+ {"application/x-ptoptimizer-script", ".pto"},
{NULL, NULL}};
gint i, j;
#include "format_raw.h"
#include "ui_fileops.h"
#include "cache.h"
+#include "jpeg_parser.h"
static gdouble exif_rational_to_double(ExifRational *r, gint sign)
fd->exif = NULL;
}
+void exif_init_cache(void)
+{
+ assert(!exif_cache);
+ exif_cache = file_cache_new(exif_release_cb, 4);
+}
+
ExifData *exif_read_fd(FileData *fd)
{
gchar *sidecar_path;
+
+ if (!exif_cache) exif_init_cache();
if (!fd || !is_readable_file(fd->path)) return NULL;
- if (!exif_cache) exif_cache = file_cache_new(exif_release_cb, 4);
-
if (file_cache_get(exif_cache, fd)) return fd->exif;
/* CACHE_TYPE_XMP_METADATA file should exist only if the metadata are
/* embedded icc in jpeg */
-
-#define JPEG_MARKER 0xFF
-#define JPEG_MARKER_SOI 0xD8
-#define JPEG_MARKER_EOI 0xD9
-#define JPEG_MARKER_APP1 0xE1
-#define JPEG_MARKER_APP2 0xE2
-
-/* jpeg container format:
- all data markers start with 0XFF
- 2 byte long file start and end markers: 0xFFD8(SOI) and 0XFFD9(EOI)
- 4 byte long data segment markers in format: 0xFFTTSSSSNNN...
- FF: 1 byte standard marker identifier
- TT: 1 byte data type
- SSSS: 2 bytes in Motorola byte alignment for length of the data.
- This value includes these 2 bytes in the count, making actual
- length of NN... == SSSS - 2.
- NNN.: the data in this segment
- */
-
-gboolean exif_jpeg_segment_find(guchar *data, guint size,
- guchar app_marker, const gchar *magic, guint magic_len,
- guint *seg_offset, guint *seg_length)
-{
- guchar marker = 0;
- guint offset = 0;
- guint length = 0;
-
- while (marker != app_marker &&
- marker != JPEG_MARKER_EOI)
- {
- offset += length;
- length = 2;
-
- if (offset + 2 >= size ||
- data[offset] != JPEG_MARKER) return FALSE;
-
- marker = data[offset + 1];
- if (marker != JPEG_MARKER_SOI &&
- marker != JPEG_MARKER_EOI)
- {
- if (offset + 4 >= size) return FALSE;
- length += ((guint)data[offset + 2] << 8) + data[offset + 3];
- }
- }
-
- if (marker == app_marker &&
- offset + length < size &&
- length >= 4 + magic_len &&
- memcmp(data + offset + 4, magic, magic_len) == 0)
- {
- *seg_offset = offset + 4;
- *seg_length = length - 4;
- return TRUE;
- }
-
- return FALSE;
-}
-
gboolean exif_jpeg_parse_color(ExifData *exif, guchar *data, guint size)
{
guint seg_offset = 0;
TT = total number of ICC segments (TT in each ICC segment should match)
*/
- while (exif_jpeg_segment_find(data + seg_offset + seg_length,
+ while (jpeg_segment_find(data + seg_offset + seg_length,
size - seg_offset - seg_length,
JPEG_MARKER_APP2,
"ICC_PROFILE\x00", 12,
#include "main.h"
#include "exif-int.h"
+#include "jpeg_parser.h"
#include "format_raw.h"
#include "ui_fileops.h"
return -2;
}
- if (exif_jpeg_segment_find(data, size, JPEG_MARKER_APP1,
+ if (jpeg_segment_find(data, size, JPEG_MARKER_APP1,
"Exif\x00\x00", 6,
&seg_offset, &seg_length))
{
void exif_add_jpeg_color_profile(ExifData *exif, guchar *cp_data, guint cp_length);
-gboolean exif_jpeg_segment_find(guchar *data, guint size,
- guchar app_marker, const gchar *magic, guint magic_len,
- guint *seg_offset, guint *seg_length);
gboolean exif_jpeg_parse_color(ExifData *exif, guchar *data, guint size);
/*raw support */
static GHashTable *file_data_pool = NULL;
static GHashTable *file_data_planned_change_hash = NULL;
-static gint sidecar_file_priority(const gchar *path);
-static FileData *file_data_new_local(const gchar *path, struct stat *st, gboolean check_sidecars, GHashTable *basename_hash);
+static gint sidecar_file_priority(const gchar *extension);
+static void file_data_check_sidecars(const GList *basename_list);
+static FileData *file_data_disconnect_sidecar_file(FileData *target, FileData *sfd);
+
/*
/*
*-----------------------------------------------------------------------------
- * file info struct
+ * changed files detection and notification
*-----------------------------------------------------------------------------
*/
-FileData *file_data_merge_sidecar_files(FileData *target, FileData *source);
-static void file_data_check_sidecars(FileData *fd, GHashTable *basename_hash);
-FileData *file_data_disconnect_sidecar_file(FileData *target, FileData *sfd);
-
-
void file_data_increment_version(FileData *fd)
{
fd->version++;
}
}
-static gint file_data_sort_by_ext(gconstpointer a, gconstpointer b)
+static gboolean file_data_check_changed_single_file(FileData *fd, struct stat *st)
{
- const FileData *fda = a;
- const FileData *fdb = b;
-
- return strcmp(fdb->extension, fda->extension);
-}
-
-static GHashTable *file_data_basename_hash_new(void)
-{
- return g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
+ if (fd->size != st->st_size ||
+ fd->date != st->st_mtime)
+ {
+ fd->size = st->st_size;
+ fd->date = st->st_mtime;
+ fd->mode = st->st_mode;
+ if (fd->thumb_pixbuf) g_object_unref(fd->thumb_pixbuf);
+ fd->thumb_pixbuf = NULL;
+ file_data_increment_version(fd);
+ file_data_send_notification(fd, NOTIFY_REREAD);
+ return TRUE;
+ }
+ return FALSE;
}
-static void file_data_basename_hash_insert(GHashTable *basename_hash, FileData *fd)
+static gboolean file_data_check_changed_files_recursive(FileData *fd, struct stat *st)
{
- GList *list;
- const gchar *ext = extension_from_path(fd->path);
- gchar *basename = ext ? g_strndup(fd->path, ext - fd->path) : g_strdup(fd->path);
-
- list = g_hash_table_lookup(basename_hash, basename);
+ gboolean ret = FALSE;
+ GList *work;
- if (!g_list_find(list, fd))
- {
- list = g_list_insert_sorted(list, file_data_ref(fd), file_data_sort_by_ext);
- g_hash_table_insert(basename_hash, basename, list);
- }
- else
+ ret = file_data_check_changed_single_file(fd, st);
+
+ work = fd->sidecar_files;
+ while (work)
{
- g_free(basename);
+ FileData *sfd = work->data;
+ struct stat st;
+ work = work->next;
+
+ if (!stat_utf8(sfd->path, &st))
+ {
+ fd->size = 0;
+ fd->date = 0;
+ file_data_disconnect_sidecar_file(fd, sfd);
+ ret = TRUE;
+ continue;
+ }
+
+ ret |= file_data_check_changed_files_recursive(sfd, &st);
}
+ return ret;
}
-#if 0
-static void file_data_basename_hash_remove(GHashTable *basename_hash, FileData *fd)
+
+gboolean file_data_check_changed_files(FileData *fd)
{
- GList *list;
- const gchar *ext = extension_from_path(fd->path);
- gchar *basename = ext ? g_strndup(fd->path, ext - fd->path) : g_strdup(fd->path);
-
- list = g_hash_table_lookup(basename_hash, basename);
-
- if (!g_list_find(list, fd)) return;
-
- list = g_list_remove(list, fd);
- file_data_unref(fd);
+ gboolean ret = FALSE;
+ struct stat st;
- if (list)
+ if (fd->parent) fd = fd->parent;
+
+ if (!stat_utf8(fd->path, &st))
{
- g_hash_table_insert(basename_hash, basename, list);
+ GList *sidecars;
+ GList *work;
+ FileData *sfd = NULL;
+
+ /* parent is missing, we have to rebuild whole group */
+ ret = TRUE;
+ fd->size = 0;
+ fd->date = 0;
+
+ /* file_data_disconnect_sidecar_file might delete the file,
+ we have to keep the reference to prevent this */
+ sidecars = filelist_copy(fd->sidecar_files);
+ work = sidecars;
+ while (work)
+ {
+ sfd = work->data;
+ work = work->next;
+
+ file_data_disconnect_sidecar_file(fd, sfd);
+ }
+ file_data_check_sidecars(sidecars); /* this will group the sidecars back together */
+ /* now we can release the sidecars */
+ filelist_free(sidecars);
+ file_data_send_notification(fd, NOTIFY_REREAD);
}
- else
+ else
{
- g_hash_table_remove(basename_hash, basename);
- g_free(basename);
+ ret |= file_data_check_changed_files_recursive(fd, &st);
}
-}
-#endif
-static void file_data_basename_hash_remove_list(gpointer key, gpointer value, gpointer data)
-{
- filelist_free((GList *)value);
+ return ret;
}
-static void file_data_basename_hash_free(GHashTable *basename_hash)
-{
- g_hash_table_foreach(basename_hash, file_data_basename_hash_remove_list, NULL);
- g_hash_table_destroy(basename_hash);
-}
+/*
+ *-----------------------------------------------------------------------------
+ * file name, extension, sorting, ...
+ *-----------------------------------------------------------------------------
+ */
static void file_data_set_collate_keys(FileData *fd)
{
return;
}
- fd->extension = extension_from_path(fd->path);
+ fd->extension = registered_extension_from_path(fd->path);
if (fd->extension == NULL)
{
fd->extension = fd->name + strlen(fd->name);
}
-
+
+ fd->sidecar_priority = sidecar_file_priority(fd->extension);
file_data_set_collate_keys(fd);
}
-static gboolean file_data_check_changed_files_recursive(FileData *fd, struct stat *st)
-{
- gboolean ret = FALSE;
- GList *work;
-
- if (fd->size != st->st_size ||
- fd->date != st->st_mtime)
- {
- fd->size = st->st_size;
- fd->date = st->st_mtime;
- fd->mode = st->st_mode;
- if (fd->thumb_pixbuf) g_object_unref(fd->thumb_pixbuf);
- fd->thumb_pixbuf = NULL;
- file_data_increment_version(fd);
- file_data_send_notification(fd, NOTIFY_REREAD);
- ret = TRUE;
- }
-
- work = fd->sidecar_files;
- while (work)
- {
- FileData *sfd = work->data;
- struct stat st;
- work = work->next;
-
- if (!stat_utf8(sfd->path, &st))
- {
- fd->size = 0;
- fd->date = 0;
- file_data_disconnect_sidecar_file(fd, sfd);
- ret = TRUE;
- continue;
- }
-
- ret |= file_data_check_changed_files_recursive(sfd, &st);
- }
- return ret;
-}
-
-
-gboolean file_data_check_changed_files(FileData *fd)
-{
- gboolean ret = FALSE;
- struct stat st;
-
- if (fd->parent) fd = fd->parent;
-
- if (!stat_utf8(fd->path, &st))
- {
- GList *sidecars;
- GList *work;
- FileData *sfd = NULL;
-
- /* parent is missing, we have to rebuild whole group */
- ret = TRUE;
- fd->size = 0;
- fd->date = 0;
-
- /* file_data_disconnect_sidecar_file might delete the file,
- we have to keep the reference to prevent this */
- sidecars = filelist_copy(fd->sidecar_files);
- work = sidecars;
- while (work)
- {
- sfd = work->data;
- work = work->next;
-
- file_data_disconnect_sidecar_file(fd, sfd);
- }
- if (sfd) file_data_check_sidecars(sfd, NULL); /* this will group the sidecars back together */
- /* now we can release the sidecars */
- filelist_free(sidecars);
- file_data_send_notification(fd, NOTIFY_REREAD);
- }
- else
- {
- ret |= file_data_check_changed_files_recursive(fd, &st);
- }
-
- return ret;
-}
+/*
+ *-----------------------------------------------------------------------------
+ * create or reuse Filedata
+ *-----------------------------------------------------------------------------
+ */
-static FileData *file_data_new(const gchar *path_utf8, struct stat *st, gboolean check_sidecars, GHashTable *basename_hash)
+static FileData *file_data_new(const gchar *path_utf8, struct stat *st, gboolean disable_sidecars)
{
FileData *fd;
- DEBUG_2("file_data_new: '%s' %d %d", path_utf8, check_sidecars, !!basename_hash);
+ DEBUG_2("file_data_new: '%s' %d", path_utf8, disable_sidecars);
+
+ if (S_ISDIR(st->st_mode)) disable_sidecars = TRUE;
if (!file_data_pool)
file_data_pool = g_hash_table_new(g_str_hash, g_str_equal);
if (fd)
{
gboolean changed;
- if (basename_hash)
- {
- file_data_basename_hash_insert(basename_hash, fd);
- if (check_sidecars)
- file_data_check_sidecars(fd, basename_hash);
- }
- if (fd->parent)
- changed = file_data_check_changed_files(fd);
- else
- changed = file_data_check_changed_files_recursive(fd, st);
- if (changed && check_sidecars && sidecar_file_priority(fd->extension))
- file_data_check_sidecars(fd, basename_hash);
+ if (disable_sidecars) file_data_disable_grouping(fd, TRUE);
+
+
+ changed = file_data_check_changed_single_file(fd, st);
+
DEBUG_2("file_data_pool hit: '%s' %s", fd->path, changed ? "(changed)" : "");
return fd;
fd->mode = st->st_mode;
fd->ref = 1;
fd->magick = 0x12345678;
+
+ if (disable_sidecars) fd->disable_grouping = TRUE;
file_data_set_path(fd, path_utf8); /* set path, name, collate_key_*, original_path */
- if (basename_hash) file_data_basename_hash_insert(basename_hash, fd);
-
- if (check_sidecars)
- file_data_check_sidecars(fd, basename_hash);
return fd;
}
-/* extension must contain only ASCII characters */
-static GList *check_case_insensitive_ext(gchar *path)
-{
- gchar *sl;
- gchar *extl;
- gint ext_len;
- GList *list = NULL;
-
- sl = path_from_utf8(path);
-
- extl = strrchr(sl, '.');
- if (extl)
- {
- gint i, j;
- extl++; /* the first char after . */
- ext_len = strlen(extl);
-
- for (i = 0; i < (1 << ext_len); i++)
- {
- struct stat st;
- gboolean skip = FALSE;
- for (j = 0; j < ext_len; j++)
- {
- if (i & (1 << (ext_len - 1 - j)))
- {
- extl[j] = g_ascii_tolower(extl[j]);
- /* make sure the result does not contain duplicates */
- if (extl[j] == g_ascii_toupper(extl[j]))
- {
- /* no change, probably a number, we have already tested this combination */
- skip = TRUE;
- break;
- }
- }
- else
- extl[j] = g_ascii_toupper(extl[j]);
- }
- if (skip) continue;
-
- if (stat(sl, &st) == 0)
- {
- list = g_list_prepend(list, file_data_new_local(sl, &st, FALSE, FALSE));
- }
- }
- }
- g_free(sl);
-
- return list;
-}
-
-static void file_data_check_sidecars(FileData *fd, GHashTable *basename_hash)
-{
- gint base_len;
- GString *fname;
- FileData *parent_fd = NULL;
- GList *work;
- const GList *basename_list = NULL;
- GList *group_list = NULL;
- if (fd->disable_grouping || !sidecar_file_priority(fd->extension))
- return;
-
- base_len = fd->extension - fd->path;
- fname = g_string_new_len(fd->path, base_len);
-
- if (basename_hash)
- {
- basename_list = g_hash_table_lookup(basename_hash, fname->str);
- }
-
-
- /* check for possible sidecar files;
- the sidecar files created here are referenced only via fd->sidecar_files or fd->parent,
- they have fd->ref set to 0 and file_data unref must chack and free them all together
- (using fd->ref would cause loops and leaks)
- */
-
- /* find all possible sidecar files and order them according to sidecar_ext_get_list,
- for case-only differences put lowercase first,
- put the result to group_list
- */
- work = sidecar_ext_get_list();
- while (work)
- {
- gchar *ext = work->data;
- work = work->next;
-
- if (!basename_hash)
- {
- GList *new_list;
- g_string_truncate(fname, base_len);
- g_string_append(fname, ext);
- new_list = check_case_insensitive_ext(fname->str);
- group_list = g_list_concat(group_list, new_list);
- }
- else
- {
- const GList *work2 = basename_list;
-
- while (work2)
- {
- FileData *sfd = work2->data;
-
- if (g_ascii_strcasecmp(ext, sfd->extension) == 0)
- {
- group_list = g_list_append(group_list, file_data_ref(sfd));
- }
- work2 = work2->next;
- }
- }
- }
- g_string_free(fname, TRUE);
-
- /* process the group list - the first one is the parent file, others are sidecars */
- work = group_list;
- while (work)
- {
- FileData *new_fd = work->data;
- work = work->next;
-
- if (new_fd->disable_grouping)
- {
- file_data_unref(new_fd);
- continue;
- }
-
- new_fd->ref--; /* do not use ref here */
-
- if (!parent_fd)
- parent_fd = new_fd; /* parent is the one with the highest prio, found first */
- else
- file_data_merge_sidecar_files(parent_fd, new_fd);
- }
- g_list_free(group_list);
-}
-
-
-static FileData *file_data_new_local(const gchar *path, struct stat *st, gboolean check_sidecars, GHashTable *basename_hash)
+static FileData *file_data_new_local(const gchar *path, struct stat *st, gboolean disable_sidecars)
{
gchar *path_utf8 = path_to_utf8(path);
- FileData *ret = file_data_new(path_utf8, st, check_sidecars, basename_hash);
+ FileData *ret = file_data_new(path_utf8, st, disable_sidecars);
g_free(path_utf8);
return ret;
}
-FileData *file_data_new_simple(const gchar *path_utf8)
+FileData *file_data_new_no_grouping(const gchar *path_utf8)
{
struct stat st;
st.st_mtime = 0;
}
- return file_data_new(path_utf8, &st, TRUE, NULL);
+ return file_data_new(path_utf8, &st, TRUE);
}
-FileData *file_data_add_sidecar_file(FileData *target, FileData *sfd)
+FileData *file_data_new_dir(const gchar *path_utf8)
{
- sfd->parent = target;
- if (!g_list_find(target->sidecar_files, sfd))
- target->sidecar_files = g_list_prepend(target->sidecar_files, sfd);
- file_data_increment_version(sfd); /* increments both sfd and target */
- return target;
-}
-
-
-FileData *file_data_merge_sidecar_files(FileData *target, FileData *source)
-{
- GList *work;
-
- file_data_add_sidecar_file(target, source);
+ struct stat st;
- work = source->sidecar_files;
- while (work)
+ if (!stat_utf8(path_utf8, &st))
{
- FileData *sfd = work->data;
- file_data_add_sidecar_file(target, sfd);
- work = work->next;
+ st.st_size = 0;
+ st.st_mtime = 0;
}
-
- g_list_free(source->sidecar_files);
- source->sidecar_files = NULL;
-
- target->sidecar_files = filelist_sort(target->sidecar_files, SORT_NAME, TRUE);
-
- return target;
+ else
+ /* dir or non-existing yet */
+ g_assert(S_ISDIR(st.st_mode));
+
+ return file_data_new(path_utf8, &st, TRUE);
}
+/*
+ *-----------------------------------------------------------------------------
+ * reference counting
+ *-----------------------------------------------------------------------------
+ */
+
#ifdef DEBUG_FILEDATA
FileData *file_data_ref_debug(const gchar *file, gint line, FileData *fd)
#else
g_assert(fd->magick == 0x12345678);
g_assert(fd->ref == 0);
+ metadata_cache_free(fd);
g_hash_table_remove(file_data_pool, fd->original_path);
g_free(fd->path);
}
}
-FileData *file_data_disconnect_sidecar_file(FileData *target, FileData *sfd)
-{
- sfd->parent = target;
- g_assert(g_list_find(target->sidecar_files, sfd));
-
- file_data_increment_version(sfd); /* increments both sfd and target */
- target->sidecar_files = g_list_remove(target->sidecar_files, sfd);
- sfd->parent = NULL;
-
- if (sfd->ref == 0)
- {
- file_data_free(sfd);
- return NULL;
- }
- return sfd;
-}
+/*
+ *-----------------------------------------------------------------------------
+ * sidecar file info struct
+ *-----------------------------------------------------------------------------
+ */
-/* disables / enables grouping for particular file, sends UPDATE notification */
-void file_data_disable_grouping(FileData *fd, gboolean disable)
+static gint file_data_sort_by_ext(gconstpointer a, gconstpointer b)
{
- if (!fd->disable_grouping == !disable) return;
+ const FileData *fda = a;
+ const FileData *fdb = b;
- fd->disable_grouping = !!disable;
+ if (fda->sidecar_priority < fdb->sidecar_priority) return -1;
+ if (fda->sidecar_priority > fdb->sidecar_priority) return 1;
- if (disable)
- {
- if (fd->parent)
- {
- FileData *parent = file_data_ref(fd->parent);
- file_data_disconnect_sidecar_file(parent, fd);
- file_data_send_notification(parent, NOTIFY_GROUPING);
- file_data_unref(parent);
- }
- else if (fd->sidecar_files)
- {
- GList *sidecar_files = filelist_copy(fd->sidecar_files);
- GList *work = sidecar_files;
- while (work)
- {
- FileData *sfd = work->data;
- work = work->next;
- file_data_disconnect_sidecar_file(fd, sfd);
- file_data_send_notification(sfd, NOTIFY_GROUPING);
- }
- file_data_check_sidecars((FileData *)sidecar_files->data, FALSE); /* this will group the sidecars back together */
- filelist_free(sidecar_files);
- }
- else
- {
- file_data_increment_version(fd); /* the functions called in the cases above increments the version too */
- }
- }
- else
- {
- file_data_increment_version(fd);
- file_data_check_sidecars(fd, FALSE);
- }
- file_data_send_notification(fd, NOTIFY_GROUPING);
+ return strcmp(fdb->extension, fda->extension);
}
-void file_data_disable_grouping_list(GList *fd_list, gboolean disable)
+
+static gint sidecar_file_priority(const gchar *extension)
{
+ gint i = 1;
GList *work;
-
- work = fd_list;
- while (work)
- {
- FileData *fd = work->data;
+
+ if (extension == NULL)
+ return 0;
+
+ work = sidecar_ext_get_list();
+
+ while (work) {
+ gchar *ext = work->data;
- file_data_disable_grouping(fd, disable);
work = work->next;
- }
+ if (g_ascii_strcasecmp(extension, ext) == 0) return i;
+ i++;
+ }
+ return 0;
}
-
-/* compare name without extension */
-gint file_data_compare_name_without_ext(FileData *fd1, FileData *fd2)
+static FileData *file_data_add_sidecar_file(FileData *target, FileData *sfd)
{
- size_t len1 = fd1->extension - fd1->name;
- size_t len2 = fd2->extension - fd2->name;
-
- if (len1 < len2) return -1;
- if (len1 > len2) return 1;
-
- return strncmp(fd1->name, fd2->name, len1); /* FIXME: utf8 */
+ sfd->parent = target;
+ if (!g_list_find(target->sidecar_files, sfd))
+ target->sidecar_files = g_list_insert_sorted(target->sidecar_files, sfd, file_data_sort_by_ext);
+ file_data_increment_version(sfd); /* increments both sfd and target */
+ return target;
}
-void file_data_change_info_free(FileDataChangeInfo *fdci, FileData *fd)
-{
- if (!fdci && fd) fdci = fd->change;
- if (!fdci) return;
+static FileData *file_data_merge_sidecar_files(FileData *target, FileData *source)
+{
+ GList *work;
+
+ file_data_add_sidecar_file(target, source);
- g_free(fdci->source);
- g_free(fdci->dest);
+ work = source->sidecar_files;
+ while (work)
+ {
+ FileData *sfd = work->data;
+ file_data_add_sidecar_file(target, sfd);
+ work = work->next;
+ }
- g_free(fdci);
+ g_list_free(source->sidecar_files);
+ source->sidecar_files = NULL;
- if (fd) fd->change = NULL;
+ return target;
}
-static gboolean file_data_can_write_directly(FileData *fd)
+static void file_data_check_sidecars(const GList *basename_list)
{
- return filter_name_is_writable(fd->extension);
+ GList *work;
+ FileData *parent_fd;
+ if (!basename_list) return;
+ /* process the group list - the first one is the parent file, others are sidecars */
+ parent_fd = basename_list->data;
+ work = basename_list->next;
+ while (work)
+ {
+ FileData *sfd = work->data;
+ work = work->next;
+
+ file_data_merge_sidecar_files(parent_fd, sfd);
+ }
+
+ /* there may be some sidecars that are already deleted - disconnect them */
+ work = parent_fd->sidecar_files;
+ while (work)
+ {
+ FileData *sfd = work->data;
+ work = work->next;
+
+ if (!g_list_find((GList *)basename_list, sfd))
+ {
+ printf("removing unknown %s: %s \n", parent_fd->path, sfd->path);
+ file_data_disconnect_sidecar_file(parent_fd, sfd);
+ file_data_send_notification(sfd, NOTIFY_REREAD);
+ file_data_send_notification(parent_fd, NOTIFY_REREAD);
+ }
+ }
}
-static gboolean file_data_can_write_sidecar(FileData *fd)
+static FileData *file_data_disconnect_sidecar_file(FileData *target, FileData *sfd)
{
- return filter_name_allow_sidecar(fd->extension) && !filter_name_is_writable(fd->extension);
+ sfd->parent = target;
+ g_assert(g_list_find(target->sidecar_files, sfd));
+
+ file_data_increment_version(sfd); /* increments both sfd and target */
+
+ target->sidecar_files = g_list_remove(target->sidecar_files, sfd);
+ sfd->parent = NULL;
+
+ if (sfd->ref == 0)
+ {
+ file_data_free(sfd);
+ return NULL;
+ }
+
+ return sfd;
}
-gchar *file_data_get_sidecar_path(FileData *fd, gboolean existing_only)
+/* disables / enables grouping for particular file, sends UPDATE notification */
+void file_data_disable_grouping(FileData *fd, gboolean disable)
{
- gchar *sidecar_path = NULL;
- GList *work;
+ if (!fd->disable_grouping == !disable) return;
- if (!file_data_can_write_sidecar(fd)) return NULL;
+ fd->disable_grouping = !!disable;
- work = fd->parent ? fd->parent->sidecar_files : fd->sidecar_files;
- while (work)
+ if (disable)
{
- FileData *sfd = work->data;
- work = work->next;
- if (g_ascii_strcasecmp(sfd->extension, ".xmp") == 0)
+ if (fd->parent)
{
- sidecar_path = g_strdup(sfd->path);
- break;
+ FileData *parent = file_data_ref(fd->parent);
+ file_data_disconnect_sidecar_file(parent, fd);
+ file_data_send_notification(parent, NOTIFY_GROUPING);
+ file_data_unref(parent);
+ }
+ else if (fd->sidecar_files)
+ {
+ GList *sidecar_files = filelist_copy(fd->sidecar_files);
+ GList *work = sidecar_files;
+ while (work)
+ {
+ FileData *sfd = work->data;
+ work = work->next;
+ file_data_disconnect_sidecar_file(fd, sfd);
+ file_data_send_notification(sfd, NOTIFY_GROUPING);
+ }
+ file_data_check_sidecars(sidecar_files); /* this will group the sidecars back together */
+ filelist_free(sidecar_files);
+ }
+ else
+ {
+ file_data_increment_version(fd); /* the functions called in the cases above increments the version too */
}
}
-
- if (!existing_only && !sidecar_path)
+ else
{
- gchar *base = remove_extension_from_path(fd->path);
- sidecar_path = g_strconcat(base, ".xmp", NULL);
- g_free(base);
+ file_data_increment_version(fd);
+ /* file_data_check_sidecars call is not necessary - the file will be re-grouped on next dir read */
}
-
- return sidecar_path;
+ file_data_send_notification(fd, NOTIFY_GROUPING);
}
-
-/*
- *-----------------------------------------------------------------------------
- * sidecar file info struct
- *-----------------------------------------------------------------------------
- */
-
-
-
-static gint sidecar_file_priority(const gchar *path)
+void file_data_disable_grouping_list(GList *fd_list, gboolean disable)
{
- const gchar *extension = extension_from_path(path);
- gint i = 1;
GList *work;
-
- if (extension == NULL)
- return 0;
-
- work = sidecar_ext_get_list();
-
- while (work) {
- gchar *ext = work->data;
+
+ work = fd_list;
+ while (work)
+ {
+ FileData *fd = work->data;
+ file_data_disable_grouping(fd, disable);
work = work->next;
- if (g_ascii_strcasecmp(extension, ext) == 0) return i;
- i++;
- }
- return 0;
+ }
}
+
/*
*-----------------------------------------------------------------------------
- * load file list
+ * filelist sorting
*-----------------------------------------------------------------------------
*/
gint filelist_sort_compare_filedata(FileData *fa, FileData *fb)
{
+ gint ret;
if (!filelist_sort_ascend)
{
FileData *tmp = fa;
break;
#ifdef HAVE_STRVERSCMP
case SORT_NUMBER:
- return strverscmp(fa->name, fb->name);
+ ret = strverscmp(fa->name, fb->name);
+ if (ret != 0) return ret;
break;
#endif
default:
}
if (options->file_sort.case_sensitive)
- return strcmp(fa->collate_key_name, fb->collate_key_name);
+ ret = strcmp(fa->collate_key_name, fb->collate_key_name);
else
- return strcmp(fa->collate_key_name_nocase, fb->collate_key_name_nocase);
+ ret = strcmp(fa->collate_key_name_nocase, fb->collate_key_name_nocase);
+
+ if (ret != 0) return ret;
+
+ /* do not return 0 unless the files are really the same
+ file_data_pool ensures that original_path is unique
+ */
+ return strcmp(fa->original_path, fb->original_path);
}
gint filelist_sort_compare_filedata_full(FileData *fa, FileData *fb, SortType method, gboolean ascend)
return filelist_insert_sort_full(list, fd, method, ascend, (GCompareFunc) filelist_sort_file_cb);
}
+/*
+ *-----------------------------------------------------------------------------
+ * basename hash - grouping of sidecars in filelist
+ *-----------------------------------------------------------------------------
+ */
+
+
+static GHashTable *file_data_basename_hash_new(void)
+{
+ return g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
+}
+
+static GList * file_data_basename_hash_insert(GHashTable *basename_hash, FileData *fd)
+{
+ GList *list;
+ gchar *basename = g_strndup(fd->path, fd->extension - fd->path);
+
+ list = g_hash_table_lookup(basename_hash, basename);
+
+ if (!g_list_find(list, fd))
+ {
+ list = g_list_insert_sorted(list, file_data_ref(fd), file_data_sort_by_ext);
+ g_hash_table_insert(basename_hash, basename, list);
+ }
+ else
+ {
+ g_free(basename);
+ }
+ return list;
+}
+
+#if 0
+static void file_data_basename_hash_remove(GHashTable *basename_hash, FileData *fd)
+{
+ GList *list;
+ gchar *basename = g_strndup(fd->path, fd->extension - fd->path);
+
+ list = g_hash_table_lookup(basename_hash, basename);
+
+ if (!g_list_find(list, fd)) return;
+
+ list = g_list_remove(list, fd);
+ file_data_unref(fd);
+
+ if (list)
+ {
+ g_hash_table_insert(basename_hash, basename, list);
+ }
+ else
+ {
+ g_hash_table_remove(basename_hash, basename);
+ g_free(basename);
+ }
+}
+#endif
+
+static void file_data_basename_hash_remove_list(gpointer key, gpointer value, gpointer data)
+{
+ filelist_free((GList *)value);
+}
+
+static void file_data_basename_hash_free(GHashTable *basename_hash)
+{
+ g_hash_table_foreach(basename_hash, file_data_basename_hash_remove_list, NULL);
+ g_hash_table_destroy(basename_hash);
+}
+
+/*
+ *-----------------------------------------------------------------------------
+ * handling sidecars in filelist
+ *-----------------------------------------------------------------------------
+ */
static GList *filelist_filter_out_sidecars(GList *flist)
{
return flist_filtered;
}
+static void file_data_basename_hash_to_sidecars(gpointer key, gpointer value, gpointer data)
+{
+ GList *basename_list = (GList *)value;
+ file_data_check_sidecars(basename_list);
+}
+
+
static gboolean is_hidden_file(const gchar *name)
{
if (name[0] != '.') return FALSE;
return TRUE;
}
-static gboolean filelist_read_real(FileData *dir_fd, GList **files, GList **dirs, gboolean follow_symlinks)
+/*
+ *-----------------------------------------------------------------------------
+ * the main filelist function
+ *-----------------------------------------------------------------------------
+ */
+
+static gboolean filelist_read_real(const gchar *dir_path, GList **files, GList **dirs, gboolean follow_symlinks)
{
DIR *dp;
struct dirent *dir;
if (files) *files = NULL;
if (dirs) *dirs = NULL;
- pathl = path_from_utf8(dir_fd->path);
+ pathl = path_from_utf8(dir_path);
if (!pathl) return FALSE;
dp = opendir(pathl);
strcmp(name, GQ_CACHE_LOCAL_METADATA) != 0 &&
strcmp(name, THUMB_FOLDER_LOCAL) != 0)
{
- dlist = g_list_prepend(dlist, file_data_new_local(filepath, &ent_sbuf, FALSE, NULL));
+ dlist = g_list_prepend(dlist, file_data_new_local(filepath, &ent_sbuf, TRUE));
}
}
else
{
if (files && filter_name_exists(name))
{
- flist = g_list_prepend(flist, file_data_new_local(filepath, &ent_sbuf, TRUE, basename_hash));
+ FileData *fd = file_data_new_local(filepath, &ent_sbuf, FALSE);
+ flist = g_list_prepend(flist, fd);
+ if (fd->sidecar_priority && !fd->disable_grouping)
+ {
+ file_data_basename_hash_insert(basename_hash, fd);
+ }
}
}
}
closedir(dp);
g_free(pathl);
- if (basename_hash) file_data_basename_hash_free(basename_hash);
if (dirs) *dirs = dlist;
- if (files) *files = filelist_filter_out_sidecars(flist);
+ if (files)
+ {
+ g_hash_table_foreach(basename_hash, file_data_basename_hash_to_sidecars, NULL);
+
+ *files = filelist_filter_out_sidecars(flist);
+ }
+ if (basename_hash) file_data_basename_hash_free(basename_hash);
return TRUE;
}
gboolean filelist_read(FileData *dir_fd, GList **files, GList **dirs)
{
- return filelist_read_real(dir_fd, files, dirs, TRUE);
+ return filelist_read_real(dir_fd->path, files, dirs, TRUE);
}
gboolean filelist_read_lstat(FileData *dir_fd, GList **files, GList **dirs)
{
- return filelist_read_real(dir_fd, files, dirs, FALSE);
+ return filelist_read_real(dir_fd->path, files, dirs, FALSE);
+}
+
+FileData *file_data_new_group(const gchar *path_utf8)
+{
+ gchar *dir;
+ struct stat st;
+ FileData *fd;
+ GList *files;
+
+ if (!stat_utf8(path_utf8, &st))
+ {
+ st.st_size = 0;
+ st.st_mtime = 0;
+ }
+
+ if (S_ISDIR(st.st_mode))
+ return file_data_new(path_utf8, &st, TRUE);
+
+ dir = remove_level_from_path(path_utf8);
+
+ filelist_read_real(dir, &files, NULL, TRUE);
+
+ fd = g_hash_table_lookup(file_data_pool, path_utf8);
+ g_assert(fd);
+ file_data_ref(fd);
+
+ filelist_free(files);
+ g_free(dir);
+ return fd;
}
+
void filelist_free(GList *list)
{
GList *work;
path = work->data;
work = work->next;
- new_list = g_list_prepend(new_list, file_data_new_simple(path));
+ new_list = g_list_prepend(new_list, file_data_new_group(path));
}
return g_list_reverse(new_list);
return list;
}
+/*
+ *-----------------------------------------------------------------------------
+ * file modification support
+ *-----------------------------------------------------------------------------
+ */
+
+
+void file_data_change_info_free(FileDataChangeInfo *fdci, FileData *fd)
+{
+ if (!fdci && fd) fdci = fd->change;
+
+ if (!fdci) return;
+
+ g_free(fdci->source);
+ g_free(fdci->dest);
+
+ g_free(fdci);
+
+ if (fd) fd->change = NULL;
+}
+
+static gboolean file_data_can_write_directly(FileData *fd)
+{
+ return filter_name_is_writable(fd->extension);
+}
+
+static gboolean file_data_can_write_sidecar(FileData *fd)
+{
+ return filter_name_allow_sidecar(fd->extension) && !filter_name_is_writable(fd->extension);
+}
+
+gchar *file_data_get_sidecar_path(FileData *fd, gboolean existing_only)
+{
+ gchar *sidecar_path = NULL;
+ GList *work;
+
+ if (!file_data_can_write_sidecar(fd)) return NULL;
+
+ work = fd->parent ? fd->parent->sidecar_files : fd->sidecar_files;
+ while (work)
+ {
+ FileData *sfd = work->data;
+ work = work->next;
+ if (g_ascii_strcasecmp(sfd->extension, ".xmp") == 0)
+ {
+ sidecar_path = g_strdup(sfd->path);
+ break;
+ }
+ }
+
+ if (!existing_only && !sidecar_path)
+ {
+ gchar *base = g_strndup(fd->path, fd->extension - fd->path);
+ sidecar_path = g_strconcat(base, ".xmp", NULL);
+ g_free(base);
+ }
+
+ return sidecar_path;
+}
/*
* marks and orientation
implementation in view_file_list.c */
+typedef struct _NotifyIdleData NotifyIdleData;
+
+struct _NotifyIdleData {
+ FileData *fd;
+ NotifyType type;
+};
typedef struct _NotifyData NotifyData;
}
-void file_data_send_notification(FileData *fd, NotifyType type)
+gboolean file_data_send_notification_idle_cb(gpointer data)
{
+ NotifyIdleData *nid = (NotifyIdleData *)data;
GList *work = notify_func_list;
while (work)
{
NotifyData *nd = (NotifyData *)work->data;
- nd->func(fd, type, nd->data);
+ nd->func(nid->fd, nid->type, nd->data);
work = work->next;
}
+ file_data_unref(nid->fd);
+ g_free(nid);
+ return FALSE;
+}
+
+void file_data_send_notification(FileData *fd, NotifyType type)
+{
+ NotifyIdleData *nid = g_new0(NotifyIdleData, 1);
+ nid->fd = file_data_ref(fd);
+ nid->type = type;
+ g_idle_add_full(G_PRIORITY_HIGH, file_data_send_notification_idle_cb, nid, NULL);
}
static GHashTable *file_data_monitor_pool = NULL;
gchar *text_from_size_abrev(gint64 size);
const gchar *text_from_time(time_t t);
-/* this expects a utf-8 path */
-FileData *file_data_new_simple(const gchar *path_utf8);
+/* scan for sidecar files - expensive */
+FileData *file_data_new_group(const gchar *path_utf8);
+
+/* should be used on helper files which can't have sidecars */
+FileData *file_data_new_no_grouping(const gchar *path_utf8);
+
+/* should be used on dirs */
+FileData *file_data_new_dir(const gchar *path_utf8);
#ifdef DEBUG_FILEDATA
FileData *file_data_ref_debug(const gchar *file, gint line, FileData *fd);
work = work->next;
name = gdk_pixbuf_format_get_name(format);
+
+ if (strcmp(name, "Digital camera RAW") == 0)
+ {
+ DEBUG_1("Skipped '%s' from loader", name);
+ g_free(name);
+ continue;
+ }
+
desc = gdk_pixbuf_format_get_description(format);
extensions = gdk_pixbuf_format_get_extensions(format);
filter_add_if_missing("ico", "Icon file", ".ico;.cur", FORMAT_CLASS_IMAGE, TRUE, FALSE, FALSE);
filter_add_if_missing("ras", "Raster", ".ras", FORMAT_CLASS_IMAGE, TRUE, FALSE, FALSE);
filter_add_if_missing("svg", "Scalable Vector Graphics", ".svg", FORMAT_CLASS_IMAGE, TRUE, FALSE, FALSE);
-
+
+ /* special formats for stereo */
+ filter_add_if_missing("jps", "Stereo side-by-side jpeg", ".jps", FORMAT_CLASS_IMAGE, TRUE, FALSE, TRUE);
+ filter_add_if_missing("mpo", "Stereo multi-image jpeg", ".mpo", FORMAT_CLASS_IMAGE, FALSE, TRUE, TRUE);
+
/* non-image files that might be desirable to show */
filter_add_if_missing("xmp", "XMP sidecar", ".xmp", FORMAT_CLASS_META, TRUE, FALSE, TRUE);
filter_add_if_missing("gqv", GQ_APPNAME " image collection", GQ_COLLECTION_EXT, FORMAT_CLASS_META, FALSE, FALSE, TRUE);
filter_add_if_missing("ufraw", "UFRaw ID file", ".ufraw", FORMAT_CLASS_META, FALSE, FALSE, TRUE);
+ filter_add_if_missing("pto", "Panorama script file", ".pto", FORMAT_CLASS_META, FALSE, FALSE, TRUE);
/* These are the raw camera formats with embedded jpeg/exif.
* (see format_raw.c and/or exiv2.cc)
return list;
}
+static gint filter_sort_ext_len_cb(gconstpointer a, gconstpointer b)
+{
+ gchar *sa = (gchar *)a;
+ gchar *sb = (gchar *)b;
+
+ gint len_a = strlen(sa);
+ gint len_b = strlen(sb);
+
+ if (len_a > len_b) return -1;
+ if (len_a < len_b) return 1;
+ return 0;
+}
+
+
void filter_rebuild(void)
{
GList *work;
}
}
+ /* make sure registered_extension_from_path finds the longer match first */
+ extension_list = g_list_sort(extension_list, filter_sort_ext_len_cb);
sidecar_ext_parse(options->sidecar.ext); /* this must be updated after changed file extensions */
}
-static gboolean filter_name_find(GList *filter, const gchar *name)
+/* return the extension part of the name or NULL */
+static const gchar *filter_name_find(GList *filter, const gchar *name)
{
GList *work;
guint ln;
if (ln >= lf)
{
/* FIXME: utf8 */
- if (g_ascii_strncasecmp(name + ln - lf, filter, lf) == 0) return TRUE;
+ if (g_ascii_strncasecmp(name + ln - lf, filter, lf) == 0) return name + ln - lf;
}
work = work->next;
}
- return FALSE;
+ return NULL;
+}
+const gchar *registered_extension_from_path(const gchar *name)
+{
+ return filter_name_find(extension_list, name);
}
-
gboolean filter_name_exists(const gchar *name)
{
if (!extension_list || options->file_filter.disable) return TRUE;
- return filter_name_find(extension_list, name);
+ return !!filter_name_find(extension_list, name);
}
gboolean filter_file_class(const gchar *name, FileFormatClass file_class)
return FALSE;
}
- return filter_name_find(file_class_extension_list[file_class], name);
+ return !!filter_name_find(file_class_extension_list[file_class], name);
}
gboolean filter_name_is_writable(const gchar *name)
{
- return filter_name_find(file_writable_list, name);
+ return !!filter_name_find(file_writable_list, name);
}
gboolean filter_name_allow_sidecar(const gchar *name)
{
- return filter_name_find(file_sidecar_list, name);
+ return !!filter_name_find(file_sidecar_list, name);
}
void filter_write_list(GString *outstr, gint indent)
void filter_rebuild(void);
GList *filter_to_list(const gchar *extensions);
+const gchar *registered_extension_from_path(const gchar *name);
gboolean filter_name_exists(const gchar *name);
gboolean filter_file_class(const gchar *name, FileFormatClass file_class);
gboolean filter_name_is_writable(const gchar *name);
image_background_set_color_from_options(fs->imd, TRUE);
image_set_delay_flip(fs->imd, options->fullscreen.clean_flip);
image_auto_refresh_enable(fs->imd, fs->normal_imd->auto_refresh);
-
+
if (options->fullscreen.clean_flip)
{
image_set_update_func(fs->imd, fullscreen_image_update_cb, fs);
image_change_from_image(fs->imd, fs->normal_imd);
+ if (options->stereo.enable_fsmode) {
+ image_stereo_set(fs->imd, options->stereo.fsmode);
+ }
+
gtk_widget_show(fs->window);
/* for hiding the mouse */
gdk_keyboard_ungrab(GDK_CURRENT_TIME);
image_change_from_image(fs->normal_imd, fs->imd);
+
+ if (options->stereo.enable_fsmode) {
+ image_stereo_set(fs->normal_imd, options->stereo.mode);
+ }
+
#ifdef HIDE_WINDOW_IN_FULLSCREEN
gtk_widget_show(fs->normal_window);
#endif
data2);
}
+void gq_marshal_VOID__INT_INT(GClosure *closure,
+ GValue *return_value G_GNUC_UNUSED,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint G_GNUC_UNUSED,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__INT_INT) (gpointer data1,
+ gint arg_1,
+ gint arg_2,
+ gpointer data2);
+ register GMarshalFunc_VOID__INT_INT callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail(n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA(closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer(param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer(param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__INT_INT) (marshal_data ? marshal_data : cc->callback);
+
+ callback(data1,
+ g_marshal_value_peek_int(param_values + 1),
+ g_marshal_value_peek_int(param_values + 2),
+ data2);
+}
+
/* VOID:DOUBLE (gq-marshal.list:3) */
/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
gpointer invocation_hint,
gpointer marshal_data);
+extern void gq_marshal_VOID__INT_INT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
/* VOID:DOUBLE (gq-marshal.list:3) */
#define gq_marshal_VOID__DOUBLE g_cclosure_marshal_VOID__DOUBLE
#include "main.h"
#include "image-load.h"
+#include "image_load_gdk.h"
+#include "image_load_jpeg.h"
+#include "image_load_tiff.h"
#include "exif.h"
#include "filedata.h"
SIGNAL_ERROR,
SIGNAL_DONE,
SIGNAL_PERCENT,
+ SIGNAL_SIZE,
SIGNAL_COUNT
};
il->requested_width = 0;
il->requested_height = 0;
+ il->actual_width = 0;
+ il->actual_height = 0;
il->shrunk = FALSE;
il->can_destroy = TRUE;
G_TYPE_NONE, 1,
G_TYPE_DOUBLE);
+ signals[SIGNAL_SIZE] =
+ g_signal_new("size_prepared",
+ G_OBJECT_CLASS_TYPE(gobject_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(ImageLoaderClass, area_ready),
+ NULL, NULL,
+ gq_marshal_VOID__INT_INT,
+ G_TYPE_NONE, 2,
+ G_TYPE_INT,
+ G_TYPE_INT);
+
}
static void image_loader_finalize(GObject *object)
return FALSE;
}
+static gboolean image_loader_emit_size_cb(gpointer data)
+{
+ gint width, height;
+ ImageLoader *il = data;
+ g_mutex_lock(il->data_mutex);
+ width = il->actual_width;
+ height = il->actual_height;
+ g_mutex_unlock(il->data_mutex);
+ g_signal_emit(il, signals[SIGNAL_SIZE], 0, width, height);
+ return FALSE;
+}
+
+
/* DONE and ERROR are emited only once, thus they can have normal priority
PERCENT and AREA_READY should be processed ASAP
*/
g_idle_add_full(G_PRIORITY_HIGH, image_loader_emit_percent_cb, il, NULL);
}
+static void image_loader_emit_size(ImageLoader *il)
+{
+ g_idle_add_full(G_PRIORITY_HIGH, image_loader_emit_size_cb, il, NULL);
+}
+
/* this function expects that il->data_mutex is locked by caller */
static void image_loader_emit_area_ready(ImageLoader *il, guint x, guint y, guint w, guint h)
{
/* the following functions may be executed in separate thread */
/* this function expects that il->data_mutex is locked by caller */
-static void image_loader_queue_delayed_erea_ready(ImageLoader *il, guint x, guint y, guint w, guint h)
+static void image_loader_queue_delayed_area_ready(ImageLoader *il, guint x, guint y, guint w, guint h)
{
ImageLoaderAreaParam *par = g_new0(ImageLoaderAreaParam, 1);
par->il = il;
return;
}
- pb = gdk_pixbuf_loader_get_pixbuf(il->loader);
+ pb = il->backend.get_pixbuf(il->loader);
if (pb == il->pixbuf)
{
return;
}
+ if (g_ascii_strcasecmp(".jps", il->fd->extension) == 0)
+ {
+ g_object_set_data(G_OBJECT(pb), "stereo_data", GINT_TO_POINTER(STEREO_PIXBUF_CROSS));
+ }
+
if (il->pixbuf) g_object_unref(il->pixbuf);
il->pixbuf = pb;
g_mutex_unlock(il->data_mutex);
}
-static void image_loader_area_updated_cb(GdkPixbufLoader *loader,
+static void image_loader_area_updated_cb(gpointer loader,
guint x, guint y, guint w, guint h,
gpointer data)
{
g_mutex_lock(il->data_mutex);
if (il->delay_area_ready)
- image_loader_queue_delayed_erea_ready(il, x, y, w, h);
+ image_loader_queue_delayed_area_ready(il, x, y, w, h);
else
image_loader_emit_area_ready(il, x, y, w, h);
+
+ if (il->stopping) il->backend.abort(il->loader);
+
g_mutex_unlock(il->data_mutex);
}
-static void image_loader_area_prepared_cb(GdkPixbufLoader *loader, gpointer data)
+static void image_loader_area_prepared_cb(gpointer loader, gpointer data)
{
+ ImageLoader *il = data;
GdkPixbuf *pb;
guchar *pix;
size_t h, rs;
http://bugzilla.gnome.org/show_bug.cgi?id=547669
http://bugzilla.gnome.org/show_bug.cgi?id=589334
*/
- gchar *format = gdk_pixbuf_format_get_name(gdk_pixbuf_loader_get_format(loader));
+ gchar *format = il->backend.get_format_name(loader);
if (strcmp(format, "svg") == 0 ||
strcmp(format, "xpm") == 0)
{
g_free(format);
- pb = gdk_pixbuf_loader_get_pixbuf(loader);
+ pb = il->backend.get_pixbuf(loader);
h = gdk_pixbuf_get_height(pb);
rs = gdk_pixbuf_get_rowstride(pb);
}
-static void image_loader_size_cb(GdkPixbufLoader *loader,
+static void image_loader_size_cb(gpointer loader,
gint width, gint height, gpointer data)
{
ImageLoader *il = data;
- GdkPixbufFormat *format;
gchar **mime_types;
gboolean scale = FALSE;
gint n;
g_mutex_lock(il->data_mutex);
+ il->actual_width = width;
+ il->actual_height = height;
if (il->requested_width < 1 || il->requested_height < 1)
{
g_mutex_unlock(il->data_mutex);
+ image_loader_emit_size(il);
return;
}
g_mutex_unlock(il->data_mutex);
- format = gdk_pixbuf_loader_get_format(loader);
- if (!format) return;
-
- mime_types = gdk_pixbuf_format_get_mime_types(format);
+ mime_types = il->backend.get_format_mime_types(loader);
n = 0;
while (mime_types[n])
{
}
g_strfreev(mime_types);
- if (!scale) return;
+ if (!scale)
+ {
+ image_loader_emit_size(il);
+ return;
+ }
g_mutex_lock(il->data_mutex);
+ gint nw, nh;
if (width > il->requested_width || height > il->requested_height)
{
- gint nw, nh;
if (((gdouble)il->requested_width / width) < ((gdouble)il->requested_height / height))
{
if (nw < 1) nw = 1;
}
- gdk_pixbuf_loader_set_size(loader, nw, nh);
+ il->actual_width = nw;
+ il->actual_height = nh;
+ il->backend.set_size(loader, nw, nh);
il->shrunk = TRUE;
}
- g_mutex_unlock(il->data_mutex);
+ g_mutex_unlock(il->data_mutex);
+ image_loader_emit_size(il);
}
static void image_loader_stop_loader(ImageLoader *il)
if (il->loader)
{
/* some loaders do not have a pixbuf till close, order is important here */
- gdk_pixbuf_loader_close(il->loader, il->error ? NULL : &il->error); /* we are interested in the first error only */
+ il->backend.close(il->loader, il->error ? NULL : &il->error); /* we are interested in the first error only */
image_loader_sync_pixbuf(il);
- g_object_unref(G_OBJECT(il->loader));
+ il->backend.free(il->loader);
il->loader = NULL;
}
g_mutex_lock(il->data_mutex);
static void image_loader_setup_loader(ImageLoader *il)
{
g_mutex_lock(il->data_mutex);
- il->loader = gdk_pixbuf_loader_new();
-
- g_signal_connect(G_OBJECT(il->loader), "area_updated",
- G_CALLBACK(image_loader_area_updated_cb), il);
- g_signal_connect(G_OBJECT(il->loader), "size_prepared",
- G_CALLBACK(image_loader_size_cb), il);
- g_signal_connect(G_OBJECT(il->loader), "area_prepared",
- G_CALLBACK(image_loader_area_prepared_cb), il);
+#ifdef HAVE_JPEG
+ if (il->bytes_total >= 2 && il->mapped_file[0] == 0xff && il->mapped_file[1] == 0xd8)
+ {
+ DEBUG_1("Using custom jpeg loader");
+ image_loader_backend_set_jpeg(&il->backend);
+ }
+ else
+#endif
+#ifdef HAVE_TIFF
+ if (il->bytes_total >= 10 &&
+ (memcmp(il->mapped_file, "MM\0*", 4) == 0 ||
+ memcmp(il->mapped_file, "II*\0", 4) == 0))
+ {
+ DEBUG_1("Using custom tiff loader");
+ image_loader_backend_set_tiff(&il->backend);
+ }
+ else
+#endif
+ image_loader_backend_set_default(&il->backend);
+
+ il->loader = il->backend.loader_new(image_loader_area_updated_cb, image_loader_size_cb, image_loader_area_prepared_cb, il);
g_mutex_unlock(il->data_mutex);
}
return FALSE;
}
- if (b < 0 || (b > 0 && !gdk_pixbuf_loader_write(il->loader, il->mapped_file + il->bytes_read, b, &il->error)))
+ if (b < 0 || (b > 0 && !il->backend.write(il->loader, il->mapped_file + il->bytes_read, b, &il->error)))
{
image_loader_error(il);
return FALSE;
if (b < 1) return FALSE;
image_loader_setup_loader(il);
-
- if (!gdk_pixbuf_loader_write(il->loader, il->mapped_file + il->bytes_read, b, &il->error))
+
+ g_assert(il->bytes_read == 0);
+ if (il->backend.load) {
+ b = il->bytes_total;
+ if (!il->backend.load(il->loader, il->mapped_file, b, &il->error))
+ {
+ image_loader_stop_loader(il);
+ return FALSE;
+ }
+ }
+ else if (!il->backend.write(il->loader, il->mapped_file, b, &il->error))
{
image_loader_stop_loader(il);
return FALSE;
il->bytes_read += b;
/* read until size is known */
- while (il->loader && !gdk_pixbuf_loader_get_pixbuf(il->loader) && b > 0 && !image_loader_get_stopping(il))
+ while (il->loader && !il->backend.get_pixbuf(il->loader) && b > 0 && !image_loader_get_stopping(il))
{
b = MIN(il->read_buffer_size, il->bytes_total - il->bytes_read);
- if (b < 0 || (b > 0 && !gdk_pixbuf_loader_write(il->loader, il->mapped_file + il->bytes_read, b, &il->error)))
+ if (b < 0 || (b > 0 && !il->backend.write(il->loader, il->mapped_file + il->bytes_read, b, &il->error)))
{
image_loader_stop_loader(il);
return FALSE;
gchar *image_loader_get_format(ImageLoader *il)
{
- GdkPixbufFormat *format;
gchar **mimev;
gchar *mime;
if (!il || !il->loader) return NULL;
- format = gdk_pixbuf_loader_get_format(il->loader);
- if (!format) return NULL;
-
- mimev = gdk_pixbuf_format_get_mime_types(format);
+ mimev = il->backend.get_format_mime_types(il->loader);
if (!mimev) return NULL;
/* return first member of mimev, as GdkPixbufLoader has no way to tell us which exact one ? */
#define TYPE_IMAGE_LOADER (image_loader_get_type())
+typedef void (*ImageLoaderBackendCbAreaPrepared)(gpointer loader, gpointer data);
+typedef void (*ImageLoaderBackendCbSize)(gpointer loader, gint width, gint height, gpointer data);
+typedef void (*ImageLoaderBackendCbAreaUpdated)(gpointer loader, guint x, guint y, guint w, guint h, gpointer data);
+
+typedef gpointer (*ImageLoaderBackendFuncLoaderNew)(ImageLoaderBackendCbAreaUpdated, ImageLoaderBackendCbSize, ImageLoaderBackendCbAreaPrepared, gpointer data);
+typedef void (*ImageLoaderBackendFuncSetSize)(gpointer loader, int width, int height);
+typedef gboolean (*ImageLoaderBackendFuncLoad)(gpointer loader, const guchar *buf, gsize count, GError **error); /* optional, load whole image at once */
+typedef gboolean (*ImageLoaderBackendFuncWrite)(gpointer loader, const guchar *buf, gsize count, GError **error);
+typedef GdkPixbuf* (*ImageLoaderBackendFuncGetPixbuf)(gpointer loader);
+typedef gboolean (*ImageLoaderBackendFuncClose)(gpointer loader, GError **error);
+typedef void (*ImageLoaderBackendFuncAbort)(gpointer loader);
+typedef void (*ImageLoaderBackendFuncFree)(gpointer loader);
+typedef gchar* (*ImageLoaderBackendFuncGetFormatName)(gpointer loader);
+typedef gchar** (*ImageLoaderBackendFuncGetFormatMimeTypes)(gpointer loader);
+
+typedef struct _ImageLoaderBackend ImageLoaderBackend;
+struct _ImageLoaderBackend
+{
+ ImageLoaderBackendFuncLoaderNew loader_new;
+ ImageLoaderBackendFuncSetSize set_size;
+ ImageLoaderBackendFuncLoad load;
+ ImageLoaderBackendFuncWrite write;
+ ImageLoaderBackendFuncGetPixbuf get_pixbuf;
+ ImageLoaderBackendFuncClose close;
+ ImageLoaderBackendFuncAbort abort;
+ ImageLoaderBackendFuncFree free;
+ ImageLoaderBackendFuncGetFormatName get_format_name;
+ ImageLoaderBackendFuncGetFormatMimeTypes get_format_mime_types;
+};
+
+
//typedef struct _ImageLoader ImageLoader;
typedef struct _ImageLoaderClass ImageLoaderClass;
gint requested_width;
gint requested_height;
+
+ gint actual_width;
+ gint actual_height;
+
gboolean shrunk;
gboolean done;
guint idle_id; /* event source id */
gint idle_priority;
- GdkPixbufLoader *loader;
+ gpointer *loader;
GError *error;
+ ImageLoaderBackend backend;
guint idle_done_id; /* event source id */
GList *area_param_list;
image_read_ahead_start(imd);
}
+static void image_load_size_cb(ImageLoader *il, guint width, guint height, gpointer data)
+{
+ ImageWindow *imd = data;
+
+ DEBUG_1("image_load_size_cb: %dx%d", width, height);
+ pixbuf_renderer_set_size_early((PixbufRenderer *)imd->pr, width, height);
+}
+
static void image_load_error_cb(ImageLoader *il, gpointer data)
{
DEBUG_1("%s image error", get_exec_time());
g_signal_connect(G_OBJECT(imd->il), "area_ready", (GCallback)image_load_area_cb, imd);
g_signal_connect(G_OBJECT(imd->il), "error", (GCallback)image_load_error_cb, imd);
g_signal_connect(G_OBJECT(imd->il), "done", (GCallback)image_load_done_cb, imd);
+ g_signal_connect(G_OBJECT(imd->il), "size_prepared", (GCallback)image_load_size_cb, imd);
}
/* this read ahead is located here merely for the callbacks, above */
void image_change_pixbuf(ImageWindow *imd, GdkPixbuf *pixbuf, gdouble zoom, gboolean lazy)
{
-
+ StereoPixbufData stereo_data = STEREO_PIXBUF_DEFAULT;
/* read_exif and similar functions can actually notice that the file has changed and trigger
a notification that removes the pixbuf from cache and unrefs it. Therefore we must ref it
here before it is taken over by the renderer. */
}
}
+ if (pixbuf)
+ {
+ stereo_data = imd->user_stereo;
+ if (stereo_data == STEREO_PIXBUF_DEFAULT)
+ {
+ stereo_data = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(pixbuf), "stereo_data"));
+ }
+ }
+
pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, NULL, NULL, FALSE);
if (imd->cm)
{
if (lazy)
{
- pixbuf_renderer_set_pixbuf_lazy((PixbufRenderer *)imd->pr, pixbuf, zoom, imd->orientation);
+ pixbuf_renderer_set_pixbuf_lazy((PixbufRenderer *)imd->pr, pixbuf, zoom, imd->orientation, stereo_data);
}
else
{
pixbuf_renderer_set_pixbuf((PixbufRenderer *)imd->pr, pixbuf, zoom);
pixbuf_renderer_set_orientation((PixbufRenderer *)imd->pr, imd->orientation);
+ pixbuf_renderer_set_stereo_data((PixbufRenderer *)imd->pr, stereo_data);
}
if (pixbuf) g_object_unref(pixbuf);
imd->orientation = source->orientation;
imd->desaturate = source->desaturate;
+ imd->user_stereo = source->user_stereo;
+
pixbuf_renderer_move(PIXBUF_RENDERER(imd->pr), PIXBUF_RENDERER(source->pr));
if (imd->cm || imd->desaturate)
if (vertical)
{
- zoom = (gdouble)pr->window_height / height;
+ zoom = (gdouble)pr->viewport_height / height;
}
else
{
- zoom = (gdouble)pr->window_width / width;
+ zoom = (gdouble)pr->viewport_width / width;
}
if (zoom < 1.0)
return zoom;
}
+/* stereo */
+gint image_stereo_get(ImageWindow *imd)
+{
+ return pixbuf_renderer_stereo_get((PixbufRenderer *)imd->pr);
+}
+
+void image_stereo_set(ImageWindow *imd, gint stereo_mode)
+{
+ DEBUG_1("Setting stereo mode %04x for imd %p", stereo_mode, imd);
+ pixbuf_renderer_stereo_set((PixbufRenderer *)imd->pr, stereo_mode);
+}
+
+void image_stereo_swap(ImageWindow *imd)
+{
+ gint stereo_mode = pixbuf_renderer_stereo_get((PixbufRenderer *)imd->pr);
+ stereo_mode ^= PR_STEREO_SWAP;
+ pixbuf_renderer_stereo_set((PixbufRenderer *)imd->pr, stereo_mode);
+}
+
+StereoPixbufData image_stereo_pixbuf_get(ImageWindow *imd)
+{
+ return imd->user_stereo;
+}
+
+void image_stereo_pixbuf_set(ImageWindow *imd, StereoPixbufData stereo_mode)
+{
+ imd->user_stereo = stereo_mode;
+ image_reload(imd);
+}
+
/* read ahead */
void image_prebuffer_set(ImageWindow *imd, FileData *fd)
NULL);
pixbuf_renderer_set_parent((PixbufRenderer *)imd->pr, (GtkWindow *)imd->top_window);
+
+ image_stereo_set(imd, options->stereo.mode);
+ pixbuf_renderer_stereo_fixed_set((PixbufRenderer *)imd->pr,
+ options->stereo.fixed_w, options->stereo.fixed_h,
+ options->stereo.fixed_x1, options->stereo.fixed_y1,
+ options->stereo.fixed_x2, options->stereo.fixed_y2);
}
void image_options_sync(void)
gchar *image_zoom_get_as_text(ImageWindow *imd);
gdouble image_zoom_get_default(ImageWindow *imd);
+/* stereo */
+gint image_stereo_get(ImageWindow *imd);
+void image_stereo_set(ImageWindow *imd, gint stereo_mode);
+void image_stereo_swap(ImageWindow *imd);
+
+StereoPixbufData image_stereo_pixbuf_get(ImageWindow *imd);
+void image_stereo_pixbuf_set(ImageWindow *imd, StereoPixbufData stereo_mode);
+
/* read ahead, pass NULL to cancel */
void image_prebuffer_set(ImageWindow *imd, FileData *fd);
--- /dev/null
+/*
+ * Geeqie
+ * (C) 2004 John Ellis
+ * Copyright (C) 2008 - 2011 The Geeqie Team
+ *
+ * Author: Vladimir Nadvornik
+ *
+ * This software is released under the GNU General Public License (GNU GPL).
+ * Please read the included file COPYING for more information.
+ * This software comes with no warranty of any kind, use at your own risk!
+ */
+
+#include "main.h"
+#include "image-load.h"
+#include "image_load_gdk.h"
+
+
+static gchar* image_loader_gdk_get_format_name(gpointer loader)
+{
+ return gdk_pixbuf_format_get_name(gdk_pixbuf_loader_get_format(GDK_PIXBUF_LOADER(loader)));
+}
+static gchar** image_loader_gdk_get_format_mime_types(gpointer loader)
+{
+ return gdk_pixbuf_format_get_mime_types(gdk_pixbuf_loader_get_format(GDK_PIXBUF_LOADER(loader)));
+}
+
+static gpointer image_loader_gdk_new(ImageLoaderBackendCbAreaUpdated area_updated_cb, ImageLoaderBackendCbSize size_cb, ImageLoaderBackendCbAreaPrepared area_prepared_cb, gpointer data)
+{
+ GdkPixbufLoader *loader = gdk_pixbuf_loader_new();
+
+ g_signal_connect(G_OBJECT(loader), "area_updated", G_CALLBACK(area_updated_cb), data);
+ g_signal_connect(G_OBJECT(loader), "size_prepared", G_CALLBACK(size_cb), data);
+ g_signal_connect(G_OBJECT(loader), "area_prepared", G_CALLBACK(area_prepared_cb), data);
+ return (gpointer) loader;
+}
+
+static void image_loader_gdk_abort(gpointer loader)
+{
+}
+
+static void image_loader_gdk_free(gpointer loader)
+{
+ g_object_unref(G_OBJECT(loader));
+}
+
+void image_loader_backend_set_default(ImageLoaderBackend *funcs)
+{
+ funcs->loader_new = image_loader_gdk_new;
+ funcs->set_size = (ImageLoaderBackendFuncSetSize) gdk_pixbuf_loader_set_size;
+ funcs->load = NULL;
+ funcs->write = (ImageLoaderBackendFuncWrite) gdk_pixbuf_loader_write;
+ funcs->get_pixbuf = (ImageLoaderBackendFuncGetPixbuf) gdk_pixbuf_loader_get_pixbuf;
+ funcs->close = (ImageLoaderBackendFuncClose) gdk_pixbuf_loader_close;
+ funcs->abort = image_loader_gdk_abort;
+ funcs->free = image_loader_gdk_free;
+
+ funcs->get_format_name = image_loader_gdk_get_format_name;
+ funcs->get_format_mime_types = image_loader_gdk_get_format_mime_types;
+}
+
+
+
--- /dev/null
+/*
+ * Geeqie
+ * (C) 2004 John Ellis
+ * Copyright (C) 2008 - 2011 The Geeqie Team
+ *
+ * Author: Vladimir Nadvornik
+ *
+ * This software is released under the GNU General Public License (GNU GPL).
+ * Please read the included file COPYING for more information.
+ * This software comes with no warranty of any kind, use at your own risk!
+ */
+
+#ifndef IMAGE_LOAD_GDK_H
+#define IMAGE_LOAD_GDK_H
+
+void image_loader_backend_set_default(ImageLoaderBackend *funcs);
+
+#endif
+
--- /dev/null
+/*
+ * Geeqie
+ * (C) 2004 John Ellis
+ * Copyright (C) 2008 - 2011 The Geeqie Team
+ *
+ * Author: Vladimir Nadvornik
+ *
+ * This software is released under the GNU General Public License (GNU GPL).
+ * Please read the included file COPYING for more information.
+ * This software comes with no warranty of any kind, use at your own risk!
+ */
+
+/* based on code from GdkPixbuf library - JPEG image loader
+ *
+ * Copyright (C) 1999 Michael Zucchi
+ * Copyright (C) 1999 The Free Software Foundation
+ *
+ * Progressive loading code Copyright (C) 1999 Red Hat, Inc.
+ *
+ * Authors: Michael Zucchi <zucchi@zedzone.mmc.com.au>
+ * Federico Mena-Quintero <federico@gimp.org>
+ * Michael Fulbright <drmike@redhat.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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.
+ */
+
+
+#include "main.h"
+
+#include "image-load.h"
+#include "image_load_jpeg.h"
+#include "jpeg_parser.h"
+
+#ifdef HAVE_JPEG
+
+#include <setjmp.h>
+#include <jpeglib.h>
+#include <jerror.h>
+
+typedef struct _ImageLoaderJpeg ImageLoaderJpeg;
+struct _ImageLoaderJpeg {
+ ImageLoaderBackendCbAreaUpdated area_updated_cb;
+ ImageLoaderBackendCbSize size_cb;
+ ImageLoaderBackendCbAreaPrepared area_prepared_cb;
+
+ gpointer data;
+
+ GdkPixbuf *pixbuf;
+ guint requested_width;
+ guint requested_height;
+
+ gboolean abort;
+ gboolean stereo;
+
+};
+
+/* error handler data */
+struct error_handler_data {
+ struct jpeg_error_mgr pub;
+ sigjmp_buf setjmp_buffer;
+ GError **error;
+};
+
+/* explode gray image data from jpeg library into rgb components in pixbuf */
+static void
+explode_gray_into_buf (struct jpeg_decompress_struct *cinfo,
+ guchar **lines)
+{
+ gint i, j;
+ guint w;
+
+ g_return_if_fail (cinfo != NULL);
+ g_return_if_fail (cinfo->output_components == 1);
+ g_return_if_fail (cinfo->out_color_space == JCS_GRAYSCALE);
+
+ /* Expand grey->colour. Expand from the end of the
+ * memory down, so we can use the same buffer.
+ */
+ w = cinfo->output_width;
+ for (i = cinfo->rec_outbuf_height - 1; i >= 0; i--) {
+ guchar *from, *to;
+
+ from = lines[i] + w - 1;
+ to = lines[i] + (w - 1) * 3;
+ for (j = w - 1; j >= 0; j--) {
+ to[0] = from[0];
+ to[1] = from[0];
+ to[2] = from[0];
+ to -= 3;
+ from--;
+ }
+ }
+}
+
+
+static void
+convert_cmyk_to_rgb (struct jpeg_decompress_struct *cinfo,
+ guchar **lines)
+{
+ gint i, j;
+
+ g_return_if_fail (cinfo != NULL);
+ g_return_if_fail (cinfo->output_components == 4);
+ g_return_if_fail (cinfo->out_color_space == JCS_CMYK);
+
+ for (i = cinfo->rec_outbuf_height - 1; i >= 0; i--) {
+ guchar *p;
+
+ p = lines[i];
+ for (j = 0; j < cinfo->output_width; j++) {
+ int c, m, y, k;
+ c = p[0];
+ m = p[1];
+ y = p[2];
+ k = p[3];
+ if (cinfo->saw_Adobe_marker) {
+ p[0] = k*c / 255;
+ p[1] = k*m / 255;
+ p[2] = k*y / 255;
+ }
+ else {
+ p[0] = (255 - k)*(255 - c) / 255;
+ p[1] = (255 - k)*(255 - m) / 255;
+ p[2] = (255 - k)*(255 - y) / 255;
+ }
+ p[3] = 255;
+ p += 4;
+ }
+ }
+}
+
+
+static gpointer image_loader_jpeg_new(ImageLoaderBackendCbAreaUpdated area_updated_cb, ImageLoaderBackendCbSize size_cb, ImageLoaderBackendCbAreaPrepared area_prepared_cb, gpointer data)
+{
+ ImageLoaderJpeg *loader = g_new0(ImageLoaderJpeg, 1);
+
+ loader->area_updated_cb = area_updated_cb;
+ loader->size_cb = size_cb;
+ loader->area_prepared_cb = area_prepared_cb;
+ loader->data = data;
+ return (gpointer) loader;
+}
+
+static void
+fatal_error_handler (j_common_ptr cinfo)
+{
+ struct error_handler_data *errmgr;
+ char buffer[JMSG_LENGTH_MAX];
+
+ errmgr = (struct error_handler_data *) cinfo->err;
+
+ /* Create the message */
+ (* cinfo->err->format_message) (cinfo, buffer);
+
+ /* broken check for *error == NULL for robustness against
+ * crappy JPEG library
+ */
+ if (errmgr->error && *errmgr->error == NULL) {
+ g_set_error (errmgr->error,
+ GDK_PIXBUF_ERROR,
+ cinfo->err->msg_code == JERR_OUT_OF_MEMORY
+ ? GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY
+ : GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+ _("Error interpreting JPEG image file (%s)"),
+ buffer);
+ }
+
+ siglongjmp (errmgr->setjmp_buffer, 1);
+
+ g_assert_not_reached ();
+}
+
+static void
+output_message_handler (j_common_ptr cinfo)
+{
+ /* This method keeps libjpeg from dumping crap to stderr */
+
+ /* do nothing */
+}
+
+
+void image_loader_jpeg_read_scanline(struct jpeg_decompress_struct *cinfo, guchar **dptr, guint rowstride)
+{
+ guchar *lines[4];
+ guchar **lptr;
+ gint i;
+
+ lptr = lines;
+ for (i = 0; i < cinfo->rec_outbuf_height; i++)
+ {
+ *lptr++ = *dptr;
+ *dptr += rowstride;
+ }
+
+ jpeg_read_scanlines (cinfo, lines, cinfo->rec_outbuf_height);
+
+ switch (cinfo->out_color_space)
+ {
+ case JCS_GRAYSCALE:
+ explode_gray_into_buf (cinfo, lines);
+ break;
+ case JCS_RGB:
+ /* do nothing */
+ break;
+ case JCS_CMYK:
+ convert_cmyk_to_rgb (cinfo, lines);
+ break;
+ default:
+ break;
+ }
+}
+
+
+static void init_source (j_decompress_ptr cinfo) {}
+static boolean fill_input_buffer (j_decompress_ptr cinfo)
+{
+ ERREXIT(cinfo, JERR_INPUT_EMPTY);
+ return TRUE;
+}
+static void skip_input_data (j_decompress_ptr cinfo, long num_bytes)
+{
+ struct jpeg_source_mgr* src = (struct jpeg_source_mgr*) cinfo->src;
+
+ if (num_bytes > src->bytes_in_buffer)
+ {
+ ERREXIT(cinfo, JERR_INPUT_EOF);
+ }
+ else if (num_bytes > 0)
+ {
+ src->next_input_byte += (size_t) num_bytes;
+ src->bytes_in_buffer -= (size_t) num_bytes;
+ }
+}
+static void term_source (j_decompress_ptr cinfo) {}
+static void set_mem_src (j_decompress_ptr cinfo, void* buffer, long nbytes)
+{
+ struct jpeg_source_mgr* src;
+
+ if (cinfo->src == NULL)
+ { /* first time for this JPEG object? */
+ cinfo->src = (struct jpeg_source_mgr *) (*cinfo->mem->alloc_small) (
+ (j_common_ptr) cinfo, JPOOL_PERMANENT,
+ sizeof(struct jpeg_source_mgr));
+ }
+
+ src = (struct jpeg_source_mgr*) cinfo->src;
+ src->init_source = init_source;
+ src->fill_input_buffer = fill_input_buffer;
+ src->skip_input_data = skip_input_data;
+ src->resync_to_restart = jpeg_resync_to_restart; /* use default method */
+ src->term_source = term_source;
+ src->bytes_in_buffer = nbytes;
+ src->next_input_byte = (JOCTET*)buffer;
+}
+
+
+static gboolean image_loader_jpeg_load (gpointer loader, const guchar *buf, gsize count, GError **error)
+{
+ ImageLoaderJpeg *lj = (ImageLoaderJpeg *) loader;
+ struct jpeg_decompress_struct cinfo;
+ struct jpeg_decompress_struct cinfo2;
+ guchar *dptr, *dptr2;
+ guint rowstride;
+ guchar *stereo_buf2 = NULL;
+ guint stereo_length = 0;
+
+ struct error_handler_data jerr;
+
+ lj->stereo = FALSE;
+
+ MPOData *mpo = jpeg_get_mpo_data(buf, count);
+ if (mpo && mpo->num_images > 1)
+ {
+ guint i;
+ gint idx1 = -1, idx2 = -1;
+ guint num2 = 1;
+
+ for (i = 0; i < mpo->num_images; i++)
+ {
+ if (mpo->images[i].type_code == 0x20002)
+ {
+ if (mpo->images[i].MPIndividualNum == 1)
+ {
+ idx1 = i;
+ }
+ else if (mpo->images[i].MPIndividualNum > num2)
+ {
+ idx2 = i;
+ num2 = mpo->images[i].MPIndividualNum;
+ }
+ }
+ }
+
+ if (idx1 >= 0 && idx2 >= 0)
+ {
+ lj->stereo = TRUE;
+ stereo_buf2 = (unsigned char *)buf + mpo->images[idx2].offset;
+ stereo_length = mpo->images[idx2].length;
+ buf = (unsigned char *)buf + mpo->images[idx1].offset;
+ count = mpo->images[idx1].length;
+ }
+ }
+ jpeg_mpo_data_free(mpo);
+
+ /* setup error handler */
+ cinfo.err = jpeg_std_error (&jerr.pub);
+ if (lj->stereo) cinfo2.err = jpeg_std_error (&jerr.pub);
+ jerr.pub.error_exit = fatal_error_handler;
+ jerr.pub.output_message = output_message_handler;
+
+ jerr.error = error;
+
+
+ if (setjmp(jerr.setjmp_buffer))
+ {
+ /* If we get here, the JPEG code has signaled an error.
+ * We need to clean up the JPEG object, close the input file, and return.
+ */
+ jpeg_destroy_decompress(&cinfo);
+ if (lj->stereo) jpeg_destroy_decompress(&cinfo2);
+ return FALSE;
+ }
+
+ jpeg_create_decompress(&cinfo);
+
+ set_mem_src(&cinfo, (unsigned char *)buf, count);
+
+
+ jpeg_read_header(&cinfo, TRUE);
+
+ if (lj->stereo)
+ {
+ jpeg_create_decompress(&cinfo2);
+ set_mem_src(&cinfo2, stereo_buf2, stereo_length);
+ jpeg_read_header(&cinfo2, TRUE);
+
+ if (cinfo.image_width != cinfo2.image_width ||
+ cinfo.image_height != cinfo2.image_height)
+ {
+ DEBUG_1("stereo data with different size");
+ jpeg_destroy_decompress(&cinfo2);
+ lj->stereo = FALSE;
+ }
+ }
+
+
+
+ lj->requested_width = lj->stereo ? cinfo.image_width * 2: cinfo.image_width;
+ lj->requested_height = cinfo.image_height;
+ lj->size_cb(loader, lj->requested_width, lj->requested_height, lj->data);
+
+ cinfo.scale_num = 1;
+ for (cinfo.scale_denom = 2; cinfo.scale_denom <= 8; cinfo.scale_denom *= 2) {
+ jpeg_calc_output_dimensions(&cinfo);
+ if (cinfo.output_width < (lj->stereo ? lj->requested_width / 2 : lj->requested_width) || cinfo.output_height < lj->requested_height) {
+ cinfo.scale_denom /= 2;
+ break;
+ }
+ }
+ jpeg_calc_output_dimensions(&cinfo);
+ if (lj->stereo)
+ {
+ cinfo2.scale_num = cinfo.scale_num;
+ cinfo2.scale_denom = cinfo.scale_denom;
+ jpeg_calc_output_dimensions(&cinfo2);
+ jpeg_start_decompress(&cinfo2);
+ }
+
+
+ jpeg_start_decompress(&cinfo);
+
+
+ if (lj->stereo)
+ {
+ if (cinfo.output_width != cinfo2.output_width ||
+ cinfo.output_height != cinfo2.output_height ||
+ cinfo.out_color_components != cinfo2.out_color_components)
+ {
+ DEBUG_1("stereo data with different output size");
+ jpeg_destroy_decompress(&cinfo2);
+ lj->stereo = FALSE;
+ }
+ }
+
+
+ lj->pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
+ cinfo.out_color_components == 4 ? TRUE : FALSE,
+ 8, lj->stereo ? cinfo.output_width * 2: cinfo.output_width, cinfo.output_height);
+
+ if (!lj->pixbuf)
+ {
+ jpeg_destroy_decompress (&cinfo);
+ if (lj->stereo) jpeg_destroy_decompress (&cinfo2);
+ return 0;
+ }
+ if (lj->stereo) g_object_set_data(G_OBJECT(lj->pixbuf), "stereo_data", GINT_TO_POINTER(STEREO_PIXBUF_CROSS));
+ lj->area_prepared_cb(loader, lj->data);
+
+ rowstride = gdk_pixbuf_get_rowstride(lj->pixbuf);
+ dptr = gdk_pixbuf_get_pixels(lj->pixbuf);
+ dptr2 = gdk_pixbuf_get_pixels(lj->pixbuf) + ((cinfo.out_color_components == 4) ? 4 * cinfo.output_width : 3 * cinfo.output_width);
+
+
+ while (cinfo.output_scanline < cinfo.output_height && !lj->abort)
+ {
+ guint scanline = cinfo.output_scanline;
+ image_loader_jpeg_read_scanline(&cinfo, &dptr, rowstride);
+ lj->area_updated_cb(loader, 0, scanline, cinfo.output_width, cinfo.rec_outbuf_height, lj->data);
+ if (lj->stereo)
+ {
+ guint scanline = cinfo2.output_scanline;
+ image_loader_jpeg_read_scanline(&cinfo2, &dptr2, rowstride);
+ lj->area_updated_cb(loader, cinfo.output_width, scanline, cinfo2.output_width, cinfo2.rec_outbuf_height, lj->data);
+ }
+ }
+
+ jpeg_finish_decompress(&cinfo);
+ jpeg_destroy_decompress(&cinfo);
+ if (lj->stereo)
+ {
+ jpeg_finish_decompress(&cinfo);
+ jpeg_destroy_decompress(&cinfo);
+ }
+
+ return TRUE;
+}
+
+static void image_loader_jpeg_set_size(gpointer loader, int width, int height)
+{
+ ImageLoaderJpeg *lj = (ImageLoaderJpeg *) loader;
+ lj->requested_width = width;
+ lj->requested_height = height;
+}
+
+static GdkPixbuf* image_loader_jpeg_get_pixbuf(gpointer loader)
+{
+ ImageLoaderJpeg *lj = (ImageLoaderJpeg *) loader;
+ return lj->pixbuf;
+}
+
+static gchar* image_loader_jpeg_get_format_name(gpointer loader)
+{
+ return g_strdup("jpeg");
+}
+static gchar** image_loader_jpeg_get_format_mime_types(gpointer loader)
+{
+ static gchar *mime[] = {"image/jpeg", NULL};
+ return g_strdupv(mime);
+}
+
+static gboolean image_loader_jpeg_close(gpointer loader, GError **error)
+{
+ return TRUE;
+}
+
+static void image_loader_jpeg_abort(gpointer loader)
+{
+ ImageLoaderJpeg *lj = (ImageLoaderJpeg *) loader;
+ lj->abort = TRUE;
+}
+
+static void image_loader_jpeg_free(gpointer loader)
+{
+ ImageLoaderJpeg *lj = (ImageLoaderJpeg *) loader;
+ if (lj->pixbuf) g_object_unref(lj->pixbuf);
+ g_free(lj);
+}
+
+
+void image_loader_backend_set_jpeg(ImageLoaderBackend *funcs)
+{
+ funcs->loader_new = image_loader_jpeg_new;
+ funcs->set_size = image_loader_jpeg_set_size;
+ funcs->load = image_loader_jpeg_load;
+ funcs->write = NULL;
+ funcs->get_pixbuf = image_loader_jpeg_get_pixbuf;
+ funcs->close = image_loader_jpeg_close;
+ funcs->abort = image_loader_jpeg_abort;
+ funcs->free = image_loader_jpeg_free;
+
+ funcs->get_format_name = image_loader_jpeg_get_format_name;
+ funcs->get_format_mime_types = image_loader_jpeg_get_format_mime_types;
+}
+
+
+
+#endif
\ No newline at end of file
--- /dev/null
+/*
+ * Geeqie
+ * (C) 2004 John Ellis
+ * Copyright (C) 2008 - 2011 The Geeqie Team
+ *
+ * Author: Vladimir Nadvornik
+ *
+ * This software is released under the GNU General Public License (GNU GPL).
+ * Please read the included file COPYING for more information.
+ * This software comes with no warranty of any kind, use at your own risk!
+ */
+
+#ifndef IMAGE_LOAD_JPEG_H
+#define IMAGE_LOAD_JPEG_H
+
+#ifdef HAVE_JPEG
+void image_loader_backend_set_jpeg(ImageLoaderBackend *funcs);
+#endif
+
+#endif
+
--- /dev/null
+/*
+ * Geeqie
+ * (C) 2004 John Ellis
+ * Copyright (C) 2008 - 2011 The Geeqie Team
+ *
+ * Author: Vladimir Nadvornik
+ *
+ * This software is released under the GNU General Public License (GNU GPL).
+ * Please read the included file COPYING for more information.
+ * This software comes with no warranty of any kind, use at your own risk!
+ */
+
+/* based on code from GdkPixbuf library - TIFF image loader
+ *
+ * Copyright (C) 1999 Mark Crichton
+ * Copyright (C) 1999 The Free Software Foundation
+ *
+ * Authors: Mark Crichton <crichton@gimp.org>
+ * Federico Mena-Quintero <federico@gimp.org>
+ * Jonathan Blandford <jrb@redhat.com>
+ * S�ren Sandmann <sandmann@daimi.au.dk>
+ *
+ * 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.
+ */
+
+#include "main.h"
+
+#include "image-load.h"
+#include "image_load_tiff.h"
+
+#ifdef HAVE_TIFF
+
+#include <tiffio.h>
+
+typedef struct _ImageLoaderTiff ImageLoaderTiff;
+struct _ImageLoaderTiff {
+ ImageLoaderBackendCbAreaUpdated area_updated_cb;
+ ImageLoaderBackendCbSize size_cb;
+ ImageLoaderBackendCbAreaPrepared area_prepared_cb;
+
+ gpointer data;
+
+ GdkPixbuf *pixbuf;
+ guint requested_width;
+ guint requested_height;
+
+ gboolean abort;
+
+ const guchar *buffer;
+ toff_t used;
+ toff_t pos;
+};
+
+static void free_buffer (guchar *pixels, gpointer data)
+{
+ g_free (pixels);
+}
+
+static tsize_t
+tiff_load_read (thandle_t handle, tdata_t buf, tsize_t size)
+{
+ ImageLoaderTiff *context = (ImageLoaderTiff *)handle;
+
+ if (context->pos + size > context->used)
+ return 0;
+
+ memcpy (buf, context->buffer + context->pos, size);
+ context->pos += size;
+ return size;
+}
+
+static tsize_t
+tiff_load_write (thandle_t handle, tdata_t buf, tsize_t size)
+{
+ return -1;
+}
+
+static toff_t
+tiff_load_seek (thandle_t handle, toff_t offset, int whence)
+{
+ ImageLoaderTiff *context = (ImageLoaderTiff *)handle;
+
+ switch (whence) {
+ case SEEK_SET:
+ if (offset > context->used)
+ return -1;
+ context->pos = offset;
+ break;
+ case SEEK_CUR:
+ if (offset + context->pos >= context->used)
+ return -1;
+ context->pos += offset;
+ break;
+ case SEEK_END:
+ if (offset + context->used > context->used)
+ return -1;
+ context->pos = context->used + offset;
+ break;
+ default:
+ return -1;
+ }
+ return context->pos;
+}
+
+static int
+tiff_load_close (thandle_t context)
+{
+ return 0;
+}
+
+static toff_t
+tiff_load_size (thandle_t handle)
+{
+ ImageLoaderTiff *context = (ImageLoaderTiff *)handle;
+
+ return context->used;
+}
+
+static int
+tiff_load_map_file (thandle_t handle, tdata_t *buf, toff_t *size)
+{
+ ImageLoaderTiff *context = (ImageLoaderTiff *)handle;
+
+ *buf = (tdata_t *) context->buffer;
+ *size = context->used;
+
+ return 0;
+}
+
+static void
+tiff_load_unmap_file (thandle_t handle, tdata_t data, toff_t offset)
+{
+}
+
+static gboolean image_loader_tiff_load (gpointer loader, const guchar *buf, gsize count, GError **error)
+{
+ ImageLoaderTiff *lt = (ImageLoaderTiff *) loader;
+
+ TIFF *tiff;
+ guchar *pixels = NULL;
+ gint width, height, rowstride, bytes;
+ uint16 orientation = 0;
+ uint16 transform = 0;
+ uint32 rowsperstrip;
+
+ lt->buffer = buf;
+ lt->used = count;
+ lt->pos = 0;
+
+ TIFFSetWarningHandler(NULL);
+
+ tiff = TIFFClientOpen ("libtiff-geeqie", "r", lt,
+ tiff_load_read, tiff_load_write,
+ tiff_load_seek, tiff_load_close,
+ tiff_load_size,
+ tiff_load_map_file, tiff_load_unmap_file);
+ if (!tiff)
+ {
+ DEBUG_1("Failed to open TIFF image");
+ return FALSE;
+ }
+
+
+
+ if (!TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width)) {
+ DEBUG_1("Could not get image width (bad TIFF file)");
+ TIFFClose(tiff);
+ return FALSE;
+ }
+
+ if (!TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height)) {
+ DEBUG_1("Could not get image height (bad TIFF file)");
+ TIFFClose(tiff);
+ return FALSE;
+ }
+
+ if (width <= 0 || height <= 0) {
+ DEBUG_1("Width or height of TIFF image is zero");
+ TIFFClose(tiff);
+ return FALSE;
+ }
+
+ rowstride = width * 4;
+ if (rowstride / 4 != width) { /* overflow */
+ DEBUG_1("Dimensions of TIFF image too large");
+ TIFFClose(tiff);
+ return FALSE;
+ }
+
+ bytes = height * rowstride;
+ if (bytes / rowstride != height) { /* overflow */
+ DEBUG_1("Dimensions of TIFF image too large");
+ TIFFClose(tiff);
+ return FALSE;
+ }
+
+ lt->requested_width = width;
+ lt->requested_height = height;
+ lt->size_cb(loader, lt->requested_width, lt->requested_height, lt->data);
+
+ pixels = g_try_malloc (bytes);
+
+ if (!pixels) {
+ DEBUG_1("Insufficient memory to open TIFF file");
+ TIFFClose(tiff);
+ return FALSE;
+ }
+
+ lt->pixbuf = gdk_pixbuf_new_from_data (pixels, GDK_COLORSPACE_RGB, TRUE, 8,
+ width, height, rowstride,
+ free_buffer, NULL);
+ if (!lt->pixbuf) {
+ g_free (pixels);
+ DEBUG_1("Insufficient memory to open TIFF file");
+ TIFFClose(tiff);
+ return FALSE;
+ }
+
+ /* Set the "orientation" key associated with this image. libtiff
+ orientation handling is odd, so further processing is required
+ by higher-level functions based on this tag. If the embedded
+ orientation tag is 1-4, libtiff flips/mirrors the image as
+ required, and no client processing is required - so we report
+ no orientation. Orientations 5-8 require rotations which would
+ swap the width and height of the image. libtiff does not do this.
+ Instead it interprets orientations 5-8 the same as 1-4.
+ See http://bugzilla.remotesensing.org/show_bug.cgi?id=1548.
+ To correct for this, the client must apply the transform normally
+ used for orientation 5 to both orientations 5 and 7, and apply
+ the transform normally used for orientation 7 for both
+ orientations 6 and 8. Then everythings works out OK! */
+
+ TIFFGetField (tiff, TIFFTAG_ORIENTATION, &orientation);
+
+ switch (orientation) {
+ case 5:
+ case 7:
+ transform = 5;
+ break;
+ case 6:
+ case 8:
+ transform = 7;
+ break;
+ default:
+ transform = 0;
+ break;
+ }
+
+
+ lt->area_prepared_cb(loader, lt->data);
+
+
+
+ if( TIFFGetField(tiff, TIFFTAG_ROWSPERSTRIP, &rowsperstrip) )
+ {
+ /* read by strip */
+ int row;
+ guchar *wrk_line = (guchar *)g_malloc(width * sizeof (uint32));
+
+
+ for( row = 0; row < height; row += rowsperstrip )
+ {
+ int rows_to_write, i_row;
+
+ if (lt->abort) {
+ break;
+ }
+
+ /* Read the strip into an RGBA array */
+ if (!TIFFReadRGBAStrip(tiff, row, (uint32 *)(pixels + row * rowstride))) {
+ break;
+ }
+
+ /*
+ * Figure out the number of scanlines actually in this strip.
+ */
+ if( row + (int)rowsperstrip > height )
+ rows_to_write = height - row;
+ else
+ rows_to_write = rowsperstrip;
+
+
+
+ /*
+ * For some reason the TIFFReadRGBAStrip() function chooses the
+ * lower left corner as the origin. Vertically mirror scanlines.
+ */
+ for( i_row = 0; i_row < rows_to_write / 2; i_row++ )
+ {
+ guchar *top_line, *bottom_line;
+
+ top_line = pixels + (row + i_row) * rowstride;
+ bottom_line = pixels + (row + rows_to_write - i_row - 1) * rowstride;
+
+ memcpy(wrk_line, top_line, 4*width);
+ memcpy(top_line, bottom_line, 4*width);
+ memcpy(bottom_line, wrk_line, 4*width);
+ }
+ lt->area_updated_cb(loader, 0, row, width, rows_to_write, lt->data);
+ }
+ g_free(wrk_line);
+ }
+ else
+ {
+ /* fallback, tiled tiff */
+ if (!TIFFReadRGBAImageOriented (tiff, width, height, (uint32 *)pixels, ORIENTATION_TOPLEFT, 1))
+ {
+ TIFFClose(tiff);
+ return FALSE;
+ }
+
+#if G_BYTE_ORDER == G_BIG_ENDIAN
+ /* Turns out that the packing used by TIFFRGBAImage depends on
+ * the host byte order...
+ */
+ while (pixels < pixbuf->pixels + bytes)
+ {
+ uint32 pixel = *(uint32 *)pixels;
+ int r = TIFFGetR(pixel);
+ int g = TIFFGetG(pixel);
+ int b = TIFFGetB(pixel);
+ int a = TIFFGetA(pixel);
+ *pixels++ = r;
+ *pixels++ = g;
+ *pixels++ = b;
+ *pixels++ = a;
+ }
+#endif
+
+ lt->area_updated_cb(loader, 0, 0, width, height, lt->data);
+ }
+ TIFFClose(tiff);
+
+ return TRUE;
+}
+
+
+static gpointer image_loader_tiff_new(ImageLoaderBackendCbAreaUpdated area_updated_cb, ImageLoaderBackendCbSize size_cb, ImageLoaderBackendCbAreaPrepared area_prepared_cb, gpointer data)
+{
+ ImageLoaderTiff *loader = g_new0(ImageLoaderTiff, 1);
+
+ loader->area_updated_cb = area_updated_cb;
+ loader->size_cb = size_cb;
+ loader->area_prepared_cb = area_prepared_cb;
+ loader->data = data;
+ return (gpointer) loader;
+}
+
+
+static void image_loader_tiff_set_size(gpointer loader, int width, int height)
+{
+ ImageLoaderTiff *lt = (ImageLoaderTiff *) loader;
+ lt->requested_width = width;
+ lt->requested_height = height;
+}
+
+static GdkPixbuf* image_loader_tiff_get_pixbuf(gpointer loader)
+{
+ ImageLoaderTiff *lt = (ImageLoaderTiff *) loader;
+ return lt->pixbuf;
+}
+
+static gchar* image_loader_tiff_get_format_name(gpointer loader)
+{
+ return g_strdup("tiff");
+}
+static gchar** image_loader_tiff_get_format_mime_types(gpointer loader)
+{
+ static gchar *mime[] = {"image/tiff", NULL};
+ return g_strdupv(mime);
+}
+
+static gboolean image_loader_tiff_close(gpointer loader, GError **error)
+{
+ return TRUE;
+}
+
+static void image_loader_tiff_abort(gpointer loader)
+{
+ ImageLoaderTiff *lt = (ImageLoaderTiff *) loader;
+ lt->abort = TRUE;
+}
+
+static void image_loader_tiff_free(gpointer loader)
+{
+ ImageLoaderTiff *lt = (ImageLoaderTiff *) loader;
+ if (lt->pixbuf) g_object_unref(lt->pixbuf);
+ g_free(lt);
+}
+
+
+void image_loader_backend_set_tiff(ImageLoaderBackend *funcs)
+{
+ funcs->loader_new = image_loader_tiff_new;
+ funcs->set_size = image_loader_tiff_set_size;
+ funcs->load = image_loader_tiff_load;
+ funcs->write = NULL;
+ funcs->get_pixbuf = image_loader_tiff_get_pixbuf;
+ funcs->close = image_loader_tiff_close;
+ funcs->abort = image_loader_tiff_abort;
+ funcs->free = image_loader_tiff_free;
+
+ funcs->get_format_name = image_loader_tiff_get_format_name;
+ funcs->get_format_mime_types = image_loader_tiff_get_format_mime_types;
+}
+
+
+
+#endif
\ No newline at end of file
--- /dev/null
+/*
+ * Geeqie
+ * (C) 2004 John Ellis
+ * Copyright (C) 2008 - 2011 The Geeqie Team
+ *
+ * Author: Vladimir Nadvornik
+ *
+ * This software is released under the GNU General Public License (GNU GPL).
+ * Please read the included file COPYING for more information.
+ * This software comes with no warranty of any kind, use at your own risk!
+ */
+
+#ifndef IMAGE_LOAD_TIFF_H
+#define IMAGE_LOAD_TIFF_H
+
+#ifdef HAVE_TIFF
+void image_loader_backend_set_tiff(ImageLoaderBackend *funcs);
+#endif
+
+#endif
+
image_change_fd(vw->imd, fd, image_zoom_get_default(NULL));
}
+ /* Wait until image is loaded otherwise size is not defined */
+ int count;
+ for (count = 10; count && !w && !h; count++)
+ {
+ image_get_image_size(vw->imd, &w, &h);
+ usleep(100000);
+ }
+
if (image_zoom_get(vw->imd) == 0.0)
{
image_get_image_size(vw->imd, &w, &h);
--- /dev/null
+/*
+ * Geeqie
+ * (C) 2004 John Ellis
+ * Copyright (C) 2008 - 2011 The Geeqie Team
+ *
+ * Author: Vladimir Nadvornik
+ *
+ * This software is released under the GNU General Public License (GNU GPL).
+ * Please read the included file COPYING for more information.
+ * This software comes with no warranty of any kind, use at your own risk!
+ */
+
+#include "main.h"
+#include "jpeg_parser.h"
+
+gboolean jpeg_segment_find(guchar *data, guint size,
+ guchar app_marker, const gchar *magic, guint magic_len,
+ guint *seg_offset, guint *seg_length)
+{
+ guchar marker = 0;
+ guint offset = 0;
+ guint length = 0;
+
+ while (marker != JPEG_MARKER_EOI)
+ {
+ offset += length;
+ length = 2;
+
+ if (offset + 2 >= size ||
+ data[offset] != JPEG_MARKER) return FALSE;
+
+ marker = data[offset + 1];
+ if (marker != JPEG_MARKER_SOI &&
+ marker != JPEG_MARKER_EOI)
+ {
+ if (offset + 4 >= size) return FALSE;
+ length += ((guint)data[offset + 2] << 8) + data[offset + 3];
+
+ if (marker == app_marker &&
+ offset + length < size &&
+ length >= 4 + magic_len &&
+ memcmp(data + offset + 4, magic, magic_len) == 0)
+ {
+ *seg_offset = offset + 4;
+ *seg_length = length - 4;
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+
+typedef enum {
+ TIFF_BYTE_ORDER_INTEL,
+ TIFF_BYTE_ORDER_MOTOROLA
+} TiffByteOrder;
+
+#define TIFF_TIFD_OFFSET_TAG 0
+#define TIFF_TIFD_OFFSET_FORMAT 2
+#define TIFF_TIFD_OFFSET_COUNT 4
+#define TIFF_TIFD_OFFSET_DATA 8
+#define TIFF_TIFD_SIZE 12
+
+
+
+guint16 tiff_byte_get_int16(guchar *f, TiffByteOrder bo)
+{
+ guint16 align_buf;
+
+ memcpy(&align_buf, f, sizeof(guint16));
+
+ if (bo == TIFF_BYTE_ORDER_INTEL)
+ return GUINT16_FROM_LE(align_buf);
+ else
+ return GUINT16_FROM_BE(align_buf);
+}
+
+guint32 tiff_byte_get_int32(guchar *f, TiffByteOrder bo)
+{
+ guint32 align_buf;
+
+ memcpy(&align_buf, f, sizeof(guint32));
+
+ if (bo == TIFF_BYTE_ORDER_INTEL)
+ return GUINT32_FROM_LE(align_buf);
+ else
+ return GUINT32_FROM_BE(align_buf);
+}
+
+void tiff_byte_put_int16(guchar *f, guint16 n, TiffByteOrder bo)
+{
+ guint16 align_buf;
+
+ if (bo == TIFF_BYTE_ORDER_INTEL)
+ {
+ align_buf = GUINT16_TO_LE(n);
+ }
+ else
+ {
+ align_buf = GUINT16_TO_BE(n);
+ }
+
+ memcpy(f, &align_buf, sizeof(guint16));
+}
+
+void tiff_byte_put_int32(guchar *f, guint32 n, TiffByteOrder bo)
+{
+ guint32 align_buf;
+
+ if (bo == TIFF_BYTE_ORDER_INTEL)
+ {
+ align_buf = GUINT32_TO_LE(n);
+ }
+ else
+ {
+ align_buf = GUINT32_TO_BE(n);
+ }
+
+ memcpy(f, &align_buf, sizeof(guint32));
+}
+
+gint tiff_directory_offset(guchar *data, const guint len,
+ guint *offset, TiffByteOrder *bo)
+{
+ if (len < 8) return FALSE;
+
+ if (memcmp(data, "II", 2) == 0)
+ {
+ *bo = TIFF_BYTE_ORDER_INTEL;
+ }
+ else if (memcmp(data, "MM", 2) == 0)
+ {
+ *bo = TIFF_BYTE_ORDER_MOTOROLA;
+ }
+ else
+ {
+ return FALSE;
+ }
+
+ if (tiff_byte_get_int16(data + 2, *bo) != 0x002A)
+ {
+ return FALSE;
+ }
+
+ *offset = tiff_byte_get_int32(data + 4, *bo);
+
+ return (*offset < len);
+}
+
+typedef gint (* FuncParseIFDEntry)(guchar *tiff, guint offset,
+ guint size, TiffByteOrder bo,
+ gpointer data);
+
+
+gint tiff_parse_IFD_table(guchar *tiff, guint offset,
+ guint size, TiffByteOrder bo,
+ guint *next_offset,
+ FuncParseIFDEntry parse_entry, gpointer data)
+{
+ guint count;
+ guint i;
+ guint next;
+
+
+ /* We should be able to read number of entries in IFD0) */
+ if (size < offset + 2) return -1;
+
+ count = tiff_byte_get_int16(tiff + offset, bo);
+ offset += 2;
+ /* Entries and next IFD offset must be readable */
+ if (size < offset + count * TIFF_TIFD_SIZE + 4) return -1;
+
+ for (i = 0; i < count; i++)
+ {
+ parse_entry(tiff, offset + i * TIFF_TIFD_SIZE, size, bo, data);
+ }
+
+ next = tiff_byte_get_int32(tiff + offset + count * TIFF_TIFD_SIZE, bo);
+ if (next_offset) *next_offset = next;
+
+ return 0;
+}
+
+static gint mpo_parse_Index_IFD_entry(guchar *tiff, guint offset,
+ guint size, TiffByteOrder bo,
+ gpointer data)
+{
+ guint tag;
+ guint format;
+ guint count;
+ guint data_val;
+ guint data_offset;
+ guint data_length;
+
+ MPOData *mpo = data;
+
+ tag = tiff_byte_get_int16(tiff + offset + TIFF_TIFD_OFFSET_TAG, bo);
+ format = tiff_byte_get_int16(tiff + offset + TIFF_TIFD_OFFSET_FORMAT, bo);
+ count = tiff_byte_get_int32(tiff + offset + TIFF_TIFD_OFFSET_COUNT, bo);
+ data_val = tiff_byte_get_int32(tiff + offset + TIFF_TIFD_OFFSET_DATA, bo);
+ DEBUG_1(" tag %x format %x count %x data_val %x", tag, format, count, data_val);
+
+ if (tag == 0xb000)
+ {
+ mpo->version = data_val;
+ DEBUG_1(" mpo version %x", mpo->version);
+ }
+ else if (tag == 0xb001)
+ {
+ mpo->num_images = data_val;
+ DEBUG_1(" num images %x", mpo->num_images);
+ }
+ else if (tag == 0xb002)
+ {
+ guint i;
+ data_offset = data_val;
+ data_length = count;
+ if (size < data_offset || size < data_offset + data_length)
+ {
+ return -1;
+ }
+ if (count != mpo->num_images * 16)
+ {
+ return -1;
+ }
+
+ mpo->images = g_new0(MPOEntry, mpo->num_images);
+
+ for (i = 0; i < mpo->num_images; i++) {
+ guint image_attr = tiff_byte_get_int32(tiff + data_offset + i * 16, bo);
+ mpo->images[i].type_code = image_attr & 0xffffff;
+ mpo->images[i].representative = !!(image_attr & 0x20000000);
+ mpo->images[i].dependent_child = !!(image_attr & 0x40000000);
+ mpo->images[i].dependent_parent = !!(image_attr & 0x80000000);
+ mpo->images[i].length = tiff_byte_get_int32(tiff + data_offset + i * 16 + 4, bo);
+ mpo->images[i].offset = tiff_byte_get_int32(tiff + data_offset + i * 16 + 8, bo);
+ mpo->images[i].dep1 = tiff_byte_get_int16(tiff + data_offset + i * 16 + 12, bo);
+ mpo->images[i].dep2 = tiff_byte_get_int16(tiff + data_offset + i * 16 + 14, bo);
+
+ if (i == 0)
+ {
+ mpo->images[i].offset = 0;
+ }
+ else
+ {
+ mpo->images[i].offset += mpo->mpo_offset;
+ }
+
+ DEBUG_1(" image %x %x %x", image_attr, mpo->images[i].length, mpo->images[i].offset);
+ }
+ }
+
+ return 0;
+}
+
+static gint mpo_parse_Attributes_IFD_entry(guchar *tiff, guint offset,
+ guint size, TiffByteOrder bo,
+ gpointer data)
+{
+ guint tag;
+ guint format;
+ guint count;
+ guint data_val;
+ guint data_offset;
+ guint data_length;
+
+ MPOEntry *mpe = data;
+
+ tag = tiff_byte_get_int16(tiff + offset + TIFF_TIFD_OFFSET_TAG, bo);
+ format = tiff_byte_get_int16(tiff + offset + TIFF_TIFD_OFFSET_FORMAT, bo);
+ count = tiff_byte_get_int32(tiff + offset + TIFF_TIFD_OFFSET_COUNT, bo);
+ data_val = tiff_byte_get_int32(tiff + offset + TIFF_TIFD_OFFSET_DATA, bo);
+ DEBUG_1(" tag %x format %x count %x data_val %x", tag, format, count, data_val);
+
+ switch (tag)
+ {
+ case 0xb000:
+ mpe->MPFVersion = data_val;
+ DEBUG_1(" mpo version %x", data_val);
+ break;
+ case 0xb101:
+ mpe->MPIndividualNum = data_val;
+ DEBUG_1(" Individual Image Number %x", mpe->MPIndividualNum);
+ break;
+ case 0xb201:
+ mpe->PanOrientation = data_val;
+ break;
+/*
+
+FIXME:
+Panorama Scanning Orientation PanOrientation 45569 B201 LONG 1
+Panorama Horizontal Overlap PanOverlap_H 45570 B202 RATIONAL 1
+Panorama Vertical Overlap PanOverlap_V 45571 B203 RATIONAL 1
+Base Viewpoint Number BaseViewpointNum 45572 B204 LONG 1
+Convergence Angle ConvergenceAngle 45573 B205 SRATIONAL 1
+Baseline Length BaselineLength 45574 B206 RATIONAL 1
+Divergence Angle VerticalDivergence 45575 B207 SRATIONAL 1
+Horizontal Axis Distance AxisDistance_X 45576 B208 SRATIONAL 1
+Vertical Axis Distance AxisDistance_Y 45577 B209 SRATIONAL 1
+Collimation Axis Distance AxisDistance_Z 45578 B20A SRATIONAL 1
+Yaw Angle YawAngle 45579 B20B SRATIONAL 1
+Pitch Angle PitchAngle 45580 B20C SRATIONAL 1
+Roll Angle RollAngle 45581 B20D
+ */
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+MPOData *jpeg_get_mpo_data(guchar *data, guint size)
+{
+ guint seg_offset;
+ guint seg_size;
+ if (jpeg_segment_find(data, size, JPEG_MARKER_APP2, "MPF\x00", 4, &seg_offset, &seg_size) && seg_size >16)
+ {
+ guint offset;
+ guint next_offset;
+ TiffByteOrder bo;
+ MPOData *mpo;
+ guint i;
+
+ DEBUG_1("mpo signature found at %x", seg_offset);
+ seg_offset += 4;
+ seg_size -= 4;
+
+ if (!tiff_directory_offset(data + seg_offset, seg_size, &offset, &bo)) return NULL;
+
+ mpo = g_new0(MPOData, 1);
+ mpo->mpo_offset = seg_offset;
+
+ tiff_parse_IFD_table(data + seg_offset, offset , seg_size, bo, &next_offset, mpo_parse_Index_IFD_entry, (gpointer)mpo);
+ if (!mpo->images) mpo->num_images = 0;
+
+
+ for (i = 0; i < mpo->num_images; i++)
+ {
+ if (mpo->images[i].offset + mpo->images[i].length > size)
+ {
+ mpo->num_images = i;
+ DEBUG_1("MPO file truncated to %d valid images, %d %d", i, mpo->images[i].offset + mpo->images[i].length, size);
+ break;
+ }
+ }
+
+ for (i = 0; i < mpo->num_images; i++)
+ {
+ if (i == 0)
+ {
+ offset = next_offset;
+ }
+ else
+ {
+ if (!jpeg_segment_find(data + mpo->images[i].offset, mpo->images[i].length, JPEG_MARKER_APP2, "MPF\x00", 4, &seg_offset, &seg_size) || seg_size <=16)
+ {
+ DEBUG_1("MPO image %d: MPO signature not found", i);
+ continue;
+ }
+
+ seg_offset += 4;
+ seg_size -= 4;
+ if (!tiff_directory_offset(data + mpo->images[i].offset + seg_offset, seg_size, &offset, &bo))
+ {
+ DEBUG_1("MPO image %d: invalid directory offset", i);
+ continue;
+ }
+
+ }
+ tiff_parse_IFD_table(data + mpo->images[i].offset + seg_offset, offset , seg_size, bo, NULL, mpo_parse_Attributes_IFD_entry, (gpointer)&mpo->images[i]);
+ }
+
+ return mpo;
+ }
+ return NULL;
+}
+
+void jpeg_mpo_data_free(MPOData *mpo)
+{
+ if (mpo)
+ {
+ if (mpo->images) g_free(mpo->images);
+ g_free(mpo);
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Geeqie
+ * (C) 2004 John Ellis
+ * Copyright (C) 2008 - 2010 The Geeqie Team
+ *
+ * Author: Vladimir Nadvornik
+ *
+ * This software is released under the GNU General Public License (GNU GPL).
+ * Please read the included file COPYING for more information.
+ * This software comes with no warranty of any kind, use at your own risk!
+ */
+
+#ifndef JPEG_PARSER_H
+#define JPEG_PARSER_H
+
+#define JPEG_MARKER 0xFF
+#define JPEG_MARKER_SOI 0xD8
+#define JPEG_MARKER_EOI 0xD9
+#define JPEG_MARKER_APP1 0xE1
+#define JPEG_MARKER_APP2 0xE2
+
+/* jpeg container format:
+ all data markers start with 0XFF
+ 2 byte long file start and end markers: 0xFFD8(SOI) and 0XFFD9(EOI)
+ 4 byte long data segment markers in format: 0xFFTTSSSSNNN...
+ FF: 1 byte standard marker identifier
+ TT: 1 byte data type
+ SSSS: 2 bytes in Motorola byte alignment for length of the data.
+ This value includes these 2 bytes in the count, making actual
+ length of NN... == SSSS - 2.
+ NNN.: the data in this segment
+ */
+
+gboolean jpeg_segment_find(guchar *data, guint size,
+ guchar app_marker, const gchar *magic, guint magic_len,
+ guint *seg_offset, guint *seg_length);
+
+
+typedef struct _MPOData MPOData;
+typedef struct _MPOEntry MPOEntry;
+
+struct _MPOEntry {
+ guint type_code;
+ gboolean representative;
+ gboolean dependent_child;
+ gboolean dependent_parent;
+ guint offset;
+ guint length;
+ guint dep1;
+ guint dep2;
+
+ guint MPFVersion;
+ guint MPIndividualNum;
+ guint PanOrientation;
+ double PanOverlap_H;
+ double PanOverlap_V;
+ guint BaseViewpointNum;
+ double ConvergenceAngle;
+ double BaselineLength;
+ double VerticalDivergence;
+ double AxisDistance_X;
+ double AxisDistance_Y;
+ double AxisDistance_Z;
+ double YawAngle;
+ double PitchAngle;
+ double RollAngle;
+
+};
+
+
+struct _MPOData {
+ guint mpo_offset;
+
+ guint version;
+ guint num_images;
+ MPOEntry *images;
+};
+
+MPOData* jpeg_get_mpo_data(guchar *data, guint size);
+void jpeg_mpo_data_free(MPOData *mpo);
+
+#endif
\ No newline at end of file
if (!path) return FALSE;
- fd = file_data_new_simple(path);
+ fd = file_data_new_group(path);
ret = layout_set_fd(lw, fd);
file_data_unref(fd);
return ret;
file_data_unregister_real_time_monitor(lw->dir_fd);
file_data_unref(lw->dir_fd);
}
- lw->dir_fd = file_data_new_simple(base);
+ lw->dir_fd = file_data_new_dir(base);
file_data_register_real_time_monitor(lw->dir_fd);
g_free(base);
}
FileData *dir_fd;
base = remove_level_from_path(fd->path);
- dir_fd = file_data_new_simple(base);
+ dir_fd = file_data_new_dir(base);
if (dir_fd != lw->dir_fd)
{
layout_set_fd(lw, dir_fd);
return image_get_desaturate(lw->image);
}
+/* stereo */
+/*
+gint layout_image_stereo_get(LayoutWindow *lw)
+{
+ if (!layout_valid(&lw)) return 0;
+
+ return image_stereo_get(lw->image);
+}
+
+void layout_image_stereo_set(LayoutWindow *lw, gint stereo_mode)
+{
+ if (!layout_valid(&lw)) return;
+
+ image_stereo_set(lw->image, stereo_mode);
+}
+void layout_image_stereo_swap(LayoutWindow *lw)
+{
+ if (!layout_valid(&lw)) return;
+ image_stereo_swap(lw->image);
+}
+*/
+
+gint layout_image_stereo_pixbuf_get(LayoutWindow *lw)
+{
+ if (!layout_valid(&lw)) return 0;
+
+ return image_stereo_pixbuf_get(lw->image);
+}
+
+void layout_image_stereo_pixbuf_set(LayoutWindow *lw, gint stereo_mode)
+{
+ if (!layout_valid(&lw)) return;
+
+ image_stereo_pixbuf_set(lw->image, stereo_mode);
+}
const gchar *layout_image_get_path(LayoutWindow *lw)
{
void layout_image_set_desaturate(LayoutWindow *lw, gboolean desaturate);
gboolean layout_image_get_desaturate(LayoutWindow *lw);
+/*
+gint layout_image_stereo_get(LayoutWindow *lw);
+void layout_image_stereo_set(LayoutWindow *lw, gint stereo_mode);
+*/
+void layout_image_stereo_swap(LayoutWindow *lw);
+
+gint layout_image_stereo_pixbuf_get(LayoutWindow *lw);
+void layout_image_stereo_pixbuf_set(LayoutWindow *lw, gint stereo_mode);
+
void layout_image_next(LayoutWindow *lw);
void layout_image_prev(LayoutWindow *lw);
void layout_image_first(LayoutWindow *lw);
layout_image_slideshow_pause_toggle(lw);
}
+
+static void layout_menu_stereo_mode_next_cb(GtkAction *action, gpointer data)
+{
+ LayoutWindow *lw = data;
+ gint mode = layout_image_stereo_pixbuf_get(lw);
+
+ /* 0->1, 1->2, 2->3, 3->1 - disable auto, then cycle */
+ mode = mode % 3 + 1;
+
+ GtkAction *radio = gtk_action_group_get_action(lw->action_group, "StereoAuto");
+ radio_action_set_current_value(GTK_RADIO_ACTION(radio), mode);
+
+ /*
+ this is called via fallback in layout_menu_stereo_mode_cb
+ layout_image_stereo_pixbuf_set(lw, mode);
+ */
+
+}
+
+static void layout_menu_stereo_mode_cb(GtkRadioAction *action, GtkRadioAction *current, gpointer data)
+{
+ LayoutWindow *lw = data;
+ gint mode = gtk_radio_action_get_current_value(action);
+ layout_image_stereo_pixbuf_set(lw, mode);
+}
+
static void layout_menu_help_cb(GtkAction *action, gpointer data)
{
LayoutWindow *lw = data;
if (!path) return;
/* Open previous path */
- dir_fd = file_data_new_simple(path);
+ dir_fd = file_data_new_dir(path);
layout_set_fd(lw, dir_fd);
file_data_unref(dir_fd);
}
if (path)
{
- FileData *dir_fd = file_data_new_simple(path);
+ FileData *dir_fd = file_data_new_dir(path);
layout_set_fd(lw, dir_fd);
file_data_unref(dir_fd);
}
{ "ColorMenu", NULL, N_("_Color Management"), NULL, NULL, NULL },
{ "ConnectZoomMenu", NULL, N_("_Connected Zoom"), NULL, NULL, NULL },
{ "SplitMenu", NULL, N_("Spli_t"), NULL, NULL, NULL },
+ { "StereoMenu", NULL, N_("Stere_o"), NULL, NULL, NULL },
{ "OverlayMenu", NULL, N_("Image _Overlay"), NULL, NULL, NULL },
{ "HelpMenu", NULL, N_("_Help"), NULL, NULL, NULL },
{ "About", GTK_STOCK_ABOUT, N_("_About"), NULL, N_("About"), CB(layout_menu_about_cb) },
{ "LogWindow", NULL, N_("_Log Window"), NULL, N_("Log Window"), CB(layout_menu_log_window_cb) },
{ "ExifWin", NULL, N_("_Exif window"), "<control>E", N_("Exif window"), CB(layout_menu_bar_exif_cb) },
+ { "StereoCycle", NULL, N_("_Cycle through stereo modes"), NULL, N_("Cycle through stereo modes"), CB(layout_menu_stereo_mode_next_cb) },
};
{ "HistogramModeLog", NULL, N_("_Log Histogram"), NULL, N_("Log Histogram"), 1 },
};
+static GtkRadioActionEntry menu_stereo_mode_entries[] = {
+ { "StereoAuto", NULL, N_("_Auto"), NULL, N_("Stereo Auto"), STEREO_PIXBUF_DEFAULT },
+ { "StereoSBS", NULL, N_("_Side by Side"), NULL, N_("Stereo Side by Side"), STEREO_PIXBUF_SBS },
+ { "StereoCross", NULL, N_("_Cross"), NULL, N_("Stereo Cross"), STEREO_PIXBUF_CROSS },
+ { "StereoOff", NULL, N_("_Off"), NULL, N_("Stereo Off"), STEREO_PIXBUF_NONE }
+};
+
#undef CB
" <menuitem action='SplitQuad'/>"
" <menuitem action='SplitSingle'/>"
" </menu>"
+" <menu action='StereoMenu'>"
+" <menuitem action='StereoAuto'/>"
+" <menuitem action='StereoSBS'/>"
+" <menuitem action='StereoCross'/>"
+" <menuitem action='StereoOff'/>"
+" <separator/>"
+" <menuitem action='StereoCycle'/>"
+" </menu>"
" <menu action='ColorMenu'>"
" <menuitem action='UseColorProfiles'/>"
" <menuitem action='UseImageProfile'/>"
gtk_action_group_add_radio_actions(lw->action_group,
menu_histogram_mode, G_N_ELEMENTS(menu_histogram_mode),
0, G_CALLBACK(layout_menu_histogram_mode_cb), lw);
+ gtk_action_group_add_radio_actions(lw->action_group,
+ menu_stereo_mode_entries, G_N_ELEMENTS(menu_stereo_mode_entries),
+ 0, G_CALLBACK(layout_menu_stereo_mode_cb), lw);
lw->ui_manager = gtk_ui_manager_new();
action = gtk_action_group_get_action(lw->action_group, "ConnectZoomMenu");
gtk_action_set_sensitive(action, lw->split_mode != SPLIT_NONE);
+ action = gtk_action_group_get_action(lw->action_group, "StereoAuto");
+ radio_action_set_current_value(GTK_RADIO_ACTION(action), layout_image_stereo_pixbuf_get(lw));
+
layout_util_sync_color(lw);
}
{
if (!*path) *path = remove_level_from_path(path_parsed);
if (!*file) *file = g_strdup(path_parsed);
- *list = g_list_prepend(*list, file_data_new_simple(path_parsed));
+ *list = g_list_prepend(*list, file_data_new_group(path_parsed));
}
}
path_parsed = g_strdup(dir);
parse_out_relatives(path_parsed);
- dir_fd = file_data_new_simple(path_parsed);
+ dir_fd = file_data_new_dir(path_parsed);
if (filelist_read(dir_fd, &files, NULL))
g_thread_init(NULL);
gdk_threads_init();
gdk_threads_enter();
+
#endif
/* init execution time counter (debug only) */
#define DEFAULT_THUMB_WIDTH 96
#define DEFAULT_THUMB_HEIGHT 72
-#define DEFAULT_MINIMAL_WINDOW_SIZE 32
+#define DEFAULT_MINIMAL_WINDOW_SIZE 100
#define IMAGE_MIN_WIDTH 100
#define SIDEBAR_DEFAULT_WIDTH 250
static gboolean metadata_file_read(gchar *path, GList **keywords, gchar **comment);
+/*
+ *-------------------------------------------------------------------
+ * long-term cache - keep keywords from whole dir in memory
+ *-------------------------------------------------------------------
+ */
+
+/* fd->cached metadata list of lists
+ each particular list contains key as a first entry, then the values
+*/
+
+static void metadata_cache_update(FileData *fd, const gchar *key, const GList *values)
+{
+ GList *work;
+
+ work = fd->cached_metadata;
+ while (work)
+ {
+ GList *entry = work->data;
+ gchar *entry_key = entry->data;
+
+ if (strcmp(entry_key, key) == 0)
+ {
+ /* key found - just replace values */
+ GList *old_values = entry->next;
+ entry->next = NULL;
+ old_values->prev = NULL;
+ string_list_free(old_values);
+ work->data = g_list_append(entry, string_list_copy(values));
+ DEBUG_1("updated %s %s\n", key, fd->path);
+ return;
+ }
+ work = work->next;
+ }
+
+ /* key not found - prepend new entry */
+ fd->cached_metadata = g_list_prepend(fd->cached_metadata,
+ g_list_prepend(string_list_copy(values), g_strdup(key)));
+ DEBUG_1("added %s %s\n", key, fd->path);
+
+}
+
+static const GList *metadata_cache_get(FileData *fd, const gchar *key)
+{
+ GList *work;
+
+ work = fd->cached_metadata;
+ while (work)
+ {
+ GList *entry = work->data;
+ gchar *entry_key = entry->data;
+
+ if (strcmp(entry_key, key) == 0)
+ {
+ /* key found */
+ DEBUG_1("found %s %s\n", key, fd->path);
+ return entry;
+ }
+ work = work->next;
+ }
+ return NULL;
+ DEBUG_1("not found %s %s\n", key, fd->path);
+}
+
+static void metadata_cache_remove(FileData *fd, const gchar *key)
+{
+ GList *work;
+
+ work = fd->cached_metadata;
+ while (work)
+ {
+ GList *entry = work->data;
+ gchar *entry_key = entry->data;
+
+ if (strcmp(entry_key, key) == 0)
+ {
+ /* key found */
+ string_list_free(entry);
+ fd->cached_metadata = g_list_delete_link(fd->cached_metadata, work);
+ DEBUG_1("removed %s %s\n", key, fd->path);
+ return;
+ }
+ work = work->next;
+ }
+ DEBUG_1("not removed %s %s\n", key, fd->path);
+}
+
+void metadata_cache_free(FileData *fd)
+{
+ GList *work;
+ if (fd->cached_metadata) DEBUG_1("freed %s\n", fd->path);
+
+ work = fd->cached_metadata;
+ while (work)
+ {
+ GList *entry = work->data;
+ string_list_free(entry);
+
+ work = work->next;
+ }
+ g_list_free(fd->cached_metadata);
+ fd->cached_metadata = NULL;
+}
+
+
+
+
+
/*
*-------------------------------------------------------------------
void metadata_notify_cb(FileData *fd, NotifyType type, gpointer data)
{
- if ((type & (NOTIFY_REREAD | NOTIFY_CHANGE)) && g_list_find(metadata_write_queue, fd))
+ if (type & (NOTIFY_REREAD | NOTIFY_CHANGE))
{
- DEBUG_1("Notify metadata: %s %04x", fd->path, type);
- if (!isname(fd->path))
+ metadata_cache_free(fd);
+
+ if (g_list_find(metadata_write_queue, fd))
{
- /* ignore deleted files */
- metadata_write_queue_remove(fd);
+ DEBUG_1("Notify metadata: %s %04x", fd->path, type);
+ if (!isname(fd->path))
+ {
+ /* ignore deleted files */
+ metadata_write_queue_remove(fd);
+ }
}
}
}
store the metadata in the cache)
FIXME: this does not catch new sidecars created by independent external programs
*/
- file_data_unref(file_data_new_simple(fd->change->dest));
+ file_data_unref(file_data_new_group(fd->change->dest));
if (success) metadata_legacy_delete(fd, fd->change->dest);
return success;
fd->modified_xmp = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)string_list_free);
}
g_hash_table_insert(fd->modified_xmp, g_strdup(key), string_list_copy((GList *)values));
+
+ metadata_cache_remove(fd, key);
+
if (fd->exif)
{
exif_update_metadata(fd->exif, key, values);
{
ExifData *exif;
GList *list = NULL;
+ const GList *cache_entry;
if (!fd) return NULL;
/* unwritten data overide everything */
if (list) return string_list_copy(list);
}
+
+ if (format == METADATA_PLAIN && strcmp(key, KEYWORD_KEY) == 0
+ && (cache_entry = metadata_cache_get(fd, key)))
+ {
+ return string_list_copy(cache_entry->next);
+ }
+
/*
Legacy metadata file is the primary source if it exists.
Merging the lists does not make much sense, because the existence of
*/
if (strcmp(key, KEYWORD_KEY) == 0)
{
- if (metadata_legacy_read(fd, &list, NULL)) return list;
- }
+ if (metadata_legacy_read(fd, &list, NULL))
+ {
+ if (format == METADATA_PLAIN)
+ {
+ metadata_cache_update(fd, key, list);
+ }
+ return list;
+ }
+ }
else if (strcmp(key, COMMENT_KEY) == 0)
{
gchar *comment = NULL;
if (!exif) return NULL;
list = exif_get_metadata(exif, key, format);
exif_free_fd(fd, exif);
+
+ if (format == METADATA_PLAIN && strcmp(key, KEYWORD_KEY) == 0)
+ {
+ metadata_cache_update(fd, key, list);
+ }
+
return list;
}
#define KEYWORD_KEY "Xmp.dc.subject"
#define ORIENTATION_KEY "Xmp.tiff.Orientation"
+void metadata_cache_free(FileData *fd);
+
gboolean metadata_write_queue_remove(FileData *fd);
gboolean metadata_write_queue_remove_list(GList *list);
gboolean metadata_write_perform(FileData *fd);
options->tree_descend_subdirs = FALSE;
options->update_on_time_change = TRUE;
+
+ options->stereo.fixed_w = 1920;
+ options->stereo.fixed_h = 1080;
+ options->stereo.fixed_x1 = 0;
+ options->stereo.fixed_y1 = 0;
+ options->stereo.fixed_x2 = 0;
+ options->stereo.fixed_y2 = 1125;
return options;
}
gboolean keywords_case_sensitive;
gboolean write_orientation;
} metadata;
-
+
+ /* Stereo */
+ struct {
+ gint mode;;
+ gint fsmode;
+ gboolean enable_fsmode;
+ gint fixed_w, fixed_h;
+ gint fixed_x1, fixed_y1;
+ gint fixed_x2, fixed_y2;
+ struct { /* options in this struct are packed to mode and fsmode entries */
+ gboolean mirror_right;
+ gboolean mirror_left;
+ gboolean flip_right;
+ gboolean flip_left;
+ gboolean swap;
+ gboolean temp_disable;
+ gboolean fs_mirror_right;
+ gboolean fs_mirror_left;
+ gboolean fs_flip_right;
+ gboolean fs_flip_left;
+ gboolean fs_swap;
+ gboolean fs_temp_disable;
+ } tmp;
+ } stereo;
};
ConfOptions *options;
*/
g_snprintf(fake_path, sizeof(fake_path), "//%04d-%02d-%02d", year, month, day);
- fd = file_data_new_simple(fake_path);
+ fd = file_data_new_no_grouping(fake_path);
fd->date = dt;
pi_day = pan_item_box_new(pw, fd, x, y, PAN_CAL_DAY_WIDTH, PAN_CAL_DAY_HEIGHT,
PAN_CAL_DAY_BORDER,
g_free(buf);
y += pi->height;
- pi_month = pan_item_box_new(pw, file_data_new_simple(fd->path),
+ pi_month = pan_item_box_new(pw, file_data_ref(fd),
x, y, 0, 0,
PAN_BOX_OUTLINE_THICKNESS,
PAN_BOX_COLOR, PAN_BOX_ALPHA,
y += pi->height;
- pi_day = pan_item_box_new(pw, file_data_new_simple(fd->path), x, y, 0, 0,
+ pi_day = pan_item_box_new(pw, file_data_ref(fd), x, y, 0, 0,
PAN_BOX_OUTLINE_THICKNESS,
PAN_BOX_COLOR, PAN_BOX_ALPHA,
PAN_BOX_OUTLINE_COLOR, PAN_BOX_OUTLINE_ALPHA);
PAN_POPUP_BORDER_COLOR, PAN_POPUP_ALPHA);
pan_item_set_key(pbox, "info");
- p = pan_item_image_new(pw, file_data_new_simple(pi->fd->path),
+ p = pan_item_image_new(pw, file_data_new_group(pi->fd->path),
pbox->x + PREF_PAD_BORDER, pbox->y + PREF_PAD_BORDER, iw, ih);
pan_item_set_key(p, "info");
pan_item_size_by_item(pbox, p, PREF_PAD_BORDER);
}
else
{
- FileData *dir_fd = file_data_new_simple(path);
+ FileData *dir_fd = file_data_new_dir(path);
tab_completion_append_to_history(pw->path_entry, path);
pan_layout_set_fd(pw, dir_fd);
#include "main.h"
#include "pixbuf-renderer.h"
+#include "renderer-tiles.h"
#include "intl.h"
#include "layout.h"
#endif
-/* size to use when breaking up image pane for rendering */
-#define PR_TILE_SIZE 128
-
-/* default size of tile cache (mb) */
-#define PR_CACHE_SIZE_DEFAULT 8
-
/* default min and max zoom */
#define PR_ZOOM_MIN -32.0
#define PR_ZOOM_MAX 32.0
#define PR_SCROLLER_UPDATES_PER_SEC 30
#define PR_SCROLLER_DEAD_ZONE 6
-/* alpha channel checkerboard background (same as gimp) */
-#define PR_ALPHA_CHECK1 0x00999999
-#define PR_ALPHA_CHECK2 0x00666666
-#define PR_ALPHA_CHECK_SIZE 16
-
/* when scaling image to below this size, use nearest pixel for scaling
* (below about 4, the other scale types become slow generating their conversion tables)
*/
#define PR_MIN_SCALE_SIZE 8
-/* round A up/down to integer count of B */
-#define ROUND_UP(A,B) ((gint)(((A)+(B)-1)/(B))*(B))
-#define ROUND_DOWN(A,B) ((gint)(((A))/(B))*(B))
-
-typedef enum {
- TILE_RENDER_NONE = 0, /* do nothing */
- TILE_RENDER_AREA, /* render an area of the tile */
- TILE_RENDER_ALL /* render the whole tile */
-} ImageTileRenderType;
-
-typedef struct _ImageTile ImageTile;
-typedef struct _QueueData QueueData;
-
-struct _ImageTile
-{
- GdkPixmap *pixmap; /* off screen buffer */
- GdkPixbuf *pixbuf; /* pixbuf area for zooming */
- gint x; /* x offset into image */
- gint y; /* y offset into image */
- gint w; /* width that is visible (may be less if at edge of image) */
- gint h; /* height '' */
-
- gboolean blank;
-
-/* render_todo: (explanation)
- NONE do nothing
- AREA render area of tile, usually only used when loading an image
- note: will jump to an ALL if render_done is not ALL.
- ALL render entire tile, if never done before w/ ALL, for expose events *only*
-*/
-
- ImageTileRenderType render_todo; /* what to do (see above) */
- ImageTileRenderType render_done; /* highest that has been done before on tile */
-
- QueueData *qd;
- QueueData *qd2;
-
- guint size; /* est. memory used by pixmap and pixbuf */
-};
-
-struct _QueueData
-{
- ImageTile *it;
- gint x;
- gint y;
- gint w;
- gint h;
- gboolean new_data;
-};
-
-typedef struct _SourceTile SourceTile;
-struct _SourceTile
-{
- gint x;
- gint y;
- GdkPixbuf *pixbuf;
- gboolean blank;
-};
-
-typedef struct _OverlayData OverlayData;
-struct _OverlayData
-{
- gint id;
-
- GdkPixbuf *pixbuf;
- GdkWindow *window;
-
- gint x;
- gint y;
-
- OverlayRendererFlags flags;
-};
-
enum {
SIGNAL_ZOOM = 0,
SIGNAL_CLICKED,
GValue *value, GParamSpec *pspec);
static gboolean pixbuf_renderer_expose(GtkWidget *widget, GdkEventExpose *event);
-static void pr_render_complete_signal(PixbufRenderer *pr);
-
-static void pr_overlay_list_clear(PixbufRenderer *pr);
static void pr_scroller_timer_set(PixbufRenderer *pr, gboolean start);
-static void pr_border_draw(PixbufRenderer *pr, gint x, gint y, gint w, gint h);
static void pr_source_tile_free_all(PixbufRenderer *pr);
-static void pr_tile_free_all(PixbufRenderer *pr);
-static void pr_tile_invalidate_region(PixbufRenderer *pr, gint x, gint y, gint w, gint h);
-static gboolean pr_tile_is_visible(PixbufRenderer *pr, ImageTile *it);
-static void pr_queue_clear(PixbufRenderer *pr);
-static void pr_queue_merge(QueueData *parent, QueueData *qd);
-static void pr_queue(PixbufRenderer *pr, gint x, gint y, gint w, gint h,
- gint clamp, ImageTileRenderType render, gboolean new_data, gboolean only_existing);
-
-static void pr_redraw(PixbufRenderer *pr, gboolean new_data);
static void pr_zoom_sync(PixbufRenderer *pr, gdouble zoom,
PrZoomFlags flags, gint px, gint py);
static void pr_signals_connect(PixbufRenderer *pr);
static void pr_size_cb(GtkWidget *widget, GtkAllocation *allocation, gpointer data);
-static void pr_hierarchy_changed_cb(GtkWidget *widget, GtkWidget *previous_toplevel, gpointer data);
static void pixbuf_renderer_paint(PixbufRenderer *pr, GdkRectangle *area);
-static gint pr_queue_draw_idle_cb(gpointer data);
+static void pr_stereo_temp_disable(PixbufRenderer *pr, gboolean disable);
/*
pr->zoom = 1.0;
pr->scale = 1.0;
+ pr->aspect_ratio = 1.0;
pr->dither_quality = GDK_RGB_DITHER_NORMAL;
pr->scroll_reset = PR_SCROLL_RESET_TOPLEFT;
- pr->draw_idle_id = 0;
-
- pr->tile_width = PR_TILE_SIZE;
- pr->tile_height = PR_TILE_SIZE;
-
- pr->tiles = NULL;
- pr->tile_cache_size = 0;
-
- pr->tile_cache_max = PR_CACHE_SIZE_DEFAULT;
-
pr->scroller_id = 0;
pr->scroller_overlay = -1;
pr->norm_center_x = 0.5;
pr->norm_center_y = 0.5;
+
+ pr->stereo_mode = PR_STEREO_NONE;
+
+ pr->renderer = (void *)renderer_tiles_new(pr);
+
+ pr->renderer2 = NULL;
gtk_widget_set_double_buffered(box, FALSE);
g_signal_connect_after(G_OBJECT(box), "size_allocate",
G_CALLBACK(pr_size_cb), pr);
- g_signal_connect(G_OBJECT(pr), "hierarchy-changed",
- G_CALLBACK(pr_hierarchy_changed_cb), pr);
-
pr_signals_connect(pr);
}
pr = PIXBUF_RENDERER(object);
- pr_queue_clear(pr);
- pr_tile_free_all(pr);
+ pr->renderer->free(pr->renderer);
+ if (pr->renderer2) pr->renderer2->free(pr->renderer2);
if (pr->pixbuf) g_object_unref(pr->pixbuf);
- if (pr->spare_tile) g_object_unref(pr->spare_tile);
pr_scroller_timer_set(pr, FALSE);
- pr_overlay_list_clear(pr);
pr_source_tile_free_all(pr);
}
pr->complete = g_value_get_boolean(value);
break;
case PROP_CACHE_SIZE_DISPLAY:
- pr->tile_cache_max = g_value_get_uint(value);
+// pr->tile_cache_max = g_value_get_uint(value);
break;
case PROP_CACHE_SIZE_TILES:
pr->source_tiles_cache_size = g_value_get_uint(value);
g_value_set_boolean(value, pr->complete);
break;
case PROP_CACHE_SIZE_DISPLAY:
- g_value_set_uint(value, pr->tile_cache_max);
+// g_value_set_uint(value, pr->tile_cache_max);
break;
case PROP_CACHE_SIZE_TILES:
g_value_set_uint(value, pr->source_tiles_cache_size);
if (cursor) gdk_cursor_unref(cursor);
}
-static gint pixmap_calc_size(GdkPixmap *pixmap)
-{
- gint w, h, d;
-
- d = gdk_drawable_get_depth(pixmap);
- gdk_drawable_get_size(pixmap, &w, &h);
- return w * h * (d / 8);
-}
-
-static gboolean pr_clip_region(gint x, gint y, gint w, gint h,
+gboolean pr_clip_region(gint x, gint y, gint w, gint h,
gint clip_x, gint clip_y, gint clip_w, gint clip_h,
gint *rx, gint *ry, gint *rw, gint *rh)
{
*-------------------------------------------------------------------
*/
-static void pr_overlay_get_position(PixbufRenderer *pr, OverlayData *od,
- gint *x, gint *y, gint *w, gint *h)
-{
- gint px, py, pw, ph;
-
- pw = gdk_pixbuf_get_width(od->pixbuf);
- ph = gdk_pixbuf_get_height(od->pixbuf);
- px = od->x;
- py = od->y;
-
- if (od->flags & OVL_RELATIVE)
- {
- if (px < 0) px = pr->window_width - pw + px;
- if (py < 0) py = pr->window_height - ph + py;
- }
-
- if (x) *x = px;
- if (y) *y = py;
- if (w) *w = pw;
- if (h) *h = ph;
-}
-
-static void pr_overlay_init_window(PixbufRenderer *pr, OverlayData *od)
-{
- gint px, py, pw, ph;
- GdkWindowAttr attributes;
- gint attributes_mask;
-
- pr_overlay_get_position(pr, od, &px, &py, &pw, &ph);
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.width = pw;
- attributes.height = ph;
- attributes.event_mask = GDK_EXPOSURE_MASK;
- attributes_mask = 0;
-
- od->window = gdk_window_new(GTK_WIDGET(pr)->window, &attributes, attributes_mask);
- gdk_window_set_user_data(od->window, pr);
- gdk_window_move(od->window, px, py);
- gdk_window_show(od->window);
-}
-
-static void pr_overlay_draw(PixbufRenderer *pr, gint x, gint y, gint w, gint h,
- ImageTile *it)
-{
- GtkWidget *box;
- GList *work;
-
- box = GTK_WIDGET(pr);
-
- work = pr->overlay_list;
- while (work)
- {
- OverlayData *od;
- gint px, py, pw, ph;
- gint rx, ry, rw, rh;
-
- od = work->data;
- work = work->next;
-
- if (!od->window) pr_overlay_init_window(pr, od);
-
- pr_overlay_get_position(pr, od, &px, &py, &pw, &ph);
- if (pr_clip_region(x, y, w, h, px, py, pw, ph, &rx, &ry, &rw, &rh))
- {
- if (!pr->overlay_buffer)
- {
- pr->overlay_buffer = gdk_pixmap_new(((GtkWidget *)pr)->window, pr->tile_width, pr->tile_height, -1);
- }
-
- if (it)
- {
-#if GTK_CHECK_VERSION(2,20,0)
- gdk_draw_drawable(pr->overlay_buffer, box->style->fg_gc[gtk_widget_get_state(box)],
-#else
- gdk_draw_drawable(pr->overlay_buffer, box->style->fg_gc[GTK_WIDGET_STATE(box)],
-#endif
- it->pixmap,
- rx - (pr->x_offset + (it->x - pr->x_scroll)),
- ry - (pr->y_offset + (it->y - pr->y_scroll)),
- 0, 0, rw, rh);
- gdk_draw_pixbuf(pr->overlay_buffer,
-#if GTK_CHECK_VERSION(2,20,0)
- box->style->fg_gc[gtk_widget_get_state(box)],
-#else
- box->style->fg_gc[GTK_WIDGET_STATE(box)],
-#endif
- od->pixbuf,
- rx - px, ry - py,
- 0, 0, rw, rh,
- pr->dither_quality, rx, ry);
-#if GTK_CHECK_VERSION(2,20,0)
- gdk_draw_drawable(od->window, box->style->fg_gc[gtk_widget_get_state(box)],
-#else
- gdk_draw_drawable(od->window, box->style->fg_gc[GTK_WIDGET_STATE(box)],
-#endif
- pr->overlay_buffer,
- 0, 0,
- rx - px, ry - py, rw, rh);
- }
- else
- {
- /* no ImageTile means region may be larger than our scratch buffer */
- gint sx, sy;
-
- for (sx = rx; sx < rx + rw; sx += pr->tile_width)
- for (sy = ry; sy < ry + rh; sy += pr->tile_height)
- {
- gint sw, sh;
-
- sw = MIN(rx + rw - sx, pr->tile_width);
- sh = MIN(ry + rh - sy, pr->tile_height);
-
- gdk_draw_rectangle(pr->overlay_buffer,
-#if GTK_CHECK_VERSION(2,20,0)
- box->style->bg_gc[gtk_widget_get_state(box)], TRUE,
-#else
- box->style->bg_gc[GTK_WIDGET_STATE(box)], TRUE,
-#endif
- 0, 0, sw, sh);
- gdk_draw_pixbuf(pr->overlay_buffer,
-#if GTK_CHECK_VERSION(2,20,0)
- box->style->fg_gc[gtk_widget_get_state(box)],
-#else
- box->style->fg_gc[GTK_WIDGET_STATE(box)],
-#endif
- od->pixbuf,
- sx - px, sy - py,
- 0, 0, sw, sh,
- pr->dither_quality, sx, sy);
-#if GTK_CHECK_VERSION(2,20,0)
- gdk_draw_drawable(od->window, box->style->fg_gc[gtk_widget_get_state(box)],
-#else
- gdk_draw_drawable(od->window, box->style->fg_gc[GTK_WIDGET_STATE(box)],
-#endif
- pr->overlay_buffer,
- 0, 0,
- sx - px, sy - py, sw, sh);
- }
- }
- }
- }
-}
-
-static void pr_overlay_queue_draw(PixbufRenderer *pr, OverlayData *od)
-{
- gint x, y, w, h;
-
- pr_overlay_get_position(pr, od, &x, &y, &w, &h);
- pr_queue(pr, pr->x_scroll - pr->x_offset + x,
- pr->y_scroll - pr->y_offset + y,
- w, h,
- FALSE, TILE_RENDER_ALL, FALSE, FALSE);
-
- pr_border_draw(pr, x, y, w, h);
-}
-
-static void pr_overlay_queue_all(PixbufRenderer *pr)
-{
- GList *work;
-
- work = pr->overlay_list;
- while (work)
- {
- OverlayData *od = work->data;
- work = work->next;
-
- pr_overlay_queue_draw(pr, od);
- }
-}
-
-static void pr_overlay_update_sizes(PixbufRenderer *pr)
-{
- GList *work;
-
- work = pr->overlay_list;
- while (work)
- {
- OverlayData *od = work->data;
- work = work->next;
-
- if (!od->window) pr_overlay_init_window(pr, od);
-
- if (od->flags & OVL_RELATIVE)
- {
- gint x, y, w, h;
-
- pr_overlay_get_position(pr, od, &x, &y, &w, &h);
- gdk_window_move_resize(od->window, x, y, w, h);
- }
- }
-}
-
-static OverlayData *pr_overlay_find(PixbufRenderer *pr, gint id)
-{
- GList *work;
-
- work = pr->overlay_list;
- while (work)
- {
- OverlayData *od = work->data;
- work = work->next;
-
- if (od->id == id) return od;
- }
-
- return NULL;
-}
-
gint pixbuf_renderer_overlay_add(PixbufRenderer *pr, GdkPixbuf *pixbuf, gint x, gint y,
OverlayRendererFlags flags)
{
- OverlayData *od;
- gint id;
-
- g_return_val_if_fail(IS_PIXBUF_RENDERER(pr), -1);
- g_return_val_if_fail(pixbuf != NULL, -1);
-
- id = 1;
- while (pr_overlay_find(pr, id)) id++;
-
- od = g_new0(OverlayData, 1);
- od->id = id;
- od->pixbuf = pixbuf;
- g_object_ref(G_OBJECT(od->pixbuf));
- od->x = x;
- od->y = y;
- od->flags = flags;
-
- pr_overlay_init_window(pr, od);
-
- pr->overlay_list = g_list_append(pr->overlay_list, od);
-
- pr_overlay_queue_draw(pr, od);
-
- return od->id;
-}
-
-static void pr_overlay_free(PixbufRenderer *pr, OverlayData *od)
-{
- pr->overlay_list = g_list_remove(pr->overlay_list, od);
-
- if (od->pixbuf) g_object_unref(G_OBJECT(od->pixbuf));
- if (od->window) gdk_window_destroy(od->window);
- g_free(od);
-
- if (!pr->overlay_list && pr->overlay_buffer)
- {
- g_object_unref(pr->overlay_buffer);
- pr->overlay_buffer = NULL;
- }
-}
-
-static void pr_overlay_list_clear(PixbufRenderer *pr)
-{
- while (pr->overlay_list)
- {
- OverlayData *od;
-
- od = pr->overlay_list->data;
- pr_overlay_free(pr, od);
- }
-}
-
-static void pr_overlay_list_reset_window(PixbufRenderer *pr)
-{
- GList *work;
-
- if (pr->overlay_buffer) g_object_unref(pr->overlay_buffer);
- pr->overlay_buffer = NULL;
-
- work = pr->overlay_list;
- while (work)
- {
- OverlayData *od = work->data;
- work = work->next;
- if (od->window) gdk_window_destroy(od->window);
- od->window = NULL;
- }
+ /* let's assume both renderers returns the same value */
+ if (pr->renderer2) pr->renderer2->overlay_add(pr->renderer2, pixbuf, x, y, flags);
+ return pr->renderer->overlay_add(pr->renderer, pixbuf, x, y, flags);
}
void pixbuf_renderer_overlay_set(PixbufRenderer *pr, gint id, GdkPixbuf *pixbuf, gint x, gint y)
{
- OverlayData *od;
-
- g_return_if_fail(IS_PIXBUF_RENDERER(pr));
-
- od = pr_overlay_find(pr, id);
- if (!od) return;
-
- if (pixbuf)
- {
- gint px, py, pw, ph;
-
- g_object_ref(G_OBJECT(pixbuf));
- g_object_unref(G_OBJECT(od->pixbuf));
- od->pixbuf = pixbuf;
-
- od->x = x;
- od->y = y;
-
- if (!od->window) pr_overlay_init_window(pr, od);
-
- pr_overlay_queue_draw(pr, od);
- pr_overlay_get_position(pr, od, &px, &py, &pw, &ph);
- gdk_window_move_resize(od->window, px, py, pw, ph);
- }
- else
- {
- pr_overlay_queue_draw(pr, od);
- pr_overlay_free(pr, od);
- }
+ pr->renderer->overlay_set(pr->renderer, id, pixbuf, x, y);
+ if (pr->renderer2) pr->renderer2->overlay_set(pr->renderer2, id, pixbuf, x, y);
}
gboolean pixbuf_renderer_overlay_get(PixbufRenderer *pr, gint id, GdkPixbuf **pixbuf, gint *x, gint *y)
{
- OverlayData *od;
-
- g_return_val_if_fail(IS_PIXBUF_RENDERER(pr), FALSE);
-
- od = pr_overlay_find(pr, id);
- if (!od) return FALSE;
-
- if (pixbuf) *pixbuf = od->pixbuf;
- if (x) *x = od->x;
- if (y) *y = od->y;
-
- return TRUE;
+ if (pr->renderer2) pr->renderer2->overlay_get(pr->renderer2, id, pixbuf, x, y);
+ return pr->renderer->overlay_get(pr->renderer, id, pixbuf, x, y);
}
void pixbuf_renderer_overlay_remove(PixbufRenderer *pr, gint id)
{
- pixbuf_renderer_overlay_set(pr, id, NULL, 0, 0);
-}
-
-static void pr_hierarchy_changed_cb(GtkWidget *widget, GtkWidget *previous_toplevel, gpointer data)
-{
- PixbufRenderer *pr = data;
- pr_overlay_list_reset_window(pr);
+ pr->renderer->overlay_set(pr->renderer, id, NULL, 0, 0);
+ if (pr->renderer2) pr->renderer2->overlay_set(pr->renderer2, id, NULL, 0, 0);
}
-
/*
*-------------------------------------------------------------------
* scroller overlay
*-------------------------------------------------------------------
*/
-static void pr_border_draw(PixbufRenderer *pr, gint x, gint y, gint w, gint h)
-{
- GtkWidget *box;
- gint rx, ry, rw, rh;
-
- box = GTK_WIDGET(pr);
-
- if (!box->window) return;
-
- if (!pr->pixbuf && !pr->source_tiles_enabled)
- {
- if (pr_clip_region(x, y, w, h,
- 0, 0,
- pr->window_width, pr->window_height,
- &rx, &ry, &rw, &rh))
- {
- gdk_window_clear_area(box->window, rx, ry, rw, rh);
- pr_overlay_draw(pr, rx, ry, rw, rh, NULL);
- }
- return;
- }
-
- if (pr->vis_width < pr->window_width)
- {
- if (pr->x_offset > 0 &&
- pr_clip_region(x, y, w, h,
- 0, 0,
- pr->x_offset, pr->window_height,
- &rx, &ry, &rw, &rh))
- {
- gdk_window_clear_area(box->window, rx, ry, rw, rh);
- pr_overlay_draw(pr, rx, ry, rw, rh, NULL);
- }
- if (pr->window_width - pr->vis_width - pr->x_offset > 0 &&
- pr_clip_region(x, y, w, h,
- pr->x_offset + pr->vis_width, 0,
- pr->window_width - pr->vis_width - pr->x_offset, pr->window_height,
- &rx, &ry, &rw, &rh))
- {
- gdk_window_clear_area(box->window, rx, ry, rw, rh);
- pr_overlay_draw(pr, rx, ry, rw, rh, NULL);
- }
- }
- if (pr->vis_height < pr->window_height)
- {
- if (pr->y_offset > 0 &&
- pr_clip_region(x, y, w, h,
- pr->x_offset, 0,
- pr->vis_width, pr->y_offset,
- &rx, &ry, &rw, &rh))
- {
- gdk_window_clear_area(box->window, rx, ry, rw, rh);
- pr_overlay_draw(pr, rx, ry, rw, rh, NULL);
- }
- if (pr->window_height - pr->vis_height - pr->y_offset > 0 &&
- pr_clip_region(x, y, w, h,
- pr->x_offset, pr->y_offset + pr->vis_height,
- pr->vis_width, pr->window_height - pr->vis_height - pr->y_offset,
- &rx, &ry, &rw, &rh))
- {
- gdk_window_clear_area(box->window, rx, ry, rw, rh);
- pr_overlay_draw(pr, rx, ry, rw, rh, NULL);
- }
- }
-}
-
static void pr_border_clear(PixbufRenderer *pr)
{
- pr_border_draw(pr, 0, 0, pr->window_width, pr->window_height);
+ pr->renderer->border_clear(pr->renderer);
+ if (pr->renderer2) pr->renderer2->border_clear(pr->renderer2);
}
void pixbuf_renderer_set_color(PixbufRenderer *pr, GdkColor *color)
#endif
}
+static void pr_redraw(PixbufRenderer *pr, gboolean new_data)
+{
+ pr->renderer->queue_clear(pr->renderer);
+ pr->renderer->redraw(pr->renderer, 0, 0, pr->width, pr->height, TRUE, TILE_RENDER_ALL, new_data, FALSE);
+ if (pr->renderer2) {
+ pr->renderer2->queue_clear(pr->renderer2);
+ pr->renderer2->redraw(pr->renderer2, 0, 0, pr->width, pr->height, TRUE, TILE_RENDER_ALL, new_data, FALSE);
+ }
+}
/*
*-------------------------------------------------------------------
if (!st) return FALSE;
- x1 = ROUND_DOWN(pr->x_scroll, pr->tile_width);
- y1 = ROUND_DOWN(pr->y_scroll, pr->tile_height);
- x2 = ROUND_UP(pr->x_scroll + pr->vis_width, pr->tile_width);
- y2 = ROUND_UP(pr->y_scroll + pr->vis_height, pr->tile_height);
+// x1 = ROUND_DOWN(pr->x_scroll, pr->tile_width);
+// y1 = ROUND_DOWN(pr->y_scroll, pr->tile_height);
+// x2 = ROUND_UP(pr->x_scroll + pr->vis_width, pr->tile_width);
+// y2 = ROUND_UP(pr->y_scroll + pr->vis_height, pr->tile_height);
+ x1 = pr->x_scroll;
+ y1 = pr->y_scroll;
+ x2 = pr->x_scroll + pr->vis_width;
+ y2 = pr->y_scroll + pr->vis_height;
return !((gdouble)st->x * pr->scale > (gdouble)x2 ||
(gdouble)(st->x + pr->source_tile_width) * pr->scale < (gdouble)x1 ||
st->blank = FALSE;
}
- pr_tile_invalidate_region(pr, st->x * pr->scale, st->y * pr->scale,
+ pr->renderer->invalidate_region(pr->renderer, st->x * pr->scale, st->y * pr->scale,
+ pr->source_tile_width * pr->scale, pr->source_tile_height * pr->scale);
+ if (pr->renderer2) pr->renderer2->invalidate_region(pr->renderer2, st->x * pr->scale, st->y * pr->scale,
pr->source_tile_width * pr->scale, pr->source_tile_height * pr->scale);
-
return st;
}
return NULL;
}
-static GList *pr_source_tile_compute_region(PixbufRenderer *pr, gint x, gint y, gint w, gint h, gboolean request)
+GList *pr_source_tile_compute_region(PixbufRenderer *pr, gint x, gint y, gint w, gint h, gboolean request)
{
gint x1, y1;
GList *list = NULL;
if (pr->func_tile_request &&
pr->func_tile_request(pr, rx, ry, rw, rh, pixbuf, pr->func_tile_data))
{
- pr_tile_invalidate_region(pr, rx * pr->scale, ry * pr->scale,
+ pr->renderer->invalidate_region(pr->renderer, rx * pr->scale, ry * pr->scale,
rw * pr->scale, rh * pr->scale);
+ if (pr->renderer2) pr->renderer2->invalidate_region(pr->renderer2, rx * pr->scale, ry * pr->scale,
+ rw * pr->scale, rh * pr->scale);
}
g_object_unref(pixbuf);
}
}
}
-static gboolean pr_source_tile_render(PixbufRenderer *pr, ImageTile *it,
- gint x, gint y, gint w, gint h,
- gboolean new_data, gboolean fast)
+void pixbuf_renderer_set_tiles(PixbufRenderer *pr, gint width, gint height,
+ gint tile_width, gint tile_height, gint cache_size,
+ PixbufRendererTileRequestFunc func_request,
+ PixbufRendererTileDisposeFunc func_dispose,
+ gpointer user_data,
+ gdouble zoom)
{
- GtkWidget *box;
- GList *list;
- GList *work;
- gboolean draw = FALSE;
+ g_return_if_fail(IS_PIXBUF_RENDERER(pr));
+ g_return_if_fail(tile_width >= 32 && tile_width >= 32);
+ g_return_if_fail(width >= 32 && height > 32);
+ g_return_if_fail(func_request != NULL);
- box = GTK_WIDGET(pr);
+ if (pr->pixbuf) g_object_unref(pr->pixbuf);
+ pr->pixbuf = NULL;
- if (pr->zoom == 1.0 || pr->scale == 1.0)
- {
- list = pr_source_tile_compute_region(pr, it->x + x, it->y + y, w, h, TRUE);
- work = list;
- while (work)
- {
- SourceTile *st;
- gint rx, ry, rw, rh;
+ pr_source_tile_unset(pr);
- st = work->data;
- work = work->next;
-
- if (pr_clip_region(st->x, st->y, pr->source_tile_width, pr->source_tile_height,
- it->x + x, it->y + y, w, h,
- &rx, &ry, &rw, &rh))
- {
- if (st->blank)
- {
- gdk_draw_rectangle(it->pixmap, box->style->black_gc, TRUE,
- rx - st->x, ry - st->y, rw, rh);
- }
- else /* (pr->zoom == 1.0 || pr->scale == 1.0) */
- {
- gdk_draw_pixbuf(it->pixmap,
-#if GTK_CHECK_VERSION(2,20,0)
- box->style->fg_gc[gtk_widget_get_state(box)],
-#else
- box->style->fg_gc[GTK_WIDGET_STATE(box)],
-#endif
- st->pixbuf,
- rx - st->x, ry - st->y,
- rx - it->x, ry - it->y,
- rw, rh,
- pr->dither_quality, rx, ry);
- }
- }
- }
- }
- else
- {
- gdouble scale_x, scale_y;
- gint sx, sy, sw, sh;
-
- if (pr->image_width == 0 || pr->image_height == 0) return FALSE;
- scale_x = (gdouble)pr->width / pr->image_width;
- scale_y = (gdouble)pr->height / pr->image_height;
-
- sx = (gdouble)(it->x + x) / scale_x;
- sy = (gdouble)(it->y + y) / scale_y;
- sw = (gdouble)w / scale_x;
- sh = (gdouble)h / scale_y;
-
- if (pr->width < PR_MIN_SCALE_SIZE || pr->height < PR_MIN_SCALE_SIZE) fast = TRUE;
-
-#if 0
- /* draws red over draw region, to check for leaks (regions not filled) */
- pixbuf_set_rect_fill(it->pixbuf, x, y, w, h, 255, 0, 0, 255);
-#endif
-
- list = pr_source_tile_compute_region(pr, sx, sy, sw, sh, TRUE);
- work = list;
- while (work)
- {
- SourceTile *st;
- gint rx, ry, rw, rh;
- gint stx, sty, stw, sth;
-
- st = work->data;
- work = work->next;
-
- stx = floor((gdouble)st->x * scale_x);
- sty = floor((gdouble)st->y * scale_y);
- stw = ceil((gdouble)(st->x + pr->source_tile_width) * scale_x) - stx;
- sth = ceil((gdouble)(st->y + pr->source_tile_height) * scale_y) - sty;
-
- if (pr_clip_region(stx, sty, stw, sth,
- it->x + x, it->y + y, w, h,
- &rx, &ry, &rw, &rh))
- {
- if (st->blank)
- {
- gdk_draw_rectangle(it->pixmap, box->style->black_gc, TRUE,
- rx - st->x, ry - st->y, rw, rh);
- }
- else
- {
- gdouble offset_x;
- gdouble offset_y;
-
- /* may need to use unfloored stx,sty values here */
- offset_x = (gdouble)(stx - it->x);
- offset_y = (gdouble)(sty - it->y);
-
- gdk_pixbuf_scale(st->pixbuf, it->pixbuf, rx - it->x, ry - it->y, rw, rh,
- (gdouble) 0.0 + offset_x,
- (gdouble) 0.0 + offset_y,
- scale_x, scale_y,
- (fast) ? GDK_INTERP_NEAREST : pr->zoom_quality);
- draw = TRUE;
- }
- }
- }
- }
-
- g_list_free(list);
-
- return draw;
-}
-
-void pixbuf_renderer_set_tiles(PixbufRenderer *pr, gint width, gint height,
- gint tile_width, gint tile_height, gint cache_size,
- PixbufRendererTileRequestFunc func_request,
- PixbufRendererTileDisposeFunc func_dispose,
- gpointer user_data,
- gdouble zoom)
-{
- g_return_if_fail(IS_PIXBUF_RENDERER(pr));
- g_return_if_fail(tile_width >= 32 && tile_width >= 32);
- g_return_if_fail(width >= 32 && height > 32);
- g_return_if_fail(func_request != NULL);
-
- if (pr->pixbuf) g_object_unref(pr->pixbuf);
- pr->pixbuf = NULL;
-
- pr_source_tile_unset(pr);
-
- if (cache_size < 4) cache_size = 4;
+ if (cache_size < 4) cache_size = 4;
pr->source_tiles_enabled = TRUE;
pr->source_tiles_cache_size = cache_size;
pr_zoom_sync(pr, zoom, flags, x, y);
}
+
/*
*-------------------------------------------------------------------
- * display tiles
+ * signal emission
*-------------------------------------------------------------------
*/
-static ImageTile *pr_tile_new(gint x, gint y, gint width, gint height)
-{
- ImageTile *it;
-
- it = g_new0(ImageTile, 1);
-
- it->x = x;
- it->y = y;
- it->w = width;
- it->h = height;
-
- it->render_done = TILE_RENDER_NONE;
-
- return it;
-}
-
-static void pr_tile_free(ImageTile *it)
-{
- if (!it) return;
-
- if (it->pixbuf) g_object_unref(it->pixbuf);
- if (it->pixmap) g_object_unref(it->pixmap);
-
- g_free(it);
-}
-
-static void pr_tile_free_all(PixbufRenderer *pr)
+static void pr_update_signal(PixbufRenderer *pr)
{
- GList *work;
-
- work = pr->tiles;
- while (work)
- {
- ImageTile *it;
-
- it = work->data;
- work = work->next;
-
- pr_tile_free(it);
- }
-
- g_list_free(pr->tiles);
- pr->tiles = NULL;
- pr->tile_cache_size = 0;
+#if 0
+ log_printf("FIXME: send updated signal\n");
+#endif
+ DEBUG_1("%s pixbuf renderer updated - started drawing %p, img: %dx%d", get_exec_time(), pr, pr->image_width, pr->image_height);
+ pr->debug_updated = TRUE;
}
-static ImageTile *pr_tile_add(PixbufRenderer *pr, gint x, gint y)
+static void pr_zoom_signal(PixbufRenderer *pr)
{
- ImageTile *it;
-
- it = pr_tile_new(x, y, pr->tile_width, pr->tile_height);
-
- if (it->x + it->w > pr->width) it->w = pr->width - it->x;
- if (it->y + it->h > pr->height) it->h = pr->height - it->y;
-
- pr->tiles = g_list_prepend(pr->tiles, it);
- pr->tile_cache_size += it->size;
-
- return it;
+ g_signal_emit(pr, signals[SIGNAL_ZOOM], 0, pr->zoom);
}
-static void pr_tile_remove(PixbufRenderer *pr, ImageTile *it)
+static void pr_clicked_signal(PixbufRenderer *pr, GdkEventButton *bevent)
{
- if (it->qd)
- {
- QueueData *qd = it->qd;
-
- it->qd = NULL;
- pr->draw_queue = g_list_remove(pr->draw_queue, qd);
- g_free(qd);
- }
-
- if (it->qd2)
- {
- QueueData *qd = it->qd2;
-
- it->qd2 = NULL;
- pr->draw_queue_2pass = g_list_remove(pr->draw_queue_2pass, qd);
- g_free(qd);
- }
-
- pr->tiles = g_list_remove(pr->tiles, it);
- pr->tile_cache_size -= it->size;
-
- pr_tile_free(it);
+ g_signal_emit(pr, signals[SIGNAL_CLICKED], 0, bevent);
}
-static void pr_tile_free_space(PixbufRenderer *pr, guint space, ImageTile *it)
+static void pr_scroll_notify_signal(PixbufRenderer *pr)
{
- GList *work;
- guint tile_max;
-
- work = g_list_last(pr->tiles);
-
- if (pr->source_tiles_enabled && pr->scale < 1.0)
- {
- gint tiles;
-
- tiles = (pr->vis_width / pr->tile_width + 1) * (pr->vis_height / pr->tile_height + 1);
- tile_max = MAX(tiles * pr->tile_width * pr->tile_height * 3,
- (gint)((gdouble)pr->tile_cache_max * 1048576.0 * pr->scale));
- }
- else
- {
- tile_max = pr->tile_cache_max * 1048576;
- }
-
- while (work && pr->tile_cache_size + space > tile_max)
- {
- ImageTile *needle;
-
- needle = work->data;
- work = work->prev;
- if (needle != it &&
- ((!needle->qd && !needle->qd2) || !pr_tile_is_visible(pr, needle))) pr_tile_remove(pr, needle);
- }
+ g_signal_emit(pr, signals[SIGNAL_SCROLL_NOTIFY], 0);
}
-static void pr_tile_invalidate_all(PixbufRenderer *pr)
+void pr_render_complete_signal(PixbufRenderer *pr)
{
- GList *work;
-
- work = pr->tiles;
- while (work)
+ if (!pr->complete)
{
- ImageTile *it;
-
- it = work->data;
- work = work->next;
-
- it->render_done = TILE_RENDER_NONE;
- it->render_todo = TILE_RENDER_ALL;
- it->blank = FALSE;
-
- it->w = MIN(pr->tile_width, pr->width - it->x);
- it->h = MIN(pr->tile_height, pr->height - it->y);
+ g_signal_emit(pr, signals[SIGNAL_RENDER_COMPLETE], 0);
+ g_object_set(G_OBJECT(pr), "complete", TRUE, NULL);
}
-}
-
-static void pr_tile_invalidate_region(PixbufRenderer *pr, gint x, gint y, gint w, gint h)
-{
- gint x1, x2;
- gint y1, y2;
- GList *work;
-
- x1 = ROUND_DOWN(x, pr->tile_width);
- x2 = ROUND_UP(x + w, pr->tile_width);
-
- y1 = ROUND_DOWN(y, pr->tile_height);
- y2 = ROUND_UP(y + h, pr->tile_height);
-
- work = pr->tiles;
- while (work)
+ if (pr->debug_updated)
{
- ImageTile *it;
-
- it = work->data;
- work = work->next;
-
- if (it->x < x2 && it->x + it->w > x1 &&
- it->y < y2 && it->y + it->h > y1)
- {
- it->render_done = TILE_RENDER_NONE;
- it->render_todo = TILE_RENDER_ALL;
- }
+ DEBUG_1("%s pixbuf renderer done %p", get_exec_time(), pr);
+ pr->debug_updated = FALSE;
}
}
-static ImageTile *pr_tile_get(PixbufRenderer *pr, gint x, gint y, gboolean only_existing)
+static void pr_drag_signal(PixbufRenderer *pr, GdkEventButton *bevent)
{
- GList *work;
-
- work = pr->tiles;
- while (work)
- {
- ImageTile *it;
-
- it = work->data;
- if (it->x == x && it->y == y)
- {
- pr->tiles = g_list_delete_link(pr->tiles, work);
- pr->tiles = g_list_prepend(pr->tiles, it);
- return it;
- }
-
- work = work->next;
- }
-
- if (only_existing) return NULL;
-
- return pr_tile_add(pr, x, y);
+ g_signal_emit(pr, signals[SIGNAL_DRAG], 0, bevent);
}
-static void pr_tile_prepare(PixbufRenderer *pr, ImageTile *it)
+static void pr_update_pixel_signal(PixbufRenderer *pr)
{
- if (!it->pixmap)
- {
- GdkPixmap *pixmap;
- guint size;
-
- pixmap = gdk_pixmap_new(((GtkWidget *)pr)->window, pr->tile_width, pr->tile_height, -1);
-
- size = pixmap_calc_size(pixmap);
- pr_tile_free_space(pr, size, it);
-
- it->pixmap = pixmap;
- it->size += size;
- pr->tile_cache_size += size;
- }
-
- if ((pr->zoom != 1.0 || pr->source_tiles_enabled || (pr->pixbuf && gdk_pixbuf_get_has_alpha(pr->pixbuf)) ||
- pr->orientation != EXIF_ORIENTATION_TOP_LEFT || pr->func_post_process) && !it->pixbuf)
- {
- GdkPixbuf *pixbuf;
- guint size;
-#if 0
-/* I don't think that we need a pixbuf with alpha channel here */
- if (pr->pixbuf)
- {
- pixbuf = gdk_pixbuf_new(gdk_pixbuf_get_colorspace(pr->pixbuf),
- gdk_pixbuf_get_has_alpha(pr->pixbuf),
- gdk_pixbuf_get_bits_per_sample(pr->pixbuf),
- pr->tile_width, pr->tile_height);
- }
- else
-#endif
- {
- pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, pr->tile_width, pr->tile_height);
- }
-
- size = gdk_pixbuf_get_rowstride(pixbuf) * pr->tile_height;
- pr_tile_free_space(pr, size, it);
-
- it->pixbuf = pixbuf;
- it->size += size;
- pr->tile_cache_size += size;
- }
+ g_signal_emit(pr, signals[SIGNAL_UPDATE_PIXEL], 0);
}
/*
*-------------------------------------------------------------------
- * drawing
+ * sync and clamp
*-------------------------------------------------------------------
*/
-static void pr_tile_coords_map_orientation(PixbufRenderer *pr,
+void pr_tile_coords_map_orientation(gint orientation,
gdouble tile_x, gdouble tile_y, /* coordinates of the tile */
gdouble image_w, gdouble image_h,
gdouble tile_w, gdouble tile_h,
{
*res_x = tile_x;
*res_y = tile_y;
- switch (pr->orientation)
+ switch (orientation)
{
case EXIF_ORIENTATION_TOP_LEFT:
/* normal -- nothing to do */
// log_printf("tile coord y:%f, ih:%d, th:%f ry:%f\n", tile_y, image_h, tile_h, *res_x);
}
-static void pr_tile_region_map_orientation(PixbufRenderer *pr,
+void pr_tile_region_map_orientation(gint orientation,
gint area_x, gint area_y, /* coordinates of the area inside tile */
gint tile_w, gint tile_h,
gint area_w, gint area_h,
*res_w = area_w;
*res_h = area_h;
- switch (pr->orientation)
+ switch (orientation)
{
case EXIF_ORIENTATION_TOP_LEFT:
/* normal -- nothing to do */
// log_printf("inside y:%d, th:%d, ah:%d ry:%d\n", area_y, tile_h, area_h, *res_x);
}
-static void pr_coords_map_orientation_reverse(PixbufRenderer *pr,
+void pr_coords_map_orientation_reverse(gint orientation,
gint area_x, gint area_y,
gint tile_w, gint tile_h,
gint area_w, gint area_h,
*res_w = area_w;
*res_h = area_h;
- switch (pr->orientation)
+ switch (orientation)
{
case EXIF_ORIENTATION_TOP_LEFT:
/* normal -- nothing to do */
break;
case EXIF_ORIENTATION_BOTTOM_RIGHT:
/* upside down */
- *res_x = tile_w - area_x - area_w;
- *res_y = tile_h - area_y - area_h;
- break;
- case EXIF_ORIENTATION_BOTTOM_LEFT:
- /* flipped */
- *res_y = tile_h - area_y - area_h;
- break;
- case EXIF_ORIENTATION_LEFT_TOP:
- *res_x = area_y;
- *res_y = area_x;
- *res_w = area_h;
- *res_h = area_w;
- break;
- case EXIF_ORIENTATION_RIGHT_TOP:
- /* rotated -90 (270) */
- *res_x = tile_w - area_y - area_h;
- *res_y = area_x;
- *res_w = area_h;
- *res_h = area_w;
- break;
- case EXIF_ORIENTATION_RIGHT_BOTTOM:
- *res_x = tile_w - area_y - area_h;
- *res_y = tile_h - area_x - area_w;
- *res_w = area_h;
- *res_h = area_w;
- break;
- case EXIF_ORIENTATION_LEFT_BOTTOM:
- /* rotated 90 */
- *res_x = area_y;
- *res_y = tile_h - area_x - area_w;
- *res_w = area_h;
- *res_h = area_w;
- break;
- default:
- /* The other values are out of range */
- break;
- }
-}
-
-
-static GdkPixbuf *pr_get_spare_tile(PixbufRenderer *pr)
-{
- if (!pr->spare_tile) pr->spare_tile = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, pr->tile_width, pr->tile_height);
- return pr->spare_tile;
-}
-
-#define COLOR_BYTES 3 /* rgb */
-
-static void pr_tile_rotate_90_clockwise(PixbufRenderer *pr, GdkPixbuf **tile, gint x, gint y, gint w, gint h)
-{
- GdkPixbuf *src = *tile;
- GdkPixbuf *dest;
- gint srs, drs;
- guchar *s_pix, *d_pix;
- guchar *sp, *dp;
- guchar *ip, *spi, *dpi;
- gint i, j;
- gint tw = pr->tile_width;
-
- srs = gdk_pixbuf_get_rowstride(src);
- s_pix = gdk_pixbuf_get_pixels(src);
- spi = s_pix + (x * COLOR_BYTES);
-
- dest = pr_get_spare_tile(pr);
- drs = gdk_pixbuf_get_rowstride(dest);
- d_pix = gdk_pixbuf_get_pixels(dest);
- dpi = d_pix + (tw - 1) * COLOR_BYTES;
-
- for (i = y; i < y + h; i++)
- {
- sp = spi + (i * srs);
- ip = dpi - (i * COLOR_BYTES);
- for (j = x; j < x + w; j++)
- {
- dp = ip + (j * drs);
- memcpy(dp, sp, COLOR_BYTES);
- sp += COLOR_BYTES;
- }
- }
-
- pr->spare_tile = src;
- *tile = dest;
-}
-
-static void pr_tile_rotate_90_counter_clockwise(PixbufRenderer *pr, GdkPixbuf **tile, gint x, gint y, gint w, gint h)
-{
- GdkPixbuf *src = *tile;
- GdkPixbuf *dest;
- gint srs, drs;
- guchar *s_pix, *d_pix;
- guchar *sp, *dp;
- guchar *ip, *spi, *dpi;
- gint i, j;
- gint th = pr->tile_height;
-
- srs = gdk_pixbuf_get_rowstride(src);
- s_pix = gdk_pixbuf_get_pixels(src);
- spi = s_pix + (x * COLOR_BYTES);
-
- dest = pr_get_spare_tile(pr);
- drs = gdk_pixbuf_get_rowstride(dest);
- d_pix = gdk_pixbuf_get_pixels(dest);
- dpi = d_pix + (th - 1) * drs;
-
- for (i = y; i < y + h; i++)
- {
- sp = spi + (i * srs);
- ip = dpi + (i * COLOR_BYTES);
- for (j = x; j < x + w; j++)
- {
- dp = ip - (j * drs);
- memcpy(dp, sp, COLOR_BYTES);
- sp += COLOR_BYTES;
- }
- }
-
- pr->spare_tile = src;
- *tile = dest;
-}
-
-static void pr_tile_mirror_only(PixbufRenderer *pr, GdkPixbuf **tile, gint x, gint y, gint w, gint h)
-{
- GdkPixbuf *src = *tile;
- GdkPixbuf *dest;
- gint srs, drs;
- guchar *s_pix, *d_pix;
- guchar *sp, *dp;
- guchar *spi, *dpi;
- gint i, j;
-
- gint tw = pr->tile_width;
-
- srs = gdk_pixbuf_get_rowstride(src);
- s_pix = gdk_pixbuf_get_pixels(src);
- spi = s_pix + (x * COLOR_BYTES);
-
- dest = pr_get_spare_tile(pr);
- drs = gdk_pixbuf_get_rowstride(dest);
- d_pix = gdk_pixbuf_get_pixels(dest);
- dpi = d_pix + (tw - x - 1) * COLOR_BYTES;
-
- for (i = y; i < y + h; i++)
- {
- sp = spi + (i * srs);
- dp = dpi + (i * drs);
- for (j = 0; j < w; j++)
- {
- memcpy(dp, sp, COLOR_BYTES);
- sp += COLOR_BYTES;
- dp -= COLOR_BYTES;
- }
- }
-
- pr->spare_tile = src;
- *tile = dest;
-}
-
-static void pr_tile_mirror_and_flip(PixbufRenderer *pr, GdkPixbuf **tile, gint x, gint y, gint w, gint h)
-{
- GdkPixbuf *src = *tile;
- GdkPixbuf *dest;
- gint srs, drs;
- guchar *s_pix, *d_pix;
- guchar *sp, *dp;
- guchar *spi, *dpi;
- gint i, j;
- gint tw = pr->tile_width;
- gint th = pr->tile_height;
-
- srs = gdk_pixbuf_get_rowstride(src);
- s_pix = gdk_pixbuf_get_pixels(src);
- spi = s_pix + (x * COLOR_BYTES);
-
- dest = pr_get_spare_tile(pr);
- drs = gdk_pixbuf_get_rowstride(dest);
- d_pix = gdk_pixbuf_get_pixels(dest);
- dpi = d_pix + (th - 1) * drs + (tw - 1) * COLOR_BYTES;
-
- for (i = y; i < y + h; i++)
- {
- sp = s_pix + (i * srs) + (x * COLOR_BYTES);
- dp = dpi - (i * drs) - (x * COLOR_BYTES);
- for (j = 0; j < w; j++)
- {
- memcpy(dp, sp, COLOR_BYTES);
- sp += COLOR_BYTES;
- dp -= COLOR_BYTES;
- }
- }
-
- pr->spare_tile = src;
- *tile = dest;
-}
-
-static void pr_tile_flip_only(PixbufRenderer *pr, GdkPixbuf **tile, gint x, gint y, gint w, gint h)
-{
- GdkPixbuf *src = *tile;
- GdkPixbuf *dest;
- gint srs, drs;
- guchar *s_pix, *d_pix;
- guchar *sp, *dp;
- guchar *spi, *dpi;
- gint i;
- gint th = pr->tile_height;
-
- srs = gdk_pixbuf_get_rowstride(src);
- s_pix = gdk_pixbuf_get_pixels(src);
- spi = s_pix + (x * COLOR_BYTES);
-
- dest = pr_get_spare_tile(pr);
- drs = gdk_pixbuf_get_rowstride(dest);
- d_pix = gdk_pixbuf_get_pixels(dest);
- dpi = d_pix + (th - 1) * drs + (x * COLOR_BYTES);
-
- for (i = y; i < y + h; i++)
- {
- sp = spi + (i * srs);
- dp = dpi - (i * drs);
- memcpy(dp, sp, w * COLOR_BYTES);
- }
-
- pr->spare_tile = src;
- *tile = dest;
-}
-
-static void pr_tile_apply_orientation(PixbufRenderer *pr, GdkPixbuf **pixbuf, gint x, gint y, gint w, gint h)
-{
- switch (pr->orientation)
- {
- case EXIF_ORIENTATION_TOP_LEFT:
- /* normal -- nothing to do */
- break;
- case EXIF_ORIENTATION_TOP_RIGHT:
- /* mirrored */
- {
- pr_tile_mirror_only(pr, pixbuf, x, y, w, h);
- }
- break;
- case EXIF_ORIENTATION_BOTTOM_RIGHT:
- /* upside down */
- {
- pr_tile_mirror_and_flip(pr, pixbuf, x, y, w, h);
- }
- break;
- case EXIF_ORIENTATION_BOTTOM_LEFT:
- /* flipped */
- {
- pr_tile_flip_only(pr, pixbuf, x, y, w, h);
- }
- break;
- case EXIF_ORIENTATION_LEFT_TOP:
- {
- pr_tile_flip_only(pr, pixbuf, x, y, w, h);
- pr_tile_rotate_90_clockwise(pr, pixbuf, x, pr->tile_height - y - h, w, h);
- }
- break;
- case EXIF_ORIENTATION_RIGHT_TOP:
- /* rotated -90 (270) */
- {
- pr_tile_rotate_90_clockwise(pr, pixbuf, x, y, w, h);
- }
- break;
- case EXIF_ORIENTATION_RIGHT_BOTTOM:
- {
- pr_tile_flip_only(pr, pixbuf, x, y, w, h);
- pr_tile_rotate_90_counter_clockwise(pr, pixbuf, x, pr->tile_height - y - h, w, h);
- }
- break;
- case EXIF_ORIENTATION_LEFT_BOTTOM:
- /* rotated 90 */
- {
- pr_tile_rotate_90_counter_clockwise(pr, pixbuf, x, y, w, h);
- }
- break;
- default:
- /* The other values are out of range */
- break;
- }
-}
-
-
-static void pr_tile_render(PixbufRenderer *pr, ImageTile *it,
- gint x, gint y, gint w, gint h,
- gboolean new_data, gboolean fast)
-{
- GtkWidget *box;
- gboolean has_alpha;
- gboolean draw = FALSE;
-
- if (it->render_todo == TILE_RENDER_NONE && it->pixmap && !new_data) return;
-
- if (it->render_done != TILE_RENDER_ALL)
- {
- x = 0;
- y = 0;
- w = it->w;
- h = it->h;
- if (!fast) it->render_done = TILE_RENDER_ALL;
- }
- else if (it->render_todo != TILE_RENDER_AREA)
- {
- if (!fast) it->render_todo = TILE_RENDER_NONE;
- return;
- }
-
- if (!fast) it->render_todo = TILE_RENDER_NONE;
-
- if (new_data) it->blank = FALSE;
-
- pr_tile_prepare(pr, it);
- has_alpha = (pr->pixbuf && gdk_pixbuf_get_has_alpha(pr->pixbuf));
-
- box = GTK_WIDGET(pr);
-
- /* FIXME checker colors for alpha should be configurable,
- * also should be drawn for blank = TRUE
- */
-
- if (it->blank)
- {
- /* no data, do fast rect fill */
- gdk_draw_rectangle(it->pixmap, box->style->black_gc, TRUE,
- 0, 0, it->w, it->h);
- }
- else if (pr->source_tiles_enabled)
- {
- draw = pr_source_tile_render(pr, it, x, y, w, h, new_data, fast);
- }
- else if (pr->zoom == 1.0 || pr->scale == 1.0)
- {
-
- gdouble src_x, src_y;
- gint pb_x, pb_y;
- gint pb_w, pb_h;
- pr_tile_coords_map_orientation(pr, it->x, it->y,
- pr->image_width, pr->image_height,
- pr->tile_width, pr->tile_height,
- &src_x, &src_y);
- pr_tile_region_map_orientation(pr, x, y,
- pr->tile_width, pr->tile_height,
- w, h,
- &pb_x, &pb_y,
- &pb_w, &pb_h);
-
- if (has_alpha)
- {
- gdk_pixbuf_composite_color(pr->pixbuf, it->pixbuf, pb_x, pb_y, pb_w, pb_h,
- (gdouble) 0.0 - src_x,
- (gdouble) 0.0 - src_y,
- 1.0, 1.0, GDK_INTERP_NEAREST,
- 255, it->x + pb_x, it->y + pb_y,
- PR_ALPHA_CHECK_SIZE, PR_ALPHA_CHECK1, PR_ALPHA_CHECK2);
- pr_tile_apply_orientation(pr, &it->pixbuf, pb_x, pb_y, pb_w, pb_h);
- draw = TRUE;
- }
- else
- {
-
-
- if (pr->orientation == EXIF_ORIENTATION_TOP_LEFT && !(pr->func_post_process && !(pr->post_process_slow && fast)))
- {
- /* faster, simple, base orientation, no postprocessing */
- gdk_draw_pixbuf(it->pixmap,
-#if GTK_CHECK_VERSION(2,20,0)
- box->style->fg_gc[gtk_widget_get_state(box)],
-#else
- box->style->fg_gc[GTK_WIDGET_STATE(box)],
-#endif
- pr->pixbuf,
- it->x + x, it->y + y,
- x, y,
- w, h,
- pr->dither_quality, it->x + x, it->y + y);
- }
- else
- {
- gdk_pixbuf_copy_area(pr->pixbuf,
- src_x + pb_x, src_y + pb_y,
- pb_w, pb_h,
- it->pixbuf,
- pb_x, pb_y);
- pr_tile_apply_orientation(pr, &it->pixbuf, pb_x, pb_y, pb_w, pb_h);
- draw = TRUE;
- }
- }
- }
- else
- {
- gdouble scale_x, scale_y;
- gdouble src_x, src_y;
- gint pb_x, pb_y;
- gint pb_w, pb_h;
-
- if (pr->image_width == 0 || pr->image_height == 0) return;
-
- scale_x = (gdouble)pr->width / pr->image_width;
- scale_y = (gdouble)pr->height / pr->image_height;
-
- pr_tile_coords_map_orientation(pr, it->x, it->y,
- pr->image_width * scale_x, pr->image_height * scale_y,
- pr->tile_width, pr->tile_height,
- &src_x, &src_y);
- pr_tile_region_map_orientation(pr, x, y,
- pr->tile_width, pr->tile_height,
- w, h,
- &pb_x, &pb_y,
- &pb_w, &pb_h);
- switch (pr->orientation)
- {
- gdouble tmp;
- case EXIF_ORIENTATION_LEFT_TOP:
- case EXIF_ORIENTATION_RIGHT_TOP:
- case EXIF_ORIENTATION_RIGHT_BOTTOM:
- case EXIF_ORIENTATION_LEFT_BOTTOM:
- tmp = scale_x;
- scale_x = scale_y;
- scale_y = tmp;
- break;
- default:
- /* nothing to do */
- break;
- }
-
- /* HACK: The pixbuf scalers get kinda buggy(crash) with extremely
- * small sizes for anything but GDK_INTERP_NEAREST
- */
- if (pr->width < PR_MIN_SCALE_SIZE || pr->height < PR_MIN_SCALE_SIZE) fast = TRUE;
-
- if (!has_alpha)
- {
- gdk_pixbuf_scale(pr->pixbuf, it->pixbuf, pb_x, pb_y, pb_w, pb_h,
- (gdouble) 0.0 - src_x,
- (gdouble) 0.0 - src_y,
- scale_x, scale_y,
- (fast) ? GDK_INTERP_NEAREST : pr->zoom_quality);
- }
- else
- {
- gdk_pixbuf_composite_color(pr->pixbuf, it->pixbuf, pb_x, pb_y, pb_w, pb_h,
- (gdouble) 0.0 - src_x,
- (gdouble) 0.0 - src_y,
- scale_x, scale_y,
- (fast) ? GDK_INTERP_NEAREST : pr->zoom_quality,
- 255, it->x + pb_x, it->y + pb_y,
- PR_ALPHA_CHECK_SIZE, PR_ALPHA_CHECK1, PR_ALPHA_CHECK2);
- }
- pr_tile_apply_orientation(pr, &it->pixbuf, pb_x, pb_y, pb_w, pb_h);
- draw = TRUE;
- }
-
- if (draw && it->pixbuf && !it->blank)
- {
-
- if (pr->func_post_process && !(pr->post_process_slow && fast))
- pr->func_post_process(pr, &it->pixbuf, x, y, w, h, pr->post_process_user_data);
-
- gdk_draw_pixbuf(it->pixmap,
-#if GTK_CHECK_VERSION(2,20,0)
- box->style->fg_gc[gtk_widget_get_state(box)],
-#else
- box->style->fg_gc[GTK_WIDGET_STATE(box)],
-#endif
- it->pixbuf,
- x, y,
- x, y,
- w, h,
- pr->dither_quality, it->x + x, it->y + y);
- }
-
-#if 0
- /* enable this line for debugging the edges of tiles */
- gdk_draw_rectangle(it->pixmap, box->style->white_gc,
- FALSE, 0, 0, it->w, it->h);
- gdk_draw_rectangle(it->pixmap, box->style->white_gc,
- FALSE, x, y, w, h);
-#endif
-}
-
-
-static void pr_tile_expose(PixbufRenderer *pr, ImageTile *it,
- gint x, gint y, gint w, gint h,
- gboolean new_data, gboolean fast)
-{
- GtkWidget *box;
-
- pr_tile_render(pr, it, x, y, w, h, new_data, fast);
-
- box = GTK_WIDGET(pr);
-
-#if GTK_CHECK_VERSION(2,20,0)
- gdk_draw_drawable(box->window, box->style->fg_gc[gtk_widget_get_state(box)],
-#else
- gdk_draw_drawable(box->window, box->style->fg_gc[GTK_WIDGET_STATE(box)],
-#endif
- it->pixmap, x, y,
- pr->x_offset + (it->x - pr->x_scroll) + x, pr->y_offset + (it->y - pr->y_scroll) + y, w, h);
-
- if (pr->overlay_list)
- {
- pr_overlay_draw(pr, pr->x_offset + (it->x - pr->x_scroll) + x,
- pr->y_offset + (it->y - pr->y_scroll) + y,
- w, h,
- it);
- }
-}
-
-
-static gboolean pr_tile_is_visible(PixbufRenderer *pr, ImageTile *it)
-{
- return (it->x + it->w >= pr->x_scroll && it->x < pr->x_scroll + pr->vis_width &&
- it->y + it->h >= pr->y_scroll && it->y < pr->y_scroll + pr->vis_height);
-}
-
-/*
- *-------------------------------------------------------------------
- * draw queue
- *-------------------------------------------------------------------
- */
-
-static gint pr_get_queued_area(GList *work)
-{
- gint area = 0;
-
- while (work)
- {
- QueueData *qd = work->data;
- area += qd->w * qd->h;
- work = work->next;
- }
- return area;
-}
-
-
-static gboolean pr_queue_schedule_next_draw(PixbufRenderer *pr, gboolean force_set)
-{
- gfloat percent;
- gint visible_area = pr->vis_width * pr->vis_height;
-
- if (!pr->loading)
- {
- /* 2pass prio */
- DEBUG_2("redraw priority: 2pass");
- pr->draw_idle_id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, pr_queue_draw_idle_cb, pr, NULL);
- return FALSE;
- }
-
- if (visible_area == 0)
- {
- /* not known yet */
- percent = 100.0;
- }
- else
- {
- percent = 100.0 * pr_get_queued_area(pr->draw_queue) / visible_area;
- }
-
- if (percent > 10.0)
- {
- /* we have enough data for starting intensive redrawing */
- DEBUG_2("redraw priority: high %.2f %%", percent);
- pr->draw_idle_id = g_idle_add_full(GDK_PRIORITY_REDRAW, pr_queue_draw_idle_cb, pr, NULL);
- return FALSE;
- }
-
- if (percent < 1.0 || force_set)
- {
- /* queue is (almost) empty, wait 50 ms*/
- DEBUG_2("redraw priority: wait %.2f %%", percent);
- pr->draw_idle_id = g_timeout_add_full(G_PRIORITY_DEFAULT_IDLE, 50, pr_queue_draw_idle_cb, pr, NULL);
- return FALSE;
- }
-
- /* keep the same priority as before */
- DEBUG_2("redraw priority: no change %.2f %%", percent);
- return TRUE;
-}
-
-
-static gboolean pr_queue_draw_idle_cb(gpointer data)
-{
- PixbufRenderer *pr = data;
- QueueData *qd;
- gboolean fast;
-
-
- if ((!pr->pixbuf && !pr->source_tiles_enabled) ||
- (!pr->draw_queue && !pr->draw_queue_2pass) ||
- !pr->draw_idle_id)
- {
- pr_render_complete_signal(pr);
-
- pr->draw_idle_id = 0;
- return FALSE;
- }
-
- if (pr->draw_queue)
- {
- qd = pr->draw_queue->data;
- fast = (pr->zoom_2pass && ((pr->zoom_quality != GDK_INTERP_NEAREST && pr->scale != 1.0) || pr->post_process_slow));
- }
- else
- {
- if (pr->loading)
- {
- /* still loading, wait till done (also drops the higher priority) */
-
- return pr_queue_schedule_next_draw(pr, FALSE);
- }
-
- qd = pr->draw_queue_2pass->data;
- fast = FALSE;
- }
-
-#if GTK_CHECK_VERSION(2,20,0)
- if (gtk_widget_get_realized(pr))
-#else
- if (GTK_WIDGET_REALIZED(pr))
-#endif
- {
- if (pr_tile_is_visible(pr, qd->it))
- {
- pr_tile_expose(pr, qd->it, qd->x, qd->y, qd->w, qd->h, qd->new_data, fast);
- }
- else if (qd->new_data)
- {
- /* if new pixel data, and we already have a pixmap, update the tile */
- qd->it->blank = FALSE;
- if (qd->it->pixmap && qd->it->render_done == TILE_RENDER_ALL)
- {
- pr_tile_render(pr, qd->it, qd->x, qd->y, qd->w, qd->h, qd->new_data, fast);
- }
- }
- }
-
- if (pr->draw_queue)
- {
- qd->it->qd = NULL;
- pr->draw_queue = g_list_remove(pr->draw_queue, qd);
- if (fast)
- {
- if (qd->it->qd2)
- {
- pr_queue_merge(qd->it->qd2, qd);
- g_free(qd);
- }
- else
- {
- qd->it->qd2 = qd;
- pr->draw_queue_2pass = g_list_append(pr->draw_queue_2pass, qd);
- }
- }
- else
- {
- g_free(qd);
- }
- }
- else
- {
- qd->it->qd2 = NULL;
- pr->draw_queue_2pass = g_list_remove(pr->draw_queue_2pass, qd);
- g_free(qd);
- }
-
- if (!pr->draw_queue && !pr->draw_queue_2pass)
- {
- pr_render_complete_signal(pr);
-
- pr->draw_idle_id = 0;
- return FALSE;
- }
-
- return pr_queue_schedule_next_draw(pr, FALSE);
-}
-
-static void pr_queue_list_free(GList *list)
-{
- GList *work;
-
- work = list;
- while (work)
- {
- QueueData *qd;
-
- qd = work->data;
- work = work->next;
-
- qd->it->qd = NULL;
- qd->it->qd2 = NULL;
- g_free(qd);
- }
-
- g_list_free(list);
-}
-
-static void pr_queue_clear(PixbufRenderer *pr)
-{
- pr_queue_list_free(pr->draw_queue);
- pr->draw_queue = NULL;
-
- pr_queue_list_free(pr->draw_queue_2pass);
- pr->draw_queue_2pass = NULL;
-
- if (pr->draw_idle_id)
- {
- g_source_remove(pr->draw_idle_id);
- pr->draw_idle_id = 0;
- }
-}
-
-static void pr_queue_merge(QueueData *parent, QueueData *qd)
-{
- if (parent->x + parent->w < qd->x + qd->w)
- {
- parent->w += (qd->x + qd->w) - (parent->x + parent->w);
- }
- if (parent->x > qd->x)
- {
- parent->w += parent->x - qd->x;
- parent->x = qd->x;
- }
-
- if (parent->y + parent->h < qd->y + qd->h)
- {
- parent->h += (qd->y + qd->h) - (parent->y + parent->h);
- }
- if (parent->y > qd->y)
- {
- parent->h += parent->y - qd->y;
- parent->y = qd->y;
- }
-
- parent->new_data |= qd->new_data;
-}
-
-static gboolean pr_clamp_to_visible(PixbufRenderer *pr, gint *x, gint *y, gint *w, gint *h)
-{
- gint nx, ny;
- gint nw, nh;
- gint vx, vy;
- gint vw, vh;
-
- vw = pr->vis_width;
- vh = pr->vis_height;
-
- vx = pr->x_scroll;
- vy = pr->y_scroll;
-
- if (*x + *w < vx || *x > vx + vw || *y + *h < vy || *y > vy + vh) return FALSE;
-
- /* now clamp it */
- nx = CLAMP(*x, vx, vx + vw);
- nw = CLAMP(*w - (nx - *x), 1, vw);
-
- ny = CLAMP(*y, vy, vy + vh);
- nh = CLAMP(*h - (ny - *y), 1, vh);
-
- *x = nx;
- *y = ny;
- *w = nw;
- *h = nh;
-
- return TRUE;
-}
-
-static gboolean pr_queue_to_tiles(PixbufRenderer *pr, gint x, gint y, gint w, gint h,
- gboolean clamp, ImageTileRenderType render,
- gboolean new_data, gboolean only_existing)
-{
- gint i, j;
- gint x1, x2;
- gint y1, y2;
-
- if (clamp && !pr_clamp_to_visible(pr, &x, &y, &w, &h)) return FALSE;
-
- x1 = ROUND_DOWN(x, pr->tile_width);
- x2 = ROUND_UP(x + w, pr->tile_width);
-
- y1 = ROUND_DOWN(y, pr->tile_height);
- y2 = ROUND_UP(y + h, pr->tile_height);
-
- for (j = y1; j <= y2; j += pr->tile_height)
- {
- for (i = x1; i <= x2; i += pr->tile_width)
- {
- ImageTile *it;
-
- it = pr_tile_get(pr, i, j,
- (only_existing &&
- (i + pr->tile_width < pr->x_scroll ||
- i > pr->x_scroll + pr->vis_width ||
- j + pr->tile_height < pr->y_scroll ||
- j > pr->y_scroll + pr->vis_height)));
- if (it)
- {
- QueueData *qd;
-
- if ((render == TILE_RENDER_ALL && it->render_done != TILE_RENDER_ALL) ||
- (render == TILE_RENDER_AREA && it->render_todo != TILE_RENDER_ALL))
- {
- it->render_todo = render;
- }
-
- qd = g_new(QueueData, 1);
- qd->it = it;
- qd->new_data = new_data;
-
- if (i < x)
- {
- qd->x = x - i;
- }
- else
- {
- qd->x = 0;
- }
- qd->w = x + w - i - qd->x;
- if (qd->x + qd->w > pr->tile_width) qd->w = pr->tile_width - qd->x;
-
- if (j < y)
- {
- qd->y = y - j;
- }
- else
- {
- qd->y = 0;
- }
- qd->h = y + h - j - qd->y;
- if (qd->y + qd->h > pr->tile_height) qd->h = pr->tile_height - qd->y;
-
- if (qd->w < 1 || qd->h < 1)
- {
- g_free(qd);
- }
- else if (it->qd)
- {
- pr_queue_merge(it->qd, qd);
- g_free(qd);
- }
- else
- {
- it->qd = qd;
- pr->draw_queue = g_list_append(pr->draw_queue, qd);
- }
- }
- }
- }
-
- return TRUE;
-}
-
-static void pr_queue(PixbufRenderer *pr, gint x, gint y, gint w, gint h,
- gboolean clamp, ImageTileRenderType render,
- gboolean new_data, gboolean only_existing)
-{
- gint nx, ny;
-
- nx = CLAMP(x, 0, pr->width - 1);
- ny = CLAMP(y, 0, pr->height - 1);
- w -= (nx - x);
- h -= (ny - y);
- w = CLAMP(w, 0, pr->width - nx);
- h = CLAMP(h, 0, pr->height - ny);
- if (w < 1 || h < 1) return;
-
- if (pr_queue_to_tiles(pr, nx, ny, w, h, clamp, render, new_data, only_existing) &&
- ((!pr->draw_queue && !pr->draw_queue_2pass) || !pr->draw_idle_id))
- {
- if (pr->draw_idle_id)
- {
- g_source_remove(pr->draw_idle_id);
- pr->draw_idle_id = 0;
- }
- pr_queue_schedule_next_draw(pr, TRUE);
- }
-}
-
-static void pr_redraw(PixbufRenderer *pr, gboolean new_data)
-{
- pr_queue_clear(pr);
- pr_queue(pr, 0, 0, pr->width, pr->height, TRUE, TILE_RENDER_ALL, new_data, FALSE);
-}
-
-/*
- *-------------------------------------------------------------------
- * signal emission
- *-------------------------------------------------------------------
- */
-
-static void pr_update_signal(PixbufRenderer *pr)
-{
-#if 0
- log_printf("FIXME: send updated signal\n");
-#endif
- DEBUG_1("%s pixbuf renderer updated - started drawing %p", get_exec_time(), pr);
- pr->debug_updated = TRUE;
-}
-
-static void pr_zoom_signal(PixbufRenderer *pr)
-{
- g_signal_emit(pr, signals[SIGNAL_ZOOM], 0, pr->zoom);
-}
-
-static void pr_clicked_signal(PixbufRenderer *pr, GdkEventButton *bevent)
-{
- g_signal_emit(pr, signals[SIGNAL_CLICKED], 0, bevent);
-}
-
-static void pr_scroll_notify_signal(PixbufRenderer *pr)
-{
- g_signal_emit(pr, signals[SIGNAL_SCROLL_NOTIFY], 0);
-}
-
-static void pr_render_complete_signal(PixbufRenderer *pr)
-{
- if (!pr->complete)
- {
- g_signal_emit(pr, signals[SIGNAL_RENDER_COMPLETE], 0);
- g_object_set(G_OBJECT(pr), "complete", TRUE, NULL);
- }
- if (pr->debug_updated)
- {
- DEBUG_1("%s pixbuf renderer done %p", get_exec_time(), pr);
- pr->debug_updated = FALSE;
+ *res_x = tile_w - area_x - area_w;
+ *res_y = tile_h - area_y - area_h;
+ break;
+ case EXIF_ORIENTATION_BOTTOM_LEFT:
+ /* flipped */
+ *res_y = tile_h - area_y - area_h;
+ break;
+ case EXIF_ORIENTATION_LEFT_TOP:
+ *res_x = area_y;
+ *res_y = area_x;
+ *res_w = area_h;
+ *res_h = area_w;
+ break;
+ case EXIF_ORIENTATION_RIGHT_TOP:
+ /* rotated -90 (270) */
+ *res_x = tile_w - area_y - area_h;
+ *res_y = area_x;
+ *res_w = area_h;
+ *res_h = area_w;
+ break;
+ case EXIF_ORIENTATION_RIGHT_BOTTOM:
+ *res_x = tile_w - area_y - area_h;
+ *res_y = tile_h - area_x - area_w;
+ *res_w = area_h;
+ *res_h = area_w;
+ break;
+ case EXIF_ORIENTATION_LEFT_BOTTOM:
+ /* rotated 90 */
+ *res_x = area_y;
+ *res_y = tile_h - area_x - area_w;
+ *res_w = area_h;
+ *res_h = area_w;
+ break;
+ default:
+ /* The other values are out of range */
+ break;
}
}
-static void pr_drag_signal(PixbufRenderer *pr, GdkEventButton *bevent)
-{
- g_signal_emit(pr, signals[SIGNAL_DRAG], 0, bevent);
-}
-
-static void pr_update_pixel_signal(PixbufRenderer *pr)
-{
- g_signal_emit(pr, signals[SIGNAL_UPDATE_PIXEL], 0);
-}
-/*
- *-------------------------------------------------------------------
- * sync and clamp
- *-------------------------------------------------------------------
- */
static void pixbuf_renderer_sync_scroll_center(PixbufRenderer *pr)
{
* of the "broken image" icon.
*/
- if (pr->width > pr->window_width)
+ if (pr->width > pr->viewport_width)
{
src_x = pr->x_scroll + pr->vis_width / 2;
pr->norm_center_x = (gdouble)src_x / pr->width;
}
- if (pr->height > pr->window_height)
+ if (pr->height > pr->viewport_height)
{
src_y = pr->y_scroll + pr->vis_height / 2;
pr->norm_center_y = (gdouble)src_y / pr->height;
old_vw = pr->vis_width;
old_vh = pr->vis_height;
- if (pr->width < pr->window_width)
+ if (pr->width < pr->viewport_width)
{
pr->vis_width = pr->width;
- pr->x_offset = (pr->window_width - pr->width) / 2;
+ pr->x_offset = (pr->viewport_width - pr->width) / 2;
}
else
{
- pr->vis_width = pr->window_width;
+ pr->vis_width = pr->viewport_width;
pr->x_offset = 0;
}
- if (pr->height < pr->window_height)
+ if (pr->height < pr->viewport_height)
{
pr->vis_height = pr->height;
- pr->y_offset = (pr->window_height - pr->height) / 2;
+ pr->y_offset = (pr->viewport_height - pr->height) / 2;
}
else
{
- pr->vis_height = pr->window_height;
+ pr->vis_height = pr->viewport_height;
pr->y_offset = 0;
}
}
else
{
- max_w = pr->window_width;
- max_h = pr->window_height;
+ max_w = pr->viewport_width;
+ max_h = pr->viewport_height;
}
if ((pr->zoom_expand && !sizeable) || w > max_w || h > max_h)
{
- if ((gdouble)max_w / w > (gdouble)max_h / h)
+ if ((gdouble)max_w / w > (gdouble)max_h / h / pr->aspect_ratio)
{
- scale = (gdouble)max_h / h;
+ scale = (gdouble)max_h / h / pr->aspect_ratio;
h = max_h;
w = w * scale + 0.5;
if (w > max_w) w = max_w;
{
scale = (gdouble)max_w / w;
w = max_w;
- h = h * scale + 0.5;
+ h = h * scale * pr->aspect_ratio + 0.5;
if (h > max_h) h = max_h;
}
{
scale = zoom;
w = w * scale;
- h = h * scale;
+ h = h * scale * pr->aspect_ratio;
}
else /* zoom out */
{
scale = 1.0 / (0.0 - zoom);
w = w * scale;
- h = h * scale;
+ h = h * scale * pr->aspect_ratio;
}
invalid = (pr->width != w || pr->height != h);
if (invalidate || invalid)
{
- pr_tile_invalidate_all(pr);
+ pr->renderer->invalidate_all(pr->renderer);
+ if (pr->renderer2) pr->renderer2->invalidate_all(pr->renderer2);
if (!lazy) pr_redraw(pr, TRUE);
}
if (redrawn) *redrawn = (invalidate || invalid);
case PR_SCROLL_RESET_NOCHANGE:
/* maintain old scroll position */
pr->x_scroll = ((gdouble)pr->image_width * old_center_x * pr->scale) - pr->vis_width / 2;
- pr->y_scroll = ((gdouble)pr->image_height * old_center_y * pr->scale) - pr->vis_height / 2;
+ pr->y_scroll = ((gdouble)pr->image_height * old_center_y * pr->scale * pr->aspect_ratio) - pr->vis_height / 2;
break;
case PR_SCROLL_RESET_CENTER:
/* center new image */
pr->x_scroll = ((gdouble)pr->image_width / 2.0 * pr->scale) - pr->vis_width / 2;
- pr->y_scroll = ((gdouble)pr->image_height / 2.0 * pr->scale) - pr->vis_height / 2;
+ pr->y_scroll = ((gdouble)pr->image_height / 2.0 * pr->scale * pr->aspect_ratio) - pr->vis_height / 2;
break;
case PR_SCROLL_RESET_TOPLEFT:
default:
if (center_point)
{
pr->x_scroll = old_cx / old_scale * pr->scale - (px - pr->x_offset);
- pr->y_scroll = old_cy / old_scale * pr->scale - (py - pr->y_offset);
+ pr->y_scroll = old_cy / old_scale * pr->scale * pr->aspect_ratio - (py - pr->y_offset);
}
else
{
pr->x_scroll = old_cx / old_scale * pr->scale - (pr->vis_width / 2);
- pr->y_scroll = old_cy / old_scale * pr->scale - (pr->vis_height / 2);
+ pr->y_scroll = old_cy / old_scale * pr->scale * pr->aspect_ratio - (pr->vis_height / 2);
}
}
if (lazy)
{
- pr_queue_clear(pr);
+ pr->renderer->queue_clear(pr->renderer);
+ if (pr->renderer2) pr->renderer2->queue_clear(pr->renderer2);
}
else
{
{
gboolean zoom_changed = FALSE;
- if (pr->window_width == new_width && pr->window_height == new_height) return;
+ gint new_viewport_width = new_width;
+ gint new_viewport_height = new_height;
+
+ if (!pr->stereo_temp_disable)
+ {
+ if (pr->stereo_mode & PR_STEREO_HORIZ)
+ {
+ new_viewport_width = new_width / 2;
+ }
+ else if (pr->stereo_mode & PR_STEREO_VERT)
+ {
+ new_viewport_height = new_height / 2;
+ }
+ else if (pr->stereo_mode & PR_STEREO_FIXED)
+ {
+ new_viewport_width = pr->stereo_fixed_width;
+ new_viewport_height = pr->stereo_fixed_height;
+ }
+ }
+
+ if (pr->window_width == new_width && pr->window_height == new_height &&
+ pr->viewport_width == new_viewport_width && pr->viewport_height == new_viewport_height) return;
pr->window_width = new_width;
pr->window_height = new_height;
+ pr->viewport_width = new_viewport_width;
+ pr->viewport_height = new_viewport_height;
if (pr->zoom == 0.0)
{
pr_size_clamp(pr);
pr_scroll_clamp(pr);
- pr_overlay_update_sizes(pr);
+ pr->renderer->update_sizes(pr->renderer);
+ if (pr->renderer2) pr->renderer2->update_sizes(pr->renderer2);
/* ensure scroller remains visible */
if (pr->scroller_overlay != -1)
{
gint x, y;
- pr_border_draw(pr, area->x, area->y, area->width, area->height);
-
- x = MAX(0, (gint)area->x - pr->x_offset + pr->x_scroll);
- y = MAX(0, (gint)area->y - pr->y_offset + pr->y_scroll);
-
- pr_queue(pr, x, y,
- MIN((gint)area->width, pr->width - x),
- MIN((gint)area->height, pr->height - y),
- FALSE, TILE_RENDER_ALL, FALSE, FALSE);
+ pr->renderer->redraw(pr->renderer, area->x, area->y, area->width, area->height,
+ FALSE, TILE_RENDER_ALL, FALSE, FALSE);
+ if (pr->renderer2)
+ {
+ pr->renderer2->redraw(pr->renderer2, area->x, area->y, area->width, area->height,
+ FALSE, TILE_RENDER_ALL, FALSE, FALSE);
+ }
}
/*
{
gint old_x, old_y;
gint x_off, y_off;
- gint w, h;
g_return_if_fail(IS_PIXBUF_RENDERER(pr));
x_off = pr->x_scroll - old_x;
y_off = pr->y_scroll - old_y;
-
- w = pr->vis_width - abs(x_off);
- h = pr->vis_height - abs(y_off);
-
- if (w < 1 || h < 1)
- {
- /* scrolled completely to new material */
- pr_queue(pr, 0, 0, pr->width, pr->height, TRUE, TILE_RENDER_ALL, FALSE, FALSE);
- return;
- }
- else
- {
- gint x1, y1;
- gint x2, y2;
- GtkWidget *box;
- GdkGC *gc;
- GdkEvent *event;
-
- if (x_off < 0)
- {
- x1 = abs(x_off);
- x2 = 0;
- }
- else
- {
- x1 = 0;
- x2 = abs(x_off);
- }
-
- if (y_off < 0)
- {
- y1 = abs(y_off);
- y2 = 0;
- }
- else
- {
- y1 = 0;
- y2 = abs(y_off);
- }
-
- box = GTK_WIDGET(pr);
-
- gc = gdk_gc_new(box->window);
- gdk_gc_set_exposures(gc, TRUE);
- gdk_draw_drawable(box->window, gc,
- box->window,
- x2 + pr->x_offset, y2 + pr->y_offset,
- x1 + pr->x_offset, y1 + pr->y_offset, w, h);
- g_object_unref(gc);
-
- if (pr->overlay_list)
- {
- pr_overlay_queue_all(pr);
- }
-
- w = pr->vis_width - w;
- h = pr->vis_height - h;
-
- if (w > 0)
- {
- pr_queue(pr,
- x_off > 0 ? pr->x_scroll + (pr->vis_width - w) : pr->x_scroll, pr->y_scroll,
- w, pr->vis_height, TRUE, TILE_RENDER_ALL, FALSE, FALSE);
- }
- if (h > 0)
- {
- /* FIXME, to optimize this, remove overlap */
- pr_queue(pr,
- pr->x_scroll, y_off > 0 ? pr->y_scroll + (pr->vis_height - h) : pr->y_scroll,
- pr->vis_width, h, TRUE, TILE_RENDER_ALL, FALSE, FALSE);
- }
-
- /* process exposures here, "expose_event" seems to miss a few with obstructed windows */
-#if ! GTK_CHECK_VERSION(2,18,0)
- while ((event = gdk_event_get_graphics_expose(box->window)) != NULL)
- {
- pixbuf_renderer_paint(pr, &event->expose.area);
-
- if (event->expose.count == 0)
- {
- gdk_event_free(event);
- break;
- }
- gdk_event_free(event);
- }
-#endif
- }
+
+ pr->renderer->scroll(pr->renderer, x_off, y_off);
+ if (pr->renderer2) pr->renderer2->scroll(pr->renderer2, x_off, y_off);
}
void pixbuf_renderer_scroll_to_point(PixbufRenderer *pr, gint x, gint y,
ay = (gdouble)pr->vis_height * y_align;
px = (gdouble)x * pr->scale - (pr->x_scroll + ax);
- py = (gdouble)y * pr->scale - (pr->y_scroll + ay);
+ py = (gdouble)y * pr->scale * pr->aspect_ratio - (pr->y_scroll + ay);
pixbuf_renderer_scroll(pr, px, py);
}
}
#if GTK_CHECK_VERSION(2,20,0)
- if (gdk_pointer_is_grabbed() && gtk_widget_has_grab(pr))
+ if (gdk_pointer_is_grabbed() && gtk_widget_has_grab(GTK_WIDGET(pr)))
#else
if (gdk_pointer_is_grabbed() && GTK_WIDGET_HAS_GRAB(pr))
#endif
G_CALLBACK(pr_mouse_release_cb), pr);
g_signal_connect(G_OBJECT(pr), "leave_notify_event",
G_CALLBACK(pr_mouse_leave_cb), pr);
- g_signal_connect(G_OBJECT(pr), "hierarchy-changed",
- G_CALLBACK(pr_hierarchy_changed_cb), pr);
g_signal_connect(G_OBJECT(pr), "leave_notify_event",
G_CALLBACK(pr_leave_notify_cb), pr);
}
+/*
+ *-------------------------------------------------------------------
+ * stereo support
+ *-------------------------------------------------------------------
+ */
+
+#define COLOR_BYTES 3 /* rgb */
+static void pr_create_anaglyph_RC(GdkPixbuf *pixbuf, GdkPixbuf *right, gint x, gint y, gint w, gint h)
+{
+ gint srs, drs;
+ guchar *s_pix, *d_pix;
+ guchar *sp, *dp;
+ guchar *spi, *dpi;
+ gint i, j;
+
+ srs = gdk_pixbuf_get_rowstride(right);
+ s_pix = gdk_pixbuf_get_pixels(right);
+ spi = s_pix + (x * COLOR_BYTES);
+
+ drs = gdk_pixbuf_get_rowstride(pixbuf);
+ d_pix = gdk_pixbuf_get_pixels(pixbuf);
+ dpi = d_pix + x * COLOR_BYTES;
+
+ for (i = y; i < y + h; i++)
+ {
+ sp = spi + (i * srs);
+ dp = dpi + (i * drs);
+ for (j = 0; j < w; j++)
+ {
+ *dp = *sp; /* copy red channel */
+ sp += COLOR_BYTES;
+ dp += COLOR_BYTES;
+ }
+ }
+}
+
+static void pr_create_anaglyph_gray(GdkPixbuf *pixbuf, GdkPixbuf *right, gint x, gint y, gint w, gint h)
+{
+ gint srs, drs;
+ guchar *s_pix, *d_pix;
+ guchar *sp, *dp;
+ guchar *spi, *dpi;
+ gint i, j;
+ const double gc[3] = {0.299, 0.587, 0.114};
+
+ srs = gdk_pixbuf_get_rowstride(right);
+ s_pix = gdk_pixbuf_get_pixels(right);
+ spi = s_pix + (x * COLOR_BYTES);
+
+ drs = gdk_pixbuf_get_rowstride(pixbuf);
+ d_pix = gdk_pixbuf_get_pixels(pixbuf);
+ dpi = d_pix + x * COLOR_BYTES;
+
+ for (i = y; i < y + h; i++)
+ {
+ sp = spi + (i * srs);
+ dp = dpi + (i * drs);
+ for (j = 0; j < w; j++)
+ {
+ guchar g1 = dp[0] * gc[0] + dp[1] * gc[1] + dp[2] * gc[2];
+ guchar g2 = sp[0] * gc[0] + sp[1] * gc[1] + sp[2] * gc[2];
+ dp[0] = g2; /* red channel from sp */
+ dp[1] = g1; /* green and blue from dp */
+ dp[2] = g1;
+ sp += COLOR_BYTES;
+ dp += COLOR_BYTES;
+ }
+ }
+}
+
+const double pr_dubois_matrix[3][6] = {
+ { 0.456, 0.500, 0.176, -0.043, -0.088, -0.002},
+ {-0.040, -0.038, -0.016, 0.378, 0.734, -0.018},
+ {-0.015, -0.021, -0.005, -0.072, -0.113, 1.226}
+ };
+
+static void pr_create_anaglyph_dubois(GdkPixbuf *pixbuf, GdkPixbuf *right, gint x, gint y, gint w, gint h)
+{
+ gint srs, drs;
+ guchar *s_pix, *d_pix;
+ guchar *sp, *dp;
+ guchar *spi, *dpi;
+ gint i, j, k;
+
+ srs = gdk_pixbuf_get_rowstride(right);
+ s_pix = gdk_pixbuf_get_pixels(right);
+ spi = s_pix + (x * COLOR_BYTES);
+
+ drs = gdk_pixbuf_get_rowstride(pixbuf);
+ d_pix = gdk_pixbuf_get_pixels(pixbuf);
+ dpi = d_pix + x * COLOR_BYTES;
+
+ for (i = y; i < y + h; i++)
+ {
+ sp = spi + (i * srs);
+ dp = dpi + (i * drs);
+ for (j = 0; j < w; j++)
+ {
+ double res[3];
+ for (k = 0; k < 3; k++)
+ {
+ double *m = pr_dubois_matrix[k];
+ res[k] = sp[0] * m[0] + sp[1] * m[1] + sp[2] * m[2] + dp[0] * m[3] + dp[1] * m[4] + dp[2] * m[5];
+ if (res[k] < 0.0) res[k] = 0;
+ if (res[k] > 255.0) res[k] = 255.0;
+ }
+ dp[0] = res[0];
+ dp[1] = res[1];
+ dp[2] = res[2];
+ sp += COLOR_BYTES;
+ dp += COLOR_BYTES;
+ }
+ }
+}
+
+void pr_create_anaglyph(guint mode, GdkPixbuf *pixbuf, GdkPixbuf *right, gint x, gint y, gint w, gint h)
+{
+ if (mode & PR_STEREO_ANAGLYPH_RC)
+ pr_create_anaglyph_RC(pixbuf, right, x, y, w, h);
+ else if (mode & PR_STEREO_ANAGLYPH_GRAY)
+ pr_create_anaglyph_gray(pixbuf, right, x, y, w, h);
+ else if (mode & PR_STEREO_ANAGLYPH_DB)
+ pr_create_anaglyph_dubois(pixbuf, right, x, y, w, h);
+}
+
/*
*-------------------------------------------------------------------
* public
*/
static void pr_pixbuf_size_sync(PixbufRenderer *pr)
{
+ pr->stereo_pixbuf_offset_left = 0;
+ pr->stereo_pixbuf_offset_right = 0;
if (!pr->pixbuf) return;
switch (pr->orientation)
{
case EXIF_ORIENTATION_LEFT_BOTTOM:
pr->image_width = gdk_pixbuf_get_height(pr->pixbuf);
pr->image_height = gdk_pixbuf_get_width(pr->pixbuf);
+ if (pr->stereo_data == STEREO_PIXBUF_SBS)
+ {
+ pr->image_height /= 2;
+ pr->stereo_pixbuf_offset_right = pr->image_height;
+ }
+ else if (pr->stereo_data == STEREO_PIXBUF_CROSS)
+ {
+ pr->image_height /= 2;
+ pr->stereo_pixbuf_offset_left = pr->image_height;
+ }
+
break;
default:
pr->image_width = gdk_pixbuf_get_width(pr->pixbuf);
pr->image_height = gdk_pixbuf_get_height(pr->pixbuf);
+ if (pr->stereo_data == STEREO_PIXBUF_SBS)
+ {
+ pr->image_width /= 2;
+ pr->stereo_pixbuf_offset_right = pr->image_width;
+ }
+ else if (pr->stereo_data == STEREO_PIXBUF_CROSS)
+ {
+ pr->image_width /= 2;
+ pr->stereo_pixbuf_offset_left = pr->image_width;
+ }
}
}
#endif
{
gdk_window_clear(box->window);
- pr_overlay_draw(pr, 0, 0, pr->window_width, pr->window_height, NULL);
+ pr->renderer->overlay_draw(pr->renderer, 0, 0, pr->viewport_width, pr->viewport_height);
+ if (pr->renderer2) pr->renderer2->overlay_draw(pr->renderer2, 0, 0, pr->viewport_width, pr->viewport_height);
}
pr_update_signal(pr);
return;
}
+ if (pr->stereo_mode & PR_STEREO_TEMP_DISABLE)
+ {
+ gint disable = !pr->pixbuf || ! pr->stereo_data;
+ pr_stereo_temp_disable(pr, disable);
+ }
+
pr_pixbuf_size_sync(pr);
pr_zoom_sync(pr, zoom, flags | PR_ZOOM_FORCE | PR_ZOOM_NEW, 0, 0);
}
pr_update_signal(pr);
}
-void pixbuf_renderer_set_pixbuf_lazy(PixbufRenderer *pr, GdkPixbuf *pixbuf, gdouble zoom, gint orientation)
+void pixbuf_renderer_set_pixbuf_lazy(PixbufRenderer *pr, GdkPixbuf *pixbuf, gdouble zoom, gint orientation, StereoPixbufData stereo_data)
{
g_return_if_fail(IS_PIXBUF_RENDERER(pr));
pr_source_tile_unset(pr);
pr->orientation = orientation;
+ pr->stereo_data = stereo_data;
pr_set_pixbuf(pr, pixbuf, zoom, PR_ZOOM_LAZY);
pr_update_signal(pr);
return pr->orientation;
}
+void pixbuf_renderer_set_stereo_data(PixbufRenderer *pr, StereoPixbufData stereo_data)
+{
+ g_return_if_fail(IS_PIXBUF_RENDERER(pr));
+
+ pr->stereo_data = stereo_data;
+
+ if (pr->stereo_mode & PR_STEREO_TEMP_DISABLE)
+ {
+ gint disable = !pr->pixbuf || ! pr->stereo_data;
+ pr_stereo_temp_disable(pr, disable);
+ }
+ pr_pixbuf_size_sync(pr);
+ pr_zoom_sync(pr, pr->zoom, PR_ZOOM_FORCE, 0, 0);
+}
+
void pixbuf_renderer_set_post_process_func(PixbufRenderer *pr, PixbufRendererPostProcessFunc func, gpointer user_data, gboolean slow)
{
g_return_if_fail(IS_PIXBUF_RENDERER(pr));
pr->post_process_user_data = source->post_process_user_data;
pr->post_process_slow = source->post_process_slow;
pr->orientation = source->orientation;
+ pr->stereo_data = source->stereo_data;
if (source->source_tiles_enabled)
{
pr->scroll_reset = scroll_reset;
pixbuf_renderer_set_pixbuf(source, NULL, source->zoom);
- pr_queue_clear(source);
- pr_tile_free_all(source);
+// pr_queue_clear(source);
+// pr_tile_free_all(source);
}
-void pixbuf_renderer_area_changed(PixbufRenderer *pr, gint src_x, gint src_y, gint src_w, gint src_h)
+void pixbuf_renderer_area_changed(PixbufRenderer *pr, gint x, gint y, gint w, gint h)
{
- gint x, y, width, height, x1, y1, x2, y2;
-
g_return_if_fail(IS_PIXBUF_RENDERER(pr));
- pr_coords_map_orientation_reverse(pr,
- src_x, src_y,
- pr->image_width, pr->image_height,
- src_w, src_h,
- &x, &y,
- &width, &height);
-
if (pr->source_tiles_enabled)
{
- pr_source_tile_changed(pr, x, y, width, height);
- }
-
- if (pr->scale != 1.0 && pr->zoom_quality != GDK_INTERP_NEAREST)
- {
- /* increase region when using a zoom quality that may access surrounding pixels */
- y -= 1;
- height += 2;
+ pr_source_tile_changed(pr, x, y, w, h);
}
- x1 = (gint)floor((gdouble)x * pr->scale);
- y1 = (gint)floor((gdouble)y * pr->scale);
- x2 = (gint)ceil((gdouble)(x + width) * pr->scale);
- y2 = (gint)ceil((gdouble)(y + height) * pr->scale);
-
- pr_queue(pr, x1, y1, x2 - x1, y2 - y1, FALSE, TILE_RENDER_AREA, TRUE, TRUE);
+ pr->renderer->area_changed(pr->renderer, x, y, w, h);
+ if (pr->renderer2) pr->renderer2->area_changed(pr->renderer2, x, y, w, h);
}
void pixbuf_renderer_zoom_adjust(PixbufRenderer *pr, gdouble increment)
}
}
+static void pr_stereo_set(PixbufRenderer *pr)
+{
+ if (!pr->renderer) pr->renderer = (void *)renderer_tiles_new(pr);
+
+ pr->renderer->stereo_set(pr->renderer, pr->stereo_mode & ~PR_STEREO_MIRROR_RIGHT & ~PR_STEREO_FLIP_RIGHT);
+
+ if (pr->stereo_mode & (PR_STEREO_HORIZ | PR_STEREO_VERT | PR_STEREO_FIXED))
+ {
+ if (!pr->renderer2) pr->renderer2 = (void *)renderer_tiles_new(pr);
+ pr->renderer2->stereo_set(pr->renderer2, (pr->stereo_mode & ~PR_STEREO_MIRROR_LEFT & ~PR_STEREO_FLIP_LEFT) | PR_STEREO_RIGHT);
+ }
+ else
+ {
+ if (pr->renderer2) pr->renderer2->free(pr->renderer2);
+ pr->renderer2 = NULL;
+ }
+ if (pr->stereo_mode & PR_STEREO_HALF)
+ {
+ if (pr->stereo_mode & PR_STEREO_HORIZ) pr->aspect_ratio = 2.0;
+ else if (pr->stereo_mode & PR_STEREO_VERT) pr->aspect_ratio = 0.5;
+ else pr->aspect_ratio = 1.0;
+ }
+ else
+ {
+ pr->aspect_ratio = 1.0;
+ }
+}
+
+void pixbuf_renderer_stereo_set(PixbufRenderer *pr, gint stereo_mode)
+{
+ gboolean redraw = !(pr->stereo_mode == stereo_mode) || pr->stereo_temp_disable;
+ pr->stereo_mode = stereo_mode;
+ if ((stereo_mode & PR_STEREO_TEMP_DISABLE) && pr->stereo_temp_disable) return;
+
+ pr->stereo_temp_disable = FALSE;
+
+ pr_stereo_set(pr);
+
+ if (redraw)
+ {
+ pr_size_sync(pr, pr->window_width, pr->window_height); /* recalculate new viewport */
+ pr_zoom_sync(pr, pr->zoom, PR_ZOOM_FORCE | PR_ZOOM_NEW, 0, 0);
+ }
+}
+
+void pixbuf_renderer_stereo_fixed_set(PixbufRenderer *pr, gint width, gint height, gint x1, gint y1, gint x2, gint y2)
+{
+ pr->stereo_fixed_width = width;
+ pr->stereo_fixed_height = height;
+ pr->stereo_fixed_x_left = x1;
+ pr->stereo_fixed_y_left = y1;
+ pr->stereo_fixed_x_right = x2;
+ pr->stereo_fixed_y_right = y2;
+}
+
+gint pixbuf_renderer_stereo_get(PixbufRenderer *pr)
+{
+ return pr->stereo_mode;
+}
+
+static void pr_stereo_temp_disable(PixbufRenderer *pr, gboolean disable)
+{
+ if (pr->stereo_temp_disable == disable) return;
+ pr->stereo_temp_disable = disable;
+ if (disable)
+ {
+ if (!pr->renderer) pr->renderer = (void *)renderer_tiles_new(pr);
+ pr->renderer->stereo_set(pr->renderer, PR_STEREO_NONE);
+ if (pr->renderer2) pr->renderer2->free(pr->renderer2);
+ pr->renderer2 = NULL;
+ pr->aspect_ratio = 1.0;
+ }
+ else
+ {
+ pr_stereo_set(pr);
+ }
+ pr_size_sync(pr, pr->window_width, pr->window_height); /* recalculate new viewport */
+}
+
gboolean pixbuf_renderer_get_pixel_colors(PixbufRenderer *pr, gint x_pixel, gint y_pixel,
gint *r_mouse, gint *g_mouse, gint *b_mouse)
{
if (!pb) return FALSE;
- pr_tile_region_map_orientation(pr,
+ pr_tile_region_map_orientation(pr->orientation,
x_pixel, y_pixel,
pr->image_width, pr->image_height,
1, 1, /*single pixel */
}
x_pixel = floor((gdouble)(pr->x_mouse - pr->x_offset + pr->x_scroll) / pr->scale);
- y_pixel = floor((gdouble)(pr->y_mouse - pr->y_offset + pr->y_scroll) / pr->scale);
+ y_pixel = floor((gdouble)(pr->y_mouse - pr->y_offset + pr->y_scroll) / pr->scale / pr->aspect_ratio);
x_pixel_clamped = CLAMP(x_pixel, 0, pr->image_width - 1);
y_pixel_clamped = CLAMP(y_pixel, 0, pr->image_height - 1);
g_return_val_if_fail(IS_PIXBUF_RENDERER(pr), FALSE);
g_return_val_if_fail(width != NULL && height != NULL, FALSE);
- if (!pr->pixbuf && !pr->source_tiles_enabled)
+ if (!pr->pixbuf && !pr->source_tiles_enabled && (!pr->image_width || !pr->image_height))
{
*width = 0;
*height = 0;
g_return_val_if_fail(IS_PIXBUF_RENDERER(pr), FALSE);
g_return_val_if_fail(width != NULL && height != NULL, FALSE);
- if (!pr->pixbuf && !pr->source_tiles_enabled)
+ if (!pr->pixbuf && !pr->source_tiles_enabled && (!pr->image_width || !pr->image_height))
{
*width = 0;
*height = 0;
}
rect->x = (gint)((gdouble)pr->x_scroll / pr->scale);
- rect->y = (gint)((gdouble)pr->y_scroll / pr->scale);
+ rect->y = (gint)((gdouble)pr->y_scroll / pr->scale / pr->aspect_ratio);
rect->width = (gint)((gdouble)pr->vis_width / pr->scale);
- rect->height = (gint)((gdouble)pr->vis_height / pr->scale);
+ rect->height = (gint)((gdouble)pr->vis_height / pr->scale / pr->aspect_ratio);
return TRUE;
}
rect->height = pr->vis_height;
return TRUE;
}
+
+void pixbuf_renderer_set_size_early(PixbufRenderer *pr, guint width, guint height)
+{
+ gdouble zoom;
+ gint w, h;
+
+ zoom = pixbuf_renderer_zoom_get(pr);
+ pr->image_width = width;
+ pr->image_height = height;
+
+ pr_zoom_clamp(pr, zoom, PR_ZOOM_FORCE, NULL);
+
+ //w = width;
+ //h = height;
+
+ //pr->width = width;
+ //pr->height = height;
+}
+
/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
#define IS_PIXBUF_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), TYPE_PIXBUF_RENDERER))
#define PIXBUF_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), TYPE_PIXBUF_RENDERER, PixbufRendererClass))
+/* alpha channel checkerboard background (same as gimp) */
+#define PR_ALPHA_CHECK1 0x00999999
+#define PR_ALPHA_CHECK2 0x00666666
+#define PR_ALPHA_CHECK_SIZE 16
+/* when scaling image to below this size, use nearest pixel for scaling
+ * (below about 4, the other scale types become slow generating their conversion tables)
+ */
+#define PR_MIN_SCALE_SIZE 8
+
+/* default size of tile cache (mb) */
+#define PR_CACHE_SIZE_DEFAULT 8
+
+/* round A up/down to integer count of B */
+#define ROUND_UP(A,B) ((gint)(((A)+(B)-1)/(B))*(B))
+#define ROUND_DOWN(A,B) ((gint)(((A))/(B))*(B))
+
+
+typedef struct _RendererFuncs RendererFuncs;
typedef struct _PixbufRenderer PixbufRenderer;
typedef struct _PixbufRendererClass PixbufRendererClass;
PR_SCROLL_RESET_COUNT,
} PixbufRendererScrollResetType;
+typedef enum {
+ TILE_RENDER_NONE = 0, /* do nothing */
+ TILE_RENDER_AREA, /* render an area of the tile */
+ TILE_RENDER_ALL /* render the whole tile */
+} ImageRenderType;
+
+typedef enum {
+ OVL_NORMAL = 0,
+ OVL_RELATIVE = 1 << 0, /* x,y coordinates are relative, negative values start bottom right */
+ /* OVL_HIDE_ON_SCROLL = 1 << 1*/ /* hide temporarily when scrolling (not yet implemented) */
+} OverlayRendererFlags;
+
+struct _RendererFuncs
+{
+ void (*redraw)(void *renderer, gint x, gint y, gint w, gint h,
+ gint clamp, ImageRenderType render, gboolean new_data, gboolean only_existing);
+ void (*area_changed)(void *renderer, gint src_x, gint src_y, gint src_w, gint src_h);
+ void (*queue_clear)(void *renderer);
+ void (*border_clear)(void *renderer);
+ void (*invalidate_all)(void *renderer);
+ void (*invalidate_region)(void *renderer, gint x, gint y, gint w, gint h);
+ void (*scroll)(void *renderer, gint x_off, gint y_off);
+ void (*update_sizes)(void *renderer);
+
+ gint (*overlay_add)(void *renderer, GdkPixbuf *pixbuf, gint x, gint y, OverlayRendererFlags flags);
+ void (*overlay_set)(void *renderer, gint id, GdkPixbuf *pixbuf, gint x, gint y);
+ gboolean (*overlay_get)(void *renderer, gint id, GdkPixbuf **pixbuf, gint *x, gint *y);
+ void (*overlay_draw)(void *renderer, gint x, gint y, gint w, gint h);
+
+ void (*stereo_set)(void *renderer, gint stereo_mode);
+
+ void (*free)(void *renderer);
+};
+
struct _PixbufRenderer
{
GtkEventBox eventbox;
gint image_width; /* image actual dimensions (pixels) */
gint image_height;
+ gint stereo_pixbuf_offset_right; /* offset of the right part of the stereo image in pixbuf */
+ gint stereo_pixbuf_offset_left; /* offset of the left part of the stereo image in pixbuf */
GdkPixbuf *pixbuf;
gint window_width; /* allocated size of window (drawing area) */
gint window_height;
- gint x_offset; /* offset of image start (non-zero when image < window) */
+ gint viewport_width; /* allocated size of viewport (same as window for normal mode, half of window for SBS mode) */
+ gint viewport_height;
+
+ gint x_offset; /* offset of image start (non-zero when viewport < window) */
gint y_offset;
gint x_mouse; /* coordinates of the mouse taken from GtkEvent */
gdouble zoom; /* zoom we want (0 is auto) */
gdouble scale; /* zoom we got (should never be 0) */
+ gdouble aspect_ratio; /* screen pixel aspect ratio (2.0 for 3DTV SBS mode) */
+
GdkInterpType zoom_quality;
gboolean zoom_2pass;
gboolean zoom_expand;
gint autofit_limit_size;
- gint tile_cache_max; /* max mb to use for offscreen buffer */
/*< private >*/
-
- gint tile_width;
- gint tile_height;
- gint tile_cols; /* count of tile columns */
- GList *tiles; /* list of buffer tiles */
- gint tile_cache_size; /* allocated size of pixmaps/pixbufs */
- GList *draw_queue; /* list of areas to redraw */
- GList *draw_queue_2pass;/* list when 2 pass is enabled */
-
- guint draw_idle_id; /* event source id */
-
gboolean in_drag;
gint drag_last_x;
gint drag_last_y;
gint scroller_xinc;
gint scroller_yinc;
- GList *overlay_list;
- GdkPixmap *overlay_buffer;
-
- GdkPixbuf *spare_tile;
-
gint orientation;
+
+ gint stereo_mode;
+
+ StereoPixbufData stereo_data;
+ gboolean stereo_temp_disable;
+ gint stereo_fixed_width;
+ gint stereo_fixed_height;
+ gint stereo_fixed_x_left;
+ gint stereo_fixed_y_left;
+ gint stereo_fixed_x_right;
+ gint stereo_fixed_y_right;
+
+ RendererFuncs *renderer;
+ RendererFuncs *renderer2;
};
struct _PixbufRendererClass
};
+
+
GType pixbuf_renderer_get_type(void);
PixbufRenderer *pixbuf_renderer_new(void);
void pixbuf_renderer_set_pixbuf(PixbufRenderer *pr, GdkPixbuf *pixbuf, gdouble zoom);
/* same as pixbuf_renderer_set_pixbuf but waits with redrawing for pixbuf_renderer_area_changed */
-void pixbuf_renderer_set_pixbuf_lazy(PixbufRenderer *pr, GdkPixbuf *pixbuf, gdouble zoom, gint orientation);
+void pixbuf_renderer_set_pixbuf_lazy(PixbufRenderer *pr, GdkPixbuf *pixbuf, gdouble zoom, gint orientation, StereoPixbufData stereo_data);
GdkPixbuf *pixbuf_renderer_get_pixbuf(PixbufRenderer *pr);
void pixbuf_renderer_set_orientation(PixbufRenderer *pr, gint orientation);
gint pixbuf_renderer_get_orientation(PixbufRenderer *pr);
+/* sets the format of stereo data in the input pixbuf */
+void pixbuf_renderer_set_stereo_data(PixbufRenderer *pr, StereoPixbufData stereo_data);
+
void pixbuf_renderer_set_post_process_func(PixbufRenderer *pr, PixbufRendererPostProcessFunc func, gpointer user_data, gboolean slow);
/* display an on-request array of pixbuf tiles */
void pixbuf_renderer_set_color(PixbufRenderer *pr, GdkColor *color);
/* overlay */
-typedef enum {
- OVL_NORMAL = 0,
- OVL_RELATIVE = 1 << 0, /* x,y coordinates are relative, negative values start bottom right */
- /* OVL_HIDE_ON_SCROLL = 1 << 1*/ /* hide temporarily when scrolling (not yet implemented) */
-} OverlayRendererFlags;
gint pixbuf_renderer_overlay_add(PixbufRenderer *pr, GdkPixbuf *pixbuf, gint x, gint y,
OverlayRendererFlags flags);
gboolean pixbuf_renderer_get_mouse_position(PixbufRenderer *pr, gint *x_pixel, gint *y_pixel);
/* x_pixel and y_pixel are the pixel coordinates \see pixbuf_renderer_get_mouse_position */
gboolean pixbuf_renderer_get_pixel_colors(PixbufRenderer *pr, gint x_pixel, gint y_pixel,
- gint *r_mouse, gint *g_mouse, gint *b_mouse);
+ gint *r_mouse, gint *g_mouse, gint *b_mouse);
+
+void pixbuf_renderer_set_size_early(PixbufRenderer *pr, guint width, guint height);
+
+/* stereo */
+void pixbuf_renderer_stereo_set(PixbufRenderer *pr, gint stereo_mode);
+gint pixbuf_renderer_stereo_get(PixbufRenderer *pr);
+void pixbuf_renderer_stereo_fixed_set(PixbufRenderer *pr, gint width, gint height, gint x1, gint y1, gint x2, gint y2);
+
+/* protected - for renderer use only*/
+
+typedef struct _SourceTile SourceTile;
+struct _SourceTile
+{
+ gint x;
+ gint y;
+ GdkPixbuf *pixbuf;
+ gboolean blank;
+};
+
+gboolean pr_clip_region(gint x, gint y, gint w, gint h,
+ gint clip_x, gint clip_y, gint clip_w, gint clip_h,
+ gint *rx, gint *ry, gint *rw, gint *rh);
+void pr_render_complete_signal(PixbufRenderer *pr);
+
+void pr_tile_coords_map_orientation(gint orientation,
+ gdouble tile_x, gdouble tile_y, /* coordinates of the tile */
+ gdouble image_w, gdouble image_h,
+ gdouble tile_w, gdouble tile_h,
+ gdouble *res_x, gdouble *res_y);
+void pr_tile_region_map_orientation(gint orientation,
+ gint area_x, gint area_y, /* coordinates of the area inside tile */
+ gint tile_w, gint tile_h,
+ gint area_w, gint area_h,
+ gint *res_x, gint *res_y,
+ gint *res_w, gint *res_h);
+void pr_coords_map_orientation_reverse(gint orientation,
+ gint area_x, gint area_y,
+ gint tile_w, gint tile_h,
+ gint area_w, gint area_h,
+ gint *res_x, gint *res_y,
+ gint *res_w, gint *res_h);
+
+GList *pr_source_tile_compute_region(PixbufRenderer *pr, gint x, gint y, gint w, gint h, gboolean request);
+
+void pr_create_anaglyph(guint mode, GdkPixbuf *pixbuf, GdkPixbuf *right, gint x, gint y, gint w, gint h);
#endif
/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
options->metadata.confirm_on_dir_change = c_options->metadata.confirm_on_dir_change;
options->metadata.keywords_case_sensitive = c_options->metadata.keywords_case_sensitive;
options->metadata.write_orientation = c_options->metadata.write_orientation;
+ options->stereo.mode = (c_options->stereo.mode & (PR_STEREO_HORIZ | PR_STEREO_VERT | PR_STEREO_FIXED | PR_STEREO_ANAGLYPH | PR_STEREO_HALF)) |
+ (c_options->stereo.tmp.mirror_right ? PR_STEREO_MIRROR_RIGHT : 0) |
+ (c_options->stereo.tmp.flip_right ? PR_STEREO_FLIP_RIGHT : 0) |
+ (c_options->stereo.tmp.mirror_left ? PR_STEREO_MIRROR_LEFT : 0) |
+ (c_options->stereo.tmp.flip_left ? PR_STEREO_FLIP_LEFT : 0) |
+ (c_options->stereo.tmp.swap ? PR_STEREO_SWAP : 0) |
+ (c_options->stereo.tmp.temp_disable ? PR_STEREO_TEMP_DISABLE : 0);
+ options->stereo.fsmode = (c_options->stereo.fsmode & (PR_STEREO_HORIZ | PR_STEREO_VERT | PR_STEREO_FIXED | PR_STEREO_ANAGLYPH | PR_STEREO_HALF)) |
+ (c_options->stereo.tmp.fs_mirror_right ? PR_STEREO_MIRROR_RIGHT : 0) |
+ (c_options->stereo.tmp.fs_flip_right ? PR_STEREO_FLIP_RIGHT : 0) |
+ (c_options->stereo.tmp.fs_mirror_left ? PR_STEREO_MIRROR_LEFT : 0) |
+ (c_options->stereo.tmp.fs_flip_left ? PR_STEREO_FLIP_LEFT : 0) |
+ (c_options->stereo.tmp.fs_swap ? PR_STEREO_SWAP : 0) |
+ (c_options->stereo.tmp.fs_temp_disable ? PR_STEREO_TEMP_DISABLE : 0);
+ options->stereo.enable_fsmode = c_options->stereo.enable_fsmode;
+ options->stereo.fixed_w = c_options->stereo.fixed_w;
+ options->stereo.fixed_h = c_options->stereo.fixed_h;
+ options->stereo.fixed_x1 = c_options->stereo.fixed_x1;
+ options->stereo.fixed_y1 = c_options->stereo.fixed_y1;
+ options->stereo.fixed_x2 = c_options->stereo.fixed_x2;
+ options->stereo.fixed_y2 = c_options->stereo.fixed_y2;
#ifdef DEBUG
set_debug_level(debug_c);
gtk_widget_show(combo);
}
+static void stereo_mode_menu_cb(GtkWidget *combo, gpointer data)
+{
+ gint *option = data;
+
+ switch (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)))
+ {
+ case 0:
+ default:
+ *option = PR_STEREO_NONE;
+ break;
+ case 1:
+ *option = PR_STEREO_ANAGLYPH_RC;
+ break;
+ case 2:
+ *option = PR_STEREO_ANAGLYPH_GRAY;
+ break;
+ case 3:
+ *option = PR_STEREO_ANAGLYPH_DB;
+ break;
+ case 4:
+ *option = PR_STEREO_HORIZ;
+ break;
+ case 5:
+ *option = PR_STEREO_HORIZ | PR_STEREO_HALF;
+ break;
+ case 6:
+ *option = PR_STEREO_VERT;
+ break;
+ case 7:
+ *option = PR_STEREO_VERT | PR_STEREO_HALF;
+ break;
+ case 8:
+ *option = PR_STEREO_FIXED;
+ break;
+ }
+}
+
+static void add_stereo_mode_menu(GtkWidget *table, gint column, gint row, const gchar *text,
+ guint option, guint *option_c, gboolean add_fixed)
+{
+ GtkWidget *combo;
+ gint current = 0;
+
+ *option_c = option;
+
+ pref_table_label(table, column, row, text, 0.0);
+
+ combo = gtk_combo_box_new_text();
+
+ gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Single image"));
+
+ gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Anaglyph Red-Cyan"));
+ if (option & PR_STEREO_ANAGLYPH_RC) current = 1;
+ gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Anaglyph Gray Red-Cyan"));
+ if (option & PR_STEREO_ANAGLYPH_GRAY) current = 2;
+ gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Anaglyph Dubois"));
+ if (option & PR_STEREO_ANAGLYPH_DB) current = 3;
+
+ gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Side by Side"));
+ gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Side by Side Half size"));
+ if (option & PR_STEREO_HORIZ)
+ {
+ current = 4;
+ if (option & PR_STEREO_HALF) current = 5;
+ }
+
+ gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Top - Bottom"));
+ gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Top - Bottom Half size"));
+ if (option & PR_STEREO_VERT)
+ {
+ current = 6;
+ if (option & PR_STEREO_HALF) current = 7;
+ }
+
+ if (add_fixed)
+ {
+ gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Fixed position"));
+ if (option & PR_STEREO_FIXED) current = 8;
+ }
+
+ gtk_combo_box_set_active(GTK_COMBO_BOX(combo), current);
+
+ g_signal_connect(G_OBJECT(combo), "changed",
+ G_CALLBACK(stereo_mode_menu_cb), option_c);
+
+ gtk_table_attach(GTK_TABLE(table), combo, column + 1, column + 2, row, row + 1,
+ GTK_EXPAND | GTK_FILL, 0, 0, 0);
+ gtk_widget_show(combo);
+}
+
static void filter_store_populate(void)
{
GList *work;
#endif
}
+/* stereo tab */
+static void config_tab_stereo(GtkWidget *notebook)
+{
+ GtkWidget *vbox;
+ GtkWidget *group;
+ GtkWidget *group2;
+ GtkWidget *table;
+ GtkWidget *box;
+ GtkWidget *box2;
+ GtkWidget *fs_button;
+ vbox = scrolled_notebook_page(notebook, _("Stereo"));
+
+ group = pref_group_new(vbox, FALSE, _("Windowed stereo mode"), GTK_ORIENTATION_VERTICAL);
+
+ table = pref_table_new(group, 2, 1, FALSE, FALSE);
+ add_stereo_mode_menu(table, 0, 0, _("Windowed stereo mode"), options->stereo.mode, &c_options->stereo.mode, FALSE);
+
+ table = pref_table_new(group, 2, 2, TRUE, FALSE);
+ box = pref_table_box(table, 0, 0, GTK_ORIENTATION_HORIZONTAL, NULL);
+ pref_checkbox_new_int(box, _("Mirror left image"),
+ options->stereo.mode & PR_STEREO_MIRROR_LEFT, &c_options->stereo.tmp.mirror_left);
+ box = pref_table_box(table, 1, 0, GTK_ORIENTATION_HORIZONTAL, NULL);
+ pref_checkbox_new_int(box, _("Flip left image"),
+ options->stereo.mode & PR_STEREO_FLIP_LEFT, &c_options->stereo.tmp.flip_left);
+ box = pref_table_box(table, 0, 1, GTK_ORIENTATION_HORIZONTAL, NULL);
+ pref_checkbox_new_int(box, _("Mirror right image"),
+ options->stereo.mode & PR_STEREO_MIRROR_RIGHT, &c_options->stereo.tmp.mirror_right);
+ box = pref_table_box(table, 1, 1, GTK_ORIENTATION_HORIZONTAL, NULL);
+ pref_checkbox_new_int(box, _("Flip right image"),
+ options->stereo.mode & PR_STEREO_FLIP_RIGHT, &c_options->stereo.tmp.flip_right);
+ pref_checkbox_new_int(group, _("Swap left and right images"),
+ options->stereo.mode & PR_STEREO_SWAP, &c_options->stereo.tmp.swap);
+ pref_checkbox_new_int(group, _("Disable stereo mode on single image source"),
+ options->stereo.mode & PR_STEREO_TEMP_DISABLE, &c_options->stereo.tmp.temp_disable);
+
+ group = pref_group_new(vbox, FALSE, _("Fullscreen stereo mode"), GTK_ORIENTATION_VERTICAL);
+ fs_button = pref_checkbox_new_int(group, _("Use different settings for fullscreen"),
+ options->stereo.enable_fsmode, &c_options->stereo.enable_fsmode);
+ box2 = pref_box_new(group, FALSE, GTK_ORIENTATION_VERTICAL, PREF_PAD_SPACE);
+ pref_checkbox_link_sensitivity(fs_button, box2);
+ table = pref_table_new(box2, 2, 1, FALSE, FALSE);
+ add_stereo_mode_menu(table, 0, 0, _("Fullscreen stereo mode"), options->stereo.fsmode, &c_options->stereo.fsmode, TRUE);
+ table = pref_table_new(box2, 2, 2, TRUE, FALSE);
+ box = pref_table_box(table, 0, 0, GTK_ORIENTATION_HORIZONTAL, NULL);
+ pref_checkbox_new_int(box, _("Mirror left image"),
+ options->stereo.fsmode & PR_STEREO_MIRROR_LEFT, &c_options->stereo.tmp.fs_mirror_left);
+ box = pref_table_box(table, 1, 0, GTK_ORIENTATION_HORIZONTAL, NULL);
+ pref_checkbox_new_int(box, _("Flip left image"),
+ options->stereo.fsmode & PR_STEREO_FLIP_LEFT, &c_options->stereo.tmp.fs_flip_left);
+ box = pref_table_box(table, 0, 1, GTK_ORIENTATION_HORIZONTAL, NULL);
+ pref_checkbox_new_int(box, _("Mirror right image"),
+ options->stereo.fsmode & PR_STEREO_MIRROR_RIGHT, &c_options->stereo.tmp.fs_mirror_right);
+ box = pref_table_box(table, 1, 1, GTK_ORIENTATION_HORIZONTAL, NULL);
+ pref_checkbox_new_int(box, _("Flip right image"),
+ options->stereo.fsmode & PR_STEREO_FLIP_RIGHT, &c_options->stereo.tmp.fs_flip_right);
+ pref_checkbox_new_int(box2, _("Swap left and right images"),
+ options->stereo.fsmode & PR_STEREO_SWAP, &c_options->stereo.tmp.fs_swap);
+ pref_checkbox_new_int(box2, _("Disable stereo mode on single image source"),
+ options->stereo.fsmode & PR_STEREO_TEMP_DISABLE, &c_options->stereo.tmp.fs_temp_disable);
+
+ group2 = pref_group_new(box2, FALSE, _("Fixed position"), GTK_ORIENTATION_VERTICAL);
+ table = pref_table_new(group2, 5, 3, FALSE, FALSE);
+ pref_table_spin_new_int(table, 0, 0, _("Width"), NULL,
+ 1, 5000, 1, options->stereo.fixed_w, &c_options->stereo.fixed_w);
+ pref_table_spin_new_int(table, 3, 0, _("Height"), NULL,
+ 1, 5000, 1, options->stereo.fixed_h, &c_options->stereo.fixed_h);
+ pref_table_spin_new_int(table, 0, 1, _("Left X"), NULL,
+ 0, 5000, 1, options->stereo.fixed_x1, &c_options->stereo.fixed_x1);
+ pref_table_spin_new_int(table, 3, 1, _("Left Y"), NULL,
+ 0, 5000, 1, options->stereo.fixed_y1, &c_options->stereo.fixed_y1);
+ pref_table_spin_new_int(table, 0, 2, _("Right X"), NULL,
+ 0, 5000, 1, options->stereo.fixed_x2, &c_options->stereo.fixed_x2);
+ pref_table_spin_new_int(table, 3, 2, _("Right Y"), NULL,
+ 0, 5000, 1, options->stereo.fixed_y2, &c_options->stereo.fixed_y2);
+
+}
+
/* Main preferences window */
static void config_window_create(void)
{
config_tab_files(notebook);
config_tab_metadata(notebook);
config_tab_color(notebook);
+ config_tab_stereo(notebook);
config_tab_behavior(notebook);
gtk_widget_show(notebook);
WRITE_NL(); WRITE_BOOL(*options, metadata.keywords_case_sensitive);
WRITE_NL(); WRITE_BOOL(*options, metadata.write_orientation);
+ WRITE_NL(); WRITE_UINT(*options, stereo.mode);
+ WRITE_NL(); WRITE_UINT(*options, stereo.fsmode);
+ WRITE_NL(); WRITE_BOOL(*options, stereo.enable_fsmode);
+ WRITE_NL(); WRITE_UINT(*options, stereo.fixed_w);
+ WRITE_NL(); WRITE_UINT(*options, stereo.fixed_h);
+ WRITE_NL(); WRITE_UINT(*options, stereo.fixed_x1);
+ WRITE_NL(); WRITE_UINT(*options, stereo.fixed_y1);
+ WRITE_NL(); WRITE_UINT(*options, stereo.fixed_x2);
+ WRITE_NL(); WRITE_UINT(*options, stereo.fixed_y2);
}
static void write_color_profile(GString *outstr, gint indent)
if (READ_BOOL(*options, metadata.keywords_case_sensitive)) continue;
if (READ_BOOL(*options, metadata.write_orientation)) continue;
+ if (READ_UINT(*options, stereo.mode)) continue;
+ if (READ_UINT(*options, stereo.fsmode)) continue;
+ if (READ_BOOL(*options, stereo.enable_fsmode)) continue;
+ if (READ_UINT(*options, stereo.fixed_w)) continue;
+ if (READ_UINT(*options, stereo.fixed_h)) continue;
+ if (READ_UINT(*options, stereo.fixed_x1)) continue;
+ if (READ_UINT(*options, stereo.fixed_y1)) continue;
+ if (READ_UINT(*options, stereo.fixed_x2)) continue;
+ if (READ_UINT(*options, stereo.fixed_y2)) continue;
+
log_printf("unknown attribute %s = %s\n", option, value);
}
static void gr_slideshow_start_rec(const gchar *text, GIOChannel *channel, gpointer data)
{
GList *list;
- FileData *dir_fd = file_data_new_simple(text);
+ FileData *dir_fd = file_data_new_dir(text);
list = filelist_recursive(dir_fd);
file_data_unref(dir_fd);
if (!list) return;
static void gr_get_sidecars(const gchar *text, GIOChannel *channel, gpointer data)
{
gchar *filename = expand_tilde(text);
- FileData *fd = file_data_new_simple(filename);
+ FileData *fd = file_data_new_group(filename);
GList *work;
if (fd->parent) fd = fd->parent;
static void gr_get_destination(const gchar *text, GIOChannel *channel, gpointer data)
{
gchar *filename = expand_tilde(text);
- FileData *fd = file_data_new_simple(filename);
+ FileData *fd = file_data_new_group(filename);
if (fd->change && fd->change->dest)
{
{
gchar *filename = expand_tilde(text);
- view_window_new(file_data_new_simple(filename));
+ view_window_new(file_data_new_group(filename));
g_free(filename);
}
new = (!collection_get_first(remote_data->command_collection));
}
- if (collection_add(remote_data->command_collection, file_data_new_simple(text), FALSE) && new)
+ if (collection_add(remote_data->command_collection, file_data_new_group(text), FALSE) && new)
{
layout_image_set_collection(NULL, remote_data->command_collection,
collection_get_first(remote_data->command_collection));
}
i++;
}
+ printf_term(N_("\n All other command line parameters are used as plain files if they exists.\n"));
}
GList *remote_build_list(GList *list, gint argc, gchar *argv[], GList **errors)
{
list = g_list_append(list, argv[i]);
}
- else if (errors)
+ else if (errors && !isfile(argv[i]))
{
*errors = g_list_append(*errors, argv[i]);
}
return list;
}
+/**
+ * \param arg_exec Binary (argv0)
+ * \param remote_list Evaluated and recognized remote commands
+ * \param path The current path
+ * \param cmd_list List of all non collections in Path
+ * \param collection_list List of all collections in argv
+ */
void remote_control(const gchar *arg_exec, GList *remote_list, const gchar *path,
GList *cmd_list, GList *collection_list)
{
--- /dev/null
+/*
+ * Geeqie
+ * (C) 2006 John Ellis
+ * Copyright (C) 2008 - 2010 The Geeqie Team
+ *
+ * Author: John Ellis
+ * Author: Vladimir Nadvornik
+ *
+ * This software is released under the GNU General Public License (GNU GPL).
+ * Please read the included file COPYING for more information.
+ * This software comes with no warranty of any kind, use at your own risk!
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#include "main.h"
+#include "pixbuf-renderer.h"
+#include "renderer-tiles.h"
+
+#include "intl.h"
+#include "layout.h"
+
+#include <gtk/gtk.h>
+
+
+/* comment this out if not using this from within Geeqie
+ * defining GQ_BUILD does these things:
+ * - Sets the shift-click scroller pixbuf to a nice icon instead of a black box
+ */
+#define GQ_BUILD 1
+
+#ifdef GQ_BUILD
+#include "main.h"
+#include "pixbuf_util.h"
+#include "exif.h"
+#else
+typedef enum {
+ EXIF_ORIENTATION_UNKNOWN = 0,
+ EXIF_ORIENTATION_TOP_LEFT = 1,
+ EXIF_ORIENTATION_TOP_RIGHT = 2,
+ EXIF_ORIENTATION_BOTTOM_RIGHT = 3,
+ EXIF_ORIENTATION_BOTTOM_LEFT = 4,
+ EXIF_ORIENTATION_LEFT_TOP = 5,
+ EXIF_ORIENTATION_RIGHT_TOP = 6,
+ EXIF_ORIENTATION_RIGHT_BOTTOM = 7,
+ EXIF_ORIENTATION_LEFT_BOTTOM = 8
+} ExifOrientationType;
+#endif
+
+
+/* size to use when breaking up image pane for rendering */
+#define PR_TILE_SIZE 128
+
+typedef struct _ImageTile ImageTile;
+typedef struct _QueueData QueueData;
+
+struct _ImageTile
+{
+ GdkPixmap *pixmap; /* off screen buffer */
+ GdkPixbuf *pixbuf; /* pixbuf area for zooming */
+ gint x; /* x offset into image */
+ gint y; /* y offset into image */
+ gint w; /* width that is visible (may be less if at edge of image) */
+ gint h; /* height '' */
+
+ gboolean blank;
+
+/* render_todo: (explanation)
+ NONE do nothing
+ AREA render area of tile, usually only used when loading an image
+ note: will jump to an ALL if render_done is not ALL.
+ ALL render entire tile, if never done before w/ ALL, for expose events *only*
+*/
+
+ ImageRenderType render_todo; /* what to do (see above) */
+ ImageRenderType render_done; /* highest that has been done before on tile */
+
+ QueueData *qd;
+ QueueData *qd2;
+
+ guint size; /* est. memory used by pixmap and pixbuf */
+};
+
+struct _QueueData
+{
+ ImageTile *it;
+ gint x;
+ gint y;
+ gint w;
+ gint h;
+ gboolean new_data;
+};
+
+typedef struct _OverlayData OverlayData;
+struct _OverlayData
+{
+ gint id;
+
+ GdkPixbuf *pixbuf;
+ GdkWindow *window;
+
+ gint x;
+ gint y;
+
+ OverlayRendererFlags flags;
+};
+
+typedef struct _RendererTiles RendererTiles;
+
+struct _RendererTiles
+{
+ RendererFuncs f;
+ PixbufRenderer *pr;
+
+ gint tile_cache_max; /* max mb to use for offscreen buffer */
+
+ gint tile_width;
+ gint tile_height;
+ gint tile_cols; /* count of tile columns */
+ GList *tiles; /* list of buffer tiles */
+ gint tile_cache_size; /* allocated size of pixmaps/pixbufs */
+ GList *draw_queue; /* list of areas to redraw */
+ GList *draw_queue_2pass;/* list when 2 pass is enabled */
+
+ GList *overlay_list;
+ GdkPixmap *overlay_buffer;
+
+ guint draw_idle_id; /* event source id */
+
+ GdkPixbuf *spare_tile;
+
+ gint stereo_mode;
+ gint stereo_off_x;
+ gint stereo_off_y;
+
+ gint x_scroll; /* allow local adjustment and mirroring */
+ gint y_scroll;
+
+};
+
+
+
+static void rt_border_draw(RendererTiles *rt, gint x, gint y, gint w, gint h);
+static void rt_overlay_draw(RendererTiles *rt, gint x, gint y, gint w, gint h, ImageTile *it);
+
+
+static void rt_tile_free_all(RendererTiles *rt);
+static void rt_tile_invalidate_region(RendererTiles *rt, gint x, gint y, gint w, gint h);
+static gboolean rt_tile_is_visible(RendererTiles *rt, ImageTile *it);
+static void rt_queue_clear(RendererTiles *rt);
+static void rt_queue_merge(QueueData *parent, QueueData *qd);
+static void rt_queue(RendererTiles *rt, gint x, gint y, gint w, gint h,
+ gint clamp, ImageRenderType render, gboolean new_data, gboolean only_existing);
+
+static void rt_hierarchy_changed_cb(GtkWidget *widget, GtkWidget *previous_toplevel, gpointer data);
+static gint rt_queue_draw_idle_cb(gpointer data);
+static void renderer_redraw(void *renderer, gint x, gint y, gint w, gint h,
+ gint clamp, ImageRenderType render, gboolean new_data, gboolean only_existing);
+
+#define GET_RIGHT_PIXBUF_OFFSET(rt) \
+ (( (rt->stereo_mode & PR_STEREO_RIGHT) && !(rt->stereo_mode & PR_STEREO_SWAP)) || \
+ (!(rt->stereo_mode & PR_STEREO_RIGHT) && (rt->stereo_mode & PR_STEREO_SWAP)) ? \
+ rt->pr->stereo_pixbuf_offset_right : rt->pr->stereo_pixbuf_offset_left )
+
+#define GET_LEFT_PIXBUF_OFFSET(rt) \
+ ((!(rt->stereo_mode & PR_STEREO_RIGHT) && !(rt->stereo_mode & PR_STEREO_SWAP)) || \
+ ( (rt->stereo_mode & PR_STEREO_RIGHT) && (rt->stereo_mode & PR_STEREO_SWAP)) ? \
+ rt->pr->stereo_pixbuf_offset_right : rt->pr->stereo_pixbuf_offset_left )
+
+
+static void rt_sync_scroll(RendererTiles *rt)
+{
+ PixbufRenderer *pr = rt->pr;
+
+ rt->x_scroll = (rt->stereo_mode & PR_STEREO_MIRROR) ?
+ pr->width - pr->vis_width - pr->x_scroll
+ : pr->x_scroll;
+
+ rt->y_scroll = (rt->stereo_mode & PR_STEREO_FLIP) ?
+ pr->height - pr->vis_height - pr->y_scroll
+ : pr->y_scroll;
+}
+
+/*
+ *-------------------------------------------------------------------
+ * borders
+ *-------------------------------------------------------------------
+ */
+
+static void rt_border_draw(RendererTiles *rt, gint x, gint y, gint w, gint h)
+{
+ PixbufRenderer *pr = rt->pr;
+ GtkWidget *box;
+ gint rx, ry, rw, rh;
+
+ box = GTK_WIDGET(pr);
+
+ if (!box->window) return;
+
+ if (!pr->pixbuf && !pr->source_tiles_enabled)
+ {
+ if (pr_clip_region(x, y, w, h,
+ 0, 0,
+ pr->viewport_width, pr->viewport_height,
+ &rx, &ry, &rw, &rh))
+ {
+ gdk_window_clear_area(box->window, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh);
+ rt_overlay_draw(rt, rx, ry, rw, rh, NULL);
+ }
+ return;
+ }
+
+ if (pr->vis_width < pr->viewport_width)
+ {
+ if (pr->x_offset > 0 &&
+ pr_clip_region(x, y, w, h,
+ 0, 0,
+ pr->x_offset, pr->viewport_height,
+ &rx, &ry, &rw, &rh))
+ {
+ gdk_window_clear_area(box->window, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh);
+ rt_overlay_draw(rt, rx, ry, rw, rh, NULL);
+ }
+ if (pr->viewport_width - pr->vis_width - pr->x_offset > 0 &&
+ pr_clip_region(x, y, w, h,
+ pr->x_offset + pr->vis_width, 0,
+ pr->viewport_width - pr->vis_width - pr->x_offset, pr->viewport_height,
+ &rx, &ry, &rw, &rh))
+ {
+ gdk_window_clear_area(box->window, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh);
+ rt_overlay_draw(rt, rx, ry, rw, rh, NULL);
+ }
+ }
+ if (pr->vis_height < pr->viewport_height)
+ {
+ if (pr->y_offset > 0 &&
+ pr_clip_region(x, y, w, h,
+ pr->x_offset, 0,
+ pr->vis_width, pr->y_offset,
+ &rx, &ry, &rw, &rh))
+ {
+ gdk_window_clear_area(box->window, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh);
+ rt_overlay_draw(rt, rx, ry, rw, rh, NULL);
+ }
+ if (pr->viewport_height - pr->vis_height - pr->y_offset > 0 &&
+ pr_clip_region(x, y, w, h,
+ pr->x_offset, pr->y_offset + pr->vis_height,
+ pr->vis_width, pr->viewport_height - pr->vis_height - pr->y_offset,
+ &rx, &ry, &rw, &rh))
+ {
+ gdk_window_clear_area(box->window, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh);
+ rt_overlay_draw(rt, rx, ry, rw, rh, NULL);
+ }
+ }
+}
+
+static void rt_border_clear(RendererTiles *rt)
+{
+ PixbufRenderer *pr = rt->pr;
+ rt_border_draw(rt, 0, 0, pr->viewport_width, pr->viewport_height);
+}
+
+
+/*
+ *-------------------------------------------------------------------
+ * display tiles
+ *-------------------------------------------------------------------
+ */
+
+static ImageTile *rt_tile_new(gint x, gint y, gint width, gint height)
+{
+ ImageTile *it;
+
+ it = g_new0(ImageTile, 1);
+
+ it->x = x;
+ it->y = y;
+ it->w = width;
+ it->h = height;
+
+ it->render_done = TILE_RENDER_NONE;
+
+ return it;
+}
+
+static void rt_tile_free(ImageTile *it)
+{
+ if (!it) return;
+
+ if (it->pixbuf) g_object_unref(it->pixbuf);
+ if (it->pixmap) g_object_unref(it->pixmap);
+
+ g_free(it);
+}
+
+static void rt_tile_free_all(RendererTiles *rt)
+{
+ GList *work;
+
+ work = rt->tiles;
+ while (work)
+ {
+ ImageTile *it;
+
+ it = work->data;
+ work = work->next;
+
+ rt_tile_free(it);
+ }
+
+ g_list_free(rt->tiles);
+ rt->tiles = NULL;
+ rt->tile_cache_size = 0;
+}
+
+static ImageTile *rt_tile_add(RendererTiles *rt, gint x, gint y)
+{
+ PixbufRenderer *pr = rt->pr;
+ ImageTile *it;
+
+ it = rt_tile_new(x, y, rt->tile_width, rt->tile_height);
+
+ if (it->x + it->w > pr->width) it->w = pr->width - it->x;
+ if (it->y + it->h > pr->height) it->h = pr->height - it->y;
+
+ rt->tiles = g_list_prepend(rt->tiles, it);
+ rt->tile_cache_size += it->size;
+
+ return it;
+}
+
+static void rt_tile_remove(RendererTiles *rt, ImageTile *it)
+{
+ if (it->qd)
+ {
+ QueueData *qd = it->qd;
+
+ it->qd = NULL;
+ rt->draw_queue = g_list_remove(rt->draw_queue, qd);
+ g_free(qd);
+ }
+
+ if (it->qd2)
+ {
+ QueueData *qd = it->qd2;
+
+ it->qd2 = NULL;
+ rt->draw_queue_2pass = g_list_remove(rt->draw_queue_2pass, qd);
+ g_free(qd);
+ }
+
+ rt->tiles = g_list_remove(rt->tiles, it);
+ rt->tile_cache_size -= it->size;
+
+ rt_tile_free(it);
+}
+
+static void rt_tile_free_space(RendererTiles *rt, guint space, ImageTile *it)
+{
+ PixbufRenderer *pr = rt->pr;
+ GList *work;
+ guint tile_max;
+
+ work = g_list_last(rt->tiles);
+
+ if (pr->source_tiles_enabled && pr->scale < 1.0)
+ {
+ gint tiles;
+
+ tiles = (pr->vis_width / rt->tile_width + 1) * (pr->vis_height / rt->tile_height + 1);
+ tile_max = MAX(tiles * rt->tile_width * rt->tile_height * 3,
+ (gint)((gdouble)rt->tile_cache_max * 1048576.0 * pr->scale));
+ }
+ else
+ {
+ tile_max = rt->tile_cache_max * 1048576;
+ }
+
+ while (work && rt->tile_cache_size + space > tile_max)
+ {
+ ImageTile *needle;
+
+ needle = work->data;
+ work = work->prev;
+ if (needle != it &&
+ ((!needle->qd && !needle->qd2) || !rt_tile_is_visible(rt, needle))) rt_tile_remove(rt, needle);
+ }
+}
+
+static void rt_tile_invalidate_all(RendererTiles *rt)
+{
+ PixbufRenderer *pr = rt->pr;
+ GList *work;
+
+ work = rt->tiles;
+ while (work)
+ {
+ ImageTile *it;
+
+ it = work->data;
+ work = work->next;
+
+ it->render_done = TILE_RENDER_NONE;
+ it->render_todo = TILE_RENDER_ALL;
+ it->blank = FALSE;
+
+ it->w = MIN(rt->tile_width, pr->width - it->x);
+ it->h = MIN(rt->tile_height, pr->height - it->y);
+ }
+}
+
+static void rt_tile_invalidate_region(RendererTiles *rt, gint x, gint y, gint w, gint h)
+{
+ gint x1, x2;
+ gint y1, y2;
+ GList *work;
+
+ x1 = ROUND_DOWN(x, rt->tile_width);
+ x2 = ROUND_UP(x + w, rt->tile_width);
+
+ y1 = ROUND_DOWN(y, rt->tile_height);
+ y2 = ROUND_UP(y + h, rt->tile_height);
+
+ work = rt->tiles;
+ while (work)
+ {
+ ImageTile *it;
+
+ it = work->data;
+ work = work->next;
+
+ if (it->x < x2 && it->x + it->w > x1 &&
+ it->y < y2 && it->y + it->h > y1)
+ {
+ it->render_done = TILE_RENDER_NONE;
+ it->render_todo = TILE_RENDER_ALL;
+ }
+ }
+}
+
+static ImageTile *rt_tile_get(RendererTiles *rt, gint x, gint y, gboolean only_existing)
+{
+ GList *work;
+
+ work = rt->tiles;
+ while (work)
+ {
+ ImageTile *it;
+
+ it = work->data;
+ if (it->x == x && it->y == y)
+ {
+ rt->tiles = g_list_delete_link(rt->tiles, work);
+ rt->tiles = g_list_prepend(rt->tiles, it);
+ return it;
+ }
+
+ work = work->next;
+ }
+
+ if (only_existing) return NULL;
+
+ return rt_tile_add(rt, x, y);
+}
+
+static gint pixmap_calc_size(GdkPixmap *pixmap)
+{
+ gint w, h, d;
+
+ d = gdk_drawable_get_depth(pixmap);
+ gdk_drawable_get_size(pixmap, &w, &h);
+ return w * h * (d / 8);
+}
+
+static void rt_tile_prepare(RendererTiles *rt, ImageTile *it)
+{
+ PixbufRenderer *pr = rt->pr;
+ if (!it->pixmap)
+ {
+ GdkPixmap *pixmap;
+ guint size;
+
+ pixmap = gdk_pixmap_new(((GtkWidget *)pr)->window, rt->tile_width, rt->tile_height, -1);
+
+ size = pixmap_calc_size(pixmap);
+ rt_tile_free_space(rt, size, it);
+
+ it->pixmap = pixmap;
+ it->size += size;
+ rt->tile_cache_size += size;
+ }
+
+ if (!it->pixbuf)
+ {
+ GdkPixbuf *pixbuf;
+ guint size;
+ pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, rt->tile_width, rt->tile_height);
+
+ size = gdk_pixbuf_get_rowstride(pixbuf) * rt->tile_height;
+ rt_tile_free_space(rt, size, it);
+
+ it->pixbuf = pixbuf;
+ it->size += size;
+ rt->tile_cache_size += size;
+ }
+}
+
+/*
+ *-------------------------------------------------------------------
+ * overlays
+ *-------------------------------------------------------------------
+ */
+
+static void rt_overlay_get_position(RendererTiles *rt, OverlayData *od,
+ gint *x, gint *y, gint *w, gint *h)
+{
+ PixbufRenderer *pr = rt->pr;
+ gint px, py, pw, ph;
+
+ pw = gdk_pixbuf_get_width(od->pixbuf);
+ ph = gdk_pixbuf_get_height(od->pixbuf);
+ px = od->x;
+ py = od->y;
+
+ if (od->flags & OVL_RELATIVE)
+ {
+ if (px < 0) px = pr->viewport_width - pw + px;
+ if (py < 0) py = pr->viewport_height - ph + py;
+ }
+
+ if (x) *x = px;
+ if (y) *y = py;
+ if (w) *w = pw;
+ if (h) *h = ph;
+}
+
+static void rt_overlay_init_window(RendererTiles *rt, OverlayData *od)
+{
+ PixbufRenderer *pr = rt->pr;
+ gint px, py, pw, ph;
+ GdkWindowAttr attributes;
+ gint attributes_mask;
+
+ rt_overlay_get_position(rt, od, &px, &py, &pw, &ph);
+
+ attributes.window_type = GDK_WINDOW_CHILD;
+ attributes.wclass = GDK_INPUT_OUTPUT;
+ attributes.width = pw;
+ attributes.height = ph;
+ attributes.event_mask = GDK_EXPOSURE_MASK;
+ attributes_mask = 0;
+
+ od->window = gdk_window_new(GTK_WIDGET(pr)->window, &attributes, attributes_mask);
+ gdk_window_set_user_data(od->window, pr);
+ gdk_window_move(od->window, px + rt->stereo_off_x, py + rt->stereo_off_y);
+ gdk_window_show(od->window);
+}
+
+static void rt_overlay_draw(RendererTiles *rt, gint x, gint y, gint w, gint h,
+ ImageTile *it)
+{
+ PixbufRenderer *pr = rt->pr;
+ GtkWidget *box;
+ GList *work;
+
+ box = GTK_WIDGET(pr);
+
+ work = rt->overlay_list;
+ while (work)
+ {
+ OverlayData *od;
+ gint px, py, pw, ph;
+ gint rx, ry, rw, rh;
+
+ od = work->data;
+ work = work->next;
+
+ if (!od->window) rt_overlay_init_window(rt, od);
+
+ rt_overlay_get_position(rt, od, &px, &py, &pw, &ph);
+ if (pr_clip_region(x, y, w, h, px, py, pw, ph, &rx, &ry, &rw, &rh))
+ {
+ if (!rt->overlay_buffer)
+ {
+ rt->overlay_buffer = gdk_pixmap_new(((GtkWidget *)pr)->window, rt->tile_width, rt->tile_height, -1);
+ }
+
+ if (it)
+ {
+#if GTK_CHECK_VERSION(2,20,0)
+ gdk_draw_drawable(rt->overlay_buffer, box->style->fg_gc[gtk_widget_get_state(box)],
+#else
+ gdk_draw_drawable(rt->overlay_buffer, box->style->fg_gc[GTK_WIDGET_STATE(box)],
+#endif
+ it->pixmap,
+ rx - (pr->x_offset + (it->x - rt->x_scroll)),
+ ry - (pr->y_offset + (it->y - rt->y_scroll)),
+ 0, 0, rw, rh);
+ gdk_draw_pixbuf(rt->overlay_buffer,
+#if GTK_CHECK_VERSION(2,20,0)
+ box->style->fg_gc[gtk_widget_get_state(box)],
+#else
+ box->style->fg_gc[GTK_WIDGET_STATE(box)],
+#endif
+ od->pixbuf,
+ rx - px, ry - py,
+ 0, 0, rw, rh,
+ pr->dither_quality, rx, ry);
+#if GTK_CHECK_VERSION(2,20,0)
+ gdk_draw_drawable(od->window, box->style->fg_gc[gtk_widget_get_state(box)],
+#else
+ gdk_draw_drawable(od->window, box->style->fg_gc[GTK_WIDGET_STATE(box)],
+#endif
+ rt->overlay_buffer,
+ 0, 0,
+ rx - px, ry - py, rw, rh);
+ }
+ else
+ {
+ /* no ImageTile means region may be larger than our scratch buffer */
+ gint sx, sy;
+
+ for (sx = rx; sx < rx + rw; sx += rt->tile_width)
+ for (sy = ry; sy < ry + rh; sy += rt->tile_height)
+ {
+ gint sw, sh;
+
+ sw = MIN(rx + rw - sx, rt->tile_width);
+ sh = MIN(ry + rh - sy, rt->tile_height);
+
+ gdk_draw_rectangle(rt->overlay_buffer,
+#if GTK_CHECK_VERSION(2,20,0)
+ box->style->bg_gc[gtk_widget_get_state(box)], TRUE,
+#else
+ box->style->bg_gc[GTK_WIDGET_STATE(box)], TRUE,
+#endif
+ 0, 0, sw, sh);
+ gdk_draw_pixbuf(rt->overlay_buffer,
+#if GTK_CHECK_VERSION(2,20,0)
+ box->style->fg_gc[gtk_widget_get_state(box)],
+#else
+ box->style->fg_gc[GTK_WIDGET_STATE(box)],
+#endif
+ od->pixbuf,
+ sx - px, sy - py,
+ 0, 0, sw, sh,
+ pr->dither_quality, sx, sy);
+#if GTK_CHECK_VERSION(2,20,0)
+ gdk_draw_drawable(od->window, box->style->fg_gc[gtk_widget_get_state(box)],
+#else
+ gdk_draw_drawable(od->window, box->style->fg_gc[GTK_WIDGET_STATE(box)],
+#endif
+ rt->overlay_buffer,
+ 0, 0,
+ sx - px, sy - py, sw, sh);
+ }
+ }
+ }
+ }
+}
+
+static void rt_overlay_queue_draw(RendererTiles *rt, OverlayData *od, gint x1, gint y1, gint x2, gint y2)
+{
+ PixbufRenderer *pr = rt->pr;
+ gint x, y, w, h;
+
+ rt_overlay_get_position(rt, od, &x, &y, &w, &h);
+
+ /* add borders */
+ x -= x1;
+ y -= y1;
+ w += x1 + x2;
+ h += y1 + y2;
+
+ rt_queue(rt, rt->x_scroll - pr->x_offset + x,
+ rt->y_scroll - pr->y_offset + y,
+ w, h,
+ FALSE, TILE_RENDER_ALL, FALSE, FALSE);
+
+ rt_border_draw(rt, x, y, w, h);
+}
+
+static void rt_overlay_queue_all(RendererTiles *rt, gint x1, gint y1, gint x2, gint y2)
+{
+ GList *work;
+
+ work = rt->overlay_list;
+ while (work)
+ {
+ OverlayData *od = work->data;
+ work = work->next;
+
+ rt_overlay_queue_draw(rt, od, x1, y1, x2, y2);
+ }
+}
+
+static void rt_overlay_update_sizes(RendererTiles *rt)
+{
+ GList *work;
+
+ work = rt->overlay_list;
+ while (work)
+ {
+ OverlayData *od = work->data;
+ work = work->next;
+
+ if (!od->window) rt_overlay_init_window(rt, od);
+
+ if (od->flags & OVL_RELATIVE)
+ {
+ gint x, y, w, h;
+
+ rt_overlay_get_position(rt, od, &x, &y, &w, &h);
+ gdk_window_move_resize(od->window, x + rt->stereo_off_x, y + rt->stereo_off_y, w, h);
+ }
+ }
+}
+
+static OverlayData *rt_overlay_find(RendererTiles *rt, gint id)
+{
+ GList *work;
+
+ work = rt->overlay_list;
+ while (work)
+ {
+ OverlayData *od = work->data;
+ work = work->next;
+
+ if (od->id == id) return od;
+ }
+
+ return NULL;
+}
+
+
+gint renderer_tiles_overlay_add(RendererTiles *rt, GdkPixbuf *pixbuf, gint x, gint y,
+ OverlayRendererFlags flags)
+{
+ PixbufRenderer *pr = rt->pr;
+ OverlayData *od;
+ gint id;
+
+ g_return_val_if_fail(IS_PIXBUF_RENDERER(pr), -1);
+ g_return_val_if_fail(pixbuf != NULL, -1);
+
+ id = 1;
+ while (rt_overlay_find(rt, id)) id++;
+
+ od = g_new0(OverlayData, 1);
+ od->id = id;
+ od->pixbuf = pixbuf;
+ g_object_ref(G_OBJECT(od->pixbuf));
+ od->x = x;
+ od->y = y;
+ od->flags = flags;
+
+ rt_overlay_init_window(rt, od);
+
+ rt->overlay_list = g_list_append(rt->overlay_list, od);
+
+ rt_overlay_queue_draw(rt, od, 0, 0, 0, 0);
+
+ return od->id;
+}
+
+static void rt_overlay_free(RendererTiles *rt, OverlayData *od)
+{
+ rt->overlay_list = g_list_remove(rt->overlay_list, od);
+
+ if (od->pixbuf) g_object_unref(G_OBJECT(od->pixbuf));
+ if (od->window) gdk_window_destroy(od->window);
+ g_free(od);
+
+ if (!rt->overlay_list && rt->overlay_buffer)
+ {
+ g_object_unref(rt->overlay_buffer);
+ rt->overlay_buffer = NULL;
+ }
+}
+
+static void rt_overlay_list_clear(RendererTiles *rt)
+{
+ while (rt->overlay_list)
+ {
+ OverlayData *od;
+
+ od = rt->overlay_list->data;
+ rt_overlay_free(rt, od);
+ }
+}
+
+static void rt_overlay_list_reset_window(RendererTiles *rt)
+{
+ GList *work;
+
+ if (rt->overlay_buffer) g_object_unref(rt->overlay_buffer);
+ rt->overlay_buffer = NULL;
+
+ work = rt->overlay_list;
+ while (work)
+ {
+ OverlayData *od = work->data;
+ work = work->next;
+ if (od->window) gdk_window_destroy(od->window);
+ od->window = NULL;
+ }
+}
+
+void renderer_tiles_overlay_set(RendererTiles *rt, gint id, GdkPixbuf *pixbuf, gint x, gint y)
+{
+ PixbufRenderer *pr = rt->pr;
+ OverlayData *od;
+
+ g_return_if_fail(IS_PIXBUF_RENDERER(pr));
+
+ od = rt_overlay_find(rt, id);
+ if (!od) return;
+
+ if (pixbuf)
+ {
+ gint px, py, pw, ph;
+
+ g_object_ref(G_OBJECT(pixbuf));
+ g_object_unref(G_OBJECT(od->pixbuf));
+ od->pixbuf = pixbuf;
+
+ od->x = x;
+ od->y = y;
+
+ if (!od->window) rt_overlay_init_window(rt, od);
+
+ rt_overlay_queue_draw(rt, od, 0, 0, 0, 0);
+ rt_overlay_get_position(rt, od, &px, &py, &pw, &ph);
+ gdk_window_move_resize(od->window, px + rt->stereo_off_x, py + rt->stereo_off_y, pw, ph);
+ }
+ else
+ {
+ rt_overlay_queue_draw(rt, od, 0, 0, 0, 0);
+ rt_overlay_free(rt, od);
+ }
+}
+
+gboolean renderer_tiles_overlay_get(RendererTiles *rt, gint id, GdkPixbuf **pixbuf, gint *x, gint *y)
+{
+ PixbufRenderer *pr = rt->pr;
+ OverlayData *od;
+
+ g_return_val_if_fail(IS_PIXBUF_RENDERER(pr), FALSE);
+
+ od = rt_overlay_find(rt, id);
+ if (!od) return FALSE;
+
+ if (pixbuf) *pixbuf = od->pixbuf;
+ if (x) *x = od->x;
+ if (y) *y = od->y;
+
+ return TRUE;
+}
+
+static void rt_hierarchy_changed_cb(GtkWidget *widget, GtkWidget *previous_toplevel, gpointer data)
+{
+ RendererTiles *rt = data;
+ rt_overlay_list_reset_window(rt);
+}
+
+/*
+ *-------------------------------------------------------------------
+ * drawing
+ *-------------------------------------------------------------------
+ */
+
+static GdkPixbuf *rt_get_spare_tile(RendererTiles *rt)
+{
+ if (!rt->spare_tile) rt->spare_tile = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, rt->tile_width, rt->tile_height);
+ return rt->spare_tile;
+}
+
+#define COLOR_BYTES 3 /* rgb */
+
+static void rt_tile_rotate_90_clockwise(RendererTiles *rt, GdkPixbuf **tile, gint x, gint y, gint w, gint h)
+{
+ GdkPixbuf *src = *tile;
+ GdkPixbuf *dest;
+ gint srs, drs;
+ guchar *s_pix, *d_pix;
+ guchar *sp, *dp;
+ guchar *ip, *spi, *dpi;
+ gint i, j;
+ gint tw = rt->tile_width;
+
+ srs = gdk_pixbuf_get_rowstride(src);
+ s_pix = gdk_pixbuf_get_pixels(src);
+ spi = s_pix + (x * COLOR_BYTES);
+
+ dest = rt_get_spare_tile(rt);
+ drs = gdk_pixbuf_get_rowstride(dest);
+ d_pix = gdk_pixbuf_get_pixels(dest);
+ dpi = d_pix + (tw - 1) * COLOR_BYTES;
+
+ for (i = y; i < y + h; i++)
+ {
+ sp = spi + (i * srs);
+ ip = dpi - (i * COLOR_BYTES);
+ for (j = x; j < x + w; j++)
+ {
+ dp = ip + (j * drs);
+ memcpy(dp, sp, COLOR_BYTES);
+ sp += COLOR_BYTES;
+ }
+ }
+
+ rt->spare_tile = src;
+ *tile = dest;
+}
+
+static void rt_tile_rotate_90_counter_clockwise(RendererTiles *rt, GdkPixbuf **tile, gint x, gint y, gint w, gint h)
+{
+ GdkPixbuf *src = *tile;
+ GdkPixbuf *dest;
+ gint srs, drs;
+ guchar *s_pix, *d_pix;
+ guchar *sp, *dp;
+ guchar *ip, *spi, *dpi;
+ gint i, j;
+ gint th = rt->tile_height;
+
+ srs = gdk_pixbuf_get_rowstride(src);
+ s_pix = gdk_pixbuf_get_pixels(src);
+ spi = s_pix + (x * COLOR_BYTES);
+
+ dest = rt_get_spare_tile(rt);
+ drs = gdk_pixbuf_get_rowstride(dest);
+ d_pix = gdk_pixbuf_get_pixels(dest);
+ dpi = d_pix + (th - 1) * drs;
+
+ for (i = y; i < y + h; i++)
+ {
+ sp = spi + (i * srs);
+ ip = dpi + (i * COLOR_BYTES);
+ for (j = x; j < x + w; j++)
+ {
+ dp = ip - (j * drs);
+ memcpy(dp, sp, COLOR_BYTES);
+ sp += COLOR_BYTES;
+ }
+ }
+
+ rt->spare_tile = src;
+ *tile = dest;
+}
+
+static void rt_tile_mirror_only(RendererTiles *rt, GdkPixbuf **tile, gint x, gint y, gint w, gint h)
+{
+ GdkPixbuf *src = *tile;
+ GdkPixbuf *dest;
+ gint srs, drs;
+ guchar *s_pix, *d_pix;
+ guchar *sp, *dp;
+ guchar *spi, *dpi;
+ gint i, j;
+
+ gint tw = rt->tile_width;
+
+ srs = gdk_pixbuf_get_rowstride(src);
+ s_pix = gdk_pixbuf_get_pixels(src);
+ spi = s_pix + (x * COLOR_BYTES);
+
+ dest = rt_get_spare_tile(rt);
+ drs = gdk_pixbuf_get_rowstride(dest);
+ d_pix = gdk_pixbuf_get_pixels(dest);
+ dpi = d_pix + (tw - x - 1) * COLOR_BYTES;
+
+ for (i = y; i < y + h; i++)
+ {
+ sp = spi + (i * srs);
+ dp = dpi + (i * drs);
+ for (j = 0; j < w; j++)
+ {
+ memcpy(dp, sp, COLOR_BYTES);
+ sp += COLOR_BYTES;
+ dp -= COLOR_BYTES;
+ }
+ }
+
+ rt->spare_tile = src;
+ *tile = dest;
+}
+
+static void rt_tile_mirror_and_flip(RendererTiles *rt, GdkPixbuf **tile, gint x, gint y, gint w, gint h)
+{
+ GdkPixbuf *src = *tile;
+ GdkPixbuf *dest;
+ gint srs, drs;
+ guchar *s_pix, *d_pix;
+ guchar *sp, *dp;
+ guchar *spi, *dpi;
+ gint i, j;
+ gint tw = rt->tile_width;
+ gint th = rt->tile_height;
+
+ srs = gdk_pixbuf_get_rowstride(src);
+ s_pix = gdk_pixbuf_get_pixels(src);
+ spi = s_pix + (x * COLOR_BYTES);
+
+ dest = rt_get_spare_tile(rt);
+ drs = gdk_pixbuf_get_rowstride(dest);
+ d_pix = gdk_pixbuf_get_pixels(dest);
+ dpi = d_pix + (th - 1) * drs + (tw - 1) * COLOR_BYTES;
+
+ for (i = y; i < y + h; i++)
+ {
+ sp = s_pix + (i * srs) + (x * COLOR_BYTES);
+ dp = dpi - (i * drs) - (x * COLOR_BYTES);
+ for (j = 0; j < w; j++)
+ {
+ memcpy(dp, sp, COLOR_BYTES);
+ sp += COLOR_BYTES;
+ dp -= COLOR_BYTES;
+ }
+ }
+
+ rt->spare_tile = src;
+ *tile = dest;
+}
+
+static void rt_tile_flip_only(RendererTiles *rt, GdkPixbuf **tile, gint x, gint y, gint w, gint h)
+{
+ GdkPixbuf *src = *tile;
+ GdkPixbuf *dest;
+ gint srs, drs;
+ guchar *s_pix, *d_pix;
+ guchar *sp, *dp;
+ guchar *spi, *dpi;
+ gint i;
+ gint th = rt->tile_height;
+
+ srs = gdk_pixbuf_get_rowstride(src);
+ s_pix = gdk_pixbuf_get_pixels(src);
+ spi = s_pix + (x * COLOR_BYTES);
+
+ dest = rt_get_spare_tile(rt);
+ drs = gdk_pixbuf_get_rowstride(dest);
+ d_pix = gdk_pixbuf_get_pixels(dest);
+ dpi = d_pix + (th - 1) * drs + (x * COLOR_BYTES);
+
+ for (i = y; i < y + h; i++)
+ {
+ sp = spi + (i * srs);
+ dp = dpi - (i * drs);
+ memcpy(dp, sp, w * COLOR_BYTES);
+ }
+
+ rt->spare_tile = src;
+ *tile = dest;
+}
+
+static void rt_tile_apply_orientation(RendererTiles *rt, gint orientation, GdkPixbuf **pixbuf, gint x, gint y, gint w, gint h)
+{
+ switch (orientation)
+ {
+ case EXIF_ORIENTATION_TOP_LEFT:
+ /* normal -- nothing to do */
+ break;
+ case EXIF_ORIENTATION_TOP_RIGHT:
+ /* mirrored */
+ {
+ rt_tile_mirror_only(rt, pixbuf, x, y, w, h);
+ }
+ break;
+ case EXIF_ORIENTATION_BOTTOM_RIGHT:
+ /* upside down */
+ {
+ rt_tile_mirror_and_flip(rt, pixbuf, x, y, w, h);
+ }
+ break;
+ case EXIF_ORIENTATION_BOTTOM_LEFT:
+ /* flipped */
+ {
+ rt_tile_flip_only(rt, pixbuf, x, y, w, h);
+ }
+ break;
+ case EXIF_ORIENTATION_LEFT_TOP:
+ {
+ rt_tile_flip_only(rt, pixbuf, x, y, w, h);
+ rt_tile_rotate_90_clockwise(rt, pixbuf, x, rt->tile_height - y - h, w, h);
+ }
+ break;
+ case EXIF_ORIENTATION_RIGHT_TOP:
+ /* rotated -90 (270) */
+ {
+ rt_tile_rotate_90_clockwise(rt, pixbuf, x, y, w, h);
+ }
+ break;
+ case EXIF_ORIENTATION_RIGHT_BOTTOM:
+ {
+ rt_tile_flip_only(rt, pixbuf, x, y, w, h);
+ rt_tile_rotate_90_counter_clockwise(rt, pixbuf, x, rt->tile_height - y - h, w, h);
+ }
+ break;
+ case EXIF_ORIENTATION_LEFT_BOTTOM:
+ /* rotated 90 */
+ {
+ rt_tile_rotate_90_counter_clockwise(rt, pixbuf, x, y, w, h);
+ }
+ break;
+ default:
+ /* The other values are out of range */
+ break;
+ }
+}
+
+static gboolean rt_source_tile_render(RendererTiles *rt, ImageTile *it,
+ gint x, gint y, gint w, gint h,
+ gboolean new_data, gboolean fast)
+{
+ PixbufRenderer *pr = rt->pr;
+ GtkWidget *box;
+ GList *list;
+ GList *work;
+ gboolean draw = FALSE;
+
+ box = GTK_WIDGET(pr);
+
+ if (pr->zoom == 1.0 || pr->scale == 1.0)
+ {
+ list = pr_source_tile_compute_region(pr, it->x + x, it->y + y, w, h, TRUE);
+ work = list;
+ while (work)
+ {
+ SourceTile *st;
+ gint rx, ry, rw, rh;
+
+ st = work->data;
+ work = work->next;
+
+ if (pr_clip_region(st->x, st->y, pr->source_tile_width, pr->source_tile_height,
+ it->x + x, it->y + y, w, h,
+ &rx, &ry, &rw, &rh))
+ {
+ if (st->blank)
+ {
+ gdk_draw_rectangle(it->pixmap, box->style->black_gc, TRUE,
+ rx - st->x, ry - st->y, rw, rh);
+ }
+ else /* (pr->zoom == 1.0 || pr->scale == 1.0) */
+ {
+ gdk_draw_pixbuf(it->pixmap,
+#if GTK_CHECK_VERSION(2,20,0)
+ box->style->fg_gc[gtk_widget_get_state(box)],
+#else
+ box->style->fg_gc[GTK_WIDGET_STATE(box)],
+#endif
+ st->pixbuf,
+ rx - st->x, ry - st->y,
+ rx - it->x, ry - it->y,
+ rw, rh,
+ pr->dither_quality, rx, ry);
+ }
+ }
+ }
+ }
+ else
+ {
+ gdouble scale_x, scale_y;
+ gint sx, sy, sw, sh;
+
+ if (pr->image_width == 0 || pr->image_height == 0) return FALSE;
+ scale_x = (gdouble)pr->width / pr->image_width;
+ scale_y = (gdouble)pr->height / pr->image_height;
+
+ sx = (gdouble)(it->x + x) / scale_x;
+ sy = (gdouble)(it->y + y) / scale_y;
+ sw = (gdouble)w / scale_x;
+ sh = (gdouble)h / scale_y;
+
+ if (pr->width < PR_MIN_SCALE_SIZE || pr->height < PR_MIN_SCALE_SIZE) fast = TRUE;
+
+#if 0
+ /* draws red over draw region, to check for leaks (regions not filled) */
+ pixbuf_set_rect_fill(it->pixbuf, x, y, w, h, 255, 0, 0, 255);
+#endif
+
+ list = pr_source_tile_compute_region(pr, sx, sy, sw, sh, TRUE);
+ work = list;
+ while (work)
+ {
+ SourceTile *st;
+ gint rx, ry, rw, rh;
+ gint stx, sty, stw, sth;
+
+ st = work->data;
+ work = work->next;
+
+ stx = floor((gdouble)st->x * scale_x);
+ sty = floor((gdouble)st->y * scale_y);
+ stw = ceil((gdouble)(st->x + pr->source_tile_width) * scale_x) - stx;
+ sth = ceil((gdouble)(st->y + pr->source_tile_height) * scale_y) - sty;
+
+ if (pr_clip_region(stx, sty, stw, sth,
+ it->x + x, it->y + y, w, h,
+ &rx, &ry, &rw, &rh))
+ {
+ if (st->blank)
+ {
+ gdk_draw_rectangle(it->pixmap, box->style->black_gc, TRUE,
+ rx - st->x, ry - st->y, rw, rh);
+ }
+ else
+ {
+ gdouble offset_x;
+ gdouble offset_y;
+
+ /* may need to use unfloored stx,sty values here */
+ offset_x = (gdouble)(stx - it->x);
+ offset_y = (gdouble)(sty - it->y);
+
+ gdk_pixbuf_scale(st->pixbuf, it->pixbuf, rx - it->x, ry - it->y, rw, rh,
+ (gdouble) 0.0 + offset_x,
+ (gdouble) 0.0 + offset_y,
+ scale_x, scale_y,
+ (fast) ? GDK_INTERP_NEAREST : pr->zoom_quality);
+ draw = TRUE;
+ }
+ }
+ }
+ }
+
+ g_list_free(list);
+
+ return draw;
+}
+
+static void rt_tile_get_region(gboolean has_alpha,
+ const GdkPixbuf *src, GdkPixbuf *dest,
+ int pb_x, int pb_y, int pb_w, int pb_h,
+ double offset_x, double offset_y, double scale_x, double scale_y,
+ GdkInterpType interp_type,
+ int check_x, int check_y)
+{
+ if (!has_alpha)
+ {
+ if (scale_x == 1.0 && scale_y == 1.0)
+ {
+ gdk_pixbuf_copy_area(src,
+ -offset_x + pb_x, -offset_y + pb_y,
+ pb_w, pb_h,
+ dest,
+ pb_x, pb_y);
+ }
+ else
+ {
+ gdk_pixbuf_scale(src, dest,
+ pb_x, pb_y, pb_w, pb_h,
+ offset_x,
+ offset_y,
+ scale_x, scale_y,
+ interp_type);
+ }
+ }
+ else
+ {
+ gdk_pixbuf_composite_color(src, dest,
+ pb_x, pb_y, pb_w, pb_h,
+ offset_x,
+ offset_y,
+ scale_x, scale_y,
+ interp_type,
+ 255, check_x, check_y,
+ PR_ALPHA_CHECK_SIZE, PR_ALPHA_CHECK1, PR_ALPHA_CHECK2);
+ }
+}
+
+
+static gint rt_get_orientation(RendererTiles *rt)
+{
+ PixbufRenderer *pr = rt->pr;
+
+ gint orientation = pr->orientation;
+ static const gint mirror[] = {1, 2, 1, 4, 3, 6, 5, 8, 7};
+ static const gint flip[] = {1, 4, 3, 2, 1, 8, 7, 6, 5};
+
+ if (rt->stereo_mode & PR_STEREO_MIRROR) orientation = mirror[orientation];
+ if (rt->stereo_mode & PR_STEREO_FLIP) orientation = flip[orientation];
+ return orientation;
+}
+
+
+static void rt_tile_render(RendererTiles *rt, ImageTile *it,
+ gint x, gint y, gint w, gint h,
+ gboolean new_data, gboolean fast)
+{
+ PixbufRenderer *pr = rt->pr;
+ GtkWidget *box;
+ gboolean has_alpha;
+ gboolean draw = FALSE;
+ gint orientation = rt_get_orientation(rt);
+
+ if (it->render_todo == TILE_RENDER_NONE && it->pixmap && !new_data) return;
+
+ if (it->render_done != TILE_RENDER_ALL)
+ {
+ x = 0;
+ y = 0;
+ w = it->w;
+ h = it->h;
+ if (!fast) it->render_done = TILE_RENDER_ALL;
+ }
+ else if (it->render_todo != TILE_RENDER_AREA)
+ {
+ if (!fast) it->render_todo = TILE_RENDER_NONE;
+ return;
+ }
+
+ if (!fast) it->render_todo = TILE_RENDER_NONE;
+
+ if (new_data) it->blank = FALSE;
+
+ rt_tile_prepare(rt, it);
+ has_alpha = (pr->pixbuf && gdk_pixbuf_get_has_alpha(pr->pixbuf));
+
+ box = GTK_WIDGET(pr);
+
+ /* FIXME checker colors for alpha should be configurable,
+ * also should be drawn for blank = TRUE
+ */
+
+ if (it->blank)
+ {
+ /* no data, do fast rect fill */
+ gdk_draw_rectangle(it->pixmap, box->style->black_gc, TRUE,
+ 0, 0, it->w, it->h);
+ }
+ else if (pr->source_tiles_enabled)
+ {
+ draw = rt_source_tile_render(rt, it, x, y, w, h, new_data, fast);
+ }
+ else if ((pr->zoom == 1.0 || pr->scale == 1.0) &&
+ pr->aspect_ratio == 1.0 &&
+ !has_alpha &&
+ orientation == EXIF_ORIENTATION_TOP_LEFT &&
+ !(pr->func_post_process && !(pr->post_process_slow && fast)) &&
+ !(rt->stereo_mode & PR_STEREO_ANAGLYPH))
+ {
+ /* special case: faster, simple, scale 1.0, base orientation, no postprocessing */
+ gdk_draw_pixbuf(it->pixmap,
+#if GTK_CHECK_VERSION(2,20,0)
+ box->style->fg_gc[gtk_widget_get_state(box)],
+#else
+ box->style->fg_gc[GTK_WIDGET_STATE(box)],
+#endif
+ pr->pixbuf,
+ it->x + x + GET_RIGHT_PIXBUF_OFFSET(rt), it->y + y,
+ x, y,
+ w, h,
+ pr->dither_quality, it->x + x, it->y + y);
+ }
+ else
+ {
+ gdouble scale_x, scale_y;
+ gdouble src_x, src_y;
+ gint pb_x, pb_y;
+ gint pb_w, pb_h;
+
+ if (pr->image_width == 0 || pr->image_height == 0) return;
+
+ scale_x = (gdouble)pr->width / pr->image_width;
+ scale_y = (gdouble)pr->height / pr->image_height;
+
+ pr_tile_coords_map_orientation(orientation, it->x, it->y,
+ pr->width, pr->height,
+ rt->tile_width, rt->tile_height,
+ &src_x, &src_y);
+ pr_tile_region_map_orientation(orientation, x, y,
+ rt->tile_width, rt->tile_height,
+ w, h,
+ &pb_x, &pb_y,
+ &pb_w, &pb_h);
+
+ switch (orientation)
+ {
+ gdouble tmp;
+ case EXIF_ORIENTATION_LEFT_TOP:
+ case EXIF_ORIENTATION_RIGHT_TOP:
+ case EXIF_ORIENTATION_RIGHT_BOTTOM:
+ case EXIF_ORIENTATION_LEFT_BOTTOM:
+ tmp = scale_x;
+ scale_x = scale_y;
+ scale_y = tmp;
+ break;
+ default:
+ /* nothing to do */
+ break;
+ }
+
+ /* HACK: The pixbuf scalers get kinda buggy(crash) with extremely
+ * small sizes for anything but GDK_INTERP_NEAREST
+ */
+ if (pr->width < PR_MIN_SCALE_SIZE || pr->height < PR_MIN_SCALE_SIZE) fast = TRUE;
+
+ rt_tile_get_region(has_alpha,
+ pr->pixbuf, it->pixbuf, pb_x, pb_y, pb_w, pb_h,
+ (gdouble) 0.0 - src_x - GET_RIGHT_PIXBUF_OFFSET(rt) * scale_x,
+ (gdouble) 0.0 - src_y,
+ scale_x, scale_y,
+ (fast) ? GDK_INTERP_NEAREST : pr->zoom_quality,
+ it->x + pb_x, it->y + pb_y);
+ if (rt->stereo_mode & PR_STEREO_ANAGLYPH &&
+ (pr->stereo_pixbuf_offset_right > 0 || pr->stereo_pixbuf_offset_left > 0))
+ {
+ GdkPixbuf *right_pb = rt_get_spare_tile(rt);
+ rt_tile_get_region(has_alpha,
+ pr->pixbuf, right_pb, pb_x, pb_y, pb_w, pb_h,
+ (gdouble) 0.0 - src_x - GET_LEFT_PIXBUF_OFFSET(rt) * scale_x,
+ (gdouble) 0.0 - src_y,
+ scale_x, scale_y,
+ (fast) ? GDK_INTERP_NEAREST : pr->zoom_quality,
+ it->x + pb_x, it->y + pb_y);
+ pr_create_anaglyph(rt->stereo_mode, it->pixbuf, right_pb, pb_x, pb_y, pb_w, pb_h);
+ /* do not care about freeing spare_tile, it will be reused */
+ }
+ rt_tile_apply_orientation(rt, orientation, &it->pixbuf, pb_x, pb_y, pb_w, pb_h);
+ draw = TRUE;
+ }
+
+ if (draw && it->pixbuf && !it->blank)
+ {
+
+ if (pr->func_post_process && !(pr->post_process_slow && fast))
+ pr->func_post_process(pr, &it->pixbuf, x, y, w, h, pr->post_process_user_data);
+
+ gdk_draw_pixbuf(it->pixmap,
+#if GTK_CHECK_VERSION(2,20,0)
+ box->style->fg_gc[gtk_widget_get_state(box)],
+#else
+ box->style->fg_gc[GTK_WIDGET_STATE(box)],
+#endif
+ it->pixbuf,
+ x, y,
+ x, y,
+ w, h,
+ pr->dither_quality, it->x + x, it->y + y);
+ }
+
+#if 0
+ /* enable this line for debugging the edges of tiles */
+ gdk_draw_rectangle(it->pixmap, box->style->white_gc,
+ FALSE, 0, 0, it->w, it->h);
+ gdk_draw_rectangle(it->pixmap, box->style->white_gc,
+ FALSE, x, y, w, h);
+#endif
+}
+
+
+static void rt_tile_expose(RendererTiles *rt, ImageTile *it,
+ gint x, gint y, gint w, gint h,
+ gboolean new_data, gboolean fast)
+{
+ PixbufRenderer *pr = rt->pr;
+ GtkWidget *box;
+
+ /* clamp to visible */
+ if (it->x + x < rt->x_scroll)
+ {
+ w -= rt->x_scroll - it->x - x;
+ x = rt->x_scroll - it->x;
+ }
+ if (it->x + x + w > rt->x_scroll + pr->vis_width)
+ {
+ w = rt->x_scroll + pr->vis_width - it->x - x;
+ }
+ if (w < 1) return;
+ if (it->y + y < rt->y_scroll)
+ {
+ h -= rt->y_scroll - it->y - y;
+ y = rt->y_scroll - it->y;
+ }
+ if (it->y + y + h > rt->y_scroll + pr->vis_height)
+ {
+ h = rt->y_scroll + pr->vis_height - it->y - y;
+ }
+ if (h < 1) return;
+
+ rt_tile_render(rt, it, x, y, w, h, new_data, fast);
+
+ box = GTK_WIDGET(pr);
+
+#if GTK_CHECK_VERSION(2,20,0)
+ gdk_draw_drawable(box->window, box->style->fg_gc[gtk_widget_get_state(box)],
+#else
+ gdk_draw_drawable(box->window, box->style->fg_gc[GTK_WIDGET_STATE(box)],
+#endif
+ it->pixmap, x, y,
+ pr->x_offset + (it->x - rt->x_scroll) + x + rt->stereo_off_x, pr->y_offset + (it->y - rt->y_scroll) + y + rt->stereo_off_y, w, h);
+
+ if (rt->overlay_list)
+ {
+ rt_overlay_draw(rt, pr->x_offset + (it->x - rt->x_scroll) + x,
+ pr->y_offset + (it->y - rt->y_scroll) + y,
+ w, h,
+ it);
+ }
+}
+
+
+static gboolean rt_tile_is_visible(RendererTiles *rt, ImageTile *it)
+{
+ PixbufRenderer *pr = rt->pr;
+ return (it->x + it->w >= rt->x_scroll && it->x < rt->x_scroll + pr->vis_width &&
+ it->y + it->h >= rt->y_scroll && it->y < rt->y_scroll + pr->vis_height);
+}
+
+/*
+ *-------------------------------------------------------------------
+ * draw queue
+ *-------------------------------------------------------------------
+ */
+
+static gint rt_get_queued_area(GList *work)
+{
+ gint area = 0;
+
+ while (work)
+ {
+ QueueData *qd = work->data;
+ area += qd->w * qd->h;
+ work = work->next;
+ }
+ return area;
+}
+
+
+static gboolean rt_queue_schedule_next_draw(RendererTiles *rt, gboolean force_set)
+{
+ PixbufRenderer *pr = rt->pr;
+ gfloat percent;
+ gint visible_area = pr->vis_width * pr->vis_height;
+
+ if (!pr->loading)
+ {
+ /* 2pass prio */
+ DEBUG_2("redraw priority: 2pass");
+ rt->draw_idle_id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, rt_queue_draw_idle_cb, rt, NULL);
+ return FALSE;
+ }
+
+ if (visible_area == 0)
+ {
+ /* not known yet */
+ percent = 100.0;
+ }
+ else
+ {
+ percent = 100.0 * rt_get_queued_area(rt->draw_queue) / visible_area;
+ }
+
+ if (percent > 10.0)
+ {
+ /* we have enough data for starting intensive redrawing */
+ DEBUG_2("redraw priority: high %.2f %%", percent);
+ rt->draw_idle_id = g_idle_add_full(GDK_PRIORITY_REDRAW, rt_queue_draw_idle_cb, rt, NULL);
+ return FALSE;
+ }
+
+ if (percent < 1.0 || force_set)
+ {
+ /* queue is (almost) empty, wait 50 ms*/
+ DEBUG_2("redraw priority: wait %.2f %%", percent);
+ rt->draw_idle_id = g_timeout_add_full(G_PRIORITY_DEFAULT_IDLE, 50, rt_queue_draw_idle_cb, rt, NULL);
+ return FALSE;
+ }
+
+ /* keep the same priority as before */
+ DEBUG_2("redraw priority: no change %.2f %%", percent);
+ return TRUE;
+}
+
+
+static gboolean rt_queue_draw_idle_cb(gpointer data)
+{
+ RendererTiles *rt = data;
+ PixbufRenderer *pr = rt->pr;
+ QueueData *qd;
+ gboolean fast;
+
+
+ if ((!pr->pixbuf && !pr->source_tiles_enabled) ||
+ (!rt->draw_queue && !rt->draw_queue_2pass) ||
+ !rt->draw_idle_id)
+ {
+ pr_render_complete_signal(pr);
+
+ rt->draw_idle_id = 0;
+ return FALSE;
+ }
+
+ if (rt->draw_queue)
+ {
+ qd = rt->draw_queue->data;
+ fast = (pr->zoom_2pass && ((pr->zoom_quality != GDK_INTERP_NEAREST && pr->scale != 1.0) || pr->post_process_slow));
+ }
+ else
+ {
+ if (pr->loading)
+ {
+ /* still loading, wait till done (also drops the higher priority) */
+
+ return rt_queue_schedule_next_draw(rt, FALSE);
+ }
+
+ qd = rt->draw_queue_2pass->data;
+ fast = FALSE;
+ }
+
+#if GTK_CHECK_VERSION(2,20,0)
+ if (gtk_widget_get_realized(pr))
+#else
+ if (GTK_WIDGET_REALIZED(pr))
+#endif
+ {
+ if (rt_tile_is_visible(rt, qd->it))
+ {
+ rt_tile_expose(rt, qd->it, qd->x, qd->y, qd->w, qd->h, qd->new_data, fast);
+ }
+ else if (qd->new_data)
+ {
+ /* if new pixel data, and we already have a pixmap, update the tile */
+ qd->it->blank = FALSE;
+ if (qd->it->pixmap && qd->it->render_done == TILE_RENDER_ALL)
+ {
+ rt_tile_render(rt, qd->it, qd->x, qd->y, qd->w, qd->h, qd->new_data, fast);
+ }
+ }
+ }
+
+ if (rt->draw_queue)
+ {
+ qd->it->qd = NULL;
+ rt->draw_queue = g_list_remove(rt->draw_queue, qd);
+ if (fast)
+ {
+ if (qd->it->qd2)
+ {
+ rt_queue_merge(qd->it->qd2, qd);
+ g_free(qd);
+ }
+ else
+ {
+ qd->it->qd2 = qd;
+ rt->draw_queue_2pass = g_list_append(rt->draw_queue_2pass, qd);
+ }
+ }
+ else
+ {
+ g_free(qd);
+ }
+ }
+ else
+ {
+ qd->it->qd2 = NULL;
+ rt->draw_queue_2pass = g_list_remove(rt->draw_queue_2pass, qd);
+ g_free(qd);
+ }
+
+ if (!rt->draw_queue && !rt->draw_queue_2pass)
+ {
+ pr_render_complete_signal(pr);
+
+ rt->draw_idle_id = 0;
+ return FALSE;
+ }
+
+ return rt_queue_schedule_next_draw(rt, FALSE);
+}
+
+static void rt_queue_list_free(GList *list)
+{
+ GList *work;
+
+ work = list;
+ while (work)
+ {
+ QueueData *qd;
+
+ qd = work->data;
+ work = work->next;
+
+ qd->it->qd = NULL;
+ qd->it->qd2 = NULL;
+ g_free(qd);
+ }
+
+ g_list_free(list);
+}
+
+static void rt_queue_clear(RendererTiles *rt)
+{
+ rt_queue_list_free(rt->draw_queue);
+ rt->draw_queue = NULL;
+
+ rt_queue_list_free(rt->draw_queue_2pass);
+ rt->draw_queue_2pass = NULL;
+
+ if (rt->draw_idle_id)
+ {
+ g_source_remove(rt->draw_idle_id);
+ rt->draw_idle_id = 0;
+ }
+ rt_sync_scroll(rt);
+}
+
+static void rt_queue_merge(QueueData *parent, QueueData *qd)
+{
+ if (parent->x + parent->w < qd->x + qd->w)
+ {
+ parent->w += (qd->x + qd->w) - (parent->x + parent->w);
+ }
+ if (parent->x > qd->x)
+ {
+ parent->w += parent->x - qd->x;
+ parent->x = qd->x;
+ }
+
+ if (parent->y + parent->h < qd->y + qd->h)
+ {
+ parent->h += (qd->y + qd->h) - (parent->y + parent->h);
+ }
+ if (parent->y > qd->y)
+ {
+ parent->h += parent->y - qd->y;
+ parent->y = qd->y;
+ }
+
+ parent->new_data |= qd->new_data;
+}
+
+static gboolean rt_clamp_to_visible(RendererTiles *rt, gint *x, gint *y, gint *w, gint *h)
+{
+ PixbufRenderer *pr = rt->pr;
+ gint nx, ny;
+ gint nw, nh;
+ gint vx, vy;
+ gint vw, vh;
+
+ vw = pr->vis_width;
+ vh = pr->vis_height;
+
+ vx = rt->x_scroll;
+ vy = rt->y_scroll;
+
+ if (*x + *w < vx || *x > vx + vw || *y + *h < vy || *y > vy + vh) return FALSE;
+
+ /* now clamp it */
+ nx = CLAMP(*x, vx, vx + vw);
+ nw = CLAMP(*w - (nx - *x), 1, vw);
+
+ ny = CLAMP(*y, vy, vy + vh);
+ nh = CLAMP(*h - (ny - *y), 1, vh);
+
+ *x = nx;
+ *y = ny;
+ *w = nw;
+ *h = nh;
+
+ return TRUE;
+}
+
+static gboolean rt_queue_to_tiles(RendererTiles *rt, gint x, gint y, gint w, gint h,
+ gboolean clamp, ImageRenderType render,
+ gboolean new_data, gboolean only_existing)
+{
+ PixbufRenderer *pr = rt->pr;
+ gint i, j;
+ gint x1, x2;
+ gint y1, y2;
+
+ if (clamp && !rt_clamp_to_visible(rt, &x, &y, &w, &h)) return FALSE;
+
+ x1 = ROUND_DOWN(x, rt->tile_width);
+ x2 = ROUND_UP(x + w, rt->tile_width);
+
+ y1 = ROUND_DOWN(y, rt->tile_height);
+ y2 = ROUND_UP(y + h, rt->tile_height);
+
+ for (j = y1; j <= y2; j += rt->tile_height)
+ {
+ for (i = x1; i <= x2; i += rt->tile_width)
+ {
+ ImageTile *it;
+
+ it = rt_tile_get(rt, i, j,
+ (only_existing &&
+ (i + rt->tile_width < rt->x_scroll ||
+ i > rt->x_scroll + pr->vis_width ||
+ j + rt->tile_height < rt->y_scroll ||
+ j > rt->y_scroll + pr->vis_height)));
+ if (it)
+ {
+ QueueData *qd;
+
+ if ((render == TILE_RENDER_ALL && it->render_done != TILE_RENDER_ALL) ||
+ (render == TILE_RENDER_AREA && it->render_todo != TILE_RENDER_ALL))
+ {
+ it->render_todo = render;
+ }
+
+ qd = g_new(QueueData, 1);
+ qd->it = it;
+ qd->new_data = new_data;
+
+ if (i < x)
+ {
+ qd->x = x - i;
+ }
+ else
+ {
+ qd->x = 0;
+ }
+ qd->w = x + w - i - qd->x;
+ if (qd->x + qd->w > rt->tile_width) qd->w = rt->tile_width - qd->x;
+
+ if (j < y)
+ {
+ qd->y = y - j;
+ }
+ else
+ {
+ qd->y = 0;
+ }
+ qd->h = y + h - j - qd->y;
+ if (qd->y + qd->h > rt->tile_height) qd->h = rt->tile_height - qd->y;
+
+ if (qd->w < 1 || qd->h < 1)
+ {
+ g_free(qd);
+ }
+ else if (it->qd)
+ {
+ rt_queue_merge(it->qd, qd);
+ g_free(qd);
+ }
+ else
+ {
+ it->qd = qd;
+ rt->draw_queue = g_list_append(rt->draw_queue, qd);
+ }
+ }
+ }
+ }
+
+ return TRUE;
+}
+
+static void rt_queue(RendererTiles *rt, gint x, gint y, gint w, gint h,
+ gboolean clamp, ImageRenderType render,
+ gboolean new_data, gboolean only_existing)
+{
+ PixbufRenderer *pr = rt->pr;
+ gint nx, ny;
+
+ rt_sync_scroll(rt);
+
+ nx = CLAMP(x, 0, pr->width - 1);
+ ny = CLAMP(y, 0, pr->height - 1);
+ w -= (nx - x);
+ h -= (ny - y);
+ w = CLAMP(w, 0, pr->width - nx);
+ h = CLAMP(h, 0, pr->height - ny);
+ if (w < 1 || h < 1) return;
+
+ if (rt_queue_to_tiles(rt, nx, ny, w, h, clamp, render, new_data, only_existing) &&
+ ((!rt->draw_queue && !rt->draw_queue_2pass) || !rt->draw_idle_id))
+ {
+ if (rt->draw_idle_id)
+ {
+ g_source_remove(rt->draw_idle_id);
+ rt->draw_idle_id = 0;
+ }
+ rt_queue_schedule_next_draw(rt, TRUE);
+ }
+}
+
+static void rt_scroll(RendererTiles *rt, gint x_off, gint y_off)
+{
+ PixbufRenderer *pr = rt->pr;
+
+ rt_sync_scroll(rt);
+ if (rt->stereo_mode & PR_STEREO_MIRROR) x_off = -x_off;
+ if (rt->stereo_mode & PR_STEREO_FLIP) y_off = -y_off;
+
+ gint w = pr->vis_width - abs(x_off);
+ gint h = pr->vis_height - abs(y_off);
+
+ if (w < 1 || h < 1)
+ {
+ /* scrolled completely to new material */
+ rt_queue(rt, 0, 0, pr->width, pr->height, TRUE, TILE_RENDER_ALL, FALSE, FALSE);
+ return;
+ }
+ else
+ {
+ gint x1, y1;
+ gint x2, y2;
+ GtkWidget *box;
+ GdkGC *gc;
+ GdkEvent *event;
+
+ if (x_off < 0)
+ {
+ x1 = abs(x_off);
+ x2 = 0;
+ }
+ else
+ {
+ x1 = 0;
+ x2 = abs(x_off);
+ }
+
+ if (y_off < 0)
+ {
+ y1 = abs(y_off);
+ y2 = 0;
+ }
+ else
+ {
+ y1 = 0;
+ y2 = abs(y_off);
+ }
+
+ box = GTK_WIDGET(pr);
+
+ gc = gdk_gc_new(box->window);
+ gdk_gc_set_exposures(gc, TRUE);
+ gdk_draw_drawable(box->window, gc,
+ box->window,
+ x2 + pr->x_offset + rt->stereo_off_x, y2 + pr->y_offset + rt->stereo_off_y,
+ x1 + pr->x_offset + rt->stereo_off_x, y1 + pr->y_offset + rt->stereo_off_y, w, h);
+ g_object_unref(gc);
+
+ rt_overlay_queue_all(rt, x2, y2, x1, y1);
+
+ w = pr->vis_width - w;
+ h = pr->vis_height - h;
+
+ if (w > 0)
+ {
+ rt_queue(rt,
+ x_off > 0 ? rt->x_scroll + (pr->vis_width - w) : rt->x_scroll, rt->y_scroll,
+ w, pr->vis_height, TRUE, TILE_RENDER_ALL, FALSE, FALSE);
+ }
+ if (h > 0)
+ {
+ /* FIXME, to optimize this, remove overlap */
+ rt_queue(rt,
+ rt->x_scroll, y_off > 0 ? rt->y_scroll + (pr->vis_height - h) : rt->y_scroll,
+ pr->vis_width, h, TRUE, TILE_RENDER_ALL, FALSE, FALSE);
+ }
+
+ /* process exposures here, "expose_event" seems to miss a few with obstructed windows */
+#if ! GTK_CHECK_VERSION(2,18,0)
+ while ((event = gdk_event_get_graphics_expose(box->window)) != NULL)
+ {
+ renderer_redraw((void *) rt, event->expose.area.x, event->expose.area.y, event->expose.area.width, event->expose.area.height,
+ FALSE, TILE_RENDER_ALL, FALSE, FALSE);
+
+ if (event->expose.count == 0)
+ {
+ gdk_event_free(event);
+ break;
+ }
+ gdk_event_free(event);
+ }
+#endif
+ }
+}
+
+static void renderer_area_changed(void *renderer, gint src_x, gint src_y, gint src_w, gint src_h)
+{
+ RendererTiles *rt = (RendererTiles *)renderer;
+ PixbufRenderer *pr = rt->pr;
+ gint x, y, width, height, x1, y1, x2, y2;
+
+ gint orientation = rt_get_orientation(rt);
+ pr_coords_map_orientation_reverse(orientation,
+ src_x - GET_RIGHT_PIXBUF_OFFSET(rt), src_y,
+ pr->image_width, pr->image_height,
+ src_w, src_h,
+ &x, &y,
+ &width, &height);
+
+ if (pr->scale != 1.0 && pr->zoom_quality != GDK_INTERP_NEAREST)
+ {
+ /* increase region when using a zoom quality that may access surrounding pixels */
+ y -= 1;
+ height += 2;
+ }
+
+ x1 = (gint)floor((gdouble)x * pr->scale);
+ y1 = (gint)floor((gdouble)y * pr->scale * pr->aspect_ratio);
+ x2 = (gint)ceil((gdouble)(x + width) * pr->scale);
+ y2 = (gint)ceil((gdouble)(y + height) * pr->scale * pr->aspect_ratio);
+
+ rt_queue(rt, x1, y1, x2 - x1, y2 - y1, FALSE, TILE_RENDER_AREA, TRUE, TRUE);
+}
+
+static void renderer_redraw(void *renderer, gint x, gint y, gint w, gint h,
+ gint clamp, ImageRenderType render, gboolean new_data, gboolean only_existing)
+{
+ RendererTiles *rt = (RendererTiles *)renderer;
+ PixbufRenderer *pr = rt->pr;
+
+ x -= rt->stereo_off_x;
+ y -= rt->stereo_off_y;
+
+ rt_border_draw(rt, x, y, w, h);
+
+ x = MAX(0, x - pr->x_offset + pr->x_scroll);
+ y = MAX(0, y - pr->y_offset + pr->y_scroll);
+
+ rt_queue(rt,
+ x, y,
+ MIN(w, pr->width - x),
+ MIN(h, pr->height - y),
+ clamp, render, new_data, only_existing);
+}
+
+static void renderer_queue_clear(void *renderer)
+{
+ rt_queue_clear((RendererTiles *)renderer);
+}
+
+static void renderer_border_clear(void *renderer)
+{
+ rt_border_clear((RendererTiles *)renderer);
+}
+
+
+static void renderer_invalidate_all(void *renderer)
+{
+ rt_tile_invalidate_all((RendererTiles *)renderer);
+}
+
+static void renderer_invalidate_region(void *renderer, gint x, gint y, gint w, gint h)
+{
+ rt_tile_invalidate_region((RendererTiles *)renderer, x, y, w, h);
+}
+
+static void renderer_overlay_draw(void *renderer, gint x, gint y, gint w, gint h)
+{
+ rt_overlay_draw((RendererTiles *)renderer, x, y, w, h, NULL);
+}
+
+static void renderer_update_sizes(void *renderer)
+{
+ RendererTiles *rt = (RendererTiles *)renderer;
+
+ rt->stereo_off_x = 0;
+ rt->stereo_off_y = 0;
+
+ if (rt->stereo_mode & PR_STEREO_RIGHT)
+ {
+ if (rt->stereo_mode & PR_STEREO_HORIZ)
+ {
+ rt->stereo_off_x = rt->pr->viewport_width;
+ }
+ else if (rt->stereo_mode & PR_STEREO_VERT)
+ {
+ rt->stereo_off_y = rt->pr->viewport_height;
+ }
+ else if (rt->stereo_mode & PR_STEREO_FIXED)
+ {
+ rt->stereo_off_x = rt->pr->stereo_fixed_x_right;
+ rt->stereo_off_y = rt->pr->stereo_fixed_y_right;
+ }
+ }
+ else
+ {
+ if (rt->stereo_mode & PR_STEREO_FIXED)
+ {
+ rt->stereo_off_x = rt->pr->stereo_fixed_x_left;
+ rt->stereo_off_y = rt->pr->stereo_fixed_y_left;
+ }
+ }
+ DEBUG_1("update size: %p %d %d %d %d", rt, rt->stereo_off_x, rt->stereo_off_y, rt->pr->viewport_width, rt->pr->viewport_height);
+ rt_sync_scroll(rt);
+ rt_overlay_update_sizes(rt);
+}
+
+static void renderer_stereo_set(void *renderer, gint stereo_mode)
+{
+ RendererTiles *rt = (RendererTiles *)renderer;
+
+ rt->stereo_mode = stereo_mode;
+}
+
+static void renderer_free(void *renderer)
+{
+ RendererTiles *rt = (RendererTiles *)renderer;
+ rt_queue_clear(rt);
+ rt_tile_free_all(rt);
+ if (rt->spare_tile) g_object_unref(rt->spare_tile);
+ if (rt->overlay_buffer) g_object_unref(rt->overlay_buffer);
+ rt_overlay_list_clear(rt);
+ /* disconnect "hierarchy-changed" */
+ g_signal_handlers_disconnect_matched(G_OBJECT(rt->pr), G_SIGNAL_MATCH_DATA,
+ 0, 0, 0, NULL, rt);
+ g_free(rt);
+}
+
+RendererFuncs *renderer_tiles_new(PixbufRenderer *pr)
+{
+ RendererTiles *rt = g_new0(RendererTiles, 1);
+
+ rt->pr = pr;
+
+ rt->f.redraw = renderer_redraw;
+ rt->f.area_changed = renderer_area_changed;
+ rt->f.queue_clear = renderer_queue_clear;
+ rt->f.border_clear = renderer_border_clear;
+ rt->f.free = renderer_free;
+ rt->f.invalidate_all = renderer_invalidate_all;
+ rt->f.invalidate_region = renderer_invalidate_region;
+ rt->f.scroll = rt_scroll;
+ rt->f.update_sizes = renderer_update_sizes;
+
+
+ rt->f.overlay_add = renderer_tiles_overlay_add;
+ rt->f.overlay_set = renderer_tiles_overlay_set;
+ rt->f.overlay_get = renderer_tiles_overlay_get;
+ rt->f.overlay_draw = renderer_overlay_draw;
+
+ rt->f.stereo_set = renderer_stereo_set;
+
+ rt->tile_width = PR_TILE_SIZE;
+ rt->tile_height = PR_TILE_SIZE;
+
+ rt->tiles = NULL;
+ rt->tile_cache_size = 0;
+
+ rt->tile_cache_max = PR_CACHE_SIZE_DEFAULT;
+
+ rt->draw_idle_id = 0;
+
+ rt->stereo_mode = 0;
+ rt->stereo_off_x = 0;
+ rt->stereo_off_y = 0;
+
+ g_signal_connect(G_OBJECT(pr), "hierarchy-changed",
+ G_CALLBACK(rt_hierarchy_changed_cb), rt);
+
+ return (RendererFuncs *) rt;
+}
+
+
+/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
--- /dev/null
+/*
+ * Geeqie
+ * (C) 2006 John Ellis
+ * Copyright (C) 2008 - 2010 The Geeqie Team
+ *
+ * Author: John Ellis
+ *
+ * This software is released under the GNU General Public License (GNU GPL).
+ * Please read the included file COPYING for more information.
+ * This software comes with no warranty of any kind, use at your own risk!
+ */
+
+#ifndef RENDERER_TILES_H
+#define RENDERER_TILES_H
+
+#include <gtk/gtkeventbox.h>
+#include <gtk/gtkwindow.h>
+
+#include <pixbuf-renderer.h>
+
+
+RendererFuncs *renderer_tiles_new(PixbufRenderer *pr);
+
+#endif
+/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
path = fd->path + strlen(sd->search_dir_fd->path);
if (path != fd->path)
{
- FileData *dir_fd = file_data_new_simple(path);
+ FileData *dir_fd = file_data_new_dir(path);
success = filelist_read(dir_fd, &list, NULL);
file_data_unref(dir_fd);
}
sd->search_similarity_cd = cache_sim_data_new();
}
- sd->img_loader = image_loader_new(file_data_new_simple(sd->search_similarity_path));
+ sd->img_loader = image_loader_new(file_data_new_group(sd->search_similarity_path));
g_signal_connect(G_OBJECT(sd->img_loader), "error", (GCallback)search_similarity_load_done_cb, sd);
g_signal_connect(G_OBJECT(sd->img_loader), "done", (GCallback)search_similarity_load_done_cb, sd);
if (image_loader_start(sd->img_loader))
if (isdir(path))
{
file_data_unref(sd->search_dir_fd);
- sd->search_dir_fd = file_data_new_simple(path);
+ sd->search_dir_fd = file_data_new_dir(path);
tab_completion_append_to_history(sd->path_entry, sd->search_dir_fd->path);
{
/* search metadata */
file_data_unref(sd->search_dir_fd);
- sd->search_dir_fd = file_data_new_simple(get_metadata_cache_dir());
+ sd->search_dir_fd = file_data_new_dir(get_metadata_cache_dir());
search_start(sd);
}
else if (sd->search_type == SEARCH_MATCH_CONTAINS)
static void thumb_loader_error_cb(ImageLoader *il, gpointer data);
-static void thumb_loader_setup(ThumbLoader *tl, const gchar *path);
+static void thumb_loader_setup(ThumbLoader *tl, FileData *fd);
static GdkPixbuf *get_xv_thumbnail(gchar *thumb_filename, gint max_w, gint max_h);
DEBUG_1("thumbnail size mismatch, regenerating: %s", tl->fd->path);
tl->cache_hit = FALSE;
- thumb_loader_setup(tl, tl->fd->path);
+ thumb_loader_setup(tl, tl->fd);
g_signal_connect(G_OBJECT(tl->il), "done", (GCallback)thumb_loader_done_cb, tl);
if (!tl->idle_done_id) tl->idle_done_id = g_idle_add(thumb_loader_done_delay_cb, tl);
}
-static void thumb_loader_setup(ThumbLoader *tl, const gchar *path)
+static void thumb_loader_setup(ThumbLoader *tl, FileData *fd)
{
- FileData *fd = file_data_new_simple(path);
image_loader_free(tl->il);
tl->il = image_loader_new(fd);
- file_data_unref(fd);
image_loader_set_priority(tl->il, G_PRIORITY_LOW);
/* this will speed up jpegs by up to 3x in some cases */
if (cache_path)
{
- thumb_loader_setup(tl, cache_path);
+ FileData *fd = file_data_new_no_grouping(cache_path);
+ thumb_loader_setup(tl, fd);
+ file_data_unref(fd);
g_free(cache_path);
tl->cache_hit = TRUE;
}
else
{
- thumb_loader_setup(tl, tl->fd->path);
+ thumb_loader_setup(tl, tl->fd);
}
g_signal_connect(G_OBJECT(tl->il), "done", (GCallback)thumb_loader_done_cb, tl);
tl->cache_hit = FALSE;
log_printf("%s", _("Thumbnail image in cache failed to load, trying to recreate.\n"));
- thumb_loader_setup(tl, tl->fd->path);
+ thumb_loader_setup(tl, tl->fd);
g_signal_connect(G_OBJECT(tl->il), "done", (GCallback)thumb_loader_done_cb, tl);
if (image_loader_start(tl->il)) return TRUE;
}
static void thumb_loader_std_error_cb(ImageLoader *il, gpointer data);
static gint thumb_loader_std_setup(ThumbLoaderStd *tl, FileData *fd);
-static gint thumb_loader_std_setup_path(ThumbLoaderStd *tl, const gchar *path);
ThumbLoaderStd *thumb_loader_std_new(gint width, gint height)
if (!tl->thumb_path_local)
{
tl->thumb_path = thumb_loader_std_cache_path(tl, TRUE, NULL, FALSE);
- if (isfile(tl->thumb_path) && thumb_loader_std_setup_path(tl, tl->thumb_path))
+ if (isfile(tl->thumb_path))
{
- tl->thumb_path_local = TRUE;
- return TRUE;
+ FileData *fd = file_data_new_no_grouping(tl->thumb_path);
+ if (thumb_loader_std_setup(tl, fd))
+ {
+ file_data_unref(fd);
+ tl->thumb_path_local = TRUE;
+ return TRUE;
+ }
+ file_data_unref(fd);
}
g_free(tl->thumb_path);
return FALSE;
}
-static gboolean thumb_loader_std_setup_path(ThumbLoaderStd *tl, const gchar *path)
-{
- FileData *fd = file_data_new_simple(path);
- gboolean ret = thumb_loader_std_setup(tl, fd);
- file_data_unref(fd);
- return ret;
-}
-
/*
* Note: Currently local_cache only specifies where to save a _new_ thumb, if
* a valid existing thumb is found anywhere the local thumb will not be created.
tl->thumb_path_local = FALSE;
found = isfile(tl->thumb_path);
- if (found && thumb_loader_std_setup_path(tl, tl->thumb_path)) return TRUE;
+ if (found)
+ {
+ FileData *fd = file_data_new_no_grouping(tl->thumb_path);
+ if (thumb_loader_std_setup(tl, fd))
+ {
+ file_data_unref(fd);
+ return TRUE;
+ }
+ file_data_unref(fd);
+ }
if (thumb_loader_std_fail_check(tl) ||
!thumb_loader_std_next_source(tl, found))
tv->func_valid = func_valid;
tv->data = data;
- if (!thumb_loader_std_setup_path(tv->tl, thumb_path))
+ FileData *fd = file_data_new_no_grouping(thumb_path);
+ if (!thumb_loader_std_setup(tv->tl, fd))
{
tv->idle_id = g_idle_add(thumb_loader_std_thumb_file_validate_idle_cb, tv);
}
tv->idle_id = 0;
}
+ file_data_unref(fd);
return tv->tl;
}
tm->tl->cache_enable = TRUE;
tm->tl->cache_hit = FALSE;
tm->tl->cache_local = FALSE;
-
file_data_unref(tm->tl->fd);
- tm->tl->fd = file_data_new_simple(tm->dest);
+ tm->tl->fd = file_data_new_group(tm->dest);
tm->tl->source_mtime = strtol(mtime_str, NULL, 10);
pathl = path_from_utf8(tm->tl->fd->path);
gboolean warned = FALSE;
FileData *dir_fd;
- dir_fd = file_data_new_simple(options->file_ops.safe_delete_path);
+ dir_fd = file_data_new_dir(options->file_ops.safe_delete_path);
if (!filelist_read(dir_fd, &list, NULL))
{
file_data_unref(dir_fd);
TOOLBAR_COUNT
} ToolbarType;
+typedef enum {
+ PR_STEREO_NONE = 0, /* do nothing */
+ PR_STEREO_DUAL = 1 << 0, /* independent stereo buffers, for example nvidia opengl */
+ PR_STEREO_FIXED = 1 << 1, /* custom position */
+ PR_STEREO_HORIZ = 1 << 2, /* side by side */
+ PR_STEREO_VERT = 1 << 3, /* above below */
+ PR_STEREO_RIGHT = 1 << 4, /* render right buffer */
+ PR_STEREO_ANAGLYPH_RC = 1 << 5, /* anaglyph red-cyan */
+ PR_STEREO_ANAGLYPH_GRAY = 1 << 6, /* anaglyph gray red-cyan*/
+ PR_STEREO_ANAGLYPH_DB = 1 << 7, /* anaglyph dubois*/
+ PR_STEREO_ANAGLYPH = PR_STEREO_ANAGLYPH_RC | PR_STEREO_ANAGLYPH_GRAY | PR_STEREO_ANAGLYPH_DB, /* anaglyph mask */
+
+ PR_STEREO_MIRROR_LEFT = 1 << 8, /* mirror */
+ PR_STEREO_FLIP_LEFT = 1 << 9, /* flip */
+
+ PR_STEREO_MIRROR_RIGHT = 1 << 10, /* mirror */
+ PR_STEREO_FLIP_RIGHT = 1 << 11, /* flip */
+
+ PR_STEREO_MIRROR = PR_STEREO_MIRROR_LEFT | PR_STEREO_MIRROR_RIGHT, /* mirror mask*/
+ PR_STEREO_FLIP = PR_STEREO_FLIP_LEFT | PR_STEREO_FLIP_RIGHT, /* flip mask*/
+ PR_STEREO_SWAP = 1 << 12, /* swap left and right buffers */
+ PR_STEREO_TEMP_DISABLE = 1 << 13, /* temporarily disable stereo mode if source image is not stereo */
+ PR_STEREO_HALF = 1 << 14
+} PixbufRendererStereoMode;
+
+typedef enum {
+ STEREO_PIXBUF_DEFAULT = 0,
+ STEREO_PIXBUF_SBS = 1,
+ STEREO_PIXBUF_CROSS = 2,
+ STEREO_PIXBUF_NONE = 3
+} StereoPixbufData;
+
#define MAX_SPLIT_IMAGES 4
typedef struct _ImageLoader ImageLoader;
gboolean delay_flip;
gint orientation;
gboolean desaturate;
+ gint user_stereo;
};
#define FILEDATA_MARKS_SIZE 6
gint64 size;
time_t date;
mode_t mode; /* this is needed at least for notification in view_dir because it is preserved after the file/directory is deleted */
+ gint sidecar_priority;
guint marks; /* each bit represents one mark */
guint valid_marks; /* zero bit means that the corresponding mark needs to be reread */
ExifData *exif;
GHashTable *modified_xmp; // hash table which contains unwritten xmp metadata in format: key->list of string values
+ GList *cached_metadata;
};
struct _LayoutOptions
/* set the dest file attributes to that of source (ignoring errors) */
- if (perms && chown(tl, st.st_uid, st.st_gid) < 0) ret = FALSE;
- if (perms && chmod(tl, st.st_mode) < 0) ret = FALSE;
+ if (perms)
+ {
+ ret = chown(tl, st.st_uid, st.st_gid);
+ /* Ignores chown errors, while still doing chown
+ (so root still can copy files preserving ownership) */
+ ret = TRUE;
+ if (chmod(tl, st.st_mode) < 0) ret = FALSE;
+ }
tb.actime = st.st_atime;
tb.modtime = st.st_mtime;
return spin;
}
+GtkWidget *pref_table_spin_new_int(GtkWidget *table, gint column, gint row,
+ const gchar *text, const gchar *suffix,
+ gint min, gint max, gint step,
+ gint value, gint *value_var)
+{
+ *value_var = value;
+ return pref_table_spin(table, column, row,
+ text, suffix,
+ (gdouble)min, (gdouble)max, (gdouble)step, 0,
+ value,
+ G_CALLBACK(pref_spin_int_cb), value_var);
+}
+
+
#if ! GTK_CHECK_VERSION(2,12,0)
static void pref_toolbar_destroy_cb(GtkWidget *widget, gpointer data)
gdouble value,
GCallback func, gpointer data);
+GtkWidget *pref_table_spin_new_int(GtkWidget *table, gint column, gint row,
+ const gchar *text, const gchar *suffix,
+ gint min, gint max, gint step,
+ gint value, gint *value_var);
+
GtkWidget *pref_toolbar_new(GtkWidget *parent_box, GtkToolbarStyle style);
GtkWidget *pref_toolbar_button(GtkWidget *toolbar,
tmp = gtk_entry_get_text(GTK_ENTRY(dd->entry));
if (!isname(tmp))
{
- path = g_strdup(tmp);
+ buf = remove_trailing_slash(tmp);
+ path = g_strdup(buf);
+ g_free(buf);
+ buf = remove_level_from_path(path);
from_text = TRUE;
}
else
GtkListStore *store;
const gchar *text;
- if (from_text) gtk_entry_set_text(GTK_ENTRY(dd->entry), dd->path);
+ if (from_text)
+ {
+ dest_populate(dd, buf);
+ g_free(buf);
+ }
store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(dd->d_view)));
break;
case UTILITY_TYPE_CREATE_FOLDER:
file_data_unref(ud->dir_fd);
- ud->dir_fd = file_data_new_simple(ud->dest_path);
+ ud->dir_fd = file_data_new_dir(ud->dest_path);
break;
case UTILITY_TYPE_DELETE:
case UTILITY_TYPE_DELETE_LINK:
g_free(buf);
}
- ud->dir_fd = file_data_new_simple(ud->dest_path);
+ ud->dir_fd = file_data_new_dir(ud->dest_path);
ud->done_func = done_func;
ud->done_data = done_data;
ViewDir *vd = data;
if (success)
{
- FileData *fd = file_data_new_simple(new_path);
+ FileData *fd = file_data_new_dir(new_path);
GtkTreeIter iter;
if (vd_find_row(vd, fd, &iter))
if (vd->select_func)
{
- FileData *fd = file_data_new_simple(path);
+ FileData *fd = file_data_new_dir(path);
vd->select_func(vd, fd, vd->select_data);
file_data_unref(fd);
}
break;
case DIRVIEW_TREE:
{
- FileData *new_fd = file_data_new_simple(new_path);
+ FileData *new_fd = file_data_new_dir(new_path);
fd = vdtree_populate_path(vd, new_fd, TRUE, TRUE);
file_data_unref(new_fd);
}
if (vd->type == DIRVIEW_TREE)
{
GtkTreeIter iter;
- FileData *base_fd = file_data_new_simple(base);
+ FileData *base_fd = file_data_new_dir(base);
if (vd_find_row(vd, base_fd, &iter))
{
if (strcmp(vd->dir_fd->path, G_DIR_SEPARATOR_S) != 0)
{
filepath = g_build_filename(vd->dir_fd->path, "..", NULL);
- fd = file_data_new_simple(filepath);
+ fd = file_data_new_dir(filepath);
VDLIST(vd)->list = g_list_prepend(VDLIST(vd)->list, fd);
g_free(filepath);
}
if (options->file_filter.show_dot_directory)
{
filepath = g_build_filename(vd->dir_fd->path, ".", NULL);
- fd = file_data_new_simple(filepath);
+ fd = file_data_new_dir(filepath);
VDLIST(vd)->list = g_list_prepend(VDLIST(vd)->list, fd);
g_free(filepath);
}
gboolean vdlist_set_fd(ViewDir *vd, FileData *dir_fd)
{
gboolean ret;
- gchar *old_path = NULL;
+ gchar *old_path = NULL; /* Used to store directory for walking up */
if (!dir_fd) return FALSE;
if (vd->dir_fd == dir_fd) return TRUE;
base = remove_level_from_path(vd->dir_fd->path);
if (strcmp(base, dir_fd->path) == 0)
{
- old_path = g_strdup(vd->dir_fd->name);
+ old_path = g_strdup(filename_from_path(vd->dir_fd->path));
}
g_free(base);
}
{
if (!nd) return;
- file_data_unref(nd->fd);
+ if (nd->fd) file_data_unref(nd->fd);
g_free(nd);
}
NodeData *nd;
gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
- if (strcmp(nd->fd->name, pd->name) == 0)
+ if (nd->fd && strcmp(nd->fd->name, pd->name) == 0)
{
fd = nd->fd;
}
/* all nodes are created with an "empty" node, so that the expander is shown
* this is removed when the child is populated */
end = g_new0(NodeData, 1);
- end->fd = file_data_new_simple("");
+ end->fd = NULL;
end->expanded = TRUE;
gtk_tree_store_append(store, &empty, &child);
if (nd->expanded)
{
- if (!isdir(nd->fd->path))
+ if (!nd->fd || !isdir(nd->fd->path))
{
if (vd->click_fd == nd->fd) vd->click_fd = NULL;
if (vd->drop_fd == nd->fd) vd->drop_fd = NULL;
if (target_fd->path[n] == G_DIR_SEPARATOR && target_fd->path[n+1] == '.')
{
gchar *name8;
- struct stat sbuf;
n++;
while (target_fd->path[n] != '\0' && target_fd->path[n] != G_DIR_SEPARATOR) n++;
name8 = g_strndup(target_fd->path, n);
- if (stat_utf8(name8, &sbuf))
+ if (isdir(name8))
{
- list = g_list_prepend(list, file_data_new_simple(name8));
+ list = g_list_prepend(list, file_data_new_dir(name8));
}
g_free(name8);
gtk_tree_model_get(store, a, DIR_COLUMN_POINTER, &nda, -1);
gtk_tree_model_get(store, b, DIR_COLUMN_POINTER, &ndb, -1);
+ if (!nda->fd && !ndb->fd) return 0;
+ if (!nda->fd) return 1;
+ if (!ndb->fd) return -1;
+
if (options->file_sort.case_sensitive)
return strcmp(nda->fd->collate_key_name, ndb->fd->collate_key_name);
else
FileData *fd;
- fd = file_data_new_simple(path);
+ fd = file_data_new_dir(path);
vdtree_add_by_data(vd, fd, NULL);
vdtree_expand_by_data(vd, fd, TRUE);
else
{
gchar *old_path = g_build_filename(vf->dir_fd->path, old, NULL);
- FileData *fd = file_data_new_simple(old_path); /* get the fd from cache */
+ FileData *fd = file_data_new_group(old_path); /* get the fd from cache */
file_util_rename_simple(fd, new_path, vf->listview);
file_data_unref(fd);
g_free(old_path);