summaryrefslogtreecommitdiffstats
path: root/server/tree_item.h
blob: 025c99771bf516ca41aa3ba6623512ed215c3ea2 (plain)
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
#ifndef TREE_ITEM_H_
# define TREE_ITEM_H_

#include <stdint.h>
#include "common/region.h"
#include "common/ring.h"
#include "red_bitmap_utils.h"

enum {
    TREE_ITEM_TYPE_NONE,
    TREE_ITEM_TYPE_DRAWABLE,
    TREE_ITEM_TYPE_CONTAINER,
    TREE_ITEM_TYPE_SHADOW,

    TREE_ITEM_TYPE_LAST,
};

typedef struct _TreeItem TreeItem;
typedef struct _Shadow Shadow;
typedef struct _Container Container;
typedef struct _DrawItem DrawItem;

/* TODO consider GNode instead */
struct _TreeItem {
    RingItem siblings_link;
    uint32_t type;
    Container *container;
    QRegion rgn;
};

/* A region "below" a copy, or the src region of the copy */
struct _Shadow {
    TreeItem base;
    QRegion on_hold;
    DrawItem* owner;
};

#define IS_SHADOW(item) ((item)->type == TREE_ITEM_TYPE_SHADOW)
#define SHADOW(item) ((Container*)(item))

struct _Container {
    TreeItem base;
    Ring items;
};

#define IS_CONTAINER(item) ((item)->type == TREE_ITEM_TYPE_CONTAINER)
#define CONTAINER(item) ((Container*)(item))

struct _DrawItem {
    TreeItem base;
    uint8_t effect;
    uint8_t container_root;
    Shadow *shadow;
};

#define IS_DRAW_ITEM(item) ((item)->type == TREE_ITEM_TYPE_DRAWABLE)
#define DRAW_ITEM(item) ((DrawItem*)(item))

static inline int is_opaque_item(TreeItem *item)
{
    return item->type == TREE_ITEM_TYPE_CONTAINER ||
        (IS_DRAW_ITEM(item) && ((DrawItem *)item)->effect == QXL_EFFECT_OPAQUE);
}

void       tree_item_dump                           (TreeItem *item);
Shadow*    tree_item_find_shadow                    (TreeItem *item);
int        tree_item_contained_by                   (TreeItem *item, Ring *ring);
Ring*      tree_item_container_items                (TreeItem *item, Ring *ring);

void       draw_item_remove_shadow                  (DrawItem *item);
Shadow*    shadow_new                               (DrawItem *item, const SpicePoint *delta);
Container* container_new                            (DrawItem *item);
void       container_free                           (Container *container);
void       container_cleanup                        (Container *container);

#endif /* TREE_ITEM_H_ */