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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 { | 53 { |
54 if (gImageQualityController) { | 54 if (gImageQualityController) { |
55 gImageQualityController->objectDestroyed(renderer); | 55 gImageQualityController->objectDestroyed(renderer); |
56 if (gImageQualityController->isEmpty()) { | 56 if (gImageQualityController->isEmpty()) { |
57 delete gImageQualityController; | 57 delete gImageQualityController; |
58 gImageQualityController = 0; | 58 gImageQualityController = 0; |
59 } | 59 } |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
| 63 InterpolationQuality ImageQualityController::chooseInterpolationQuality(Graphics
Context* context, RenderObject* object, Image* image, const void* layer, const L
ayoutSize& layoutSize) |
| 64 { |
| 65 if (InterpolationDefault == InterpolationLow) |
| 66 return InterpolationLow; |
| 67 |
| 68 if (shouldPaintAtLowQuality(context, object, image, layer, layoutSize)) |
| 69 return InterpolationLow; |
| 70 |
| 71 // For images that are potentially animated we paint them at medium quality. |
| 72 if (image && image->maybeAnimated()) |
| 73 return InterpolationMedium; |
| 74 |
| 75 return InterpolationDefault; |
| 76 } |
| 77 |
63 ImageQualityController::~ImageQualityController() | 78 ImageQualityController::~ImageQualityController() |
64 { | 79 { |
65 // This will catch users of ImageQualityController that forget to call clean
Up. | 80 // This will catch users of ImageQualityController that forget to call clean
Up. |
66 ASSERT(!gImageQualityController || gImageQualityController->isEmpty()); | 81 ASSERT(!gImageQualityController || gImageQualityController->isEmpty()); |
67 } | 82 } |
68 | 83 |
69 ImageQualityController::ImageQualityController() | 84 ImageQualityController::ImageQualityController() |
70 : m_timer(this, &ImageQualityController::highQualityRepaintTimerFired) | 85 : m_timer(this, &ImageQualityController::highQualityRepaintTimerFired) |
71 , m_animatedResizeIsActive(false) | 86 , m_animatedResizeIsActive(false) |
72 , m_liveResizeOptimizationIsActive(false) | 87 , m_liveResizeOptimizationIsActive(false) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 bool ImageQualityController::shouldPaintAtLowQuality(GraphicsContext* context, R
enderObject* object, Image* image, const void *layer, const LayoutSize& layoutSi
ze) | 145 bool ImageQualityController::shouldPaintAtLowQuality(GraphicsContext* context, R
enderObject* object, Image* image, const void *layer, const LayoutSize& layoutSi
ze) |
131 { | 146 { |
132 // If the image is not a bitmap image, then none of this is relevant and we
just paint at high | 147 // If the image is not a bitmap image, then none of this is relevant and we
just paint at high |
133 // quality. | 148 // quality. |
134 if (!image || !image->isBitmapImage() || context->paintingDisabled()) | 149 if (!image || !image->isBitmapImage() || context->paintingDisabled()) |
135 return false; | 150 return false; |
136 | 151 |
137 if (object->style()->imageRendering() == ImageRenderingOptimizeContrast) | 152 if (object->style()->imageRendering() == ImageRenderingOptimizeContrast) |
138 return true; | 153 return true; |
139 | 154 |
140 // For images that are potentially animated we paint them at low quality. | |
141 if (image->maybeAnimated()) | |
142 return true; | |
143 | |
144 // Look ourselves up in the hashtables. | 155 // Look ourselves up in the hashtables. |
145 ObjectLayerSizeMap::iterator i = m_objectLayerSizeMap.find(object); | 156 ObjectLayerSizeMap::iterator i = m_objectLayerSizeMap.find(object); |
146 LayerSizeMap* innerMap = i != m_objectLayerSizeMap.end() ? &i->value : 0; | 157 LayerSizeMap* innerMap = i != m_objectLayerSizeMap.end() ? &i->value : 0; |
147 LayoutSize oldSize; | 158 LayoutSize oldSize; |
148 bool isFirstResize = true; | 159 bool isFirstResize = true; |
149 if (innerMap) { | 160 if (innerMap) { |
150 LayerSizeMap::iterator j = innerMap->find(layer); | 161 LayerSizeMap::iterator j = innerMap->find(layer); |
151 if (j != innerMap->end()) { | 162 if (j != innerMap->end()) { |
152 isFirstResize = false; | 163 isFirstResize = false; |
153 oldSize = j->value; | 164 oldSize = j->value; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 // This object has been resized to two different sizes while the timer | 218 // 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 | 219 // is active, so draw at low quality, set the flag for animated resizes and |
209 // the object to the list for high quality redraw. | 220 // the object to the list for high quality redraw. |
210 set(object, innerMap, layer, scaledLayoutSize); | 221 set(object, innerMap, layer, scaledLayoutSize); |
211 m_animatedResizeIsActive = true; | 222 m_animatedResizeIsActive = true; |
212 restartTimer(); | 223 restartTimer(); |
213 return true; | 224 return true; |
214 } | 225 } |
215 | 226 |
216 } // namespace WebCore | 227 } // namespace WebCore |
OLD | NEW |