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

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: Created 3 years, 11 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 363c577fb781308428af3b117f9023011c8558e7..46636c162873beff2bfb7b63f03213e8311da4e0 100644
--- a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
@@ -319,8 +319,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;
@@ -382,47 +421,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(SkCanvas* 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