summaryrefslogtreecommitdiff
path: root/xps
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2012-09-28 17:51:30 +0100
committerRobin Watts <robin.watts@artifex.com>2012-10-01 12:19:36 +0100
commit4fbdba66f22d7388592c7946de16ec3ee79ade36 (patch)
tree6ddc28078aabd9635da859e3cde91d08ae707459 /xps
parenta1a37ae36043d8dba89cecfa345119ad32f81b9e (diff)
downloadmupdf-4fbdba66f22d7388592c7946de16ec3ee79ade36.tar.xz
Bug 693330: Change shadings to decompose to meshes at render time.
Currently, the mupdf code loads shadings at parse time, and instantly decomposes them into a mesh of triangles. This mesh of triangles is the transformed and rendered as required. Unfortunately the storage space for the mesh is typically much greater than the original representation. In this commit, we move the shading stream parsing/decomposition code into a general 'fz_process_mesh' function within res_shade. We then grab a copy of the buffer at load time, and 'process' (decompose/paint) at render time. For the test file on the bug, memory falls from the reported 660Mb to 30Mb. For another test file (txt9780547775815_ingested.pdf page 271) it reduces memory use from 750Meg to 33Meg. These figures could be further reduced by storing the compressed streams from the pdf file rather than the uncompressed ones. Incorporating typo fix and unused function removal from Sebras. Thanks. Remove unused function in shading code
Diffstat (limited to 'xps')
-rw-r--r--xps/xps_gradient.c38
1 files changed, 16 insertions, 22 deletions
diff --git a/xps/xps_gradient.c b/xps/xps_gradient.c
index e5699719..2d98953e 100644
--- a/xps/xps_gradient.c
+++ b/xps/xps_gradient.c
@@ -219,20 +219,17 @@ xps_draw_one_radial_gradient(xps_document *doc, fz_matrix ctm,
shade->use_background = 0;
shade->use_function = 1;
shade->type = FZ_RADIAL;
- shade->extend[0] = extend;
- shade->extend[1] = extend;
+ shade->u.a_or_r.extend[0] = extend;
+ shade->u.a_or_r.extend[1] = extend;
xps_sample_gradient_stops(shade, stops, count);
- shade->mesh_len = 6;
- shade->mesh_cap = 6;
- shade->mesh = fz_malloc_array(doc->ctx, shade->mesh_cap, sizeof(float));
- shade->mesh[0] = x0;
- shade->mesh[1] = y0;
- shade->mesh[2] = r0;
- shade->mesh[3] = x1;
- shade->mesh[4] = y1;
- shade->mesh[5] = r1;
+ shade->u.a_or_r.coords[0][0] = x0;
+ shade->u.a_or_r.coords[0][1] = y0;
+ shade->u.a_or_r.coords[0][2] = r0;
+ shade->u.a_or_r.coords[1][0] = x1;
+ shade->u.a_or_r.coords[1][1] = y1;
+ shade->u.a_or_r.coords[1][2] = r1;
fz_fill_shade(doc->dev, shade, ctm, 1);
@@ -260,20 +257,17 @@ xps_draw_one_linear_gradient(xps_document *doc, fz_matrix ctm,
shade->use_background = 0;
shade->use_function = 1;
shade->type = FZ_LINEAR;
- shade->extend[0] = extend;
- shade->extend[1] = extend;
+ shade->u.a_or_r.extend[0] = extend;
+ shade->u.a_or_r.extend[1] = extend;
xps_sample_gradient_stops(shade, stops, count);
- shade->mesh_len = 6;
- shade->mesh_cap = 6;
- shade->mesh = fz_malloc_array(doc->ctx, shade->mesh_cap, sizeof(float));
- shade->mesh[0] = x0;
- shade->mesh[1] = y0;
- shade->mesh[2] = 0;
- shade->mesh[3] = x1;
- shade->mesh[4] = y1;
- shade->mesh[5] = 0;
+ shade->u.a_or_r.coords[0][0] = x0;
+ shade->u.a_or_r.coords[0][1] = y0;
+ shade->u.a_or_r.coords[0][2] = 0;
+ shade->u.a_or_r.coords[1][0] = x1;
+ shade->u.a_or_r.coords[1][1] = y1;
+ shade->u.a_or_r.coords[1][2] = 0;
fz_fill_shade(doc->dev, shade, ctm, doc->opacity[doc->opacity_top]);