Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: third_party/WebKit/Source/core/layout/ImageQualityController.cpp

Issue 2391893004: Reformat comments in core/layout up until LayoutBox (Closed)
Patch Set: Rebase w/HEAD (again) Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 cleanUp . 94 // This will catch users of ImageQualityController that forget to call
95 // cleanUp.
95 ASSERT(!gImageQualityController || gImageQualityController->isEmpty()); 96 ASSERT(!gImageQualityController || gImageQualityController->isEmpty());
96 } 97 }
97 98
98 ImageQualityController::ImageQualityController() 99 ImageQualityController::ImageQualityController()
99 : m_timer(wrapUnique(new Timer<ImageQualityController>( 100 : m_timer(wrapUnique(new Timer<ImageQualityController>(
100 this, 101 this,
101 &ImageQualityController::highQualityRepaintTimerFired))), 102 &ImageQualityController::highQualityRepaintTimerFired))),
102 m_frameTimeWhenTimerStarted(0.0) {} 103 m_frameTimeWhenTimerStarted(0.0) {}
103 104
104 void ImageQualityController::setTimer(std::unique_ptr<TimerBase> newTimer) { 105 void ImageQualityController::setTimer(std::unique_ptr<TimerBase> newTimer) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 m_frameTimeWhenTimerStarted = lastFrameTimeMonotonic; 161 m_frameTimeWhenTimerStarted = lastFrameTimeMonotonic;
161 } 162 }
162 } 163 }
163 164
164 bool ImageQualityController::shouldPaintAtLowQuality( 165 bool ImageQualityController::shouldPaintAtLowQuality(
165 const LayoutObject& object, 166 const LayoutObject& object,
166 Image* image, 167 Image* image,
167 const void* layer, 168 const void* layer,
168 const LayoutSize& layoutSize, 169 const LayoutSize& layoutSize,
169 double lastFrameTimeMonotonic) { 170 double lastFrameTimeMonotonic) {
170 // If the image is not a bitmap image, then none of this is relevant and we ju st paint at high 171 // If the image is not a bitmap image, then none of this is relevant and we
171 // quality. 172 // just paint at high quality.
172 if (!image || !image->isBitmapImage()) 173 if (!image || !image->isBitmapImage())
173 return false; 174 return false;
174 175
175 if (!layer) 176 if (!layer)
176 return false; 177 return false;
177 178
178 if (object.style()->imageRendering() == ImageRenderingOptimizeContrast) 179 if (object.style()->imageRendering() == ImageRenderingOptimizeContrast)
179 return true; 180 return true;
180 181
181 if (LocalFrame* frame = object.frame()) { 182 if (LocalFrame* frame = object.frame()) {
(...skipping 14 matching lines...) Expand all
196 bool isFirstResize = true; 197 bool isFirstResize = true;
197 if (innerMap) { 198 if (innerMap) {
198 LayerSizeMap::iterator j = innerMap->find(layer); 199 LayerSizeMap::iterator j = innerMap->find(layer);
199 if (j != innerMap->end()) { 200 if (j != innerMap->end()) {
200 isFirstResize = false; 201 isFirstResize = false;
201 oldSize = j->value; 202 oldSize = j->value;
202 } 203 }
203 } 204 }
204 205
205 if (layoutSize == image->size()) { 206 if (layoutSize == image->size()) {
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. 207 // There is no scale in effect. If we had a scale in effect before, we can
208 // just remove this object from the list.
207 removeLayer(object, innerMap, layer); 209 removeLayer(object, innerMap, layer);
208 return false; 210 return false;
209 } 211 }
210 212
211 // If an animated resize is active for this object, paint in low quality and k ick the timer ahead. 213 // If an animated resize is active for this object, paint in low quality and
214 // kick the timer ahead.
212 if (objectIsResizing) { 215 if (objectIsResizing) {
213 bool sizesChanged = oldSize != layoutSize; 216 bool sizesChanged = oldSize != layoutSize;
214 set(object, innerMap, layer, layoutSize, sizesChanged); 217 set(object, innerMap, layer, layoutSize, sizesChanged);
215 if (sizesChanged) 218 if (sizesChanged)
216 restartTimer(lastFrameTimeMonotonic); 219 restartTimer(lastFrameTimeMonotonic);
217 return true; 220 return true;
218 } 221 }
219 // If this is the first time resizing this image, or its size is the 222 // If this is the first time resizing this image, or its size is the
220 // same as the last resize, draw at high res, but record the paint 223 // same as the last resize, draw at high res, but record the paint
221 // size and set the timer. 224 // size and set the timer.
(...skipping 10 matching lines...) Expand all
232 } 235 }
233 // This object has been resized to two different sizes while the timer 236 // This object has been resized to two different sizes while the timer
234 // is active, so draw at low quality, set the flag for animated resizes and 237 // is active, so draw at low quality, set the flag for animated resizes and
235 // the object to the list for high quality redraw. 238 // the object to the list for high quality redraw.
236 set(object, innerMap, layer, layoutSize, true); 239 set(object, innerMap, layer, layoutSize, true);
237 restartTimer(lastFrameTimeMonotonic); 240 restartTimer(lastFrameTimeMonotonic);
238 return true; 241 return true;
239 } 242 }
240 243
241 } // namespace blink 244 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698