Chromium Code Reviews| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 continue; | 135 continue; |
| 136 | 136 |
| 137 // TODO(wangxianzhu): Use LayoutObject::getMutableForPainting(). | 137 // TODO(wangxianzhu): Use LayoutObject::getMutableForPainting(). |
| 138 const_cast<LayoutObject*>(i.key)->setShouldDoFullPaintInvalidation(); | 138 const_cast<LayoutObject*>(i.key)->setShouldDoFullPaintInvalidation(); |
| 139 i.value.isResizing = false; | 139 i.value.isResizing = false; |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 | 142 |
| 143 void ImageQualityController::restartTimer() | 143 void ImageQualityController::restartTimer() |
| 144 { | 144 { |
| 145 m_timer->startOneShot(cLowQualityTimeThreshold, BLINK_FROM_HERE); | 145 // Avoid reposting the timer if it's already active. While it does cancel |
|
chrishtr
2016/04/21 20:30:59
restartTimer() is called in order to push the 500m
| |
| 146 // the previous one, the MessageLoop does not actually support cancelation | |
| 147 // which means on a page with hundreds of images we end up processing | |
| 148 // hundreds of cancelled tasks. | |
| 149 if (!m_timer->isActive()) | |
| 150 m_timer->startOneShot(cLowQualityTimeThreshold, BLINK_FROM_HERE); | |
| 146 } | 151 } |
| 147 | 152 |
| 148 bool ImageQualityController::shouldPaintAtLowQuality(const LayoutObject& object, Image* image, const void *layer, const LayoutSize& layoutSize) | 153 bool ImageQualityController::shouldPaintAtLowQuality(const LayoutObject& object, Image* image, const void *layer, const LayoutSize& layoutSize) |
| 149 { | 154 { |
| 150 // If the image is not a bitmap image, then none of this is relevant and we just paint at high | 155 // If the image is not a bitmap image, then none of this is relevant and we just paint at high |
| 151 // quality. | 156 // quality. |
| 152 if (!image || !image->isBitmapImage()) | 157 if (!image || !image->isBitmapImage()) |
| 153 return false; | 158 return false; |
| 154 | 159 |
| 155 if (!layer) | 160 if (!layer) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 } | 211 } |
| 207 // This object has been resized to two different sizes while the timer | 212 // This object has been resized to two different sizes while the timer |
| 208 // is active, so draw at low quality, set the flag for animated resizes and | 213 // is active, so draw at low quality, set the flag for animated resizes and |
| 209 // the object to the list for high quality redraw. | 214 // the object to the list for high quality redraw. |
| 210 set(object, innerMap, layer, layoutSize, true); | 215 set(object, innerMap, layer, layoutSize, true); |
| 211 restartTimer(); | 216 restartTimer(); |
| 212 return true; | 217 return true; |
| 213 } | 218 } |
| 214 | 219 |
| 215 } // namespace blink | 220 } // namespace blink |
| OLD | NEW |