summaryrefslogtreecommitdiff
path: root/draw/draw_device.c
AgeCommit message (Collapse)Author
2012-06-11Fix Bug 693102: Overflows in large pixmap indexing.Robin Watts
When we allocate a pixmap > 2G, but < 4G, the index into that pixmap, when calculated as an int can be negative. Fix this with various casts to unsigned int. If we ever move to support >4G images we'll need to rejig the casting to cast each part of the element to ptrdiff_t first.
2012-04-10Add fz_new_draw_device_with_bbox functionRobin Watts
Restricts rendering to a sub rectangle of the supplied bbox.
2012-03-16Bug 692805: BBox rounding issuesRobin Watts
Currently all conversions from rect to bbox are done using a single function, fz_round_rect. This causes problems, as sometimes we want 'round, allowing for slight calculation errors' and sometimes we want 'round slavishly to ensure we have a bbox that covers the rect'. We therefore split these 2 cases into 2 separate functions; fz_round_rect is kept, meaning "round outwards allowing for slight errors", and fz_bbox_covering_rect is added to mean "give us the smallest bbox that is guaranteed to cover rect". No regressions seen.
2012-03-13Fix potential memory overrun.Robin Watts
Taken from Sumatra.patch - Many thanks.
2012-03-13Add ctx argument and rename fz_bound_pixmap to fz_pixmap_bbox.Tor Andersson
2012-03-13Rename some functions and accessors to be more consistent.Tor Andersson
Debug printing functions: debug -> print. Accessors: get noun attribute -> noun attribute. Find -> lookup when the returned value is not reference counted. pixmap_with_rect -> pixmap_with_bbox. We are reserving the word "find" to mean lookups that give ownership of objects to the caller. Lookup is used in other places where the ownership is not transferred, or simple values are returned. The rename is done by the sed script in scripts/rename3.sed
2012-03-12Change order of params in fz_convert_color to C standard.Robin Watts
C's standard is copy(dst, src), so we move to adopt that here. Hopefully no one is calling this routine other than us - if they are, then I apologise! Better to aim for consistency before we freeze the API at v1.0 than to carry an inconsistent API around ever after.
2012-03-12Change order of params in fz_convert_pixmap to C standard.Robin Watts
C's standard is copy(dst, src), so we move to adopt that here. Hopefully no one is calling this routine other than us - if they are, then I apologise! Better to aim for consistency before we freeze the API at v1.0 than to carry an inconsistent API around ever after.
2012-03-12Merge branch 'master' into header-splitRobin Watts
2012-03-09Fix overeager cleanup code.Robin Watts
In the cancel or error case, we cleanup pixmaps left on the draw devices stack. We were cleaning up one layer more in the error code than in normal code, leading to a double free.
2012-03-06Split fitz.h/mupdf.h into internal/external headers.Robin Watts
Attempt to separate public API from internal functions.
2012-02-25Rework image handling for on demand decodeRobin Watts
Introduce a new 'fz_image' type; this type contains rudimentary information about images (such as native, size, colorspace etc) and a function to call to get a pixmap of that image (with a size hint). Instead of passing pixmaps through the device interface (and holding pixmaps in the display list) we now pass images instead. The rendering routines therefore call fz_image_to_pixmap to get pixmaps to render, and fz_pixmap_drop those afterwards. The file format handling routines therefore need to produce images rather than pixmaps; xps and cbz currently just wrap pixmaps as images. PDF is more involved. The stream handling routines in PDF have been altered so that they can recognise when the last stream entry in a filter dictionary is an image decoding filter. Rather than applying this filter, they read and store the parameters into a pdf_image_params structure, and stop decoding at that point. This allows us to read the compressed data for an image into memory as a block. We can then restart the image decode process later. pdf_images therefore consist of the compressed image data for images. When a pixmap is requested for such an image, the code checks to see if we have one (of an appropriate size), and if not, decodes it. The size hint is used to determine whether it is possible to subsample the image; currently this is only supported for JPEGs, but we could add generic subsampling code later. In order to handle caching the produced images, various changes have been made to the store and the underlying hash table. Previously the store was indexed purely by fz_obj keys; we don't have an fz_obj key any more, so have extended the store by adding a concept of a key 'type'. A key type is a pointer to a set of functions that keep/drop/compare and make a hashable key from a key pointer. We make a pdf_store.c file that contains functions to offer the existing fz_obj based functions, and add a new 'type' for keys (based on the fz_image handle, and the subsample factor) in the pdf_image.c file. While working on this, a problem became apparent in the existing store codel; fz_obj objects had no protection on their reference counts, hence an interpreter thread could try to alter a ref count at the same time as a malloc caused an eviction from the store. This has been solved by using the alloc lock as protection. This in turn requires some tweaks to the code to make sure we don't try and keep/drop fz_obj's from the store code while the alloc lock is held. A side effect of this work is that when a hash table is created, we inform it what lock should be used to protect its innards (if any). If the alloc lock is used, the insert method knows to drop/retake it to allow it to safely expand the hash table. Callers to the hash functions have the responsibility of taking/dropping the appropriate lock, and ensuring that they cope with the possibility that insert might drop the alloc lock, causing race conditions.
2012-02-07Rename a few functions.Tor Andersson
2012-02-03Be consistent about passing a fz_context in path/text/shade functions.Tor Andersson
2012-02-03Be consistent about passing a fz_context argument in pixmap functions.Tor Andersson
2012-02-03Make fz_malloc_struct return zeroed memory.Tor Andersson
2012-01-24Correct SEGV/assert in cluster tests.Robin Watts
fz_draw_fill_image_mask was improperly nesting group start/ends, by calling fz_knockout_start at the top, and then fz_knockout_start again at the end. Changing this latter one to fz_knockout_end solves the problem. Also tweak the debugging code slightly to give more readable results.
2012-01-24Solve (some) SEGVS in cluster tests.Robin Watts
The cluster testing of MuPDF repeatedly crashes on pdf/PDF_1.7_FTS/fts_20_2008.pdf. Investigation shows this is because we fail to write the newly allocated mask back to the graphics state stack when starting a clip_stroke_text drawing operation. This causes later pops to fall over. Simple fix.
2012-01-23Remove assert in tiling code.Robin Watts
Both Zeniko and Malc have said that this causes problems. Following a hint from malc, the following command causes the assert to trigger: win32/Debug/pdfdraw.exe -r0.3 -o out.png ../MyTests/pdf_reference17.pdf 1143 I suspect it's because of the extreme resolution, and the round_rect call. At any rate, disabling the assert is of no real import.
2012-01-21Update image scaling subpixel offset calculations for top-down images.Tor Andersson
2012-01-20Bitmap 'patch' scaling - second attempt.Robin Watts
When scaling a bitmap, currently we always scale the entire bitmap, even if we only need a small section of the result. This patch changes the code to take an optional 'clip' bbox, and only scales as many pixels as are required to generate the required output region.
2012-01-20Revert "Bitmap 'patch' scaling."Tor Andersson
This reverts commit 08e84b18e5c1dbe8f3d32dd0aeb4b4c43debce9f.
2012-01-19Bitmap 'patch' scaling.Robin Watts
When scaling a bitmap, currently we always scale the entire bitmap, even if we only need a small section of the result. This patch changes the code to take an optional 'clip' bbox, and only scales as much of the input as as required for this output region.
2012-01-11Hide glyph cache in context.Tor Andersson
2012-01-11Calculate accurate per-glyph bounding boxes for fz_bound_text.Tor Andersson
2012-01-10Fix many spelling errors.Sebastian Rasmussen
2012-01-06draw_device; device state stack handling fixes.Robin Watts
Only create a shape if we need to. Correctly cleanup, thus avoiding a double free of mask later on. Thanks to Zeniko for spotting these.
2012-01-03Rework draw device stack handling.Robin Watts
As we create clips/transparency groups etc, we maintain a stack of draw device states. Here we change this from having a 'current' state, and storing changes on the stack to always keeping the complete current state on the head of the stack. This should make error cleanup easier, as well as being conceptually easier to follow (for me at least).
2012-01-02Fix bug 692593 - solve crash due to inappropriately sized shape plane.Robin Watts
When starting to tile, create a shape plane if one exists. When finishing tiling, plot the shape plane back too. This solves the SEGVs. Something isn't quite right with the blending colours on part of this file though.
2011-12-30Enable knockout and non-isolated group support.Robin Watts
Testsseem to indicate that this works, and gives noticable improvements. Enabling by default.
2011-12-24Bug 692489 - fix SEGV in non-isolated/knockout blendingRobin Watts
Restrict images to the size of the shape when blending back. This seems to solve the problem; leaving code disabled until full tests complete.
2011-12-21Fix whitespace.Tor Andersson
2011-12-19More memsqueezing fixes.Robin Watts
2011-12-17More Memory Squeezing fixes.Robin Watts
2011-12-16Add fz_malloc_struct, and make code use it.Robin Watts
The new fz_malloc_struct(A,B) macro allocates sizeof(B) bytes using fz_malloc, and then passes the resultant pointer to Memento_label to label it with "B". This costs nothing in non-memento builds, but gives much nicer listings of leaked blocks when memento is enabled.
2011-12-08Stylistic changes when testing pointer values for NULL.Tor Andersson
Also: use 'cannot' instead of 'failed to' in error messages.
2011-12-07Fix tile coverage calculations.Robin Watts
The code attempts to spot cases where a pattern tile is so large that only 1 repeat is visible. Due to rounding errors, this test could sometimes fail, and (on badly formed files) we'd attempt to allocate huge pixmaps. The fix is to allow for rounding errors.
2011-11-25Merge branch 'master' into contextRobin Watts
2011-11-15Allow draw device to use a dynamic stack.Robin Watts
Previously, we had a hardwired 96 element stack for clipping/group nesting etc. If this was exceeeded during rendering we would give an error. Now we allow for that stack to be extended dynamically at runtime. If the stack extension fails, we will give an error and die.
2011-11-15Merge branch 'master' into contextRobin Watts
Mostly redoing the xps_context to xps_document change and adding contexts to newly written code. Conflicts: apps/pdfapp.c apps/pdfapp.h apps/x11_main.c apps/xpsdraw.c draw/draw_device.c draw/draw_scale.c fitz/base_object.c fitz/fitz.h pdf/mupdf.h pdf/pdf_interpret.c pdf/pdf_outline.c pdf/pdf_page.c xps/muxps.h xps/xps_doc.c xps/xps_xml.c
2011-11-14Grid fitting tweaks.Robin Watts
Extract the grid fitting code from the scaling code and the affine image drawing code into it's own separate function. This reduces code duplication. It also allows us to make better allowance for rounding errors. Add a voodoo offset in the draw_affine.c code for painting interpolated images. This gives us the best possible match between all the different combinations of scaled/unscaled and interpolated/uninterpolated images.
2011-09-21Add warning context.Tor Andersson
2011-09-15Add context to mupdf.Robin Watts
Huge pervasive change to lots of files, adding a context for exception handling and allocation. In time we'll move more statics into there. Also fix some for(i = 0; i < function(...); i++) calls.
2011-09-03Introduce ATTEMPT_KNOCKOUT_AND_ISOLATED define (off by default).Robin Watts
Until such time as the knockout and isolated group support is known to work properly, leave it disabled so we behave the same as we have until now.
2011-08-06Cosmetic style fixes.Tor Andersson
2011-08-05More changes to blending of groups.Robin Watts
In an effort to solve bug 692377, examine what ghostscript does, and move mupdf into line with it. Firstly, it seems that rather than collecting a pure 'shape' plane ghostscript keeps a 'shape-with-alpha' plane. Only a tiny change is required to move mupdf to the do the same thing, so done here. Secondly, it seems that ghostscript 'uncomposites' the result of non-isolated groups, before applying the blend mode. It's not clear to me that this is entirely correct; this 'uncomposite' operation assumes that all compositing has been done internally with the 'normal' blend mode. Nonetheless, I do the same here, and it seems to work. This 'uncomposite' operation may yet turn out to be a source of bugs if I have muddled the use of premultiplied and non-premultiplied components, but it seems to work on the testfiles I have.
2011-08-04Fix part of bug 692377: "hivemind" PDF regressionRobin Watts
Comment #3 on bug 692377 notes that the "Hivemind" pdf (from bug 692203) has regressed; this is due to the new shape code not working quite right with mask groups. Fixed here. It also showed up a bug in the shape code with filled paths at non full alpha. Also fixed. In tracking this down, I've extended the DUMP_GROUP_BLENDS debugging code to give more readable output. Also committed here. This still leaves a regression in l16.pdf which the bug was originally reopened about, but that's a much more minor one.
2011-08-03Fix bug 692388; colored type3 fonts drawn incorrectly.Robin Watts
All glyphs in type3 colored fonts were drawn mirrored in y due to an incorrectly setup transformation matrix. The bug was reported by Zeniko, with a helpful example file that showed the problem. Until then I'd been working using only fts_23_2303.pdf as an example, which uses geometric shapes, so isn't obvious that it's wrong. Also my copy of acrobat fails to render them.
2011-08-03Add (disabled by default) debug code for group blends.Robin Watts
Some code that I find useful for debugging the group blending code.
2011-08-01Fix bug 692377: Incorrect rendering of blending groups.Robin Watts
A combination of constant alpha and non-zero blending modes resulted in incorrect rendering. Various fixes seem to have made it work: * Allow for non-full alpha when blending non-isolated groups back. * Clamp blended pixels to allow for overflow. * Allow for alpha in the shape blending.