Index: boost/gil/algorithm.hpp =================================================================== --- boost/gil/algorithm.hpp (revision 83084) +++ boost/gil/algorithm.hpp (working copy) @@ -1,6 +1,6 @@ /* Copyright 2005-2007 Adobe Systems Incorporated - + Use, modification and distribution are subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt). @@ -8,7 +8,6 @@ See http://opensource.adobe.com/gil for most recent version including documentation. */ - /*************************************************************************************************/ #ifndef GIL_ALGORITHM_HPP @@ -34,7 +33,7 @@ #include "bit_aligned_pixel_iterator.hpp" //////////////////////////////////////////////////////////////////////////////////////// -/// \file +/// \file /// \brief Some basic STL-style algorithms when applied to image views /// \author Lubomir Bourdev and Hailin Jin \n /// Adobe Systems Incorporated @@ -48,7 +47,6 @@ //#endif namespace boost { namespace gil { - //forward declarations template struct planar_pixel_iterator; @@ -82,10 +80,9 @@ /// is overloaded to perform \p std::copy for each of the planes. \p std::copy over bitwise-copiable pixels results in /// std::copy over unsigned char, which STL typically implements via \p memmove. /// -/// As a result \p copy_pixels may result in a single call to \p memmove for interleaved 1D-traversable views, +/// As a result \p copy_pixels may result in a single call to \p memmove for interleaved 1D-traversable views, /// or one per each plane of planar 1D-traversable views, or one per each row of interleaved non-1D-traversable images, etc. - /// \defgroup STLOptimizations Performance overloads of STL algorithms /// \ingroup ImageViewAlgorithm /// \brief overloads of STL algorithms allowing more efficient implementation when used with GIL constructs @@ -146,30 +143,29 @@ /// \brief std::copy for image views namespace std { - /// \ingroup STLOptimizations /// \brief Copy when both src and dst are interleaved and of the same type can be just memmove -template -GIL_FORCEINLINE boost::gil::pixel* -copy(boost::gil::pixel* first, boost::gil::pixel* last, - boost::gil::pixel* dst) { +template +GIL_FORCEINLINE boost::gil::pixel* +copy(boost::gil::pixel* first, boost::gil::pixel* last, + boost::gil::pixel* dst) { return (boost::gil::pixel*)std::copy((unsigned char*)first,(unsigned char*)last, (unsigned char*)dst); } /// \ingroup STLOptimizations /// \brief Copy when both src and dst are interleaved and of the same type can be just memmove -template -GIL_FORCEINLINE boost::gil::pixel* -copy(const boost::gil::pixel* first, const boost::gil::pixel* last, - boost::gil::pixel* dst) { +template +GIL_FORCEINLINE boost::gil::pixel* +copy(const boost::gil::pixel* first, const boost::gil::pixel* last, + boost::gil::pixel* dst) { return (boost::gil::pixel*)std::copy((unsigned char*)first,(unsigned char*)last, (unsigned char*)dst); } } // namespace std namespace boost { namespace gil { namespace detail { -template struct copy_fn { - GIL_FORCEINLINE I operator()(I first, I last, O dst) const { return std::copy(first,last,dst); } +template struct copy_fn { + GIL_FORCEINLINE I operator()(I first, I last, O dst) const { return std::copy(first,last,dst); } }; } // namespace detail } } // namespace boost::gil @@ -178,7 +174,7 @@ /// \ingroup STLOptimizations /// \brief Copy when both src and dst are planar pointers is copy for each channel template GIL_FORCEINLINE -boost::gil::planar_pixel_iterator copy(boost::gil::planar_pixel_iterator first, boost::gil::planar_pixel_iterator last, boost::gil::planar_pixel_iterator dst) { +boost::gil::planar_pixel_iterator copy(boost::gil::planar_pixel_iterator first, boost::gil::planar_pixel_iterator last, boost::gil::planar_pixel_iterator dst) { boost::gil::gil_function_requires::value_type,typename std::iterator_traits::value_type> >(); static_for_each(first,last,dst,boost::gil::detail::copy_fn()); return dst+(last-first); @@ -274,7 +270,6 @@ } return dst+n; } - } // namespace detail } } // namespace boost::gil @@ -285,16 +280,13 @@ GIL_FORCEINLINE boost::gil::iterator_from_2d
    copy1(boost::gil::iterator_from_2d first, boost::gil::iterator_from_2d last, boost::gil::iterator_from_2d
      dst) { return boost::gil::detail::copy_with_2d_iterators(first,last,dst); } - } // namespace std namespace boost { namespace gil { - - /// \ingroup ImageViewSTLAlgorithmsCopyPixels /// \brief std::copy for image views template GIL_FORCEINLINE -void copy_pixels(const View1& src, const View2& dst) { +void copy_pixels(const View1& src, const View2& dst) { assert(src.dimensions()==dst.dimensions()); detail::copy_with_2d_iterators(src.begin(),src.end(),dst.begin()); } @@ -321,13 +313,13 @@ copy_and_convert_pixels_fn() {} copy_and_convert_pixels_fn(CC cc_in) : _cc(cc_in) {} // when the two color spaces are incompatible, a color conversion is performed - template GIL_FORCEINLINE + template GIL_FORCEINLINE result_type apply_incompatible(const V1& src, const V2& dst) const { copy_pixels(color_converted_view(src,_cc),dst); } // If the two color spaces are compatible, copy_and_convert is just copy - template GIL_FORCEINLINE + template GIL_FORCEINLINE result_type apply_compatible(const V1& src, const V2& dst) const { copy_pixels(src,dst); } @@ -335,9 +327,9 @@ } // namespace detail /// \ingroup ImageViewSTLAlgorithmsCopyAndConvertPixels -template -GIL_FORCEINLINE -void copy_and_convert_pixels(const V1& src, const V2& dst,CC cc) { +template +GIL_FORCEINLINE +void copy_and_convert_pixels(const V1& src, const V2& dst,CC cc) { detail::copy_and_convert_pixels_fn ccp(cc); ccp(src,dst); } @@ -345,13 +337,12 @@ struct default_color_converter; /// \ingroup ImageViewSTLAlgorithmsCopyAndConvertPixels -template -GIL_FORCEINLINE -void copy_and_convert_pixels(const View1& src, const View2& dst) { +template +GIL_FORCEINLINE +void copy_and_convert_pixels(const View1& src, const View2& dst) { detail::copy_and_convert_pixels_fn ccp; ccp(src,dst); } - } } // namespace boost::gil ////////////////////////////////////////////////////////////////////////////////////// @@ -364,14 +355,13 @@ /// \ingroup ImageViewSTLAlgorithms /// \brief std::fill for image views - namespace std { /// \ingroup STLOptimizations /// \brief std::fill(I,I,V) with I being a iterator_from_2d /// /// Invoked when one calls std::fill(I,I,V) with I being a iterator_from_2d (which is /// a 1D iterator over the pixels in an image). For contiguous images (i.e. images that have -/// no alignment gap at the end of each row) it is more efficient to use the underlying +/// no alignment gap at the end of each row) it is more efficient to use the underlying /// pixel iterator that does not check for the end of rows. For non-contiguous images fill /// resolves to fill of each row using the underlying pixel iterator, which is still faster template @@ -389,11 +379,10 @@ n-=numToDo; } } -} +} } // namespace std namespace boost { namespace gil { - namespace detail { /// struct to do std::fill struct std_fill_t { @@ -404,13 +393,13 @@ }; /// std::fill for planar iterators template -GIL_FORCEINLINE +GIL_FORCEINLINE void fill_aux(It first, It last, const P& p, mpl::true_) { static_for_each(first,last,p,std_fill_t()); } /// std::fill for interleaved iterators template -GIL_FORCEINLINE +GIL_FORCEINLINE void fill_aux(It first, It last, const P& p,mpl::false_) { std::fill(first,last,p); } @@ -418,10 +407,10 @@ /// \ingroup ImageViewSTLAlgorithmsFillPixels /// \brief std::fill for image views -template GIL_FORCEINLINE +template GIL_FORCEINLINE void fill_pixels(const View& img_view, const Value& val) { if (img_view.is_1d_traversable()) - detail::fill_aux(img_view.begin().x(), img_view.end().x(), + detail::fill_aux(img_view.begin().x(), img_view.end().x(), val,is_planar()); else for (std::ptrdiff_t y=0; y GIL_FORCEINLINE void destruct_range_impl( It first , It last @@ -461,14 +448,13 @@ void destruct_range_impl( It , It , typename enable_if< mpl::or_< mpl::not_< is_pointer< It > > - , boost::has_trivial_destructor< typename std::iterator_traits< It >::value_type > + , boost::has_trivial_destructor< typename std::iterator_traits< It >::value_type > > >::type* /* ptr */ = 0) {} template GIL_FORCEINLINE void destruct_range(It first, It last) { - destruct_range_impl( first , last ); @@ -480,25 +466,24 @@ /// destruct for planar iterators template -GIL_FORCEINLINE +GIL_FORCEINLINE void destruct_aux(It first, It last, mpl::true_) { static_for_each(first,last,std_destruct_t()); } /// destruct for interleaved iterators template -GIL_FORCEINLINE +GIL_FORCEINLINE void destruct_aux(It first, It last, mpl::false_) { destruct_range(first,last); } - } // namespace detail /// \ingroup ImageViewSTLAlgorithmsDestructPixels /// \brief Invokes the in-place destructor on every pixel of the view -template GIL_FORCEINLINE +template GIL_FORCEINLINE void destruct_pixels(const View& img_view) { - if (img_view.is_1d_traversable()) - detail::destruct_aux(img_view.begin().x(), img_view.end().x(), + if (img_view.is_1d_traversable()) + detail::destruct_aux(img_view.begin().x(), img_view.end().x(), is_planar()); else for (std::ptrdiff_t y=0; y -GIL_FORCEINLINE +GIL_FORCEINLINE void uninitialized_fill_aux(It first, It last, const P& p, mpl::true_) { int channel=0; try { typedef typename std::iterator_traits::value_type pixel_t; while (channel < num_channels::value) { - std::uninitialized_fill(dynamic_at_c(first,channel), dynamic_at_c(last,channel), + std::uninitialized_fill(dynamic_at_c(first,channel), dynamic_at_c(last,channel), dynamic_at_c(p,channel)); ++channel; } @@ -543,22 +526,21 @@ /// std::uninitialized_fill for interleaved iterators /// If an exception is thrown destructs any in-place copy-constructed objects template -GIL_FORCEINLINE +GIL_FORCEINLINE void uninitialized_fill_aux(It first, It last, const P& p,mpl::false_) { std::uninitialized_fill(first,last,p); } - } // namespace detail /// \ingroup ImageViewSTLAlgorithmsUninitializedFillPixels /// \brief std::uninitialized_fill for image views. /// Does not support planar heterogeneous views. /// If an exception is thrown destructs any in-place copy-constructed pixels -template +template void uninitialized_fill_pixels(const View& img_view, const Value& val) { - if (img_view.is_1d_traversable()) - detail::uninitialized_fill_aux(img_view.begin().x(), img_view.end().x(), + if (img_view.is_1d_traversable()) + detail::uninitialized_fill_aux(img_view.begin().x(), img_view.end().x(), val,is_planar()); else { typename View::y_coord_t y; @@ -585,8 +567,7 @@ /// \brief invokes the default constructor on every pixel of an image view namespace detail { - -template GIL_FORCEINLINE +template GIL_FORCEINLINE void default_construct_range_impl(It first, It last, mpl::true_) { typedef typename std::iterator_traits::value_type value_t; It first1=first; @@ -601,15 +582,15 @@ } } -template GIL_FORCEINLINE +template GIL_FORCEINLINE void default_construct_range_impl(It, It, mpl::false_) {} -template GIL_FORCEINLINE +template GIL_FORCEINLINE void default_construct_range(It first, It last) { default_construct_range_impl(first, last, typename is_pointer::type()); } /// uninitialized_default_construct for planar iterators template -GIL_FORCEINLINE +GIL_FORCEINLINE void default_construct_aux(It first, It last, mpl::true_) { int channel=0; try { @@ -627,7 +608,7 @@ /// uninitialized_default_construct for interleaved iterators template -GIL_FORCEINLINE +GIL_FORCEINLINE void default_construct_aux(It first, It last, mpl::false_) { default_construct_range(first,last); } @@ -636,11 +617,9 @@ struct has_trivial_pixel_constructor : public boost::has_trivial_constructor {}; template struct has_trivial_pixel_constructor : public boost::has_trivial_constructor::type> {}; - } // namespace detail namespace detail { - template< typename View, bool B > GIL_FORCEINLINE void default_construct_pixels_impl( const View& img_view , boost::enable_if< is_same< mpl::bool_< B > @@ -649,7 +628,7 @@ >* /* ptr */ = 0 ) { - if( img_view.is_1d_traversable() ) + if( img_view.is_1d_traversable() ) { detail::default_construct_aux( img_view.begin().x() , img_view.end().x() @@ -681,19 +660,15 @@ throw; } } - } - } // namespace detail - /// \ingroup ImageViewSTLAlgorithmsDefaultConstructPixels /// \brief Invokes the in-place default constructor on every pixel of the (uninitialized) view. /// Does not support planar heterogeneous views. /// If an exception is thrown destructs any in-place default-constructed pixels -template +template void default_construct_pixels(const View& img_view) { - detail::default_construct_pixels_impl< View , detail::has_trivial_pixel_constructor< View , is_planar< View >::value @@ -701,7 +676,6 @@ >( img_view ); } - ////////////////////////////////////////////////////////////////////////////////////// /// /// uninitialized_copy_pixels @@ -713,10 +687,9 @@ /// \brief std::uninitialized_copy for image views namespace detail { - /// std::uninitialized_copy for pairs of planar iterators template -GIL_FORCEINLINE +GIL_FORCEINLINE void uninitialized_copy_aux(It1 first1, It1 last1, It2 first2, mpl::true_) { int channel=0; @@ -736,7 +709,7 @@ } /// std::uninitialized_copy for interleaved or mixed iterators template -GIL_FORCEINLINE +GIL_FORCEINLINE void uninitialized_copy_aux(It1 first1, It1 last1, It2 first2,mpl::false_) { std::uninitialized_copy(first1,last1,first2); @@ -747,13 +720,13 @@ /// \brief std::uninitialized_copy for image views. /// Does not support planar heterogeneous views. /// If an exception is thrown destructs any in-place copy-constructed objects -template +template void uninitialized_copy_pixels(const View1& view1, const View2& view2) { - typedef mpl::bool_::value && is_planar::value> is_planar; + typedef mpl::bool_::value && is_planar::value> is_planar; assert(view1.dimensions()==view2.dimensions()); if (view1.is_1d_traversable() && view2.is_1d_traversable()) - detail::uninitialized_copy_aux(view1.begin().x(), view1.end().x(), - view2.begin().x(), + detail::uninitialized_copy_aux(view1.begin().x(), view1.end().x(), + view2.begin().x(), is_planar()); else { typename View1::y_coord_t y; @@ -780,9 +753,9 @@ /// \ingroup ImageViewSTLAlgorithms /// \brief std::for_each for image views /// -/// For contiguous images (i.e. images that have no alignment gap at the end of each row) it is -/// more efficient to use the underlying pixel iterator that does not check for the end of rows. -/// For non-contiguous images for_each_pixel resolves to for_each of each row using the underlying +/// For contiguous images (i.e. images that have no alignment gap at the end of each row) it is +/// more efficient to use the underlying pixel iterator that does not check for the end of rows. +/// For non-contiguous images for_each_pixel resolves to for_each of each row using the underlying /// pixel iterator, which is still faster /// \ingroup ImageViewSTLAlgorithmsForEachPixel @@ -813,7 +786,6 @@ return fun; } - ////////////////////////////////////////////////////////////////////////////////////// /// /// generate_pixels @@ -849,17 +821,16 @@ template GIL_FORCEINLINE bool equal_n(I1 i1, std::ptrdiff_t n, I2 i2); namespace detail { - template struct equal_n_fn { GIL_FORCEINLINE bool operator()(I1 i1, std::ptrdiff_t n, I2 i2) const { return std::equal(i1,i1+n, i2); } }; -/// Equal when both ranges are interleaved and of the same type. +/// Equal when both ranges are interleaved and of the same type. /// GIL pixels are bitwise comparable, so memcmp is used. User-defined pixels that are not bitwise comparable need to provide an overload template struct equal_n_fn*, const pixel*> { - GIL_FORCEINLINE bool operator()(const pixel* i1, std::ptrdiff_t n, const pixel* i2) const { + GIL_FORCEINLINE bool operator()(const pixel* i1, std::ptrdiff_t n, const pixel* i2) const { return memcmp(i1, i2, n*sizeof(pixel))==0; } }; @@ -871,8 +842,8 @@ /// User-defined channels that are not bitwise comparable need to provide an overload template struct equal_n_fn, planar_pixel_iterator > { - GIL_FORCEINLINE bool operator()(const planar_pixel_iterator i1, std::ptrdiff_t n, const planar_pixel_iterator i2) const { - ptrdiff_t numBytes=n*sizeof(typename std::iterator_traits::value_type); + GIL_FORCEINLINE bool operator()(const planar_pixel_iterator i1, std::ptrdiff_t n, const planar_pixel_iterator i2) const { + std::ptrdiff_t numBytes=n*sizeof(typename std::iterator_traits::value_type); for (std::ptrdiff_t i=0; i::value; ++i) if (memcmp(dynamic_at_c(i1,i), dynamic_at_c(i2,i), numBytes)!=0) @@ -881,7 +852,6 @@ } }; - /// Source range is delimited by image iterators template // IL Models ConstPixelLocatorConcept, O Models PixelIteratorConcept struct equal_n_fn,I2> { @@ -953,14 +923,14 @@ /// \brief std::equal(I1,I1,I2) with I1 and I2 being a iterator_from_2d /// /// Invoked when one calls std::equal(I1,I1,I2) with I1 and I2 being a iterator_from_2d (which is -/// a 1D iterator over the pixels in an image). Attempts to demote the source and destination +/// a 1D iterator over the pixels in an image). Attempts to demote the source and destination /// iterators to simpler/faster types if the corresponding range is contiguous. /// For contiguous images (i.e. images that have -/// no alignment gap at the end of each row) it is more efficient to use the underlying +/// no alignment gap at the end of each row) it is more efficient to use the underlying /// pixel iterator that does not check for the end of rows. If the underlying pixel iterator /// happens to be a fundamental planar/interleaved pointer, the call may further resolve /// to memcmp. Otherwise it resolves to copying each row using the underlying pixel iterator -template GIL_FORCEINLINE +template GIL_FORCEINLINE bool equal(boost::gil::iterator_from_2d first, boost::gil::iterator_from_2d last, boost::gil::iterator_from_2d first2) { boost::gil::gil_function_requires >(); boost::gil::gil_function_requires >(); @@ -980,10 +950,9 @@ } // namespace std namespace boost { namespace gil { - /// \ingroup ImageViewSTLAlgorithmsEqualPixels /// \brief std::equal for image views -template GIL_FORCEINLINE +template GIL_FORCEINLINE bool equal_pixels(const View1& v1, const View2& v2) { assert(v1.dimensions()==v2.dimensions()); return std::equal(v1.begin(),v1.end(),v2.begin()); // std::equal has overloads with GIL iterators for optimal performance @@ -1001,7 +970,7 @@ /// \ingroup ImageViewSTLAlgorithmsTransformPixels /// \brief std::transform for image views -template GIL_FORCEINLINE +template GIL_FORCEINLINE F transform_pixels(const View1& src,const View2& dst, F fun) { assert(src.dimensions()==dst.dimensions()); for (std::ptrdiff_t y=0; y GIL_FORCEINLINE +template GIL_FORCEINLINE F transform_pixels(const View1& src1, const View2& src2,const View3& dst, F fun) { for (std::ptrdiff_t y=0; y GIL_FORCEINLINE +template GIL_FORCEINLINE F transform_pixel_positions(const View1& src,const View2& dst, F fun) { assert(src.dimensions()==dst.dimensions()); typename View1::xy_locator loc=src.xy_at(0,0); @@ -1048,7 +1017,7 @@ /// \ingroup ImageViewSTLAlgorithmsTransformPixelPositions /// \brief transform_pixel_positions with two sources -template GIL_FORCEINLINE +template GIL_FORCEINLINE F transform_pixel_positions(const View1& src1,const View2& src2,const View3& dst, F fun) { assert(src1.dimensions()==dst.dimensions()); assert(src2.dimensions()==dst.dimensions()); @@ -1063,11 +1032,10 @@ } return fun; } - } } // namespace boost::gil //#ifdef _MSC_VER //#pragma warning(pop) //#endif -#endif +#endif \ No newline at end of file Index: boost/gil/locator.hpp =================================================================== --- boost/gil/locator.hpp (revision 83084) +++ boost/gil/locator.hpp (working copy) @@ -1,6 +1,6 @@ /* Copyright 2005-2007 Adobe Systems Incorporated - + Use, modification and distribution are subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt). @@ -13,9 +13,8 @@ #ifndef GIL_LOCATOR_H #define GIL_LOCATOR_H - //////////////////////////////////////////////////////////////////////////////////////// -/// \file +/// \file /// \brief pixel 2D locator /// \author Lubomir Bourdev and Hailin Jin \n /// Adobe Systems Incorporated @@ -31,13 +30,11 @@ /// Pixel 2D LOCATOR //////////////////////////////////////////////////////////////////////////////////////// - namespace boost { namespace gil { - //forward declarations -template ptrdiff_t memunit_step(const P*); -template P* memunit_advanced(const P* p, ptrdiff_t diff); -template P& memunit_advanced_ref(P* p, ptrdiff_t diff); +template std::ptrdiff_t memunit_step(const P*); +template P* memunit_advanced(const P* p, std::ptrdiff_t diff); +template P& memunit_advanced_ref(P* p, std::ptrdiff_t diff); template struct iterator_add_deref; template class point2; namespace detail { @@ -62,7 +59,7 @@ /// \brief base class for models of PixelLocatorConcept /// \ingroup PixelLocatorModel PixelBasedModel /// -/// Pixel locator is similar to a pixel iterator, but allows for 2D navigation of pixels within an image view. +/// Pixel locator is similar to a pixel iterator, but allows for 2D navigation of pixels within an image view. /// It has a 2D difference_type and supports random access operations like: /// \code /// difference_type offset2(2,3); @@ -76,7 +73,7 @@ /// It is called a locator because it doesn't implement the complete interface of a random access iterator. /// For example, increment and decrement operations don't make sense (no way to specify dimension). /// Also 2D difference between two locators cannot be computed without knowledge of the X position within the image. -/// +/// /// This base class provides most of the methods and typedefs needed to create a model of a locator. GIL provides two /// locator models as subclasses of \p pixel_2d_locator_base. A memory-based locator, \p memory_based_2d_locator and a virtual /// locator, \p virtual_2d_locator. @@ -108,7 +105,7 @@ /// // return the vertical distance to another locator. Some models need the horizontal distance to compute it /// y_coord_t y_distance_to(const my_locator& loc2, x_coord_t xDiff) const; /// -/// // return true iff incrementing an x-iterator located at the last column will position it at the first +/// // return true iff incrementing an x-iterator located at the last column will position it at the first /// // column of the next row. Some models need the image width to determine that. /// bool is_1d_traversable(x_coord_t width) const; /// }; @@ -159,12 +156,12 @@ Loc& operator+=(const difference_type& d) { concrete().x()+=d.x; concrete().y()+=d.y; return concrete(); } Loc& operator-=(const difference_type& d) { concrete().x()-=d.x; concrete().y()-=d.y; return concrete(); } - + Loc operator+(const difference_type& d) const { return xy_at(d); } Loc operator-(const difference_type& d) const { return xy_at(-d); } // Some locators can cache 2D coordinates for faster subsequent access. By default there is no caching - typedef difference_type cached_location_t; + typedef difference_type cached_location_t; cached_location_t cache_location(const difference_type& d) const { return d; } cached_location_t cache_location(x_coord_t dx, y_coord_t dy)const { return difference_type(dx,dy); } @@ -177,7 +174,7 @@ // helper classes for each axis of pixel_2d_locator_base namespace detail { - template + template class locator_axis<0,Loc> { typedef typename Loc::point_t point_t; public: @@ -190,7 +187,7 @@ inline iterator operator()(const Loc& loc, const point_t& d) const { return loc.x_at(d); } }; - template + template class locator_axis<1,Loc> { typedef typename Loc::point_t point_t; public: @@ -224,10 +221,10 @@ /// while its base iterator provides horizontal navigation. /// /// Each instantiation is optimal in terms of size and efficiency. -/// For example, xy locator over interleaved rgb image results in a step iterator consisting of -/// one std::ptrdiff_t for the row size and one native pointer (8 bytes total). ++locator.x() resolves to pointer -/// increment. At the other extreme, a 2D navigation of the even pixels of a planar CMYK image results in a step -/// iterator consisting of one std::ptrdiff_t for the doubled row size, and one step iterator consisting of +/// For example, xy locator over interleaved rgb image results in a step iterator consisting of +/// one std::ptrdiff_t for the row size and one native pointer (8 bytes total). ++locator.x() resolves to pointer +/// increment. At the other extreme, a 2D navigation of the even pixels of a planar CMYK image results in a step +/// iterator consisting of one std::ptrdiff_t for the doubled row size, and one step iterator consisting of /// one std::ptrdiff_t for the horizontal step of two and a CMYK planar_pixel_iterator consisting of 4 pointers (24 bytes). /// In this case ++locator.x() results in four native pointer additions. /// @@ -255,8 +252,8 @@ template struct add_deref { typedef memory_based_2d_locator::type> type; - static type make(const memory_based_2d_locator& loc, const Deref& nderef) { - return type(iterator_add_deref::make(loc.y(),nderef)); + static type make(const memory_based_2d_locator& loc, const Deref& nderef) { + return type(iterator_add_deref::make(loc.y(),nderef)); } }; @@ -278,8 +275,8 @@ x_iterator& x() { return _p.base(); } y_iterator& y() { return _p; } - // These are faster versions of functions already provided in the superclass - x_iterator x_at (x_coord_t dx, y_coord_t dy) const { return memunit_advanced(x(), offset(dx,dy)); } + // These are faster versions of functions already provided in the superclass + x_iterator x_at (x_coord_t dx, y_coord_t dy) const { return memunit_advanced(x(), offset(dx,dy)); } x_iterator x_at (const difference_type& d) const { return memunit_advanced(x(), offset(d.x,d.y)); } this_t xy_at (x_coord_t dx, y_coord_t dy) const { return this_t(x_at( dx , dy ), row_size()); } this_t xy_at (const difference_type& d) const { return this_t(x_at( d.x, d.y), row_size()); } @@ -301,7 +298,7 @@ bool is_1d_traversable(x_coord_t width) const { return row_size()-pixel_size()*width==0; } // is there no gap at the end of each row? // Returns the vertical distance (it2.y-it1.y) between two x_iterators given the difference of their x positions - std::ptrdiff_t y_distance_to(const this_t& p2, x_coord_t xDiff) const { + std::ptrdiff_t y_distance_to(const this_t& p2, x_coord_t xDiff) const { std::ptrdiff_t rowDiff=memunit_distance(x(),p2.x())-pixel_size()*xDiff; assert(( rowDiff % row_size())==0); return rowDiff / row_size(); @@ -356,7 +353,6 @@ struct dynamic_y_step_type > { typedef memory_based_2d_locator type; }; - } } // namespace boost::gil -#endif +#endif \ No newline at end of file Index: boost/gil/planar_pixel_iterator.hpp =================================================================== --- boost/gil/planar_pixel_iterator.hpp (revision 83084) +++ boost/gil/planar_pixel_iterator.hpp (working copy) @@ -1,6 +1,6 @@ /* Copyright 2005-2007 Adobe Systems Incorporated - + Use, modification and distribution are subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt). @@ -14,7 +14,7 @@ #define GIL_PLANAR_PTR_H //////////////////////////////////////////////////////////////////////////////////////// -/// \file +/// \file /// \brief planar pixel pointer class /// \author Lubomir Bourdev and Hailin Jin \n /// Adobe Systems Incorporated @@ -30,12 +30,11 @@ #include "step_iterator.hpp" namespace boost { namespace gil { - //forward declaration (as this file is included in planar_pixel_reference.hpp) -template +template struct planar_pixel_reference; -/// \defgroup ColorBaseModelPlanarPtr planar_pixel_iterator +/// \defgroup ColorBaseModelPlanarPtr planar_pixel_iterator /// \ingroup ColorBaseModel /// \brief A homogeneous color base whose element is a channel iterator. Models HomogeneousColorBaseValueConcept /// This class is used as an iterator to a planar pixel. @@ -49,7 +48,7 @@ /// /// Planar pixels have channel data that is not consecutive in memory. /// To abstract this we use classes to represent references and pointers to planar pixels. -/// +/// /// \ingroup PixelIteratorModelPlanarPtr ColorBaseModelPlanarPtr PixelBasedModel template struct planar_pixel_iterator : public iterator_facade, @@ -69,7 +68,7 @@ typedef typename parent_t::reference reference; typedef typename parent_t::difference_type difference_type; - planar_pixel_iterator() : color_base_parent_t(0) {} + planar_pixel_iterator() : color_base_parent_t(0) {} planar_pixel_iterator(bool) {} // constructor that does not fill with zero (for performance) planar_pixel_iterator(const ChannelPtr& v0, const ChannelPtr& v1) : color_base_parent_t(v0,v1) {} @@ -77,20 +76,19 @@ planar_pixel_iterator(const ChannelPtr& v0, const ChannelPtr& v1, const ChannelPtr& v2, const ChannelPtr& v3) : color_base_parent_t(v0,v1,v2,v3) {} planar_pixel_iterator(const ChannelPtr& v0, const ChannelPtr& v1, const ChannelPtr& v2, const ChannelPtr& v3, const ChannelPtr& v4) : color_base_parent_t(v0,v1,v2,v3,v4) {} - template + template planar_pixel_iterator(const planar_pixel_iterator& ptr) : color_base_parent_t(ptr) {} - /// Copy constructor and operator= from pointers to compatible planar pixels or planar pixel references. /// That allow constructs like pointer = &value or pointer = &reference /// Since we should not override operator& that's the best we can do. - template + template planar_pixel_iterator(P* pix) : color_base_parent_t(pix, true) { function_requires >(); } struct address_of { template T* operator()(T& t) { return &t; } }; - template + template planar_pixel_iterator& operator=(P* pix) { function_requires >(); static_transform(*pix,*this, address_of()); @@ -116,10 +114,10 @@ void increment() { static_transform(*this,*this,detail::inc()); } void decrement() { static_transform(*this,*this,detail::dec()); } - void advance(ptrdiff_t d) { static_transform(*this,*this,std::bind2nd(detail::plus_asymmetric(),d)); } + void advance(std::ptrdiff_t d) { static_transform(*this,*this,std::bind2nd(detail::plus_asymmetric(),d)); } reference dereference() const { return this->template deref(); } - ptrdiff_t distance_to(const planar_pixel_iterator& it) const { return gil::at_c<0>(it)-gil::at_c<0>(*this); } + std::ptrdiff_t distance_to(const planar_pixel_iterator& it) const { return gil::at_c<0>(it)-gil::at_c<0>(*this); } bool equal(const planar_pixel_iterator& it) const { return gil::at_c<0>(*this)==gil::at_c<0>(it); } }; @@ -128,31 +126,31 @@ template struct channel_iterator_is_mutable : public mpl::false_ {}; } -template -struct const_iterator_type > { +template +struct const_iterator_type > { private: typedef typename std::iterator_traits::value_type channel_t; public: - typedef planar_pixel_iterator::const_pointer,C> type; + typedef planar_pixel_iterator::const_pointer,C> type; }; // The default implementation when the iterator is a C pointer is to use the standard constness semantics -template +template struct iterator_is_mutable > : public detail::channel_iterator_is_mutable {}; ///////////////////////////// // ColorBasedConcept ///////////////////////////// -template +template struct kth_element_type, K> { typedef IC type; }; -template +template struct kth_element_reference_type, K> : public add_reference {}; -template +template struct kth_element_const_reference_type, K> : public add_reference::type> {}; ///////////////////////////// @@ -183,8 +181,8 @@ inline std::ptrdiff_t memunit_step(const planar_pixel_iterator&) { return sizeof(typename std::iterator_traits::value_type); } template -inline std::ptrdiff_t memunit_distance(const planar_pixel_iterator& p1, const planar_pixel_iterator& p2) { - return memunit_distance(gil::at_c<0>(p1),gil::at_c<0>(p2)); +inline std::ptrdiff_t memunit_distance(const planar_pixel_iterator& p1, const planar_pixel_iterator& p2) { + return memunit_distance(gil::at_c<0>(p1),gil::at_c<0>(p2)); } template @@ -196,7 +194,7 @@ }; template -inline void memunit_advance(planar_pixel_iterator& p, std::ptrdiff_t diff) { +inline void memunit_advance(planar_pixel_iterator& p, std::ptrdiff_t diff) { static_transform(p, p, memunit_advance_fn(diff)); } @@ -208,7 +206,7 @@ } template -inline planar_pixel_reference::reference,ColorSpace> +inline planar_pixel_reference::reference,ColorSpace> memunit_advanced_ref(const planar_pixel_iterator& ptr, std::ptrdiff_t diff) { return planar_pixel_reference::reference,ColorSpace>(ptr, diff); } @@ -221,7 +219,6 @@ struct dynamic_x_step_type > { typedef memory_based_step_iterator > type; }; - } } // namespace boost::gil -#endif +#endif \ No newline at end of file