Changeset 61710 in webkit


Ignore:
Timestamp:
Jun 23, 2010 2:52:30 PM (14 years ago)
Author:
senorblanco@chromium.org
Message:

2010-06-23 Stephen White <senorblanco@chromium.org>

Reviewed by David Hyatt.

This is a tweak to the resize algorithm introduced in r61341, and
is a fix for the regression described in
https://bugs.webkit.org/show_bug.cgi?id=41036

The goal is to bring back the some of old behaviour, without regressing
too much of the performance gains in r61341.

The old algorithm was:

  • on first resize, draw in high quality and record the paint time
  • if we've already drawn at this size, use the same quality as last time
  • on subsequent resizes, if the resize occurs within X ms of the previous one, draw at low quality and set a timer (one timer per image).
  • when each timer expires, draw that image at high quality

The r61341 algorithm was:

  • on first resize, draw the image in low quality, add it to a list of resized images, and set a timer (one timer for all images)
  • when the timer expires, redraw all resized images in high quality

The new algorithm is:

  • on first resize, if no other animated resizes are outstanding, draw in high quality and set the timer (one timer for all images)
  • if any images have been resized to two different sizes in the last X ms, draw all resized images in low quality and kick the timer forward
  • when the timer expires, if any animated resizes occured, redraw all resized images in high quality, and reset the flag

This should cause GUIMark and the IE9 demos to have good performance
after the first frame, while other pages with only static resizes
should be unaffected.

  • rendering/RenderBoxModelObject.cpp: Change the LastPaintTimeMap to a LastPaintSizeMap: we now record the last size an image was resized to, rather than the time it was painted (the time actually became redundant in r61341 when I added the check for m_timer.isActive(): we only care if anything is resizing while the timer is active). (WebCore::ImageQualityController::ImageQualityController): Add an initializer for the m_animatedResizeIsActive flag. (WebCore::ImageQualityController::objectDestroyed): Reset the m_animatedResizeIsActive flag if this was the last object in the list. (WebCore::ImageQualityController::highQualityRepaintTimerFired): Only repaint all the images if there was an animated resize (otherwise, everything is already high quality). (WebCore::ImageQualityController::shouldPaintAtLowQuality): Implement the above algorithm.

2010-06-23 Stephen White <senorblanco@chromium.org>

Reviewed by David Hyatt.

Temporarily put the tests broken by the resize change into
test_expectations.txt.
https://bugs.webkit.org/show_bug.cgi?id=41036

  • platform/chromium/test_expectations.txt:
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r61709 r61710  
     12010-06-23  Stephen White  <senorblanco@chromium.org>
     2
     3        Reviewed by David Hyatt.
     4
     5        Temporarily put the tests broken by the resize change into
     6        test_expectations.txt.
     7        https://bugs.webkit.org/show_bug.cgi?id=41036
     8
     9        * platform/chromium/test_expectations.txt:
     10
    1112010-06-23  Abhishek Arya  <inferno@chromium.org>
    212
  • trunk/LayoutTests/platform/chromium/test_expectations.txt

    r61670 r61710  
    28892889BUGWK37538 : printing/page-format-data.html = TEXT
    28902890
     2891// These need to be rebaselined after
     2892// https://bugs.webkit.org/show_bug.cgi?id=41036
     2893BUG_SENORBLANCO WIN LINUX : css2.1/t090501-c414-flt-03-b-g.html = IMAGE
     2894BUG_SENORBLANCO WIN LINUX : css2.1/t090501-c5525-flt-l-00-b-g.html = IMAGE
     2895BUG_SENORBLANCO WIN LINUX : css2.1/t090501-c5525-flt-r-00-b-g.html = IMAGE
     2896BUG_SENORBLANCO WIN LINUX : fast/backgrounds/size/backgroundSize01.html = IMAGE
     2897BUG_SENORBLANCO WIN LINUX : fast/backgrounds/size/backgroundSize02.html = IMAGE
     2898BUG_SENORBLANCO WIN LINUX : fast/backgrounds/size/backgroundSize04.html = IMAGE
     2899BUG_SENORBLANCO WIN LINUX : fast/backgrounds/size/backgroundSize05.html = IMAGE
     2900BUG_SENORBLANCO WIN LINUX : fast/backgrounds/size/backgroundSize06.html = IMAGE
     2901BUG_SENORBLANCO WIN LINUX : fast/backgrounds/size/backgroundSize07.html = IMAGE
     2902BUG_SENORBLANCO WIN LINUX : fast/backgrounds/size/backgroundSize08.html = IMAGE
     2903BUG_SENORBLANCO WIN LINUX : fast/backgrounds/size/backgroundSize09.html = IMAGE
     2904BUG_SENORBLANCO WIN LINUX : fast/backgrounds/size/backgroundSize10.html = IMAGE
     2905BUG_SENORBLANCO WIN LINUX : fast/backgrounds/size/backgroundSize11.html = IMAGE
     2906BUG_SENORBLANCO WIN LINUX : fast/backgrounds/size/backgroundSize12.html = IMAGE
     2907BUG_SENORBLANCO WIN LINUX : fast/backgrounds/size/backgroundSize13.html = IMAGE
     2908BUG_SENORBLANCO WIN LINUX : fast/backgrounds/size/backgroundSize14.html = IMAGE
     2909BUG_SENORBLANCO WIN LINUX : fast/backgrounds/size/backgroundSize15.html = IMAGE
     2910BUG_SENORBLANCO WIN LINUX : fast/backgrounds/size/backgroundSize16.html = IMAGE
     2911BUG_SENORBLANCO WIN LINUX : fast/backgrounds/size/backgroundSize17.html = IMAGE
     2912BUG_SENORBLANCO WIN LINUX : fast/backgrounds/size/backgroundSize18.html = IMAGE
     2913BUG_SENORBLANCO WIN LINUX : fast/backgrounds/size/backgroundSize19.html = IMAGE
     2914BUG_SENORBLANCO WIN LINUX : fast/backgrounds/size/backgroundSize20.html = IMAGE
     2915BUG_SENORBLANCO WIN LINUX : fast/backgrounds/size/backgroundSize21.html = IMAGE
     2916BUG_SENORBLANCO WIN LINUX : fast/backgrounds/size/backgroundSize22.html = IMAGE
     2917BUG_SENORBLANCO WIN LINUX : fast/block/positioning/replaced-inside-fixed-top-bottom.html = IMAGE
     2918BUG_SENORBLANCO WIN LINUX : fast/css/value-list-out-of-bounds-crash.html = IMAGE
     2919BUG_SENORBLANCO WIN LINUX : fast/events/pointer-events-2.html = IMAGE
     2920BUG_SENORBLANCO WIN LINUX : fast/forms/input-type-change.html = IMAGE
     2921BUG_SENORBLANCO WIN LINUX : fast/replaced/absolute-image-sizing.html = IMAGE
     2922BUG_SENORBLANCO WIN LINUX : fast/replaced/image-sizing.html = IMAGE
     2923BUG_SENORBLANCO WIN LINUX : tables/mozilla/bugs/bug101674.html = IMAGE
     2924BUG_SENORBLANCO WIN LINUX : tables/mozilla/bugs/bug11026.html = IMAGE
     2925BUG_SENORBLANCO WIN LINUX : tables/mozilla/bugs/bug1188.html = IMAGE
     2926BUG_SENORBLANCO WIN LINUX : tables/mozilla/bugs/bug1296.html = IMAGE
     2927BUG_SENORBLANCO WIN LINUX : tables/mozilla/bugs/bug1430.html = IMAGE
     2928BUG_SENORBLANCO WIN LINUX : tables/mozilla/bugs/bug14929.html = IMAGE
     2929BUG_SENORBLANCO WIN LINUX : tables/mozilla/bugs/bug15544.html = IMAGE
     2930BUG_SENORBLANCO WIN LINUX : tables/mozilla/bugs/bug2981-2.html = IMAGE
     2931BUG_SENORBLANCO WIN LINUX : tables/mozilla/bugs/bug4093.html = IMAGE
     2932BUG_SENORBLANCO WIN LINUX : tables/mozilla/bugs/bug4284.html = IMAGE
     2933BUG_SENORBLANCO WIN LINUX : tables/mozilla/bugs/bug4427.html = IMAGE
     2934BUG_SENORBLANCO WIN LINUX : tables/mozilla/bugs/bug56563.html = IMAGE
     2935BUG_SENORBLANCO WIN LINUX : tables/mozilla/bugs/bug625.html = IMAGE
     2936BUG_SENORBLANCO WIN LINUX : tables/mozilla/bugs/bug6404.html = IMAGE
     2937BUG_SENORBLANCO WIN LINUX : tables/mozilla/bugs/bug97383.html = IMAGE
     2938BUG_SENORBLANCO WIN LINUX : tables/mozilla/core/bloomberg.html = IMAGE
     2939BUG_SENORBLANCO WIN LINUX : tables/mozilla/core/col_widths_auto_autoFix.html = IMAGE
     2940BUG_SENORBLANCO WIN LINUX : tables/mozilla/core/misc.html = IMAGE
     2941BUG_SENORBLANCO WIN LINUX : tables/mozilla/marvin/tbody_valign_baseline.html = IMAGE
     2942BUG_SENORBLANCO WIN LINUX : tables/mozilla/marvin/tbody_valign_bottom.html = IMAGE
     2943BUG_SENORBLANCO WIN LINUX : tables/mozilla/marvin/tbody_valign_middle.html = IMAGE
     2944BUG_SENORBLANCO WIN LINUX : tables/mozilla/marvin/tbody_valign_top.html = IMAGE
     2945BUG_SENORBLANCO WIN LINUX : tables/mozilla/marvin/td_valign_baseline.html = IMAGE
     2946BUG_SENORBLANCO WIN LINUX : tables/mozilla/marvin/td_valign_bottom.html = IMAGE
     2947BUG_SENORBLANCO WIN LINUX : tables/mozilla/marvin/td_valign_middle.html = IMAGE
     2948BUG_SENORBLANCO WIN LINUX : tables/mozilla/marvin/td_valign_top.html = IMAGE
     2949BUG_SENORBLANCO WIN LINUX : tables/mozilla/marvin/tfoot_valign_baseline.html = IMAGE
     2950BUG_SENORBLANCO WIN LINUX : tables/mozilla/marvin/tfoot_valign_bottom.html = IMAGE
     2951BUG_SENORBLANCO WIN LINUX : tables/mozilla/marvin/tfoot_valign_middle.html = IMAGE
     2952BUG_SENORBLANCO WIN LINUX : tables/mozilla/marvin/tfoot_valign_top.html = IMAGE
     2953BUG_SENORBLANCO WIN LINUX : tables/mozilla/marvin/th_valign_baseline.html = IMAGE
     2954BUG_SENORBLANCO WIN LINUX : tables/mozilla/marvin/th_valign_bottom.html = IMAGE
     2955BUG_SENORBLANCO WIN LINUX : tables/mozilla/marvin/th_valign_middle.html = IMAGE
     2956BUG_SENORBLANCO WIN LINUX : tables/mozilla/marvin/th_valign_top.html = IMAGE
     2957BUG_SENORBLANCO WIN LINUX : tables/mozilla/marvin/thead_valign_baseline.html = IMAGE
     2958BUG_SENORBLANCO WIN LINUX : tables/mozilla/marvin/thead_valign_bottom.html = IMAGE
     2959BUG_SENORBLANCO WIN LINUX : tables/mozilla/marvin/thead_valign_middle.html = IMAGE
     2960BUG_SENORBLANCO WIN LINUX : tables/mozilla/marvin/thead_valign_top.html = IMAGE
     2961BUG_SENORBLANCO WIN LINUX : tables/mozilla/marvin/tr_valign_baseline.html = IMAGE
     2962BUG_SENORBLANCO WIN LINUX : tables/mozilla/marvin/tr_valign_bottom.html = IMAGE
     2963BUG_SENORBLANCO WIN LINUX : tables/mozilla/marvin/tr_valign_middle.html = IMAGE
     2964BUG_SENORBLANCO WIN LINUX : tables/mozilla/marvin/tr_valign_top.html = IMAGE
     2965BUG_SENORBLANCO WIN LINUX : tables/mozilla/other/cell_widths.html = IMAGE
     2966BUG_SENORBLANCO WIN LINUX : tables/mozilla_expected_failures/bugs/97619.html = IMAGE
     2967BUG_SENORBLANCO WIN LINUX : tables/mozilla_expected_failures/bugs/bug6933.html = IMAGE
     2968
     2969BUG_SENORBLANCO MAC : css2.1/t0804-c5510-padn-00-b-ag.html = IMAGE
     2970BUG_SENORBLANCO MAC : css2.1/t0905-c414-flt-01-d-g.html = IMAGE
     2971BUG_SENORBLANCO MAC : css2.1/t090501-c414-flt-02-d-g.html = IMAGE
     2972BUG_SENORBLANCO MAC : css2.1/t090501-c414-flt-03-b-g.html = IMAGE
     2973BUG_SENORBLANCO MAC : css2.1/t090501-c414-flt-ln-01-d-g.html = IMAGE
     2974BUG_SENORBLANCO MAC : css2.1/t090501-c5525-flt-l-00-b-g.html = IMAGE
     2975BUG_SENORBLANCO MAC : css2.1/t090501-c5525-flt-r-00-b-g.html = IMAGE
     2976BUG_SENORBLANCO MAC : css2.1/t100304-c43-rpl-bbx-00-d-g.html = IMAGE
     2977BUG_SENORBLANCO MAC : css2.1/t100304-c43-rpl-bbx-01-d-g.html = IMAGE
     2978BUG_SENORBLANCO MAC : css2.1/t1004-c5524-width-00-b-g.html = IMAGE
     2979BUG_SENORBLANCO MAC : css2.1/t100801-c544-valgn-02-d-agi.html = IMAGE
     2980BUG_SENORBLANCO MAC : css2.1/t100801-c544-valgn-03-d-agi.html = IMAGE
     2981BUG_SENORBLANCO MAC : css2.1/t100801-c544-valgn-04-d-agi.html = IMAGE
     2982BUG_SENORBLANCO MAC : fast/backgrounds/repeat/mask-negative-offset-repeat.html = IMAGE
     2983BUG_SENORBLANCO MAC : fast/backgrounds/size/backgroundSize01.html = IMAGE
     2984BUG_SENORBLANCO MAC : fast/backgrounds/size/backgroundSize05.html = IMAGE
     2985BUG_SENORBLANCO MAC : fast/backgrounds/size/backgroundSize06.html = IMAGE
     2986BUG_SENORBLANCO MAC : fast/backgrounds/size/backgroundSize07.html = IMAGE
     2987BUG_SENORBLANCO MAC : fast/backgrounds/size/backgroundSize08.html = IMAGE
     2988BUG_SENORBLANCO MAC : fast/backgrounds/size/backgroundSize09.html = IMAGE
     2989BUG_SENORBLANCO MAC : fast/backgrounds/size/backgroundSize10.html = IMAGE
     2990BUG_SENORBLANCO MAC : fast/backgrounds/size/backgroundSize11.html = IMAGE
     2991BUG_SENORBLANCO MAC : fast/backgrounds/size/backgroundSize12.html = IMAGE
     2992BUG_SENORBLANCO MAC : fast/backgrounds/size/backgroundSize16.html = IMAGE
     2993BUG_SENORBLANCO MAC : fast/backgrounds/size/backgroundSize17.html = IMAGE
     2994BUG_SENORBLANCO MAC : fast/backgrounds/size/backgroundSize18.html = IMAGE
     2995BUG_SENORBLANCO MAC : fast/backgrounds/size/backgroundSize19.html = IMAGE
     2996BUG_SENORBLANCO MAC : fast/backgrounds/size/backgroundSize20.html = IMAGE
     2997BUG_SENORBLANCO MAC : fast/backgrounds/size/backgroundSize21.html = IMAGE
     2998BUG_SENORBLANCO MAC : fast/backgrounds/size/backgroundSize22.html = IMAGE
     2999BUG_SENORBLANCO MAC : fast/backgrounds/size/zero.html = IMAGE
     3000BUG_SENORBLANCO MAC : fast/block/positioning/replaced-inside-fixed-top-bottom.html = IMAGE
     3001BUG_SENORBLANCO MAC : fast/canvas/canvas-as-image.html = IMAGE
     3002BUG_SENORBLANCO MAC : fast/css/value-list-out-of-bounds-crash.html = IMAGE
     3003BUG_SENORBLANCO MAC : fast/forms/input-type-change.html = IMAGE
     3004BUG_SENORBLANCO MAC : fast/replaced/001.html = IMAGE
     3005BUG_SENORBLANCO MAC : fast/replaced/002.html = IMAGE
     3006BUG_SENORBLANCO MAC : fast/replaced/003.html = IMAGE
     3007BUG_SENORBLANCO MAC : fast/replaced/absolute-image-sizing.html = IMAGE
     3008BUG_SENORBLANCO MAC : fast/replaced/image-sizing.html = IMAGE
     3009BUG_SENORBLANCO MAC : tables/mozilla/bugs/bug11026.html = IMAGE
     3010BUG_SENORBLANCO MAC : tables/mozilla/bugs/bug1188.html = IMAGE
     3011BUG_SENORBLANCO MAC : tables/mozilla/bugs/bug1296.html = IMAGE
     3012BUG_SENORBLANCO MAC : tables/mozilla/bugs/bug1430.html = IMAGE
     3013BUG_SENORBLANCO MAC : tables/mozilla/bugs/bug14929.html = IMAGE
     3014BUG_SENORBLANCO MAC : tables/mozilla/bugs/bug15544.html = IMAGE
     3015BUG_SENORBLANCO MAC : tables/mozilla/bugs/bug23235.html = IMAGE
     3016BUG_SENORBLANCO MAC : tables/mozilla/bugs/bug2981-2.html = IMAGE
     3017BUG_SENORBLANCO MAC : tables/mozilla/bugs/bug4093.html = IMAGE
     3018BUG_SENORBLANCO MAC : tables/mozilla/bugs/bug4284.html = IMAGE
     3019BUG_SENORBLANCO MAC : tables/mozilla/bugs/bug4427.html = IMAGE
     3020BUG_SENORBLANCO MAC : tables/mozilla/bugs/bug4523.html = IMAGE
     3021BUG_SENORBLANCO MAC : tables/mozilla/bugs/bug56563.html = IMAGE
     3022BUG_SENORBLANCO MAC : tables/mozilla/bugs/bug6404.html = IMAGE
     3023BUG_SENORBLANCO MAC : tables/mozilla/bugs/bug86708.html = IMAGE
     3024BUG_SENORBLANCO MAC : tables/mozilla/bugs/bug97383.html = IMAGE
     3025BUG_SENORBLANCO MAC : tables/mozilla/core/col_widths_auto_autoFix.html = IMAGE
     3026BUG_SENORBLANCO MAC : tables/mozilla/core/misc.html = IMAGE
     3027BUG_SENORBLANCO MAC : tables/mozilla/marvin/tbody_valign_baseline.html = IMAGE
     3028BUG_SENORBLANCO MAC : tables/mozilla/marvin/tbody_valign_bottom.html = IMAGE
     3029BUG_SENORBLANCO MAC : tables/mozilla/marvin/tbody_valign_middle.html = IMAGE
     3030BUG_SENORBLANCO MAC : tables/mozilla/marvin/tbody_valign_top.html = IMAGE
     3031BUG_SENORBLANCO MAC : tables/mozilla/marvin/td_valign_baseline.html = IMAGE
     3032BUG_SENORBLANCO MAC : tables/mozilla/marvin/td_valign_bottom.html = IMAGE
     3033BUG_SENORBLANCO MAC : tables/mozilla/marvin/td_valign_middle.html = IMAGE
     3034BUG_SENORBLANCO MAC : tables/mozilla/marvin/td_valign_top.html = IMAGE
     3035BUG_SENORBLANCO MAC : tables/mozilla/marvin/tfoot_valign_baseline.html = IMAGE
     3036BUG_SENORBLANCO MAC : tables/mozilla/marvin/tfoot_valign_bottom.html = IMAGE
     3037BUG_SENORBLANCO MAC : tables/mozilla/marvin/tfoot_valign_middle.html = IMAGE
     3038BUG_SENORBLANCO MAC : tables/mozilla/marvin/tfoot_valign_top.html = IMAGE
     3039BUG_SENORBLANCO MAC : tables/mozilla/marvin/th_valign_baseline.html = IMAGE
     3040BUG_SENORBLANCO MAC : tables/mozilla/marvin/th_valign_bottom.html = IMAGE
     3041BUG_SENORBLANCO MAC : tables/mozilla/marvin/th_valign_middle.html = IMAGE
     3042BUG_SENORBLANCO MAC : tables/mozilla/marvin/th_valign_top.html = IMAGE
     3043BUG_SENORBLANCO MAC : tables/mozilla/marvin/thead_valign_baseline.html = IMAGE
     3044BUG_SENORBLANCO MAC : tables/mozilla/marvin/thead_valign_bottom.html = IMAGE
     3045BUG_SENORBLANCO MAC : tables/mozilla/marvin/thead_valign_middle.html = IMAGE
     3046BUG_SENORBLANCO MAC : tables/mozilla/marvin/thead_valign_top.html = IMAGE
     3047BUG_SENORBLANCO MAC : tables/mozilla/marvin/tr_valign_baseline.html = IMAGE
     3048BUG_SENORBLANCO MAC : tables/mozilla/marvin/tr_valign_bottom.html = IMAGE
     3049BUG_SENORBLANCO MAC : tables/mozilla/marvin/tr_valign_middle.html = IMAGE
     3050BUG_SENORBLANCO MAC : tables/mozilla/marvin/tr_valign_top.html = IMAGE
     3051BUG_SENORBLANCO MAC : tables/mozilla_expected_failures/bugs/97619.html = IMAGE
     3052BUG_SENORBLANCO MAC : tables/mozilla_expected_failures/bugs/bug6933.html = IMAGE
  • trunk/WebCore/ChangeLog

    r61709 r61710  
     12010-06-23  Stephen White  <senorblanco@chromium.org>
     2
     3        Reviewed by David Hyatt.
     4
     5        This is a tweak to the resize algorithm introduced in r61341, and
     6        is a fix for the regression described in
     7        https://bugs.webkit.org/show_bug.cgi?id=41036
     8
     9        The goal is to bring back the some of old behaviour, without regressing
     10        too much of the performance gains in r61341.
     11
     12        The old algorithm was:
     13        - on first resize, draw in high quality and record the paint time
     14        - if we've already drawn at this size, use the same quality as last time
     15        - on subsequent resizes, if the resize occurs within X ms of the
     16          previous one, draw at low quality and set a timer (one timer per
     17          image).
     18        - when each timer expires, draw that image at high quality
     19
     20        The r61341 algorithm was: 
     21        - on first resize, draw the image in low quality, add it to a list of
     22          resized images, and set a timer (one timer for all images)
     23        - when the timer expires, redraw all resized images in high quality
     24
     25        The new algorithm is:
     26        - on first resize, if no other animated resizes are outstanding, draw in
     27          high quality and set the timer (one timer for all images)
     28        - if any images have been resized to two different sizes in the last
     29          X ms, draw all resized images in low quality and kick the timer
     30          forward
     31        - when the timer expires, if any animated resizes occured, redraw all
     32          resized images in high quality, and reset the flag
     33
     34        This should cause GUIMark and the IE9 demos to have good performance
     35        after the first frame, while other pages with only static resizes
     36        should be unaffected.
     37
     38        * rendering/RenderBoxModelObject.cpp:
     39        Change the LastPaintTimeMap to a LastPaintSizeMap:  we now record the
     40        last size an image was resized to, rather than the time it was painted
     41        (the time actually became redundant in r61341 when I added the
     42        check for m_timer.isActive():  we only care if anything is resizing
     43        while the timer is active).
     44        (WebCore::ImageQualityController::ImageQualityController):
     45        Add an initializer for the m_animatedResizeIsActive flag.
     46        (WebCore::ImageQualityController::objectDestroyed):
     47        Reset the m_animatedResizeIsActive flag if this was the last object
     48        in the list.
     49        (WebCore::ImageQualityController::highQualityRepaintTimerFired):
     50        Only repaint all the images if there was an animated resize (otherwise,
     51        everything is already high quality).
     52        (WebCore::ImageQualityController::shouldPaintAtLowQuality):
     53        Implement the above algorithm.
     54
    1552010-06-23  Abhishek Arya  <inferno@chromium.org>
    256
  • trunk/WebCore/rendering/RenderBoxModelObject.cpp

    r61341 r61710  
    5050static const double cLowQualityTimeThreshold = 0.500; // 500 ms
    5151
    52 typedef HashMap<RenderBoxModelObject*, double> LastPaintTimeMap;
     52typedef HashMap<RenderBoxModelObject*, IntSize> LastPaintSizeMap;
    5353
    5454class ImageQualityController : public Noncopyable {
     
    6262    void restartTimer();
    6363
    64     LastPaintTimeMap m_lastPaintTimeMap;
     64    LastPaintSizeMap m_lastPaintSizeMap;
    6565    Timer<ImageQualityController> m_timer;
     66    bool m_animatedResizeIsActive;
    6667};
    6768
    6869ImageQualityController::ImageQualityController()
    6970    : m_timer(this, &ImageQualityController::highQualityRepaintTimerFired)
     71    , m_animatedResizeIsActive(false)
    7072{
    7173}
     
    7375void ImageQualityController::objectDestroyed(RenderBoxModelObject* object)
    7476{
    75     m_lastPaintTimeMap.remove(object);
    76     if (m_lastPaintTimeMap.isEmpty())
     77    m_lastPaintSizeMap.remove(object);
     78    if (m_lastPaintSizeMap.isEmpty()) {
     79        m_animatedResizeIsActive = false;
    7780        m_timer.stop();
     81    }
    7882}
    7983   
    8084void ImageQualityController::highQualityRepaintTimerFired(Timer<ImageQualityController>*)
    8185{
    82     for (LastPaintTimeMap::iterator it = m_lastPaintTimeMap.begin(); it != m_lastPaintTimeMap.end(); ++it)
    83         it->first->repaint();
     86    if (m_animatedResizeIsActive) {
     87        m_animatedResizeIsActive = false;
     88        for (LastPaintSizeMap::iterator it = m_lastPaintSizeMap.begin(); it != m_lastPaintSizeMap.end(); ++it)
     89            it->first->repaint();
     90    }
    8491}
    8592
    8693void ImageQualityController::restartTimer()
    8794{
    88     m_timer.startOneShot(cLowQualityTimeThreshold * 1.05);
     95    m_timer.startOneShot(cLowQualityTimeThreshold);
    8996}
    9097
     
    101108
    102109    // Look ourselves up in the hashtable.
    103     LastPaintTimeMap::iterator i = m_lastPaintTimeMap.find(object);
     110    LastPaintSizeMap::iterator i = m_lastPaintSizeMap.find(object);
    104111
    105112    const AffineTransform& currentTransform = context->getCTM();
     
    107114    if (!contextIsScaled && imageSize == size) {
    108115        // There is no scale in effect. If we had a scale in effect before, we can just remove this object from the list.
    109         if (i != m_lastPaintTimeMap.end())
    110             m_lastPaintTimeMap.remove(object);
     116        if (i != m_lastPaintSizeMap.end())
     117            m_lastPaintSizeMap.remove(object);
    111118
    112119        return false;
     
    119126            return true;
    120127    }
    121     double newTime = currentTime();
    122     if (i != m_lastPaintTimeMap.end() && newTime - i->second >= cLowQualityTimeThreshold && !m_timer.isActive()) {
    123         // If it has been at least cLowQualityTimeThreshold seconds since the
    124         // last time a resize was requested, and the timer is no longer active,
    125         // draw at high quality and don't set the timer.
     128    // If this is the first time resizing this image, or its size is the
     129    // same as the last resize, draw at high res, but record the paint
     130    // size and set the timer.
     131    if (i == m_lastPaintSizeMap.end() || size == i->second) {
     132        restartTimer();
     133        m_lastPaintSizeMap.set(object, size);
     134        return false;
     135    }
     136    // If an animated resize is active, paint in low quality and kick the timer ahead.
     137    if (m_animatedResizeIsActive) {
     138        m_lastPaintSizeMap.set(object, size);
     139        restartTimer();
     140        return true;
     141    }
     142    // If the timer is no longer active, draw at high quality and don't
     143    // set the timer.
     144    if (!m_timer.isActive()) {
    126145        objectDestroyed(object);
    127146        return false;
    128147    }
    129     // Draw at low quality first and set a timer for high quality.
    130     m_lastPaintTimeMap.set(object, newTime);
     148    // This object has been resized to two different sizes while the timer
     149    // is active, so draw at low quality, set the flag for animated resizes and
     150    // the object to the list for high quality redraw.
     151    m_lastPaintSizeMap.set(object, size);
     152    m_animatedResizeIsActive = true;
    131153    restartTimer();
    132154    return true;
Note: See TracChangeset for help on using the changeset viewer.