1 #ifndef __NR_FILTER_SLOT_H__
2 #define __NR_FILTER_SLOT_H__
4 /*
5 * A container class for filter slots. Allows for simple getting and
6 * setting images in filter slots without having to bother with
7 * table indexes and such.
8 *
9 * Author:
10 * Niko Kiirala <niko@kiirala.com>
11 *
12 * Copyright (C) 2006 Niko Kiirala
13 *
14 * Released under GNU GPL, read the file 'COPYING' for more information
15 */
17 #include "libnr/nr-pixblock.h"
19 struct NRArenaItem;
21 namespace NR {
23 class FilterSlot {
24 public:
25 /** Creates a new FilterSlot object.
26 * First parameter specifies the amount of slots this SilterSlot
27 * should reserve beforehand. If a negative number is given,
28 * two slots will be reserved.
29 * Second parameter specifies the arena item, which should be used
30 * for background accesses from filters.
31 */
32 FilterSlot(int slots, NRArenaItem const *item);
33 /** Destroys the FilterSlot object and all its contents */
34 ~FilterSlot();
36 /** Returns the pixblock in specified slot.
37 * Parameter 'slot' may be either an positive integer or one of
38 * pre-defined filter slot types: NR_FILTER_SLOT_NOT_SET,
39 * NR_FILTER_SOURCEGRAPHIC, NR_FILTER_SOURCEALPHA,
40 * NR_FILTER_BACKGROUNDIMAGE, NR_FILTER_BACKGROUNDALPHA,
41 * NR_FILTER_FILLPAINT, NR_FILTER_SOURCEPAINT.
42 * If the defined filter slot is not set before, this function
43 * returns NULL. Also, that filter slot is created in process.
44 */
45 NRPixBlock *get(int slot);
47 /** Sets or re-sets the pixblock associated with given slot.
48 * If there was a pixblock already assigned with this slot,
49 * that pixblock is destroyed.
50 * Pixblocks passed to this function should be considered
51 * managed by this FilterSlot object.
52 * Pixblocks passed to this function should be reserved with
53 * c++ -style new-operator.
54 */
55 void set(int slot, NRPixBlock *pb);
57 /** Returns the number of slots in use. */
58 int get_slot_count();
60 private:
61 NRPixBlock **_slot;
62 int *_slot_number;
63 int _slot_count;
65 int _last_out;
67 NRArenaItem const *_arena_item;
69 /** Returns the table index of given slot. If that slot does not exist,
70 * it is created. Table index can be used to read the correct
71 * pixblock from _slot */
72 int _get_index(int slot);
73 };
75 }
77 #endif // __NR_FILTER_SLOT_H__
78 /*
79 Local Variables:
80 mode:c++
81 c-file-style:"stroustrup"
82 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
83 indent-tabs-mode:nil
84 fill-column:99
85 End:
86 */
87 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :