diff options
Diffstat (limited to 'fitz')
-rw-r--r-- | fitz/base_geometry.c | 110 | ||||
-rw-r--r-- | fitz/fitz-internal.h | 28 | ||||
-rw-r--r-- | fitz/fitz.h | 34 | ||||
-rw-r--r-- | fitz/res_font.c | 16 | ||||
-rw-r--r-- | fitz/res_pixmap.c | 29 |
5 files changed, 148 insertions, 69 deletions
diff --git a/fitz/base_geometry.c b/fitz/base_geometry.c index 1486279f..317c8df1 100644 --- a/fitz/base_geometry.c +++ b/fitz/base_geometry.c @@ -3,6 +3,24 @@ #define MAX4(a,b,c,d) fz_max(fz_max(a,b), fz_max(c,d)) #define MIN4(a,b,c,d) fz_min(fz_min(a,b), fz_min(c,d)) +/* A useful macro to add with overflow detection and clamping. + + We want to do "b = a + x", but to allow for overflow. Consider the + top bits, and the cases in which overflow occurs: + + overflow a x b ~a^x a^b (~a^x)&(a^b) + no 0 0 0 1 0 0 + yes 0 0 1 1 1 1 + no 0 1 0 0 0 0 + no 0 1 1 0 1 0 + no 1 0 0 0 1 0 + no 1 0 1 0 0 0 + yes 1 1 0 1 1 1 + no 1 1 1 1 0 0 +*/ +#define ADD_WITH_SAT(b,a,x) \ + ((b) = (a) + (x), (b) = (((~(a)^(x))&((a)^(b))) < 0 ? ((x) < 0 ? INT_MIN : INT_MAX) : (b))) + /* Matrices, points and affine transformations */ const fz_matrix fz_identity = { 1, 0, 0, 1, 0, 0 }; @@ -170,36 +188,57 @@ const fz_rect fz_infinite_rect = { 1, 1, -1, -1 }; const fz_rect fz_empty_rect = { 0, 0, 0, 0 }; const fz_rect fz_unit_rect = { 0, 0, 1, 1 }; -fz_rect -fz_rect_covering_rect(fz_rect f) +const fz_irect fz_infinite_irect = { 1, 1, -1, -1 }; +const fz_irect fz_empty_irect = { 0, 0, 0, 0 }; +const fz_irect fz_unit_irect = { 0, 0, 1, 1 }; + +fz_irect +fz_rect_covering_rect(fz_rect a) { - f.x0 = floorf(f.x0); - f.y0 = floorf(f.y0); - f.x1 = ceilf(f.x1); - f.y1 = ceilf(f.y1); + fz_irect b; + + a.x0 = floorf(a.x0); + a.y0 = floorf(a.y0); + a.x1 = ceilf(a.x1); + a.y1 = ceilf(a.y1); /* check for integer overflow */ - f.x0 = fz_clamp(f.x0, MIN_SAFE_INT, MAX_SAFE_INT); - f.y0 = fz_clamp(f.y0, MIN_SAFE_INT, MAX_SAFE_INT); - f.x1 = fz_clamp(f.x1, MIN_SAFE_INT, MAX_SAFE_INT); - f.y1 = fz_clamp(f.y1, MIN_SAFE_INT, MAX_SAFE_INT); - return f; + b.x0 = fz_clamp(a.x0, MIN_SAFE_INT, MAX_SAFE_INT); + b.y0 = fz_clamp(a.y0, MIN_SAFE_INT, MAX_SAFE_INT); + b.x1 = fz_clamp(a.x1, MIN_SAFE_INT, MAX_SAFE_INT); + b.y1 = fz_clamp(a.y1, MIN_SAFE_INT, MAX_SAFE_INT); + + return b; } fz_rect -fz_round_rect(fz_rect f) +fz_rect_from_irect(fz_irect a) { - f.x0 = floorf(f.x0 + 0.001); - f.y0 = floorf(f.y0 + 0.001); - f.x1 = ceilf(f.x1 - 0.001); - f.y1 = ceilf(f.y1 - 0.001); + fz_rect b; + b.x0 = a.x0; + b.y0 = a.y0; + b.x1 = a.x1; + b.y1 = a.y1; + return b; +} + +fz_irect +fz_round_rect(fz_rect a) +{ + fz_irect b; + + a.x0 = floorf(a.x0 + 0.001); + a.y0 = floorf(a.y0 + 0.001); + a.x1 = ceilf(a.x1 - 0.001); + a.y1 = ceilf(a.y1 - 0.001); /* check for integer overflow */ - f.x0 = fz_clamp(f.x0, MIN_SAFE_INT, MAX_SAFE_INT); - f.y0 = fz_clamp(f.y0, MIN_SAFE_INT, MAX_SAFE_INT); - f.x1 = fz_clamp(f.x1, MIN_SAFE_INT, MAX_SAFE_INT); - f.y1 = fz_clamp(f.y1, MIN_SAFE_INT, MAX_SAFE_INT); - return f; + b.x0 = fz_clamp(a.x0, MIN_SAFE_INT, MAX_SAFE_INT); + b.y0 = fz_clamp(a.y0, MIN_SAFE_INT, MAX_SAFE_INT); + b.x1 = fz_clamp(a.x1, MIN_SAFE_INT, MAX_SAFE_INT); + b.y1 = fz_clamp(a.y1, MIN_SAFE_INT, MAX_SAFE_INT); + + return b; } fz_rect @@ -218,6 +257,22 @@ fz_intersect_rect(fz_rect a, fz_rect b) return (r.x1 < r.x0 || r.y1 < r.y0) ? fz_empty_rect : r; } +fz_irect +fz_intersect_irect(fz_irect a, fz_irect b) +{ + fz_irect r; + /* Check for empty box before infinite box */ + if (fz_is_empty_rect(a)) return fz_empty_irect; + if (fz_is_empty_rect(b)) return fz_empty_irect; + if (fz_is_infinite_rect(a)) return b; + if (fz_is_infinite_rect(b)) return a; + r.x0 = fz_maxi(a.x0, b.x0); + r.y0 = fz_maxi(a.y0, b.y0); + r.x1 = fz_mini(a.x1, b.x1); + r.y1 = fz_mini(a.y1, b.y1); + return (r.x1 < r.x0 || r.y1 < r.y0) ? fz_empty_irect : r; +} + fz_rect fz_union_rect(fz_rect a, fz_rect b) { @@ -270,6 +325,19 @@ fz_translate_rect(fz_rect a, float xoff, float yoff) return b; } +fz_irect +fz_translate_irect(fz_irect a, int xoff, int yoff) +{ + fz_irect b; + if (fz_is_empty_rect(a)) return a; + if (fz_is_infinite_rect(a)) return a; + ADD_WITH_SAT(b.x0, a.x0, xoff); + ADD_WITH_SAT(b.y0, a.y0, yoff); + ADD_WITH_SAT(b.x1, a.x1, xoff); + ADD_WITH_SAT(b.y1, a.y1, yoff); + return b; +} + fz_rect fz_expand_rect(fz_rect a, float expand) { diff --git a/fitz/fitz-internal.h b/fitz/fitz-internal.h index e7e7ca3b..518ed8c2 100644 --- a/fitz/fitz-internal.h +++ b/fitz/fitz-internal.h @@ -872,22 +872,22 @@ struct fz_pixmap_s void fz_free_pixmap_imp(fz_context *ctx, fz_storable *pix); -void fz_copy_pixmap_rect(fz_context *ctx, fz_pixmap *dest, fz_pixmap *src, fz_rect r); +void fz_copy_pixmap_rect(fz_context *ctx, fz_pixmap *dest, fz_pixmap *src, fz_irect r); void fz_premultiply_pixmap(fz_context *ctx, fz_pixmap *pix); fz_pixmap *fz_alpha_from_gray(fz_context *ctx, fz_pixmap *gray, int luminosity); unsigned int fz_pixmap_size(fz_context *ctx, fz_pixmap *pix); -fz_pixmap *fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, float h, fz_rect *clip); +fz_pixmap *fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, float h, fz_irect *clip); typedef struct fz_scale_cache_s fz_scale_cache; fz_scale_cache *fz_new_scale_cache(fz_context *ctx); void fz_free_scale_cache(fz_context *ctx, fz_scale_cache *cache); -fz_pixmap *fz_scale_pixmap_cached(fz_context *ctx, fz_pixmap *src, float x, float y, float w, float h, fz_rect *clip, fz_scale_cache *cache_x, fz_scale_cache *cache_y); +fz_pixmap *fz_scale_pixmap_cached(fz_context *ctx, fz_pixmap *src, float x, float y, float w, float h, fz_irect *clip, fz_scale_cache *cache_x, fz_scale_cache *cache_y); void fz_subsample_pixmap(fz_context *ctx, fz_pixmap *tile, int factor); -fz_rect fz_pixmap_bbox_no_ctx(fz_pixmap *src); +fz_irect fz_pixmap_bbox_no_ctx(fz_pixmap *src); typedef struct fz_compression_params_s fz_compression_params; @@ -1187,10 +1187,10 @@ void fz_purge_glyph_cache(fz_context *ctx); fz_path *fz_outline_ft_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm); fz_path *fz_outline_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix ctm); fz_pixmap *fz_render_ft_glyph(fz_context *ctx, fz_font *font, int cid, fz_matrix trm, int aa); -fz_pixmap *fz_render_t3_glyph(fz_context *ctx, fz_font *font, int cid, fz_matrix trm, fz_colorspace *model, fz_rect scissor); +fz_pixmap *fz_render_t3_glyph(fz_context *ctx, fz_font *font, int cid, fz_matrix trm, fz_colorspace *model, fz_irect scissor); fz_pixmap *fz_render_ft_stroked_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm, fz_matrix ctm, fz_stroke_state *state); -fz_pixmap *fz_render_glyph(fz_context *ctx, fz_font*, int, fz_matrix, fz_colorspace *model, fz_rect scissor); -fz_pixmap *fz_render_stroked_glyph(fz_context *ctx, fz_font*, int, fz_matrix, fz_matrix, fz_stroke_state *stroke, fz_rect scissor); +fz_pixmap *fz_render_glyph(fz_context *ctx, fz_font*, int, fz_matrix, fz_colorspace *model, fz_irect scissor); +fz_pixmap *fz_render_stroked_glyph(fz_context *ctx, fz_font*, int, fz_matrix, fz_matrix, fz_stroke_state *stroke, fz_irect scissor); void fz_render_t3_glyph_direct(fz_context *ctx, fz_device *dev, fz_font *font, int gid, fz_matrix trm, void *gstate, int nestedDepth); void fz_prepare_t3_glyph(fz_context *ctx, fz_font *font, int gid, int nestedDepth); @@ -1300,7 +1300,7 @@ void fz_drop_shade(fz_context *ctx, fz_shade *shade); void fz_free_shade_imp(fz_context *ctx, fz_storable *shade); fz_rect fz_bound_shade(fz_context *ctx, fz_shade *shade, fz_matrix ctm); -void fz_paint_shade(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_rect bbox); +void fz_paint_shade(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_irect bbox); /* * Handy routine for processing mesh based shades @@ -1339,13 +1339,13 @@ typedef struct fz_gel_s fz_gel; fz_gel *fz_new_gel(fz_context *ctx); void fz_insert_gel(fz_gel *gel, float x0, float y0, float x1, float y1); -void fz_reset_gel(fz_gel *gel, fz_rect clip); +void fz_reset_gel(fz_gel *gel, fz_irect clip); void fz_sort_gel(fz_gel *gel); -fz_rect fz_bound_gel(fz_gel *gel); +fz_irect fz_bound_gel(fz_gel *gel); void fz_free_gel(fz_gel *gel); int fz_is_rect_gel(fz_gel *gel); -void fz_scan_convert(fz_gel *gel, int eofill, fz_rect clip, fz_pixmap *pix, unsigned char *colorbv); +void fz_scan_convert(fz_gel *gel, int eofill, fz_irect clip, fz_pixmap *pix, unsigned char *colorbv); void fz_flatten_fill_path(fz_gel *gel, fz_path *path, fz_matrix ctm, float flatness); void fz_flatten_stroke_path(fz_gel *gel, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm, float flatness, float linewidth); @@ -1458,12 +1458,12 @@ void fz_paint_solid_color(unsigned char * restrict dp, int n, int w, unsigned ch void fz_paint_span(unsigned char * restrict dp, unsigned char * restrict sp, int n, int w, int alpha); void fz_paint_span_with_color(unsigned char * restrict dp, unsigned char * restrict mp, int n, int w, unsigned char *color); -void fz_paint_image(fz_pixmap *dst, fz_rect scissor, fz_pixmap *shape, fz_pixmap *img, fz_matrix ctm, int alpha); -void fz_paint_image_with_color(fz_pixmap *dst, fz_rect scissor, fz_pixmap *shape, fz_pixmap *img, fz_matrix ctm, unsigned char *colorbv); +void fz_paint_image(fz_pixmap *dst, fz_irect scissor, fz_pixmap *shape, fz_pixmap *img, fz_matrix ctm, int alpha); +void fz_paint_image_with_color(fz_pixmap *dst, fz_irect scissor, fz_pixmap *shape, fz_pixmap *img, fz_matrix ctm, unsigned char *colorbv); void fz_paint_pixmap(fz_pixmap *dst, fz_pixmap *src, int alpha); void fz_paint_pixmap_with_mask(fz_pixmap *dst, fz_pixmap *src, fz_pixmap *msk); -void fz_paint_pixmap_with_bbox(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_rect bbox); +void fz_paint_pixmap_with_bbox(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_irect bbox); void fz_blend_pixmap(fz_pixmap *dst, fz_pixmap *src, int alpha, int blendmode, int isolated, fz_pixmap *shape); void fz_blend_pixel(unsigned char dp[3], unsigned char bp[3], unsigned char sp[3], int blendmode); diff --git a/fitz/fitz.h b/fitz/fitz.h index 7243c341..0e025e44 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -748,6 +748,18 @@ struct fz_rect_s }; /* + fz_irect is a rectangle using integers instead of floats. + + It's used in the draw device and for pixmap dimensions. +*/ +typedef struct fz_irect_s fz_irect; +struct fz_irect_s +{ + int x0, y0; + int x1, y1; +}; + +/* A rectangle with sides of length one. The bottom left corner is at (0, 0) and the top right corner @@ -761,6 +773,7 @@ extern const fz_rect fz_unit_rect; Both the top left and bottom right corner are at (0, 0). */ extern const fz_rect fz_empty_rect; +extern const fz_irect fz_empty_irect; /* An infinite rectangle with negative area. @@ -769,6 +782,7 @@ extern const fz_rect fz_empty_rect; at (-1, -1). */ extern const fz_rect fz_infinite_rect; +extern const fz_irect fz_infinite_irect; /* fz_is_empty_rect: Check if rectangle is empty. @@ -912,6 +926,7 @@ float fz_matrix_expansion(fz_matrix m); /* sumatrapdf */ Does not throw exceptions. */ fz_rect fz_intersect_rect(fz_rect a, fz_rect b); +fz_irect fz_intersect_irect(fz_irect a, fz_irect b); /* fz_union_rect: Compute union of two rectangles. @@ -938,7 +953,7 @@ fz_rect fz_union_rect(fz_rect a, fz_rect b); Does not throw exceptions. */ -fz_rect fz_rect_covering_rect(fz_rect rect); +fz_irect fz_rect_covering_rect(fz_rect rect); /* fz_round_rect: Round rectangle coordinates. @@ -956,7 +971,9 @@ fz_rect fz_rect_covering_rect(fz_rect rect); Does not throw exceptions. */ -fz_rect fz_round_rect(fz_rect rect); +fz_irect fz_round_rect(fz_rect rect); + +fz_rect fz_rect_from_irect(fz_irect rect); /* fz_expand_rect: Expand a bbox by a given amount in all directions. @@ -973,6 +990,7 @@ fz_rect fz_expand_rect(fz_rect b, float expand); Does not throw exceptions. */ fz_rect fz_translate_rect(fz_rect a, float xoff, float yoff); +fz_irect fz_translate_irect(fz_irect a, int xoff, int yoff); /* fz_transform_point: Apply a transformation to a point. @@ -1245,7 +1263,7 @@ typedef struct fz_pixmap_s fz_pixmap; /* fz_pixmap_bbox: Return the bounding box for a pixmap. */ -fz_rect fz_pixmap_bbox(fz_context *ctx, fz_pixmap *pix); +fz_irect fz_pixmap_bbox(fz_context *ctx, fz_pixmap *pix); /* fz_pixmap_width: Return the width of the pixmap in pixels. @@ -1289,7 +1307,7 @@ fz_pixmap *fz_new_pixmap(fz_context *ctx, fz_colorspace *cs, int w, int h); Returns a pointer to the new pixmap. Throws exception on failure to allocate. */ -fz_pixmap *fz_new_pixmap_with_bbox(fz_context *ctx, fz_colorspace *colorspace, fz_rect bbox); +fz_pixmap *fz_new_pixmap_with_bbox(fz_context *ctx, fz_colorspace *colorspace, fz_irect bbox); /* fz_new_pixmap_with_data: Create a new pixmap, with it's origin at @@ -1328,7 +1346,7 @@ fz_pixmap *fz_new_pixmap_with_data(fz_context *ctx, fz_colorspace *colorspace, i Returns a pointer to the new pixmap. Throws exception on failure to allocate. */ -fz_pixmap *fz_new_pixmap_with_bbox_and_data(fz_context *ctx, fz_colorspace *colorspace, fz_rect rect, unsigned char *samples); +fz_pixmap *fz_new_pixmap_with_bbox_and_data(fz_context *ctx, fz_colorspace *colorspace, fz_irect rect, unsigned char *samples); /* fz_keep_pixmap: Take a reference to a pixmap. @@ -1396,7 +1414,7 @@ void fz_clear_pixmap_with_value(fz_context *ctx, fz_pixmap *pix, int value); Does not throw exceptions. */ -void fz_clear_pixmap_rect_with_value(fz_context *ctx, fz_pixmap *pix, int value, fz_rect r); +void fz_clear_pixmap_rect_with_value(fz_context *ctx, fz_pixmap *pix, int value, fz_irect r); /* fz_clear_pixmap_with_value: Sets all components (including alpha) of @@ -1423,7 +1441,7 @@ void fz_invert_pixmap(fz_context *ctx, fz_pixmap *pix); Does not throw exceptions. */ -void fz_invert_pixmap_rect(fz_pixmap *image, fz_rect rect); +void fz_invert_pixmap_rect(fz_pixmap *image, fz_irect rect); /* fz_gamma_pixmap: Apply gamma correction to a pixmap. All components @@ -1624,7 +1642,7 @@ fz_device *fz_new_draw_device(fz_context *ctx, fz_pixmap *dest); clip: Bounding box to restrict any marking operations of the draw device. */ -fz_device *fz_new_draw_device_with_bbox(fz_context *ctx, fz_pixmap *dest, fz_rect clip); +fz_device *fz_new_draw_device_with_bbox(fz_context *ctx, fz_pixmap *dest, fz_irect clip); /* Text extraction device: Used for searching, format conversion etc. diff --git a/fitz/res_font.c b/fitz/res_font.c index 1b07d060..56481962 100644 --- a/fitz/res_font.c +++ b/fitz/res_font.c @@ -887,11 +887,12 @@ fz_bound_t3_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm) } fz_pixmap * -fz_render_t3_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm, fz_colorspace *model, fz_rect scissor) +fz_render_t3_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm, fz_colorspace *model, fz_irect scissor) { fz_display_list *list; fz_matrix ctm; - fz_rect bbox; + fz_rect bounds; + fz_irect bbox; fz_device *dev; fz_pixmap *glyph; fz_pixmap *result; @@ -920,13 +921,10 @@ fz_render_t3_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm, fz_co model = NULL; /* Treat as masked */ } - bbox = fz_bound_glyph(ctx, font, gid, trm); - bbox.x0 -= 1; - bbox.y0 -= 1; - bbox.x1 += 1; - bbox.y1 += 1; - - bbox = fz_intersect_rect(bbox, scissor); + bounds = fz_bound_glyph(ctx, font, gid, trm); + bounds = fz_expand_rect(bounds, 1); + bbox = fz_rect_covering_rect(bounds); + bbox = fz_intersect_irect(bbox, scissor); glyph = fz_new_pixmap_with_bbox(ctx, model ? model : fz_device_gray, bbox); fz_clear_pixmap(ctx, glyph); diff --git a/fitz/res_pixmap.c b/fitz/res_pixmap.c index eb5d58ef..60e615ec 100644 --- a/fitz/res_pixmap.c +++ b/fitz/res_pixmap.c @@ -83,9 +83,8 @@ fz_new_pixmap(fz_context *ctx, fz_colorspace *colorspace, int w, int h) } fz_pixmap * -fz_new_pixmap_with_bbox(fz_context *ctx, fz_colorspace *colorspace, fz_rect rf) +fz_new_pixmap_with_bbox(fz_context *ctx, fz_colorspace *colorspace, fz_irect r) { - fz_rect r = fz_round_rect(rf); fz_pixmap *pixmap = fz_new_pixmap(ctx, colorspace, r.x1 - r.x0, r.y1 - r.y0); pixmap->x = r.x0; pixmap->y = r.y0; @@ -93,19 +92,18 @@ fz_new_pixmap_with_bbox(fz_context *ctx, fz_colorspace *colorspace, fz_rect rf) } fz_pixmap * -fz_new_pixmap_with_bbox_and_data(fz_context *ctx, fz_colorspace *colorspace, fz_rect rf, unsigned char *samples) +fz_new_pixmap_with_bbox_and_data(fz_context *ctx, fz_colorspace *colorspace, fz_irect r, unsigned char *samples) { - fz_rect r = fz_round_rect(rf); fz_pixmap *pixmap = fz_new_pixmap_with_data(ctx, colorspace, r.x1 - r.x0, r.y1 - r.y0, samples); pixmap->x = r.x0; pixmap->y = r.y0; return pixmap; } -fz_rect +fz_irect fz_pixmap_bbox(fz_context *ctx, fz_pixmap *pix) { - fz_rect bbox; + fz_irect bbox; bbox.x0 = pix->x; bbox.y0 = pix->y; bbox.x1 = pix->x + pix->w; @@ -113,10 +111,10 @@ fz_pixmap_bbox(fz_context *ctx, fz_pixmap *pix) return bbox; } -fz_rect +fz_irect fz_pixmap_bbox_no_ctx(fz_pixmap *pix) { - fz_rect bbox; + fz_irect bbox; bbox.x0 = pix->x; bbox.y0 = pix->y; bbox.x1 = pix->x + pix->w; @@ -166,15 +164,14 @@ fz_clear_pixmap_with_value(fz_context *ctx, fz_pixmap *pix, int value) } void -fz_copy_pixmap_rect(fz_context *ctx, fz_pixmap *dest, fz_pixmap *src, fz_rect r) +fz_copy_pixmap_rect(fz_context *ctx, fz_pixmap *dest, fz_pixmap *src, fz_irect r) { const unsigned char *srcp; unsigned char *destp; int x, y, w, destspan, srcspan; - r = fz_round_rect(r); - r = fz_intersect_rect(r, fz_pixmap_bbox(ctx, dest)); - r = fz_intersect_rect(r, fz_pixmap_bbox(ctx, src)); + r = fz_intersect_irect(r, fz_pixmap_bbox(ctx, dest)); + r = fz_intersect_irect(r, fz_pixmap_bbox(ctx, src)); w = r.x1 - r.x0; y = r.y1 - r.y0; if (w <= 0 || y <= 0) @@ -267,13 +264,12 @@ fz_copy_pixmap_rect(fz_context *ctx, fz_pixmap *dest, fz_pixmap *src, fz_rect r) } void -fz_clear_pixmap_rect_with_value(fz_context *ctx, fz_pixmap *dest, int value, fz_rect r) +fz_clear_pixmap_rect_with_value(fz_context *ctx, fz_pixmap *dest, int value, fz_irect r) { unsigned char *destp; int x, y, w, k, destspan; - r = fz_round_rect(r); - r = fz_intersect_rect(r, fz_pixmap_bbox(ctx, dest)); + r = fz_intersect_irect(r, fz_pixmap_bbox(ctx, dest)); w = r.x1 - r.x0; y = r.y1 - r.y0; if (w <= 0 || y <= 0) @@ -384,13 +380,12 @@ fz_invert_pixmap(fz_context *ctx, fz_pixmap *pix) } } -void fz_invert_pixmap_rect(fz_pixmap *image, fz_rect r) +void fz_invert_pixmap_rect(fz_pixmap *image, fz_irect r) { unsigned char *p; int x0, x1, y0, y1; int x, y, n; - r = fz_round_rect(r); x0 = fz_clampi(r.x0 - image->x, 0, image->w - 1); x1 = fz_clampi(r.x1 - image->x, 0, image->w - 1); y0 = fz_clampi(r.y0 - image->y, 0, image->h - 1); |