summaryrefslogtreecommitdiffstats
path: root/src/display
diff options
context:
space:
mode:
Diffstat (limited to 'src/display')
-rw-r--r--src/display/canvas-axonomgrid.cpp4
-rw-r--r--src/display/canvas-grid.cpp19
-rw-r--r--src/display/canvas-grid.h2
-rw-r--r--src/display/canvas-rotate.cpp47
-rw-r--r--src/display/curve.cpp29
-rw-r--r--src/display/curve.h8
-rw-r--r--src/display/drawing-surface.h1
-rw-r--r--src/display/drawing-text.cpp33
-rw-r--r--src/display/makefile.in17
-rw-r--r--src/display/nr-filter-blend.cpp129
-rw-r--r--src/display/nr-filter-blend.h8
-rw-r--r--src/display/nr-filter-diffuselighting.h6
-rw-r--r--src/display/nr-filter-primitive.h7
13 files changed, 136 insertions, 174 deletions
diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp
index 589cc849d..187597794 100644
--- a/src/display/canvas-axonomgrid.cpp
+++ b/src/display/canvas-axonomgrid.cpp
@@ -294,8 +294,8 @@ CanvasAxonomGrid::readRepr()
gridunit = unit_table.getUnit(value); // Display unit identifier in grid menu
}
- for (GSList *l = canvasitems; l != NULL; l = l->next) {
- sp_canvas_item_request_update ( SP_CANVAS_ITEM(l->data) );
+ for (auto i:canvasitems) {
+ sp_canvas_item_request_update(i);
}
return;
}
diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp
index 4243d3365..01bfc2fc0 100644
--- a/src/display/canvas-grid.cpp
+++ b/src/display/canvas-grid.cpp
@@ -149,7 +149,6 @@ CanvasGrid::CanvasGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocume
}
namedview = nv;
- canvasitems = NULL;
}
CanvasGrid::~CanvasGrid()
@@ -157,11 +156,9 @@ CanvasGrid::~CanvasGrid()
if (repr) {
repr->removeListenerByData (this);
}
-
- while (canvasitems) {
- sp_canvas_item_destroy(SP_CANVAS_ITEM(canvasitems->data));
- canvasitems = g_slist_remove(canvasitems, canvasitems->data);
- }
+ for (auto i:canvasitems)
+ sp_canvas_item_destroy(i);
+ canvasitems.clear();
}
const char *
@@ -276,8 +273,8 @@ CanvasGrid::createCanvasItem(SPDesktop * desktop)
// but share the same CanvasGrid object; that is what this function is for.
// check if there is already a canvasitem on this desktop linking to this grid
- for (GSList *l = canvasitems; l != NULL; l = l->next) {
- if ( desktop->getGridGroup() == SP_CANVAS_GROUP(SP_CANVAS_ITEM(l->data)->parent) ) {
+ for (auto i:canvasitems) {
+ if ( desktop->getGridGroup() == SP_CANVAS_GROUP(i->parent) ) {
return NULL;
}
}
@@ -287,7 +284,7 @@ CanvasGrid::createCanvasItem(SPDesktop * desktop)
sp_canvas_item_show(SP_CANVAS_ITEM(item));
g_object_ref(item); // since we're keeping a link to this item, we need to bump up the ref count
- canvasitems = g_slist_prepend(canvasitems, item);
+ canvasitems.push_back(item);
return item;
}
@@ -650,8 +647,8 @@ CanvasXYGrid::readRepr()
gridunit = unit_table.getUnit(value); // Display unit identifier in grid menu
}
- for (GSList *l = canvasitems; l != NULL; l = l->next) {
- sp_canvas_item_request_update ( SP_CANVAS_ITEM(l->data) );
+ for (auto i:canvasitems) {
+ sp_canvas_item_request_update(i);
}
return;
diff --git a/src/display/canvas-grid.h b/src/display/canvas-grid.h
index 91fa43e69..6b36390c8 100644
--- a/src/display/canvas-grid.h
+++ b/src/display/canvas-grid.h
@@ -112,7 +112,7 @@ protected:
virtual Gtk::Widget * newSpecificWidget() = 0;
- GSList * canvasitems; // list of created canvasitems
+ std::vector<SPCanvasItem*> canvasitems; // list of created canvasitems
SPNamedView * namedview;
diff --git a/src/display/canvas-rotate.cpp b/src/display/canvas-rotate.cpp
index aaf6b962c..1d917a677 100644
--- a/src/display/canvas-rotate.cpp
+++ b/src/display/canvas-rotate.cpp
@@ -72,13 +72,13 @@ static void sp_canvas_rotate_update( SPCanvasItem *item, Geom::Affine const &/*a
// std::cout << "sp_canvas_rotate_update: surface_copy is NULL" << std::endl;
return;
}
-
+
// Destroy surface_rotated if it already exists.
if (cr->surface_rotated != NULL) {
cairo_surface_destroy (cr->surface_rotated);
cr->surface_rotated = NULL;
}
-
+
// Create rotated surface
cr->surface_rotated = ink_cairo_surface_create_identical(cr->surface_copy);
double width = cairo_image_surface_get_width (cr->surface_rotated);
@@ -91,7 +91,7 @@ static void sp_canvas_rotate_update( SPCanvasItem *item, Geom::Affine const &/*a
cairo_set_source_surface( context, cr->surface_copy, 0, 0 );
cairo_paint( context );
cairo_destroy( context);
-
+
// We cover the entire canvas
item->x1 = -G_MAXINT;
item->y1 = -G_MAXINT;
@@ -108,8 +108,9 @@ static void sp_canvas_rotate_render( SPCanvasItem *item, SPCanvasBuf *buf)
// std::cout << " buf->rect: " << buf->rect << std::endl;
// std::cout << " buf->canvas_rect: " << buf->canvas_rect << std::endl;
SPCanvasRotate *cr = SP_CANVAS_ROTATE(item);
+ auto ct = buf->ct;
- if (!buf->ct) {
+ if (!ct) {
return;
}
@@ -119,26 +120,26 @@ static void sp_canvas_rotate_render( SPCanvasItem *item, SPCanvasBuf *buf)
}
// Draw rotated canvas
- cairo_save (buf->ct);
- cairo_translate (buf->ct,
+ cairo_save (ct);
+ cairo_translate (ct,
buf->canvas_rect.left() - buf->rect.left(),
buf->canvas_rect.top() - buf->rect.top() );
- cairo_set_operator (buf->ct, CAIRO_OPERATOR_SOURCE );
- cairo_set_source_surface (buf->ct, cr->surface_rotated, 0, 0 );
- cairo_paint (buf->ct);
- cairo_restore (buf->ct);
+ cairo_set_operator (ct, CAIRO_OPERATOR_SOURCE );
+ cairo_set_source_surface (ct, cr->surface_rotated, 0, 0 );
+ cairo_paint (ct);
+ cairo_restore (ct);
// Draw line from center to cursor
- cairo_save (buf->ct);
- cairo_translate (buf->ct, -buf->rect.left(), -buf->rect.top());
- cairo_new_path (buf->ct);
- cairo_move_to (buf->ct, cr->center[Geom::X], cr->center[Geom::Y]);
- cairo_rel_line_to (buf->ct, cr->cursor[Geom::X], cr->cursor[Geom::Y]);
- cairo_set_line_width (buf->ct, 2);
- ink_cairo_set_source_rgba32 (buf->ct, 0xff00007f);
- cairo_stroke (buf->ct);
- cairo_restore (buf->ct);
+ cairo_save (ct);
+ cairo_translate (ct, -buf->rect.left(), -buf->rect.top());
+ cairo_new_path (ct);
+ cairo_move_to (ct, cr->center[Geom::X], cr->center[Geom::Y]);
+ cairo_rel_line_to (ct, cr->cursor[Geom::X], cr->cursor[Geom::Y]);
+ cairo_set_line_width (ct, 2);
+ ink_cairo_set_source_rgba32 (ct, 0xff00007f);
+ cairo_stroke (ct);
+ cairo_restore (ct);
}
@@ -187,7 +188,7 @@ static int sp_canvas_rotate_event (SPCanvasItem *item, GdkEvent *event)
// Correct line for snapping of angle
double distance = rcursor.length();
- cr->cursor = Geom::Point::polar( Geom::rad_from_deg(angle), distance );
+ cr->cursor = Geom::Point::polar( Geom::rad_from_deg(angle), distance );
// Update screen
// sp_canvas_item_request_update( item );
@@ -214,7 +215,7 @@ static int sp_canvas_rotate_event (SPCanvasItem *item, GdkEvent *event)
cr->surface_rotated = NULL;
}
// sp_canvas_item_show (desktop->drawing);
-
+
break;
case GDK_KEY_PRESS:
// std::cout << " Key press: " << std::endl;
@@ -260,10 +261,10 @@ void sp_canvas_rotate_paint (SPCanvasRotate *canvas_rotate, cairo_surface_t *bac
double width = cairo_image_surface_get_width (background);
double height = cairo_image_surface_get_height (background);
-
+
// Draw rotated canvas
cairo_t *context = cairo_create( background );
-
+
cairo_save (context);
cairo_set_operator( context, CAIRO_OPERATOR_SOURCE );
cairo_translate( context, width/2.0, height/2.0 );
diff --git a/src/display/curve.cpp b/src/display/curve.cpp
index 6e662b17b..1115978e9 100644
--- a/src/display/curve.cpp
+++ b/src/display/curve.cpp
@@ -38,6 +38,15 @@ SPCurve::SPCurve(Geom::PathVector const& pathv)
_pathv(pathv)
{}
+//concat constructor
+SPCurve::SPCurve(std::list<SPCurve *> const& l) : _refcount(1)
+{
+ for (auto c:l) {
+ _pathv.insert( _pathv.end(), c->get_pathvector().begin(), c->get_pathvector().end() );
+ }
+}
+
+
SPCurve *
SPCurve::new_from_rect(Geom::Rect const &rect, bool all_four_sides)
{
@@ -134,32 +143,24 @@ SPCurve::copy() const
* Return new curve that is the concatenation of all curves in list.
*/
SPCurve *
-SPCurve::concat(GSList const *list)
-{
- SPCurve *new_curve = new SPCurve();
-
- for (GSList const *l = list; l != NULL; l = l->next) {
- SPCurve *c = static_cast<SPCurve *>(l->data);
- new_curve->_pathv.insert( new_curve->_pathv.end(), c->get_pathvector().begin(), c->get_pathvector().end() );
- }
-
- return new_curve;
-}
+SPCurve::concat(std::list<SPCurve *> l){
+ return new SPCurve(l);
+};
/**
* Returns a list of new curves corresponding to the subpaths in \a curve.
* 2geomified
*/
-GSList *
+std::list<SPCurve *>
SPCurve::split() const
{
- GSList *l = NULL;
+ std::list<SPCurve *> l;
for (Geom::PathVector::const_iterator path_it = _pathv.begin(); path_it != _pathv.end(); ++path_it) {
Geom::PathVector newpathv;
newpathv.push_back(*path_it);
SPCurve * newcurve = new SPCurve(newpathv);
- l = g_slist_prepend(l, newcurve);
+ l.push_back(newcurve);
}
return l;
diff --git a/src/display/curve.h b/src/display/curve.h
index 8375e1105..87b9984a8 100644
--- a/src/display/curve.h
+++ b/src/display/curve.h
@@ -16,8 +16,7 @@
#include <2geom/pathvector.h>
#include <cstddef>
#include <boost/optional.hpp>
-
-extern "C" { typedef struct _GSList GSList; }
+#include <list>
/**
* Wrapper around a Geom::PathVector object.
@@ -27,6 +26,7 @@ public:
/* Constructors */
explicit SPCurve();
explicit SPCurve(Geom::PathVector const& pathv);
+ explicit SPCurve(std::list<SPCurve *> const& pathv);
static SPCurve * new_from_rect(Geom::Rect const &rect, bool all_four_sides = false);
virtual ~SPCurve();
@@ -78,8 +78,8 @@ public:
SPCurve * append_continuous(SPCurve const *c1, double tolerance);
SPCurve * create_reverse() const;
- GSList * split() const;
- static SPCurve * concat(GSList const *list);
+ std::list<SPCurve *> split() const;
+ static SPCurve * concat(std::list<SPCurve *> l);
protected:
size_t _refcount;
diff --git a/src/display/drawing-surface.h b/src/display/drawing-surface.h
index 7bec1606a..78471649a 100644
--- a/src/display/drawing-surface.h
+++ b/src/display/drawing-surface.h
@@ -12,7 +12,6 @@
#ifndef SEEN_INKSCAPE_DISPLAY_DRAWING_SURFACE_H
#define SEEN_INKSCAPE_DISPLAY_DRAWING_SURFACE_H
-#include <boost/shared_ptr.hpp>
#include <cairo.h>
#include <2geom/affine.h>
#include <2geom/rect.h>
diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp
index 21af7b200..3f6b5b34a 100644
--- a/src/display/drawing-text.cpp
+++ b/src/display/drawing-text.cpp
@@ -91,12 +91,11 @@ unsigned DrawingGlyphs::_updateItem(Geom::IntRect const &/*area*/, UpdateContext
if (_transform) {
scale_bigbox /= _transform->descrim();
}
-
/* Because there can be text decorations the bounding box must correspond in Y to a little above the glyph's ascend
and a little below its descend. This leaves room for overline and underline. The left and right sides
- come from the glyph's bounding box. Note that the initial direction of ascender is positive down in Y, and
- this flips after the transform is applied. So change the sign on descender. 1.1 provides a little extra space
+ come from the glyph's bounding box. Note that the initial direction of ascender is positive down in Y, and
+ this flips after the transform is applied. So change the sign on descender. 1.1 provides a little extra space
above and below the max/min y positions of the letters to place the text decorations.*/
Geom::Rect b;
@@ -129,10 +128,10 @@ unsigned DrawingGlyphs::_updateItem(Geom::IntRect const &/*area*/, UpdateContext
Geom::Rect pbigbox(Geom::Point(0.0, _asc*scale_bigbox*0.66),Geom::Point(_width*scale_bigbox, 0.0));
pb = pbigbox * ctx.ctm;
}
-
+
#if 0
/* FIXME if this is commented out then not even an approximation of pick on decorations */
- /* adjust the pick box up or down to include the decorations.
+ /* adjust the pick box up or down to include the decorations.
This is only approximate since at this point we don't know how wide that line is, if it has
an unusual offset, and so forth. The selection point is set at what is roughly the center of
the decoration (vertically) for the wide ones, like wavy and double line.
@@ -146,7 +145,7 @@ unsigned DrawingGlyphs::_updateItem(Geom::IntRect const &/*area*/, UpdateContext
Geom::Rect padjbox(Geom::Point(0.0, top),Geom::Point(_width*scale_bigbox, bot));
pb.unionWith(padjbox * ctx.ctm);
}
-#endif
+#endif
if (ggroup->_nrstyle.stroke.type != NRStyle::PAINT_NONE) {
// this expands the selection box for cases where the stroke is "thick"
@@ -263,8 +262,8 @@ DrawingText::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, un
void DrawingText::decorateStyle(DrawingContext &dc, double vextent, double xphase, Geom::Point const &p1, Geom::Point const &p2, double thickness)
{
double wave[16]={
- 0.000000, 0.382499, 0.706825, 0.923651, 1.000000, 0.923651, 0.706825, 0.382499,
- 0.000000, -0.382499, -0.706825, -0.923651, -1.000000, -0.923651, -0.706825, -0.382499,
+ 0.000000, 0.382499, 0.706825, 0.923651, 1.000000, 0.923651, 0.706825, 0.382499,
+ 0.000000, -0.382499, -0.706825, -0.923651, -1.000000, -0.923651, -0.706825, -0.382499,
};
int dashes[16]={
8, 7, 6, 5,
@@ -283,7 +282,7 @@ void DrawingText::decorateStyle(DrawingContext &dc, double vextent, double xphas
/* For most spans draw the last little bit right to p2 or even a little beyond.
This allows decoration continuity within the line, and does not step outside the clip box off the end
- For the first/last section on the line though, stay well clear of the edge, or when the
+ For the first/last section on the line though, stay well clear of the edge, or when the
text is dragged it may "spray" pixels.
*/
/* snap to nearest step in X */
@@ -329,7 +328,7 @@ void DrawingText::decorateStyle(DrawingContext &dc, double vextent, double xphas
}
i = 0; // once in phase, it stays in phase
}
- }
+ }
else if(_nrstyle.text_decoration_style & TEXT_DECORATION_STYLE_DASHED){
Geom::Point pv = ps;
while(1){
@@ -354,7 +353,7 @@ void DrawingText::decorateStyle(DrawingContext &dc, double vextent, double xphas
}
i = 0; // once in phase, it stays in phase
}
- }
+ }
else if(_nrstyle.text_decoration_style & TEXT_DECORATION_STYLE_WAVY){
double amp = vextent/10.0;
double x = ps[Geom::X];
@@ -375,10 +374,10 @@ void DrawingText::decorateStyle(DrawingContext &dc, double vextent, double xphas
if(x <= ps[Geom::X])break;
}
dc.closePath();
- }
+ }
else { // TEXT_DECORATION_STYLE_SOLID, also default in case it was not set for some reason
dc.rectangle( Geom::Rect(ps + poff, pf - poff));
- }
+ }
}
/* returns scaled line thickness */
@@ -629,7 +628,7 @@ unsigned DrawingText::_renderItem(DrawingContext &dc, Geom::IntRect const &/*are
{
Inkscape::DrawingContext::Save save(dc);
dc.transform(_ctm); // Needed so that fill pattern rotates with text
-
+
if (has_td_fill && fill_first) {
_nrstyle.applyTextDecorationFill(dc);
dc.fillPreserve();
@@ -685,11 +684,7 @@ void DrawingText::_clipItem(DrawingContext &dc, Geom::IntRect const &/*area*/)
DrawingItem *
DrawingText::_pickItem(Geom::Point const &p, double delta, unsigned flags)
{
- DrawingItem *picked = DrawingGroup::_pickItem(p, delta, flags);
- if (picked) {
- return this;
- }
- return NULL;
+ return DrawingGroup::_pickItem(p, delta, flags) ? this : NULL;
}
bool
diff --git a/src/display/makefile.in b/src/display/makefile.in
deleted file mode 100644
index 747f18e11..000000000
--- a/src/display/makefile.in
+++ /dev/null
@@ -1,17 +0,0 @@
-# Convenience stub makefile to call the real Makefile.
-
-@SET_MAKE@
-
-OBJEXT = @OBJEXT@
-
-# Explicit so that it's the default rule.
-all:
- cd .. && $(MAKE) display/all
-
-clean %.a %.$(OBJEXT):
- cd .. && $(MAKE) display/$@
-
-.PHONY: all clean
-
-.SUFFIXES:
-.SUFFIXES: .a .$(OBJEXT)
diff --git a/src/display/nr-filter-blend.cpp b/src/display/nr-filter-blend.cpp
index d0db6b42e..49dfc7ec4 100644
--- a/src/display/nr-filter-blend.cpp
+++ b/src/display/nr-filter-blend.cpp
@@ -3,7 +3,7 @@
*//*
* "This filter composites two objects together using commonly used
* imaging software blending modes. It performs a pixel-wise combination
- * of two input images."
+ * of two input images."
* http://www.w3.org/TR/SVG11/filters.html#feBlend
*
* Authors:
@@ -32,7 +32,18 @@
namespace Inkscape {
namespace Filters {
-FilterBlend::FilterBlend()
+const std::set<FilterBlendMode> FilterBlend::_valid_modes {
+ BLEND_NORMAL, BLEND_MULTIPLY,
+ BLEND_SCREEN, BLEND_DARKEN,
+ BLEND_LIGHTEN, BLEND_OVERLAY,
+ BLEND_COLORDODGE, BLEND_COLORBURN,
+ BLEND_HARDLIGHT, BLEND_SOFTLIGHT,
+ BLEND_DIFFERENCE, BLEND_EXCLUSION,
+ BLEND_HUE, BLEND_SATURATION,
+ BLEND_COLOR, BLEND_LUMINOSITY
+ };
+
+FilterBlend::FilterBlend()
: _blend_mode(BLEND_NORMAL),
_input2(NR_FILTER_SLOT_NOT_SET)
{}
@@ -44,6 +55,47 @@ FilterPrimitive * FilterBlend::create() {
FilterBlend::~FilterBlend()
{}
+static inline cairo_operator_t get_cairo_op(FilterBlendMode _blend_mode)
+{
+ switch (_blend_mode) {
+ case BLEND_MULTIPLY:
+ return CAIRO_OPERATOR_MULTIPLY;
+ case BLEND_SCREEN:
+ return CAIRO_OPERATOR_SCREEN;
+ case BLEND_DARKEN:
+ return CAIRO_OPERATOR_DARKEN;
+ case BLEND_LIGHTEN:
+ return CAIRO_OPERATOR_LIGHTEN;
+ // New in CSS Compositing and Blending Level 1
+ case BLEND_OVERLAY:
+ return CAIRO_OPERATOR_OVERLAY;
+ case BLEND_COLORDODGE:
+ return CAIRO_OPERATOR_COLOR_DODGE;
+ case BLEND_COLORBURN:
+ return CAIRO_OPERATOR_COLOR_BURN;
+ case BLEND_HARDLIGHT:
+ return CAIRO_OPERATOR_HARD_LIGHT;
+ case BLEND_SOFTLIGHT:
+ return CAIRO_OPERATOR_SOFT_LIGHT;
+ case BLEND_DIFFERENCE:
+ return CAIRO_OPERATOR_DIFFERENCE;
+ case BLEND_EXCLUSION:
+ return CAIRO_OPERATOR_EXCLUSION;
+ case BLEND_HUE:
+ return CAIRO_OPERATOR_HSL_HUE;
+ case BLEND_SATURATION:
+ return CAIRO_OPERATOR_HSL_SATURATION;
+ case BLEND_COLOR:
+ return CAIRO_OPERATOR_HSL_COLOR;
+ case BLEND_LUMINOSITY:
+ return CAIRO_OPERATOR_HSL_LUMINOSITY;
+
+ case BLEND_NORMAL:
+ default:
+ return CAIRO_OPERATOR_OVER;
+ }
+}
+
void FilterBlend::render_cairo(FilterSlot &slot)
{
cairo_surface_t *input1 = slot.getcairo(_input);
@@ -71,59 +123,7 @@ void FilterBlend::render_cairo(FilterSlot &slot)
// All of the blend modes are implemented in Cairo as of 1.10.
// For a detailed description, see:
// http://cairographics.org/operators/
- switch (_blend_mode) {
- case BLEND_MULTIPLY:
- cairo_set_operator(out_ct, CAIRO_OPERATOR_MULTIPLY);
- break;
- case BLEND_SCREEN:
- cairo_set_operator(out_ct, CAIRO_OPERATOR_SCREEN);
- break;
- case BLEND_DARKEN:
- cairo_set_operator(out_ct, CAIRO_OPERATOR_DARKEN);
- break;
- case BLEND_LIGHTEN:
- cairo_set_operator(out_ct, CAIRO_OPERATOR_LIGHTEN);
- break;
- // New in CSS Compositing and Blending Level 1
- case BLEND_OVERLAY:
- cairo_set_operator(out_ct, CAIRO_OPERATOR_OVERLAY);
- break;
- case BLEND_COLORDODGE:
- cairo_set_operator(out_ct, CAIRO_OPERATOR_COLOR_DODGE);
- break;
- case BLEND_COLORBURN:
- cairo_set_operator(out_ct, CAIRO_OPERATOR_COLOR_BURN);
- break;
- case BLEND_HARDLIGHT:
- cairo_set_operator(out_ct, CAIRO_OPERATOR_HARD_LIGHT);
- break;
- case BLEND_SOFTLIGHT:
- cairo_set_operator(out_ct, CAIRO_OPERATOR_SOFT_LIGHT);
- break;
- case BLEND_DIFFERENCE:
- cairo_set_operator(out_ct, CAIRO_OPERATOR_DIFFERENCE);
- break;
- case BLEND_EXCLUSION:
- cairo_set_operator(out_ct, CAIRO_OPERATOR_EXCLUSION);
- break;
- case BLEND_HUE:
- cairo_set_operator(out_ct, CAIRO_OPERATOR_HSL_HUE);
- break;
- case BLEND_SATURATION:
- cairo_set_operator(out_ct, CAIRO_OPERATOR_HSL_SATURATION);
- break;
- case BLEND_COLOR:
- cairo_set_operator(out_ct, CAIRO_OPERATOR_HSL_COLOR);
- break;
- case BLEND_LUMINOSITY:
- cairo_set_operator(out_ct, CAIRO_OPERATOR_HSL_LUMINOSITY);
- break;
-
- case BLEND_NORMAL:
- default:
- cairo_set_operator(out_ct, CAIRO_OPERATOR_OVER);
- break;
- }
+ cairo_set_operator(out_ct, get_cairo_op(_blend_mode));
cairo_paint(out_ct);
cairo_destroy(out_ct);
@@ -145,13 +145,8 @@ double FilterBlend::complexity(Geom::Affine const &)
bool FilterBlend::uses_background()
{
- if (_input == NR_FILTER_BACKGROUNDIMAGE || _input == NR_FILTER_BACKGROUNDALPHA ||
- _input2 == NR_FILTER_BACKGROUNDIMAGE || _input2 == NR_FILTER_BACKGROUNDALPHA)
- {
- return true;
- } else {
- return false;
- }
+ return (_input == NR_FILTER_BACKGROUNDIMAGE || _input == NR_FILTER_BACKGROUNDALPHA ||
+ _input2 == NR_FILTER_BACKGROUNDIMAGE || _input2 == NR_FILTER_BACKGROUNDALPHA);
}
void FilterBlend::set_input(int slot) {
@@ -164,15 +159,7 @@ void FilterBlend::set_input(int input, int slot) {
}
void FilterBlend::set_mode(FilterBlendMode mode) {
- if (mode == BLEND_NORMAL || mode == BLEND_MULTIPLY ||
- mode == BLEND_SCREEN || mode == BLEND_DARKEN ||
- mode == BLEND_LIGHTEN || mode == BLEND_OVERLAY ||
- mode == BLEND_COLORDODGE || mode == BLEND_COLORBURN ||
- mode == BLEND_HARDLIGHT || mode == BLEND_SOFTLIGHT ||
- mode == BLEND_DIFFERENCE || mode == BLEND_EXCLUSION ||
- mode == BLEND_HUE || mode == BLEND_SATURATION ||
- mode == BLEND_COLOR || mode == BLEND_LUMINOSITY
- )
+ if (_valid_modes.count(mode))
{
_blend_mode = mode;
}
diff --git a/src/display/nr-filter-blend.h b/src/display/nr-filter-blend.h
index 30c9d6725..5b1295c88 100644
--- a/src/display/nr-filter-blend.h
+++ b/src/display/nr-filter-blend.h
@@ -6,7 +6,7 @@
*
* "This filter composites two objects together using commonly used
* imaging software blending modes. It performs a pixel-wise combination
- * of two input images."
+ * of two input images."
* http://www.w3.org/TR/SVG11/filters.html#feBlend
*
* Authors:
@@ -16,6 +16,7 @@
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
+#include <set>
#include "display/nr-filter-primitive.h"
@@ -29,14 +30,14 @@ enum FilterBlendMode {
BLEND_DARKEN,
BLEND_LIGHTEN,
// New in CSS Compositing and Blending Level 1
- BLEND_OVERLAY,
+ BLEND_OVERLAY,
BLEND_COLORDODGE,
BLEND_COLORBURN,
BLEND_HARDLIGHT,
BLEND_SOFTLIGHT,
BLEND_DIFFERENCE,
BLEND_EXCLUSION,
- BLEND_HUE,
+ BLEND_HUE,
BLEND_SATURATION,
BLEND_COLOR,
BLEND_LUMINOSITY,
@@ -59,6 +60,7 @@ public:
void set_mode(FilterBlendMode mode);
private:
+ static const std::set<FilterBlendMode> _valid_modes;
FilterBlendMode _blend_mode;
int _input2;
};
diff --git a/src/display/nr-filter-diffuselighting.h b/src/display/nr-filter-diffuselighting.h
index 7739b3ea6..5ce505979 100644
--- a/src/display/nr-filter-diffuselighting.h
+++ b/src/display/nr-filter-diffuselighting.h
@@ -7,7 +7,7 @@
* Authors:
* Niko Kiirala <niko@kiirala.com>
* Jean-Rene Reinhard <jr@komite.net>
- *
+ *
* Copyright (C) 2007 authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
@@ -26,7 +26,7 @@ typedef unsigned int guint32;
namespace Inkscape {
namespace Filters {
-
+
class FilterDiffuseLighting : public FilterPrimitive {
public:
FilterDiffuseLighting();
@@ -54,7 +54,7 @@ private:
} /* namespace Filters */
} /* namespace Inkscape */
-#endif /* __NR_FILTER_DIFFUSELIGHTING_H__ */
+#endif /* SEEN_NR_FILTER_DIFFUSELIGHTING_H */
/*
Local Variables:
mode:c++
diff --git a/src/display/nr-filter-primitive.h b/src/display/nr-filter-primitive.h
index 4b7577159..a1339cc6c 100644
--- a/src/display/nr-filter-primitive.h
+++ b/src/display/nr-filter-primitive.h
@@ -69,7 +69,7 @@ public:
// returns cache score factor, reflecting the cost of rendering this filter
// this should return how many times slower this primitive is that normal rendering
virtual double complexity(Geom::Affine const &/*ctm*/) { return 1.0; }
-
+
virtual bool uses_background() {
if (_input == NR_FILTER_BACKGROUNDIMAGE || _input == NR_FILTER_BACKGROUNDALPHA) {
return true;
@@ -138,10 +138,7 @@ protected:
} /* namespace Filters */
} /* namespace Inkscape */
-
-
-
-#endif /* __NR_FILTER_PRIMITIVE_H__ */
+#endif /* SEEN_NR_FILTER_PRIMITIVE_H */
/*
Local Variables:
mode:c++