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

Unified Diff: third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp

Issue 2653933003: Make stream captures work on canvases that are not in the DOM. (Closed)
Patch Set: rebase Created 3 years, 10 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/html/HTMLCanvasElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
index eba91ca79608f05aca6d5e730789e2b46d794800..5e84495edfae63401b4f9fbcaa38135577e6633f 100644
--- a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
@@ -325,8 +325,47 @@ void HTMLCanvasElement::didDraw(const FloatRect& rect) {
buffer()->didDraw(rect);
}
-void HTMLCanvasElement::didFinalizeFrame() {
+void HTMLCanvasElement::finalizeFrame() {
+ if (hasImageBuffer())
+ m_imageBuffer->finalizeFrame();
+ m_context->incrementFrameCount();
notifyListenersCanvasChanged();
+}
+
+void HTMLCanvasElement::didDisableAcceleration() {
+ // We must force a paint invalidation on the canvas even if it's
+ // content did not change because it layer was destroyed.
+ didDraw(FloatRect(0, 0, size().width(), size().height()));
+}
+
+void HTMLCanvasElement::restoreCanvasMatrixClipStack(SkCanvas* canvas) const {
+ if (m_context)
+ m_context->restoreCanvasMatrixClipStack(canvas);
+}
+
+void HTMLCanvasElement::doDeferredPaintInvalidation() {
+ DCHECK(!m_dirtyRect.isEmpty());
+ if (m_context->is2d()) {
+ FloatRect srcRect(0, 0, size().width(), size().height());
+ m_dirtyRect.intersect(srcRect);
+ LayoutBox* lb = layoutBox();
+ FloatRect invalidationRect;
+ if (lb) {
+ FloatRect mappedDirtyRect =
+ mapRect(m_dirtyRect, srcRect, FloatRect(lb->contentBoxRect()));
+ if (m_context->isAccelerated()) {
+ // Accelerated 2D canvases need the dirty rect to be expressed relative
+ // to the content box, as opposed to the layout box.
+ mappedDirtyRect.move(-lb->contentBoxOffset());
+ }
+ invalidationRect = mappedDirtyRect;
+ } else {
+ invalidationRect = m_dirtyRect;
+ }
+ if (hasImageBuffer()) {
+ m_imageBuffer->doPaintInvalidation(invalidationRect);
+ }
+ }
if (m_dirtyRect.isEmpty())
return;
@@ -388,48 +427,6 @@ void HTMLCanvasElement::didFinalizeFrame() {
m_pendingRenderingModeSwitch = false;
}
- m_context->incrementFrameCount();
-}
-
-void HTMLCanvasElement::didDisableAcceleration() {
- // We must force a paint invalidation on the canvas even if it's
- // content did not change because it layer was destroyed.
- didDraw(FloatRect(0, 0, size().width(), size().height()));
-}
-
-void HTMLCanvasElement::restoreCanvasMatrixClipStack(
- PaintCanvas* canvas) const {
- if (m_context)
- m_context->restoreCanvasMatrixClipStack(canvas);
-}
-
-void HTMLCanvasElement::doDeferredPaintInvalidation() {
- DCHECK(!m_dirtyRect.isEmpty());
- if (!m_context->is2d()) {
- didFinalizeFrame();
- } else {
- FloatRect srcRect(0, 0, size().width(), size().height());
- m_dirtyRect.intersect(srcRect);
- LayoutBox* lb = layoutBox();
- FloatRect invalidationRect;
- if (lb) {
- FloatRect mappedDirtyRect =
- mapRect(m_dirtyRect, srcRect, FloatRect(lb->contentBoxRect()));
- if (m_context->isAccelerated()) {
- // Accelerated 2D canvases need the dirty rect to be expressed relative
- // to the content box, as opposed to the layout box.
- mappedDirtyRect.move(-lb->contentBoxOffset());
- }
- invalidationRect = mappedDirtyRect;
- } else {
- invalidationRect = m_dirtyRect;
- }
- if (hasImageBuffer()) {
- m_imageBuffer->finalizeFrame(invalidationRect);
- } else {
- didFinalizeFrame();
- }
- }
DCHECK(m_dirtyRect.isEmpty());
}

Powered by Google App Engine
This is Rietveld 408576698