[latex3-commits] [git/LaTeX3-latex3-latex3] master: Use stack for opacity with pdfTeX, etc. (612edc517)

Joseph Wright joseph.wright at morningstar2.co.uk
Sun Jan 24 18:11:06 CET 2021


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/612edc5170a34c4cc5ee5385ad023d0d23c80a10

>---------------------------------------------------------------

commit 612edc5170a34c4cc5ee5385ad023d0d23c80a10
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Sun Jan 24 17:10:57 2021 +0000

    Use stack for opacity with pdfTeX, etc.


>---------------------------------------------------------------

612edc5170a34c4cc5ee5385ad023d0d23c80a10
 l3backend/l3backend-opacity.dtx         | 51 +++++++++++++++++++++++++--------
 l3kernel/testfiles/m3expl001.luatex.tlg |  6 ++--
 l3kernel/testfiles/m3expl001.tlg        |  6 ++--
 l3kernel/testfiles/m3expl001.xetex.tlg  |  6 ++--
 l3kernel/testfiles/m3expl003.luatex.tlg |  6 ++--
 l3kernel/testfiles/m3expl003.tlg        |  6 ++--
 l3kernel/testfiles/m3expl003.xetex.tlg  |  6 ++--
 7 files changed, 63 insertions(+), 24 deletions(-)

diff --git a/l3backend/l3backend-opacity.dtx b/l3backend/l3backend-opacity.dtx
index ec867d2da..57c9a1dbf 100644
--- a/l3backend/l3backend-opacity.dtx
+++ b/l3backend/l3backend-opacity.dtx
@@ -126,6 +126,14 @@
 %    \end{macrocode}
 % \end{variable}
 %
+% \begin{variable}{\l_@@_backend_fill_tl, \l_@@_backend_stroke_tl}
+%   We use |tl| here for speed: at the backend, this should be reasonable.
+%    \begin{macrocode}
+\tl_new:N \l_@@_backend_fill_tl
+\tl_new:N \l_@@_backend_stroke_tl
+%    \end{macrocode}
+% \end{variable}
+%
 % \begin{macro}{\@@_backend_select:n, \@@_backend_select_aux:n}
 % \begin{macro}{\@@_backend_reset:}
 %   Other than the need to evaluate the opacity as an \texttt{fp}, much the
@@ -139,6 +147,8 @@
  }
 \cs_new_protected:Npn \@@_backend_select_aux:n #1
   {
+    \tl_set:Nn \l_@@_backend_fill_tl {#1}
+    \tl_set:Nn \l_@@_backend_stroke_tl {#1}
     \pdfmanagement_add:nnn { Page / Resources / ExtGState }
       { opacity #1 }
       { << /ca ~ #1 /CA ~ #1 >> }
@@ -156,23 +166,40 @@
 % \end{macro}
 %
 % \begin{macro}{\@@_backend_fill:n, \@@_backend_stroke:n}
-% \begin{macro}{\@@_backend:nn, \@@_backend:xn}
-%   Similar to the above but with no stack and only adding to one or other of
-%   the entries.
+% \begin{macro}{\@@_backend_fillstroke:nn, \@@_backend_fillstroke:xx}
+%   For separate fill and stroke, we need to work out if we need to do
+%   more work or if we can stick to a single setting.
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_backend_fill:n #1
-  { \@@_backend:nn { \fp_eval:n { min(max(0,#1),1) } } { ca } }
+  {
+    \@@_backend_fill_stroke:xx
+      { \fp_eval:n { min(max(0,#1),1) } }
+      \l_@@_backend_stroke_tl
+  }
 \cs_new_protected:Npn \@@_backend_stroke:n #1
-  { \@@_backend:nn { \fp_eval:n { min(max(0,#1),1) } } { CA } }
-\cs_new_protected:Npn \@@_backend:nn #1#2
   {
-    \pdfmanagement_add:nnn { Page / Resources / ExtGState }
-      { opacity #1 }
-      { << /#2 ~ #1 >> }
-   \@@_backend_stack_push:nn \c_@@_backend_stack_int
-     { /opacity #1 ~ gs }
+    \@@_backend_fill_stroke:xx
+      \l_@@_backend_fill_tl
+      { \fp_eval:n { min(max(0,#1),1) } }
   }
-\cs_generate_variant:Nn \@@_backend:nn { x }
+\cs_new_protected:Npn \@@_backend_fill_stroke:nn #1#2
+  {
+    \str_if_eq:nnTF {#1} {#2}
+      { \@@_backend_select_aux:n {#1} }
+      {
+        \tl_set:Nn \l_@@_backend_fill_tl {#1}
+        \tl_set:Nn \l_@@_backend_stroke_tl {#2}
+        \pdfmanagement_add:nnn { Page / Resources / ExtGState }
+          { opacity.fill #1 }
+          { << /ca ~ #1 >> }
+        \pdfmanagement_add:nnn { Page / Resources / ExtGState }
+          { opacity.stroke #1 }
+          { << /CA ~ #2 >> }
+        \@@_backend_stack_push:nn \c_@@_backend_stack_int
+         { /opacity.fill #1 ~ gs /opacity.stroke #2 ~ gs }
+      }
+  }
+\cs_generate_variant:Nn \@@_backend_fill_stroke:nn { xx }
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index 9c2fc3c44..1c33fdfb7 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -148,11 +148,13 @@ Defining \__pdf_backend_version_major: on line ...
 Defining \__pdf_backend_version_minor: on line ...
 Defining \__pdf_backend_bdc:nn on line ...
 Defining \__pdf_backend_emc: on line ...
+Defining \l__opacity_backend_fill_tl on line ...
+Defining \l__opacity_backend_stroke_tl on line ...
 Defining \__opacity_backend_select:n on line ...
 Defining \__opacity_backend_select_aux:n on line ...
 Defining \__opacity_backend_reset: on line ...
 Defining \__opacity_backend_fill:n on line ...
 Defining \__opacity_backend_stroke:n on line ...
-Defining \__opacity_backend:nn on line ...
-Defining \__opacity_backend:xn on line ...
+Defining \__opacity_backend_fill_stroke:nn on line ...
+Defining \__opacity_backend_fill_stroke:xx on line ...
 ))
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index 4b68d6958..424614f2c 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -148,11 +148,13 @@ Defining \__pdf_backend_version_major: on line ...
 Defining \__pdf_backend_version_minor: on line ...
 Defining \__pdf_backend_bdc:nn on line ...
 Defining \__pdf_backend_emc: on line ...
+Defining \l__opacity_backend_fill_tl on line ...
+Defining \l__opacity_backend_stroke_tl on line ...
 Defining \__opacity_backend_select:n on line ...
 Defining \__opacity_backend_select_aux:n on line ...
 Defining \__opacity_backend_reset: on line ...
 Defining \__opacity_backend_fill:n on line ...
 Defining \__opacity_backend_stroke:n on line ...
-Defining \__opacity_backend:nn on line ...
-Defining \__opacity_backend:xn on line ...
+Defining \__opacity_backend_fill_stroke:nn on line ...
+Defining \__opacity_backend_fill_stroke:xx on line ...
 ))
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index 88b35c195..715b1f2c3 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -171,11 +171,13 @@ Defining \__pdf_backend_version_major: on line ...
 Defining \__pdf_backend_version_minor: on line ...
 Defining \__pdf_backend_bdc:nn on line ...
 Defining \__pdf_backend_emc: on line ...
+Defining \l__opacity_backend_fill_tl on line ...
+Defining \l__opacity_backend_stroke_tl on line ...
 Defining \__opacity_backend_select:n on line ...
 Defining \__opacity_backend_select_aux:n on line ...
 Defining \__opacity_backend_reset: on line ...
 Defining \__opacity_backend_fill:n on line ...
 Defining \__opacity_backend_stroke:n on line ...
-Defining \__opacity_backend:nn on line ...
-Defining \__opacity_backend:xn on line ...
+Defining \__opacity_backend_fill_stroke:nn on line ...
+Defining \__opacity_backend_fill_stroke:xx on line ...
 ))
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index 9c2fc3c44..1c33fdfb7 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -148,11 +148,13 @@ Defining \__pdf_backend_version_major: on line ...
 Defining \__pdf_backend_version_minor: on line ...
 Defining \__pdf_backend_bdc:nn on line ...
 Defining \__pdf_backend_emc: on line ...
+Defining \l__opacity_backend_fill_tl on line ...
+Defining \l__opacity_backend_stroke_tl on line ...
 Defining \__opacity_backend_select:n on line ...
 Defining \__opacity_backend_select_aux:n on line ...
 Defining \__opacity_backend_reset: on line ...
 Defining \__opacity_backend_fill:n on line ...
 Defining \__opacity_backend_stroke:n on line ...
-Defining \__opacity_backend:nn on line ...
-Defining \__opacity_backend:xn on line ...
+Defining \__opacity_backend_fill_stroke:nn on line ...
+Defining \__opacity_backend_fill_stroke:xx on line ...
 ))
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index 4b68d6958..424614f2c 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -148,11 +148,13 @@ Defining \__pdf_backend_version_major: on line ...
 Defining \__pdf_backend_version_minor: on line ...
 Defining \__pdf_backend_bdc:nn on line ...
 Defining \__pdf_backend_emc: on line ...
+Defining \l__opacity_backend_fill_tl on line ...
+Defining \l__opacity_backend_stroke_tl on line ...
 Defining \__opacity_backend_select:n on line ...
 Defining \__opacity_backend_select_aux:n on line ...
 Defining \__opacity_backend_reset: on line ...
 Defining \__opacity_backend_fill:n on line ...
 Defining \__opacity_backend_stroke:n on line ...
-Defining \__opacity_backend:nn on line ...
-Defining \__opacity_backend:xn on line ...
+Defining \__opacity_backend_fill_stroke:nn on line ...
+Defining \__opacity_backend_fill_stroke:xx on line ...
 ))
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index 88b35c195..715b1f2c3 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -171,11 +171,13 @@ Defining \__pdf_backend_version_major: on line ...
 Defining \__pdf_backend_version_minor: on line ...
 Defining \__pdf_backend_bdc:nn on line ...
 Defining \__pdf_backend_emc: on line ...
+Defining \l__opacity_backend_fill_tl on line ...
+Defining \l__opacity_backend_stroke_tl on line ...
 Defining \__opacity_backend_select:n on line ...
 Defining \__opacity_backend_select_aux:n on line ...
 Defining \__opacity_backend_reset: on line ...
 Defining \__opacity_backend_fill:n on line ...
 Defining \__opacity_backend_stroke:n on line ...
-Defining \__opacity_backend:nn on line ...
-Defining \__opacity_backend:xn on line ...
+Defining \__opacity_backend_fill_stroke:nn on line ...
+Defining \__opacity_backend_fill_stroke:xx on line ...
 ))





More information about the latex3-commits mailing list.