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

Unified Diff: third_party/WebKit/Source/core/paint/HTMLCanvasPainter.cpp

Issue 2121933003: [SPv2] Paint accelerated canvases as foreign layers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add 'override' keyword to StubChromeClientForSPv2::didPaint Created 4 years, 5 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/core/paint/HTMLCanvasPainter.cpp
diff --git a/third_party/WebKit/Source/core/paint/HTMLCanvasPainter.cpp b/third_party/WebKit/Source/core/paint/HTMLCanvasPainter.cpp
index a1136ebb46d64e5e8271b9707761a5f205f9caab..4ec8ab0f32b3c32194deed8d12a9606ce5daa3f1 100644
--- a/third_party/WebKit/Source/core/paint/HTMLCanvasPainter.cpp
+++ b/third_party/WebKit/Source/core/paint/HTMLCanvasPainter.cpp
@@ -5,25 +5,41 @@
#include "core/paint/HTMLCanvasPainter.h"
#include "core/html/HTMLCanvasElement.h"
+#include "core/html/canvas/CanvasRenderingContext.h"
#include "core/layout/LayoutHTMLCanvas.h"
#include "core/paint/LayoutObjectDrawingRecorder.h"
#include "core/paint/PaintInfo.h"
#include "platform/geometry/LayoutPoint.h"
#include "platform/graphics/paint/ClipRecorder.h"
+#include "platform/graphics/paint/ForeignLayerDisplayItem.h"
namespace blink {
void HTMLCanvasPainter::paintReplaced(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
GraphicsContext& context = paintInfo.context;
- if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, m_layoutHTMLCanvas, paintInfo.phase))
- return;
LayoutRect contentRect = m_layoutHTMLCanvas.contentBoxRect();
contentRect.moveBy(paintOffset);
LayoutRect paintRect = m_layoutHTMLCanvas.replacedContentRect();
paintRect.moveBy(paintOffset);
+ HTMLCanvasElement* canvas = toHTMLCanvasElement(m_layoutHTMLCanvas.node());
+
+ if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()
+ && canvas->renderingContext() && canvas->renderingContext()->isAccelerated()) {
+ if (WebLayer* layer = canvas->renderingContext()->platformLayer()) {
+ IntRect pixelSnappedRect = pixelSnappedIntRect(contentRect);
+ recordForeignLayer(
+ context, m_layoutHTMLCanvas, DisplayItem::ForeignLayerCanvas,
+ layer, pixelSnappedRect.location(), pixelSnappedRect.size());
+ return;
+ }
+ }
+
+ if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, m_layoutHTMLCanvas, paintInfo.phase))
+ return;
+
LayoutObjectDrawingRecorder drawingRecorder(context, m_layoutHTMLCanvas, paintInfo.phase, contentRect);
#if ENABLE(ASSERT)
// The drawing may be in display list mode or image mode, producing different pictures for the same result.
@@ -45,7 +61,7 @@ void HTMLCanvasPainter::paintReplaced(const PaintInfo& paintInfo, const LayoutPo
InterpolationQuality previousInterpolationQuality = context.imageInterpolationQuality();
context.setImageInterpolationQuality(interpolationQuality);
- toHTMLCanvasElement(m_layoutHTMLCanvas.node())->paint(context, paintRect);
+ canvas->paint(context, paintRect);
context.setImageInterpolationQuality(previousInterpolationQuality);
if (clip)
« no previous file with comments | « third_party/WebKit/Source/core/core.gypi ('k') | third_party/WebKit/Source/core/paint/HTMLCanvasPainterTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698