diff options
| author | Niko Kiirala <niko@kiirala.com> | 2007-09-19 10:26:44 +0000 |
|---|---|---|
| committer | kiirala <kiirala@users.sourceforge.net> | 2007-09-19 10:26:44 +0000 |
| commit | 34caada7790e60e41ec35f92f18bf0bc5dd25b2f (patch) | |
| tree | f18ca0d93ead15cd374b83a9dbe12c3b9f995551 /src/display | |
| parent | Handle Dialog events properly (diff) | |
| download | inkscape-34caada7790e60e41ec35f92f18bf0bc5dd25b2f.tar.gz inkscape-34caada7790e60e41ec35f92f18bf0bc5dd25b2f.zip | |
Fixed a rendering bug & crash when filtering empty objects
(bzr r3775)
Diffstat (limited to 'src/display')
| -rw-r--r-- | src/display/nr-filter.cpp | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index 2e973b4ec..770d9d0a9 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -104,16 +104,35 @@ Filter::~Filter() int Filter::render(NRArenaItem const *item, NRPixBlock *pb) { - if(!_primitive[0]) { + if (!_primitive[0]) { // TODO: Should clear the input buffer instead of just returning - return 0; + return 1; } Matrix trans = *item->ctm; FilterSlot slot(_slot_count, item); - Rect item_bbox = *item->item_bbox; + Rect item_bbox; + try { + item_bbox = *item->item_bbox; + } catch (NR::IsNothing) { + // Bounding box might not exist, so create a dummy one. + Point zero(0, 0); + item_bbox = Rect(zero, zero); + } + if (item_bbox.min()[X] > item_bbox.max()[X] + || item_bbox.min()[Y] > item_bbox.max()[Y]) + { + // Code below assumes non-negative size. + return 1; + } + Rect filter_area = filter_effect_area(item_bbox); + if (item_bbox.isEmpty()) { + // It's no use to try and filter an empty object. + return 1; + } + FilterUnits units(_filter_units, _primitive_units); units.set_ctm(trans); units.set_item_bbox(item_bbox); @@ -200,6 +219,10 @@ void Filter::area_enlarge(NRRectL &bbox, Matrix const &m) { } void Filter::bbox_enlarge(NRRectL &bbox) { + // Modifying empty bounding boxes confuses rest of the renderer, so + // let's not do that. + if (bbox.x0 > bbox.x1 || bbox.y0 > bbox.y1) return; + /* TODO: this is wrong. Should use bounding box in user coordinates * and find its extents in display coordinates. */ Point min(bbox.x0, bbox.y0); |
