1 /* Libart_LGPL - library of basic graphic primitives
2 * Copyright (C) 1998 Raph Levien
3 *
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.
8 *
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.
13 *
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.
18 */
19
20 #include "config.h"
21 #include "art_uta.h"
22
23 #include <string.h>
24 #include "art_misc.h"
25
26 /**
27 * art_uta_new: Allocate a new uta.
28 * @x0: Left coordinate of uta.
29 * @y0: Top coordinate of uta.
30 * @x1: Right coordinate of uta.
31 * @y1: Bottom coordinate of uta.
32 *
33 * Allocates a new microtile array. The arguments are in units of
34 * tiles, not pixels.
35 *
36 * Returns: the newly allocated #ArtUta.
37 **/
38 ArtUta *
art_uta_new(int x0,int y0,int x1,int y1)39 art_uta_new (int x0, int y0, int x1, int y1)
40 {
41 ArtUta *uta;
42
43 uta = art_new (ArtUta, 1);
44 uta->x0 = x0;
45 uta->y0 = y0;
46 uta->width = x1 - x0;
47 uta->height = y1 - y0;
48
49 uta->utiles = art_new (ArtUtaBbox, uta->width * uta->height);
50
51 memset (uta->utiles, 0, uta->width * uta->height * sizeof(ArtUtaBbox));
52 return uta;
53 }
54
55 /**
56 * art_uta_new_coords: Allocate a new uta, based on pixel coordinates.
57 * @x0: Left coordinate of uta.
58 * @y0: Top coordinate of uta.
59 * @x1: Right coordinate of uta.
60 * @y1: Bottom coordinate of uta.
61 *
62 * Allocates a new microtile array. The arguments are in pixels
63 *
64 * Returns: the newly allocated #ArtUta.
65 **/
66 ArtUta *
art_uta_new_coords(int x0,int y0,int x1,int y1)67 art_uta_new_coords (int x0, int y0, int x1, int y1)
68 {
69 return art_uta_new (x0 >> ART_UTILE_SHIFT, y0 >> ART_UTILE_SHIFT,
70 1 + (x1 >> ART_UTILE_SHIFT),
71 1 + (y1 >> ART_UTILE_SHIFT));
72 }
73
74 /**
75 * art_uta_free: Free a uta.
76 * @uta: The uta to free.
77 *
78 * Frees the microtile array structure, including the actual microtile
79 * data.
80 **/
81 void
art_uta_free(ArtUta * uta)82 art_uta_free (ArtUta *uta)
83 {
84 art_free (uta->utiles);
85 art_free (uta);
86 }
87
88 /* User to Aardvark! */
89