| 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..358cebfbe01de7a7f4753a2ae4644eca6441f548 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"
|
| @@ -988,6 +989,60 @@ void BaseRenderingContext2D::drawImage(ExecutionContext* executionContext, Canva
|
| if (!drawingCanvas())
|
| return;
|
|
|
| + Optional<ScopedUsHistogramTimer> timer;
|
| + if (imageBuffer() && imageBuffer()->isAccelerated()) {
|
| + if (imageSource->isVideoElement()) {
|
| + DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterVideoGPU, ("Blink.Canvas.DrawImage.VideoGPU", 0, 10000000, 50));
|
| + timer.emplace(scopedUsCounterVideoGPU);
|
| + } else if (imageSource->isCanvasElement()) {
|
| + DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterCanvasGPU, ("Blink.Canvas.DrawImage.CanvasGPU", 0, 10000000, 50));
|
| + timer.emplace(scopedUsCounterCanvasGPU);
|
| + } else if (imageSource->isSVGSource()) {
|
| + DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterSVGGPU, ("Blink.Canvas.DrawImage.SVGGPU", 0, 10000000, 50));
|
| + timer.emplace(scopedUsCounterSVGGPU);
|
| + } else if (imageSource->isImageBitmap()) {
|
| + DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterImageBitmapGPU, ("Blink.Canvas.DrawImage.ImageBitmapGPU", 0, 10000000, 50));
|
| + timer.emplace(scopedUsCounterImageBitmapGPU);
|
| + } else {
|
| + DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterOthersGPU, ("Blink.Canvas.DrawImage.OthersGPU", 0, 10000000, 50));
|
| + timer.emplace(scopedUsCounterOthersGPU);
|
| + }
|
| + } else if (imageBuffer() && imageBuffer()->isRecording()) {
|
| + if (imageSource->isVideoElement()) {
|
| + DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterVideoDisplayList, ("Blink.Canvas.DrawImage.VideoDisplayList", 0, 10000000, 50));
|
| + timer.emplace(scopedUsCounterVideoDisplayList);
|
| + } else if (imageSource->isCanvasElement()) {
|
| + DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterCanvasDisplayList, ("Blink.Canvas.DrawImage.CanvasDisplayList", 0, 10000000, 50));
|
| + timer.emplace(scopedUsCounterCanvasDisplayList);
|
| + } else if (imageSource->isSVGSource()) {
|
| + DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterSVGDisplayList, ("Blink.Canvas.DrawImage.SVGDisplayList", 0, 10000000, 50));
|
| + timer.emplace(scopedUsCounterSVGDisplayList);
|
| + } else if (imageSource->isImageBitmap()) {
|
| + DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterImageBitmapDisplayList, ("Blink.Canvas.DrawImage.ImageBitmapDisplayList", 0, 10000000, 50));
|
| + timer.emplace(scopedUsCounterImageBitmapDisplayList);
|
| + } else {
|
| + DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterOthersDisplayList, ("Blink.Canvas.DrawImage.OthersDisplayList", 0, 10000000, 50));
|
| + timer.emplace(scopedUsCounterOthersDisplayList);
|
| + }
|
| + } else {
|
| + if (imageSource->isVideoElement()) {
|
| + DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterVideoCPU, ("Blink.Canvas.DrawImage.VideoCPU", 0, 10000000, 50));
|
| + timer.emplace(scopedUsCounterVideoCPU);
|
| + } else if (imageSource->isCanvasElement()) {
|
| + DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterCanvasCPU, ("Blink.Canvas.DrawImage.CanvasCPU", 0, 10000000, 50));
|
| + timer.emplace(scopedUsCounterCanvasCPU);
|
| + } else if (imageSource->isSVGSource()) {
|
| + DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterSVGCPU, ("Blink.Canvas.DrawImage.SVGCPU", 0, 10000000, 50));
|
| + timer.emplace(scopedUsCounterSVGCPU);
|
| + } else if (imageSource->isImageBitmap()) {
|
| + DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterImageBitmapCPU, ("Blink.Canvas.DrawImage.ImageBitmapCPU", 0, 10000000, 50));
|
| + timer.emplace(scopedUsCounterImageBitmapCPU);
|
| + } else {
|
| + DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterOthersCPU, ("Blink.Canvas.DrawImage.OthersCPU", 0, 10000000, 50));
|
| + timer.emplace(scopedUsCounterOthersCPU);
|
| + }
|
| + }
|
| +
|
| RefPtr<Image> image;
|
| FloatSize defaultObjectSize(width(), height());
|
| SourceImageStatus sourceImageStatus = InvalidSourceImageStatus;
|
| @@ -1190,6 +1245,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, scopedUsCounterDisplayList, ("Blink.Canvas.GetImageData.DisplayList", 0, 10000000, 50));
|
| + timer.emplace(scopedUsCounterDisplayList);
|
| + } else {
|
| + DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterCPU, ("Blink.Canvas.GetImageData.CPU", 0, 10000000, 50));
|
| + timer.emplace(scopedUsCounterCPU);
|
| + }
|
| +
|
| if (!originClean())
|
| exceptionState.throwSecurityError("The canvas has been tainted by cross-origin data.");
|
| else if (!sw || !sh)
|
| @@ -1243,6 +1310,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, scopedUsCounterDisplayList, ("Blink.Canvas.PutImageData.DisplayList", 0, 10000000, 50));
|
| + timer.emplace(scopedUsCounterDisplayList);
|
| + } else {
|
| + DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterCPU, ("Blink.Canvas.PutImageData.CPU", 0, 10000000, 50));
|
| + timer.emplace(scopedUsCounterCPU);
|
| + }
|
| +
|
| if (data->data()->bufferBase()->isNeutered()) {
|
| exceptionState.throwDOMException(InvalidStateError, "The source data has been neutered.");
|
| return;
|
|
|