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

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

Issue 2625873005: Add an heuristic for promoting canvases to GPU acceleration (Closed)
Patch Set: webgl test fix Created 3 years, 11 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "modules/canvas2d/BaseRenderingContext2D.h" 5 #include "modules/canvas2d/BaseRenderingContext2D.h"
6 6
7 #include "bindings/core/v8/ExceptionMessages.h" 7 #include "bindings/core/v8/ExceptionMessages.h"
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "core/css/cssom/CSSURLImageValue.h" 9 #include "core/css/cssom/CSSURLImageValue.h"
10 #include "core/css/parser/CSSParser.h" 10 #include "core/css/parser/CSSParser.h"
(...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 return; 1167 return;
1168 1168
1169 DisableDeferralReason reason = DisableDeferralReasonUnknown; 1169 DisableDeferralReason reason = DisableDeferralReasonUnknown;
1170 if (shouldDisableDeferral(imageSource, &reason)) 1170 if (shouldDisableDeferral(imageSource, &reason))
1171 disableDeferral(reason); 1171 disableDeferral(reason);
1172 else if (image->isTextureBacked()) 1172 else if (image->isTextureBacked())
1173 disableDeferral(DisableDeferralDrawImageWithTextureBackedSourceImage); 1173 disableDeferral(DisableDeferralDrawImageWithTextureBackedSourceImage);
1174 1174
1175 validateStateStack(); 1175 validateStateStack();
1176 1176
1177 willDrawImage(imageSource);
1178
1179 validateStateStack();
1180
1177 // Heuristic for disabling acceleration based on anticipated texture upload 1181 // Heuristic for disabling acceleration based on anticipated texture upload
1178 // overhead. 1182 // overhead.
1179 // See comments in ExpensiveCanvasHeuristicParameters.h for explanation. 1183 // See comments in ExpensiveCanvasHeuristicParameters.h for explanation.
1180 ImageBuffer* buffer = imageBuffer(); 1184 ImageBuffer* buffer = imageBuffer();
1181 if (buffer && buffer->isAccelerated() && !imageSource->isAccelerated()) { 1185 if (buffer && buffer->isAccelerated() && !imageSource->isAccelerated()) {
1182 float srcArea = srcRect.width() * srcRect.height(); 1186 float srcArea = srcRect.width() * srcRect.height();
1183 if (srcArea > ExpensiveCanvasHeuristicParameters:: 1187 if (srcArea > ExpensiveCanvasHeuristicParameters::
1184 DrawImageTextureUploadHardSizeLimit) { 1188 DrawImageTextureUploadHardSizeLimit) {
1185 buffer->disableAcceleration(); 1189 buffer->disableAcceleration();
1186 } else if (srcArea > ExpensiveCanvasHeuristicParameters:: 1190 } else if (srcArea > ExpensiveCanvasHeuristicParameters::
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
2013 ExpensiveCanvasHeuristicParameters::ShadowFixedCost[index] * 2017 ExpensiveCanvasHeuristicParameters::ShadowFixedCost[index] *
2014 m_usageCounters.numBlurredShadows + 2018 m_usageCounters.numBlurredShadows +
2015 ExpensiveCanvasHeuristicParameters:: 2019 ExpensiveCanvasHeuristicParameters::
2016 ShadowVariableCostPerAreaTimesShadowBlurSquared[index] * 2020 ShadowVariableCostPerAreaTimesShadowBlurSquared[index] *
2017 m_usageCounters.boundingBoxAreaTimesShadowBlurSquared; 2021 m_usageCounters.boundingBoxAreaTimesShadowBlurSquared;
2018 2022
2019 return basicCostOfDrawCalls + fillTypeAdjustment + shadowAdjustment; 2023 return basicCostOfDrawCalls + fillTypeAdjustment + shadowAdjustment;
2020 } 2024 }
2021 2025
2022 } // namespace blink 2026 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698