diff options
| author | Alex Valavanis <valavanisalex@gmail.com> | 2017-02-05 16:04:35 +0000 |
|---|---|---|
| committer | Alex Valavanis <valavanisalex@gmail.com> | 2017-02-05 16:04:35 +0000 |
| commit | 349536d49558ec5841e799eb33a4cbbb3fa9722d (patch) | |
| tree | 7e6a4cb6e7ecff3a3d81e99a8c3c3a246839a195 /src | |
| parent | CMake: Supress status messages for install target on Windows (considerably sp... (diff) | |
| download | inkscape-349536d49558ec5841e799eb33a4cbbb3fa9722d.tar.gz inkscape-349536d49558ec5841e799eb33a4cbbb3fa9722d.zip | |
Fix C++11 errors and warnings with g++-7
Fixed bugs:
- https://launchpad.net/bugs/1660992
(bzr r15477)
Diffstat (limited to 'src')
| -rw-r--r-- | src/box3d.cpp | 4 | ||||
| -rw-r--r-- | src/filters/image.cpp | 5 | ||||
| -rw-r--r-- | src/inkgc/gc-core.h | 6 | ||||
| -rw-r--r-- | src/inkgc/gc-managed.h | 2 | ||||
| -rw-r--r-- | src/inkgc/gc.cpp | 2 | ||||
| -rw-r--r-- | src/live_effects/lpeobject-reference.cpp | 4 | ||||
| -rw-r--r-- | src/live_effects/parameter/item.cpp | 13 | ||||
| -rw-r--r-- | src/live_effects/parameter/path.cpp | 13 | ||||
| -rw-r--r-- | src/sp-conn-end.cpp | 3 | ||||
| -rw-r--r-- | src/sp-filter.cpp | 10 | ||||
| -rw-r--r-- | src/sp-gradient.cpp | 4 | ||||
| -rw-r--r-- | src/sp-hatch.cpp | 5 | ||||
| -rw-r--r-- | src/sp-item.cpp | 7 | ||||
| -rw-r--r-- | src/sp-lpe-item.cpp | 5 | ||||
| -rw-r--r-- | src/sp-offset.cpp | 7 | ||||
| -rw-r--r-- | src/sp-pattern.cpp | 4 | ||||
| -rw-r--r-- | src/sp-tag-use-reference.cpp | 5 | ||||
| -rw-r--r-- | src/sp-tag-use.cpp | 5 | ||||
| -rw-r--r-- | src/sp-tag-use.h | 1 | ||||
| -rw-r--r-- | src/sp-tref.cpp | 4 | ||||
| -rw-r--r-- | src/sp-use-reference.cpp | 4 | ||||
| -rw-r--r-- | src/sp-use.cpp | 2 | ||||
| -rw-r--r-- | src/style-internal.cpp | 6 | ||||
| -rw-r--r-- | src/style.cpp | 8 | ||||
| -rw-r--r-- | src/trace/trace.h | 4 | ||||
| -rw-r--r-- | src/ui/tools/flood-tool.cpp | 59 | ||||
| -rw-r--r-- | src/uri-references.cpp | 9 | ||||
| -rw-r--r-- | src/uri-references.h | 3 | ||||
| -rw-r--r-- | src/uri.cpp | 14 | ||||
| -rw-r--r-- | src/uri.h | 11 |
30 files changed, 145 insertions, 84 deletions
diff --git a/src/box3d.cpp b/src/box3d.cpp index dfc4d06e7..23766895a 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -15,12 +15,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "box3d.h" + #include <glibmm/i18n.h> #include "attributes.h" #include "xml/document.h" #include "xml/repr.h" -#include "box3d.h" +#include "bad-uri-exception.h" #include "box3d-side.h" #include "ui/tools/box3d-tool.h" #include "perspective-line.h" diff --git a/src/filters/image.cpp b/src/filters/image.cpp index 887201eb3..3dedb28ad 100644 --- a/src/filters/image.cpp +++ b/src/filters/image.cpp @@ -14,12 +14,15 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "image.h" + #include <sigc++/bind.h> + +#include "bad-uri-exception.h" #include "display/nr-filter-image.h" #include "uri.h" #include "uri-references.h" #include "attributes.h" -#include "image.h" #include "xml/repr.h" #include "display/nr-filter.h" diff --git a/src/inkgc/gc-core.h b/src/inkgc/gc-core.h index d9d0bf4ff..a27510f50 100644 --- a/src/inkgc/gc-core.h +++ b/src/inkgc/gc-core.h @@ -18,7 +18,7 @@ #include <new> #include <cstdlib> -#include <cstddef> + #ifdef HAVE_GC_GC_H # include <gc/gc.h> #else @@ -137,7 +137,6 @@ inline void *operator new(std::size_t size, Inkscape::GC::CollectionPolicy collect, Inkscape::GC::CleanupFunc cleanup=NULL, void *data=NULL) -throw(std::bad_alloc) { using namespace Inkscape::GC; @@ -168,7 +167,6 @@ inline void *operator new(std::size_t size, Inkscape::GC::ScanPolicy scan, Inkscape::GC::CleanupFunc cleanup=NULL, void *data=NULL) -throw(std::bad_alloc) { return operator new(size, scan, Inkscape::GC::AUTO, cleanup, data); } @@ -178,7 +176,6 @@ inline void *operator new[](std::size_t size, Inkscape::GC::CollectionPolicy collect, Inkscape::GC::CleanupFunc cleanup=NULL, void *data=NULL) -throw(std::bad_alloc) { return operator new(size, scan, collect, cleanup, data); } @@ -187,7 +184,6 @@ inline void *operator new[](std::size_t size, Inkscape::GC::ScanPolicy scan, Inkscape::GC::CleanupFunc cleanup=NULL, void *data=NULL) -throw(std::bad_alloc) { return operator new[](size, scan, Inkscape::GC::AUTO, cleanup, data); } diff --git a/src/inkgc/gc-managed.h b/src/inkgc/gc-managed.h index f435d7802..97b2b816e 100644 --- a/src/inkgc/gc-managed.h +++ b/src/inkgc/gc-managed.h @@ -30,7 +30,6 @@ public: void *operator new(std::size_t size, ScanPolicy scan=default_scan, CollectionPolicy collect=default_collect) - throw (std::bad_alloc) { return ::operator new(size, scan, collect); } @@ -38,7 +37,6 @@ public: void *operator new[](std::size_t size, ScanPolicy scan=default_scan, CollectionPolicy collect=default_collect) - throw (std::bad_alloc) { return ::operator new[](size, scan, collect); } diff --git a/src/inkgc/gc.cpp b/src/inkgc/gc.cpp index ffa94ea2a..b1bd07af6 100644 --- a/src/inkgc/gc.cpp +++ b/src/inkgc/gc.cpp @@ -173,7 +173,7 @@ public: {} }; -Ops const &get_ops() throw (InvalidGCModeError) { +Ops const &get_ops() { char *mode_string=std::getenv("_INKSCAPE_GC"); if (mode_string) { if (!std::strcmp(mode_string, "enable")) { diff --git a/src/live_effects/lpeobject-reference.cpp b/src/live_effects/lpeobject-reference.cpp index 1940806bd..83cd6623c 100644 --- a/src/live_effects/lpeobject-reference.cpp +++ b/src/live_effects/lpeobject-reference.cpp @@ -6,9 +6,11 @@ * Released under GNU GPL, read the file 'COPYING' for more information. */ +#include "live_effects/lpeobject-reference.h" + #include <string.h> -#include "live_effects/lpeobject-reference.h" +#include "bad-uri-exception.h" #include "live_effects/lpeobject.h" #include "uri.h" diff --git a/src/live_effects/parameter/item.cpp b/src/live_effects/parameter/item.cpp index 8caea4e26..93cf2b15f 100644 --- a/src/live_effects/parameter/item.cpp +++ b/src/live_effects/parameter/item.cpp @@ -5,15 +5,20 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "ui/widget/point.h" +#include "live_effects/parameter/item.h" + #include <glibmm/i18n.h> -#include "live_effects/parameter/item.h" +#include <gtkmm/button.h> +#include <gtkmm/label.h> + +#include "bad-uri-exception.h" +#include "ui/widget/point.h" + #include "live_effects/effect.h" #include "svg/svg.h" #include "widgets/icon.h" -#include <gtk/gtk.h> #include "selection-chemistry.h" #include "xml/repr.h" #include "desktop.h" @@ -25,8 +30,6 @@ // required for linking to other paths #include "uri.h" -#include <gtkmm/button.h> -#include <gtkmm/label.h> #include "ui/icon-names.h" namespace Inkscape { diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index f0c494267..dafc6d406 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -5,10 +5,16 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "ui/widget/point.h" +#include "live_effects/parameter/path.h" + #include <glibmm/i18n.h> -#include "live_effects/parameter/path.h" +#include <gtkmm/button.h> +#include <gtkmm/label.h> + +#include "bad-uri-exception.h" +#include "ui/widget/point.h" + #include "live_effects/effect.h" #include "svg/svg.h" #include <2geom/svg-path-parser.h> @@ -17,7 +23,6 @@ #include <2geom/d2.h> #include "widgets/icon.h" -#include <gtk/gtk.h> #include "selection-chemistry.h" #include "xml/repr.h" #include "desktop.h" @@ -44,8 +49,6 @@ #include "ui/tool/multi-path-manipulator.h" #include "ui/tool/shape-record.h" -#include <gtkmm/button.h> -#include <gtkmm/label.h> #include "ui/icon-names.h" namespace Inkscape { diff --git a/src/sp-conn-end.cpp b/src/sp-conn-end.cpp index 9ce1a3b56..3c3b8abb0 100644 --- a/src/sp-conn-end.cpp +++ b/src/sp-conn-end.cpp @@ -1,11 +1,12 @@ +#include "sp-conn-end.h" #include <cstring> #include <string> #include <limits> +#include "bad-uri-exception.h" #include "display/curve.h" #include "xml/repr.h" -#include "sp-conn-end.h" #include "sp-path.h" #include "uri.h" #include "document.h" diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index 26ea03c6c..052fa7fe2 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -17,21 +17,25 @@ #include <config.h> #endif +#include "sp-filter.h" + #include <map> #include <string.h> -using std::map; -using std::pair; #include <glibmm.h> + +#include "bad-uri-exception.h" #include "attributes.h" #include "display/nr-filter.h" #include "document.h" -#include "sp-filter.h" #include "sp-filter-reference.h" #include "sp-filter-primitive.h" #include "uri.h" #include "xml/repr.h" +using std::map; +using std::pair; + #define SP_MACROS_SILENT static void filter_ref_changed(SPObject *old_ref, SPObject *ref, SPFilter *filter); diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index f02149cbb..c1934dd92 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -24,6 +24,8 @@ #define noSP_GRADIENT_VERBOSE //#define OBJECT_TRACE +#include "sp-gradient.h" + #include <cstring> #include <string> @@ -34,12 +36,12 @@ #include <sigc++/functors/ptr_fun.h> #include <sigc++/adaptors/bind.h> +#include "bad-uri-exception.h" #include "display/cairo-utils.h" #include "svg/svg.h" #include "svg/css-ostringstream.h" #include "attributes.h" #include "document-private.h" -#include "sp-gradient.h" #include "gradient-chemistry.h" #include "sp-gradient-reference.h" #include "sp-linear-gradient.h" diff --git a/src/sp-hatch.cpp b/src/sp-hatch.cpp index 02d95c75c..f1958a53b 100644 --- a/src/sp-hatch.cpp +++ b/src/sp-hatch.cpp @@ -12,11 +12,15 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "sp-hatch.h" + #include <cstring> #include <string> + #include <2geom/transforms.h> #include <sigc++/functors/mem_fun.h> +#include "bad-uri-exception.h" #include "svg/svg.h" #include "display/cairo-utils.h" #include "display/drawing-context.h" @@ -25,7 +29,6 @@ #include "display/drawing-pattern.h" #include "attributes.h" #include "document-private.h" -#include "sp-hatch.h" #include "sp-hatch-path.h" SPHatch::SPHatch() diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 5d02020c6..e2f678957 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -17,6 +17,10 @@ #endif #include "sp-item.h" + +#include <glibmm/i18n.h> + +#include "bad-uri-exception.h" #include "svg/svg.h" #include "print.h" #include "display/drawing-item.h" @@ -25,10 +29,7 @@ #include "uri.h" #include "inkscape.h" #include "desktop.h" - - #include "style.h" -#include <glibmm/i18n.h> #include "sp-root.h" #include "sp-clippath.h" #include "sp-mask.h" diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index 00671b936..ca0f78a00 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -15,10 +15,11 @@ #ifdef HAVE_CONFIG_H #endif -#include "ui/tool/multi-path-manipulator.h" - #include <glibmm/i18n.h> +#include "bad-uri-exception.h" +#include "ui/tool/multi-path-manipulator.h" + #include "live_effects/effect.h" #include "live_effects/lpe-path_length.h" #include "live_effects/lpeobject.h" diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp index 9e2264d76..e5b1b5d69 100644 --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@ -18,13 +18,17 @@ #include <config.h> #endif +#include "sp-offset.h" + #include <cstring> #include <string> +#include <glibmm/i18n.h> + +#include "bad-uri-exception.h" #include "svg/svg.h" #include "attributes.h" #include "display/curve.h" -#include <glibmm/i18n.h> #include "livarot/Path.h" #include "livarot/Shape.h" @@ -32,7 +36,6 @@ #include "enums.h" #include "preferences.h" #include "sp-text.h" -#include "sp-offset.h" #include "sp-use-reference.h" #include "uri.h" diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 9d6296a0d..377c035fc 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -16,11 +16,14 @@ #include <config.h> #endif +#include "sp-pattern.h" + #include <cstring> #include <string> #include <glibmm.h> #include <2geom/transforms.h> +#include "bad-uri-exception.h" #include "svg/svg.h" #include "display/cairo-utils.h" #include "display/drawing-context.h" @@ -29,7 +32,6 @@ #include "display/drawing-group.h" #include "attributes.h" #include "document-private.h" -#include "sp-pattern.h" #include "sp-factory.h" diff --git a/src/sp-tag-use-reference.cpp b/src/sp-tag-use-reference.cpp index cca24ed85..bb03c120a 100644 --- a/src/sp-tag-use-reference.cpp +++ b/src/sp-tag-use-reference.cpp @@ -6,11 +6,12 @@ * Released under GNU GPL, read the file 'COPYING' for more information. */ +#include "sp-tag-use-reference.h" + #include <cstring> #include <string> -#include "sp-tag-use-reference.h" - +#include "bad-uri-exception.h" #include "livarot/Path.h" #include "preferences.h" #include "sp-shape.h" diff --git a/src/sp-tag-use.cpp b/src/sp-tag-use.cpp index 935f7429e..1312b923f 100644 --- a/src/sp-tag-use.cpp +++ b/src/sp-tag-use.cpp @@ -10,10 +10,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "sp-tag-use.h" + #include <cstring> #include <string> #include <glibmm/i18n.h> + +#include "bad-uri-exception.h" #include "display/drawing-group.h" #include "attributes.h" #include "document.h" @@ -23,7 +27,6 @@ #include "style.h" #include "sp-factory.h" #include "sp-symbol.h" -#include "sp-tag-use.h" #include "sp-tag-use-reference.h" SPTagUse::SPTagUse() diff --git a/src/sp-tag-use.h b/src/sp-tag-use.h index 3f238d654..651c8f045 100644 --- a/src/sp-tag-use.h +++ b/src/sp-tag-use.h @@ -22,6 +22,7 @@ #define SP_TAG_USE(obj) (dynamic_cast<SPTagUse*> (obj)) #define SP_IS_TAG_USE(obj) (dynamic_cast<SPTagUse*> (obj) != NULL) +class SPItem; class SPTagUse; class SPTagUseReference; diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index e25ddb5a4..014876478 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -16,13 +16,15 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "sp-tref.h" + #include <glibmm/i18n.h> +#include "bad-uri-exception.h" #include "attributes.h" #include "document.h" #include "sp-factory.h" #include "sp-text.h" -#include "sp-tref.h" #include "style.h" #include "text-editing.h" diff --git a/src/sp-use-reference.cpp b/src/sp-use-reference.cpp index 3dd63df40..ea8bc5e86 100644 --- a/src/sp-use-reference.cpp +++ b/src/sp-use-reference.cpp @@ -7,11 +7,13 @@ * Released under GNU GPL, read the file 'COPYING' for more information. */ +#include "sp-use-reference.h" + #include <cstring> #include <string> +#include "bad-uri-exception.h" #include "enums.h" -#include "sp-use-reference.h" #include "display/curve.h" #include "livarot/Path.h" diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 6ba03dad9..648852961 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -19,6 +19,8 @@ #include <2geom/transforms.h> #include <glibmm/i18n.h> #include <glibmm/markup.h> + +#include "bad-uri-exception.h" #include "display/drawing-group.h" #include "attributes.h" #include "document.h" diff --git a/src/style-internal.cpp b/src/style-internal.cpp index a6ccdf376..54d1a0867 100644 --- a/src/style-internal.cpp +++ b/src/style-internal.cpp @@ -27,6 +27,10 @@ #endif #include "style-internal.h" + +#include <glibmm/regex.h> + +#include "bad-uri-exception.h" #include "style.h" #include "svg/svg.h" @@ -40,8 +44,6 @@ #include "svg/css-ostringstream.h" #include "util/units.h" -#include <glibmm/regex.h> - // TODO REMOVE OR MAKE MEMBER FUNCTIONS void sp_style_fill_paint_server_ref_changed( SPObject *old_ref, SPObject *ref, SPStyle *style); void sp_style_stroke_paint_server_ref_changed(SPObject *old_ref, SPObject *ref, SPStyle *style); diff --git a/src/style.cpp b/src/style.cpp index 86377db08..b65cb26cb 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -23,10 +23,15 @@ #include <config.h> #endif +#include "style.h" + #include <cstring> #include <string> #include <algorithm> +#include <glibmm/regex.h> + +#include "bad-uri-exception.h" #include "libcroco/cr-sel-eng.h" #include "xml/croco-node-iface.h" @@ -38,14 +43,11 @@ #include "uri-references.h" #include "uri.h" #include "sp-paint-server.h" -#include "style.h" #include "svg/css-ostringstream.h" #include "xml/simple-document.h" #include "util/units.h" #include "preferences.h" -#include <glibmm/regex.h> - using Inkscape::CSSOStringStream; using std::vector; diff --git a/src/trace/trace.h b/src/trace/trace.h index 662b2537e..f562e89aa 100644 --- a/src/trace/trace.h +++ b/src/trace/trace.h @@ -13,10 +13,6 @@ # include "config.h" #endif -#ifdef HAVE_STDLIB_H -# include <stdlib.h> -#endif - #ifdef HAVE_STRING_H # include <string.h> #endif diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp index 1801a0ea0..6e1d085aa 100644 --- a/src/ui/tools/flood-tool.cpp +++ b/src/ui/tools/flood-tool.cpp @@ -21,6 +21,7 @@ #include <config.h> #endif +#include <cmath> #include "trace/potrace/inkscape-potrace.h" #include <2geom/pathvector.h> #include <gdk/gdkkeysyms.h> @@ -186,6 +187,21 @@ inline unsigned char * get_trace_pixel(guchar *trace_px, int x, int y, int width } /** + * \brief Check whether two unsigned integers are close to each other + * + * \param[in] a The 1st unsigned int + * \param[in] b The 2nd unsigned int + * \param[in] d The threshold for comparison + * + * \return true if |a-b| <= d; false otherwise + */ +static bool compare_guint32(guint32 const a, guint32 const b, guint32 const d) +{ + const int difference = std::abs(static_cast<int>(a) - static_cast<int>(b)); + return difference <= d; +} + +/** * Compare a pixel in a pixel buffer with another pixel to determine if a point should be included in the fill operation. * @param check The pixel in the pixel buffer to check. * @param orig The original selected pixel to use as the fill target color. @@ -196,7 +212,6 @@ inline unsigned char * get_trace_pixel(guchar *trace_px, int x, int y, int width */ static bool compare_pixels(guint32 check, guint32 orig, guint32 merged_orig_pixel, guint32 dtc, int threshold, PaintBucketChannels method) { - int diff = 0; float hsl_check[3] = {0,0,0}, hsl_orig[3] = {0,0,0}; guint32 ac = 0, rc = 0, gc = 0, bc = 0; @@ -222,27 +237,35 @@ static bool compare_pixels(guint32 check, guint32 orig, guint32 merged_orig_pixe switch (method) { case FLOOD_CHANNELS_ALPHA: - return abs(static_cast<int>(ac) - ao) <= threshold; + return compare_guint32(ac, ao, threshold); case FLOOD_CHANNELS_R: - return abs(static_cast<int>(ac ? unpremul_alpha(rc, ac) : 0) - (ao ? unpremul_alpha(ro, ao) : 0)) <= threshold; + return compare_guint32(ac ? unpremul_alpha(rc, ac) : 0, + ao ? unpremul_alpha(ro, ao) : 0, + threshold); case FLOOD_CHANNELS_G: - return abs(static_cast<int>(ac ? unpremul_alpha(gc, ac) : 0) - (ao ? unpremul_alpha(go, ao) : 0)) <= threshold; + return compare_guint32(ac ? unpremul_alpha(gc, ac) : 0, + ao ? unpremul_alpha(go, ao) : 0, + threshold); case FLOOD_CHANNELS_B: - return abs(static_cast<int>(ac ? unpremul_alpha(bc, ac) : 0) - (ao ? unpremul_alpha(bo, ao) : 0)) <= threshold; + return compare_guint32(ac ? unpremul_alpha(bc, ac) : 0, + ao ? unpremul_alpha(bo, ao) : 0, + threshold); case FLOOD_CHANNELS_RGB: - guint32 amc, rmc, bmc, gmc; - //amc = 255*255 - (255-ac)*(255-ad); amc = (amc + 127) / 255; - //amc = (255-ac)*ad + 255*ac; amc = (amc + 127) / 255; - amc = 255; // Why are we looking at desktop? Cairo version ignores destop alpha - rmc = (255-ac)*rd + 255*rc; rmc = (rmc + 127) / 255; - gmc = (255-ac)*gd + 255*gc; gmc = (gmc + 127) / 255; - bmc = (255-ac)*bd + 255*bc; bmc = (bmc + 127) / 255; - - diff += abs(static_cast<int>(amc ? unpremul_alpha(rmc, amc) : 0) - (amop ? unpremul_alpha(rmop, amop) : 0)); - diff += abs(static_cast<int>(amc ? unpremul_alpha(gmc, amc) : 0) - (amop ? unpremul_alpha(gmop, amop) : 0)); - diff += abs(static_cast<int>(amc ? unpremul_alpha(bmc, amc) : 0) - (amop ? unpremul_alpha(bmop, amop) : 0)); - return ((diff / 3) <= ((threshold * 3) / 4)); - + { + guint32 amc, rmc, bmc, gmc; + //amc = 255*255 - (255-ac)*(255-ad); amc = (amc + 127) / 255; + //amc = (255-ac)*ad + 255*ac; amc = (amc + 127) / 255; + amc = 255; // Why are we looking at desktop? Cairo version ignores destop alpha + rmc = (255-ac)*rd + 255*rc; rmc = (rmc + 127) / 255; + gmc = (255-ac)*gd + 255*gc; gmc = (gmc + 127) / 255; + bmc = (255-ac)*bd + 255*bc; bmc = (bmc + 127) / 255; + + int diff = 0; // The total difference between each of the 3 color components + diff += std::abs(static_cast<int>(amc ? unpremul_alpha(rmc, amc) : 0) - static_cast<int>(amop ? unpremul_alpha(rmop, amop) : 0)); + diff += std::abs(static_cast<int>(amc ? unpremul_alpha(gmc, amc) : 0) - static_cast<int>(amop ? unpremul_alpha(gmop, amop) : 0)); + diff += std::abs(static_cast<int>(amc ? unpremul_alpha(bmc, amc) : 0) - static_cast<int>(amop ? unpremul_alpha(bmop, amop) : 0)); + return ((diff / 3) <= ((threshold * 3) / 4)); + } case FLOOD_CHANNELS_H: return ((int)(fabs(hsl_check[0] - hsl_orig[0]) * 100.0) <= threshold); case FLOOD_CHANNELS_S: diff --git a/src/uri-references.cpp b/src/uri-references.cpp index 170c98beb..7d6abd10a 100644 --- a/src/uri-references.cpp +++ b/src/uri-references.cpp @@ -11,16 +11,19 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "uri-references.h" + #include <iostream> #include <cstring> +#include <glibmm/miscutils.h> + +#include "bad-uri-exception.h" #include "document.h" #include "sp-object.h" #include "uri.h" -#include "uri-references.h" #include "extract-uri.h" #include "sp-tag-use.h" -#include <glibmm/miscutils.h> namespace Inkscape { @@ -103,7 +106,7 @@ bool URIReference::_acceptObject(SPObject *obj) const -void URIReference::attach(const URI &uri) throw(BadURIException) +void URIReference::attach(const URI &uri) { SPDocument *document = NULL; diff --git a/src/uri-references.h b/src/uri-references.h index e56ea0612..ce0f5f2ae 100644 --- a/src/uri-references.h +++ b/src/uri-references.h @@ -20,7 +20,6 @@ #include <sigc++/connection.h> #include <sigc++/trackable.h> -#include "bad-uri-exception.h" #include "sp-object.h" #include "sp-item.h" #include "sp-use.h" @@ -66,7 +65,7 @@ public: * @param rel_document document for relative URIs * @param uri the URI to watch */ - void attach(URI const& uri) throw(BadURIException); + void attach(URI const& uri); /** * Detaches from the currently attached URI target, if any; diff --git a/src/uri.cpp b/src/uri.cpp index f2578b989..9178c8ae8 100644 --- a/src/uri.cpp +++ b/src/uri.cpp @@ -8,11 +8,13 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib.h> #include "uri.h" + #include <glibmm/ustring.h> #include <glibmm/miscutils.h> +#include "bad-uri-exception.h" + namespace Inkscape { URI::URI() { @@ -25,7 +27,7 @@ URI::URI(const URI &uri) { _impl = uri._impl; } -URI::URI(gchar const *preformed) throw(BadURIException) { +URI::URI(gchar const *preformed) { xmlURIPtr uri; if (!preformed) { throw MalformedURIException(); @@ -132,7 +134,7 @@ const gchar *URI::Impl::getOpaque() const { return (gchar *)_uri->opaque; } -gchar *URI::to_native_filename(gchar const* uri) throw(BadURIException) +gchar *URI::to_native_filename(gchar const* uri) { gchar *filename = NULL; URI tmp(uri); @@ -166,7 +168,7 @@ const std::string URI::getFullPath(std::string const &base) const { /* TODO !!! proper error handling */ -gchar *URI::toNativeFilename() const throw(BadURIException) { +gchar *URI::toNativeFilename() const { gchar *uriString = toString(); if (isRelativePath()) { return uriString; @@ -181,7 +183,7 @@ gchar *URI::toNativeFilename() const throw(BadURIException) { } } -URI URI::fromUtf8( gchar const* path ) throw (BadURIException) { +URI URI::fromUtf8( gchar const* path ) { if ( !path ) { throw MalformedURIException(); } @@ -215,7 +217,7 @@ URI URI::fromUtf8( gchar const* path ) throw (BadURIException) { } /* TODO !!! proper error handling */ -URI URI::from_native_filename(gchar const *path) throw(BadURIException) { +URI URI::from_native_filename(gchar const *path) { gchar *uri = g_filename_to_uri(path, NULL, NULL); URI result(uri); g_free( uri ); @@ -13,7 +13,6 @@ #include <exception> #include <libxml/uri.h> -#include "bad-uri-exception.h" #include <string> namespace Inkscape { @@ -37,7 +36,7 @@ public: * * @param preformed Properly quoted C-style string to be represented. */ - explicit URI(char const *preformed) throw(BadURIException); + explicit URI(char const *preformed); /** * Destructor. @@ -98,15 +97,15 @@ public: const char *getOpaque() const { return _impl->getOpaque(); } - static URI fromUtf8( char const* path ) throw (BadURIException); + static URI fromUtf8( char const* path ); - static URI from_native_filename(char const *path) throw(BadURIException); + static URI from_native_filename(char const *path); - static char *to_native_filename(char const* uri) throw(BadURIException); + static char *to_native_filename(char const* uri); const std::string getFullPath(std::string const &base) const; - char *toNativeFilename() const throw(BadURIException); + char *toNativeFilename() const; /** * Returns a glib string version of this URI. |
