| Index: third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp
|
| diff --git a/third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp b/third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp
|
| index e0db5591d855ae297d2134e964605ecc916ca831..e18695113413e3db4d91ea3dc405909736b4dc74 100644
|
| --- a/third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp
|
| +++ b/third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp
|
| @@ -964,7 +964,6 @@ void BaseRenderingContext2D::drawImageInternal(SkCanvas* c, CanvasImageSource* i
|
| trackDrawCall(DrawBitmapImage, nullptr, dstRect.width(), dstRect.height());
|
| }
|
|
|
| -
|
| int initialSaveCount = c->getSaveCount();
|
| SkPaint imagePaint = *paint;
|
|
|
| @@ -1076,6 +1075,26 @@ void BaseRenderingContext2D::drawImage(ExecutionContext* executionContext, Canva
|
|
|
| validateStateStack();
|
|
|
| + // Heuristic for disabling acceleration based on anticipated texture upload overhead
|
| + // See comments in ExpensiveCanvasHeuristicParameters.h for explanation.
|
| + ImageBuffer* buffer = imageBuffer();
|
| + if (buffer && buffer->isAccelerated() && !imageSource->isAccelerated()) {
|
| + float srcArea = srcRect.width() * srcRect.height();
|
| + if (srcArea > ExpensiveCanvasHeuristicParameters::DrawImageTextureUploadHardSizeLimit) {
|
| + buffer->disableAcceleration();
|
| + } else if (srcArea > ExpensiveCanvasHeuristicParameters::DrawImageTextureUploadSoftSizeLimit) {
|
| + SkRect bounds = dstRect;
|
| + SkMatrix ctm = drawingCanvas()->getTotalMatrix();
|
| + ctm.mapRect(&bounds);
|
| + float dstArea = dstRect.width() * dstRect.height();
|
| + if (srcArea > dstArea * ExpensiveCanvasHeuristicParameters::DrawImageTextureUploadSoftSizeLimitScaleThreshold) {
|
| + buffer->disableAcceleration();
|
| + }
|
| + }
|
| + }
|
| +
|
| + validateStateStack();
|
| +
|
| // TODO(xidachen): After collecting some data, come back and prune off
|
| // the ones that is not needed.
|
| Optional<ScopedUsHistogramTimer> timer;
|
|
|