summaryrefslogtreecommitdiff
path: root/source/fitz/shade.c
AgeCommit message (Collapse)Author
2018-08-14Bug 699631: Handle unsupported triangle mesh edge flags.Sebastian Rasmussen
There were two issues with the code parsing the triangle mesh's edge flags: * meshes were not require to start with an independent triangle * out of range edge flags caused vertices to be ignored A mesh where the edge flag of the first vertice is out of range, and the edge flag of the second vertex indicates continuation of a prior triangle would result in trying to create a triangle where the third coordinate would be uninitialized. This commit requires the edge flag of the first vertex to indicate a new independent triangle and if out of range edge flags are encountered they are treated as if they indicate a new triangle. Thanks to oss-fuzz for reporting.
2018-07-05Pass rect and matrix by value in geometry functions.Tor Andersson
Several things irk me about passing values as const pointers: * They can be NULL, which is not a valid value. * They require explicit temporary variables for storage. * They don't compose easily in a legible manner, requiring weird pointer passing semantics where the variable being assigned is hidden as an argument in the innermost function call. * We can't change the value through the pointer, requiring yet more local variables to hold copies of the input value. In the device interface where we pass a matrix to a function, we often find ourselves making a local copy of the matrix so we can concatenate other transforms to it. This copying is a lot of unnecessary busywork that I hope to eventually avoid by laying the groundwork with this commit. This is a rather large API change, so I apologize for the inconvenience, but I hope the end result and gain in legibility will be worth the pain.
2017-05-29Make PI/RADIAN/SQRT2/LN2 global single precision float constants.Sebastian Rasmussen
2017-04-27Remove debug printing code.Tor Andersson
It's not used, so prone to bit rot. Better to purge it.
2017-04-27Include required system headers.Tor Andersson
2017-03-22Rename fz_putc/puts/printf to fz_write_*.Tor Andersson
Rename fz_write to fz_write_data. Rename fz_write_buffer_* and fz_buffer_printf to fz_append_*. Be consistent in naming: fz_write_* calls write to fz_output. fz_append_* calls append to fz_buffer. Update documentation.
2016-10-18Avoid checking argument to fz_drop_*()/fz_free().Sebastian Rasmussen
As fz_drop_*()/fz_free() all must handle NULL.
2016-10-07Rename fz_process_mesh to fz_process_shade.Robin Watts
Better name as not all shadings are meshes.
2016-10-06Hide internals of fz_colorspaceRobin Watts
The implementation does not need to be in the public API.
2016-02-22Drop const from fz_shade.Tor Andersson
Shading objects are immutable and opaque once constructed. Therefore there is no need for the const keyword.
2016-01-13Add lots of consts.Robin Watts
In general, we should use 'const fz_blah' in device calls whenever the callee should not alter the fz_blah. Push this through. This shows up various places where we fz_keep and fz_drop these const things. I've updated the fz_keep and fz_drops with appropriate casts to remove the consts. We may need to do the union dance to avoid the consts for some compilers, but will only do that if required. I think this is nicer overall, even allowing for the const<->no const problems.
2015-12-11Use fz_output instead of FILE* for most of our output needs.Tor Andersson
Use fz_output in debug printing functions. Use fz_output in pdfshow. Use fz_output in fz_trace_device instead of stdout. Use fz_output in pdf-write.c. Rename fz_new_output_to_filename to fz_new_output_with_path. Add seek and tell to fz_output. Remove unused functions like fz_fprintf. Fix typo in pdf_print_obj.
2015-02-17Add ctx parameter and remove embedded contexts for API regularity.Tor Andersson
Purge several embedded contexts: Remove embedded context in fz_output. Remove embedded context in fz_stream. Remove embedded context in fz_device. Remove fz_rebind_stream (since it is no longer necessary). Remove embedded context in svg_device. Remove embedded context in XML parser. Add ctx argument to fz_document functions. Remove embedded context in fz_document. Remove embedded context in pdf_document. Remove embedded context in pdf_obj. Make fz_page independent of fz_document in the interface. We shouldn't need to pass the document to all functions handling a page. If a page is tied to the source document, it's redundant; otherwise it's just pointless. Fix reference counting oddity in fz_new_image_from_pixmap.
2015-02-17Rename fz_close_* and fz_free_* to fz_drop_*.Tor Andersson
Rename fz_close to fz_drop_stream. Rename fz_close_archive to fz_drop_archive. Rename fz_close_output to fz_drop_output. Rename fz_free_* to fz_drop_*. Rename pdf_free_* to pdf_drop_*. Rename xps_free_* to xps_drop_*.
2014-08-27Allow NULL callback functions in the mesh processor.Tor Andersson
Let either or both of the 'prepare' and 'process' callbacks be no-ops.
2014-05-01Fix 694084: compute number of segments in radial shading from radius.Tor Andersson
2014-02-17Simplify shade vertex preparation and remove redundant memcpy calls.Tor Andersson
2014-01-02Bug 694585: Slow rendering of meshesRobin Watts
In the existing code for meshes, we decompose the mesh down into quads (or triangles) and then call a process routine to actually do the work. This process routine typically maps each vertexes position/color and plots it. As each vertex is used several times by neighbouring patches, this results in each vertex being processed several times. The fix in this commit is therefore to break the processing into 'prepare' and 'process' phases. Each vertex is 'prepared' before being used in the 'process' phase. This cuts the number of prepare operations in half. In testing, this reduced the time for a (release build, generating ppm at default resolution) run from 33.4s to 23.5s.
2013-06-20Rearrange source files.Tor Andersson