Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
1892 serge 1
/* cairo - a vector graphics library with display and print output
2
 *
3
 * Copyright © 2009 Chris Wilson
4
 *
5
 * This library is free software; you can redistribute it and/or
6
 * modify it either under the terms of the GNU Lesser General Public
7
 * License version 2.1 as published by the Free Software Foundation
8
 * (the "LGPL") or, at your option, under the terms of the Mozilla
9
 * Public License Version 1.1 (the "MPL"). If you do not alter this
10
 * notice, a recipient may use your version of this file under either
11
 * the MPL or the LGPL.
12
 *
13
 * You should have received a copy of the LGPL along with this library
14
 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
15
 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
16
 * You should have received a copy of the MPL along with this library
17
 * in the file COPYING-MPL-1.1
18
 *
19
 * The contents of this file are subject to the Mozilla Public License
20
 * Version 1.1 (the "License"); you may not use this file except in
21
 * compliance with the License. You may obtain a copy of the License at
22
 * http://www.mozilla.org/MPL/
23
 *
24
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
25
 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
26
 * the specific language governing rights and limitations.
27
 *
28
 * The Original Code is the cairo graphics library.
29
 *
30
 * The Initial Developer of the Original Code is Chris Wilson.
31
 *
32
 * Contributor(s):
33
 *      Chris Wilson 
34
 *
35
 */
36
 
37
#ifndef CAIRO_RTREE_PRIVATE_H
38
#define CAIRO_RTREE_PRIVATE_H
39
 
40
#include "cairo-compiler-private.h"
41
#include "cairo-types-private.h"
42
 
43
#include "cairo-freelist-private.h"
44
#include "cairo-list-private.h"
45
 
46
enum {
47
    CAIRO_RTREE_NODE_AVAILABLE,
48
    CAIRO_RTREE_NODE_DIVIDED,
49
    CAIRO_RTREE_NODE_OCCUPIED,
50
};
51
 
52
typedef struct _cairo_rtree_node {
53
    struct _cairo_rtree_node *children[4], *parent;
54
    void **owner;
55
    cairo_list_t link;
56
    uint16_t pinned;
57
    uint16_t state;
58
    uint16_t x, y;
59
    uint16_t width, height;
60
} cairo_rtree_node_t;
61
 
62
typedef struct _cairo_rtree {
63
    cairo_rtree_node_t root;
64
    int min_size;
65
    cairo_list_t pinned;
66
    cairo_list_t available;
67
    cairo_list_t evictable;
68
    cairo_freepool_t node_freepool;
69
} cairo_rtree_t;
70
 
71
cairo_private cairo_rtree_node_t *
72
_cairo_rtree_node_create (cairo_rtree_t		 *rtree,
73
		          cairo_rtree_node_t	 *parent,
74
			  int			  x,
75
			  int			  y,
76
			  int			  width,
77
			  int			  height);
78
 
79
cairo_private cairo_status_t
80
_cairo_rtree_node_insert (cairo_rtree_t *rtree,
81
	                  cairo_rtree_node_t *node,
82
			  int width,
83
			  int height,
84
			  cairo_rtree_node_t **out);
85
 
86
cairo_private void
87
_cairo_rtree_node_collapse (cairo_rtree_t *rtree, cairo_rtree_node_t *node);
88
 
89
cairo_private void
90
_cairo_rtree_node_remove (cairo_rtree_t *rtree, cairo_rtree_node_t *node);
91
 
92
cairo_private void
93
_cairo_rtree_node_destroy (cairo_rtree_t *rtree, cairo_rtree_node_t *node);
94
 
95
cairo_private void
96
_cairo_rtree_init (cairo_rtree_t	*rtree,
97
	           int			 width,
98
		   int			 height,
99
		   int			 min_size,
100
		   int			 node_size);
101
 
102
cairo_private cairo_int_status_t
103
_cairo_rtree_insert (cairo_rtree_t	     *rtree,
104
		     int		      width,
105
	             int		      height,
106
	             cairo_rtree_node_t	    **out);
107
 
108
cairo_private cairo_int_status_t
109
_cairo_rtree_evict_random (cairo_rtree_t	 *rtree,
110
		           int			  width,
111
		           int			  height,
112
		           cairo_rtree_node_t	**out);
113
 
114
static inline void *
115
_cairo_rtree_pin (cairo_rtree_t *rtree, cairo_rtree_node_t *node)
116
{
117
    if (! node->pinned) {
118
	cairo_list_move (&node->link, &rtree->pinned);
119
	node->pinned = 1;
120
    }
121
 
122
    return node;
123
}
124
 
125
cairo_private void
126
_cairo_rtree_unpin (cairo_rtree_t *rtree);
127
 
128
cairo_private void
129
_cairo_rtree_reset (cairo_rtree_t *rtree);
130
 
131
cairo_private void
132
_cairo_rtree_fini (cairo_rtree_t *rtree);
133
 
134
#endif /* CAIRO_RTREE_PRIVATE_H */