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

Side by Side Diff: third_party/WebKit/Source/modules/canvas/HTMLCanvasElementModule.cpp

Issue 2493673002: Synchronize OffscreenCanvas content with the placeholder canvas (Closed)
Patch Set: fix obsolete test Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/canvas/HTMLCanvasElementModule.h" 5 #include "modules/canvas/HTMLCanvasElementModule.h"
6 6
7 #include "core/dom/DOMNodeIds.h" 7 #include "core/dom/DOMNodeIds.h"
8 #include "core/html/canvas/CanvasContextCreationAttributes.h" 8 #include "core/html/canvas/CanvasContextCreationAttributes.h"
9 #include "core/html/canvas/CanvasRenderingContext.h" 9 #include "core/html/canvas/CanvasRenderingContext.h"
10 #include "core/offscreencanvas/OffscreenCanvas.h" 10 #include "core/offscreencanvas/OffscreenCanvas.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 HTMLCanvasElement& canvas, 58 HTMLCanvasElement& canvas,
59 ExceptionState& exceptionState) { 59 ExceptionState& exceptionState) {
60 if (canvas.renderingContext()) { 60 if (canvas.renderingContext()) {
61 exceptionState.throwDOMException( 61 exceptionState.throwDOMException(
62 InvalidStateError, 62 InvalidStateError,
63 "Cannot transfer control from a canvas that has a rendering context."); 63 "Cannot transfer control from a canvas that has a rendering context.");
64 return nullptr; 64 return nullptr;
65 } 65 }
66 OffscreenCanvas* offscreenCanvas = 66 OffscreenCanvas* offscreenCanvas =
67 OffscreenCanvas::create(canvas.width(), canvas.height()); 67 OffscreenCanvas::create(canvas.width(), canvas.height());
68 offscreenCanvas->setAssociatedCanvasId(DOMNodeIds::idForNode(&canvas)); 68
69 int canvasId = DOMNodeIds::idForNode(&canvas);
70 offscreenCanvas->setPlaceholderCanvasId(canvasId);
71 canvas.registerPlaceholder(canvasId);
69 72
70 CanvasSurfaceLayerBridge* bridge = canvas.surfaceLayerBridge(); 73 CanvasSurfaceLayerBridge* bridge = canvas.surfaceLayerBridge();
71 if (bridge) { 74 if (bridge) {
72 // If a bridge exists, it means canvas.createSurfaceLayer() has been called 75 // If a bridge exists, it means canvas.createSurfaceLayer() has been called
73 // and its SurfaceId has been populated as well. 76 // and its SurfaceId has been populated as well.
74 offscreenCanvas->setSurfaceId( 77 offscreenCanvas->setSurfaceId(
75 bridge->getSurfaceId().frame_sink_id().client_id(), 78 bridge->getSurfaceId().frame_sink_id().client_id(),
76 bridge->getSurfaceId().frame_sink_id().sink_id(), 79 bridge->getSurfaceId().frame_sink_id().sink_id(),
77 bridge->getSurfaceId().local_frame_id().local_id(), 80 bridge->getSurfaceId().local_frame_id().local_id(),
78 bridge->getSurfaceId() 81 bridge->getSurfaceId()
79 .local_frame_id() 82 .local_frame_id()
80 .nonce() 83 .nonce()
81 .GetHighForSerialization(), 84 .GetHighForSerialization(),
82 bridge->getSurfaceId() 85 bridge->getSurfaceId()
83 .local_frame_id() 86 .local_frame_id()
84 .nonce() 87 .nonce()
85 .GetLowForSerialization()); 88 .GetLowForSerialization());
86 } 89 }
87 return offscreenCanvas; 90 return offscreenCanvas;
88 } 91 }
89 } 92 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698