Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4680 right-hear 1
#include "fitz.h"
2
 
3
/* TODO: add clip stack and use to intersect bboxes */
4
 
5
static void
6
fz_bbox_fill_path(void *user, fz_path *path, int even_odd, fz_matrix ctm,
7
	fz_colorspace *colorspace, float *color, float alpha)
8
{
9
	fz_bbox *result = user;
10
	fz_bbox bbox = fz_round_rect(fz_bound_path(path, NULL, ctm));
11
	*result = fz_union_bbox(*result, bbox);
12
}
13
 
14
static void
15
fz_bbox_stroke_path(void *user, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm,
16
	fz_colorspace *colorspace, float *color, float alpha)
17
{
18
	fz_bbox *result = user;
19
	fz_bbox bbox = fz_round_rect(fz_bound_path(path, stroke, ctm));
20
	*result = fz_union_bbox(*result, bbox);
21
}
22
 
23
static void
24
fz_bbox_fill_text(void *user, fz_text *text, fz_matrix ctm,
25
	fz_colorspace *colorspace, float *color, float alpha)
26
{
27
	fz_bbox *result = user;
28
	fz_bbox bbox = fz_round_rect(fz_bound_text(text, ctm));
29
	*result = fz_union_bbox(*result, bbox);
30
}
31
 
32
static void
33
fz_bbox_stroke_text(void *user, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm,
34
	fz_colorspace *colorspace, float *color, float alpha)
35
{
36
	fz_bbox *result = user;
37
	fz_bbox bbox = fz_round_rect(fz_bound_text(text, ctm));
38
	*result = fz_union_bbox(*result, bbox);
39
}
40
 
41
static void
42
fz_bbox_fill_shade(void *user, fz_shade *shade, fz_matrix ctm, float alpha)
43
{
44
	fz_bbox *result = user;
45
	fz_bbox bbox = fz_round_rect(fz_bound_shade(shade, ctm));
46
	*result = fz_union_bbox(*result, bbox);
47
}
48
 
49
static void
50
fz_bbox_fill_image(void *user, fz_pixmap *image, fz_matrix ctm, float alpha)
51
{
52
	fz_bbox *result = user;
53
	fz_bbox bbox = fz_round_rect(fz_transform_rect(ctm, fz_unit_rect));
54
	*result = fz_union_bbox(*result, bbox);
55
}
56
 
57
static void
58
fz_bbox_fill_image_mask(void *user, fz_pixmap *image, fz_matrix ctm,
59
	fz_colorspace *colorspace, float *color, float alpha)
60
{
61
	fz_bbox_fill_image(user, image, ctm, alpha);
62
}
63
 
64
fz_device *
65
fz_new_bbox_device(fz_bbox *result)
66
{
67
	fz_device *dev;
68
 
69
	dev = fz_new_device(result);
70
 
71
	dev->fill_path = fz_bbox_fill_path;
72
	dev->stroke_path = fz_bbox_stroke_path;
73
	dev->fill_text = fz_bbox_fill_text;
74
	dev->stroke_text = fz_bbox_stroke_text;
75
	dev->fill_shade = fz_bbox_fill_shade;
76
	dev->fill_image = fz_bbox_fill_image;
77
	dev->fill_image_mask = fz_bbox_fill_image_mask;
78
 
79
	*result = fz_empty_bbox;
80
 
81
	return dev;
82
}