From ebf4167e4f3ec3ca9f5ece6c5316abc209a9f049 Mon Sep 17 00:00:00 2001 From: kiirala Date: Sat, 28 Mar 2009 12:01:17 +0000 Subject: [PATCH] Made functions in nr-filter-utils inlineable --- src/display/nr-filter-utils.cpp | 19 ++----------------- src/display/nr-filter-utils.h | 22 ++++++++++++++++++---- src/display/pixblock-scaler.cpp | 5 ++++- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/display/nr-filter-utils.cpp b/src/display/nr-filter-utils.cpp index e9e422094..d36c0beb5 100644 --- a/src/display/nr-filter-utils.cpp +++ b/src/display/nr-filter-utils.cpp @@ -3,23 +3,8 @@ namespace Inkscape { namespace Filters { -int clamp(int const val) { - if (val < 0) return 0; - if (val > 255) return 255; - return val; -} - -int clamp3(int const val) { - if (val < 0) return 0; - if (val > 16581375) return 16581375; - return val; -} - -int clamp_alpha(int const val, int const alpha) { - if (val < 0) return 0; - if (val > alpha) return alpha; - return val; -} +/* Everything moved to .h, because they were short functions that should + * get inlined */ } /* namespace Filters */ } /* namespace Inkscape */ diff --git a/src/display/nr-filter-utils.h b/src/display/nr-filter-utils.h index ccdaec1a8..c825a814e 100644 --- a/src/display/nr-filter-utils.h +++ b/src/display/nr-filter-utils.h @@ -14,7 +14,6 @@ #include "round.h" -/* Shouldn't these be inlined? */ namespace Inkscape { namespace Filters { @@ -25,7 +24,12 @@ namespace Filters { * \return 0 if the value is smaller than 0, 255 if it is greater 255, else v * \param v the value to clamp */ -int clamp(int const val); +__attribute__ ((const)) +inline int clamp(int const val) { + if (val < 0) return 0; + if (val > 255) return 255; + return val; +} /** * Clamps an integer value to a value between 0 and 255^3. @@ -33,7 +37,12 @@ int clamp(int const val); * \return 0 if the value is smaller than 0, 255^3 (16581375) if it is greater than 255^3, else v * \param v the value to clamp */ -int clamp3(int const val); +__attribute__ ((const)) +inline int clamp3(int const val) { + if (val < 0) return 0; + if (val > 16581375) return 16581375; + return val; +} /** * Macro to use the clamp function with double inputs and unsigned char output @@ -48,7 +57,12 @@ int clamp3(int const val); * \param val the value to clamp * \param alpha the maximum value to clamp to */ -int clamp_alpha(int const val, int const alpha); +__attribute__ ((const)) +inline int clamp_alpha(int const val, int const alpha) { + if (val < 0) return 0; + if (val > alpha) return alpha; + return val; +} } /* namespace Filters */ } /* namespace Inkscape */ diff --git a/src/display/pixblock-scaler.cpp b/src/display/pixblock-scaler.cpp index 767334935..cefbfe4fb 100644 --- a/src/display/pixblock-scaler.cpp +++ b/src/display/pixblock-scaler.cpp @@ -13,7 +13,10 @@ #include #include -using std::floor; +#if defined (SOLARIS) && (SOLARIS == 8) +#include "round.h" +using Inkscape::round; +#endif #include "display/nr-filter-utils.h" #include "libnr/nr-pixblock.h" -- 2.30.2