| 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> |
| 65 | 66 |
| 66 namespace blink { | 67 namespace blink { |
| 67 | 68 |
| 68 // An helper function for the two create() methods. The return value is an | 69 // An helper function for the two create() methods. The return value is an |
| 69 // indicate of whether the create() should return nullptr or not. | 70 // indicate of whether the create() should return nullptr or not. |
| 70 static bool shouldCreateContext(WebGraphicsContext3DProvider* contextProvider) | 71 static bool shouldCreateContext(WebGraphicsContext3DProvider* contextProvider) |
| 71 { | 72 { |
| 72 if (!contextProvider) | 73 if (!contextProvider) |
| 73 return false; | 74 return false; |
| 74 gpu::gles2::GLES2Interface* gl = contextProvider->contextGL(); | 75 gpu::gles2::GLES2Interface* gl = contextProvider->contextGL(); |
| 75 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(gl); | 76 std::unique_ptr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(
gl); |
| 76 if (!extensionsUtil) | 77 if (!extensionsUtil) |
| 77 return false; | 78 return false; |
| 78 if (extensionsUtil->supportsExtension("GL_EXT_debug_marker")) { | 79 if (extensionsUtil->supportsExtension("GL_EXT_debug_marker")) { |
| 79 String contextLabel(String::format("WebGLRenderingContext-%p", contextPr
ovider)); | 80 String contextLabel(String::format("WebGLRenderingContext-%p", contextPr
ovider)); |
| 80 gl->PushGroupMarkerEXT(0, contextLabel.ascii().data()); | 81 gl->PushGroupMarkerEXT(0, contextLabel.ascii().data()); |
| 81 } | 82 } |
| 82 return true; | 83 return true; |
| 83 } | 84 } |
| 84 | 85 |
| 85 CanvasRenderingContext* WebGLRenderingContext::Factory::create(ScriptState* scri
ptState, OffscreenCanvas* offscreenCanvas, const CanvasContextCreationAttributes
& attrs) | 86 CanvasRenderingContext* WebGLRenderingContext::Factory::create(ScriptState* scri
ptState, OffscreenCanvas* offscreenCanvas, const CanvasContextCreationAttributes
& attrs) |
| 86 { | 87 { |
| 87 WebGLContextAttributes attributes = toWebGLContextAttributes(attrs); | 88 WebGLContextAttributes attributes = toWebGLContextAttributes(attrs); |
| 88 OwnPtr<WebGraphicsContext3DProvider> contextProvider(createWebGraphicsContex
t3DProvider(scriptState, attributes, 1)); | 89 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider(createWebGraph
icsContext3DProvider(scriptState, attributes, 1)); |
| 89 if (!shouldCreateContext(contextProvider.get())) | 90 if (!shouldCreateContext(contextProvider.get())) |
| 90 return nullptr; | 91 return nullptr; |
| 91 | 92 |
| 92 WebGLRenderingContext* renderingContext = new WebGLRenderingContext(offscree
nCanvas, std::move(contextProvider), attributes); | 93 WebGLRenderingContext* renderingContext = new WebGLRenderingContext(offscree
nCanvas, std::move(contextProvider), attributes); |
| 93 if (!renderingContext->drawingBuffer()) | 94 if (!renderingContext->drawingBuffer()) |
| 94 return nullptr; | 95 return nullptr; |
| 95 renderingContext->initializeNewContext(); | 96 renderingContext->initializeNewContext(); |
| 96 renderingContext->registerContextExtensions(); | 97 renderingContext->registerContextExtensions(); |
| 97 | 98 |
| 98 return renderingContext; | 99 return renderingContext; |
| 99 } | 100 } |
| 100 | 101 |
| 101 CanvasRenderingContext* WebGLRenderingContext::Factory::create(HTMLCanvasElement
* canvas, const CanvasContextCreationAttributes& attrs, Document&) | 102 CanvasRenderingContext* WebGLRenderingContext::Factory::create(HTMLCanvasElement
* canvas, const CanvasContextCreationAttributes& attrs, Document&) |
| 102 { | 103 { |
| 103 WebGLContextAttributes attributes = toWebGLContextAttributes(attrs); | 104 WebGLContextAttributes attributes = toWebGLContextAttributes(attrs); |
| 104 OwnPtr<WebGraphicsContext3DProvider> contextProvider(createWebGraphicsContex
t3DProvider(canvas, attributes, 1)); | 105 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider(createWebGraph
icsContext3DProvider(canvas, attributes, 1)); |
| 105 if (!shouldCreateContext(contextProvider.get())) | 106 if (!shouldCreateContext(contextProvider.get())) |
| 106 return nullptr; | 107 return nullptr; |
| 107 | 108 |
| 108 WebGLRenderingContext* renderingContext = new WebGLRenderingContext(canvas,
std::move(contextProvider), attributes); | 109 WebGLRenderingContext* renderingContext = new WebGLRenderingContext(canvas,
std::move(contextProvider), attributes); |
| 109 if (!renderingContext->drawingBuffer()) { | 110 if (!renderingContext->drawingBuffer()) { |
| 110 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "Could not create a WebGL context.")); | 111 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "Could not create a WebGL context.")); |
| 111 return nullptr; | 112 return nullptr; |
| 112 } | 113 } |
| 113 renderingContext->initializeNewContext(); | 114 renderingContext->initializeNewContext(); |
| 114 renderingContext->registerContextExtensions(); | 115 renderingContext->registerContextExtensions(); |
| 115 | 116 |
| 116 return renderingContext; | 117 return renderingContext; |
| 117 } | 118 } |
| 118 | 119 |
| 119 void WebGLRenderingContext::Factory::onError(HTMLCanvasElement* canvas, const St
ring& error) | 120 void WebGLRenderingContext::Factory::onError(HTMLCanvasElement* canvas, const St
ring& error) |
| 120 { | 121 { |
| 121 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontext
creationerror, false, true, error)); | 122 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontext
creationerror, false, true, error)); |
| 122 } | 123 } |
| 123 | 124 |
| 124 WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, Pa
ssOwnPtr<WebGraphicsContext3DProvider> contextProvider, const WebGLContextAttrib
utes& requestedAttributes) | 125 WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, st
d::unique_ptr<WebGraphicsContext3DProvider> contextProvider, const WebGLContextA
ttributes& requestedAttributes) |
| 125 : WebGLRenderingContextBase(passedCanvas, std::move(contextProvider), reques
tedAttributes) | 126 : WebGLRenderingContextBase(passedCanvas, std::move(contextProvider), reques
tedAttributes) |
| 126 { | 127 { |
| 127 } | 128 } |
| 128 | 129 |
| 129 WebGLRenderingContext::WebGLRenderingContext(OffscreenCanvas* passedOffscreenCan
vas, PassOwnPtr<WebGraphicsContext3DProvider> contextProvider, const WebGLContex
tAttributes& requestedAttributes) | 130 WebGLRenderingContext::WebGLRenderingContext(OffscreenCanvas* passedOffscreenCan
vas, std::unique_ptr<WebGraphicsContext3DProvider> contextProvider, const WebGLC
ontextAttributes& requestedAttributes) |
| 130 : WebGLRenderingContextBase(passedOffscreenCanvas, std::move(contextProvider
), requestedAttributes) | 131 : WebGLRenderingContextBase(passedOffscreenCanvas, std::move(contextProvider
), requestedAttributes) |
| 131 { | 132 { |
| 132 } | 133 } |
| 133 | 134 |
| 134 WebGLRenderingContext::~WebGLRenderingContext() | 135 WebGLRenderingContext::~WebGLRenderingContext() |
| 135 { | 136 { |
| 136 } | 137 } |
| 137 | 138 |
| 138 void WebGLRenderingContext::setCanvasGetContextResult(RenderingContext& result) | 139 void WebGLRenderingContext::setCanvasGetContextResult(RenderingContext& result) |
| 139 { | 140 { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 visitor->traceWrappers(m_webglDebugShaders); | 232 visitor->traceWrappers(m_webglDebugShaders); |
| 232 visitor->traceWrappers(m_webglDrawBuffers); | 233 visitor->traceWrappers(m_webglDrawBuffers); |
| 233 visitor->traceWrappers(m_webglCompressedTextureASTC); | 234 visitor->traceWrappers(m_webglCompressedTextureASTC); |
| 234 visitor->traceWrappers(m_webglCompressedTextureATC); | 235 visitor->traceWrappers(m_webglCompressedTextureATC); |
| 235 visitor->traceWrappers(m_webglCompressedTextureETC1); | 236 visitor->traceWrappers(m_webglCompressedTextureETC1); |
| 236 visitor->traceWrappers(m_webglCompressedTexturePVRTC); | 237 visitor->traceWrappers(m_webglCompressedTexturePVRTC); |
| 237 visitor->traceWrappers(m_webglCompressedTextureS3TC); | 238 visitor->traceWrappers(m_webglCompressedTextureS3TC); |
| 238 visitor->traceWrappers(m_webglDepthTexture); | 239 visitor->traceWrappers(m_webglDepthTexture); |
| 239 } | 240 } |
| 240 } // namespace blink | 241 } // namespace blink |
| OLD | NEW |