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

Side by Side Diff: third_party/WebKit/Source/core/offscreencanvas/OffscreenCanvas.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "core/offscreencanvas/OffscreenCanvas.h" 5 #include "core/offscreencanvas/OffscreenCanvas.h"
6 6
7 #include "core/dom/ExceptionCode.h" 7 #include "core/dom/ExceptionCode.h"
8 #include "core/fileapi/Blob.h" 8 #include "core/fileapi/Blob.h"
9 #include "core/html/ImageData.h" 9 #include "core/html/ImageData.h"
10 #include "core/html/canvas/CanvasAsyncBlobCreator.h" 10 #include "core/html/canvas/CanvasAsyncBlobCreator.h"
(...skipping 14 matching lines...) Expand all
25 : m_size(size), m_originClean(true) {} 25 : m_size(size), m_originClean(true) {}
26 26
27 OffscreenCanvas* OffscreenCanvas::create(unsigned width, unsigned height) { 27 OffscreenCanvas* OffscreenCanvas::create(unsigned width, unsigned height) {
28 return new OffscreenCanvas( 28 return new OffscreenCanvas(
29 IntSize(clampTo<int>(width), clampTo<int>(height))); 29 IntSize(clampTo<int>(width), clampTo<int>(height)));
30 } 30 }
31 31
32 void OffscreenCanvas::setWidth(unsigned width, ExceptionState& exceptionState) { 32 void OffscreenCanvas::setWidth(unsigned width, ExceptionState& exceptionState) {
33 // If this OffscreenCanvas is transferred control by an html canvas, 33 // If this OffscreenCanvas is transferred control by an html canvas,
34 // its size is determined by html canvas's size and cannot be resized. 34 // its size is determined by html canvas's size and cannot be resized.
35 if (m_canvasId >= 0) { 35 if (hasPlaceholderCanvas()) {
36 exceptionState.throwDOMException(InvalidStateError, 36 exceptionState.throwDOMException(InvalidStateError,
37 "Resizing is not allowed on an " 37 "Resizing is not allowed on an "
38 "OffscreenCanvas that has been " 38 "OffscreenCanvas that has been "
39 "transferred control from a canvas."); 39 "transferred control from a canvas.");
40 return; 40 return;
41 } 41 }
42 m_size.setWidth(clampTo<int>(width)); 42 m_size.setWidth(clampTo<int>(width));
43 } 43 }
44 44
45 void OffscreenCanvas::setHeight(unsigned height, 45 void OffscreenCanvas::setHeight(unsigned height,
46 ExceptionState& exceptionState) { 46 ExceptionState& exceptionState) {
47 // Same comment as above. 47 // Same comment as above.
48 if (m_canvasId >= 0) { 48 if (hasPlaceholderCanvas()) {
49 exceptionState.throwDOMException(InvalidStateError, 49 exceptionState.throwDOMException(InvalidStateError,
50 "Resizing is not allowed on an " 50 "Resizing is not allowed on an "
51 "OffscreenCanvas that has been " 51 "OffscreenCanvas that has been "
52 "transferred control from a canvas."); 52 "transferred control from a canvas.");
53 return; 53 return;
54 } 54 }
55 m_size.setHeight(clampTo<int>(height)); 55 m_size.setHeight(clampTo<int>(height));
56 } 56 }
57 57
58 void OffscreenCanvas::setNeutered() { 58 void OffscreenCanvas::setNeutered() {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 bool OffscreenCanvas::isAccelerated() const { 177 bool OffscreenCanvas::isAccelerated() const {
178 return m_context && m_context->isAccelerated(); 178 return m_context && m_context->isAccelerated();
179 } 179 }
180 180
181 OffscreenCanvasFrameDispatcher* OffscreenCanvas::getOrCreateFrameDispatcher() { 181 OffscreenCanvasFrameDispatcher* OffscreenCanvas::getOrCreateFrameDispatcher() {
182 if (!m_frameDispatcher) { 182 if (!m_frameDispatcher) {
183 // The frame dispatcher connects the current thread of OffscreenCanvas 183 // The frame dispatcher connects the current thread of OffscreenCanvas
184 // (either main or worker) to the browser process and remains unchanged 184 // (either main or worker) to the browser process and remains unchanged
185 // throughout the lifetime of this OffscreenCanvas. 185 // throughout the lifetime of this OffscreenCanvas.
186 m_frameDispatcher = wrapUnique(new OffscreenCanvasFrameDispatcherImpl( 186 m_frameDispatcher = wrapUnique(new OffscreenCanvasFrameDispatcherImpl(
187 m_clientId, m_sinkId, m_localId, m_nonceHigh, m_nonceLow, width(), 187 m_clientId, m_sinkId, m_localId, m_nonceHigh, m_nonceLow,
188 height())); 188 m_placeholderCanvasId, width(), height()));
189 } 189 }
190 return m_frameDispatcher.get(); 190 return m_frameDispatcher.get();
191 } 191 }
192 192
193 ScriptPromise OffscreenCanvas::convertToBlob(ScriptState* scriptState, 193 ScriptPromise OffscreenCanvas::convertToBlob(ScriptState* scriptState,
194 const ImageEncodeOptions& options, 194 const ImageEncodeOptions& options,
195 ExceptionState& exceptionState) { 195 ExceptionState& exceptionState) {
196 if (this->isNeutered()) { 196 if (this->isNeutered()) {
197 exceptionState.throwDOMException(InvalidStateError, 197 exceptionState.throwDOMException(InvalidStateError,
198 "OffscreenCanvas object is detached."); 198 "OffscreenCanvas object is detached.");
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 asyncCreator->scheduleAsyncBlobCreation(options.quality()); 235 asyncCreator->scheduleAsyncBlobCreation(options.quality());
236 236
237 return resolver->promise(); 237 return resolver->promise();
238 } 238 }
239 239
240 DEFINE_TRACE(OffscreenCanvas) { 240 DEFINE_TRACE(OffscreenCanvas) {
241 visitor->trace(m_context); 241 visitor->trace(m_context);
242 } 242 }
243 243
244 } // namespace blink 244 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698