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

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

Issue 1992253002: Adding performance tracking for canvas API calls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 29c48be833467769c8dbb93287dc9d2d2fd54f10..75a3d81a126f951ccce9480fadeb7fe4c08a74f8 100644
--- a/third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp
+++ b/third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp
@@ -17,6 +17,7 @@
#include "modules/canvas2d/CanvasPattern.h"
#include "modules/canvas2d/CanvasStyle.h"
#include "modules/canvas2d/Path2D.h"
+#include "platform/Histogram.h"
#include "platform/geometry/FloatQuad.h"
#include "platform/graphics/Color.h"
#include "platform/graphics/ExpensiveCanvasHeuristicParameters.h"
@@ -985,6 +986,18 @@ void BaseRenderingContext2D::drawImage(ExecutionContext* executionContext, Canva
double sx, double sy, double sw, double sh,
double dx, double dy, double dw, double dh, ExceptionState& exceptionState)
{
+ Optional<ScopedUsHistogramTimer> timer;
+ if (imageBuffer() && imageBuffer()->isAccelerated()) {
+ DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterGPU, ("Blink.Canvas.DrawImage.GPU", 0, 10000000, 50));
Justin Novosad 2016/05/19 15:36:55 Should also classify by type of image source.
xidachen 2016/05/20 12:36:54 Done.
+ timer.emplace(scopedUsCounterGPU);
+ } else if (imageBuffer() && imageBuffer()->isRecording()) {
+ DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterDL, ("Blink.Canvas.DrawImage.DL", 0, 10000000, 50));
+ timer.emplace(scopedUsCounterDL);
+ } else {
+ DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterSW, ("Blink.Canvas.DrawImage.SW", 0, 10000000, 50));
+ timer.emplace(scopedUsCounterSW);
+ }
+
if (!drawingCanvas())
return;
@@ -1167,6 +1180,18 @@ ImageData* BaseRenderingContext2D::createImageData(ImageData* imageData, Excepti
ImageData* BaseRenderingContext2D::createImageData(double sw, double sh, ExceptionState& exceptionState) const
{
+ Optional<ScopedUsHistogramTimer> timer;
+ if (imageBuffer() && imageBuffer()->isAccelerated()) {
+ DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterGPU, ("Blink.Canvas.CreateImageData.GPU", 0, 10000000, 50));
Justin Novosad 2016/05/19 15:36:55 I don think we need to measure this one. It's over
xidachen 2016/05/20 12:36:54 Done.
+ timer.emplace(scopedUsCounterGPU);
+ } else if (imageBuffer() && imageBuffer()->isRecording()) {
+ DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterDL, ("Blink.Canvas.CreateImageData.DL", 0, 10000000, 50));
+ timer.emplace(scopedUsCounterDL);
+ } else {
+ DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterSW, ("Blink.Canvas.CreateImageData.SW", 0, 10000000, 50));
+ timer.emplace(scopedUsCounterSW);
+ }
+
if (!sw || !sh) {
exceptionState.throwDOMException(IndexSizeError, String::format("The source %s is 0.", sw ? "height" : "width"));
return nullptr;
@@ -1190,6 +1215,18 @@ ImageData* BaseRenderingContext2D::createImageData(double sw, double sh, Excepti
ImageData* BaseRenderingContext2D::getImageData(double sx, double sy, double sw, double sh, ExceptionState& exceptionState) const
{
+ Optional<ScopedUsHistogramTimer> timer;
+ if (imageBuffer() && imageBuffer()->isAccelerated()) {
+ DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterGPU, ("Blink.Canvas.GetImageData.GPU", 0, 10000000, 50));
+ timer.emplace(scopedUsCounterGPU);
+ } else if (imageBuffer() && imageBuffer()->isRecording()) {
+ DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterDL, ("Blink.Canvas.GetImageData.DL", 0, 10000000, 50));
+ timer.emplace(scopedUsCounterDL);
+ } else {
+ DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterSW, ("Blink.Canvas.GetImageData.SW", 0, 10000000, 50));
+ timer.emplace(scopedUsCounterSW);
+ }
+
if (!originClean())
exceptionState.throwSecurityError("The canvas has been tainted by cross-origin data.");
else if (!sw || !sh)
@@ -1243,6 +1280,18 @@ void BaseRenderingContext2D::putImageData(ImageData* data, double dx, double dy,
void BaseRenderingContext2D::putImageData(ImageData* data, double dx, double dy, double dirtyX, double dirtyY, double dirtyWidth, double dirtyHeight, ExceptionState& exceptionState)
{
+ Optional<ScopedUsHistogramTimer> timer;
+ if (imageBuffer() && imageBuffer()->isAccelerated()) {
+ DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterGPU, ("Blink.Canvas.PutImageData.GPU", 0, 10000000, 50));
+ timer.emplace(scopedUsCounterGPU);
+ } else if (imageBuffer() && imageBuffer()->isRecording()) {
+ DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterDL, ("Blink.Canvas.PutImageData.DL", 0, 10000000, 50));
+ timer.emplace(scopedUsCounterDL);
+ } else {
+ DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterSW, ("Blink.Canvas.PutImageData.SW", 0, 10000000, 50));
+ timer.emplace(scopedUsCounterSW);
+ }
+
if (data->data()->bufferBase()->isNeutered()) {
exceptionState.throwDOMException(InvalidStateError, "The source data has been neutered.");
return;

Powered by Google App Engine
This is Rietveld 408576698