| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 #include "modules/webgl/WebGLContextEvent.h" | 55 #include "modules/webgl/WebGLContextEvent.h" |
| 56 #include "modules/webgl/WebGLDebugRendererInfo.h" | 56 #include "modules/webgl/WebGLDebugRendererInfo.h" |
| 57 #include "modules/webgl/WebGLDebugShaders.h" | 57 #include "modules/webgl/WebGLDebugShaders.h" |
| 58 #include "modules/webgl/WebGLDepthTexture.h" | 58 #include "modules/webgl/WebGLDepthTexture.h" |
| 59 #include "modules/webgl/WebGLDrawBuffers.h" | 59 #include "modules/webgl/WebGLDrawBuffers.h" |
| 60 #include "modules/webgl/WebGLLoseContext.h" | 60 #include "modules/webgl/WebGLLoseContext.h" |
| 61 #include "platform/CheckedInt.h" | 61 #include "platform/CheckedInt.h" |
| 62 #include "platform/graphics/gpu/DrawingBuffer.h" | 62 #include "platform/graphics/gpu/DrawingBuffer.h" |
| 63 #include "public/platform/Platform.h" | 63 #include "public/platform/Platform.h" |
| 64 #include "public/platform/WebGraphicsContext3DProvider.h" | 64 #include "public/platform/WebGraphicsContext3DProvider.h" |
| 65 #include <memory> | |
| 66 | 65 |
| 67 namespace blink { | 66 namespace blink { |
| 68 | 67 |
| 69 // An helper function for the two create() methods. The return value is an | 68 // An helper function for the two create() methods. The return value is an |
| 70 // indicate of whether the create() should return nullptr or not. | 69 // indicate of whether the create() should return nullptr or not. |
| 71 static bool shouldCreateContext(WebGraphicsContext3DProvider* contextProvider) | 70 static bool shouldCreateContext(WebGraphicsContext3DProvider* contextProvider) |
| 72 { | 71 { |
| 73 if (!contextProvider) | 72 if (!contextProvider) |
| 74 return false; | 73 return false; |
| 75 gpu::gles2::GLES2Interface* gl = contextProvider->contextGL(); | 74 gpu::gles2::GLES2Interface* gl = contextProvider->contextGL(); |
| 76 std::unique_ptr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(
gl); | 75 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(gl); |
| 77 if (!extensionsUtil) | 76 if (!extensionsUtil) |
| 78 return false; | 77 return false; |
| 79 if (extensionsUtil->supportsExtension("GL_EXT_debug_marker")) { | 78 if (extensionsUtil->supportsExtension("GL_EXT_debug_marker")) { |
| 80 String contextLabel(String::format("WebGLRenderingContext-%p", contextPr
ovider)); | 79 String contextLabel(String::format("WebGLRenderingContext-%p", contextPr
ovider)); |
| 81 gl->PushGroupMarkerEXT(0, contextLabel.ascii().data()); | 80 gl->PushGroupMarkerEXT(0, contextLabel.ascii().data()); |
| 82 } | 81 } |
| 83 return true; | 82 return true; |
| 84 } | 83 } |
| 85 | 84 |
| 86 CanvasRenderingContext* WebGLRenderingContext::Factory::create(ScriptState* scri
ptState, OffscreenCanvas* offscreenCanvas, const CanvasContextCreationAttributes
& attrs) | 85 CanvasRenderingContext* WebGLRenderingContext::Factory::create(ScriptState* scri
ptState, OffscreenCanvas* offscreenCanvas, const CanvasContextCreationAttributes
& attrs) |
| 87 { | 86 { |
| 88 WebGLContextAttributes attributes = toWebGLContextAttributes(attrs); | 87 WebGLContextAttributes attributes = toWebGLContextAttributes(attrs); |
| 89 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider(createWebGraph
icsContext3DProvider(scriptState, attributes, 1)); | 88 OwnPtr<WebGraphicsContext3DProvider> contextProvider(createWebGraphicsContex
t3DProvider(scriptState, attributes, 1)); |
| 90 if (!shouldCreateContext(contextProvider.get())) | 89 if (!shouldCreateContext(contextProvider.get())) |
| 91 return nullptr; | 90 return nullptr; |
| 92 | 91 |
| 93 WebGLRenderingContext* renderingContext = new WebGLRenderingContext(offscree
nCanvas, std::move(contextProvider), attributes); | 92 WebGLRenderingContext* renderingContext = new WebGLRenderingContext(offscree
nCanvas, std::move(contextProvider), attributes); |
| 94 if (!renderingContext->drawingBuffer()) | 93 if (!renderingContext->drawingBuffer()) |
| 95 return nullptr; | 94 return nullptr; |
| 96 renderingContext->initializeNewContext(); | 95 renderingContext->initializeNewContext(); |
| 97 renderingContext->registerContextExtensions(); | 96 renderingContext->registerContextExtensions(); |
| 98 | 97 |
| 99 return renderingContext; | 98 return renderingContext; |
| 100 } | 99 } |
| 101 | 100 |
| 102 CanvasRenderingContext* WebGLRenderingContext::Factory::create(HTMLCanvasElement
* canvas, const CanvasContextCreationAttributes& attrs, Document&) | 101 CanvasRenderingContext* WebGLRenderingContext::Factory::create(HTMLCanvasElement
* canvas, const CanvasContextCreationAttributes& attrs, Document&) |
| 103 { | 102 { |
| 104 WebGLContextAttributes attributes = toWebGLContextAttributes(attrs); | 103 WebGLContextAttributes attributes = toWebGLContextAttributes(attrs); |
| 105 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider(createWebGraph
icsContext3DProvider(canvas, attributes, 1)); | 104 OwnPtr<WebGraphicsContext3DProvider> contextProvider(createWebGraphicsContex
t3DProvider(canvas, attributes, 1)); |
| 106 if (!shouldCreateContext(contextProvider.get())) | 105 if (!shouldCreateContext(contextProvider.get())) |
| 107 return nullptr; | 106 return nullptr; |
| 108 | 107 |
| 109 WebGLRenderingContext* renderingContext = new WebGLRenderingContext(canvas,
std::move(contextProvider), attributes); | 108 WebGLRenderingContext* renderingContext = new WebGLRenderingContext(canvas,
std::move(contextProvider), attributes); |
| 110 if (!renderingContext->drawingBuffer()) { | 109 if (!renderingContext->drawingBuffer()) { |
| 111 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "Could not create a WebGL context.")); | 110 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "Could not create a WebGL context.")); |
| 112 return nullptr; | 111 return nullptr; |
| 113 } | 112 } |
| 114 renderingContext->initializeNewContext(); | 113 renderingContext->initializeNewContext(); |
| 115 renderingContext->registerContextExtensions(); | 114 renderingContext->registerContextExtensions(); |
| 116 | 115 |
| 117 return renderingContext; | 116 return renderingContext; |
| 118 } | 117 } |
| 119 | 118 |
| 120 void WebGLRenderingContext::Factory::onError(HTMLCanvasElement* canvas, const St
ring& error) | 119 void WebGLRenderingContext::Factory::onError(HTMLCanvasElement* canvas, const St
ring& error) |
| 121 { | 120 { |
| 122 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontext
creationerror, false, true, error)); | 121 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontext
creationerror, false, true, error)); |
| 123 } | 122 } |
| 124 | 123 |
| 125 WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, st
d::unique_ptr<WebGraphicsContext3DProvider> contextProvider, const WebGLContextA
ttributes& requestedAttributes) | 124 WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, Pa
ssOwnPtr<WebGraphicsContext3DProvider> contextProvider, const WebGLContextAttrib
utes& requestedAttributes) |
| 126 : WebGLRenderingContextBase(passedCanvas, std::move(contextProvider), reques
tedAttributes) | 125 : WebGLRenderingContextBase(passedCanvas, std::move(contextProvider), reques
tedAttributes) |
| 127 { | 126 { |
| 128 } | 127 } |
| 129 | 128 |
| 130 WebGLRenderingContext::WebGLRenderingContext(OffscreenCanvas* passedOffscreenCan
vas, std::unique_ptr<WebGraphicsContext3DProvider> contextProvider, const WebGLC
ontextAttributes& requestedAttributes) | 129 WebGLRenderingContext::WebGLRenderingContext(OffscreenCanvas* passedOffscreenCan
vas, PassOwnPtr<WebGraphicsContext3DProvider> contextProvider, const WebGLContex
tAttributes& requestedAttributes) |
| 131 : WebGLRenderingContextBase(passedOffscreenCanvas, std::move(contextProvider
), requestedAttributes) | 130 : WebGLRenderingContextBase(passedOffscreenCanvas, std::move(contextProvider
), requestedAttributes) |
| 132 { | 131 { |
| 133 } | 132 } |
| 134 | 133 |
| 135 WebGLRenderingContext::~WebGLRenderingContext() | 134 WebGLRenderingContext::~WebGLRenderingContext() |
| 136 { | 135 { |
| 137 } | 136 } |
| 138 | 137 |
| 139 void WebGLRenderingContext::setCanvasGetContextResult(RenderingContext& result) | 138 void WebGLRenderingContext::setCanvasGetContextResult(RenderingContext& result) |
| 140 { | 139 { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 visitor->traceWrappers(m_webglDebugShaders); | 231 visitor->traceWrappers(m_webglDebugShaders); |
| 233 visitor->traceWrappers(m_webglDrawBuffers); | 232 visitor->traceWrappers(m_webglDrawBuffers); |
| 234 visitor->traceWrappers(m_webglCompressedTextureASTC); | 233 visitor->traceWrappers(m_webglCompressedTextureASTC); |
| 235 visitor->traceWrappers(m_webglCompressedTextureATC); | 234 visitor->traceWrappers(m_webglCompressedTextureATC); |
| 236 visitor->traceWrappers(m_webglCompressedTextureETC1); | 235 visitor->traceWrappers(m_webglCompressedTextureETC1); |
| 237 visitor->traceWrappers(m_webglCompressedTexturePVRTC); | 236 visitor->traceWrappers(m_webglCompressedTexturePVRTC); |
| 238 visitor->traceWrappers(m_webglCompressedTextureS3TC); | 237 visitor->traceWrappers(m_webglCompressedTextureS3TC); |
| 239 visitor->traceWrappers(m_webglDepthTexture); | 238 visitor->traceWrappers(m_webglDepthTexture); |
| 240 } | 239 } |
| 241 } // namespace blink | 240 } // namespace blink |
| OLD | NEW |