| 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/webgl/WebGL2RenderingContext.h" | 5 #include "modules/webgl/WebGL2RenderingContext.h" |
| 6 | 6 |
| 7 #include "bindings/modules/v8/OffscreenCanvasRenderingContext2DOrWebGLRenderingC
ontextOrWebGL2RenderingContext.h" | 7 #include "bindings/modules/v8/OffscreenCanvasRenderingContext2DOrWebGLRenderingC
ontextOrWebGL2RenderingContext.h" |
| 8 #include "bindings/modules/v8/RenderingContext.h" | 8 #include "bindings/modules/v8/RenderingContext.h" |
| 9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
| 10 #include "core/frame/Settings.h" | 10 #include "core/frame/Settings.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 CanvasRenderingContext* WebGL2RenderingContext::Factory::create(HTMLCanvasElemen
t* canvas, const CanvasContextCreationAttributes& attrs, Document&) | 35 CanvasRenderingContext* WebGL2RenderingContext::Factory::create(HTMLCanvasElemen
t* canvas, const CanvasContextCreationAttributes& attrs, Document&) |
| 36 { | 36 { |
| 37 if (!RuntimeEnabledFeatures::unsafeES3APIsEnabled()) { | 37 if (!RuntimeEnabledFeatures::unsafeES3APIsEnabled()) { |
| 38 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "Creation of WebGL2 contexts disabled.")); | 38 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "Creation of WebGL2 contexts disabled.")); |
| 39 return nullptr; | 39 return nullptr; |
| 40 } | 40 } |
| 41 | 41 |
| 42 WebGLContextAttributes attributes = toWebGLContextAttributes(attrs); | 42 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider(createWebGraph
icsContext3DProvider(canvas, attrs, 2)); |
| 43 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider(createWebGraph
icsContext3DProvider(canvas, attributes, 2)); | |
| 44 if (!contextProvider) | 43 if (!contextProvider) |
| 45 return nullptr; | 44 return nullptr; |
| 46 gpu::gles2::GLES2Interface* gl = contextProvider->contextGL(); | 45 gpu::gles2::GLES2Interface* gl = contextProvider->contextGL(); |
| 47 std::unique_ptr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(
gl); | 46 std::unique_ptr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(
gl); |
| 48 if (!extensionsUtil) | 47 if (!extensionsUtil) |
| 49 return nullptr; | 48 return nullptr; |
| 50 if (extensionsUtil->supportsExtension("GL_EXT_debug_marker")) { | 49 if (extensionsUtil->supportsExtension("GL_EXT_debug_marker")) { |
| 51 String contextLabel(String::format("WebGL2RenderingContext-%p", contextP
rovider.get())); | 50 String contextLabel(String::format("WebGL2RenderingContext-%p", contextP
rovider.get())); |
| 52 gl->PushGroupMarkerEXT(0, contextLabel.ascii().data()); | 51 gl->PushGroupMarkerEXT(0, contextLabel.ascii().data()); |
| 53 } | 52 } |
| 54 | 53 |
| 55 WebGL2RenderingContext* renderingContext = new WebGL2RenderingContext(canvas
, std::move(contextProvider), attributes); | 54 WebGL2RenderingContext* renderingContext = new WebGL2RenderingContext(canvas
, std::move(contextProvider), attrs); |
| 56 | 55 |
| 57 if (!renderingContext->drawingBuffer()) { | 56 if (!renderingContext->drawingBuffer()) { |
| 58 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "Could not create a WebGL2 context.")); | 57 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "Could not create a WebGL2 context.")); |
| 59 return nullptr; | 58 return nullptr; |
| 60 } | 59 } |
| 61 | 60 |
| 62 renderingContext->initializeNewContext(); | 61 renderingContext->initializeNewContext(); |
| 63 renderingContext->registerContextExtensions(); | 62 renderingContext->registerContextExtensions(); |
| 64 | 63 |
| 65 return renderingContext; | 64 return renderingContext; |
| 66 } | 65 } |
| 67 | 66 |
| 68 void WebGL2RenderingContext::Factory::onError(HTMLCanvasElement* canvas, const S
tring& error) | 67 void WebGL2RenderingContext::Factory::onError(HTMLCanvasElement* canvas, const S
tring& error) |
| 69 { | 68 { |
| 70 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontext
creationerror, false, true, error)); | 69 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontext
creationerror, false, true, error)); |
| 71 } | 70 } |
| 72 | 71 |
| 73 WebGL2RenderingContext::WebGL2RenderingContext(HTMLCanvasElement* passedCanvas,
std::unique_ptr<WebGraphicsContext3DProvider> contextProvider, const WebGLContex
tAttributes& requestedAttributes) | 72 WebGL2RenderingContext::WebGL2RenderingContext(HTMLCanvasElement* passedCanvas,
std::unique_ptr<WebGraphicsContext3DProvider> contextProvider, const CanvasConte
xtCreationAttributes& requestedAttributes) |
| 74 : WebGL2RenderingContextBase(passedCanvas, std::move(contextProvider), reque
stedAttributes) | 73 : WebGL2RenderingContextBase(passedCanvas, std::move(contextProvider), reque
stedAttributes) |
| 75 { | 74 { |
| 76 } | 75 } |
| 77 | 76 |
| 78 WebGL2RenderingContext::~WebGL2RenderingContext() | 77 WebGL2RenderingContext::~WebGL2RenderingContext() |
| 79 { | 78 { |
| 80 | 79 |
| 81 } | 80 } |
| 82 | 81 |
| 83 void WebGL2RenderingContext::setCanvasGetContextResult(RenderingContext& result) | 82 void WebGL2RenderingContext::setCanvasGetContextResult(RenderingContext& result) |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 visitor->traceWrappers(m_webglCompressedTextureATC); | 139 visitor->traceWrappers(m_webglCompressedTextureATC); |
| 141 visitor->traceWrappers(m_webglCompressedTextureETC1); | 140 visitor->traceWrappers(m_webglCompressedTextureETC1); |
| 142 visitor->traceWrappers(m_webglCompressedTexturePVRTC); | 141 visitor->traceWrappers(m_webglCompressedTexturePVRTC); |
| 143 visitor->traceWrappers(m_webglCompressedTextureS3TC); | 142 visitor->traceWrappers(m_webglCompressedTextureS3TC); |
| 144 visitor->traceWrappers(m_webglDebugRendererInfo); | 143 visitor->traceWrappers(m_webglDebugRendererInfo); |
| 145 visitor->traceWrappers(m_webglDebugShaders); | 144 visitor->traceWrappers(m_webglDebugShaders); |
| 146 visitor->traceWrappers(m_webglLoseContext); | 145 visitor->traceWrappers(m_webglLoseContext); |
| 147 } | 146 } |
| 148 | 147 |
| 149 } // namespace blink | 148 } // namespace blink |
| OLD | NEW |