| 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 "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" |
| 11 #include "wtf/MathExtras.h" | 11 #include "wtf/MathExtras.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 OffscreenCanvas::OffscreenCanvas(const IntSize& size) | 15 OffscreenCanvas::OffscreenCanvas(ExecutionContext* executionContext, const IntSi
ze& size) |
| 16 : m_size(size) | 16 : m_executionContext(executionContext) |
| 17 , m_size(size) |
| 18 , m_originClean(true) |
| 17 { | 19 { |
| 18 } | 20 } |
| 19 | 21 |
| 20 OffscreenCanvas* OffscreenCanvas::create(unsigned width, unsigned height) | 22 OffscreenCanvas* OffscreenCanvas::create(ExecutionContext* executionContext, uns
igned width, unsigned height) |
| 21 { | 23 { |
| 22 return new OffscreenCanvas(IntSize(clampTo<int>(width), clampTo<int>(height)
)); | 24 return new OffscreenCanvas(executionContext, IntSize(clampTo<int>(width), cl
ampTo<int>(height))); |
| 23 } | 25 } |
| 24 | 26 |
| 25 void OffscreenCanvas::setWidth(unsigned width) | 27 void OffscreenCanvas::setWidth(unsigned width) |
| 26 { | 28 { |
| 27 m_size.setWidth(clampTo<int>(width)); | 29 m_size.setWidth(clampTo<int>(width)); |
| 28 } | 30 } |
| 29 | 31 |
| 30 void OffscreenCanvas::setHeight(unsigned height) | 32 void OffscreenCanvas::setHeight(unsigned height) |
| 31 { | 33 { |
| 32 m_size.setHeight(clampTo<int>(height)); | 34 m_size.setHeight(clampTo<int>(height)); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 } | 97 } |
| 96 | 98 |
| 97 void OffscreenCanvas::registerRenderingContextFactory(PassOwnPtr<CanvasRendering
ContextFactory> renderingContextFactory) | 99 void OffscreenCanvas::registerRenderingContextFactory(PassOwnPtr<CanvasRendering
ContextFactory> renderingContextFactory) |
| 98 { | 100 { |
| 99 CanvasRenderingContext::ContextType type = renderingContextFactory->getConte
xtType(); | 101 CanvasRenderingContext::ContextType type = renderingContextFactory->getConte
xtType(); |
| 100 ASSERT(type < CanvasRenderingContext::ContextTypeCount); | 102 ASSERT(type < CanvasRenderingContext::ContextTypeCount); |
| 101 ASSERT(!renderingContextFactories()[type]); | 103 ASSERT(!renderingContextFactories()[type]); |
| 102 renderingContextFactories()[type] = std::move(renderingContextFactory); | 104 renderingContextFactories()[type] = std::move(renderingContextFactory); |
| 103 } | 105 } |
| 104 | 106 |
| 107 bool OffscreenCanvas::originClean() const |
| 108 { |
| 109 // TODO(crbug.com/607575): Make Settings accessable in worker and use |
| 110 // disableReadingFromCanvas to determine originClean value. |
| 111 return m_originClean; |
| 112 } |
| 113 |
| 114 SecurityOrigin* OffscreenCanvas::getSecurityOrigin() const |
| 115 { |
| 116 return getExecutionContext()->getSecurityOrigin(); |
| 117 } |
| 118 |
| 105 DEFINE_TRACE(OffscreenCanvas) | 119 DEFINE_TRACE(OffscreenCanvas) |
| 106 { | 120 { |
| 107 visitor->trace(m_context); | 121 visitor->trace(m_context); |
| 122 visitor->trace(m_executionContext); |
| 108 } | 123 } |
| 109 | 124 |
| 110 } // namespace blink | 125 } // namespace blink |
| OLD | NEW |