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

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

Issue 1881563003: Implement OffscreenCanvas.getContext('webgl') (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase and remove static_cast 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 return nullptr; 51 return nullptr;
52 } 52 }
53 ImageBitmap* image = m_context->transferToImageBitmap(exceptionState); 53 ImageBitmap* image = m_context->transferToImageBitmap(exceptionState);
54 if (!image) { 54 if (!image) {
55 // Undocumented exception (not in spec) 55 // Undocumented exception (not in spec)
56 exceptionState.throwDOMException(V8GeneralError, "Out of memory"); 56 exceptionState.throwDOMException(V8GeneralError, "Out of memory");
57 } 57 }
58 return image; 58 return image;
59 } 59 }
60 60
61 CanvasRenderingContext* OffscreenCanvas::getCanvasRenderingContext(const String& id, const CanvasContextCreationAttributes& attributes) 61 CanvasRenderingContext* OffscreenCanvas::getCanvasRenderingContext(ScriptState* scriptState, const String& id, const CanvasContextCreationAttributes& attributes )
62 { 62 {
63 CanvasRenderingContext::ContextType contextType = CanvasRenderingContext::co ntextTypeFromId(id); 63 CanvasRenderingContext::ContextType contextType = CanvasRenderingContext::co ntextTypeFromId(id);
64 64
65 // Unknown type. 65 // Unknown type.
66 if (contextType == CanvasRenderingContext::ContextTypeCount) 66 if (contextType == CanvasRenderingContext::ContextTypeCount)
67 return nullptr; 67 return nullptr;
68 68
69 CanvasRenderingContextFactory* factory = getRenderingContextFactory(contextT ype); 69 CanvasRenderingContextFactory* factory = getRenderingContextFactory(contextT ype);
70 if (!factory) 70 if (!factory)
71 return nullptr; 71 return nullptr;
72 72
73 if (m_context) { 73 if (m_context) {
74 if (m_context->getContextType() != contextType) { 74 if (m_context->getContextType() != contextType) {
75 factory->onError(this, "OffscreenCanvas has an existing context of a different type"); 75 factory->onError(this, "OffscreenCanvas has an existing context of a different type");
76 return nullptr; 76 return nullptr;
77 } 77 }
78 } else { 78 } else {
79 m_context = factory->create(this, attributes); 79 m_context = factory->create(scriptState, this, attributes);
80 } 80 }
81 81
82 return m_context.get(); 82 return m_context.get();
83 } 83 }
84 84
85 OffscreenCanvas::ContextFactoryVector& OffscreenCanvas::renderingContextFactorie s() 85 OffscreenCanvas::ContextFactoryVector& OffscreenCanvas::renderingContextFactorie s()
86 { 86 {
87 DEFINE_STATIC_LOCAL(ContextFactoryVector, s_contextFactories, (CanvasRenderi ngContext::ContextTypeCount)); 87 DEFINE_STATIC_LOCAL(ContextFactoryVector, s_contextFactories, (CanvasRenderi ngContext::ContextTypeCount));
88 return s_contextFactories; 88 return s_contextFactories;
89 } 89 }
(...skipping 11 matching lines...) Expand all
101 ASSERT(!renderingContextFactories()[type]); 101 ASSERT(!renderingContextFactories()[type]);
102 renderingContextFactories()[type] = std::move(renderingContextFactory); 102 renderingContextFactories()[type] = std::move(renderingContextFactory);
103 } 103 }
104 104
105 DEFINE_TRACE(OffscreenCanvas) 105 DEFINE_TRACE(OffscreenCanvas)
106 { 106 {
107 visitor->trace(m_context); 107 visitor->trace(m_context);
108 } 108 }
109 109
110 } // namespace blink 110 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698