[gs-commits] ghostpdl branch, pdfi, updated. jbig2dec-0.14-2207-g3fecb8b
[email protected] (Nancy Durgin)
| Newsgroups | gmane.comp.printing.ghostscript.cvs |
|---|---|
| Message-ID | <[email protected]> |
The ghostpdl branch, pdfi has been updated
via 3fecb8bcf59d4f1e93edab637a861332cf43063c (commit)
from ae75a069aa5436603b606f67150c4f1fd769ead1 (commit)
----------------------------------------------------------------------
commit 3fecb8bcf59d4f1e93edab637a861332cf43063c
Author: Nancy Durgin <[email protected]>
Date: Tue Sep 10 13:45:35 2019 -0700
Implement transparency for shading
Also, change the format of the object number for compressed objects to make
it easier to search through logs when debugging.
diff --git a/pdf/pdf_int.c b/pdf/pdf_int.c
index 1bc5123..4a8c84a 100644
--- a/pdf/pdf_int.c
+++ b/pdf/pdf_int.c
@@ -414,7 +414,7 @@ int pdfi_dereference(pdf_context *ctx, uint64_t obj, uint64_t gen, pdf_obj **obj
gs_offset_t offset = 0;
if (ctx->pdfdebug) {
- dmprintf1(ctx->memory, "%% Reading compressed object %"PRIi64, obj);
+ dmprintf1(ctx->memory, "%% Reading compressed object (%"PRIi64" 0 obj)", obj);
dmprintf1(ctx->memory, " from ObjStm with object number %"PRIi64"\n", compressed_entry->object_num);
}
diff --git a/pdf/pdf_shading.c b/pdf/pdf_shading.c
index 2fb3557..dd09710 100644
--- a/pdf/pdf_shading.c
+++ b/pdf/pdf_shading.c
@@ -25,6 +25,7 @@
#include "pdf_file.h"
#include "pdf_loop_detect.h"
#include "pdf_colour.h"
+#include "pdf_trans.h"
#include "gxshade.h"
#include "gsptype2.h"
@@ -695,13 +696,51 @@ pdfi_shading_free(pdf_context *ctx, gs_shading_t *psh)
gs_free_object(ctx->memory, psh, "Free shading, finished");
}
+/* Setup for transparency (see pdf_draw.ps/sh) */
+static int
+pdfi_shading_setup_trans(pdf_context *ctx, pdfi_trans_state_t *state, pdf_dict *shading)
+{
+ int code;
+ gs_rect bbox;
+ pdf_array *BBox = NULL;
+
+ code = pdfi_gsave(ctx);
+ if (code < 0)
+ return code;
+
+ code = pdfi_dict_knownget_type(ctx, shading, "BBox", PDF_ARRAY, (pdf_obj **)&BBox);
+ if (code > 0) {
+ pdfi_array_to_gs_rect(ctx, BBox, &bbox);
+ code = gs_moveto(ctx->pgs, bbox.p.x, bbox.p.y);
+ if (code < 0)
+ goto exit;
+ code = gs_lineto(ctx->pgs, bbox.q.x, 0.);
+ if (code < 0)
+ goto exit;
+ code = gs_lineto(ctx->pgs, 0., bbox.q.y);
+ if (code < 0)
+ goto exit;
+ code = gs_closepath(ctx->pgs);
+ } else {
+ code = gs_clippath(ctx->pgs);
+ }
+
+
+ code = pdfi_trans_setup(ctx, state, TRANSPARENCY_Caller_Other, gs_getfillconstantalpha(ctx->pgs));
+ exit:
+ pdfi_countdown(BBox);
+ pdfi_grestore(ctx);
+ return code;
+}
+
int pdfi_shading(pdf_context *ctx, pdf_dict *stream_dict, pdf_dict *page_dict)
{
int code, code1;
pdf_name *n = NULL;
- pdf_obj *o = NULL;
+ pdf_dict *Shading = NULL;
gs_shading_t *psh = NULL;
gs_offset_t savedoffset;
+ pdfi_trans_state_t trans_state;
if (pdfi_count_stack(ctx) < 1)
return_error(gs_error_stackunderflow);
@@ -722,27 +761,39 @@ int pdfi_shading(pdf_context *ctx, pdf_dict *stream_dict, pdf_dict *page_dict)
if (code < 0)
goto exit1;
- code = pdfi_find_resource(ctx, (unsigned char *)"Shading", n, stream_dict, page_dict, &o);
+ code = pdfi_find_resource(ctx, (unsigned char *)"Shading", n, stream_dict, page_dict,
+ (pdf_obj **)&Shading);
if (code < 0)
goto exit2;
- if (o->type != PDF_DICT) {
+ if (Shading->type != PDF_DICT) {
code = gs_note_error(gs_error_typecheck);
goto exit2;
}
- code = pdfi_shading_build(ctx, stream_dict, page_dict, (pdf_dict *)o, &psh);
+ code = pdfi_shading_build(ctx, stream_dict, page_dict, Shading, &psh);
if (code < 0)
goto exit2;
+ if (ctx->page_has_transparency) {
+ code = pdfi_shading_setup_trans(ctx, &trans_state, Shading);
+ if (code < 0)
+ goto exit2;
+ }
+
code = gs_shfill(ctx->pgs, psh);
- if (psh) {
- pdfi_shading_free(ctx, psh);
+ if (ctx->page_has_transparency) {
+ code1 = pdfi_trans_teardown(ctx, &trans_state);
+ if (code == 0)
+ code = code1;
}
exit2:
- pdfi_countdown(o);
+ if (psh)
+ pdfi_shading_free(ctx, psh);
+
+ pdfi_countdown(Shading);
code1 = pdfi_grestore(ctx);
if (code == 0)
code = code1;
diff --git a/pdf/pdf_trans.h b/pdf/pdf_trans.h
index 4a63414..26a8189 100644
--- a/pdf/pdf_trans.h
+++ b/pdf/pdf_trans.h
@@ -26,7 +26,7 @@ typedef struct {
} pdfi_trans_state_t;
typedef enum {
- TRANSPARENCY_CALLER_Other,
+ TRANSPARENCY_Caller_Other,
TRANSPARENCY_Caller_Image,
TRANSPARENCY_Caller_Stroke,
TRANSPARENCY_Caller_Fill,
Summary of changes:
pdf/pdf_int.c | 2 +-
pdf/pdf_shading.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++------
pdf/pdf_trans.h | 2 +-
3 files changed, 60 insertions(+), 9 deletions(-)