ó
 m[c           @` st   d  d l  m Z m Z m Z m Z d  d l Z d  d l Z d  d l m	 Z	 d  d l
 m Z d e f d „  ƒ  YZ d S(   i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t   RendererAgg(   t   process_figure_for_rasterizingt   MixedModeRendererc           B` sD   e  Z d  Z d d d „ Z d j ƒ  Z d „  Z d „  Z d „  Z	 RS(   u&  
    A helper class to implement a renderer that switches between
    vector and raster drawing.  An example may be a PDF writer, where
    most things are drawn with PDF vector commands, but some very
    complex objects, such as quad meshes, are rasterised and then
    output as images.
    c         C` s†   | d k r t } n  | |  _ | |  _ | |  _ | |  _ | |  _ d |  _ d |  _ | |  _	 | j
 ƒ  |  _ | |  _ |  j | ƒ d S(   u+  
        Parameters
        ----------
        figure : `matplotlib.figure.Figure`
            The figure instance.

        width : scalar
            The width of the canvas in logical units

        height : scalar
            The height of the canvas in logical units

        dpi : scalar
            The dpi of the canvas

        vector_renderer : `matplotlib.backend_bases.RendererBase`
            An instance of a subclass of
            `~matplotlib.backend_bases.RendererBase` that will be used for the
            vector drawing.

        raster_renderer_class : `matplotlib.backend_bases.RendererBase`
            The renderer class to use for the raster drawing.  If not provided,
            this will use the Agg backend (which is currently the only viable
            option anyway.)

        i    N(   t   NoneR   t   _raster_renderer_classt   _widtht   _heightt   dpit   _vector_renderert   _raster_renderert   _rasterizingt   figuret   get_dpit   _figdpit   _bbox_inches_restoret   _set_current_renderer(   t   selfR   t   widtht   heightR   t   vector_renderert   raster_renderer_classt   bbox_inches_restore(    (    s@   lib/python2.7/site-packages/matplotlib/backends/backend_mixed.pyt   __init__   s    										uë  
        close_group draw_image draw_markers draw_path
        draw_path_collection draw_quad_mesh draw_tex draw_text
        finalize flipy get_canvas_width_height get_image_magnification
        get_texmanager get_text_width_height_descent new_gc open_group
        option_image_nocomposite points_to_pixels strip_math
        start_filter stop_filter draw_gouraud_triangle
        draw_gouraud_triangles option_scale_image
        _text2path _get_text_path_transform height width
        c         C` sd   | |  _  x< |  j D]1 } t | | ƒ r t |  | t | | ƒ ƒ q q W|  j | _ |  j | _ d  S(   N(   t	   _renderert   _methodst   hasattrt   setattrt   getattrt   start_rasterizingt   stop_rasterizing(   R   t   renderert   method(    (    s@   lib/python2.7/site-packages/matplotlib/backends/backend_mixed.pyR   S   s    	 c         C` s¡   |  j  j |  j ƒ |  j r= t |  j  |  j ƒ } | |  _ n  |  j d k rŽ |  j |  j |  j |  j |  j |  j ƒ |  _	 |  j
 |  j	 ƒ n  |  j d 7_ d S(   u  
        Enter "raster" mode.  All subsequent drawing commands (until
        stop_rasterizing is called) will be drawn with the raster
        backend.

        If start_rasterizing is called multiple times before
        stop_rasterizing is called, this method has no effect.
        i    i   N(   R   t   set_dpiR   R   R   R   R   R	   R
   R   R   (   R   t   r(    (    s@   lib/python2.7/site-packages/matplotlib/backends/backend_mixed.pyR    \   s    		)c         C` sk  |  j  d 8_  |  j  d k r7|  j |  j ƒ |  j |  j } |  j j ƒ  \ } } | \ } } } } | d k r| d k rt j | d t j	 ƒ} | j
 | | d f ƒ } | d d d … } |  j j ƒ  }	 |  j j |	 | |  j |  j | | | |  j |  j | ƒ n  d |  _ t |  _  |  j j |  j ƒ n  |  j rgt |  j |  j |  j ƒ }
 |
 |  _ n  d S(   u9  
        Exit "raster" mode.  All of the drawing that was done since
        the last start_rasterizing command will be copied to the
        vector backend by calling draw_image.

        If stop_rasterizing is called multiple times before
        start_rasterizing is called, this method has no effect.
        i   i    t   dtypei   Niÿÿÿÿ(   R   R   R   R
   R   R   t   tostring_rgba_minimizedt   npt
   frombuffert   uint8t   reshapeR   t   new_gct
   draw_imageR   R   t   FalseR   R$   R   R   (   R   R   t   buffert   boundst   lt   bt   wt   ht   imaget   gcR%   (    (    s@   lib/python2.7/site-packages/matplotlib/backends/backend_mixed.pyR!   t   s0    		
				N(
   t   __name__t
   __module__t   __doc__R   R   t   splitR   R   R    R!   (    (    (    s@   lib/python2.7/site-packages/matplotlib/backends/backend_mixed.pyR      s   ;			(   t
   __future__R    R   R   R   t   numpyR(   t   sixt   matplotlib.backends.backend_aggR   t   matplotlib.tight_bboxR   t   objectR   (    (    (    s@   lib/python2.7/site-packages/matplotlib/backends/backend_mixed.pyt   <module>   s
   "