| 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/html/canvas/CanvasContextCreationAttributes.h" | 7 #include "core/html/canvas/CanvasContextCreationAttributes.h" |
| 8 #include "modules/offscreencanvas/OffscreenCanvasRenderingContext.h" | 8 #include "modules/offscreencanvas/OffscreenCanvasRenderingContext.h" |
| 9 #include "modules/offscreencanvas/OffscreenCanvasRenderingContextFactory.h" | 9 #include "modules/offscreencanvas/OffscreenCanvasRenderingContextFactory.h" |
| 10 #include "modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.h" | 10 #include "modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 // Unknown type. | 39 // Unknown type. |
| 40 if (contextType == OffscreenCanvasRenderingContext::ContextTypeCount) | 40 if (contextType == OffscreenCanvasRenderingContext::ContextTypeCount) |
| 41 return nullptr; | 41 return nullptr; |
| 42 | 42 |
| 43 OffscreenCanvasRenderingContextFactory* factory = getRenderingContextFactory
(contextType); | 43 OffscreenCanvasRenderingContextFactory* factory = getRenderingContextFactory
(contextType); |
| 44 if (!factory) | 44 if (!factory) |
| 45 return nullptr; | 45 return nullptr; |
| 46 | 46 |
| 47 if (m_context) { | 47 if (m_context) { |
| 48 if (m_context->contextType() != contextType) { | 48 if (m_context->getContextType() != contextType) { |
| 49 factory->onError(this, "OffscreenCanvas has an existing context of a
different type"); | 49 factory->onError(this, "OffscreenCanvas has an existing context of a
different type"); |
| 50 return nullptr; | 50 return nullptr; |
| 51 } | 51 } |
| 52 } else { | 52 } else { |
| 53 m_context = factory->create(this, attributes); | 53 m_context = factory->create(this, attributes); |
| 54 } | 54 } |
| 55 | 55 |
| 56 // TODO: When there're more than one context type implemented in the future, | 56 // TODO: When there're more than one context type implemented in the future, |
| 57 // the return type here should be changed to base class of all Offscreen | 57 // the return type here should be changed to base class of all Offscreen |
| 58 // context types. | 58 // context types. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 74 } | 74 } |
| 75 | 75 |
| 76 OffscreenCanvasRenderingContextFactory* OffscreenCanvas::getRenderingContextFact
ory(int type) | 76 OffscreenCanvasRenderingContextFactory* OffscreenCanvas::getRenderingContextFact
ory(int type) |
| 77 { | 77 { |
| 78 ASSERT(type < OffscreenCanvasRenderingContext::ContextTypeCount); | 78 ASSERT(type < OffscreenCanvasRenderingContext::ContextTypeCount); |
| 79 return renderingContextFactories()[type].get(); | 79 return renderingContextFactories()[type].get(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void OffscreenCanvas::registerRenderingContextFactory(PassOwnPtr<OffscreenCanvas
RenderingContextFactory> renderingContextFactory) | 82 void OffscreenCanvas::registerRenderingContextFactory(PassOwnPtr<OffscreenCanvas
RenderingContextFactory> renderingContextFactory) |
| 83 { | 83 { |
| 84 OffscreenCanvasRenderingContext::ContextType type = renderingContextFactory-
>contextType(); | 84 OffscreenCanvasRenderingContext::ContextType type = renderingContextFactory-
>getContextType(); |
| 85 ASSERT(type < OffscreenCanvasRenderingContext::ContextTypeCount); | 85 ASSERT(type < OffscreenCanvasRenderingContext::ContextTypeCount); |
| 86 ASSERT(!renderingContextFactories()[type]); | 86 ASSERT(!renderingContextFactories()[type]); |
| 87 renderingContextFactories()[type] = renderingContextFactory; | 87 renderingContextFactories()[type] = renderingContextFactory; |
| 88 } | 88 } |
| 89 | 89 |
| 90 DEFINE_TRACE(OffscreenCanvas) | 90 DEFINE_TRACE(OffscreenCanvas) |
| 91 { | 91 { |
| 92 visitor->trace(m_context); | 92 visitor->trace(m_context); |
| 93 } | 93 } |
| 94 | 94 |
| 95 } // namespace blink | 95 } // namespace blink |
| OLD | NEW |