| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 85 |
| 86 return InterpolationDefault; | 86 return InterpolationDefault; |
| 87 } | 87 } |
| 88 | 88 |
| 89 ImageQualityController::~ImageQualityController() | 89 ImageQualityController::~ImageQualityController() |
| 90 { | 90 { |
| 91 // This will catch users of ImageQualityController that forget to call clean
Up. | 91 // This will catch users of ImageQualityController that forget to call clean
Up. |
| 92 ASSERT(!gImageQualityController || gImageQualityController->isEmpty()); | 92 ASSERT(!gImageQualityController || gImageQualityController->isEmpty()); |
| 93 } | 93 } |
| 94 | 94 |
| 95 // FIXME(sky): m_liveResizeOptimizationIsActive is never set to true. |
| 95 ImageQualityController::ImageQualityController() | 96 ImageQualityController::ImageQualityController() |
| 96 : m_timer(this, &ImageQualityController::highQualityRepaintTimerFired) | 97 : m_timer(this, &ImageQualityController::highQualityRepaintTimerFired) |
| 97 , m_animatedResizeIsActive(false) | 98 , m_animatedResizeIsActive(false) |
| 98 , m_liveResizeOptimizationIsActive(false) | 99 , m_liveResizeOptimizationIsActive(false) |
| 99 { | 100 { |
| 100 } | 101 } |
| 101 | 102 |
| 102 void ImageQualityController::removeLayer(RenderObject* object, LayerSizeMap* inn
erMap, const void* layer) | 103 void ImageQualityController::removeLayer(RenderObject* object, LayerSizeMap* inn
erMap, const void* layer) |
| 103 { | 104 { |
| 104 if (innerMap) { | 105 if (innerMap) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 128 } | 129 } |
| 129 } | 130 } |
| 130 | 131 |
| 131 void ImageQualityController::highQualityRepaintTimerFired(Timer<ImageQualityCont
roller>*) | 132 void ImageQualityController::highQualityRepaintTimerFired(Timer<ImageQualityCont
roller>*) |
| 132 { | 133 { |
| 133 if (!m_animatedResizeIsActive && !m_liveResizeOptimizationIsActive) | 134 if (!m_animatedResizeIsActive && !m_liveResizeOptimizationIsActive) |
| 134 return; | 135 return; |
| 135 m_animatedResizeIsActive = false; | 136 m_animatedResizeIsActive = false; |
| 136 | 137 |
| 137 for (ObjectLayerSizeMap::iterator it = m_objectLayerSizeMap.begin(); it != m
_objectLayerSizeMap.end(); ++it) { | 138 for (ObjectLayerSizeMap::iterator it = m_objectLayerSizeMap.begin(); it != m
_objectLayerSizeMap.end(); ++it) { |
| 138 if (LocalFrame* frame = it->key->document().frame()) { | |
| 139 // If this renderer's containing FrameView is in live resize, punt t
he timer and hold back for now. | |
| 140 if (frame->view() && frame->view()->inLiveResize()) { | |
| 141 restartTimer(); | |
| 142 return; | |
| 143 } | |
| 144 } | |
| 145 it->key->setShouldDoFullPaintInvalidation(true); | 139 it->key->setShouldDoFullPaintInvalidation(true); |
| 146 } | 140 } |
| 147 | 141 |
| 148 m_liveResizeOptimizationIsActive = false; | 142 m_liveResizeOptimizationIsActive = false; |
| 149 } | 143 } |
| 150 | 144 |
| 151 void ImageQualityController::restartTimer() | 145 void ImageQualityController::restartTimer() |
| 152 { | 146 { |
| 153 m_timer.startOneShot(cLowQualityTimeThreshold, FROM_HERE); | 147 m_timer.startOneShot(cLowQualityTimeThreshold, FROM_HERE); |
| 154 } | 148 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 178 | 172 |
| 179 const AffineTransform& currentTransform = context->getCTM(); | 173 const AffineTransform& currentTransform = context->getCTM(); |
| 180 bool contextIsScaled = !currentTransform.isIdentityOrTranslationOrFlipped(); | 174 bool contextIsScaled = !currentTransform.isIdentityOrTranslationOrFlipped(); |
| 181 | 175 |
| 182 // Make sure to use the unzoomed image size, since if a full page zoom is in
effect, the image | 176 // Make sure to use the unzoomed image size, since if a full page zoom is in
effect, the image |
| 183 // is actually being scaled. | 177 // is actually being scaled. |
| 184 LayoutSize scaledImageSize = currentTransform.mapSize(image->size()); | 178 LayoutSize scaledImageSize = currentTransform.mapSize(image->size()); |
| 185 LayoutSize scaledLayoutSize = currentTransform.mapSize(roundedIntSize(layout
Size)); | 179 LayoutSize scaledLayoutSize = currentTransform.mapSize(roundedIntSize(layout
Size)); |
| 186 | 180 |
| 187 // If the containing FrameView is being resized, paint at low quality until
resizing is finished. | 181 // If the containing FrameView is being resized, paint at low quality until
resizing is finished. |
| 188 if (LocalFrame* frame = object->document().frame()) { | 182 if (m_liveResizeOptimizationIsActive) { |
| 189 bool frameViewIsCurrentlyInLiveResize = frame->view() && frame->view()->
inLiveResize(); | 183 // Live resize has ended, paint in HQ and remove this object from the li
st. |
| 190 if (frameViewIsCurrentlyInLiveResize) { | 184 removeLayer(object, innerMap, layer); |
| 191 set(object, innerMap, layer, scaledLayoutSize); | 185 return false; |
| 192 restartTimer(); | |
| 193 m_liveResizeOptimizationIsActive = true; | |
| 194 return true; | |
| 195 } | |
| 196 if (m_liveResizeOptimizationIsActive) { | |
| 197 // Live resize has ended, paint in HQ and remove this object from th
e list. | |
| 198 removeLayer(object, innerMap, layer); | |
| 199 return false; | |
| 200 } | |
| 201 } | 186 } |
| 202 | 187 |
| 203 // See crbug.com/382491. This test is insufficient to ensure that there is n
o scale | 188 // See crbug.com/382491. This test is insufficient to ensure that there is n
o scale |
| 204 // applied in the compositor, but it is probably adequate here. In the worst
case we | 189 // applied in the compositor, but it is probably adequate here. In the worst
case we |
| 205 // draw at high quality when we need not. | 190 // draw at high quality when we need not. |
| 206 if (!contextIsScaled && scaledLayoutSize == scaledImageSize) { | 191 if (!contextIsScaled && scaledLayoutSize == scaledImageSize) { |
| 207 // There is no scale in effect. If we had a scale in effect before, we c
an just remove this object from the list. | 192 // There is no scale in effect. If we had a scale in effect before, we c
an just remove this object from the list. |
| 208 removeLayer(object, innerMap, layer); | 193 removeLayer(object, innerMap, layer); |
| 209 return false; | 194 return false; |
| 210 } | 195 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 232 // This object has been resized to two different sizes while the timer | 217 // This object has been resized to two different sizes while the timer |
| 233 // is active, so draw at low quality, set the flag for animated resizes and | 218 // is active, so draw at low quality, set the flag for animated resizes and |
| 234 // the object to the list for high quality redraw. | 219 // the object to the list for high quality redraw. |
| 235 set(object, innerMap, layer, scaledLayoutSize); | 220 set(object, innerMap, layer, scaledLayoutSize); |
| 236 m_animatedResizeIsActive = true; | 221 m_animatedResizeIsActive = true; |
| 237 restartTimer(); | 222 restartTimer(); |
| 238 return true; | 223 return true; |
| 239 } | 224 } |
| 240 | 225 |
| 241 } // namespace blink | 226 } // namespace blink |
| OLD | NEW |