$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r67652 - sandbox/gil/boost/gil/extension/io2
From: dsaritz_at_[hidden]
Date: 2011-01-04 12:35:30
Author: psiha
Date: 2011-01-04 12:35:29 EST (Tue, 04 Jan 2011)
New Revision: 67652
URL: http://svn.boost.org/trac/boost/changeset/67652
Log:
Replaced the formatted_image_traits<Impl>::view_to_native_format metaclass with the gil_to_native_format<> metafunction.
Minor compile time optimizations.
Minor other refactoring and stylistic changes.
Text files modified: 
   sandbox/gil/boost/gil/extension/io2/formatted_image.hpp |    48 +++++++++++++++++++++++++---------------
   sandbox/gil/boost/gil/extension/io2/gp_image.hpp        |    12 +++++-----                              
   sandbox/gil/boost/gil/extension/io2/libjpeg_image.hpp   |    10 ++++----                                
   sandbox/gil/boost/gil/extension/io2/libpng_image.hpp    |    15 ++++++-----                             
   sandbox/gil/boost/gil/extension/io2/libtiff_image.hpp   |    12 +++++-----                              
   sandbox/gil/boost/gil/extension/io2/wic_image.hpp       |    12 +++++-----                              
   6 files changed, 61 insertions(+), 48 deletions(-)
Modified: sandbox/gil/boost/gil/extension/io2/formatted_image.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/formatted_image.hpp	(original)
+++ sandbox/gil/boost/gil/extension/io2/formatted_image.hpp	2011-01-04 12:35:29 EST (Tue, 04 Jan 2011)
@@ -508,6 +508,14 @@
 template <class Impl>
 class formatted_image : public formatted_image_base
 {
+private:
+    template <typename T> struct gil_to_native_format;
+
+    template <typename PixelType, typename IsPlanar>
+    struct gil_to_native_format_aux
+        : formatted_image_traits<Impl>::gil_to_native_format:: BOOST_NESTED_TEMPLATE apply<PixelType, IsPlanar::value>::type
+    {};
+
 public:
     typedef typename formatted_image_traits<Impl>::format_t format_t;
 
@@ -515,9 +523,16 @@
     typedef typename formatted_image_traits<Impl>::roi_t                     roi;
     typedef typename roi::offset_t                                           offset_t;
 
-    typedef any_image<supported_pixel_formats>     dynamic_image_t;
-    typedef typename dynamic_image_t::const_view_t const_view_t;
-    typedef typename dynamic_image_t::      view_t       view_t;
+    template <typename PixelType, typename IsPlanar>
+    struct gil_to_native_format<mpl::pair<PixelType, IsPlanar > > : gil_to_native_format_aux<PixelType, IsPlanar> {};
+
+    template <typename PixelType, bool IsPlanar>
+    struct gil_to_native_format<image<PixelType, IsPlanar> > : gil_to_native_format_aux<PixelType, mpl::bool_<IsPlanar> > {};
+
+    template <typename Locator>
+    struct gil_to_native_format<image_view<Locator> > : gil_to_native_format_aux<typename image_view<Locator>::value_type, is_planar<image_view<Locator> > > {};
+    
+    typedef any_image<supported_pixel_formats> dynamic_image_t;
 
     template <typename Source>
     struct reader_for
@@ -554,12 +569,12 @@
 
     public:
         typedef typename base_writer_t::wrapper
-            <
-                first_layer_wrapper,
-                Target,
-                typename formatted_image_traits<Impl>::writer_view_data_t,
-                default_format
-            > type;
+                <
+                    first_layer_wrapper,
+                    Target,
+                    typename formatted_image_traits<Impl>::writer_view_data_t,
+                    default_format
+                > type;
     };
 
     BOOST_STATIC_CONSTANT( bool, has_full_roi = (is_same<roi::offset_t, roi::point_t>::value) );
@@ -614,7 +629,7 @@
 
     struct write_is_supported
     {
-        template<typename View>
+        template <typename View>
         struct apply : public is_supported<View> {};
     };
 
@@ -627,10 +642,8 @@
         template <typename ImageIndex>
         void operator()( ImageIndex )
         {
-            format_t const image_format
-            (
-                formatted_image_traits<Impl>::view_to_native_format::apply<typename mpl::at<supported_pixel_formats, ImageIndex>::type::view_t>::value
-            );
+            typedef typename mpl::at<supported_pixel_formats, ImageIndex>::type pixel_format_t;
+            format_t const image_format( gil_to_native_format<pixel_format_t>::value );
             if ( image_format == this->format_ )
             {
                 BOOST_ASSERT( image_id_ == -1 );
@@ -638,7 +651,7 @@
             }
         }
 
-        format_t /*const*/ format_;
+        format_t     const format_  ;
         unsigned int       image_id_;
 
     private:
@@ -671,7 +684,7 @@
     template <typename View>
     bool formats_mismatch() const
     {
-        return formats_mismatch( formatted_image_traits<Impl>::view_to_native_format:: BOOST_NESTED_TEMPLATE apply<get_original_view_t<View>::type>::value );
+        return formats_mismatch( gil_to_native_format<get_original_view_t<View>::type>::value );
     }
 
     bool formats_mismatch( typename formatted_image_traits<Impl>::format_t const other_format ) const
@@ -820,8 +833,7 @@
     template <typename Images, typename dimensions_policy, typename formats_policy>
     void copy_to_image( any_image<Images> & im ) const
     {
-        typedef mpl::range_c<std::size_t, 0, typename Impl::supported_pixel_formats> valid_range_t;
-        switch_<valid_range_t>
+        switch_<valid_type_id_range_t>
         (
             impl().current_image_format_id(),
             read_dynamic_image<Images, dimensions_policy, formats_policy>( im, *this ),
Modified: sandbox/gil/boost/gil/extension/io2/gp_image.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/gp_image.hpp	(original)
+++ sandbox/gil/boost/gil/extension/io2/gp_image.hpp	2011-01-04 12:35:29 EST (Tue, 04 Jan 2011)
@@ -93,8 +93,8 @@
 
 struct view_gp_format
 {
-    template <class View>
-    struct apply : gil_to_gp_format<typename View::value_type, is_planar<View>::value> {};
+    template <typename Pixel, bool IsPlanar>
+    struct apply : gil_to_gp_format<Pixel, IsPlanar> {};
 };
 
 
@@ -274,10 +274,10 @@
 
     typedef detail::gp_roi roi_t;
 
-    typedef detail::view_gp_format view_to_native_format;
+    typedef detail::view_gp_format gil_to_native_format;
 
-    template <class View>
-    struct is_supported : detail::is_supported<view_to_native_format::apply<View>::value> {};
+    template <typename Pixel, bool IsPlanar>
+    struct is_supported : detail::is_supported<gil_to_native_format:: BOOST_NESTED_TEMPLATE apply<Pixel, IsPlanar>::value> {};
 
     typedef mpl::map5
     <
@@ -329,7 +329,7 @@
             Width       = view.width();
             Height      = view.height();
             Stride      = view.pixels().row_size();
-            PixelFormat = view_to_native_format::apply<View>::value;
+            PixelFormat = gil_to_native_format<View>::value;
             Scan0       = formatted_image_base::get_raw_data( view );
             Reserved    = 0;
         }
Modified: sandbox/gil/boost/gil/extension/io2/libjpeg_image.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/libjpeg_image.hpp	(original)
+++ sandbox/gil/boost/gil/extension/io2/libjpeg_image.hpp	2011-01-04 12:35:29 EST (Tue, 04 Jan 2011)
@@ -56,8 +56,8 @@
 
 struct view_libjpeg_format
 {
-    template <class View>
-    struct apply : gil_to_libjpeg_format<typename View::value_type, is_planar<View>::value> {};
+    template <typename Pixel, bool IsPlanar>
+    struct apply : gil_to_libjpeg_format<Pixel, IsPlanar> {};
 };
 
 
@@ -417,11 +417,11 @@
     typedef       ::J_COLOR_SPACE                   format_t;
     typedef detail::libjpeg_supported_pixel_formats supported_pixel_formats_t;
     typedef detail::libjpeg_roi                     roi_t;
-    typedef detail::view_libjpeg_format             view_to_native_format;
+    typedef detail::view_libjpeg_format             gil_to_native_format;
     typedef detail::view_data_t                     view_data_t;
 
-    template <class View>
-    struct is_supported : mpl::bool_<view_to_native_format::apply<View>::value != JCS_UNKNOWN> {};
+    template <typename Pixel, bool IsPlanar>
+    struct is_supported : mpl::bool_<gil_to_native_format::apply<Pixel, IsPlanar>::value != JCS_UNKNOWN> {};
 
     typedef mpl::map3
             <
Modified: sandbox/gil/boost/gil/extension/io2/libpng_image.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/libpng_image.hpp	(original)
+++ sandbox/gil/boost/gil/extension/io2/libpng_image.hpp	2011-01-04 12:35:29 EST (Tue, 04 Jan 2011)
@@ -56,13 +56,13 @@
 
 struct view_libpng_format
 {
-    template <class View>
-    struct apply : gil_to_libpng_format<typename View::value_type, is_planar<View>::value> {};
+    template <typename Pixel, bool IsPlanar>
+    struct apply : gil_to_libpng_format<Pixel, IsPlanar> {};
 };
 
 
-template <class View>
-struct is_view_supported : mpl::bool_<view_libpng_format::apply<View>::value != -1> {};
+template <typename Pixel, bool IsPlanar>
+struct is_view_supported : mpl::bool_<view_libpng_format::apply<Pixel, IsPlanar>::value != -1> {};
 
 
 typedef mpl::vector6
@@ -386,11 +386,11 @@
     typedef         int                            format_t;
     typedef detail::libpng_supported_pixel_formats supported_pixel_formats_t;
     typedef detail::libpng_roi                     roi_t;
-    typedef detail::view_libpng_format             view_to_native_format;
+    typedef detail::view_libpng_format             gil_to_native_format;
     typedef detail::libpng_view_data_t             view_data_t;
 
-    template <class View>
-    struct is_supported : detail::is_view_supported<View> {};
+    template <typename Pixel, bool IsPlanar>
+    struct is_supported : detail::is_view_supported<Pixel, IsPlanar> {};
 
     typedef mpl::map3
             <
@@ -588,6 +588,7 @@
         else
         if ( colour_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8 )
             ::png_set_expand_gray_1_2_4_to_8( &png_object() );
+
         if ( ::png_get_valid( &png_object(), &info_object(), PNG_INFO_tRNS ) )
             ::png_set_tRNS_to_alpha( &png_object() );
 
Modified: sandbox/gil/boost/gil/extension/io2/libtiff_image.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/libtiff_image.hpp	(original)
+++ sandbox/gil/boost/gil/extension/io2/libtiff_image.hpp	2011-01-04 12:35:29 EST (Tue, 04 Jan 2011)
@@ -118,8 +118,8 @@
 
 struct view_libtiff_format
 {
-    template <class View>
-    struct apply : gil_to_libtiff_format<typename View::value_type, is_planar<View>::value> {};
+    template <typename Pixel, bool IsPlanar>
+    struct apply : gil_to_libtiff_format<Pixel, IsPlanar> {};
 };
 
 
@@ -265,7 +265,7 @@
         stride_    ( view.pixels().row_size() ),
         offset_    ( offset                   )
         #ifdef _DEBUG
-            ,format_id_( view_libtiff_format::apply<View>::value )
+            ,format_id_( view_libtiff_format::apply<typename View::value_type, is_planar<View>::value>::value )
         #endif
     {
         set_buffers( view, is_planar<View>() );
@@ -485,7 +485,7 @@
 
     typedef detail::generic_vertical_roi roi_t;
 
-    typedef detail::view_libtiff_format view_to_native_format;
+    typedef detail::view_libtiff_format gil_to_native_format;
 
     typedef detail::tiff_view_data_t view_data_t;
 
@@ -508,8 +508,8 @@
 
     typedef detail::tiff_writer_view_data_t writer_view_data_t;
 
-    BOOST_STATIC_CONSTANT( unsigned int, desired_alignment  = sizeof( void *) );
-    BOOST_STATIC_CONSTANT( bool        , builtin_conversion = false           );
+    BOOST_STATIC_CONSTANT( unsigned int, desired_alignment  = sizeof( void * ) );
+    BOOST_STATIC_CONSTANT( bool        , builtin_conversion = false            );
 };
 
 
Modified: sandbox/gil/boost/gil/extension/io2/wic_image.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/wic_image.hpp	(original)
+++ sandbox/gil/boost/gil/extension/io2/wic_image.hpp	2011-01-04 12:35:29 EST (Tue, 04 Jan 2011)
@@ -102,8 +102,8 @@
 
 struct view_wic_format
 {
-    template <class View>
-    struct apply : gil_to_wic_format<typename View::value_type, is_planar<View>::value> {};
+    template <typename Pixel, bool IsPlanar>
+    struct apply : gil_to_wic_format<Pixel, IsPlanar> {};
 };
 
 
@@ -152,7 +152,7 @@
     wic_view_data_t( View const & view )
         :
         p_roi_ ( 0                                   ),
-        format_( view_wic_format::apply<View>::value )
+        format_( view_wic_format::apply<typename View::value_type, is_planar<View>::value>::value )
     {
         set_bitmapdata_for_view( view );
     }
@@ -295,16 +295,16 @@
 
     typedef detail::wic_roi roi_t;
 
-    typedef detail::view_wic_format view_to_native_format;
+    typedef detail::view_wic_format gil_to_native_format;
 
-    template <class View>
+    template <typename Pixel, bool IsPlanar>
     struct is_supported
         :
         mpl::not_
         <
             is_same
             <
-                typename view_to_native_format::apply<View>::type,
+                typename gil_to_native_format:: BOOST_NESTED_TEMPLATE apply<Pixel, IsPlanar>::type,
                 //format_guid<wic_format                  >,
                 detail::format_guid<GUID_WICPixelFormatUndefined>
             >