Changeset 568 for gtkimageview

Show
Ignore:
Timestamp:
09/01/08 05:08:10 (5 years ago)
Author:
bjourne
Message:

Fix for #23. If the views allocation is very small and it tries show a
zoom to fitted image, the zoom factor becomes really small like 0.0001
or so, which triggers the bug
http://bugzilla.gnome.org/show_bug.cgi?id=80925 in gdk-pixbuf. Add a
workaround which prevents the zoom factor from ever being smaller than
0.02.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gtkimageview/docs/reference/releasehistory.sgml

    r560 r568  
    1818    <itemizedlist> 
    1919      <listitem> 
     20        Fix for <ulink url = 
     21        "http://trac.bjourne.webfactional.com/ticket/23">ticket23</ulink>. To 
     22        small zoom factors are disallowed which should prevent the 
     23        filter matrices to become rediculously large and eat up all 
     24        memory. 
     25      </listitem>   
     26      <listitem> 
    2027        Horizontal scrolls should not crash GtkImageView anymore. 
    2128      </listitem> 
  • gtkimageview/src/gtkimageview.c

    r560 r568  
    473473 
    474474    gdouble zoom = MIN (ratio_y, ratio_x); 
    475     zoom = MIN (zoom, 1.0); 
     475 
     476    // Disallow to small zoom factors, they eat up all memory because 
     477    // the filter matrices becomes to large. See #80925. 
     478    zoom = CLAMP (zoom, gtk_zooms_get_min_zoom (), 1.0); 
    476479 
    477480    gtk_image_view_set_zoom_no_center (view, zoom, is_allocating); 
     
    520523        return FALSE; 
    521524 
    522     // This is a workaround for #80925. If the image area gets to 
    523     // small, then gdk-pixbuf's scale matrix becomes ridiculously 
    524     // large which causes noticable and wasteful cpu spikes. 
    525     Size alloc = gtk_image_view_get_allocated_size (view); 
    526     if (alloc.width <= 1 || alloc.height <= 1) 
    527         return FALSE; 
    528      
    529525    view->is_rendering = TRUE; 
    530526     
    531527    // Image area is the area on the widget occupied by the pixbuf.  
    532528    GdkRectangle image_area; 
     529    Size alloc = gtk_image_view_get_allocated_size (view); 
    533530    gtk_image_view_get_draw_rect (view, &image_area); 
    534531    if (image_area.x > 0 || 
  • gtkimageview/src/gtkzooms.c

    r337 r568  
    3232 
    3333static const gdouble ZOOMS[] = { 
    34     0.05, 0.07, 0.10, 
     34    0.02, 0.05, 0.07, 0.10, 
    3535    0.15, 0.20, 0.30, 0.50, 0.75, 1.0, 
    3636    1.5, 2.0, 3.0, 5.0, 7.5, 10.0,