From: Foster B. <fos...@us...> - 2006-02-23 23:29:32
|
Update of /cvsroot/adobe-source/sandbox/adobe-source/adobe/gil/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25760/adobe/gil/core Modified Files: algorithm.hpp cmyk.hpp gil_concept.hpp gil_config.hpp image.hpp lab.hpp pixel_iterator.hpp rgb.hpp rgba.hpp typedefs.hpp utilities.hpp variant.hpp Log Message: the state of things. We've been working to isolate static_text_t (now called label_t) but it has been slow going because we're trying to wrestle with perfecting the API and what effect that has on other components that were using label_t in a way that isn't in accordance with the new API we're trying to write. As it stands static_disabled_text_m is broken on both platforms, but everything else should be working better. Index: image.hpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/gil/core/image.hpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** image.hpp 3 Feb 2006 18:33:37 -0000 1.3 --- image.hpp 23 Feb 2006 23:28:56 -0000 1.4 *************** *** 275,279 **** void create_with_own_data_(const point_type& dimensions, unsigned int alignment, is_planar<false>) { ! std::size_t rowsize_in_bytes=get_aligned(dimensions.x*sizeof(typename V::value_type),alignment); unsigned char* tmp=_alloc.allocate(rowsize_in_bytes*dimensions.y); try { --- 275,279 ---- void create_with_own_data_(const point_type& dimensions, unsigned int alignment, is_planar<false>) { ! std::size_t rowsize_in_bytes=align(dimensions.x*sizeof(typename V::value_type),alignment); unsigned char* tmp=_alloc.allocate(rowsize_in_bytes*dimensions.y); try { *************** *** 285,289 **** } void create_with_own_data_(const point_type& dimensions, unsigned int alignment, is_planar<true>) { ! std::size_t planesize_in_bytes=get_aligned(dimensions.x*dimensions.y*sizeof(typename V::channel_type),alignment); std::size_t image_size_in_bytes=planesize_in_bytes*V::color_space_type::num_channels; unsigned char* tmp=_alloc.allocate(image_size_in_bytes); --- 285,289 ---- } void create_with_own_data_(const point_type& dimensions, unsigned int alignment, is_planar<true>) { ! std::size_t planesize_in_bytes=align(dimensions.x*dimensions.y*sizeof(typename V::channel_type),alignment); std::size_t image_size_in_bytes=planesize_in_bytes*V::color_space_type::num_channels; unsigned char* tmp=_alloc.allocate(image_size_in_bytes); *************** *** 300,304 **** template <typename V1,typename V2> bool operator==(const image<V1>& im1,const image<V2>& im2) { ! if (&im1==&im2) return true; if (const_view(im1).dimensions()!=const_view(im2).dimensions()) return false; return std::equal(const_view(im1).begin(),const_view(im1).end(),const_view(im2).begin()); // TODO: change this to equal_pixels (for performance) --- 300,304 ---- template <typename V1,typename V2> bool operator==(const image<V1>& im1,const image<V2>& im2) { ! if ((void*)(&im1)==(void*)(&im2)) return true; if (const_view(im1).dimensions()!=const_view(im2).dimensions()) return false; return std::equal(const_view(im1).begin(),const_view(im1).end(),const_view(im2).begin()); // TODO: change this to equal_pixels (for performance) Index: cmyk.hpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/gil/core/cmyk.hpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** cmyk.hpp 3 Feb 2006 18:33:37 -0000 1.2 --- cmyk.hpp 23 Feb 2006 23:28:56 -0000 1.3 *************** *** 96,101 **** planar_ptr(unsigned char* data, ptrdiff_t step=1) : parent_type((T*)data, (T*)(data+step), (T*)(data+step+step), (T*)(data+step*3)) {} ! planar_ptr(const planar_ptr& ptr) : parent_type(ptr) {} ! planar_ptr& operator=(const planar_ptr& ptr) { this->p=ptr.p; return *this; } /// Copy constructor and operator= from pointers to compatible planar pixels or planar pixel references. --- 96,101 ---- planar_ptr(unsigned char* data, ptrdiff_t step=1) : parent_type((T*)data, (T*)(data+step), (T*)(data+step+step), (T*)(data+step*3)) {} ! template <typename T1,typename C1> planar_ptr(const planar_ptr<T1,C1>& ptr) : parent_type(ptr) {} ! template <typename T1,typename C1> planar_ptr& operator=(const planar_ptr<T1,C1>& ptr) { this->p=ptr.p; return *this; } /// Copy constructor and operator= from pointers to compatible planar pixels or planar pixel references. Index: algorithm.hpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/gil/core/algorithm.hpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** algorithm.hpp 3 Feb 2006 18:33:37 -0000 1.3 --- algorithm.hpp 23 Feb 2006 23:28:56 -0000 1.4 *************** *** 12,15 **** --- 12,16 ---- #include "gil_config.hpp" #include "gil_concept.hpp" + #include <boost/bind.hpp> #include <cassert> #include <algorithm> *************** *** 82,86 **** while (n>0) { ptrdiff_t numToCopy=std::min<const ptrdiff_t>(n, src.width()-src.x()); ! copy_n(src.x_it(), numToCopy, dst); dst+=numToCopy; src+=numToCopy; --- 83,87 ---- while (n>0) { ptrdiff_t numToCopy=std::min<const ptrdiff_t>(n, src.width()-src.x()); ! adobe::copy_n(src.x_it(), numToCopy, dst); dst+=numToCopy; src+=numToCopy; *************** *** 99,103 **** while (n>0) { ptrdiff_t numToCopy=std::min<const ptrdiff_t>(n,dst.width()-dst.x()); ! copy_n(src, numToCopy, dst.x_it()); dst+=numToCopy; src+=numToCopy; --- 100,104 ---- while (n>0) { ptrdiff_t numToCopy=std::min<const ptrdiff_t>(n,dst.width()-dst.x()); ! adobe::copy_n(src, numToCopy, dst.x_it()); dst+=numToCopy; src+=numToCopy; *************** *** 121,125 **** while (n>0) { ptrdiff_t numToCopy=std::min<const ptrdiff_t>(n,dst.width()-dst.x()); ! copy_n(src.x_it(), numToCopy, dst.x_it()); dst+=numToCopy; src+=numToCopy; --- 122,126 ---- while (n>0) { ptrdiff_t numToCopy=std::min<const ptrdiff_t>(n,dst.width()-dst.x()); ! adobe::copy_n(src.x_it(), numToCopy, dst.x_it()); dst+=numToCopy; src+=numToCopy; *************** *** 221,225 **** typename V2> // Model image view void copy_pixels(const variant<C1>& src, const V2& dst) { ! src.apply_visitor(GIL::bind2nd(GIL::detail::copy_pixels_fn(), dst)); } --- 222,226 ---- typename V2> // Model image view void copy_pixels(const variant<C1>& src, const V2& dst) { ! src.apply_visitor(boost::bind(GIL::detail::copy_pixels_fn(), _1, dst)); } *************** *** 227,231 **** typename C2> // Model non-const image view concept space void copy_pixels(const V1& src, const variant<C2>& dst) { ! dst.apply_visitor(GIL::bind1st(GIL::detail::copy_pixels_fn(), src)); } --- 228,232 ---- typename C2> // Model non-const image view concept space void copy_pixels(const V1& src, const variant<C2>& dst) { ! dst.apply_visitor(boost::bind(GIL::detail::copy_pixels_fn(), src, _2)); } *************** *** 272,276 **** typename V2> // Model image view void copy_and_convert_pixels(const variant<C1>& src, const V2& dst) { ! src.apply_visitor(GIL::bind2nd(detail::copy_and_convert_pixels_fn(), dst)); } --- 273,277 ---- typename V2> // Model image view void copy_and_convert_pixels(const variant<C1>& src, const V2& dst) { ! src.apply_visitor(boost::bind(detail::copy_and_convert_pixels_fn(), _1, dst)); } *************** *** 278,282 **** typename C2> // Model non-const image view concept space void copy_and_convert_pixels(const V1& src, const variant<C2>& dst) { ! dst.apply_visitor(GIL::bind1st(detail::copy_and_convert_pixels_fn(), src)); } --- 279,283 ---- typename C2> // Model non-const image view concept space void copy_and_convert_pixels(const V1& src, const variant<C2>& dst) { ! dst.apply_visitor(boost::bind(detail::copy_and_convert_pixels_fn(), src, _2)); } Index: gil_config.hpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/gil/core/gil_config.hpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gil_config.hpp 3 Feb 2006 18:33:37 -0000 1.2 --- gil_config.hpp 23 Feb 2006 23:28:56 -0000 1.3 *************** *** 10,23 **** #define GIL_CONFIG_H ! #ifdef NO_ASL ! #define GIL gil ! #define ADOBE_GIL_NAMESPACE_BEGIN namespace GIL { ! #define ADOBE_GIL_NAMESPACE_END } ! #else #include <adobe/config.hpp> #define GIL adobe::gil #define ADOBE_GIL_NAMESPACE_BEGIN namespace adobe { namespace gil { #define ADOBE_GIL_NAMESPACE_END } } #endif #endif --- 10,200 ---- #define GIL_CONFIG_H ! //////////////////////////////////////////////////////////////////////////////////////// ! /// \file ! /// \brief GIL configuration file ! /// \author Lubomir Bourdev and Hailin Jin \n ! /// Adobe Systems Incorporated ! /// ! /// This file provides the glue for using GIL independently of ASL. ! /// ! //////////////////////////////////////////////////////////////////////////////////////// ! ! #ifndef NO_ASL ! #include <adobe/config.hpp> #define GIL adobe::gil #define ADOBE_GIL_NAMESPACE_BEGIN namespace adobe { namespace gil { #define ADOBE_GIL_NAMESPACE_END } } + + #include <adobe/functional.hpp> + #include <adobe/algorithm/copy.hpp> + #include <adobe/iterator.hpp> + + #else + + #define GIL gil + #define ADOBE_GIL_NAMESPACE_BEGIN namespace GIL { + #define ADOBE_GIL_NAMESPACE_END } + + #include <functional> + #include <boost/iterator/iterator_adaptor.hpp> + + namespace adobe { + + #if !defined(ADOBE_NO_DOCUMENTATION) + namespace fn { } + using namespace fn; + namespace fn { #endif + //////////////////////////////////////////////////////////////////////////////////////// + /// + /// \brief copy_n taken from SGI STL. + /// + //////////////////////////////////////////////////////////////////////////////////////// + + namespace detail { + template <class InputIter, class Size, class OutputIter> + std::pair<InputIter, OutputIter> _copy_n(InputIter first, Size count, + OutputIter result, + std::input_iterator_tag) { + for ( ; count > 0; --count) { + *result = *first; + ++first; + ++result; + } + return std::pair<InputIter, OutputIter>(first, result); + } + + template <class RAIter, class Size, class OutputIter> + inline std::pair<RAIter, OutputIter> + _copy_n(RAIter first, Size count, OutputIter result, std::random_access_iterator_tag) { + RAIter last = first + count; + return std::pair<RAIter, OutputIter>(last, std::copy(first, last, result)); + } + + template <class InputIter, class Size, class OutputIter> + inline std::pair<InputIter, OutputIter> + _copy_n(InputIter first, Size count, OutputIter result) { + return _copy_n(first, count, result, typename std::iterator_traits<InputIter>::iterator_category()); + } + } + + template <class InputIter, class Size, class OutputIter> + inline std::pair<InputIter, OutputIter> + copy_n(InputIter first, Size count, OutputIter result) { + return detail::_copy_n(first, count, result); + } + + //////////////////////////////////////////////////////////////////////////////////////// + /// + // STEP ITERATOR ADAPTOR + /// \brief step iterator adaptor + /// + /// An adaptor over an existing iterator that changes the step unit + /// (i.e. distance(it,it+1)) by a given predicate. Instead of calling base's + /// operators ++, --, +=, -=, etc. the adaptor is using the passed policy object S_FN + /// for advancing and for computing the distance between iterators. + /// + //////////////////////////////////////////////////////////////////////////////////////// + + template <typename DERIVED, // type of the derived class + typename IT, // Models Iterator + typename S_FN> // A policy object that can compute the distance between two iterators of type IT + // and can advance an iterator of type IT a given number of IT's units + class step_iterator_adaptor : public boost::iterator_adaptor<DERIVED, IT, boost::use_default, boost::use_default, boost::use_default, typename S_FN::difference_type> { + public: + typedef boost::iterator_adaptor<DERIVED, IT, boost::use_default, boost::use_default, boost::use_default, typename S_FN::difference_type> parent_type; + typedef typename std::iterator_traits<IT>::difference_type base_difference_type; + typedef typename S_FN::difference_type difference_type; + typedef typename std::iterator_traits<IT>::reference reference; + + step_iterator_adaptor() {} + step_iterator_adaptor(const IT& it, S_FN step_fn=S_FN()) : parent_type(it), _step_fn(step_fn) {} + + difference_type step() const { return _step_fn.step(); } + + protected: + S_FN _step_fn; + private: + friend class boost::iterator_core_access; + + void increment() { _step_fn.advance(this->base_reference(),1); } + void decrement() { _step_fn.advance(this->base_reference(),-1); } + void advance(base_difference_type d) { _step_fn.advance(this->base_reference(),d); } + difference_type distance_to(const step_iterator_adaptor& it) const { return _step_fn.difference(this->base_reference(),it.base_reference()); } + }; + + // although boost::iterator_adaptor defines these, the default implementation computes distance and compares for zero. + // it is often faster to just apply the relation operator to the base + template <typename D,typename IT,typename S_FN> inline + bool operator>(const step_iterator_adaptor<D,IT,S_FN>& p1, const step_iterator_adaptor<D,IT,S_FN>& p2) { + return p1.step()>0 ? p1.base()> p2.base() : p1.base()< p2.base(); + } + + template <typename D,typename IT,typename S_FN> inline + bool operator<(const step_iterator_adaptor<D,IT,S_FN>& p1, const step_iterator_adaptor<D,IT,S_FN>& p2) { + return p1.step()>0 ? p1.base()< p2.base() : p1.base()> p2.base(); + } + + template <typename D,typename IT,typename S_FN> inline + bool operator>=(const step_iterator_adaptor<D,IT,S_FN>& p1, const step_iterator_adaptor<D,IT,S_FN>& p2) { + return p1.step()>0 ? p1.base()>=p2.base() : p1.base()<=p2.base(); + } + + template <typename D,typename IT,typename S_FN> inline + bool operator<=(const step_iterator_adaptor<D,IT,S_FN>& p1, const step_iterator_adaptor<D,IT,S_FN>& p2) { + return p1.step()>0 ? p1.base()<=p2.base() : p1.base()>=p2.base(); + } + + template <typename D,typename IT,typename S_FN> inline + bool operator==(const step_iterator_adaptor<D,IT,S_FN>& p1, const step_iterator_adaptor<D,IT,S_FN>& p2) { + return p1.base()==p2.base(); + } + + template <typename D,typename IT,typename S_FN> inline + bool operator!=(const step_iterator_adaptor<D,IT,S_FN>& p1, const step_iterator_adaptor<D,IT,S_FN>& p2) { + return p1.base()!=p2.base(); + } + + /*************************************************************************************************/ + + /// \brief plus function object whose arguments may be of different type. + template <typename T1, typename T2> + struct plus_asymmetric : public std::binary_function<T1,T2,T1> + { + T1 operator()(T1 f1, T2 f2) const { + return f1+f2; + } + }; + + /*************************************************************************************************/ + + /// \brief operator++ wrapped in a function object + template <typename T> + struct inc : public std::unary_function<T,T> + { + T operator()(T x) const { return ++x; } + }; + + /*************************************************************************************************/ + + /// \brief operator-- wrapped in a function object + template <typename T> + struct dec : public std::unary_function<T,T> + { + T operator()(T x) const { return --x; } + }; + + + #if !defined(ADOBE_NO_DOCUMENTATION) + } // namespace fn + #endif + + } // namespace adobe + + /*************************************************************************************************/ + + #endif // NO_ASL + #endif Index: variant.hpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/gil/core/variant.hpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** variant.hpp 3 Feb 2006 18:33:37 -0000 1.2 --- variant.hpp 23 Feb 2006 23:28:56 -0000 1.3 *************** *** 23,26 **** --- 23,27 ---- #include "color_convert.hpp" #include "typedefs.hpp" + #include <boost\bind.hpp> ADOBE_GIL_NAMESPACE_BEGIN *************** *** 144,152 **** template <typename T> result_type operator()(const T& t2) { ! return _v1.apply_visitor(gil::bind2nd(_op, t2)); } template <typename T> result_type operator()(T& t2) { ! return _v1.apply_visitor(gil::bind2nd(_op, t2)); } }; --- 145,153 ---- template <typename T> result_type operator()(const T& t2) { ! return _v1.apply_visitor(boost::bind(_op, _1, t2)); } template <typename T> result_type operator()(T& t2) { ! return _v1.apply_visitor(boost::bind(_op, _1, t2)); } }; *************** *** 168,174 **** //#endif template <typename C> inline bool operator==(const variant<C>& x, const variant<C>& y) { ! return x._id==y._id && apply_visitor(x,y,equal_to()); } template <typename C> --- 169,198 ---- //#endif + + namespace detail { + template <bool COMPATIBLE> struct equal_to_fn1 { + template <typename X, typename Y> static bool apply(const X& x, const Y& y) { return x==y; } + }; + + // == invoked on incompatible images or image views + template <> struct equal_to_fn1<false> { + template <typename X, typename Y> static bool apply(const X&, const Y&) { return false; } + }; + + // X and Y must have value_type member typedef that models PixelConcept and operator== that takes type with compatible pixel + // (X and Y are compatible images or image views) + struct equal_to_fn { + typedef bool result_type; + template <typename X, typename Y> result_type operator()(const X& x, const Y& y) const { + return equal_to_fn1<are_pixels_compatible<typename X::value_type, typename Y::value_type>::value>::apply(x,y); + } + }; + } + + // REVISIT: variant's operator== currently works only over images and image views (since it uses are_pixels_compatible on T::value_type). + // Consider extending it to arbitrary concept spaces. template <typename C> inline bool operator==(const variant<C>& x, const variant<C>& y) { ! return x._id==y._id && apply_visitor(x,y,detail::equal_to_fn()); } template <typename C> Index: rgba.hpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/gil/core/rgba.hpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** rgba.hpp 3 Feb 2006 18:33:37 -0000 1.2 --- rgba.hpp 23 Feb 2006 23:28:56 -0000 1.3 *************** *** 93,99 **** /// from raw data planar_ptr(unsigned char* data, ptrdiff_t step=1) : parent_type((T*)data, (T*)(data+step), (T*)(data+step+step), (T*)(data+step*3)) {} ! ! planar_ptr(const planar_ptr& ptr) : parent_type(ptr) {} ! planar_ptr& operator=(const planar_ptr& ptr) { this->p=ptr.p; return *this; } /// Copy constructor and operator= from pointers to compatible planar pixels or planar pixel references. --- 93,99 ---- /// from raw data planar_ptr(unsigned char* data, ptrdiff_t step=1) : parent_type((T*)data, (T*)(data+step), (T*)(data+step+step), (T*)(data+step*3)) {} ! ! template <typename T1,typename C1> planar_ptr(const planar_ptr<T1,C1>& ptr) : parent_type(ptr) {} ! template <typename T1,typename C1> planar_ptr& operator=(const planar_ptr<T1,C1>& ptr) { this->p=ptr.p; return *this; } /// Copy constructor and operator= from pointers to compatible planar pixels or planar pixel references. Index: lab.hpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/gil/core/lab.hpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** lab.hpp 3 Feb 2006 18:33:37 -0000 1.2 --- lab.hpp 23 Feb 2006 23:28:56 -0000 1.3 *************** *** 90,95 **** planar_ptr(unsigned char* data, ptrdiff_t step=1) : parent_type((T*)data, (T*)(data+step), (T*)(data+step+step)) {} ! planar_ptr(const planar_ptr& ptr) : parent_type(ptr) {} ! planar_ptr& operator=(const planar_ptr& ptr) { this->p=ptr.p; return *this; } /// Copy constructor and operator= from pointers to compatible planar pixels or planar pixel references. --- 90,95 ---- planar_ptr(unsigned char* data, ptrdiff_t step=1) : parent_type((T*)data, (T*)(data+step), (T*)(data+step+step)) {} ! template <typename T1,typename C1> planar_ptr(const planar_ptr<T1,C1>& ptr) : parent_type(ptr) {} ! template <typename T1,typename C1> planar_ptr& operator=(const planar_ptr<T1,C1>& ptr) { this->p=ptr.p; return *this; } /// Copy constructor and operator= from pointers to compatible planar pixels or planar pixel references. Index: rgb.hpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/gil/core/rgb.hpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** rgb.hpp 3 Feb 2006 18:33:37 -0000 1.2 --- rgb.hpp 23 Feb 2006 23:28:56 -0000 1.3 *************** *** 123,128 **** planar_ptr(unsigned char* data, ptrdiff_t step=1) : parent_type((T*)data, (T*)(data+step), (T*)(data+step+step)) {} ! planar_ptr(const planar_ptr& ptr) : parent_type(ptr) {} ! planar_ptr& operator=(const planar_ptr& ptr) { this->p=ptr.p; return *this; } /// Copy constructor and operator= from pointers to compatible planar pixels or planar pixel references. --- 123,128 ---- planar_ptr(unsigned char* data, ptrdiff_t step=1) : parent_type((T*)data, (T*)(data+step), (T*)(data+step+step)) {} ! template <typename T1,typename C1> planar_ptr(const planar_ptr<T1,C1>& ptr) : parent_type(ptr) {} ! template <typename T1,typename C1> planar_ptr& operator=(const planar_ptr<T1,C1>& ptr) { this->p=ptr.p; return *this; } /// Copy constructor and operator= from pointers to compatible planar pixels or planar pixel references. Index: pixel_iterator.hpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/gil/core/pixel_iterator.hpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pixel_iterator.hpp 3 Feb 2006 18:33:37 -0000 1.3 --- pixel_iterator.hpp 23 Feb 2006 23:28:56 -0000 1.4 *************** *** 28,31 **** --- 28,69 ---- //////////////////////////////////////////////////////////////////////////////////////// + /// \addtogroup Iterators + /// + /// Immutable interleaved pixel iterator + /// + /// MODELS: PixelIteratorAdaptorConcept + /// + /// Normally pixel iterator classes can model both mutable and immutable iterators, + /// depending on whether they are instantiated with mutable or immutable value types. + /// The only exception is interleaved pixel iterator, which is not a class but a raw C pointer. + /// The mutable interleaved pixel iterator is "pixel<T,CS>*" + /// The immutable equivalent would be "pixel<const T,CS>*". This _almost_ works. The only problem + /// is that there is no automatic conversion from pixel<T,CS>* to pixel<const T,CS>*. Providing such + /// conversion forces us to wrap the immutable pixel iterator into the adaptor class below + /// + //////////////////////////////////////////////////////////////////////////////////////// + + template <typename T, typename C> // Models Pixel Iterator + struct const_interleaved_pixel_iterator : public boost::iterator_adaptor<const_interleaved_pixel_iterator<T,C>, pixel<typename channel_traits<T>::const_value_type,C>*> { + typedef boost::iterator_adaptor<const_interleaved_pixel_iterator<T,C>, pixel<typename channel_traits<T>::const_value_type,C>*> parent_type; + typedef pixel<typename channel_traits<T>::const_value_type,C>* base_type; + typedef pixel<typename channel_traits<T>::value_type,C>* mutable_type; + typedef typename parent_type::difference_type difference_type; + typedef typename parent_type::reference reference; + + const_interleaved_pixel_iterator() {} + const_interleaved_pixel_iterator(const const_interleaved_pixel_iterator& it) : parent_type(it) {} + const_interleaved_pixel_iterator(base_type it) : parent_type(it) {} + const_interleaved_pixel_iterator(mutable_type it) : parent_type(reinterpret_cast<base_type>(it)) {} // constructing immutable from mutable + + /// For some reason operator[] provided by boost::iterator_facade returns a custom class that is convertible to reference + /// We require our own reference because it is registered in iterator_traits + reference operator[](difference_type d) const { return *(*this+d);} + + base_type& base() { return this->base_reference(); } + const base_type& base() const { return this->base_reference(); } + }; + + //////////////////////////////////////////////////////////////////////////////////////// /// \addtogroup PlanarPtr /// *************** *** 69,75 **** friend class boost::iterator_core_access; ! void increment() { per_channel_set_op(inc<T*>(),p,p); } ! void decrement() { per_channel_set_op(dec<T*>(),p,p); } ! void advance(ptrdiff_t d) { per_channel_set_op(std::bind2nd(plus<T*,ptrdiff_t>(),d),p,p); } ptrdiff_t distance_to(const planar_ptr_base& it) const { return it.p[0]-p[0]; } --- 107,113 ---- friend class boost::iterator_core_access; ! void increment() { per_channel_set_op(adobe::inc<T*>(),p,p); } ! void decrement() { per_channel_set_op(adobe::dec<T*>(),p,p); } ! void advance(ptrdiff_t d) { per_channel_set_op(std::bind2nd(adobe::plus_asymmetric<T*,ptrdiff_t>(),d),p,p); } ptrdiff_t distance_to(const planar_ptr_base& it) const { return it.p[0]-p[0]; } *************** *** 96,99 **** --- 134,141 ---- ///@ingroup byte_step template <typename T, typename C> + inline ptrdiff_t byte_step(const const_interleaved_pixel_iterator<T,C>& p) { return sizeof(pixel<T,C>); } + + ///@ingroup byte_step + template <typename T, typename C> inline ptrdiff_t byte_step(const planar_ptr<T,C>&) { return sizeof(T); } *************** *** 111,114 **** --- 153,162 ---- /// @ingroup byte_distance template <typename T, typename C> + inline ptrdiff_t byte_distance(const const_interleaved_pixel_iterator<T,C>& p1, const const_interleaved_pixel_iterator<T,C>& p2) { + return byte_distance(p1.base(), p2.base()); + } + + /// @ingroup byte_distance + template <typename T, typename C> inline ptrdiff_t byte_distance(const planar_ptr<T,C>& p1, const planar_ptr<T,C>& p2) { return byte_distance(p1.p[0],p2.p[0]); *************** *** 128,131 **** --- 176,185 ---- /// @ingroup byte_advance + template <typename T, typename C> + inline void byte_advance(const_interleaved_pixel_iterator<T,C> &p, ptrdiff_t byteDiff) { + byte_advance(p.base(), byteDiff); + } + + /// @ingroup byte_advance template <typename P> struct byte_advance_fn { *************** *** 154,157 **** --- 208,217 ---- /// @ingroup byte_advanced template <typename T, typename C> + inline const_interleaved_pixel_iterator<T,C> byte_advanced(const const_interleaved_pixel_iterator<T,C>& p, ptrdiff_t byteDiff) { + return const_interleaved_pixel_iterator<T,C>(byte_advanced(p.base(),byteDiff)); + } + + /// @ingroup byte_advanced + template <typename T, typename C> inline planar_ptr<T,C> byte_advanced(const planar_ptr<T,C>& p, ptrdiff_t byteDiff) { planar_ptr<T,C> ret=p; *************** *** 173,176 **** --- 233,242 ---- } + ///@ingroup byte_advanced_ref + template <typename T, typename C> + inline pixel<typename channel_traits<T>::const_value_type,C>& byte_advanced_ref(const const_interleaved_pixel_iterator<T,C>& p, ptrdiff_t byteDiff) { + return *byte_advanced(p.base(),byteDiff); + } + template <typename I> class pixel_step_iterator; *************** *** 216,224 **** template <typename IT> ! class pixel_step_iterator : public step_iterator_adaptor<pixel_step_iterator<IT>, IT, byte_step_fn<IT> > { GIL_CLASS_REQUIRE(IT, GIL, ByteAdvancableIteratorConcept); GIL_CLASS_REQUIRE(IT, GIL, PixelIteratorConcept); public: ! typedef step_iterator_adaptor<pixel_step_iterator<IT>, IT, byte_step_fn<IT> > parent_type; typedef typename parent_type::reference reference; typedef typename parent_type::difference_type difference_type; --- 282,290 ---- template <typename IT> ! class pixel_step_iterator : public adobe::step_iterator_adaptor<pixel_step_iterator<IT>, IT, byte_step_fn<IT> > { GIL_CLASS_REQUIRE(IT, GIL, ByteAdvancableIteratorConcept); GIL_CLASS_REQUIRE(IT, GIL, PixelIteratorConcept); public: ! typedef adobe::step_iterator_adaptor<pixel_step_iterator<IT>, IT, byte_step_fn<IT> > parent_type; typedef typename parent_type::reference reference; typedef typename parent_type::difference_type difference_type; *************** *** 472,477 **** --- 538,545 ---- pixel_image_iterator(const LOC2& p, int width, int x=0) : _x(x), _width(width), _p(p) {} pixel_image_iterator(const pixel_image_iterator& pit) : _x(pit._x), _width(pit._width), _p(pit._p) {} + template <typename LOC> pixel_image_iterator(const pixel_image_iterator<LOC>& pit) : _x(pit._x), _width(pit._width), _p(pit._p) {} private: + template <typename LOC> friend class pixel_image_iterator; friend class boost::iterator_core_access; reference dereference() const { return *_p; } *************** *** 547,551 **** dereference_iterator_adaptor() {} dereference_iterator_adaptor(IT it, D_FN deref_fn=D_FN()) : parent_type(it), _deref_fn(deref_fn) {} ! /// For some reason operator[] provided by boost::iterator_facade returns a custom class that is convertible to reference /// We require our own reference because it is registered in iterator_traits --- 615,619 ---- dereference_iterator_adaptor() {} dereference_iterator_adaptor(IT it, D_FN deref_fn=D_FN()) : parent_type(it), _deref_fn(deref_fn) {} ! template <typename IT1, typename DFN1> dereference_iterator_adaptor(const dereference_iterator_adaptor<IT1,DFN1>& it) : parent_type(it.base()), _deref_fn(it._deref_fn) {} /// For some reason operator[] provided by boost::iterator_facade returns a custom class that is convertible to reference /// We require our own reference because it is registered in iterator_traits *************** *** 564,567 **** --- 632,636 ---- const IT& base() const { return this->base_reference(); } private: + template <typename IT1, typename DFN1> friend class dereference_iterator_adaptor; friend class boost::iterator_core_access; *************** *** 646,653 **** typedef value_type* pointer; typedef GIL::pixel_step_iterator<GIL::pixel<T,C>*> dynamic_step_type; ! typedef GIL::pixel<typename GIL::channel_traits<T>::const_value_type,C>* const_type; BOOST_STATIC_CONSTANT(bool, is_planar=false); }; /// \brief Planar pixels use special proxy classes for pointers and references template <typename T, typename C> --- 715,738 ---- typedef value_type* pointer; typedef GIL::pixel_step_iterator<GIL::pixel<T,C>*> dynamic_step_type; ! typedef GIL::const_interleaved_pixel_iterator<T,C> const_type; BOOST_STATIC_CONSTANT(bool, is_planar=false); }; + /// \brief Pterator over immutable interleaved pixels + template <typename T, typename C> + struct iterator_traits<GIL::const_interleaved_pixel_iterator<T,C> > : public iterator_traits_base<typename GIL::channel_traits<T>::const_value_type,C> { + typedef typename GIL::channel_traits<T>::const_value_type channel_type; + typedef GIL::pixel<channel_type,C> value_type; + typedef value_type& reference; + typedef reference const_reference; + typedef GIL::const_interleaved_pixel_iterator<T,C> pointer; + typedef GIL::pixel_step_iterator<value_type*> dynamic_step_type; + typedef pointer const_type; + BOOST_STATIC_CONSTANT(bool, is_planar=false); + BOOST_STATIC_CONSTANT(bool, is_base=false); + typedef value_type* base_type; + typedef dynamic_step_type dynamic_step_base_type; + }; + /// \brief Planar pixels use special proxy classes for pointers and references template <typename T, typename C> *************** *** 665,681 **** struct iterator_traits<GIL::pixel<T&,C>*> : public iterator_traits<GIL::planar_ptr<T,C> >{}; ! template <typename DERIVED,typename BASE,typename S_FN> ! struct iterator_traits<GIL::step_iterator_adaptor<DERIVED,BASE,S_FN> > : public iterator_traits<BASE> { ! typedef typename S_FN::difference_type difference_type; ! BOOST_STATIC_CONSTANT(bool, is_base=false); ! typedef BASE base_type; ! }; ! ! template <typename IT> ! struct iterator_traits<GIL::pixel_step_iterator<IT> > : public iterator_traits<typename GIL::pixel_step_iterator<IT>::parent_type> { ! typedef GIL::pixel_step_iterator<typename std::iterator_traits<IT>::const_type> const_type; BOOST_STATIC_CONSTANT(bool, is_base=false); typedef IT base_type; - typedef GIL::pixel_step_iterator<typename std::iterator_traits<IT>::dynamic_step_type> dynamic_step_base_type; }; --- 750,760 ---- struct iterator_traits<GIL::pixel<T&,C>*> : public iterator_traits<GIL::planar_ptr<T,C> >{}; ! template <typename IT> ! struct iterator_traits<GIL::pixel_step_iterator<IT> > : public iterator_traits<IT> { ! typedef GIL::pixel_step_iterator<typename std::iterator_traits<IT>::const_type> const_type; ! typedef typename GIL::pixel_step_iterator<IT>::difference_type difference_type; ! typedef GIL::pixel_step_iterator<typename std::iterator_traits<IT>::dynamic_step_type> dynamic_step_base_type; BOOST_STATIC_CONSTANT(bool, is_base=false); typedef IT base_type; }; *************** *** 691,702 **** typedef typename D_FN::value_type value_type; typedef typename D_FN::const_reference const_reference; ! typedef typename D_FN::pointer pointer; ! typedef typename D_FN::const_pointer const_type; ! typedef typename std::iterator_traits<pointer>::channel_type channel_type; ! typedef typename std::iterator_traits<pointer>::color_space_type color_space_type; BOOST_STATIC_CONSTANT(bool, is_base=false); BOOST_STATIC_CONSTANT(bool, pixel_data_is_real=false); typedef I base_type; ! typedef GIL::dereference_iterator_adaptor<typename iterator_traits<I>::dynamic_step_type,D_FN> dynamic_step_base_type; typedef dynamic_step_base_type dynamic_step_type; }; --- 770,781 ---- typedef typename D_FN::value_type value_type; typedef typename D_FN::const_reference const_reference; ! typedef typename GIL::dereference_iterator_adaptor<I,D_FN> pointer; ! typedef typename GIL::dereference_iterator_adaptor<typename std::iterator_traits<I>::const_type,D_FN> const_type; ! typedef typename value_type::channel_type channel_type; ! typedef typename value_type::color_space_type color_space_type; BOOST_STATIC_CONSTANT(bool, is_base=false); BOOST_STATIC_CONSTANT(bool, pixel_data_is_real=false); typedef I base_type; ! typedef GIL::dereference_iterator_adaptor<typename std::iterator_traits<I>::dynamic_step_type,D_FN> dynamic_step_base_type; typedef dynamic_step_base_type dynamic_step_type; }; Index: gil_concept.hpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/gil/core/gil_concept.hpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** gil_concept.hpp 3 Feb 2006 18:33:37 -0000 1.3 --- gil_concept.hpp 23 Feb 2006 23:28:56 -0000 1.4 *************** *** 366,369 **** --- 366,371 ---- typedef typename std::iterator_traits<IT>::const_type const_type; + const_type const_it(it); // immutable iterator must be constructible from (possibly mutable) iterator + static const bool ib=std::iterator_traits<IT>::is_base; boost::ignore_unused_variable_warning(ib); static const bool ip=std::iterator_traits<IT>::is_planar; boost::ignore_unused_variable_warning(ip); Index: utilities.hpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/gil/core/utilities.hpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** utilities.hpp 3 Feb 2006 18:33:37 -0000 1.2 --- utilities.hpp 23 Feb 2006 23:28:56 -0000 1.3 *************** *** 14,18 **** #include <cmath> #include <cstddef> - #include <boost/iterator/iterator_adaptor.hpp> //////////////////////////////////////////////////////////////////////////////////////// --- 14,17 ---- *************** *** 49,68 **** const point2& operator=(const point2& p) { x=p.x; y=p.y; return *this; } - bool operator==(const point2& p) const { return (p.x==x && p.y==y); } - bool operator!=(const point2& p) const { return p.x!=x || p.y!=y; } ! point2 operator+(const point2& p) const { return point2(x+p.x,y+p.y);} ! point2 operator-(const point2& p) const { return point2(x-p.x,y-p.y);} ! T operator*(const point2& p) const { return x*p.x + y*p.y; } ! point2<double> operator*(double t) const { return point2<double>(x*t,y*t); } ! point2 operator*(int t) const { return point2(x*t,y*t); } ! point2<double> operator/(double t) const { return t==0 ? point2<double>(0,0):point2<double>(x/t,y/t); } ! template <typename T1> point2<double> operator/(const point2<T1>& p) const { return point2<double>(x/(double)p.x,y/(double)p.y); } ! point2 operator<<(int shift) const { return point2(x<<shift,y<<shift); } ! point2 operator>>(int shift) const { return point2(x>>shift,y>>shift); } const point2& operator+=(const point2& p) { x+=p.x; y+=p.y; return *this; } const point2& operator-=(const point2& p) { x-=p.x; y-=p.y; return *this; } const point2& operator/=(double t) { x/=t; y/=t; return *this; } ! const point2 operator-() const { return point2<T>(-x,-y); } const T& operator[](std::size_t i) const { return (reinterpret_cast<const T*>(&x))[i]; } --- 48,58 ---- const point2& operator=(const point2& p) { x=p.x; y=p.y; return *this; } ! point2 operator<<(int shift) const { return point2(x<<shift,y<<shift); } ! point2 operator>>(int shift) const { return point2(x>>shift,y>>shift); } const point2& operator+=(const point2& p) { x+=p.x; y+=p.y; return *this; } const point2& operator-=(const point2& p) { x-=p.x; y-=p.y; return *this; } const point2& operator/=(double t) { x/=t; y/=t; return *this; } ! point2 operator-() const { return point2<T>(-x,-y); } const T& operator[](std::size_t i) const { return (reinterpret_cast<const T*>(&x))[i]; } *************** *** 72,284 **** }; ! template <typename T> std::ostream& operator<<(const point2<T>& p, std::ostream& os) { os << p.x<<" "<<p.y<<" "; return os; } ! template <typename T> std::istream& operator>>( point2<T>& p, std::istream& is) { is >> p.x >> p.y; return is; } ! ! template <typename T> std::ostream& operator<<(std::ostream& os, const point2<T>& p) { return p<<os; } ! template <typename T> std::istream& operator>>(std::istream& is, point2<T>& p) { return p>>is; } ! ! template <typename T> inline T dist_sqrd(const point2<T>& p) { return p.x*p.x + p.y*p.y; } ! template <typename T> inline T dist(const point2<T>& p) { return sqrt(dist_sqrd(p)); } ! ! template <typename T> inline T dist_sqrd(const point2<T>& p1, const point2<T>& p2) { return (p1.x-p2.x)*(p1.x-p2.x) + (p1.y-p2.y)*(p1.y-p2.y); } ! template <typename T> inline T dist(const point2<T>& p1, const point2<T>& p2) { return sqrt(dist_sqrd(p1,p2)); } ! ! ! template <typename FLOAT> inline int round (FLOAT x) { return x>=0 ? int(x+0.5) : int(x-0.5); } ! template <typename FLOAT> inline int round_up (FLOAT x) { int intX=int(x); return (x<=intX) ? intX : intX+1; } ! template <typename FLOAT> inline int round_down(FLOAT x) { int intX=int(x); return (x>=intX) ? intX : intX-1; } ! template <typename FLOAT> inline point2<int> round (const point2<FLOAT>& p) { return point2<int>(round (p.x),round (p.y)); } ! template <typename FLOAT> inline point2<int> round_up (const point2<FLOAT>& p) { return point2<int>(round_up (p.x),round_up (p.y)); } ! template <typename FLOAT> inline point2<int> round_down(const point2<FLOAT>& p) { return point2<int>(round_down(p.x),round_down(p.y)); } ! ! //////////////////////////////////////////////////////////////////////////////////////// ! /// ! /// computing size with alignment ! /// ! //////////////////////////////////////////////////////////////////////////////////////// ! ! template <typename T> inline T get_aligned(T val, int align) { return val+(align - val%align)%align; } ! ! ! /// \brief plus function object whose arguments may be of different type. ! template <typename T1, typename T2> ! struct plus : public std::binary_function<T1,T2,T1> { ! T1 operator()(T1 f1, T2 f2) const { ! return f1+f2; ! } ! }; ! ! /// \brief operator++ wrapped in a function object ! template <typename T> ! struct inc : public std::unary_function<T,T> { ! T operator()(T x) const { return ++x; } ! }; ! ! /// \brief operator-- wrapped in a function object ! template <typename T> ! struct dec : public std::unary_function<T,T> { ! T operator()(T x) const { return --x; } ! }; ! ! // \brief similar to std::equal_to<T> but both arguments are allowed to have different types (as long as they are equality-comparable) ! // and the types are bound upon application, not upon definition. ! struct equal_to { ! typedef bool result_type; ! ! template <typename X, typename Y> ! result_type operator()(const X& x, const Y& y) const { return x==y; } ! }; ! ! //////////////////////////////////////////////////////////////////////////////////////// ! /// ! /// \brief copy_n taken from SGI STL. ! /// ! //////////////////////////////////////////////////////////////////////////////////////// ! ! template <class _InputIter, class _Size, class _OutputIter> ! std::pair<_InputIter, _OutputIter> __copy_n(_InputIter __first, _Size __count, ! _OutputIter __result, ! std::input_iterator_tag) { ! for ( ; __count > 0; --__count) { ! *__result = *__first; ! ++__first; ! ++__result; ! } ! return std::pair<_InputIter, _OutputIter>(__first, __result); ! } ! ! template <class _RAIter, class _Size, class _OutputIter> ! inline std::pair<_RAIter, _OutputIter> ! __copy_n(_RAIter __first, _Size __count, ! _OutputIter __result, ! std::random_access_iterator_tag) { ! _RAIter __last = __first + __count; ! return std::pair<_RAIter, _OutputIter>(__last, std::copy(__first, __last, __result)); ! } ! ! template <class _Iter> ! inline typename std::iterator_traits<_Iter>::iterator_category ! ___iterator_category(const _Iter&) ! { ! typedef typename std::iterator_traits<_Iter>::iterator_category _Category; ! return _Category(); ! } ! ! template <class _InputIter, class _Size, class _OutputIter> ! inline std::pair<_InputIter, _OutputIter> ! __copy_n(_InputIter __first, _Size __count, _OutputIter __result) { ! return __copy_n(__first, __count, __result, ! ___iterator_category(__first)); ! } ! ! template <class _InputIter, class _Size, class _OutputIter> ! inline std::pair<_InputIter, _OutputIter> ! copy_n(_InputIter __first, _Size __count, _OutputIter __result) { ! return __copy_n(__first, __count, __result); ! } //////////////////////////////////////////////////////////////////////////////////////// /// ! /// \brief unary_compose taken from SGI STL. /// //////////////////////////////////////////////////////////////////////////////////////// - template <class OP1, class OP2> - class unary_compose : public std::unary_function<typename OP2::argument_type, typename OP1::result_type> { - protected: - OP1 _M_fn1; - OP2 _M_fn2; - public: - unary_compose(){} // Added a default constructor (missing from SGI's STL) - unary_compose(const OP1& __x, const OP2& __y) : _M_fn1(__x), _M_fn2(__y) {} - typename OP1::result_type operator()(const typename OP2::argument_type& __x) const { return _M_fn1(_M_fn2(__x)); } - }; - - /// \brief similar to std::binder2nd but the parameter types are specified in the application operator (not in the class declaration) - template<typename BIN_FN, typename RIGHT> class binder2nd { - public: - typedef typename BIN_FN::result_type result_type; - - binder2nd(const BIN_FN& bin_op, const RIGHT& right) : _bin_op(bin_op), _right(right) {} - - template <typename LEFT> - result_type operator()(const LEFT& left) const { return _bin_op(left, _right); } - - protected: - BIN_FN _bin_op; // the functor to apply - RIGHT _right; // the right operand - }; - - // \brief helper function for binder2nd - template<typename BIN_FN, typename RIGHT> inline binder2nd<BIN_FN,RIGHT> bind2nd(const BIN_FN& bin_fn, const RIGHT& right) { - return binder2nd<BIN_FN,RIGHT>(bin_fn, right); - } - - /// \brief similar to std::binder1st but the parameter types are specified in the application operator (not in the class declaration) - template<typename BIN_FN, typename LEFT> class binder1st { - public: - typedef typename BIN_FN::result_type result_type; - - binder1st(const BIN_FN& bin_op, const LEFT& left) : _bin_op(bin_op), _left(left) {} - - template <typename RIGHT> - result_type operator()(const RIGHT& right) const { return _bin_op(_left, right); } - - protected: - BIN_FN _bin_op; // the functor to apply - LEFT _left; // the left operand - }; ! // \brief helper function for binder1st ! template<typename BIN_FN, typename LEFT> inline binder1st<BIN_FN,LEFT> bind1st(const BIN_FN& bin_fn, const LEFT& left) { ! return binder1st<BIN_FN,LEFT>(bin_fn, left); ! } //////////////////////////////////////////////////////////////////////////////////////// - /// - // STEP ITERATOR ADAPTOR - /// \brief step iterator adaptor /// ! /// An adaptor over an existing iterator that changes the step unit ! /// (i.e. distance(it,it+1)) by a given predicate. Instead of calling base's ! /// operators ++, --, +=, -=, etc. the adaptor is using the passed policy object S_FN ! /// for advancing and for computing the distance between iterators. /// //////////////////////////////////////////////////////////////////////////////////////// ! template <typename DERIVED, // type of the derived class ! typename IT, // Models Iterator ! typename S_FN> // A policy object that can compute the distance between two iterators of type IT ! // and can advance an iterator of type IT a given number of IT's units ! class step_iterator_adaptor : public boost::iterator_adaptor<DERIVED, IT, boost::use_default, boost::use_default, boost::use_default, typename S_FN::difference_type> { ! public: ! typedef boost::iterator_adaptor<DERIVED, IT, boost::use_default, boost::use_default, boost::use_default, typename S_FN::difference_type> parent_type; ! typedef typename std::iterator_traits<IT>::difference_type base_difference_type; ! typedef typename S_FN::difference_type difference_type; ! typedef typename std::iterator_traits<IT>::reference reference; ! ! step_iterator_adaptor() {} ! step_iterator_adaptor(const IT& it, S_FN step_fn=S_FN()) : parent_type(it), _step_fn(step_fn) {} ! ! difference_type step() const { return _step_fn.step(); } ! ! // although boost::iterator_adaptor defines these, the default implementation computes distance and compares for zero. ! // it is often faster to just apply the relation operator to the base ! bool operator> (const step_iterator_adaptor& p) const { return step()>0 ? this->base_reference()> p.base_reference() : this->base_reference()< p.base_reference(); } ! bool operator< (const step_iterator_adaptor& p) const { return step()>0 ? this->base_reference()< p.base_reference() : this->base_reference()> p.base_reference(); } ! bool operator>=(const step_iterator_adaptor& p) const { return step()>0 ? this->base_reference()>=p.base_reference() : this->base_reference()<=p.base_reference(); } ! bool operator<=(const step_iterator_adaptor& p) const { return step()>0 ? this->base_reference()<=p.base_reference() : this->base_reference()>=p.base_reference(); } ! bool operator==(const step_iterator_adaptor& p) const { return this->base_reference()==p.base_reference(); } ! bool operator!=(const step_iterator_adaptor& p) const { return this->base_reference()!=p.base_reference(); } ! protected: ! S_FN _step_fn; ! private: ! friend class boost::iterator_core_access; - void increment() { _step_fn.advance(this->base_reference(),1); } - void decrement() { _step_fn.advance(this->base_reference(),-1); } - void advance(base_difference_type d) { _step_fn.advance(this->base_reference(),d); } - difference_type distance_to(const step_iterator_adaptor& it) const { return _step_fn.difference(this->base_reference(),it.base_reference()); } - }; --- 62,108 ---- }; ! template <typename T> inline ! bool operator==(const point2<T>& p1, const point2<T>& p2) { return (p1.x==p2.x && p1.y==p2.y); } ! template <typename T> inline ! bool operator!=(const point2<T>& p1, const point2<T>& p2) { return p1.x!=p2.x || p1.y!=p2.y; } ! template <typename T> inline ! point2<T> operator+(const point2<T>& p1, const point2<T>& p2) { return point2<T>(p1.x+p2.x,p1.y+p2.y); } ! template <typename T> inline ! point2<T> operator-(const point2<T>& p1, const point2<T>& p2) { return point2<T>(p1.x-p2.x,p1.y-p2.y); } ! template <typename T> inline ! T operator*(const point2<T>& p1, const point2<T>& p2) { return p1.x*p2.x + p1.y*p2.y; } ! template <typename T> inline ! point2<double> operator/(const point2<T>& p, double t) { return t==0 ? point2<double>(0,0):point2<double>(p.x/t,p.y/t); } ! template <typename T> inline ! point2<double> operator*(const point2<T>& p, double t) { return point2<double>(p.x*t,p.y*t); } //////////////////////////////////////////////////////////////////////////////////////// /// ! /// Rounding of real numbers / points to integers / integer points /// //////////////////////////////////////////////////////////////////////////////////////// ! inline int iround(float x ) { return static_cast<int>(x + (x < 0.0f ? -0.5f : 0.5f)); } ! inline int iround(double x) { return static_cast<int>(x + (x < 0.0 ? -0.5 : 0.5)); } ! inline int ifloor(float x ) { return static_cast<int>(std::floor(x)); } ! inline int ifloor(double x) { return static_cast<int>(std::floor(x)); } ! inline int iceil(float x ) { return static_cast<int>(std::ceil(x)); } ! inline int iceil(double x) { return static_cast<int>(std::ceil(x)); } + inline point2<int> iround(const point2<float >& p) { return point2<int>(iround(p.x),iround(p.y)); } + inline point2<int> iround(const point2<double>& p) { return point2<int>(iround(p.x),iround(p.y)); } + inline point2<int> ifloor(const point2<float >& p) { return point2<int>(ifloor(p.x),ifloor(p.y)); } + inline point2<int> ifloor(const point2<double>& p) { return point2<int>(ifloor(p.x),ifloor(p.y)); } + inline point2<int> iceil (const point2<float >& p) { return point2<int>(iceil(p.x), iceil(p.y)); } + inline point2<int> iceil (const point2<double>& p) { return point2<int>(iceil(p.x), iceil(p.y)); } //////////////////////////////////////////////////////////////////////////////////////// /// ! /// computing size with alignment /// //////////////////////////////////////////////////////////////////////////////////////// ! template <typename T> inline T align(T val, int alignment) { return val+(alignment - val%alignment)%alignment; } Index: typedefs.hpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/gil/core/typedefs.hpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** typedefs.hpp 3 Feb 2006 18:33:37 -0000 1.3 --- typedefs.hpp 23 Feb 2006 23:28:56 -0000 1.4 *************** *** 35,38 **** --- 35,39 ---- struct cmyk_tag; template <typename T, typename C> struct pixel; + template <typename T, typename C> struct const_interleaved_pixel_iterator; template <typename T, typename C> struct planar_ref; template <typename T, typename C> struct planar_ptr; *************** *** 186,207 **** typedef cmyk32_pixel* cmyk32_ptr; ! typedef gray8c_pixel* gray8c_ptr; ! typedef gray16c_pixel* gray16c_ptr; ! typedef gray32c_pixel* gray32c_ptr; ! typedef rgb8c_pixel* rgb8c_ptr; ! typedef rgb16c_pixel* rgb16c_ptr; ! typedef rgb32c_pixel* rgb32c_ptr; ! typedef bgr8c_pixel* bgr8c_ptr; ! typedef bgr16c_pixel* bgr16c_ptr; ! typedef bgr32c_pixel* bgr32c_ptr; ! typedef rgba8c_pixel * rgba8c_ptr; ! typedef rgba16c_pixel* rgba16c_ptr; ! typedef rgba32c_pixel* rgba32c_ptr; ! typedef lab8c_pixel* lab8c_ptr; ! typedef lab16c_pixel* lab16c_ptr; ! typedef lab32c_pixel* lab32c_ptr; ! typedef cmyk8c_pixel* cmyk8c_ptr; ! typedef cmyk16c_pixel* cmyk16c_ptr; ! typedef cmyk32c_pixel* cmyk32c_ptr; // planar pixel pointers --- 187,208 ---- typedef cmyk32_pixel* cmyk32_ptr; ! typedef const_interleaved_pixel_iterator<bits8 , gray_tag> gray8c_ptr; ! typedef const_interleaved_pixel_iterator<bits16, gray_tag> gray16c_ptr; ! typedef const_interleaved_pixel_iterator<bits32, gray_tag> gray32c_ptr; ! typedef const_interleaved_pixel_iterator<bits8 , rgb_tag> rgb8c_ptr; ! typedef const_interleaved_pixel_iterator<bits16, rgb_tag> rgb16c_ptr; ! typedef const_interleaved_pixel_iterator<bits32, rgb_tag> rgb32c_ptr; ! typedef const_interleaved_pixel_iterator<bits8 , bgr_tag> bgr8c_ptr; ! typedef const_interleaved_pixel_iterator<bits16, bgr_tag> bgr16c_ptr; ! typedef const_interleaved_pixel_iterator<bits32, bgr_tag> bgr32c_ptr; ! typedef const_interleaved_pixel_iterator<bits8 , rgba_tag> rgba8c_ptr; ! typedef const_interleaved_pixel_iterator<bits16, rgba_tag> rgba16c_ptr; ! typedef const_interleaved_pixel_iterator<bits32, rgba_tag> rgba32c_ptr; ! typedef const_interleaved_pixel_iterator<bits8 , lab_tag> lab8c_ptr; ! typedef const_interleaved_pixel_iterator<bits16, lab_tag> lab16c_ptr; ! typedef const_interleaved_pixel_iterator<bits32, lab_tag> lab32c_ptr; ! typedef const_interleaved_pixel_iterator<bits8 , cmyk_tag> cmyk8c_ptr; ! typedef const_interleaved_pixel_iterator<bits16, cmyk_tag> cmyk16c_ptr; ! typedef const_interleaved_pixel_iterator<bits32, cmyk_tag> cmyk32c_ptr; // planar pixel pointers |