index e6a78c8c7089c275fc3388f5743a0ae221e8c5a5..1501afcbecb91699ac83b4c227033a5adebe11ba 100644 (file)
*/
#include <assert.h>
+#include <string.h>
#include "display/nr-arena-item.h"
#include "display/nr-filter-types.h"
void FilterSlot::set(int slot_nr, NRPixBlock *pb)
{
- int index = _get_index(slot_nr);
+ /* Unnamed slot is for saving filter primitive results, when parameter
+ * 'result' is not set. Only the filter immediately after this one
+ * can access unnamed results, so we don't have to worry about overwriting
+ * previous results in filter chain. On the other hand, we may not
+ * overwrite any other image with this one, because they might be
+ * accessed later on. */
+ int index = ((slot_nr != NR_FILTER_SLOT_NOT_SET)
+ ? _get_index(slot_nr)
+ : _get_index(NR_FILTER_UNNAMED_SLOT));
assert(index >= 0);
+ // Unnamed slot is only for NR::FilterSlot internal use.
+ assert(slot_nr != NR_FILTER_UNNAMED_SLOT);
assert(slot_nr == NR_FILTER_SLOT_NOT_SET ||_slot_number[index] == slot_nr);
if (slot_nr == NR_FILTER_SOURCEGRAPHIC || slot_nr == NR_FILTER_BACKGROUNDIMAGE) {
slot_nr == NR_FILTER_BACKGROUNDIMAGE ||
slot_nr == NR_FILTER_BACKGROUNDALPHA ||
slot_nr == NR_FILTER_FILLPAINT ||
- slot_nr == NR_FILTER_STROKEPAINT);
+ slot_nr == NR_FILTER_STROKEPAINT ||
+ slot_nr == NR_FILTER_UNNAMED_SLOT);
int index = -1;
if (slot_nr == NR_FILTER_SLOT_NOT_SET) {
int seek = _slot_count;
do {
seek--;
- } while (_slot_number[seek] == NR_FILTER_SLOT_NOT_SET && seek >= 0);
+ } while ((seek >= 0) && (_slot_number[seek] == NR_FILTER_SLOT_NOT_SET));
/* If there is no space for more slots, create more space */
if (seek == _slot_count - 1) {
NRPixBlock **new_slot = new NRPixBlock*[_slot_count * 2];