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

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

Issue 117703004: Free temporary GPU and memory resources held by inactive or hidden 2D canvases (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: typo Created 6 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
« no previous file with comments | « Source/core/html/HTMLCanvasElement.h ('k') | Source/core/page/Page.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLCanvasElement.cpp
diff --git a/Source/core/html/HTMLCanvasElement.cpp b/Source/core/html/HTMLCanvasElement.cpp
index ae520f32f8e825c698f310b478cd4769e155f020..4261c16be2d9766a3c6298130bc45f207be91457 100644
--- a/Source/core/html/HTMLCanvasElement.cpp
+++ b/Source/core/html/HTMLCanvasElement.cpp
@@ -71,6 +71,7 @@ static const int MaxSkiaDim = 32767; // Maximum width/height in CSS pixels.
HTMLCanvasElement::HTMLCanvasElement(Document& document)
: HTMLElement(canvasTag, document)
+ , DocumentVisibilityObserver(document)
, m_size(DefaultWidth, DefaultHeight)
, m_rendererIsCanvas(false)
, m_ignoreReset(false)
@@ -571,4 +572,26 @@ AffineTransform HTMLCanvasElement::baseTransform() const
return m_imageBuffer->baseTransform();
}
+void HTMLCanvasElement::didChangeVisibilityState(PageVisibilityState visibility)
+{
+ if (hasImageBuffer()) {
+ bool hidden = visibility != PageVisibilityStateVisible;
+ if (hidden) {
+ clearCopiedImage();
+ if (is3D()) {
+ m_imageBuffer.clear();
+ }
+ }
+ if (hasImageBuffer()) {
+ m_imageBuffer->setIsHidden(hidden);
+ }
+ }
+}
+
+void HTMLCanvasElement::didMoveToNewDocument(Document& oldDocument)
+{
+ setObservedDocument(document());
+ HTMLElement::didMoveToNewDocument(oldDocument);
+}
+
}
« no previous file with comments | « Source/core/html/HTMLCanvasElement.h ('k') | Source/core/page/Page.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698