summaryrefslogtreecommitdiffstats
path: root/src/display
diff options
context:
space:
mode:
authorThomas Holder <thomas@thomas-holder.de>2019-10-28 11:30:14 +0000
committerThomas Holder <thomas@thomas-holder.de>2019-10-28 11:30:14 +0000
commit1a12c0f5f163794584dfe7b25d4f1feb3156cb6d (patch)
treed6c79997499865b493f1986042a4b3f23f945f1e /src/display
parentUpdate cs.po (diff)
downloadinkscape-1a12c0f5f163794584dfe7b25d4f1feb3156cb6d.tar.gz
inkscape-1a12c0f5f163794584dfe7b25d4f1feb3156cb6d.zip
refactor SPIEnum: more type safety
fixes ungrouping of "font-weight:bolder" fixes "titling-caps" parsing fixes a casting error in CairoRenderContext::renderGlyphtext
Diffstat (limited to 'src/display')
-rw-r--r--src/display/cairo-utils.cpp9
-rw-r--r--src/display/cairo-utils.h4
-rw-r--r--src/display/drawing-item.cpp4
-rw-r--r--src/display/drawing-item.h12
4 files changed, 16 insertions, 13 deletions
diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp
index f560b9f19..f061a22d3 100644
--- a/src/display/cairo-utils.cpp
+++ b/src/display/cairo-utils.cpp
@@ -1252,12 +1252,12 @@ private:
/* None */
};
-unsigned ink_cairo_operator_to_css_blend(cairo_operator_t cairo_operator)
+SPBlendMode ink_cairo_operator_to_css_blend(cairo_operator_t cairo_operator)
{
// All of the blend modes are implemented in Cairo as of 1.10.
// For a detailed description, see:
// http://cairographics.org/operators/
- unsigned res = SP_CSS_BLEND_NORMAL;
+ auto res = SP_CSS_BLEND_NORMAL;
switch (cairo_operator) {
case CAIRO_OPERATOR_MULTIPLY:
res = SP_CSS_BLEND_MULTIPLY;
@@ -1312,7 +1312,7 @@ unsigned ink_cairo_operator_to_css_blend(cairo_operator_t cairo_operator)
return res;
}
-cairo_operator_t ink_css_blend_to_cairo_operator(unsigned css_blend)
+cairo_operator_t ink_css_blend_to_cairo_operator(SPBlendMode css_blend)
{
// All of the blend modes are implemented in Cairo as of 1.10.
// For a detailed description, see:
@@ -1366,9 +1366,10 @@ cairo_operator_t ink_css_blend_to_cairo_operator(unsigned css_blend)
res = CAIRO_OPERATOR_HSL_LUMINOSITY;
break;
case SP_CSS_BLEND_NORMAL:
- default:
res = CAIRO_OPERATOR_OVER;
break;
+ default:
+ g_error("Invalid SPBlendMode %d", css_blend);
}
return res;
}
diff --git a/src/display/cairo-utils.h b/src/display/cairo-utils.h
index 36800f699..232e66600 100644
--- a/src/display/cairo-utils.h
+++ b/src/display/cairo-utils.h
@@ -156,8 +156,8 @@ void ink_cairo_pattern_set_matrix(cairo_pattern_t *cp, Geom::Affine const &m);
void ink_matrix_to_2geom(Geom::Affine &, cairo_matrix_t const &);
void ink_matrix_to_cairo(cairo_matrix_t &, Geom::Affine const &);
-cairo_operator_t ink_css_blend_to_cairo_operator(unsigned blend_mode);
-unsigned ink_cairo_operator_to_css_blend(cairo_operator_t cairo_operator);
+cairo_operator_t ink_css_blend_to_cairo_operator(SPBlendMode blend_mode);
+SPBlendMode ink_cairo_operator_to_css_blend(cairo_operator_t cairo_operator);
cairo_surface_t *ink_cairo_surface_copy(cairo_surface_t *s);
cairo_surface_t *ink_cairo_surface_create_identical(cairo_surface_t *s);
cairo_surface_t *ink_cairo_surface_create_same_size(cairo_surface_t *s, cairo_content_t c);
diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp
index eba5fb6e2..3cdfc72a9 100644
--- a/src/display/drawing-item.cpp
+++ b/src/display/drawing-item.cpp
@@ -243,7 +243,7 @@ DrawingItem::setAntialiasing(unsigned a)
}
void
-DrawingItem::setIsolation(unsigned isolation)
+DrawingItem::setIsolation(bool isolation)
{
_isolation = isolation;
//if( isolation != 0 ) std::cout << "isolation: " << isolation << std::endl;
@@ -251,7 +251,7 @@ DrawingItem::setIsolation(unsigned isolation)
}
void
-DrawingItem::setBlendMode(unsigned mix_blend_mode)
+DrawingItem::setBlendMode(SPBlendMode mix_blend_mode)
{
_mix_blend_mode = mix_blend_mode;
//if( mix_blend_mode != 0 ) std::cout << "setBlendMode: " << mix_blend_mode << std::endl;
diff --git a/src/display/drawing-item.h b/src/display/drawing-item.h
index 7c8b0cefe..8dd4fc5dc 100644
--- a/src/display/drawing-item.h
+++ b/src/display/drawing-item.h
@@ -21,6 +21,8 @@
#include <exception>
#include <list>
+#include "style-enums.h"
+
namespace Glib {
class ustring;
}
@@ -94,9 +96,6 @@ public:
DrawingItem(Drawing &drawing);
virtual ~DrawingItem();
- unsigned _isolation : 1;
- unsigned _mix_blend_mode : 4;
-
Geom::OptIntRect geometricBounds() const { return _bbox; }
Geom::OptIntRect visualBounds() const { return _drawbox; }
Geom::OptRect itemBounds() const { return _item_bbox; }
@@ -121,8 +120,8 @@ public:
virtual void setChildrenStyle(SPStyle *context_style);
void setOpacity(float opacity);
void setAntialiasing(unsigned a);
- void setIsolation(unsigned isolation); // CSS Compositing and Blending
- void setBlendMode(unsigned blend_mode);
+ void setIsolation(bool isolation); // CSS Compositing and Blending
+ void setBlendMode(SPBlendMode blend_mode);
void setTransform(Geom::Affine const &trans);
void setClip(DrawingItem *item);
void setMask(DrawingItem *item);
@@ -231,6 +230,9 @@ protected:
/// otherwise the group is returned
unsigned _antialias : 2; ///< antialiasing level (NONE/FAST/GOOD(DEFAULT)/BEST)
+ bool _isolation : 1;
+ SPBlendMode _mix_blend_mode;
+
friend class Drawing;
};