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

Unified Diff: third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp

Issue 2210123002: Improved heuristic for disable acceleration. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
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 f85fa19e099fb93512ea3ba4641da01ac768635c..2743c43acde742f6a912291d55a9183a6722baa8 100644
--- a/third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp
+++ b/third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp
@@ -949,7 +949,12 @@ static bool isDrawScalingDown(const FloatRect& srcRect, const FloatRect& dstRect
void BaseRenderingContext2D::drawImageInternal(SkCanvas* c, CanvasImageSource* imageSource, Image* image, const FloatRect& srcRect, const FloatRect& dstRect, const SkPaint* paint)
{
- trackDrawCall(DrawImage, nullptr, dstRect.width(), dstRect.height());
+ if (imageSource->isSVGSource()) {
+ trackDrawCall(DrawSVGImage, nullptr, dstRect.width(), dstRect.height());
+ } else {
+ trackDrawCall(DrawPNGImage, nullptr, dstRect.width(), dstRect.height());
+ }
+
int initialSaveCount = c->getSaveCount();
SkPaint imagePaint = *paint;
@@ -1544,11 +1549,8 @@ void BaseRenderingContext2D::trackDrawCall(DrawCallType callType, Path2D* path2d
skPath = m_path.getSkPath();
}
- if (callType == FillPath && !(skPath.getConvexity() == SkPath::kConvex_Convexity)) {
- m_usageCounters.numNonConvexFillPathCalls++;
- }
- if (!(callType == FillRect || callType == StrokeRect || callType == DrawImage)) {
+ if (!(callType == FillRect || callType == StrokeRect || callType == DrawSVGImage || callType == DrawPNGImage)) {
// The correct width and height were not passed as parameters
const SkRect& boundingRect = skPath.getBounds();
boundingRectWidth = static_cast<double>(std::abs(boundingRect.width()));
@@ -1557,6 +1559,11 @@ void BaseRenderingContext2D::trackDrawCall(DrawCallType callType, Path2D* path2d
boundingRectPerimeter = 2.0 * boundingRectWidth + 2.0 * boundingRectHeight;
}
+ if (callType == FillPath && !(skPath.getConvexity() == SkPath::kConvex_Convexity)) {
Justin Novosad 2016/08/04 15:53:16 !(a == b) -> a != b
sebastienlc 2016/08/04 16:36:27 Done.
+ m_usageCounters.numNonConvexFillPathCalls++;
+ m_usageCounters.nonConvexFillPathArea += boundingRectArea;
+ }
+
m_usageCounters.boundingBoxPerimeterDrawCalls[callType] += boundingRectPerimeter;
m_usageCounters.boundingBoxAreaDrawCalls[callType] += boundingRectArea;
@@ -1569,10 +1576,12 @@ void BaseRenderingContext2D::trackDrawCall(DrawCallType callType, Path2D* path2d
CanvasGradient* gradient = canvasStyle->getCanvasGradient();
if (gradient) {
- m_usageCounters.numGradients++;
+
if (gradient->getGradient()->isRadial()) {
+ m_usageCounters.numRadialGradients++;
m_usageCounters.boundingBoxAreaFillType[BaseRenderingContext2D::RadialGradientFillType] += boundingRectArea;
} else {
+ m_usageCounters.numLinearGradients++;
m_usageCounters.boundingBoxAreaFillType[BaseRenderingContext2D::LinearGradientFillType] += boundingRectArea;
}
} else if (canvasStyle->getCanvasPattern()) {
@@ -1583,9 +1592,9 @@ void BaseRenderingContext2D::trackDrawCall(DrawCallType callType, Path2D* path2d
}
}
- if (callType == DrawImage) {
- m_usageCounters.boundingBoxPerimeterDrawCalls[DrawImage] += boundingRectPerimeter;
- m_usageCounters.boundingBoxAreaDrawCalls[DrawImage] += boundingRectArea;
+ if (callType == DrawSVGImage || callType == DrawPNGImage) {
+ m_usageCounters.boundingBoxPerimeterDrawCalls[callType] += boundingRectPerimeter;
+ m_usageCounters.boundingBoxAreaDrawCalls[callType] += boundingRectArea;
}
if (callType == FillText
@@ -1594,7 +1603,8 @@ void BaseRenderingContext2D::trackDrawCall(DrawCallType callType, Path2D* path2d
|| callType == StrokePath
|| callType == FillRect
|| callType == StrokeRect
- || callType == DrawImage) {
+ || callType == DrawSVGImage
+ || callType == DrawPNGImage) {
if (state().shadowBlur() > 0.0 && SkColorGetA(state().shadowColor()) > 0) {
m_usageCounters.numBlurredShadows++;
m_usageCounters.boundingBoxAreaTimesShadowBlurSquared += boundingRectArea * state().shadowBlur() * state().shadowBlur();
@@ -1622,12 +1632,14 @@ DEFINE_TRACE(BaseRenderingContext2D)
}
BaseRenderingContext2D::UsageCounters::UsageCounters() :
- numDrawCalls {0, 0, 0, 0, 0, 0},
- boundingBoxPerimeterDrawCalls {0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
- boundingBoxAreaDrawCalls {0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
+ numDrawCalls {0, 0, 0, 0, 0, 0, 0},
+ boundingBoxPerimeterDrawCalls {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
Justin Novosad 2016/08/04 15:53:16 0.0 -> 0.0f here and below
sebastienlc 2016/08/04 16:36:27 Done.
+ boundingBoxAreaDrawCalls {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
boundingBoxAreaFillType {0.0, 0.0, 0.0, 0.0},
numNonConvexFillPathCalls(0),
- numGradients(0),
+ nonConvexFillPathArea(0.0),
+ numRadialGradients(0),
+ numLinearGradients(0),
numPatterns(0),
numDrawWithComplexClips(0),
numBlurredShadows(0),

Powered by Google App Engine
This is Rietveld 408576698