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

Side by Side Diff: third_party/WebKit/Source/core/offscreencanvas/OffscreenCanvas.cpp

Issue 1917733004: Reland of: Make OffscreenCanvas Transferable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address all comments Created 4 years, 7 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 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/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/html/canvas/CanvasRenderingContextFactory.h" 10 #include "core/html/canvas/CanvasRenderingContextFactory.h"
(...skipping 14 matching lines...) Expand all
25 void OffscreenCanvas::setWidth(unsigned width) 25 void OffscreenCanvas::setWidth(unsigned width)
26 { 26 {
27 m_size.setWidth(clampTo<int>(width)); 27 m_size.setWidth(clampTo<int>(width));
28 } 28 }
29 29
30 void OffscreenCanvas::setHeight(unsigned height) 30 void OffscreenCanvas::setHeight(unsigned height)
31 { 31 {
32 m_size.setHeight(clampTo<int>(height)); 32 m_size.setHeight(clampTo<int>(height));
33 } 33 }
34 34
35 void OffscreenCanvas::setNeutered()
36 {
37 ASSERT(!m_context);
38 m_isNeutered = true;
39 m_size.setWidth(0);
40 m_size.setHeight(0);
41 }
42
35 ImageBitmap* OffscreenCanvas::transferToImageBitmap(ExceptionState& exceptionSta te) 43 ImageBitmap* OffscreenCanvas::transferToImageBitmap(ExceptionState& exceptionSta te)
36 { 44 {
45 if (m_isNeutered) {
46 exceptionState.throwDOMException(InvalidStateError, "Cannot transfer an ImageBitmap from a detached OffscreenCanvas");
47 return nullptr;
48 }
37 if (!m_context) { 49 if (!m_context) {
38 exceptionState.throwDOMException(InvalidStateError, "Cannot transfer an ImageBitmap from an OffscreenCanvas with no context"); 50 exceptionState.throwDOMException(InvalidStateError, "Cannot transfer an ImageBitmap from an OffscreenCanvas with no context");
39 return nullptr; 51 return nullptr;
40 } 52 }
41 ImageBitmap* image = m_context->transferToImageBitmap(exceptionState); 53 ImageBitmap* image = m_context->transferToImageBitmap(exceptionState);
42 if (!image) { 54 if (!image) {
43 // Undocumented exception (not in spec) 55 // Undocumented exception (not in spec)
44 exceptionState.throwDOMException(V8GeneralError, "Out of memory"); 56 exceptionState.throwDOMException(V8GeneralError, "Out of memory");
45 } 57 }
46 return image; 58 return image;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 { 98 {
87 CanvasRenderingContext::ContextType type = renderingContextFactory->getConte xtType(); 99 CanvasRenderingContext::ContextType type = renderingContextFactory->getConte xtType();
88 ASSERT(type < CanvasRenderingContext::ContextTypeCount); 100 ASSERT(type < CanvasRenderingContext::ContextTypeCount);
89 ASSERT(!renderingContextFactories()[type]); 101 ASSERT(!renderingContextFactories()[type]);
90 renderingContextFactories()[type] = renderingContextFactory; 102 renderingContextFactories()[type] = renderingContextFactory;
91 } 103 }
92 104
93 DEFINE_TRACE(OffscreenCanvas) 105 DEFINE_TRACE(OffscreenCanvas)
94 { 106 {
95 visitor->trace(m_context); 107 visitor->trace(m_context);
96 visitor->trace(m_canvas);
97 } 108 }
98 109
99 } // namespace blink 110 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698