[gs-commits] ghostpdl branch, pdfi, updated. jbig2dec-0.14-2564-g2896124
[email protected] (Nancy Durgin) Wed, 20 Nov 2019 19:32:53 +0000 (UTC)
| Newsgroups | gmane.comp.printing.ghostscript.cvs |
|---|---|
| Message-ID | <[email protected]> |
The ghostpdl branch, pdfi has been updated
via 28961247238d9ddd775072aeba7868846bbcc91c (commit)
from 1a1bcfc1df89b57dfd2e339b7672dd91b60fd6d3 (commit)
----------------------------------------------------------------------
commit 28961247238d9ddd775072aeba7868846bbcc91c
Author: Nancy Durgin <[email protected]>
Date: Tue Nov 19 13:14:08 2019 -0800
Refactor some code, start annotation module
Refactor page code for readability.
Add stub routine to handle annotations.
Add pdf_annot.c module.
None of this should change anything in rendering.
diff --git a/pdf/pdf.mak b/pdf/pdf.mak
index b758ca2..70db9e2 100644
--- a/pdf/pdf.mak
+++ b/pdf/pdf.mak
@@ -95,6 +95,9 @@ $(PDFOBJ)pdf_image.$(OBJ): $(PDFSRC)pdf_image.c $(PDFINCLUDES) $(PDF_MAK) $(MAKE
$(PDFOBJ)pdf_page.$(OBJ): $(PDFSRC)pdf_page.c $(PDFINCLUDES) $(PDF_MAK) $(MAKEDIRS)
$(PDFCCC) $(PDFSRC)pdf_page.c $(PDFO_)pdf_page.$(OBJ)
+$(PDFOBJ)pdf_annot.$(OBJ): $(PDFSRC)pdf_annot.c $(PDFINCLUDES) $(PDF_MAK) $(MAKEDIRS)
+ $(PDFCCC) $(PDFSRC)pdf_annot.c $(PDFO_)pdf_annot.$(OBJ)
+
$(PDFOBJ)pdf_stack.$(OBJ): $(PDFSRC)pdf_stack.c $(PDFINCLUDES) $(PDF_MAK) $(MAKEDIRS)
$(PDFCCC) $(PDFSRC)pdf_stack.c $(PDFO_)pdf_stack.$(OBJ)
@@ -166,6 +169,7 @@ PDF_OBJS=\
$(PDFOBJ)pdf_stack.$(OBJ)\
$(PDFOBJ)pdf_image.$(OBJ)\
$(PDFOBJ)pdf_page.$(OBJ)\
+ $(PDFOBJ)pdf_annot.$(OBJ)\
$(PDFOBJ)pdf_agl.$(OBJ) \
$(PDFOBJ)pdf_fapi.$(OBJ)\
$(PDFOBJ)pdf_font.$(OBJ)\
diff --git a/pdf/pdf_annot.c b/pdf/pdf_annot.c
new file mode 100644
index 0000000..42698c0
--- /dev/null
+++ b/pdf/pdf_annot.c
@@ -0,0 +1,47 @@
+/* Copyright (C) 2001-2019 Artifex Software, Inc.
+ All Rights Reserved.
+
+ This software is provided AS-IS with no warranty, either express or
+ implied.
+
+ This software is distributed under license and may not be copied,
+ modified or distributed except as expressly authorized under the terms
+ of the license contained in the file LICENSE in this distribution.
+
+ Refer to licensing information at http://www.artifex.com or contact
+ Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
+ CA 94945, U.S.A., +1(415)492-9861, for further information.
+*/
+
+/* Annotation handling for the PDF interpreter */
+
+#include "pdf_int.h"
+#include "plmain.h"
+#include "pdf_stack.h"
+#include "pdf_annot.h"
+#include "pdf_file.h"
+#include "pdf_dict.h"
+#include "pdf_array.h"
+#include "pdf_loop_detect.h"
+#include "pdf_colour.h"
+#include "pdf_trans.h"
+#include "pdf_gstate.h"
+#include "pdf_misc.h"
+#include "pdf_optcontent.h"
+#include "pdf_annot.h"
+
+int pdfi_do_annotations(pdf_context *ctx, pdf_dict *page_dict)
+{
+ int code = 0;
+ pdf_array *Annots = NULL;
+
+ if (!ctx->showannots)
+ return 0;
+
+ code = pdfi_dict_knownget_type(ctx, page_dict, "Annots", PDF_ARRAY, (pdf_obj **)&Annots);
+ if (code == 0)
+ return code;
+
+ pdfi_countdown(Annots);
+ return code;
+}
diff --git a/pdf/pdf_annot.h b/pdf/pdf_annot.h
new file mode 100644
index 0000000..6a6781f
--- /dev/null
+++ b/pdf/pdf_annot.h
@@ -0,0 +1,23 @@
+/* Copyright (C) 2001-2019 Artifex Software, Inc.
+ All Rights Reserved.
+
+ This software is provided AS-IS with no warranty, either express or
+ implied.
+
+ This software is distributed under license and may not be copied,
+ modified or distributed except as expressly authorized under the terms
+ of the license contained in the file LICENSE in this distribution.
+
+ Refer to licensing information at http://www.artifex.com or contact
+ Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
+ CA 94945, U.S.A., +1(415)492-9861, for further information.
+*/
+
+/* Annotation handling for the PDF interpreter */
+
+#ifndef PDF_ANNOTATIONS
+#define PDF_ANNOTATIONS
+
+int pdfi_do_annotations(pdf_context *ctx, pdf_dict *page_dict);
+
+#endif
diff --git a/pdf/pdf_page.c b/pdf/pdf_page.c
index a6cbf44..6fea12d 100644
--- a/pdf/pdf_page.c
+++ b/pdf/pdf_page.c
@@ -28,6 +28,7 @@
#include "pdf_gstate.h"
#include "pdf_misc.h"
#include "pdf_optcontent.h"
+#include "pdf_annot.h"
static int pdfi_process_page_contents(pdf_context *ctx, pdf_dict *page_dict)
{
@@ -120,6 +121,37 @@ page_error:
return code;
}
+/* Render one page (including annotations) (see pdf_main.ps/showpagecontents) */
+static int pdfi_process_one_page(pdf_context *ctx, pdf_dict *page_dict)
+{
+ stream_save local_entry_save;
+ int code, code1;
+
+ /* Save the current stream state, for later cleanup, in a local variable */
+ local_save_stream_state(ctx, &local_entry_save);
+ initialise_stream_save(ctx);
+
+ code = pdfi_process_page_contents(ctx, page_dict);
+
+ /* Put our state back the way it was before we ran the contents
+ * and check if the stream had problems
+ */
+#ifdef PROBE_STREAMS
+ if (ctx->pgs->level > ctx->current_stream_save.gsave_level ||
+ pdfi_count_stack(ctx) > ctx->current_stream_save.stack_count)
+ code = ((pdf_context *)0)->first_page;
+#endif
+
+ cleanup_context_interpretation(ctx, &local_entry_save);
+ local_restore_stream_state(ctx, &local_entry_save);
+
+ code1 = pdfi_do_annotations(ctx, page_dict);
+ if (code > 0)
+ code = code1;
+
+ return code;
+}
+
/* Just dealing with UserUnit for now.
* See pdf_PDF2PS_matrix and .pdfshowpage_Install
*/
@@ -264,6 +296,53 @@ static int pdfi_set_media_size(pdf_context *ctx, pdf_dict *page_dict)
return 0;
}
+/* Setup default transfer functions */
+static void pdfi_setup_transfers(pdf_context *ctx)
+{
+ if (ctx->pgs->set_transfer.red == 0x00) {
+ ctx->DefaultTransfers[0].proc = gs_identity_transfer;
+ memset(ctx->DefaultTransfers[0].values, 0x00, transfer_map_size * sizeof(frac));
+ } else {
+ ctx->DefaultTransfers[0].proc = ctx->pgs->set_transfer.red->proc;
+ memcpy(ctx->DefaultTransfers[0].values, ctx->pgs->set_transfer.red->values, transfer_map_size * sizeof(frac));
+ }
+ if (ctx->pgs->set_transfer.green == 0x00) {
+ ctx->DefaultTransfers[1].proc = gs_identity_transfer;
+ memset(ctx->DefaultTransfers[1].values, 0x00, transfer_map_size * sizeof(frac));
+ } else {
+ ctx->DefaultTransfers[1].proc = ctx->pgs->set_transfer.green->proc;
+ memcpy(ctx->DefaultTransfers[1].values, ctx->pgs->set_transfer.green->values, transfer_map_size * sizeof(frac));
+ }
+ if (ctx->pgs->set_transfer.blue == 0x00) {
+ ctx->DefaultTransfers[2].proc = gs_identity_transfer;
+ memset(ctx->DefaultTransfers[2].values, 0x00, transfer_map_size * sizeof(frac));
+ } else {
+ ctx->DefaultTransfers[2].proc = ctx->pgs->set_transfer.blue->proc;
+ memcpy(ctx->DefaultTransfers[2].values, ctx->pgs->set_transfer.blue->values, transfer_map_size * sizeof(frac));
+ }
+ if (ctx->pgs->set_transfer.gray == 0x00) {
+ ctx->DefaultTransfers[3].proc = gs_identity_transfer;
+ memset(ctx->DefaultTransfers[3].values, 0x00, transfer_map_size * sizeof(frac));
+ } else {
+ ctx->DefaultTransfers[3].proc = ctx->pgs->set_transfer.gray->proc;
+ memcpy(ctx->DefaultTransfers[3].values, ctx->pgs->set_transfer.gray->values, transfer_map_size * sizeof(frac));
+ }
+ if (ctx->pgs->black_generation == 0x00) {
+ ctx->DefaultBG.proc = gs_identity_transfer;
+ memset(ctx->DefaultBG.values, 0x00, transfer_map_size * sizeof(frac));
+ } else {
+ ctx->DefaultBG.proc = ctx->pgs->black_generation->proc;
+ memcpy(ctx->DefaultBG.values, ctx->pgs->black_generation->values, transfer_map_size * sizeof(frac));
+ }
+ if (ctx->pgs->undercolor_removal == 0x00) {
+ ctx->DefaultUCR.proc = gs_identity_transfer;
+ memset(ctx->DefaultUCR.values, 0x00, transfer_map_size * sizeof(frac));
+ } else {
+ ctx->DefaultUCR.proc = ctx->pgs->undercolor_removal->proc;
+ memcpy(ctx->DefaultUCR.values, ctx->pgs->undercolor_removal->values, transfer_map_size * sizeof(frac));
+ }
+}
+
int pdfi_page_render(pdf_context *ctx, uint64_t page_num)
{
int code, code1=0;
@@ -273,7 +352,6 @@ int pdfi_page_render(pdf_context *ctx, uint64_t page_num)
bool page_group_known = false;
int page_index = page_num >> 3;
char page_bit = 0x80 >> (page_num % 8);
- stream_save local_entry_save;
pdf_dict *group_dict = NULL;
if (page_num > ctx->num_pages)
@@ -335,48 +413,8 @@ int pdfi_page_render(pdf_context *ctx, uint64_t page_num)
code = gs_setsmoothness(ctx->pgs, 0.02); /* Match gs code */
ctx->TextBlockDepth = 0;
- if (ctx->pgs->set_transfer.red == 0x00) {
- ctx->DefaultTransfers[0].proc = gs_identity_transfer;
- memset(ctx->DefaultTransfers[0].values, 0x00, transfer_map_size * sizeof(frac));
- } else {
- ctx->DefaultTransfers[0].proc = ctx->pgs->set_transfer.red->proc;
- memcpy(ctx->DefaultTransfers[0].values, ctx->pgs->set_transfer.red->values, transfer_map_size * sizeof(frac));
- }
- if (ctx->pgs->set_transfer.green == 0x00) {
- ctx->DefaultTransfers[1].proc = gs_identity_transfer;
- memset(ctx->DefaultTransfers[1].values, 0x00, transfer_map_size * sizeof(frac));
- } else {
- ctx->DefaultTransfers[1].proc = ctx->pgs->set_transfer.green->proc;
- memcpy(ctx->DefaultTransfers[1].values, ctx->pgs->set_transfer.green->values, transfer_map_size * sizeof(frac));
- }
- if (ctx->pgs->set_transfer.blue == 0x00) {
- ctx->DefaultTransfers[2].proc = gs_identity_transfer;
- memset(ctx->DefaultTransfers[2].values, 0x00, transfer_map_size * sizeof(frac));
- } else {
- ctx->DefaultTransfers[2].proc = ctx->pgs->set_transfer.blue->proc;
- memcpy(ctx->DefaultTransfers[2].values, ctx->pgs->set_transfer.blue->values, transfer_map_size * sizeof(frac));
- }
- if (ctx->pgs->set_transfer.gray == 0x00) {
- ctx->DefaultTransfers[3].proc = gs_identity_transfer;
- memset(ctx->DefaultTransfers[3].values, 0x00, transfer_map_size * sizeof(frac));
- } else {
- ctx->DefaultTransfers[3].proc = ctx->pgs->set_transfer.gray->proc;
- memcpy(ctx->DefaultTransfers[3].values, ctx->pgs->set_transfer.gray->values, transfer_map_size * sizeof(frac));
- }
- if (ctx->pgs->black_generation == 0x00) {
- ctx->DefaultBG.proc = gs_identity_transfer;
- memset(ctx->DefaultBG.values, 0x00, transfer_map_size * sizeof(frac));
- } else {
- ctx->DefaultBG.proc = ctx->pgs->black_generation->proc;
- memcpy(ctx->DefaultBG.values, ctx->pgs->black_generation->values, transfer_map_size * sizeof(frac));
- }
- if (ctx->pgs->undercolor_removal == 0x00) {
- ctx->DefaultUCR.proc = gs_identity_transfer;
- memset(ctx->DefaultUCR.values, 0x00, transfer_map_size * sizeof(frac));
- } else {
- ctx->DefaultUCR.proc = ctx->pgs->undercolor_removal->proc;
- memcpy(ctx->DefaultUCR.values, ctx->pgs->undercolor_removal->values, transfer_map_size * sizeof(frac));
- }
+ pdfi_setup_transfers(ctx);
+
dbgmprintf1(ctx->memory, "Current page transparency setting is %d\n", ctx->PageTransparencyArray[page_index] & page_bit ? 1 : 0);
/* Force NOTRANSPARENCY here if required, until we can get it working... */
@@ -420,23 +458,8 @@ int pdfi_page_render(pdf_context *ctx, uint64_t page_num)
*/
pdfi_set_DefaultQState(ctx, ctx->pgs);
- /* Save the current stream state, for later cleanup, in a local variable */
- local_save_stream_state(ctx, &local_entry_save);
- initialise_stream_save(ctx);
-
- code = pdfi_process_page_contents(ctx, page_dict);
-
- /* Put our state back the way it was before we ran the contents
- * and check if the stream had problems
- */
-#ifdef PROBE_STREAMS
- if (ctx->pgs->level > ctx->current_stream_save.gsave_level ||
- pdfi_count_stack(ctx) > ctx->current_stream_save.stack_count)
- code = ((pdf_context *)0)->first_page;
-#endif
-
- cleanup_context_interpretation(ctx, &local_entry_save);
- local_restore_stream_state(ctx, &local_entry_save);
+ /* Render one page (including annotations) */
+ code = pdfi_process_one_page(ctx, page_dict);
if (ctx->page_has_transparency && page_group_known) {
code1 = pdfi_trans_end_group(ctx);
Summary of changes:
pdf/pdf.mak | 4 ++
pdf/pdf_annot.c | 47 ++++++++++++++
base/png_.h => pdf/pdf_annot.h | 13 ++--
pdf/pdf_page.c | 143 ++++++++++++++++++++++++-----------------
4 files changed, 138 insertions(+), 69 deletions(-)
create mode 100644 pdf/pdf_annot.c
copy base/png_.h => pdf/pdf_annot.h (78%)