summaryrefslogtreecommitdiff
path: root/source/fitz/draw-glyph.c
AgeCommit message (Collapse)Author
2018-07-05Pass matrices by value: device and document interface.Tor Andersson
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-11-09Bug 698353: Avoid having our API depend on DEBUG/NDEBUG.Robin Watts
Currently, our API uses static inlines for fz_lock and fz_unlock, the definitions for which depend on whether we build NDEBUG or not. This isn't ideal as it causes problems when people link a release binary with a debug lib (or vice versa). We really want to continue to use static inlines for the locking functions as used from MuPDF, as we hit them hard in the keep/drop functions. We therefore remove fz_lock/fz_unlock from the public API entirely. Accordingly, we move the fz_lock/fz_unlock static inlines into fitz-imp.h (an internal header), together with the fz_keep_.../fz_drop_... functions. We then have public fz_lock/fz_unlock functions for any external callers to use that are free of compilications. At the same time, to avoid another indirection, we change from holding the locking functions as a pointer to a struct to a struct itself.
2017-09-08Remove unnecessary fz_try()/fz_catch().Sebastian Rasmussen
2017-09-07Initialize variables to appease clang scan-build.Sebastian Rasmussen
2017-06-22Move rasterizer/anti-alias choices into the draw device.Robin Watts
We still use the fz_context versions as the default, but these can be overridden with draw device options.
2017-04-27Include required system headers.Tor Andersson
2017-04-27Rename FMT_zu to FZ_FMT_zu.Tor Andersson
Don't use FMT_zu macro for fz_throw/fz_warn, since we can portably handle '%zu' in our own printf formatting.
2016-12-27Strip extraneous blank lines.Tor Andersson
2016-11-14More API tweaks.Robin Watts
Move internal functions from public to private headers.
2016-10-14Drop all contexts the same way.Sebastian Rasmussen
* Handle multiple calls to fz_drop_colorspace_context() and fz_drop_font_context(). * Allow missing context in call to fz_drop_aa_context() and fz_drop_glyph_cache_context(). * Only drop font context objects when dropping the last reference. * Avoid unnecessary NULL checks.
2016-10-07Add ctx to fz_font functions.Robin Watts
2016-10-05Move fz_font definition to be private.Robin Watts
Move the definition of fz_font to be in a private header file rather than in the public API. Add accessors for specific parts of the structure and use them as appropriate. The font flags, and the harfbuzz records remain public. This means that only 3 files now need access to the font implementation (font.c, pdf-font.c and pdf-type3.c). This may be able to be improved further in future.
2016-07-22Move hash calculation outside locked region.Robin Watts
Try to reduce contention on the glyphcache lock.
2016-06-17Use 'size_t' instead of int as appropriate.Robin Watts
This silences the many warnings we get when building for x64 in windows. This does not address any of the warnings we get in thirdparty libraries - in particular harfbuzz. These look (at a quick glance) harmless though.
2016-05-24fz_pixmap revamp: add stride and make alpha optionalRobin Watts
fz_pixmaps now have an explicit stride value. By default no change from before, but code all copes with extra gaps at the end of the line. The alpha data in fz_pixmaps is no longer compulsory. mudraw: use rgb not rgba (ppmraw), cmyk not cmyka (pkmraw). Update halftone code to not expect alpha plane. Update PNG writing to cope with alpha less input. Also hide repeated params within the png output context. ARM code needs updating.
2016-04-26Allow text/graphics aa levels to be controlled separately.Robin Watts
2016-03-16Bug 696648: Send -sm output to stderr.Robin Watts
Thanks to Marcos for spotting the missing case.
2016-01-21Drop the const on fz_font.Tor Andersson
The font is an immutable opaque structure, no need to add the const keyword since users aren't expected or expecting to change it.
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-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.
2013-11-27fix regression from da277059b37380d57028ff79a636f4d725c96e8fSimon Bünzli
The changes to fz_render_glyph cause the scissor rectangle to no longer match the transformation matrix which causes Type 3 glyphs to be clipped at larger resolutions.
2013-09-13Fix various compile warnings spotted by the cluster.Robin Watts
2013-09-02Expose subpixel glyph adjustment calculations.Robin Watts
Pull subpixel glyph adjustment calculations into fz_subpixel_adjust. This reduces the repetition of code, and will be helpful for the OpenGL device.
2013-09-02Add glyph rendering routines that return fz_pixmaps rather than fz_glyphs.Robin Watts
These do no caching, and are intended to be useful for the opengl device.
2013-09-02Be smarter when quantising sub pixel positions for glyphs.Robin Watts
For large glyphs, sub pixel positioning is supremely unimportant. Even for smaller glyphs, we don't need 5*5 possible sub pixel positions. Base the degree of sub pixel quantisation on the size of the glyphs. This should result in better cache use. We push all the glyph sub positioning logic into fz_render_glyph (and fz_render_stroked_glyph). This simplifies the calling code. We also tweak fz_render_glyph so that it updates the transform it is called with to reflect the sub pixel positioning. This solves various problems: Firstly, we can round positions both up and down to achieve a smaller net displacement (e.g. (0.99, 0.99) can go to (1,1) rather than (0.75, 0.75) if we have a subpixel position resolution of 1/4 pixels). Secondly, glyphs that are drawn from outlines will have exactly the same subpixel changes applied. This is unlikely to be noticable, but it does mean that baselines should avoid having any shifts in them. Finally, it enables us to avoid lots of unnecessary copying of matrices, hopefully reducing overhead.
2013-08-30Use RLE coding scheme for glyph bitmaps.Robin Watts
Rather than generating fz_pixmaps for glyphs, we generate fz_glyphs. fz_glyphs can either contain a pixmap, or an RLEd representation (if it's a mask, and it's smaller). Should take less memory in the cache, and should be faster to plot.
2013-08-28Dump glyph cache size as part of mudraw -MRobin Watts
2013-08-26Fix memory leak in new glyph cache code.Robin Watts
Forgot to drop the font.
2013-08-22Rework glyph cache to enable partial eviction.Robin Watts
The current code uses a hash table with linear probing. This means that when the cache fills up, we have no alternative but to bin the whole thing (or do an expensive rebuild). Change to using a simple hash table with linked lists of bucket chains, and additional LRU lists. This way we can ditch the oldest glyphs as we need more space.
2013-06-27Bug 694382: Fix problems arising from recent pdf_obj changes.Robin Watts
Thanks to zeniko for spotting these problems. When we close a document, purge the glyph cache to ensure that no type3 glyphs hang around with pointers to pdf_obj's that are now gone. Pass doc to pdf_new_obj_from_str rather than NULL. We believe that the reason this needed to be NULL is no longer valid. Also, revert to using an int for ref counts. In a quick test of our regression suite we only found 2 files that ever made a refcount > 256 (and they never got larger than 768), but the potential is there for issues. Reverting to an int until we can think of a better idea.
2013-06-20Rearrange source files.Tor Andersson