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