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; ty... [truncated message content] |