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

Side by Side Diff: Source/core/rendering/ImageQualityController.cpp

Issue 201513003: Implement InterpolationMedium to filter animated images (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 (shouldPaintAtLowQuality(context, object, image, layer, layoutSize))
66 return InterpolationLow;
Stephen White 2014/03/18 17:26:43 We actually might want to consider using Medium he
Alpha Left Google 2014/03/18 22:59:13 That's right. We can update that later.
67
68 // For images that are potentially animated we paint them at low quality.
Stephen Chennney 2014/03/18 12:56:32 This comment doesn't seem to match the code. Is th
Alpha Left Google 2014/03/18 22:59:13 The code is correct. I've updated the comments.
69 if (image && image->maybeAnimated())
70 return InterpolationMedium;
71
72 return InterpolationDefault;
73 }
74
63 ImageQualityController::~ImageQualityController() 75 ImageQualityController::~ImageQualityController()
64 { 76 {
65 // This will catch users of ImageQualityController that forget to call clean Up. 77 // This will catch users of ImageQualityController that forget to call clean Up.
66 ASSERT(!gImageQualityController || gImageQualityController->isEmpty()); 78 ASSERT(!gImageQualityController || gImageQualityController->isEmpty());
67 } 79 }
68 80
69 ImageQualityController::ImageQualityController() 81 ImageQualityController::ImageQualityController()
70 : m_timer(this, &ImageQualityController::highQualityRepaintTimerFired) 82 : m_timer(this, &ImageQualityController::highQualityRepaintTimerFired)
71 , m_animatedResizeIsActive(false) 83 , m_animatedResizeIsActive(false)
72 , m_liveResizeOptimizationIsActive(false) 84 , m_liveResizeOptimizationIsActive(false)
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 bool ImageQualityController::shouldPaintAtLowQuality(GraphicsContext* context, R enderObject* object, Image* image, const void *layer, const LayoutSize& layoutSi ze) 142 bool ImageQualityController::shouldPaintAtLowQuality(GraphicsContext* context, R enderObject* object, Image* image, const void *layer, const LayoutSize& layoutSi ze)
131 { 143 {
132 // If the image is not a bitmap image, then none of this is relevant and we just paint at high 144 // If the image is not a bitmap image, then none of this is relevant and we just paint at high
133 // quality. 145 // quality.
134 if (!image || !image->isBitmapImage() || context->paintingDisabled()) 146 if (!image || !image->isBitmapImage() || context->paintingDisabled())
135 return false; 147 return false;
136 148
137 if (object->style()->imageRendering() == ImageRenderingOptimizeContrast) 149 if (object->style()->imageRendering() == ImageRenderingOptimizeContrast)
138 return true; 150 return true;
139 151
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. 152 // Look ourselves up in the hashtables.
145 ObjectLayerSizeMap::iterator i = m_objectLayerSizeMap.find(object); 153 ObjectLayerSizeMap::iterator i = m_objectLayerSizeMap.find(object);
146 LayerSizeMap* innerMap = i != m_objectLayerSizeMap.end() ? &i->value : 0; 154 LayerSizeMap* innerMap = i != m_objectLayerSizeMap.end() ? &i->value : 0;
147 LayoutSize oldSize; 155 LayoutSize oldSize;
148 bool isFirstResize = true; 156 bool isFirstResize = true;
149 if (innerMap) { 157 if (innerMap) {
150 LayerSizeMap::iterator j = innerMap->find(layer); 158 LayerSizeMap::iterator j = innerMap->find(layer);
151 if (j != innerMap->end()) { 159 if (j != innerMap->end()) {
152 isFirstResize = false; 160 isFirstResize = false;
153 oldSize = j->value; 161 oldSize = j->value;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 // This object has been resized to two different sizes while the timer 215 // 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 216 // is active, so draw at low quality, set the flag for animated resizes and
209 // the object to the list for high quality redraw. 217 // the object to the list for high quality redraw.
210 set(object, innerMap, layer, scaledLayoutSize); 218 set(object, innerMap, layer, scaledLayoutSize);
211 m_animatedResizeIsActive = true; 219 m_animatedResizeIsActive = true;
212 restartTimer(); 220 restartTimer();
213 return true; 221 return true;
214 } 222 }
215 223
216 } // namespace WebCore 224 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698