OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ExpensiveCanvasHeuristicParameters_h | 5 #ifndef ExpensiveCanvasHeuristicParameters_h |
6 #define ExpensiveCanvasHeuristicParameters_h | 6 #define ExpensiveCanvasHeuristicParameters_h |
7 | 7 |
8 namespace blink { | 8 namespace blink { |
9 | 9 |
10 namespace ExpensiveCanvasHeuristicParameters { | 10 namespace ExpensiveCanvasHeuristicParameters { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 }; // enum | 87 }; // enum |
88 | 88 |
89 // Constants and Coefficients for 2D Canvas Dynamic Rendering Mode Switching | 89 // Constants and Coefficients for 2D Canvas Dynamic Rendering Mode Switching |
90 // ========================================================================= | 90 // ========================================================================= |
91 | 91 |
92 // Approximate relative costs of different types of operations for the | 92 // Approximate relative costs of different types of operations for the |
93 // accelerated rendering pipeline and the recording rendering pipeline. | 93 // accelerated rendering pipeline and the recording rendering pipeline. |
94 // These costs were estimated experimentally using the tools located in the | 94 // These costs were estimated experimentally using the tools located in the |
95 // third_party/WebKit/Source/modules/canvas2d/performance_analysis directory. | 95 // third_party/WebKit/Source/modules/canvas2d/performance_analysis directory. |
96 | 96 |
97 // The RenderingModeCostIndex enum is used to access the heuristic coefficients
that correspond | 97 // The RenderingModeCostIndex enum is used to access the heuristic coefficients |
98 // to a given rendering mode. For exmaple, FillRectFixedCost[RecordingModeIndex]
is the estimated | 98 // that correspond to a given rendering mode. For exmaple, |
99 // fixed cost for FillRect in recording mode. | 99 // FillRectFixedCost[RecordingModeIndex] is the estimated fixed cost for |
| 100 // FillRect in recording mode. |
100 enum RenderingModeCostIndex { | 101 enum RenderingModeCostIndex { |
101 RecordingModeIndex = 0, | 102 RecordingModeIndex = 0, |
102 AcceleratedModeIndex = 1, | 103 AcceleratedModeIndex = 1, |
103 NumRederingModesCostIdexes = 2 | 104 NumRederingModesCostIdexes = 2 |
104 }; | 105 }; |
105 | 106 |
106 const float FillRectFixedCost[NumRederingModesCostIdexes] = {6.190e-03f, | 107 const float FillRectFixedCost[NumRederingModesCostIdexes] = {6.190e-03f, |
107 7.715e-03f}; | 108 7.715e-03f}; |
108 const float FillConvexPathFixedCost[NumRederingModesCostIdexes] = {1.251e-02f, | 109 const float FillConvexPathFixedCost[NumRederingModesCostIdexes] = {1.251e-02f, |
109 1.231e-02f}; | 110 1.231e-02f}; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 const float DrawSVGImageFixedCost[NumRederingModesCostIdexes] = {1.431e-01f, | 163 const float DrawSVGImageFixedCost[NumRederingModesCostIdexes] = {1.431e-01f, |
163 2.958e-01f}; | 164 2.958e-01f}; |
164 const float DrawPNGImageFixedCost[NumRederingModesCostIdexes] = {1.278e-02f, | 165 const float DrawPNGImageFixedCost[NumRederingModesCostIdexes] = {1.278e-02f, |
165 1.306e-02f}; | 166 1.306e-02f}; |
166 | 167 |
167 const float DrawSVGImageVariableCostPerArea[NumRederingModesCostIdexes] = { | 168 const float DrawSVGImageVariableCostPerArea[NumRederingModesCostIdexes] = { |
168 1.030e-05f, 4.463e-06f}; | 169 1.030e-05f, 4.463e-06f}; |
169 const float DrawPNGImageVariableCostPerArea[NumRederingModesCostIdexes] = { | 170 const float DrawPNGImageVariableCostPerArea[NumRederingModesCostIdexes] = { |
170 1.727e-06f, 0.0f}; | 171 1.727e-06f, 0.0f}; |
171 | 172 |
172 // Two conditions must be met before the isAccelerationOptimalForCanvasContent h
euristics recommends | 173 // Two conditions must be met before the isAccelerationOptimalForCanvasContent |
173 // switching out of the accelerated mode. | 174 // heuristics recommends switching out of the accelerated mode: |
174 // 1. The difference in estimated cost per frame is larger than MinCostPerFram
eImprovementToSuggestDisableAcceleration. | 175 // 1. The difference in estimated cost per frame is larger than |
175 // This ensures that the overhead involved in a switch of rendering mode an
d the risk of making a wrong decision | 176 // MinCostPerFrameImprovementToSuggestDisableAcceleration. This ensures |
176 // are justified by a large expected increased performance. | 177 // that the overhead involved in a switch of rendering mode and the risk of |
177 // 2. The percent reduction in rendering cost is larger than MinPercentageImpr
ovementToSuggestDisableAcceleration. | 178 // making a wrong decision are justified by a large expected increased |
178 // This ensures that there is a high level of confidence that the performan
ce would be improved in recording mode. | 179 // performance. |
| 180 // 2. The percent reduction in rendering cost is larger than |
| 181 // MinPercentageImprovementToSuggestDisableAcceleration. This ensures that |
| 182 // there is a high level of confidence that the performance would be |
| 183 // improved in recording mode. |
179 const float MinCostPerFrameImprovementToSuggestDisableAcceleration = 15.0f; | 184 const float MinCostPerFrameImprovementToSuggestDisableAcceleration = 15.0f; |
180 const float MinPercentageImprovementToSuggestDisableAcceleration = 30.0f; | 185 const float MinPercentageImprovementToSuggestDisableAcceleration = 30.0f; |
181 | 186 |
182 // Minimum number of frames that need to be rendered | 187 // Minimum number of frames that need to be rendered |
183 // before the rendering pipeline may be switched. Having this set | 188 // before the rendering pipeline may be switched. Having this set |
184 // to more than 1 increases the sample size of usage data before a | 189 // to more than 1 increases the sample size of usage data before a |
185 // decision is made, improving the accuracy of heuristics. | 190 // decision is made, improving the accuracy of heuristics. |
186 const int MinFramesBeforeSwitch = 3; | 191 const int MinFramesBeforeSwitch = 3; |
187 | 192 |
188 } // namespace ExpensiveCanvasHeuristicParameters | 193 } // namespace ExpensiveCanvasHeuristicParameters |
189 | 194 |
190 } // namespace blink | 195 } // namespace blink |
191 | 196 |
192 #endif | 197 #endif |
OLD | NEW |