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.
23 #include "art_uta_rect.h"
26 * art_uta_from_irect: Generate uta covering a rectangle.
27 * @bbox: The source rectangle.
29 * Generates a uta exactly covering @bbox. Please do not call this
30 * function with a @bbox with zero height or width.
32 * Return value: the new uta.
35 art_uta_from_irect (ArtIRect *bbox)
42 int xf0, yf0, xf1, yf1;
45 uta = art_new (ArtUta, 1);
46 uta->x0 = bbox->x0 >> ART_UTILE_SHIFT;
47 uta->y0 = bbox->y0 >> ART_UTILE_SHIFT;
48 width = ((bbox->x1 + ART_UTILE_SIZE - 1) >> ART_UTILE_SHIFT) - uta->x0;
49 height = ((bbox->y1 + ART_UTILE_SIZE - 1) >> ART_UTILE_SHIFT) - uta->y0;
50 utiles = art_new (ArtUtaBbox, width * height);
56 xf0 = bbox->x0 & (ART_UTILE_SIZE - 1);
57 yf0 = bbox->y0 & (ART_UTILE_SIZE - 1);
58 xf1 = ((bbox->x1 - 1) & (ART_UTILE_SIZE - 1)) + 1;
59 yf1 = ((bbox->y1 - 1) & (ART_UTILE_SIZE - 1)) + 1;
63 utiles[0] = ART_UTA_BBOX_CONS (xf0, yf0, xf1, yf1);
66 utiles[0] = ART_UTA_BBOX_CONS (xf0, yf0, ART_UTILE_SIZE, yf1);
67 bb = ART_UTA_BBOX_CONS (0, yf0, ART_UTILE_SIZE, yf1);
68 for (x = 1; x < width - 1; x++)
70 utiles[x] = ART_UTA_BBOX_CONS (0, yf0, xf1, yf1);
77 utiles[0] = ART_UTA_BBOX_CONS (xf0, yf0, xf1, ART_UTILE_SIZE);
78 bb = ART_UTA_BBOX_CONS (xf0, 0, xf1, ART_UTILE_SIZE);
79 for (y = 1; y < height - 1; y++)
81 utiles[y] = ART_UTA_BBOX_CONS (xf0, 0, xf1, yf1);
86 ART_UTA_BBOX_CONS (xf0, yf0, ART_UTILE_SIZE, ART_UTILE_SIZE);
87 bb = ART_UTA_BBOX_CONS (0, yf0, ART_UTILE_SIZE, ART_UTILE_SIZE);
88 for (x = 1; x < width - 1; x++)
90 utiles[x] = ART_UTA_BBOX_CONS (0, yf0, xf1, ART_UTILE_SIZE);
92 for (y = 1; y < height - 1; y++)
95 ART_UTA_BBOX_CONS (xf0, 0, ART_UTILE_SIZE, ART_UTILE_SIZE);
96 bb = ART_UTA_BBOX_CONS (0, 0, ART_UTILE_SIZE, ART_UTILE_SIZE);
97 for (x = 1; x < width - 1; x++)
99 utiles[ix++] = ART_UTA_BBOX_CONS (0, 0, xf1, ART_UTILE_SIZE);
101 utiles[ix++] = ART_UTA_BBOX_CONS (xf0, 0, ART_UTILE_SIZE, yf1);
102 bb = ART_UTA_BBOX_CONS (0, 0, ART_UTILE_SIZE, yf1);
103 for (x = 1; x < width - 1; x++)
105 utiles[ix++] = ART_UTA_BBOX_CONS (0, 0, xf1, yf1);