1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
namespace PluggIt {
class Updates
{
private DFBUpdates m_updates;
private DFBRegion *m_regions;
public Updates( unsigned int max_regions = 8 ) {
m_regions = (DFBRegion*) D_CALLOC( max_regions ?: 1, sizeof(DFBRegion) );
dfb_updates_init( &m_updates, m_regions, max_regions );
}
virtual ~Updates() {
dfb_updates_deinit( &m_updates );
D_FREE( m_regions );
}
public void addRegion( const DFBRegion ®ion ) {
dfb_updates_add( &m_updates, ®ion );
}
public DFBRegion bounding() const {
return m_updates.bounding;
}
public void get_rectangles( DFBRectangle *ret_rects, int *ret_num ) {
dfb_updates_get_rectangles( &m_updates, ret_rects, ret_num );
}
public unsigned int num_regions() const {
return m_updates.num_regions;
}
public void reset() {
dfb_updates_reset( &m_updates );
}
public void GetRectangles( vector<DFBRectangle_C> &rects ) {
D_MAGIC_ASSERT( &m_updates, DFBUpdates );
D_ASSERT( m_updates.regions != NULL );
D_ASSERT( m_updates.num_regions >= 0 );
D_ASSERT( m_updates.num_regions <= m_updates.max_regions );
switch (m_updates.num_regions) {
case 0:
break;
default: {
int n, d, total, bounding;
dfb_updates_stat( &m_updates, &total, &bounding );
n = m_updates.max_regions - m_updates.num_regions + 1;
d = n + 1;
/* Try to optimize updates. Use individual regions only if not too much overhead. */
if (total < bounding * n / d) {
for (n=0; n<m_updates.num_regions; n++)
rects.push_back( DFBRectangle( m_updates.regions[n] ) );
break;
}
}
/* fall through */
case 1:
rects.push_back( DFBRectangle( m_updates.bounding ) );
break;
}
}
};
}
|