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

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

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
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef BaseRenderingContext2D_h 5 #ifndef BaseRenderingContext2D_h
6 #define BaseRenderingContext2D_h 6 #define BaseRenderingContext2D_h
7 7
8 #include "bindings/modules/v8/HTMLImageElementOrHTMLVideoElementOrHTMLCanvasElem entOrImageBitmap.h" 8 #include "bindings/modules/v8/HTMLImageElementOrHTMLVideoElementOrHTMLCanvasElem entOrImageBitmap.h"
9 #include "bindings/modules/v8/StringOrCanvasGradientOrCanvasPattern.h" 9 #include "bindings/modules/v8/StringOrCanvasGradientOrCanvasPattern.h"
10 #include "core/html/ImageData.h" 10 #include "core/html/ImageData.h"
11 #include "modules/ModulesExport.h" 11 #include "modules/ModulesExport.h"
12 #include "modules/canvas2d/CanvasGradient.h" 12 #include "modules/canvas2d/CanvasGradient.h"
13 #include "modules/canvas2d/CanvasPathMethods.h" 13 #include "modules/canvas2d/CanvasPathMethods.h"
14 #include "modules/canvas2d/CanvasRenderingContext2DState.h" 14 #include "modules/canvas2d/CanvasRenderingContext2DState.h"
15 #include "modules/canvas2d/CanvasStyle.h" 15 #include "modules/canvas2d/CanvasStyle.h"
16 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h"
16 #include "third_party/skia/include/core/SkCanvas.h" 17 #include "third_party/skia/include/core/SkCanvas.h"
17 18
18 namespace blink { 19 namespace blink {
19 20
20 class CanvasImageSource; 21 class CanvasImageSource;
21 class Color; 22 class Color;
22 class Image; 23 class Image;
23 class ImageBuffer; 24 class ImageBuffer;
24 class Path2D; 25 class Path2D;
25 class SVGMatrixTearOff; 26 class SVGMatrixTearOff;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 159
159 virtual bool isContextLost() const = 0; 160 virtual bool isContextLost() const = 0;
160 161
161 void restoreMatrixClipStack(SkCanvas*) const; 162 void restoreMatrixClipStack(SkCanvas*) const;
162 163
163 DECLARE_VIRTUAL_TRACE(); 164 DECLARE_VIRTUAL_TRACE();
164 165
165 enum DrawCallType { 166 enum DrawCallType {
166 StrokePath = 0, 167 StrokePath = 0,
167 FillPath, 168 FillPath,
168 DrawImage, 169 DrawVectorImage,
170 DrawBitmapImage,
169 FillText, 171 FillText,
170 StrokeText, 172 StrokeText,
171 FillRect, 173 FillRect,
172 StrokeRect, 174 StrokeRect,
173 DrawCallTypeCount // used to specify the size of storage arrays 175 DrawCallTypeCount // used to specify the size of storage arrays
174 }; 176 };
175 177
176 enum PathFillType { 178 enum PathFillType {
177 ColorFillType, 179 ColorFillType,
178 LinearGradientFillType, 180 LinearGradientFillType,
179 RadialGradientFillType, 181 RadialGradientFillType,
180 PatternFillType, 182 PatternFillType,
181 PathFillTypeCount // used to specify the size of storage arrays 183 PathFillTypeCount // used to specify the size of storage arrays
182 }; 184 };
183 185
184 struct UsageCounters { 186 struct UsageCounters {
185 int numDrawCalls[DrawCallTypeCount]; // use DrawCallType enum as index 187 int numDrawCalls[DrawCallTypeCount]; // use DrawCallType enum as index
186 double boundingBoxPerimeterDrawCalls[DrawCallTypeCount]; 188 float boundingBoxPerimeterDrawCalls[DrawCallTypeCount];
187 double boundingBoxAreaDrawCalls[DrawCallTypeCount]; 189 float boundingBoxAreaDrawCalls[DrawCallTypeCount];
188 double boundingBoxAreaFillType[PathFillTypeCount]; 190 float boundingBoxAreaFillType[PathFillTypeCount];
189 int numNonConvexFillPathCalls; 191 int numNonConvexFillPathCalls;
190 int numGradients; 192 float nonConvexFillPathArea;
193 int numRadialGradients;
194 int numLinearGradients;
191 int numPatterns; 195 int numPatterns;
192 int numDrawWithComplexClips; 196 int numDrawWithComplexClips;
193 int numBlurredShadows; 197 int numBlurredShadows;
194 double boundingBoxAreaTimesShadowBlurSquared; 198 float boundingBoxAreaTimesShadowBlurSquared;
195 double boundingBoxPerimeterTimesShadowBlurSquared; 199 float boundingBoxPerimeterTimesShadowBlurSquared;
196 int numFilters; 200 int numFilters;
197 int numGetImageDataCalls; 201 int numGetImageDataCalls;
198 double areaGetImageDataCalls; 202 float areaGetImageDataCalls;
199 int numPutImageDataCalls; 203 int numPutImageDataCalls;
200 double areaPutImageDataCalls; 204 float areaPutImageDataCalls;
201 int numClearRectCalls; 205 int numClearRectCalls;
202 int numDrawFocusCalls; 206 int numDrawFocusCalls;
203 int numFramesSinceReset; 207 int numFramesSinceReset;
204 208
205 UsageCounters(); 209 UsageCounters();
206 }; 210 };
207 211
208 const UsageCounters& getUsage(); 212 const UsageCounters& getUsage();
209 213
210 protected: 214 protected:
(...skipping 17 matching lines...) Expand all
228 232
229 void checkOverdraw(const SkRect&, const SkPaint*, CanvasRenderingContext2DSt ate::ImageType, DrawType); 233 void checkOverdraw(const SkRect&, const SkPaint*, CanvasRenderingContext2DSt ate::ImageType, DrawType);
230 234
231 HeapVector<Member<CanvasRenderingContext2DState>> m_stateStack; 235 HeapVector<Member<CanvasRenderingContext2DState>> m_stateStack;
232 AntiAliasingMode m_clipAntialiasing; 236 AntiAliasingMode m_clipAntialiasing;
233 237
234 void trackDrawCall(DrawCallType, Path2D* path2d = nullptr, int width = 0, in t height = 0); 238 void trackDrawCall(DrawCallType, Path2D* path2d = nullptr, int width = 0, in t height = 0);
235 239
236 mutable UsageCounters m_usageCounters; 240 mutable UsageCounters m_usageCounters;
237 241
242
243 float estimateRenderingCost(ExpensiveCanvasHeuristicParameters::RenderingMod eCostIndex) const;
238 private: 244 private:
239 void realizeSaves(); 245 void realizeSaves();
240 246
241 bool shouldDrawImageAntialiased(const FloatRect& destRect) const; 247 bool shouldDrawImageAntialiased(const FloatRect& destRect) const;
242 248
243 void drawPathInternal(const Path&, CanvasRenderingContext2DState::PaintType, SkPath::FillType = SkPath::kWinding_FillType); 249 void drawPathInternal(const Path&, CanvasRenderingContext2DState::PaintType, SkPath::FillType = SkPath::kWinding_FillType);
244 void drawImageInternal(SkCanvas*, CanvasImageSource*, Image*, const FloatRec t& srcRect, const FloatRect& dstRect, const SkPaint*); 250 void drawImageInternal(SkCanvas*, CanvasImageSource*, Image*, const FloatRec t& srcRect, const FloatRect& dstRect, const SkPaint*);
245 void clipInternal(const Path&, const String& windingRuleString); 251 void clipInternal(const Path&, const String& windingRuleString);
246 252
247 bool isPointInPathInternal(const Path&, const double x, const double y, cons t String& windingRuleString); 253 bool isPointInPathInternal(const Path&, const double x, const double y, cons t String& windingRuleString);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 foregroundPaint.setXfermodeMode(SkXfermode::kSrcOver_Mode); 342 foregroundPaint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
337 c->setMatrix(ctm); 343 c->setMatrix(ctm);
338 drawFunc(c, &foregroundPaint); 344 drawFunc(c, &foregroundPaint);
339 c->restore(); 345 c->restore();
340 c->setMatrix(ctm); 346 c->setMatrix(ctm);
341 } 347 }
342 348
343 } // namespace blink 349 } // namespace blink
344 350
345 #endif // BaseRenderingContext2D_h 351 #endif // BaseRenderingContext2D_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698