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

Side by Side Diff: third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp

Issue 2210123002: Improved heuristic for disable acceleration. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Disable trackDrawCall when Canvas 2D Dynamic Rendering Mode Switching is disabled Created 4 years, 4 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
OLDNEW
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 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::isAccelerationOptimalForCanvasContent() const 1071 bool CanvasRenderingContext2D::isAccelerationOptimalForCanvasContent() const
1072 { 1072 {
1073 // Simple heuristic to determine if the GPU accelerated pipeline should be 1073 // Heuristic to determine if the GPU accelerated rendering pipeline is optim al
1074 // used to maximize performance of 2D canvas based on past usage. 1074 // for performance based on past usage. It has a bias towards suggesting tha t the
1075 // accelerated pipeline is optimal.
1075 1076
1076 int numDrawPathCalls = 1077 float acceleratedCost = estimateRenderingCost(ExpensiveCanvasHeuristicParame ters::AcceleratedModeIndex);
1077 m_usageCounters.numDrawCalls[StrokePath] +
1078 m_usageCounters.numDrawCalls[FillPath] +
1079 m_usageCounters.numDrawCalls[FillText] +
1080 m_usageCounters.numDrawCalls[StrokeText] +
1081 m_usageCounters.numDrawCalls[FillRect] +
1082 m_usageCounters.numDrawCalls[StrokeRect];
1083 1078
1084 double acceleratedCost = 1079 float recordingCost = estimateRenderingCost(ExpensiveCanvasHeuristicParamete rs::RecordingModeIndex);
1085 numDrawPathCalls * ExpensiveCanvasHeuristicParameters::AcceleratedDrawPa thApproximateCost +
1086 m_usageCounters.numGetImageDataCalls * ExpensiveCanvasHeuristicParameter s::AcceleratedGetImageDataApproximateCost+
1087 m_usageCounters.numDrawCalls[DrawImage] * ExpensiveCanvasHeuristicParame ters::AcceleratedDrawImageApproximateCost;
1088 1080
1089 double recordingCost = 1081 float costDifference = acceleratedCost - recordingCost;
1090 numDrawPathCalls * ExpensiveCanvasHeuristicParameters::RecordingDrawPath ApproximateCost + 1082 float percentCostReduction = costDifference / acceleratedCost * 100.0;
1091 m_usageCounters.numGetImageDataCalls * ExpensiveCanvasHeuristicParameter s::UnacceleratedGetImageDataApproximateCost + 1083 float costDifferencePerFrame = costDifference / m_usageCounters.numFramesSin ceReset;
1092 m_usageCounters.numDrawCalls[DrawImage] * ExpensiveCanvasHeuristicParame ters::RecordingDrawImageApproximateCost;
1093 1084
1094 if (recordingCost * ExpensiveCanvasHeuristicParameters::AcceleratedHeuristic Bias < acceleratedCost) { 1085 if (percentCostReduction >= ExpensiveCanvasHeuristicParameters::MinPercentag eImprovementToSuggestDisableAcceleration
1086 && costDifferencePerFrame >= ExpensiveCanvasHeuristicParameters::MinCost PerFrameImprovementToSuggestDisableAcceleration) {
1095 return false; 1087 return false;
1096 } 1088 }
1097 return true; 1089 return true;
1098 } 1090 }
1099 1091
1100 void CanvasRenderingContext2D::resetUsageTracking() 1092 void CanvasRenderingContext2D::resetUsageTracking()
1101 { 1093 {
1102 UsageCounters newCounters; 1094 UsageCounters newCounters;
1103 m_usageCounters = newCounters; 1095 m_usageCounters = newCounters;
1104 } 1096 }
1105 1097
1106 } // namespace blink 1098 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698