diff options
Diffstat (limited to 'src/display')
| -rw-r--r-- | src/display/Makefile_insert | 2 | ||||
| -rw-r--r-- | src/display/nr-arena-item.cpp | 5 | ||||
| -rw-r--r-- | src/display/nr-filter-offset.cpp | 92 | ||||
| -rw-r--r-- | src/display/nr-filter-offset.h | 50 | ||||
| -rw-r--r-- | src/display/nr-filter-skeleton.cpp | 64 | ||||
| -rw-r--r-- | src/display/nr-filter-skeleton.h | 57 | ||||
| -rw-r--r-- | src/display/nr-filter-slot.cpp | 1 | ||||
| -rw-r--r-- | src/display/nr-filter.cpp | 4 |
8 files changed, 272 insertions, 3 deletions
diff --git a/src/display/Makefile_insert b/src/display/Makefile_insert index 95502170a..a4d747001 100644 --- a/src/display/Makefile_insert +++ b/src/display/Makefile_insert @@ -71,6 +71,8 @@ display_libspdisplay_a_SOURCES = \ display/nr-filter-gaussian.h \ display/nr-filter-blend.cpp \ display/nr-filter-blend.h \ + display/nr-filter-offset.cpp \ + display/nr-filter-offset.h \ display/nr-filter-slot.cpp \ display/nr-filter-slot.h \ display/nr-filter-types.h \ diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index b7ff825d2..a4fdcf5bc 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -414,9 +414,10 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area /* If background access is used, save the pixblock address. * This address is set to NULL at the end of this block */ - if (item->background_new - || (item->parent && item->parent->background_pb)) { + if (item->background_new) { item->background_pb = &ipb; + } else if (item->parent && item->parent->background_pb) { + item->background_pb = item->parent->background_pb; } ipb.visible_area = pb->visible_area; unsigned int state = NR_ARENA_ITEM_VIRTUAL (item, render) (ct, item, &carea, &ipb, flags); diff --git a/src/display/nr-filter-offset.cpp b/src/display/nr-filter-offset.cpp new file mode 100644 index 000000000..ee6741d20 --- /dev/null +++ b/src/display/nr-filter-offset.cpp @@ -0,0 +1,92 @@ +/* + * feOffset filter primitive renderer + * + * Authors: + * Niko Kiirala <niko@kiirala.com> + * + * Copyright (C) 2007 authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "display/nr-filter-offset.h" +#include "display/nr-filter-slot.h" +#include "libnr/nr-blit.h" +#include "libnr/nr-matrix.h" +#include "libnr/nr-pixblock.h" +#include "libnr/nr-point.h" +#include "libnr/nr-point-matrix-ops.h" +#include "libnr/nr-rect-l.h" + +namespace NR { + +FilterOffset::FilterOffset() : + dx(0), dy(0) +{} + +FilterPrimitive * FilterOffset::create() { + return new FilterOffset(); +} + +FilterOffset::~FilterOffset() +{} + +int FilterOffset::render(FilterSlot &slot, Matrix const &trans) { + NRPixBlock *in = slot.get(_input); + NRPixBlock *out = new NRPixBlock; + + Point offset(dx, dy); + offset *= trans; + offset[X] -= trans[4]; + offset[Y] -= trans[5]; + + nr_pixblock_setup_fast(out, in->mode, + in->area.x0, in->area.y0, in->area.x1, in->area.y1, + true); + nr_blit_pixblock_pixblock(out, in); + + out->area.x0 += static_cast<NR::ICoord>(offset[X]); + out->area.y0 += static_cast<NR::ICoord>(offset[Y]); + out->area.x1 += static_cast<NR::ICoord>(offset[X]); + out->area.y1 += static_cast<NR::ICoord>(offset[Y]); + out->visible_area = out->area; + + out->empty = FALSE; + slot.set(_output, out); + + return 0; +} + +void FilterOffset::set_dx(double amount) { + dx = amount; +} + +void FilterOffset::set_dy(double amount) { + dy = amount; +} + +void FilterOffset::area_enlarge(NRRectL &area, Matrix const &trans) +{ + Point offset(dx, dy); + offset *= trans; + offset[X] -= trans[4]; + offset[Y] -= trans[5]; + + area.x0 -= static_cast<NR::ICoord>(offset[X]); + area.x1 -= static_cast<NR::ICoord>(offset[X]); + area.y0 -= static_cast<NR::ICoord>(offset[Y]); + area.y1 -= static_cast<NR::ICoord>(offset[Y]); +} + +} /* namespace NR */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/display/nr-filter-offset.h b/src/display/nr-filter-offset.h new file mode 100644 index 000000000..7c39b0ecc --- /dev/null +++ b/src/display/nr-filter-offset.h @@ -0,0 +1,50 @@ +#ifndef __NR_FILTER_OFFSET_H__ +#define __NR_FILTER_OFFSET_H__ + +/* + * feOffset filter primitive renderer + * + * Authors: + * Niko Kiirala <niko@kiirala.com> + * + * Copyright (C) 2007 authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "display/nr-filter-primitive.h" +#include "display/nr-filter-slot.h" +#include "libnr/nr-matrix.h" +#include "libnr/nr-rect-l.h" + +namespace NR { + +class FilterOffset : public FilterPrimitive { +public: + FilterOffset(); + static FilterPrimitive *create(); + virtual ~FilterOffset(); + + virtual int render(FilterSlot &slot, Matrix const &trans); + virtual void area_enlarge(NRRectL &area, Matrix const &trans); + + void set_dx(double amount); + void set_dy(double amount); + +private: + double dx, dy; +}; + +} /* namespace NR */ + +#endif /* __NR_FILTER_OFFSET_H__ */ +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/display/nr-filter-skeleton.cpp b/src/display/nr-filter-skeleton.cpp new file mode 100644 index 000000000..f595f13f1 --- /dev/null +++ b/src/display/nr-filter-skeleton.cpp @@ -0,0 +1,64 @@ +/* + * Filter primitive renderer skeleton class + * You can create your new filter primitive renderer by replacing + * all occurences of Skeleton, skeleton and SKELETON with your filter + * type, like gaussian or blend in respective case. + * + * This can be accomplished with the following sed command: + * sed -e "s/Skeleton/Name/g" -e "s/skeleton/name" -e "s/SKELETON/NAME" + * nr-filter-skeleton.cpp >nr-filter-name.cpp + * + * (on one line, replace occurences of 'name' with your filter name) + * + * Remember to convert the .h file too. The sed command is same for both + * files. + * + * Authors: + * Niko Kiirala <niko@kiirala.com> + * + * Copyright (C) 2007 authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "display/nr-filter-skeleton.h" +#include "display/nr-filter-slot.h" +#include "libnr/nr-pixblock.h" +#include "libnr/nr-matrix.h" + +namespace NR { + +FilterSkeleton::FilterSkeleton() +{} + +FilterPrimitive * FilterSkeleton::create() { + return new FilterSkeleton(); +} + +FilterSkeleton::~FilterSkeleton() +{} + +int FilterSkeleton::render(FilterSlot &slot, Matrix const &trans) { + NRPixBlock *in = slot.get(_input); + NRPixBlock *out; + + /* Insert rendering code here */ + + out->empty = FALSE; + slot.set(_output, out); + + return 0; +} + +} /* namespace NR */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/display/nr-filter-skeleton.h b/src/display/nr-filter-skeleton.h new file mode 100644 index 000000000..ae3a08046 --- /dev/null +++ b/src/display/nr-filter-skeleton.h @@ -0,0 +1,57 @@ +#ifndef __NR_FILTER_SKELETON_H__ +#define __NR_FILTER_SKELETON_H__ + +/* + * Filter primitive renderer skeleton class + * You can create your new filter primitive renderer by replacing + * all occurences of Skeleton, skeleton and SKELETON with your filter + * type, like gaussian or blend in respective case. + * + * This can be accomplished with the following sed command: + * sed -e "s/Skeleton/Name/g" -e "s/skeleton/name" -e "s/SKELETON/NAME" + * nr-filter-skeleton.h >nr-filter-name.h + * + * (on one line, replace occurences of 'name' with your filter name) + * + * Remember to convert the .cpp file too. The sed command is same for both + * files. + * + * Authors: + * Niko Kiirala <niko@kiirala.com> + * + * Copyright (C) 2007 authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "display/nr-filter-primitive.h" +#include "display/nr-filter-slot.h" +#include "libnr/nr-matrix.h" + +namespace NR { + +class FilterSkeleton : public FilterPrimitive { +public: + FilterSkeleton(); + static FilterPrimitive *create(); + virtual ~FilterSkeleton(); + + virtual int render(FilterSlot &slot, Matrix const &trans); + +private: + +}; + +} /* namespace NR */ + +#endif /* __NR_FILTER_SKELETON_H__ */ +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/display/nr-filter-slot.cpp b/src/display/nr-filter-slot.cpp index 673754f18..250aee10b 100644 --- a/src/display/nr-filter-slot.cpp +++ b/src/display/nr-filter-slot.cpp @@ -84,6 +84,7 @@ NRPixBlock *FilterSlot::get(int slot_nr) delete pb; return NULL; } + pb->empty = FALSE; this->set(NR_FILTER_BACKGROUNDIMAGE, pb); } } diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index 38ed3938a..33e89ac3e 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -22,6 +22,7 @@ #include "display/pixblock-transform.h" #include "display/nr-filter-gaussian.h" #include "display/nr-filter-blend.h" +#include "display/nr-filter-offset.h" #include "display/nr-arena-item.h" #include "libnr/nr-pixblock.h" @@ -209,6 +210,7 @@ int Filter::render(NRArenaItem const *item, NRPixBlock *pb) return 0; nr_blit_pixblock_pixblock(in, pb); } + in->empty = FALSE; slot.set(NR_FILTER_SOURCEGRAPHIC, in); in = NULL; // in is now handled by FilterSlot, we should not touch it @@ -316,7 +318,7 @@ void Filter::_create_constructor_table() _constructor[NR_FILTER_IMAGE] = NULL; _constructor[NR_FILTER_MERGE] = NULL; _constructor[NR_FILTER_MORPHOLOGY] = NULL; - _constructor[NR_FILTER_OFFSET] = NULL; + _constructor[NR_FILTER_OFFSET] = &FilterOffset::create; _constructor[NR_FILTER_SPECULARLIGHTING] = NULL; _constructor[NR_FILTER_TILE] = NULL; _constructor[NR_FILTER_TURBULENCE] = NULL; |
