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 "config.h" | 5 #include "config.h" |
6 #include "core/html/canvas/WebGL2RenderingContext.h" | 6 #include "core/html/canvas/WebGL2RenderingContext.h" |
7 | 7 |
8 #include "core/frame/LocalFrame.h" | 8 #include "core/frame/LocalFrame.h" |
9 #include "core/frame/Settings.h" | 9 #include "core/frame/Settings.h" |
10 #include "core/html/canvas/CHROMIUMSubscribeUniform.h" | 10 #include "core/html/canvas/CHROMIUMSubscribeUniform.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 namespace blink { | 27 namespace blink { |
28 | 28 |
29 PassOwnPtrWillBeRawPtr<WebGL2RenderingContext> WebGL2RenderingContext::create(HT
MLCanvasElement* canvas, const CanvasContextCreationAttributes& attrs) | 29 PassOwnPtrWillBeRawPtr<WebGL2RenderingContext> WebGL2RenderingContext::create(HT
MLCanvasElement* canvas, const CanvasContextCreationAttributes& attrs) |
30 { | 30 { |
31 if (!RuntimeEnabledFeatures::unsafeES3APIsEnabled()) { | 31 if (!RuntimeEnabledFeatures::unsafeES3APIsEnabled()) { |
32 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "Creation of WebGL2 contexts disabled.")); | 32 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "Creation of WebGL2 contexts disabled.")); |
33 return nullptr; | 33 return nullptr; |
34 } | 34 } |
35 | 35 |
36 WebGLContextAttributes attributes = toWebGLContextAttributes(attrs); | 36 WebGLContextAttributes attributes = toWebGLContextAttributes(attrs); |
37 OwnPtr<blink::WebGraphicsContext3D> context(createWebGraphicsContext3D(canva
s, attributes, 2)); | 37 OwnPtr<WebGraphicsContext3D> context(createWebGraphicsContext3D(canvas, attr
ibutes, 2)); |
38 if (!context) | 38 if (!context) |
39 return nullptr; | 39 return nullptr; |
40 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(context.g
et()); | 40 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(context.g
et()); |
41 if (!extensionsUtil) | 41 if (!extensionsUtil) |
42 return nullptr; | 42 return nullptr; |
43 if (extensionsUtil->supportsExtension("GL_EXT_debug_marker")) { | 43 if (extensionsUtil->supportsExtension("GL_EXT_debug_marker")) { |
44 String contextLabel(String::format("WebGL2RenderingContext-%p", context.
get())); | 44 String contextLabel(String::format("WebGL2RenderingContext-%p", context.
get())); |
45 context->pushGroupMarkerEXT(contextLabel.ascii().data()); | 45 context->pushGroupMarkerEXT(contextLabel.ascii().data()); |
46 } | 46 } |
47 | 47 |
48 OwnPtrWillBeRawPtr<WebGL2RenderingContext> renderingContext = adoptPtrWillBe
Noop(new WebGL2RenderingContext(canvas, context.release(), attributes)); | 48 OwnPtrWillBeRawPtr<WebGL2RenderingContext> renderingContext = adoptPtrWillBe
Noop(new WebGL2RenderingContext(canvas, context.release(), attributes)); |
49 renderingContext->initializeNewContext(); | 49 renderingContext->initializeNewContext(); |
50 renderingContext->registerContextExtensions(); | 50 renderingContext->registerContextExtensions(); |
51 | 51 |
52 if (!renderingContext->drawingBuffer()) { | 52 if (!renderingContext->drawingBuffer()) { |
53 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "Could not create a WebGL2 context.")); | 53 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "Could not create a WebGL2 context.")); |
54 return nullptr; | 54 return nullptr; |
55 } | 55 } |
56 | 56 |
57 return renderingContext.release(); | 57 return renderingContext.release(); |
58 } | 58 } |
59 | 59 |
60 WebGL2RenderingContext::WebGL2RenderingContext(HTMLCanvasElement* passedCanvas,
PassOwnPtr<blink::WebGraphicsContext3D> context, const WebGLContextAttributes& r
equestedAttributes) | 60 WebGL2RenderingContext::WebGL2RenderingContext(HTMLCanvasElement* passedCanvas,
PassOwnPtr<WebGraphicsContext3D> context, const WebGLContextAttributes& requeste
dAttributes) |
61 : WebGL2RenderingContextBase(passedCanvas, context, requestedAttributes) | 61 : WebGL2RenderingContextBase(passedCanvas, context, requestedAttributes) |
62 { | 62 { |
63 } | 63 } |
64 | 64 |
65 WebGL2RenderingContext::~WebGL2RenderingContext() | 65 WebGL2RenderingContext::~WebGL2RenderingContext() |
66 { | 66 { |
67 | 67 |
68 } | 68 } |
69 | 69 |
70 void WebGL2RenderingContext::registerContextExtensions() | 70 void WebGL2RenderingContext::registerContextExtensions() |
(...skipping 20 matching lines...) Expand all Loading... |
91 visitor->trace(m_webglCompressedTextureETC1); | 91 visitor->trace(m_webglCompressedTextureETC1); |
92 visitor->trace(m_webglCompressedTexturePVRTC); | 92 visitor->trace(m_webglCompressedTexturePVRTC); |
93 visitor->trace(m_webglCompressedTextureS3TC); | 93 visitor->trace(m_webglCompressedTextureS3TC); |
94 visitor->trace(m_webglDebugRendererInfo); | 94 visitor->trace(m_webglDebugRendererInfo); |
95 visitor->trace(m_webglDebugShaders); | 95 visitor->trace(m_webglDebugShaders); |
96 visitor->trace(m_webglLoseContext); | 96 visitor->trace(m_webglLoseContext); |
97 WebGL2RenderingContextBase::trace(visitor); | 97 WebGL2RenderingContextBase::trace(visitor); |
98 } | 98 } |
99 | 99 |
100 } // namespace blink | 100 } // namespace blink |
OLD | NEW |