| 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 17 matching lines...) Expand all Loading... |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "core/layout/ImageQualityController.h" | 31 #include "core/layout/ImageQualityController.h" |
| 32 | 32 |
| 33 #include "core/frame/FrameView.h" | 33 #include "core/frame/FrameView.h" |
| 34 #include "core/frame/LocalFrame.h" | 34 #include "core/frame/LocalFrame.h" |
| 35 #include "core/frame/Settings.h" | 35 #include "core/frame/Settings.h" |
| 36 #include "core/page/ChromeClient.h" | 36 #include "core/page/ChromeClient.h" |
| 37 #include "core/page/Page.h" | 37 #include "core/page/Page.h" |
| 38 #include "wtf/PtrUtil.h" | |
| 39 | 38 |
| 40 namespace blink { | 39 namespace blink { |
| 41 | 40 |
| 42 const double ImageQualityController::cLowQualityTimeThreshold = 0.500; // 500 ms | 41 const double ImageQualityController::cLowQualityTimeThreshold = 0.500; // 500 ms |
| 43 const double ImageQualityController::cTimerRestartThreshold = 0.250; // 250 ms | 42 const double ImageQualityController::cTimerRestartThreshold = 0.250; // 250 ms |
| 44 | 43 |
| 45 static ImageQualityController* gImageQualityController = nullptr; | 44 static ImageQualityController* gImageQualityController = nullptr; |
| 46 | 45 |
| 47 ImageQualityController* ImageQualityController::imageQualityController() | 46 ImageQualityController* ImageQualityController::imageQualityController() |
| 48 { | 47 { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 // This will catch users of ImageQualityController that forget to call clean
Up. | 90 // This will catch users of ImageQualityController that forget to call clean
Up. |
| 92 ASSERT(!gImageQualityController || gImageQualityController->isEmpty()); | 91 ASSERT(!gImageQualityController || gImageQualityController->isEmpty()); |
| 93 } | 92 } |
| 94 | 93 |
| 95 ImageQualityController::ImageQualityController() | 94 ImageQualityController::ImageQualityController() |
| 96 : m_timer(wrapUnique(new Timer<ImageQualityController>(this, &ImageQualityCo
ntroller::highQualityRepaintTimerFired))) | 95 : m_timer(wrapUnique(new Timer<ImageQualityController>(this, &ImageQualityCo
ntroller::highQualityRepaintTimerFired))) |
| 97 , m_frameTimeWhenTimerStarted(0.0) | 96 , m_frameTimeWhenTimerStarted(0.0) |
| 98 { | 97 { |
| 99 } | 98 } |
| 100 | 99 |
| 101 void ImageQualityController::setTimer(Timer<ImageQualityController>* newTimer) | 100 void ImageQualityController::setTimer(std::unique_ptr<TimerBase> newTimer) |
| 102 { | 101 { |
| 103 m_timer = wrapUnique(newTimer); | 102 m_timer = std::move(newTimer); |
| 104 } | 103 } |
| 105 | 104 |
| 106 void ImageQualityController::removeLayer(const LayoutObject& object, LayerSizeMa
p* innerMap, const void* layer) | 105 void ImageQualityController::removeLayer(const LayoutObject& object, LayerSizeMa
p* innerMap, const void* layer) |
| 107 { | 106 { |
| 108 if (innerMap) { | 107 if (innerMap) { |
| 109 innerMap->remove(layer); | 108 innerMap->remove(layer); |
| 110 if (innerMap->isEmpty()) | 109 if (innerMap->isEmpty()) |
| 111 objectDestroyed(object); | 110 objectDestroyed(object); |
| 112 } | 111 } |
| 113 } | 112 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 126 } | 125 } |
| 127 | 126 |
| 128 void ImageQualityController::objectDestroyed(const LayoutObject& object) | 127 void ImageQualityController::objectDestroyed(const LayoutObject& object) |
| 129 { | 128 { |
| 130 m_objectLayerSizeMap.remove(&object); | 129 m_objectLayerSizeMap.remove(&object); |
| 131 if (m_objectLayerSizeMap.isEmpty()) { | 130 if (m_objectLayerSizeMap.isEmpty()) { |
| 132 m_timer->stop(); | 131 m_timer->stop(); |
| 133 } | 132 } |
| 134 } | 133 } |
| 135 | 134 |
| 136 void ImageQualityController::highQualityRepaintTimerFired(Timer<ImageQualityCont
roller>*) | 135 void ImageQualityController::highQualityRepaintTimerFired(TimerBase*) |
| 137 { | 136 { |
| 138 for (auto& i : m_objectLayerSizeMap) { | 137 for (auto& i : m_objectLayerSizeMap) { |
| 139 // Only invalidate the object if it is animating. | 138 // Only invalidate the object if it is animating. |
| 140 if (!i.value.isResizing) | 139 if (!i.value.isResizing) |
| 141 continue; | 140 continue; |
| 142 | 141 |
| 143 // TODO(wangxianzhu): Use LayoutObject::getMutableForPainting(). | 142 // TODO(wangxianzhu): Use LayoutObject::getMutableForPainting(). |
| 144 const_cast<LayoutObject*>(i.key)->setShouldDoFullPaintInvalidation(); | 143 const_cast<LayoutObject*>(i.key)->setShouldDoFullPaintInvalidation(); |
| 145 i.value.isResizing = false; | 144 i.value.isResizing = false; |
| 146 } | 145 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 } | 220 } |
| 222 // This object has been resized to two different sizes while the timer | 221 // This object has been resized to two different sizes while the timer |
| 223 // is active, so draw at low quality, set the flag for animated resizes and | 222 // is active, so draw at low quality, set the flag for animated resizes and |
| 224 // the object to the list for high quality redraw. | 223 // the object to the list for high quality redraw. |
| 225 set(object, innerMap, layer, layoutSize, true); | 224 set(object, innerMap, layer, layoutSize, true); |
| 226 restartTimer(lastFrameTimeMonotonic); | 225 restartTimer(lastFrameTimeMonotonic); |
| 227 return true; | 226 return true; |
| 228 } | 227 } |
| 229 | 228 |
| 230 } // namespace blink | 229 } // namespace blink |
| OLD | NEW |