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

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

Issue 899163003: Move rendering/RenderObject to layout/LayoutObject. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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
« no previous file with comments | « Source/core/rendering/ImageQualityController.h ('k') | Source/core/rendering/LayoutState.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 static ImageQualityController* gImageQualityController = 0; 42 static ImageQualityController* gImageQualityController = 0;
43 43
44 ImageQualityController* ImageQualityController::imageQualityController() 44 ImageQualityController* ImageQualityController::imageQualityController()
45 { 45 {
46 if (!gImageQualityController) 46 if (!gImageQualityController)
47 gImageQualityController = new ImageQualityController; 47 gImageQualityController = new ImageQualityController;
48 48
49 return gImageQualityController; 49 return gImageQualityController;
50 } 50 }
51 51
52 void ImageQualityController::remove(RenderObject* renderer) 52 void ImageQualityController::remove(LayoutObject* renderer)
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 bool ImageQualityController::has(RenderObject* renderer) 63 bool ImageQualityController::has(LayoutObject* renderer)
64 { 64 {
65 return gImageQualityController && gImageQualityController->m_objectLayerSize Map.contains(renderer); 65 return gImageQualityController && gImageQualityController->m_objectLayerSize Map.contains(renderer);
66 } 66 }
67 67
68 InterpolationQuality ImageQualityController::chooseInterpolationQuality(Graphics Context* context, RenderObject* object, Image* image, const void* layer, const L ayoutSize& layoutSize) 68 InterpolationQuality ImageQualityController::chooseInterpolationQuality(Graphics Context* context, LayoutObject* object, Image* image, const void* layer, const L ayoutSize& layoutSize)
69 { 69 {
70 if (object->style()->imageRendering() == ImageRenderingPixelated) 70 if (object->style()->imageRendering() == ImageRenderingPixelated)
71 return InterpolationNone; 71 return InterpolationNone;
72 72
73 if (InterpolationDefault == InterpolationLow) 73 if (InterpolationDefault == InterpolationLow)
74 return InterpolationLow; 74 return InterpolationLow;
75 75
76 if (shouldPaintAtLowQuality(context, object, image, layer, layoutSize)) 76 if (shouldPaintAtLowQuality(context, object, image, layer, layoutSize))
77 return InterpolationLow; 77 return InterpolationLow;
78 78
(...skipping 10 matching lines...) Expand all
89 ASSERT(!gImageQualityController || gImageQualityController->isEmpty()); 89 ASSERT(!gImageQualityController || gImageQualityController->isEmpty());
90 } 90 }
91 91
92 ImageQualityController::ImageQualityController() 92 ImageQualityController::ImageQualityController()
93 : m_timer(this, &ImageQualityController::highQualityRepaintTimerFired) 93 : m_timer(this, &ImageQualityController::highQualityRepaintTimerFired)
94 , m_animatedResizeIsActive(false) 94 , m_animatedResizeIsActive(false)
95 , m_liveResizeOptimizationIsActive(false) 95 , m_liveResizeOptimizationIsActive(false)
96 { 96 {
97 } 97 }
98 98
99 void ImageQualityController::removeLayer(RenderObject* object, LayerSizeMap* inn erMap, const void* layer) 99 void ImageQualityController::removeLayer(LayoutObject* object, LayerSizeMap* inn erMap, const void* layer)
100 { 100 {
101 if (innerMap) { 101 if (innerMap) {
102 innerMap->remove(layer); 102 innerMap->remove(layer);
103 if (innerMap->isEmpty()) 103 if (innerMap->isEmpty())
104 objectDestroyed(object); 104 objectDestroyed(object);
105 } 105 }
106 } 106 }
107 107
108 void ImageQualityController::set(RenderObject* object, LayerSizeMap* innerMap, c onst void* layer, const LayoutSize& size) 108 void ImageQualityController::set(LayoutObject* object, LayerSizeMap* innerMap, c onst void* layer, const LayoutSize& size)
109 { 109 {
110 if (innerMap) 110 if (innerMap)
111 innerMap->set(layer, size); 111 innerMap->set(layer, size);
112 else { 112 else {
113 LayerSizeMap newInnerMap; 113 LayerSizeMap newInnerMap;
114 newInnerMap.set(layer, size); 114 newInnerMap.set(layer, size);
115 m_objectLayerSizeMap.set(object, newInnerMap); 115 m_objectLayerSizeMap.set(object, newInnerMap);
116 } 116 }
117 } 117 }
118 118
119 void ImageQualityController::objectDestroyed(RenderObject* object) 119 void ImageQualityController::objectDestroyed(LayoutObject* object)
120 { 120 {
121 m_objectLayerSizeMap.remove(object); 121 m_objectLayerSizeMap.remove(object);
122 if (m_objectLayerSizeMap.isEmpty()) { 122 if (m_objectLayerSizeMap.isEmpty()) {
123 m_animatedResizeIsActive = false; 123 m_animatedResizeIsActive = false;
124 m_timer.stop(); 124 m_timer.stop();
125 } 125 }
126 } 126 }
127 127
128 void ImageQualityController::highQualityRepaintTimerFired(Timer<ImageQualityCont roller>*) 128 void ImageQualityController::highQualityRepaintTimerFired(Timer<ImageQualityCont roller>*)
129 { 129 {
(...skipping 13 matching lines...) Expand all
143 } 143 }
144 144
145 m_liveResizeOptimizationIsActive = false; 145 m_liveResizeOptimizationIsActive = false;
146 } 146 }
147 147
148 void ImageQualityController::restartTimer() 148 void ImageQualityController::restartTimer()
149 { 149 {
150 m_timer.startOneShot(cLowQualityTimeThreshold, FROM_HERE); 150 m_timer.startOneShot(cLowQualityTimeThreshold, FROM_HERE);
151 } 151 }
152 152
153 bool ImageQualityController::shouldPaintAtLowQuality(GraphicsContext* context, R enderObject* object, Image* image, const void *layer, const LayoutSize& layoutSi ze) 153 bool ImageQualityController::shouldPaintAtLowQuality(GraphicsContext* context, L ayoutObject* object, Image* image, const void *layer, const LayoutSize& layoutSi ze)
154 { 154 {
155 // 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
156 // quality. 156 // quality.
157 if (!image || !image->isBitmapImage()) 157 if (!image || !image->isBitmapImage())
158 return false; 158 return false;
159 159
160 if (object->style()->imageRendering() == ImageRenderingOptimizeContrast) 160 if (object->style()->imageRendering() == ImageRenderingOptimizeContrast)
161 return true; 161 return true;
162 162
163 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) 163 if (RuntimeEnabledFeatures::slimmingPaintEnabled())
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 // This object has been resized to two different sizes while the timer 232 // This object has been resized to two different sizes while the timer
233 // is active, so draw at low quality, set the flag for animated resizes and 233 // is active, so draw at low quality, set the flag for animated resizes and
234 // the object to the list for high quality redraw. 234 // the object to the list for high quality redraw.
235 set(object, innerMap, layer, scaledLayoutSize); 235 set(object, innerMap, layer, scaledLayoutSize);
236 m_animatedResizeIsActive = true; 236 m_animatedResizeIsActive = true;
237 restartTimer(); 237 restartTimer();
238 return true; 238 return true;
239 } 239 }
240 240
241 } // namespace blink 241 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/rendering/ImageQualityController.h ('k') | Source/core/rendering/LayoutState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698