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

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

Issue 2644653003: Make OffscreenCanvas animation in sync with its placeholder canvas's parent frame rate (Closed)
Patch Set: rebase again 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 084703a4cd27ac3ac695b4cbb24adcf7579c1a37..26c1d6f7aa326d79ccca002a2898f625eecd84ec 100644
--- a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
@@ -38,6 +38,7 @@
#include "core/dom/ExceptionCode.h"
#include "core/dom/TaskRunnerHelper.h"
#include "core/fileapi/File.h"
+#include "core/frame/FrameHost.h"
#include "core/frame/ImageBitmap.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/Settings.h"
@@ -56,6 +57,7 @@
#include "core/layout/LayoutHTMLCanvas.h"
#include "core/layout/api/LayoutViewItem.h"
#include "core/layout/compositing/PaintLayerCompositor.h"
+#include "core/page/ChromeClient.h"
#include "core/paint/PaintLayer.h"
#include "core/paint/PaintTiming.h"
#include "platform/Histogram.h"
@@ -1423,9 +1425,18 @@ String HTMLCanvasElement::getIdFromControl(const Element* element) {
void HTMLCanvasElement::createLayer() {
DCHECK(!m_surfaceLayerBridge);
- m_surfaceLayerBridge = WTF::wrapUnique(new CanvasSurfaceLayerBridge(this));
- // Creates a placeholder layer first before Surface is created.
- m_surfaceLayerBridge->createSolidColorLayer();
+ LocalFrame* frame = document().frame();
+ WebLayerTreeView* layerTreeView = nullptr;
+ // TODO(xlai): Ensure OffscreenCanvas commit() is still functional when a
+ // frame-less HTML canvas's document is reparenting under another frame.
+ // See crbug.com/683172.
+ if (frame) {
+ layerTreeView = frame->host()->chromeClient().getWebLayerTreeView(frame);
+ m_surfaceLayerBridge =
+ WTF::wrapUnique(new CanvasSurfaceLayerBridge(this, layerTreeView));
+ // Creates a placeholder layer first before Surface is created.
+ m_surfaceLayerBridge->createSolidColorLayer();
+ }
}
void HTMLCanvasElement::OnWebLayerReplaced() {

Powered by Google App Engine
This is Rietveld 408576698