Age | Commit message (Collapse) | Author | Files | Lines |
|
As an aide to tracking down the source of uninitialised reads, run
VALGRIND_CHECK_MEM_IS_DEFINED() over the contents of image surfaces at the
boundary between backends, e.g. upon setting a glyph image or acquiring
a source image.
|
|
It is possible for cairo_surface_write_to_png() to acquire a non-standard
image surface when, for example, we try to dump a low bit-depth XServer.
Handle this scenario by coercing the unknown image format to a standard
type via pixman.
|
|
|
|
As pointed out by Truc Truong,
cairo_image_surface_create_from_png_stream() cannot return NULL and so the
documentation was incorrect.
Fixes http://bugs.freedesktop.org/show_bug.cgi?id=20075
Bug 20075 There is a misprint in the spec for
cairo_image_surface_create_from_png_stream() function
|
|
This reverts commit 564d64a1323c5cbcde2dd9365ac790fe8aa1c5a6.
In hindsight, and with further discussion with Jeff Muizelaar, this
behaviour of using the stored contents from the mime-data is completely
the opposite of the users' expectations. When the user calls
cairo_surface_write_to_png(), usually in the course of debugging their
rendering code, they expect the precise contents of the surface to be
saved.
|
|
_cairo_memory_stream_destroy() finalizes the stream even if the stream was
in error and that error is reported back to the caller - so ensure we
don't try to free the stream again.
|
|
The error path was missing a _cairo_output_stream_destroy() to cleanup a
copy of the incoming PNG data.
|
|
Use the gcc likelihood annotation to indicate that allocation failures are
extremely unlikely.
|
|
The error paths should be hit very rarely during normal operation, so mark
them as being unlikely so gcc may emit better code.
|
|
Adrian Johnson reported that cygwin complained about the use of the void *
within feof() as it was using a macro and attempted a to deference the
void*...
|
|
A limitation of the current API was that the destroy notifier was called
on the mime-data block. This prevents the user from passing in a pointer
to a managed block, for example a mime-data block belonging to a
ref-counted object. We can overcome this by allowing the user to specify
the closure to be used with the destroy notifier.
|
|
Write out the original PNG mime-data if attached to the surface during
cairo_surface_write_to_png(). Similar to how the compressed alternate
representations are handled by the other backends.
Note: by automatically attaching and using the mime-data in preference to
the image data, we break the read_from_png(); draw(); write_to_png()
cycle.
|
|
Attach the original png data as an alternate representation for image
surfaces created by cairo_surface_create_from_png().
|
|
If the ARGB32 is opaque, discard the alpha channel - so we should generate
byte identical output to the reference images.
|
|
Commit 20b1b33c0fc7 added some "paranoid checks" to our png
loading code. One of these was checking that if png_get_IHDR
first reports an interlace value other than PNG_INTERLACE_NONE
that after we call png_set_interlace_handling then we do
get PNG_INTERLACE_NONE from the next call to png_get_IHDR.
However, libpng doesn't seem to actually have that behavior.
When testing cairo_image_surface_create_from_png with an
interlanced PNG file, (which the test suite happens not to
do---even now), the call to png_set_interlace_handling is
doing the trick, but the check for PNG_INTERLACE_NONE is
failing.
So, with the check in place, loading an interlaced PNG image
fails with CAIRO_STATUS_READ_ERROR. By simply removing
that check, an interlaced image loads just fine.
|
|
Compare the current output against a previous run to determine if there
has been any change since last time, and only run through imagediff if
there has been. For the vector surfaces, we can check the vector output
first and potentially skip the rasterisation. On my machine this reduces
the time for a second run from 6 minutes to 2m30s. As most of the time,
most test output will remain unchanged, so this seems to be a big win. On
unix systems, hard linking is used to reduce the amount of storage space
required - others will see about a three-fold increase in the amount of
disk used. The directory continues to be a stress test for file selectors.
In order to reduce the changes between runs, the current time is no longer
written to the PNG files (justified by that it only exists as a debugging
aid) and the boilerplate tweaks the PS surface so that the creation date
is fixed. To fully realise the benefits here, we need to strip the
creation time from all the reference images...
The biggest problem with using the caches is that different runs of the
test suite can go through different code paths, introducing potential
Heisenbergs. If you suspect that caching is interfering with the test
results, use 'make -C test clean-caches check'.
|
|
libpng changed behaviour in v1.2.30 to call the png_ptr->output_flush_fn
in png_write_end(). If no flush function is provided with
png_set_write_fn(), libpng will use its default fflush() instead - which
assumes that closure passed is a FILE* and not an arbitrary user pointer.
Consequently, we must actually set a dummy output_flush_fn to avoid
segfaulting.
|
|
|
|
|
|
Otherwise libpng gets very confused and we start scribbling over invalid
memory whilst reading in the PNG.
|
|
After specifying how to transform the various colour modes into ones we
can handle, re-read the image header to confirm that the output on
reading the PNG will be RGB24 or ARGB32. This simplifies our logic
considerably as we no longer have to second guess the colour space
transformation that will be performed by libpng. (And allows for some
paranoid checks.)
|
|
jeremie54 reported a regression in the handling of transparent paletted
PNGs beween 1.4.14 and 1.6.4. This was caused by the change to load
opaque PNGs into a RGB24 image surface, which made the assumption that
indexed PNGs were opaque. However, alpha/transparency in PNG is more
complicated, as PNG uses a tRNS chunk to supply transparency data for
paletted images and other image types that don't need a full alpha
channel. Therefore if the PNG contains a tRNS chunk always generate an
ARGB32 surface.
|
|
Cut'n'paste from commit c1f765:
Without these checks, a user could hit an assertion failure by passing
a finished surface to cairo_surface_write_to_png_stream. Now we return
a nice CAIRO_STATUS_SURFACE_FINISHED error in that case instead.
|
|
Without these checks, a user could hit an assertion failure
by passing a finished surface to cairo_surface_write_to_png.
Now we return a nice CAIRO_STATUS_SURFACE_FINISHED error in
that case instead.
|
|
For PNG_COLOR_TYPE_GRAY images the bKGD value is read from white.gray
which was uninitialized, triggering the "PNG warning = Ignoring attempt
to write bKGD chunk out-of-range for bit_depth" reported by Emmanuel
Pacaud. This patch sets the background gray value to white, the same as
for RGB images.
|
|
Whilst splitting the patches, I left in this line which would preserve
1-bit grayscale unexpanded, but without any of the other FORMAT_A1
support.
|
|
If the PNG does not have an alpha channel, then create an opaque image.
|
|
Use cairo_format_stride_for_width() instead of assuming the pixel size
and manually calculating the row stride. This should make it easier to
support loading multiple image formats in future.
|
|
On some OOM paths, libpng raises a warning as opposed to an error,
these were not being propagated back to the caller. We were also not
checking that we did not overwrite a pre-existing error status when
raising an error whilst performing I/O.
|
|
Only translate an UNSUPPORTED error into a SURFACE_TYPE_MISMATCH, all
others can be returned to the user unadulterated.
PNG doesn't support width==0 or height==0 and generates an error
whilst writing - which without further information is assumed to be
a NO_MEMORY error. So check the image size at the start and return a
WRITE_ERROR for a zero sized image.
|
|
|
|
|
|
Unexport all the static error surfaces and use a function to select
the appropriate error surface for the status.
|
|
After using fopen() and friends check the global errno to determine the
most appropriate error return - especially important when running
memfault, where correct reporting of NO_MEMORY errors is required.
|
|
We need to check for both ferror() and feof() when handling short reads.
|
|
If libpng has not been compiled with jmpbuf support, then we cannot
atempt to use it - in which case we fall back to png's default error
handler and abort.
|
|
gcc warns that 'rows' is missing a volatile qualifier - so add it.
|
|
Add the _cairo_error() markup to the original error sites within the png
read/write functions.
|
|
Every time we assign or return a hard-coded error status wrap that value
with a call to _cairo_error(). So the idiom becomes:
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
or
return _cairo_error (CAIRO_STATUS_INVALID_DASH);
This ensures that a breakpoint placed on _cairo_error() will trigger
immediately cairo detects the error.
|
|
Use the png_struct->error_ptr to propagate the error status from the
user/stdio read and write functions through the png_error() to the
cairo_surface_write_to_png*() and cairo_surface_read_from_png*()
functions. From there the error is returned back to the user either
directly or as the most appropriate error surface.
(Fixes https://bugs.freedesktop.org/show_bug.cgi?id=6909)
|
|
Avoid calling malloc(0) for an empty image.
|
|
This patch introduces three macros: _cairo_malloc_ab,
_cairo_malloc_abc, _cairo_malloc_ab_plus_c and replaces various calls
to malloc(a*b), malloc(a*b*c), and malloc(a*b+c) with them. The macros
return NULL if int overflow would occur during the allocation. See
CODING_STYLE for more information.
|
|
For some reason this was returning CAIRO_STATUS_NULL_POINTER.
Now fixed to return CAIRO_STATUS_INVALID_FORMAT.
|
|
|
|
With the introduction of the error callbacks for PNG, we have the
opportunity for the user to set a breakpoint (via _cairo_error) at the
point the error is first rasied.
|
|
We wish to avoid writing to file descriptors (and streams) that are
outside cairo's control. In this case, the messages are superfluous as
the errors are propagated via the cairo_status_t returns.
|
|
png_set_gray_1_2_4_to_8 is deprecated in libpng >= 1.2.9, the identical
substitute for it is png_set_expand_gray_1_2_4_to_8
|
|
I introduced some compiler warnings into read_png() with the superfluous
introduction of a couple of volatile qualifiers. I'm sure at the time,
the reason was that gcc suggested adding them - however, ATM gcc issues
no warnings without them.
|
|
During MT cairo testing we get the error "libpng: Read Error" which is
emitted should the fread return fewer bytes than asked. However, this is
not necessarily an error, so double-check the ferror() status before
raising a png_error().
|
|
This is necessary to avoid many portability problems as cairoint.h includes
config.h. Without a test, we will regress again, hence add it.
The inclusion idiom for cairo now is:
#include "cairoint.h"
#include "cairo-something.h"
#include "cairo-anotherthing-private.h"
#include <some-library.h>
#include <other-library/other-file.h>
Moreover, some standard headers files are included from cairoint.h and need
not be included again.
|