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 #include <memory> | |
13 | 12 |
14 namespace blink { | 13 namespace blink { |
15 | 14 |
16 OffscreenCanvas::OffscreenCanvas(const IntSize& size) | 15 OffscreenCanvas::OffscreenCanvas(const IntSize& size) |
17 : m_size(size) | 16 : m_size(size) |
18 , m_originClean(true) | 17 , m_originClean(true) |
19 { | 18 { |
20 } | 19 } |
21 | 20 |
22 OffscreenCanvas* OffscreenCanvas::create(unsigned width, unsigned height) | 21 OffscreenCanvas* OffscreenCanvas::create(unsigned width, unsigned height) |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 DEFINE_STATIC_LOCAL(ContextFactoryVector, s_contextFactories, (CanvasRenderi
ngContext::ContextTypeCount)); | 88 DEFINE_STATIC_LOCAL(ContextFactoryVector, s_contextFactories, (CanvasRenderi
ngContext::ContextTypeCount)); |
90 return s_contextFactories; | 89 return s_contextFactories; |
91 } | 90 } |
92 | 91 |
93 CanvasRenderingContextFactory* OffscreenCanvas::getRenderingContextFactory(int t
ype) | 92 CanvasRenderingContextFactory* OffscreenCanvas::getRenderingContextFactory(int t
ype) |
94 { | 93 { |
95 ASSERT(type < CanvasRenderingContext::ContextTypeCount); | 94 ASSERT(type < CanvasRenderingContext::ContextTypeCount); |
96 return renderingContextFactories()[type].get(); | 95 return renderingContextFactories()[type].get(); |
97 } | 96 } |
98 | 97 |
99 void OffscreenCanvas::registerRenderingContextFactory(std::unique_ptr<CanvasRend
eringContextFactory> renderingContextFactory) | 98 void OffscreenCanvas::registerRenderingContextFactory(PassOwnPtr<CanvasRendering
ContextFactory> renderingContextFactory) |
100 { | 99 { |
101 CanvasRenderingContext::ContextType type = renderingContextFactory->getConte
xtType(); | 100 CanvasRenderingContext::ContextType type = renderingContextFactory->getConte
xtType(); |
102 ASSERT(type < CanvasRenderingContext::ContextTypeCount); | 101 ASSERT(type < CanvasRenderingContext::ContextTypeCount); |
103 ASSERT(!renderingContextFactories()[type]); | 102 ASSERT(!renderingContextFactories()[type]); |
104 renderingContextFactories()[type] = std::move(renderingContextFactory); | 103 renderingContextFactories()[type] = std::move(renderingContextFactory); |
105 } | 104 } |
106 | 105 |
107 bool OffscreenCanvas::originClean() const | 106 bool OffscreenCanvas::originClean() const |
108 { | 107 { |
109 // TODO(crbug.com/607575): Make Settings accessable in worker and use | 108 // TODO(crbug.com/607575): Make Settings accessable in worker and use |
110 // disableReadingFromCanvas to determine originClean value. | 109 // disableReadingFromCanvas to determine originClean value. |
111 return m_originClean; | 110 return m_originClean; |
112 } | 111 } |
113 | 112 |
114 DEFINE_TRACE(OffscreenCanvas) | 113 DEFINE_TRACE(OffscreenCanvas) |
115 { | 114 { |
116 visitor->trace(m_context); | 115 visitor->trace(m_context); |
117 } | 116 } |
118 | 117 |
119 } // namespace blink | 118 } // namespace blink |
OLD | NEW |