mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-08 13:48:02 +02:00
do not ignore errors, return NULL instead (moz#874315)
In the quartz backend there are occasional errors where returning NULL can be used to signal that an error has occured. Mozilla bug #874315.
This commit is contained in:
parent
07fd091e3e
commit
6fec51990e
1 changed files with 28 additions and 9 deletions
|
|
@ -437,17 +437,23 @@ _cairo_quartz_surface_to_quartz (cairo_surface_t *target, cairo_surface_t *pat_s
|
|||
cairo_surface_t *ref_type = target;
|
||||
cairo_surface_t *new_surf = NULL;
|
||||
cairo_rectangle_int_t rect;
|
||||
cairo_status_t status;
|
||||
|
||||
if (ref_type == NULL)
|
||||
ref_type = cairo_quartz_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
|
||||
|
||||
_cairo_surface_get_extents (pat_surf, &rect);
|
||||
status = _cairo_surface_get_extents (pat_surf, &rect);
|
||||
if (status)
|
||||
return NULL;
|
||||
|
||||
_cairo_surface_clone_similar (ref_type, pat_surf, rect.x, rect.y,
|
||||
status = _cairo_surface_clone_similar (ref_type, pat_surf, rect.x, rect.y,
|
||||
rect.width, rect.height, &new_surf);
|
||||
|
||||
if (target == NULL)
|
||||
cairo_surface_destroy(ref_type);
|
||||
|
||||
if (status)
|
||||
return NULL;
|
||||
|
||||
quartz_surf = (cairo_quartz_surface_t *) new_surf;
|
||||
} else {
|
||||
/* If it's a quartz surface, we can try to see if it's a CGBitmapContext;
|
||||
|
|
@ -455,7 +461,6 @@ _cairo_quartz_surface_to_quartz (cairo_surface_t *target, cairo_surface_t *pat_s
|
|||
*/
|
||||
cairo_surface_reference (pat_surf);
|
||||
quartz_surf = (cairo_quartz_surface_t*) pat_surf;
|
||||
|
||||
}
|
||||
|
||||
return quartz_surf;
|
||||
|
|
@ -468,10 +473,15 @@ SurfacePatternDrawFunc (void *info, CGContextRef context)
|
|||
cairo_surface_pattern_t *spat = (cairo_surface_pattern_t *) info;
|
||||
cairo_surface_t *pat_surf = spat->surface;
|
||||
|
||||
cairo_quartz_surface_t *quartz_surf = _cairo_quartz_surface_to_quartz (NULL, pat_surf);
|
||||
CGImageRef img = CGBitmapContextCreateImage (quartz_surf->cgContext);
|
||||
cairo_quartz_surface_t *quartz_surf;
|
||||
CGImageRef img;
|
||||
CGRect imageBounds;
|
||||
|
||||
quartz_surf = _cairo_quartz_surface_to_quartz (NULL, pat_surf);
|
||||
if (!quartz_surf)
|
||||
return;
|
||||
|
||||
img = CGBitmapContextCreateImage (quartz_surf->cgContext);
|
||||
if (!img) {
|
||||
// ... give up.
|
||||
ND((stderr, "CGBitmapContextCreateImage failed\n"));
|
||||
|
|
@ -554,6 +564,7 @@ _cairo_quartz_cairo_repeating_surface_pattern_to_quartz (cairo_quartz_surface_t
|
|||
(CGFunctionReleaseInfoCallback) cairo_pattern_destroy };
|
||||
CGPatternRef cgpat;
|
||||
float rw, rh;
|
||||
cairo_status_t status;
|
||||
|
||||
cairo_pattern_union_t *snap_pattern = NULL;
|
||||
cairo_pattern_t *target_pattern = abspat;
|
||||
|
|
@ -566,7 +577,10 @@ _cairo_quartz_cairo_repeating_surface_pattern_to_quartz (cairo_quartz_surface_t
|
|||
spat = (cairo_surface_pattern_t *) abspat;
|
||||
pat_surf = spat->surface;
|
||||
|
||||
_cairo_surface_get_extents (pat_surf, &extents);
|
||||
status = _cairo_surface_get_extents (pat_surf, &extents);
|
||||
if (status)
|
||||
return NULL;
|
||||
|
||||
pbounds.origin.x = 0;
|
||||
pbounds.origin.y = 0;
|
||||
|
||||
|
|
@ -672,12 +686,17 @@ _cairo_quartz_setup_source (cairo_quartz_surface_t *surface,
|
|||
{
|
||||
cairo_surface_pattern_t *spat = (cairo_surface_pattern_t *) source;
|
||||
cairo_surface_t *pat_surf = spat->surface;
|
||||
cairo_quartz_surface_t *quartz_surf = _cairo_quartz_surface_to_quartz ((cairo_surface_t *) surface, pat_surf);
|
||||
CGImageRef img = CGBitmapContextCreateImage (quartz_surf->cgContext);
|
||||
cairo_quartz_surface_t *quartz_surf;
|
||||
CGImageRef img;
|
||||
cairo_matrix_t m = spat->base.matrix;
|
||||
cairo_rectangle_int_t extents;
|
||||
cairo_status_t status;
|
||||
|
||||
quartz_surf = _cairo_quartz_surface_to_quartz ((cairo_surface_t *) surface, pat_surf);
|
||||
if (!quartz_surf)
|
||||
return DO_UNSUPPORTED;
|
||||
|
||||
img = CGBitmapContextCreateImage (quartz_surf->cgContext);
|
||||
if (!img)
|
||||
return DO_UNSUPPORTED;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue