[latex3-commits] [l3svn] 03/03: Cache images with (x)dvipdfmx

noreply at latex-project.org noreply at latex-project.org
Tue May 16 16:50:49 CEST 2017


This is an automated email from the git hooks/post-receive script.

joseph pushed a commit to branch master
in repository l3svn.

commit 5e4d28ae83f642859d04e60ed1a5fbd486658fcc
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue May 16 13:47:45 2017 +0100

    Cache images with (x)dvipdfmx
    
    This is currently not in dvipdfmx.def/xetex.def but is similar to the approach
    taken by pdftex.def. Primitive support is not available, meaning that for XeTeX
    one cannot use \XeTeX(pdf|pic)file here: there is no real benefit at the inclusion
    stage anyway.
    
    Probably this concept could/should be ported back to the 2e drivers: makes smaller
    PDFs for any cases where images are repeated.
---
 l3kernel/l3drivers.dtx                 |   51 ++++++++++++++++++++++++++++----
 l3kernel/testfiles/m3expl001.ptex.tlg  |    7 ++++-
 l3kernel/testfiles/m3expl001.uptex.tlg |    7 ++++-
 l3kernel/testfiles/m3expl001.xetex.tlg |    7 ++++-
 l3kernel/testfiles/m3expl002.ptex.tlg  |    1 +
 l3kernel/testfiles/m3expl002.uptex.tlg |    1 +
 l3kernel/testfiles/m3expl002.xetex.tlg |    1 +
 l3kernel/testfiles/m3expl003.ptex.tlg  |    7 ++++-
 l3kernel/testfiles/m3expl003.uptex.tlg |    7 ++++-
 l3kernel/testfiles/m3expl003.xetex.tlg |    7 ++++-
 l3kernel/testfiles/m3expl004.ptex.tlg  |    1 +
 l3kernel/testfiles/m3expl004.uptex.tlg |    1 +
 l3kernel/testfiles/m3expl004.xetex.tlg |    1 +
 l3kernel/testfiles/m3expl006.ptex.tlg  |    1 +
 l3kernel/testfiles/m3expl006.uptex.tlg |    1 +
 l3kernel/testfiles/m3expl006.xetex.tlg |    1 +
 16 files changed, 91 insertions(+), 11 deletions(-)

diff --git a/l3kernel/l3drivers.dtx b/l3kernel/l3drivers.dtx
index 7940485..5bdb092 100644
--- a/l3kernel/l3drivers.dtx
+++ b/l3kernel/l3drivers.dtx
@@ -950,12 +950,21 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{variable}[aux]{\g_@@_image_int}
+%   Used to track the object number associated with each image.
+%    \begin{macrocode}
+\int_new:N \g_@@_image_int
+%    \end{macrocode}
+% \end{variable}
+%
 % \begin{macro}[int]
 %   {
 %     \@@_image_include_eps:n, \@@_image_include_jpg:n,
 %     \@@_image_include_pdf:n, \@@_image_include_png:n
 %   }
-%  \begin{macro}[aux]{\@@_image_include_aux:nn}
+%  \begin{macro}[aux]{\@@_image_include_auxi:nn}
+%  \begin{macro}[aux]{\@@_image_include_auxii:nnn, \@@_image_include_auxii:xnn}
+%  \begin{macro}[aux]{\@@_image_include_auxiii:nn}
 %  The special syntax depends on the file type.
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_image_include_eps:n #1
@@ -963,15 +972,45 @@
     \tex_special:D { PSfile = #1 }
   }
 \cs_new_protected:Npn \@@_image_include_jpg:n #1
-  { \@@_image_include_aux:nn {#1} { image } }
+  { \@@_image_include_auxi:nn {#1} { image } }
 \cs_new_eq:NN \@@_image_include_png:n \@@_image_include_png:n
 \cs_new_protected:Npn \@@_image_include_pdf:n #1
-  { \@@_image_include_aux:nn {#1} { epdf } }
-\cs_new_protected:Npn \@@_image_include_aux:nn #1#2
+  { \@@_image_include_auxi:nn {#1} { epdf } }
+%    \end{macrocode}
+%   Image inclusion is set up to use the fact that each image is stored in
+%   the PDF as an XObject. This means that we can include repeated images
+%   only once and refer to them. To allow that, track the nature of each
+%   image: much the same as for the direct PDF mode case.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_image_include_auxi:nn #1#2
+  {
+    \@@_image_include_auxii:xnn
+      {
+        \int_compare:nNnT \l__image_page_int > 0
+          { :P \int_use:N \l__image_page_int }
+        \tl_if_empty:NF \l__image_pagebox_tl
+          { : \l__image_pagebox_tl }
+      }
+      {#1} {#2}
+  }
+\cs_new_protected:Npn \@@_image_include_auxii:nnn #1#2#3
+  {
+    \int_if_exist:cTF { c__image_ #2#1 _int }
+      {
+        \tex_special:D
+          { pdf:usexobj~@image \int_use:c { c__image_ #2#1 _int } }
+      }
+      { \@@_image_include_auxiii:nn {#2} {#1} {#3} }
+  }
+\cs_generate_variant:Nn \@@_image_include_auxii:nnn { x }
+\cs_new_protected:Npn \@@_image_include_auxiii:nnn #1#2#3
   {
+    \int_gincr:N \g_@@_image_int
+    \int_const:cn { c__image_ #1#2 _int } { \g_@@_image_int }
     \tex_special:D
       {
-        pdf:#2~
+        pdf:#3~
+        @image \int_use:c { c__image_ #1#2 _int }
         \int_compare:nNnT \l__image_page_int > 0
           { page ~ \int_use:N \l__image_page_int \c_space_tl }
         \tl_if_empty:NF \l__image_pagebox_tl
@@ -982,6 +1021,8 @@
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
+% \end{macro}
+% \end{macro}
 %
 %    \begin{macrocode}
 %</dvipdfmx|xdvipdfmx>
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index 7657f51..939c7d7 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -5022,11 +5022,16 @@ Defining \__driver_image_getbb_eps:n on line ...
 Defining \__driver_image_getbb_jpg:n on line ...
 Defining \__driver_image_getbb_png:n on line ...
 Defining \__driver_image_getbb_pdf:n on line ...
+Defining \g__driver_image_int on line ...
+\g__driver_image_int=\count145
 Defining \__driver_image_include_eps:n on line ...
 Defining \__driver_image_include_jpg:n on line ...
 Defining \__driver_image_include_png:n on line ...
 Defining \__driver_image_include_pdf:n on line ...
-Defining \__driver_image_include_aux:nn on line ...
+Defining \__driver_image_include_auxi:nn on line ...
+Defining \__driver_image_include_auxii:nnn on line ...
+Defining \__driver_image_include_auxii:xnn on line ...
+Defining \__driver_image_include_auxiii:nnn on line ...
 Defining \__driver_draw_literal:n on line ...
 Defining \__driver_draw_literal:x on line ...
 Defining \__driver_draw_begin: on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index d448bf3..b23fe2d 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -5223,11 +5223,16 @@ Defining \__driver_image_getbb_eps:n on line ...
 Defining \__driver_image_getbb_jpg:n on line ...
 Defining \__driver_image_getbb_png:n on line ...
 Defining \__driver_image_getbb_pdf:n on line ...
+Defining \g__driver_image_int on line ...
+\g__driver_image_int=\count145
 Defining \__driver_image_include_eps:n on line ...
 Defining \__driver_image_include_jpg:n on line ...
 Defining \__driver_image_include_png:n on line ...
 Defining \__driver_image_include_pdf:n on line ...
-Defining \__driver_image_include_aux:nn on line ...
+Defining \__driver_image_include_auxi:nn on line ...
+Defining \__driver_image_include_auxii:nnn on line ...
+Defining \__driver_image_include_auxii:xnn on line ...
+Defining \__driver_image_include_auxiii:nnn on line ...
 Defining \__driver_draw_literal:n on line ...
 Defining \__driver_draw_literal:x on line ...
 Defining \__driver_draw_begin: on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index 2c5bfee..8b1f274 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -5029,11 +5029,16 @@ Defining \l__driver_color_current_tl on line ...
 Defining \__driver_color_ensure_current: on line ...
 Defining \__driver_color_reset: on line ...
 Defining \__driver_image_getbb_eps:n on line ...
+Defining \g__driver_image_int on line ...
+\g__driver_image_int=\count144
 Defining \__driver_image_include_eps:n on line ...
 Defining \__driver_image_include_jpg:n on line ...
 Defining \__driver_image_include_png:n on line ...
 Defining \__driver_image_include_pdf:n on line ...
-Defining \__driver_image_include_aux:nn on line ...
+Defining \__driver_image_include_auxi:nn on line ...
+Defining \__driver_image_include_auxii:nnn on line ...
+Defining \__driver_image_include_auxii:xnn on line ...
+Defining \__driver_image_include_auxiii:nnn on line ...
 Defining \__driver_image_getbb_jpg:n on line ...
 Defining \__driver_image_getbb_png:n on line ...
 Defining \__driver_image_getbb_pdf:n on line ...
diff --git a/l3kernel/testfiles/m3expl002.ptex.tlg b/l3kernel/testfiles/m3expl002.ptex.tlg
index 5d811d2..a2b72f2 100644
--- a/l3kernel/testfiles/m3expl002.ptex.tlg
+++ b/l3kernel/testfiles/m3expl002.ptex.tlg
@@ -93,5 +93,6 @@ Don't change this file in any respect.
 \l__coffin_scaled_total_height_dim=\dimen161
 \l__coffin_scaled_width_dim=\dimen162
 ) (l3dvipdfmx.def
+\g__driver_image_int=\count145
 \l__driver_tmp_box=\box71
 ))
diff --git a/l3kernel/testfiles/m3expl002.uptex.tlg b/l3kernel/testfiles/m3expl002.uptex.tlg
index 5d811d2..a2b72f2 100644
--- a/l3kernel/testfiles/m3expl002.uptex.tlg
+++ b/l3kernel/testfiles/m3expl002.uptex.tlg
@@ -93,5 +93,6 @@ Don't change this file in any respect.
 \l__coffin_scaled_total_height_dim=\dimen161
 \l__coffin_scaled_width_dim=\dimen162
 ) (l3dvipdfmx.def
+\g__driver_image_int=\count145
 \l__driver_tmp_box=\box71
 ))
diff --git a/l3kernel/testfiles/m3expl002.xetex.tlg b/l3kernel/testfiles/m3expl002.xetex.tlg
index 17016e8..e57b3cc 100644
--- a/l3kernel/testfiles/m3expl002.xetex.tlg
+++ b/l3kernel/testfiles/m3expl002.xetex.tlg
@@ -93,5 +93,6 @@ Don't change this file in any respect.
 \l__coffin_scaled_total_height_dim=\dimen161
 \l__coffin_scaled_width_dim=\dimen162
 ) (l3xdvipdfmx.def
+\g__driver_image_int=\count144
 \l__driver_tmp_box=\box71
 ))
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index 9327781..60e750a 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -5023,11 +5023,16 @@ Defining \__driver_image_getbb_eps:n on line ...
 Defining \__driver_image_getbb_jpg:n on line ...
 Defining \__driver_image_getbb_png:n on line ...
 Defining \__driver_image_getbb_pdf:n on line ...
+Defining \g__driver_image_int on line ...
+\g__driver_image_int=\count145
 Defining \__driver_image_include_eps:n on line ...
 Defining \__driver_image_include_jpg:n on line ...
 Defining \__driver_image_include_png:n on line ...
 Defining \__driver_image_include_pdf:n on line ...
-Defining \__driver_image_include_aux:nn on line ...
+Defining \__driver_image_include_auxi:nn on line ...
+Defining \__driver_image_include_auxii:nnn on line ...
+Defining \__driver_image_include_auxii:xnn on line ...
+Defining \__driver_image_include_auxiii:nnn on line ...
 Defining \__driver_draw_literal:n on line ...
 Defining \__driver_draw_literal:x on line ...
 Defining \__driver_draw_begin: on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index 89cccd5..b6afbd3 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -5224,11 +5224,16 @@ Defining \__driver_image_getbb_eps:n on line ...
 Defining \__driver_image_getbb_jpg:n on line ...
 Defining \__driver_image_getbb_png:n on line ...
 Defining \__driver_image_getbb_pdf:n on line ...
+Defining \g__driver_image_int on line ...
+\g__driver_image_int=\count145
 Defining \__driver_image_include_eps:n on line ...
 Defining \__driver_image_include_jpg:n on line ...
 Defining \__driver_image_include_png:n on line ...
 Defining \__driver_image_include_pdf:n on line ...
-Defining \__driver_image_include_aux:nn on line ...
+Defining \__driver_image_include_auxi:nn on line ...
+Defining \__driver_image_include_auxii:nnn on line ...
+Defining \__driver_image_include_auxii:xnn on line ...
+Defining \__driver_image_include_auxiii:nnn on line ...
 Defining \__driver_draw_literal:n on line ...
 Defining \__driver_draw_literal:x on line ...
 Defining \__driver_draw_begin: on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index 606670c..1e440d2 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -5030,11 +5030,16 @@ Defining \l__driver_color_current_tl on line ...
 Defining \__driver_color_ensure_current: on line ...
 Defining \__driver_color_reset: on line ...
 Defining \__driver_image_getbb_eps:n on line ...
+Defining \g__driver_image_int on line ...
+\g__driver_image_int=\count144
 Defining \__driver_image_include_eps:n on line ...
 Defining \__driver_image_include_jpg:n on line ...
 Defining \__driver_image_include_png:n on line ...
 Defining \__driver_image_include_pdf:n on line ...
-Defining \__driver_image_include_aux:nn on line ...
+Defining \__driver_image_include_auxi:nn on line ...
+Defining \__driver_image_include_auxii:nnn on line ...
+Defining \__driver_image_include_auxii:xnn on line ...
+Defining \__driver_image_include_auxiii:nnn on line ...
 Defining \__driver_image_getbb_jpg:n on line ...
 Defining \__driver_image_getbb_png:n on line ...
 Defining \__driver_image_getbb_pdf:n on line ...
diff --git a/l3kernel/testfiles/m3expl004.ptex.tlg b/l3kernel/testfiles/m3expl004.ptex.tlg
index 5d811d2..a2b72f2 100644
--- a/l3kernel/testfiles/m3expl004.ptex.tlg
+++ b/l3kernel/testfiles/m3expl004.ptex.tlg
@@ -93,5 +93,6 @@ Don't change this file in any respect.
 \l__coffin_scaled_total_height_dim=\dimen161
 \l__coffin_scaled_width_dim=\dimen162
 ) (l3dvipdfmx.def
+\g__driver_image_int=\count145
 \l__driver_tmp_box=\box71
 ))
diff --git a/l3kernel/testfiles/m3expl004.uptex.tlg b/l3kernel/testfiles/m3expl004.uptex.tlg
index 5d811d2..a2b72f2 100644
--- a/l3kernel/testfiles/m3expl004.uptex.tlg
+++ b/l3kernel/testfiles/m3expl004.uptex.tlg
@@ -93,5 +93,6 @@ Don't change this file in any respect.
 \l__coffin_scaled_total_height_dim=\dimen161
 \l__coffin_scaled_width_dim=\dimen162
 ) (l3dvipdfmx.def
+\g__driver_image_int=\count145
 \l__driver_tmp_box=\box71
 ))
diff --git a/l3kernel/testfiles/m3expl004.xetex.tlg b/l3kernel/testfiles/m3expl004.xetex.tlg
index 17016e8..e57b3cc 100644
--- a/l3kernel/testfiles/m3expl004.xetex.tlg
+++ b/l3kernel/testfiles/m3expl004.xetex.tlg
@@ -93,5 +93,6 @@ Don't change this file in any respect.
 \l__coffin_scaled_total_height_dim=\dimen161
 \l__coffin_scaled_width_dim=\dimen162
 ) (l3xdvipdfmx.def
+\g__driver_image_int=\count144
 \l__driver_tmp_box=\box71
 ))
diff --git a/l3kernel/testfiles/m3expl006.ptex.tlg b/l3kernel/testfiles/m3expl006.ptex.tlg
index 5b14ec1..457751d 100644
--- a/l3kernel/testfiles/m3expl006.ptex.tlg
+++ b/l3kernel/testfiles/m3expl006.ptex.tlg
@@ -94,5 +94,6 @@ Author: Bruno Le Floch and Joseph Wright
 \l__coffin_scaled_total_height_dim=\dimen161
 \l__coffin_scaled_width_dim=\dimen162
 ) (l3dvipdfmx.def
+\g__driver_image_int=\count145
 \l__driver_tmp_box=\box71
 ))
diff --git a/l3kernel/testfiles/m3expl006.uptex.tlg b/l3kernel/testfiles/m3expl006.uptex.tlg
index 5b14ec1..457751d 100644
--- a/l3kernel/testfiles/m3expl006.uptex.tlg
+++ b/l3kernel/testfiles/m3expl006.uptex.tlg
@@ -94,5 +94,6 @@ Author: Bruno Le Floch and Joseph Wright
 \l__coffin_scaled_total_height_dim=\dimen161
 \l__coffin_scaled_width_dim=\dimen162
 ) (l3dvipdfmx.def
+\g__driver_image_int=\count145
 \l__driver_tmp_box=\box71
 ))
diff --git a/l3kernel/testfiles/m3expl006.xetex.tlg b/l3kernel/testfiles/m3expl006.xetex.tlg
index 25a37ef..54ffc7f 100644
--- a/l3kernel/testfiles/m3expl006.xetex.tlg
+++ b/l3kernel/testfiles/m3expl006.xetex.tlg
@@ -94,5 +94,6 @@ Author: Bruno Le Floch and Joseph Wright
 \l__coffin_scaled_total_height_dim=\dimen161
 \l__coffin_scaled_width_dim=\dimen162
 ) (l3xdvipdfmx.def
+\g__driver_image_int=\count144
 \l__driver_tmp_box=\box71
 ))

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the latex3-commits mailing list