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"
20 #include <vector>
22 struct NRArenaItem;
24 namespace Inkscape {
25 namespace Filters {
27 class FilterSlot {
28 public:
29 /** Creates a new FilterSlot object.
30 * First parameter specifies the amount of slots this SilterSlot
31 * should reserve beforehand. If a negative number is given,
32 * two slots will be reserved.
33 * Second parameter specifies the arena item, which should be used
34 * for background accesses from filters.
35 */
36 FilterSlot(int slots, NRArenaItem const *item);
37 /** Destroys the FilterSlot object and all its contents */
38 virtual ~FilterSlot();
40 /** Returns the pixblock in specified slot.
41 * Parameter 'slot' may be either an positive integer or one of
42 * pre-defined filter slot types: NR_FILTER_SLOT_NOT_SET,
43 * NR_FILTER_SOURCEGRAPHIC, NR_FILTER_SOURCEALPHA,
44 * NR_FILTER_BACKGROUNDIMAGE, NR_FILTER_BACKGROUNDALPHA,
45 * NR_FILTER_FILLPAINT, NR_FILTER_SOURCEPAINT.
46 * If the defined filter slot is not set before, this function
47 * returns NULL. Also, that filter slot is created in process.
48 */
49 NRPixBlock *get(int slot);
51 /** Gets the final result from this filter.
52 * The result is fetched from the specified slot, see description of
53 * method get for valid values. The pixblock 'result' will be modified
54 * to contain the result image, ready to be used in the rest of rendering
55 * pipeline
56 */
57 void get_final(int slot, NRPixBlock *result);
59 /** Sets or re-sets the pixblock associated with given slot.
60 * If there was a pixblock already assigned with this slot,
61 * that pixblock is destroyed.
62 * Pixblocks passed to this function should be considered
63 * managed by this FilterSlot object if takeOwnership==true.
64 * Pixblocks passed to this function should be reserved with
65 * c++ -style new-operator (if managed by FilterSlot).
66 */
67 void set(int slot, NRPixBlock *pb, bool takeOwnership=true);
69 /** Returns the number of slots in use. */
70 int get_slot_count();
72 /** arenaitem getter method*/
73 NRArenaItem const* get_arenaitem();
75 /** Sets the unit system to be used for the internal images. */
76 void set_units(FilterUnits const &units);
78 /** Sets the filtering quality. Affects used interpolation methods */
79 void set_quality(FilterQuality const q);
81 /** Sets the gaussian filtering quality. Affects used interpolation methods */
82 void set_blurquality(int const q);
84 /** Gets the gaussian filtering quality. Affects used interpolation methods */
85 int get_blurquality(void);
87 private:
88 struct slot_entry_t {
89 NRPixBlock* pb;
90 int number;
91 bool owned;
92 slot_entry_t() : pb(0), number(NR_FILTER_SLOT_NOT_SET), owned(false) {}
93 ~slot_entry_t();
94 };
95 std::vector<slot_entry_t> _slots;
97 int _last_out;
99 FilterQuality filterquality;
101 int blurquality;
103 NRArenaItem const *_arena_item;
105 FilterUnits units;
107 /** Returns the table index of given slot. If that slot does not exist,
108 * it is created. Table index can be used to read the correct
109 * pixblock from _slot */
110 int _get_index(int slot);
111 };
113 } /* namespace Filters */
114 } /* namespace Inkscape */
116 #endif // __NR_FILTER_SLOT_H__
117 /*
118 Local Variables:
119 mode:c++
120 c-file-style:"stroustrup"
121 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
122 indent-tabs-mode:nil
123 fill-column:99
124 End:
125 */
126 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :