~docky-core/plank/respect-struts

« back to all changes in this revision

Viewing changes to lib/DockRenderer.vala

  • Committer: Rico Tzschichholz
  • Date: 2015-07-16 08:24:10 UTC
  • Revision ID: ricotz@ubuntu.com-20150716082410-tkbn5mqoxbe6j41n
Add ability to cache multiple sizes of drawn items

Show diffs side-by-side

added added

removed removed

Lines of Context:
749
749
                        
750
750
                        DockSurface? icon_overlay_surface = null;
751
751
                        if (item.CountVisible || item.ProgressVisible)
752
 
                                icon_overlay_surface = item.get_foreground_surface (draw_item_foreground);
 
752
                                icon_overlay_surface = item.get_foreground_surface (icon_size * window_scale_factor, icon_size * window_scale_factor, item_buffer, (DrawDataFunc<DockItem>) draw_item_foreground);
753
753
                        
754
754
                        if (icon_overlay_surface != null) {
755
755
                                icon_cr.set_source_surface (icon_overlay_surface.Internal, 0, 0);
809
809
                {
810
810
                        unowned PositionManager position_manager = controller.position_manager;
811
811
                        var shadow_size = position_manager.IconShadowSize;
812
 
 
 
812
                        // Inflate size to fit shadow
 
813
                        var icon_size = (int) draw_value.icon_size + 2 * shadow_size;
 
814
                        
813
815
                        // load and draw the icon shadow
814
816
                        DockSurface? icon_shadow_surface = null;
815
817
                        if (shadow_size > 0)
816
 
                                icon_shadow_surface = item.get_background_surface (draw_item_background);
 
818
                                icon_shadow_surface = item.get_background_surface (icon_size * window_scale_factor, icon_size * window_scale_factor, item_buffer, (DrawDataFunc<DockItem>) draw_item_background);
817
819
                        
818
820
                        if (icon_shadow_surface != null) {
819
821
                                if (window_scale_factor > 1) {
832
834
                        }
833
835
                }
834
836
                
835
 
                DockSurface draw_item_foreground (DockItem item, DockSurface icon_surface, DockSurface? current_surface)
 
837
                [CCode (instance_pos = -1)]
 
838
                DockSurface draw_item_foreground (int width, int height, DockSurface model, DockItem item)
836
839
                {
837
 
                        unowned PositionManager position_manager = controller.position_manager;
838
 
                        var width = icon_surface.Width;
839
 
                        var height = icon_surface.Height;
840
 
                        
841
 
                        if (current_surface != null
842
 
                                && width == current_surface.Width && height == current_surface.Height)
843
 
                                return current_surface;
844
 
                        
845
840
                        Logger.verbose ("DockItem.draw_item_overlay (width = %i, height = %i)", width, height);
846
 
                        var surface = new DockSurface.with_dock_surface (width, height, icon_surface);
 
841
                        var surface = new DockSurface.with_dock_surface (width, height, model);
847
842
                        
848
843
                        var icon_size = int.min (width, height) * window_scale_factor;
849
844
                        var urgent_color = get_styled_color ();
860
855
                        return surface;
861
856
                }
862
857
                
863
 
                DockSurface draw_item_background (DockItem item, DockSurface icon_surface, DockSurface? current_surface)
 
858
                [CCode (instance_pos = -1)]
 
859
                DockSurface draw_item_background (int width, int height, DockSurface model, DockItem item)
864
860
                {
865
861
                        unowned PositionManager position_manager = controller.position_manager;
866
862
                        var shadow_size = position_manager.IconShadowSize * window_scale_factor;
867
863
                        
868
 
                        // Inflate size to fit shadow
869
 
                        var width = icon_surface.Width + 2 * shadow_size;
870
 
                        var height = icon_surface.Height + 2 * shadow_size;
871
 
                        
872
 
                        if (current_surface != null
873
 
                                && width == current_surface.Width && height == current_surface.Height)
874
 
                                return current_surface;
 
864
                        var draw_value = position_manager.get_draw_value_for_item (item);
 
865
                        var icon_size = (int) draw_value.icon_size;
 
866
                        var icon_surface = item.get_surface (icon_size, icon_size, model);
875
867
                        
876
868
                        Logger.verbose ("DockItem.draw_icon_with_shadow (width = %i, height = %i, shadow_size = %i)", width, height, shadow_size);
877
 
                        var surface = new DockSurface.with_dock_surface (width, height, icon_surface);
 
869
                        var surface = new DockSurface.with_dock_surface (width, height, model);
878
870
                        unowned Cairo.Context cr = surface.Context;
879
871
                        var shadow_surface = icon_surface.create_mask (0.4, null);
880
872