1 /* Libart_LGPL - library of basic graphic primitives
2 * Copyright (C) 1998 Raph Levien
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 #include "art_uta_rect.h"
28 * art_uta_from_irect: Generate uta covering a rectangle.
29 * @bbox: The source rectangle.
31 * Generates a uta exactly covering @bbox. Please do not call this
32 * function with a @bbox with zero height or width.
34 * Return value: the new uta.
37 art_uta_from_irect (ArtIRect
*bbox
)
44 int xf0
, yf0
, xf1
, yf1
;
47 uta
= art_new (ArtUta
, 1);
48 uta
->x0
= bbox
->x0
>> ART_UTILE_SHIFT
;
49 uta
->y0
= bbox
->y0
>> ART_UTILE_SHIFT
;
50 width
= ((bbox
->x1
+ ART_UTILE_SIZE
- 1) >> ART_UTILE_SHIFT
) - uta
->x0
;
51 height
= ((bbox
->y1
+ ART_UTILE_SIZE
- 1) >> ART_UTILE_SHIFT
) - uta
->y0
;
52 utiles
= art_new (ArtUtaBbox
, width
* height
);
58 xf0
= bbox
->x0
& (ART_UTILE_SIZE
- 1);
59 yf0
= bbox
->y0
& (ART_UTILE_SIZE
- 1);
60 xf1
= ((bbox
->x1
- 1) & (ART_UTILE_SIZE
- 1)) + 1;
61 yf1
= ((bbox
->y1
- 1) & (ART_UTILE_SIZE
- 1)) + 1;
65 utiles
[0] = ART_UTA_BBOX_CONS (xf0
, yf0
, xf1
, yf1
);
68 utiles
[0] = ART_UTA_BBOX_CONS (xf0
, yf0
, ART_UTILE_SIZE
, yf1
);
69 bb
= ART_UTA_BBOX_CONS (0, yf0
, ART_UTILE_SIZE
, yf1
);
70 for (x
= 1; x
< width
- 1; x
++)
72 utiles
[x
] = ART_UTA_BBOX_CONS (0, yf0
, xf1
, yf1
);
79 utiles
[0] = ART_UTA_BBOX_CONS (xf0
, yf0
, xf1
, ART_UTILE_SIZE
);
80 bb
= ART_UTA_BBOX_CONS (xf0
, 0, xf1
, ART_UTILE_SIZE
);
81 for (y
= 1; y
< height
- 1; y
++)
83 utiles
[y
] = ART_UTA_BBOX_CONS (xf0
, 0, xf1
, yf1
);
88 ART_UTA_BBOX_CONS (xf0
, yf0
, ART_UTILE_SIZE
, ART_UTILE_SIZE
);
89 bb
= ART_UTA_BBOX_CONS (0, yf0
, ART_UTILE_SIZE
, ART_UTILE_SIZE
);
90 for (x
= 1; x
< width
- 1; x
++)
92 utiles
[x
] = ART_UTA_BBOX_CONS (0, yf0
, xf1
, ART_UTILE_SIZE
);
94 for (y
= 1; y
< height
- 1; y
++)
97 ART_UTA_BBOX_CONS (xf0
, 0, ART_UTILE_SIZE
, ART_UTILE_SIZE
);
98 bb
= ART_UTA_BBOX_CONS (0, 0, ART_UTILE_SIZE
, ART_UTILE_SIZE
);
99 for (x
= 1; x
< width
- 1; x
++)
101 utiles
[ix
++] = ART_UTA_BBOX_CONS (0, 0, xf1
, ART_UTILE_SIZE
);
103 utiles
[ix
++] = ART_UTA_BBOX_CONS (xf0
, 0, ART_UTILE_SIZE
, yf1
);
104 bb
= ART_UTA_BBOX_CONS (0, 0, ART_UTILE_SIZE
, yf1
);
105 for (x
= 1; x
< width
- 1; x
++)
107 utiles
[ix
++] = ART_UTA_BBOX_CONS (0, 0, xf1
, yf1
);