| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 return InterpolationLow; | 84 return InterpolationLow; |
| 85 | 85 |
| 86 // For images that are potentially animated we paint them at medium quality. | 86 // For images that are potentially animated we paint them at medium quality. |
| 87 if (image && image->maybeAnimated()) | 87 if (image && image->maybeAnimated()) |
| 88 return InterpolationMedium; | 88 return InterpolationMedium; |
| 89 | 89 |
| 90 return InterpolationDefault; | 90 return InterpolationDefault; |
| 91 } | 91 } |
| 92 | 92 |
| 93 ImageQualityController::~ImageQualityController() { | 93 ImageQualityController::~ImageQualityController() { |
| 94 // This will catch users of ImageQualityController that forget to call | 94 // This will catch users of ImageQualityController that forget to call cleanUp
. |
| 95 // cleanUp. | |
| 96 ASSERT(!gImageQualityController || gImageQualityController->isEmpty()); | 95 ASSERT(!gImageQualityController || gImageQualityController->isEmpty()); |
| 97 } | 96 } |
| 98 | 97 |
| 99 ImageQualityController::ImageQualityController() | 98 ImageQualityController::ImageQualityController() |
| 100 : m_timer(wrapUnique(new Timer<ImageQualityController>( | 99 : m_timer(wrapUnique(new Timer<ImageQualityController>( |
| 101 this, | 100 this, |
| 102 &ImageQualityController::highQualityRepaintTimerFired))), | 101 &ImageQualityController::highQualityRepaintTimerFired))), |
| 103 m_frameTimeWhenTimerStarted(0.0) {} | 102 m_frameTimeWhenTimerStarted(0.0) {} |
| 104 | 103 |
| 105 void ImageQualityController::setTimer(std::unique_ptr<TimerBase> newTimer) { | 104 void ImageQualityController::setTimer(std::unique_ptr<TimerBase> newTimer) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 m_frameTimeWhenTimerStarted = lastFrameTimeMonotonic; | 160 m_frameTimeWhenTimerStarted = lastFrameTimeMonotonic; |
| 162 } | 161 } |
| 163 } | 162 } |
| 164 | 163 |
| 165 bool ImageQualityController::shouldPaintAtLowQuality( | 164 bool ImageQualityController::shouldPaintAtLowQuality( |
| 166 const LayoutObject& object, | 165 const LayoutObject& object, |
| 167 Image* image, | 166 Image* image, |
| 168 const void* layer, | 167 const void* layer, |
| 169 const LayoutSize& layoutSize, | 168 const LayoutSize& layoutSize, |
| 170 double lastFrameTimeMonotonic) { | 169 double lastFrameTimeMonotonic) { |
| 171 // If the image is not a bitmap image, then none of this is relevant and we | 170 // If the image is not a bitmap image, then none of this is relevant and we ju
st paint at high |
| 172 // just paint at high quality. | 171 // quality. |
| 173 if (!image || !image->isBitmapImage()) | 172 if (!image || !image->isBitmapImage()) |
| 174 return false; | 173 return false; |
| 175 | 174 |
| 176 if (!layer) | 175 if (!layer) |
| 177 return false; | 176 return false; |
| 178 | 177 |
| 179 if (object.style()->imageRendering() == ImageRenderingOptimizeContrast) | 178 if (object.style()->imageRendering() == ImageRenderingOptimizeContrast) |
| 180 return true; | 179 return true; |
| 181 | 180 |
| 182 if (LocalFrame* frame = object.frame()) { | 181 if (LocalFrame* frame = object.frame()) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 197 bool isFirstResize = true; | 196 bool isFirstResize = true; |
| 198 if (innerMap) { | 197 if (innerMap) { |
| 199 LayerSizeMap::iterator j = innerMap->find(layer); | 198 LayerSizeMap::iterator j = innerMap->find(layer); |
| 200 if (j != innerMap->end()) { | 199 if (j != innerMap->end()) { |
| 201 isFirstResize = false; | 200 isFirstResize = false; |
| 202 oldSize = j->value; | 201 oldSize = j->value; |
| 203 } | 202 } |
| 204 } | 203 } |
| 205 | 204 |
| 206 if (layoutSize == image->size()) { | 205 if (layoutSize == image->size()) { |
| 207 // There is no scale in effect. If we had a scale in effect before, we can | 206 // There is no scale in effect. If we had a scale in effect before, we can j
ust remove this object from the list. |
| 208 // just remove this object from the list. | |
| 209 removeLayer(object, innerMap, layer); | 207 removeLayer(object, innerMap, layer); |
| 210 return false; | 208 return false; |
| 211 } | 209 } |
| 212 | 210 |
| 213 // If an animated resize is active for this object, paint in low quality and | 211 // If an animated resize is active for this object, paint in low quality and k
ick the timer ahead. |
| 214 // kick the timer ahead. | |
| 215 if (objectIsResizing) { | 212 if (objectIsResizing) { |
| 216 bool sizesChanged = oldSize != layoutSize; | 213 bool sizesChanged = oldSize != layoutSize; |
| 217 set(object, innerMap, layer, layoutSize, sizesChanged); | 214 set(object, innerMap, layer, layoutSize, sizesChanged); |
| 218 if (sizesChanged) | 215 if (sizesChanged) |
| 219 restartTimer(lastFrameTimeMonotonic); | 216 restartTimer(lastFrameTimeMonotonic); |
| 220 return true; | 217 return true; |
| 221 } | 218 } |
| 222 // If this is the first time resizing this image, or its size is the | 219 // If this is the first time resizing this image, or its size is the |
| 223 // same as the last resize, draw at high res, but record the paint | 220 // same as the last resize, draw at high res, but record the paint |
| 224 // size and set the timer. | 221 // size and set the timer. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 235 } | 232 } |
| 236 // This object has been resized to two different sizes while the timer | 233 // This object has been resized to two different sizes while the timer |
| 237 // is active, so draw at low quality, set the flag for animated resizes and | 234 // is active, so draw at low quality, set the flag for animated resizes and |
| 238 // the object to the list for high quality redraw. | 235 // the object to the list for high quality redraw. |
| 239 set(object, innerMap, layer, layoutSize, true); | 236 set(object, innerMap, layer, layoutSize, true); |
| 240 restartTimer(lastFrameTimeMonotonic); | 237 restartTimer(lastFrameTimeMonotonic); |
| 241 return true; | 238 return true; |
| 242 } | 239 } |
| 243 | 240 |
| 244 } // namespace blink | 241 } // namespace blink |
| OLD | NEW |