Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
| 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
| 6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> | 6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> |
| 7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
| 8 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. | 8 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. |
| 9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
| 10 * | 10 * |
| (...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1061 } | 1061 } |
| 1062 | 1062 |
| 1063 unsigned CanvasRenderingContext2D::hitRegionsCount() const | 1063 unsigned CanvasRenderingContext2D::hitRegionsCount() const |
| 1064 { | 1064 { |
| 1065 if (m_hitRegionManager) | 1065 if (m_hitRegionManager) |
| 1066 return m_hitRegionManager->getHitRegionsCount(); | 1066 return m_hitRegionManager->getHitRegionsCount(); |
| 1067 | 1067 |
| 1068 return 0; | 1068 return 0; |
| 1069 } | 1069 } |
| 1070 | 1070 |
| 1071 bool CanvasRenderingContext2D::shouldAccelerate() const | |
| 1072 { | |
| 1073 // Simple heuristic to determine if the GPU accelerated pipeline should be | |
| 1074 // used to maximize performance of 2D canvas based on past usage. | |
| 1075 // The current implementation has a bias towards suggesting | |
| 1076 // the use of the accelerated pipeline. The coefficients used | |
| 1077 // to estimate the rendering cost of pipelines are approximate | |
| 1078 // and were determined experimentally. | |
| 1079 | |
| 1080 int numDrawPathCalls = | |
| 1081 m_usageCounters.numDrawCalls[StrokePath] + | |
| 1082 m_usageCounters.numDrawCalls[FillPath] + | |
| 1083 m_usageCounters.numDrawCalls[FillText] + | |
| 1084 m_usageCounters.numDrawCalls[StrokeText] + | |
| 1085 m_usageCounters.numDrawCalls[FillRect] + | |
| 1086 m_usageCounters.numDrawCalls[StrokeRect]; | |
| 1087 | |
| 1088 double acceleratedCost = | |
| 1089 numDrawPathCalls * 0.004 + | |
|
Justin Novosad
2016/07/12 19:31:24
These coefficients should all go in ExpensiveCAnva
sebastienlc
2016/07/13 19:51:02
Done.
| |
| 1090 m_usageCounters.numGetImageDataCalls * 0.1 + | |
| 1091 m_usageCounters.numDrawCalls[DrawImage] * 0.002; | |
| 1092 | |
| 1093 double unacceleratedCost = | |
| 1094 numDrawPathCalls * 0.0014 + | |
| 1095 m_usageCounters.numGetImageDataCalls * 0.001 + | |
| 1096 m_usageCounters.numDrawCalls[DrawImage] * 0.004; | |
| 1097 | |
| 1098 double unacceleratedPenalty = 1.5; // greater than 1 to create a bias toward s suggesting acceleration | |
|
Justin Novosad
2016/07/12 19:31:24
This threshold should be in ExpensiveCanvasHeurist
sebastienlc
2016/07/13 19:51:02
Done.
| |
| 1099 if (unacceleratedCost * unacceleratedPenalty < acceleratedCost) { | |
| 1100 return false; | |
| 1101 } | |
| 1102 return true; | |
| 1103 } | |
| 1104 | |
| 1071 } // namespace blink | 1105 } // namespace blink |
| OLD | NEW |