| OLD | NEW |
| 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 "modules/offscreencanvas/OffscreenCanvas.h" | 5 #include "modules/offscreencanvas/OffscreenCanvas.h" |
| 6 | 6 |
| 7 #include "core/dom/ExceptionCode.h" | 7 #include "core/dom/ExceptionCode.h" |
| 8 #if !ENABLE(OILPAN) | 8 #if !ENABLE(OILPAN) |
| 9 #include "core/frame/ImageBitmap.h" // So ~RefPtr can call unref() | 9 #include "core/frame/ImageBitmap.h" // So ~RefPtr can call unref() |
| 10 #endif | 10 #endif |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 } else { | 58 } else { |
| 59 m_context = factory->create(this, attributes); | 59 m_context = factory->create(this, attributes); |
| 60 } | 60 } |
| 61 | 61 |
| 62 // TODO: When there're more than one context type implemented in the future, | 62 // TODO: When there're more than one context type implemented in the future, |
| 63 // the return type here should be changed to base class of all Offscreen | 63 // the return type here should be changed to base class of all Offscreen |
| 64 // context types. | 64 // context types. |
| 65 return static_cast<OffscreenCanvasRenderingContext2D*>(m_context.get()); | 65 return static_cast<OffscreenCanvasRenderingContext2D*>(m_context.get()); |
| 66 } | 66 } |
| 67 | 67 |
| 68 RawPtr<ImageBitmap> OffscreenCanvas::transferToImageBitmap(ExceptionState& excep
tionState) | 68 ImageBitmap* OffscreenCanvas::transferToImageBitmap(ExceptionState& exceptionSta
te) |
| 69 { | 69 { |
| 70 if (!m_context) { | 70 if (!m_context) { |
| 71 exceptionState.throwDOMException(InvalidStateError, "Cannot transfer an
ImageBitmap from an OffscreenCanvas with no context"); | 71 exceptionState.throwDOMException(InvalidStateError, "Cannot transfer an
ImageBitmap from an OffscreenCanvas with no context"); |
| 72 return nullptr; | 72 return nullptr; |
| 73 } | 73 } |
| 74 RawPtr<ImageBitmap> image = m_context->transferToImageBitmap(exceptionState)
; | 74 ImageBitmap* image = m_context->transferToImageBitmap(exceptionState); |
| 75 if (!image) { | 75 if (!image) { |
| 76 // Undocumented exception (not in spec) | 76 // Undocumented exception (not in spec) |
| 77 exceptionState.throwDOMException(V8GeneralError, "Out of memory"); | 77 exceptionState.throwDOMException(V8GeneralError, "Out of memory"); |
| 78 } | 78 } |
| 79 return image.release(); | 79 return image; |
| 80 } | 80 } |
| 81 | 81 |
| 82 OffscreenCanvasRenderingContext2D* OffscreenCanvas::renderingContext() const | 82 OffscreenCanvasRenderingContext2D* OffscreenCanvas::renderingContext() const |
| 83 { | 83 { |
| 84 // TODO: When there're more than one context type implemented in the future, | 84 // TODO: When there're more than one context type implemented in the future, |
| 85 // the return type here should be changed to base class of all Offscreen | 85 // the return type here should be changed to base class of all Offscreen |
| 86 // context types. | 86 // context types. |
| 87 return static_cast<OffscreenCanvasRenderingContext2D*>(m_context.get()); | 87 return static_cast<OffscreenCanvasRenderingContext2D*>(m_context.get()); |
| 88 } | 88 } |
| 89 | 89 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 107 renderingContextFactories()[type] = renderingContextFactory; | 107 renderingContextFactories()[type] = renderingContextFactory; |
| 108 } | 108 } |
| 109 | 109 |
| 110 DEFINE_TRACE(OffscreenCanvas) | 110 DEFINE_TRACE(OffscreenCanvas) |
| 111 { | 111 { |
| 112 visitor->trace(m_context); | 112 visitor->trace(m_context); |
| 113 visitor->trace(m_canvas); | 113 visitor->trace(m_canvas); |
| 114 } | 114 } |
| 115 | 115 |
| 116 } // namespace blink | 116 } // namespace blink |
| OLD | NEW |