[gs-commits] ghostpdl branch, pdfi, updated. jbig2dec-0.14-2112-ge7790c9

[email protected] (Nancy Durgin)
Newsgroups gmane.comp.printing.ghostscript.cvs
Message-ID <[email protected]>
The ghostpdl branch, pdfi has been updated
       via  e7790c9e0ef9e599aebe2ce84e56022dce310602 (commit)
      from  4e8997d4784d586220229b859e078f9c4ca17f21 (commit)

----------------------------------------------------------------------
commit e7790c9e0ef9e599aebe2ce84e56022dce310602
Author: Nancy Durgin <[email protected]>
Date:   Tue Aug 20 11:21:35 2019 -0700

    Fix Matrix in forms
    
    Need to save and restore the matrix manually, when changing it for
    the execgroup.  This is based on how the PS code handles it.  Comment in
    the PS code claims that can't just do a gsave/grestore...
    
    This should fix a bunch of visual regressions from previous commit.

diff --git a/pdf/pdf_trans.c b/pdf/pdf_trans.c
index f6de93f..5c5dd3d 100644
--- a/pdf/pdf_trans.c
+++ b/pdf/pdf_trans.c
@@ -41,6 +41,7 @@ static int pdfi_trans_set_mask(pdf_context *ctx, pdfi_int_gstate *igs)
     pdf_name *n = NULL;
     pdf_obj *CS = NULL;
     double f;
+    gs_matrix save_matrix, GroupMat;
 
     code = pdfi_dict_knownget_type(ctx, SMask, "Type", PDF_NAME, (pdf_obj **)&n);
     if (code > 0 && pdfi_name_is(n, "Mask")) {
@@ -78,7 +79,9 @@ static int pdfi_trans_set_mask(pdf_context *ctx, pdfi_int_gstate *igs)
                have gs_begin_transparency_mask work correctly.  Or at least that's
                what the PS code comments claim (see pdf_draw.ps/.execmaskgroup)
             */
-            gs_setmatrix(ctx->pgs, &igs->GroupGState->ctm);
+            gs_currentmatrix(ctx->pgs, &save_matrix);
+            gs_currentmatrix(igs->GroupGState, &GroupMat);
+            gs_setmatrix(ctx->pgs, &GroupMat);
 
             /* CS is in the dict "Group" inside the dict "G" */
             /* TODO: Not sure if this is a required thing or just one possibility */
@@ -110,8 +113,13 @@ static int pdfi_trans_set_mask(pdf_context *ctx, pdfi_int_gstate *igs)
             code = gs_begin_transparency_mask(ctx->pgs, &params, &bbox, true);
             if (code < 0)
                 goto exit;
+            /* TODO: Error handling... */
             code = pdfi_form_execgroup(ctx, ctx->CurrentPageDict, G_dict, igs->GroupGState);
             code = gs_end_transparency_mask(ctx->pgs, 0);
+            /* Put back the matrix (we couldn't just rely on gsave/grestore for whatever reason,
+             * according to PS code anyway...
+             */
+            gs_setmatrix(ctx->pgs, &save_matrix);
         }
     } else {
         /* take action on a non-/Mask entry. What does this mean ? What do we need to do */


Summary of changes:
 pdf/pdf_trans.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.