From 4fbdba66f22d7388592c7946de16ec3ee79ade36 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Fri, 28 Sep 2012 17:51:30 +0100 Subject: 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 --- xps/xps_gradient.c | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) (limited to 'xps') 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]); -- cgit v1.2.3