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,2007 Niko Kiirala
13 *
14 * Released under GNU GPL, read the file 'COPYING' for more information
15 */
17 #include "libnr/nr-pixblock.h"
18 #include "display/nr-filter-types.h"
19 #include "display/nr-filter-units.h"
21 struct NRArenaItem;
23 namespace Inkscape {
24 namespace Filters {
26 class FilterSlot {
27 public:
28 /** Creates a new FilterSlot object.
29 * First parameter specifies the amount of slots this SilterSlot
30 * should reserve beforehand. If a negative number is given,
31 * two slots will be reserved.
32 * Second parameter specifies the arena item, which should be used
33 * for background accesses from filters.
34 */
35 FilterSlot(int slots, NRArenaItem const *item);
36 /** Destroys the FilterSlot object and all its contents */
37 virtual ~FilterSlot();
39 /** Returns the pixblock in specified slot.
40 * Parameter 'slot' may be either an positive integer or one of
41 * pre-defined filter slot types: NR_FILTER_SLOT_NOT_SET,
42 * NR_FILTER_SOURCEGRAPHIC, NR_FILTER_SOURCEALPHA,
43 * NR_FILTER_BACKGROUNDIMAGE, NR_FILTER_BACKGROUNDALPHA,
44 * NR_FILTER_FILLPAINT, NR_FILTER_SOURCEPAINT.
45 * If the defined filter slot is not set before, this function
46 * returns NULL. Also, that filter slot is created in process.
47 */
48 NRPixBlock *get(int slot);
50 /** Gets the final result from this filter.
51 * The result is fetched from the specified slot, see description of
52 * method get for valid values. The pixblock 'result' will be modified
53 * to contain the result image, ready to be used in the rest of rendering
54 * pipeline
55 */
56 void get_final(int slot, NRPixBlock *result);
58 /** Sets or re-sets the pixblock associated with given slot.
59 * If there was a pixblock already assigned with this slot,
60 * that pixblock is destroyed.
61 * Pixblocks passed to this function should be considered
62 * managed by this FilterSlot object.
63 * Pixblocks passed to this function should be reserved with
64 * c++ -style new-operator.
65 */
66 void set(int slot, NRPixBlock *pb);
68 /** Returns the number of slots in use. */
69 int get_slot_count();
71 /** arenaitem getter method*/
72 NRArenaItem const* get_arenaitem();
74 /** Sets the unit system to be used for the internal images. */
75 void set_units(FilterUnits const &units);
77 /** Sets the filtering quality. Affects used interpolation methods */
78 void set_quality(FilterQuality const q);
80 private:
81 NRPixBlock **_slot;
82 int *_slot_number;
83 int _slot_count;
85 int _last_out;
87 FilterQuality filterquality;
89 NRArenaItem const *_arena_item;
91 FilterUnits units;
93 /** Returns the table index of given slot. If that slot does not exist,
94 * it is created. Table index can be used to read the correct
95 * pixblock from _slot */
96 int _get_index(int slot);
97 };
99 } /* namespace Filters */
100 } /* namespace Inkscape */
102 #endif // __NR_FILTER_SLOT_H__
103 /*
104 Local Variables:
105 mode:c++
106 c-file-style:"stroustrup"
107 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
108 indent-tabs-mode:nil
109 fill-column:99
110 End:
111 */
112 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :