1 /*
2  * Cogl
3  *
4  * A Low Level GPU Graphics and Utilities API
5  *
6  * Copyright (C) 2009 Intel Corporation.
7  *
8  * Permission is hereby granted, free of charge, to any person
9  * obtaining a copy of this software and associated documentation
10  * files (the "Software"), to deal in the Software without
11  * restriction, including without limitation the rights to use, copy,
12  * modify, merge, publish, distribute, sublicense, and/or sell copies
13  * of the Software, and to permit persons to whom the Software is
14  * furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
23  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
24  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26  * SOFTWARE.
27  */
28 
29 #ifndef __COGL_RECTANGLE_MAP_H
30 #define __COGL_RECTANGLE_MAP_H
31 
32 #include <glib.h>
33 #include "cogl-types.h"
34 
35 typedef struct _CoglRectangleMap      CoglRectangleMap;
36 typedef struct _CoglRectangleMapEntry CoglRectangleMapEntry;
37 
38 typedef void (* CoglRectangleMapCallback) (const CoglRectangleMapEntry *entry,
39                                            void *rectangle_data,
40                                            void *user_data);
41 
42 struct _CoglRectangleMapEntry
43 {
44   unsigned int x, y;
45   unsigned int width, height;
46 };
47 
48 CoglRectangleMap *
49 _cogl_rectangle_map_new (unsigned int width,
50                          unsigned int height,
51                          GDestroyNotify value_destroy_func);
52 
53 CoglBool
54 _cogl_rectangle_map_add (CoglRectangleMap *map,
55                          unsigned int width,
56                          unsigned int height,
57                          void *data,
58                          CoglRectangleMapEntry *rectangle);
59 
60 void
61 _cogl_rectangle_map_remove (CoglRectangleMap *map,
62                             const CoglRectangleMapEntry *rectangle);
63 
64 unsigned int
65 _cogl_rectangle_map_get_width (CoglRectangleMap *map);
66 
67 unsigned int
68 _cogl_rectangle_map_get_height (CoglRectangleMap *map);
69 
70 unsigned int
71 _cogl_rectangle_map_get_remaining_space (CoglRectangleMap *map);
72 
73 unsigned int
74 _cogl_rectangle_map_get_n_rectangles (CoglRectangleMap *map);
75 
76 void
77 _cogl_rectangle_map_foreach (CoglRectangleMap *map,
78                              CoglRectangleMapCallback callback,
79                              void *data);
80 
81 void
82 _cogl_rectangle_map_free (CoglRectangleMap *map);
83 
84 #endif /* __COGL_RECTANGLE_MAP_H */
85