| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 #include "modules/webgl/WebGLDepthTexture.h" | 59 #include "modules/webgl/WebGLDepthTexture.h" |
| 60 #include "modules/webgl/WebGLDrawBuffers.h" | 60 #include "modules/webgl/WebGLDrawBuffers.h" |
| 61 #include "modules/webgl/WebGLLoseContext.h" | 61 #include "modules/webgl/WebGLLoseContext.h" |
| 62 #include "platform/CheckedInt.h" | 62 #include "platform/CheckedInt.h" |
| 63 #include "platform/graphics/gpu/DrawingBuffer.h" | 63 #include "platform/graphics/gpu/DrawingBuffer.h" |
| 64 #include "public/platform/Platform.h" | 64 #include "public/platform/Platform.h" |
| 65 #include "public/platform/WebGraphicsContext3DProvider.h" | 65 #include "public/platform/WebGraphicsContext3DProvider.h" |
| 66 | 66 |
| 67 namespace blink { | 67 namespace blink { |
| 68 | 68 |
| 69 // An helper function for the two create() methods. The return value is an |
| 70 // indicate of whether the create() should return nullptr or not. |
| 71 static bool createHelper(WebGraphicsContext3DProvider* contextProvider) |
| 72 { |
| 73 if (!contextProvider) |
| 74 return false; |
| 75 gpu::gles2::GLES2Interface* gl = contextProvider->contextGL(); |
| 76 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(gl); |
| 77 if (!extensionsUtil) |
| 78 return false; |
| 79 if (extensionsUtil->supportsExtension("GL_EXT_debug_marker")) { |
| 80 String contextLabel(String::format("WebGLRenderingContext-%p", contextPr
ovider)); |
| 81 gl->PushGroupMarkerEXT(0, contextLabel.ascii().data()); |
| 82 } |
| 83 return true; |
| 84 } |
| 85 |
| 86 OffscreenCanvasRenderingContext* WebGLRenderingContext::OffscreenCanvasFactory::
create(ScriptState* scriptState, OffscreenCanvas* offscreenCanvas, const CanvasC
ontextCreationAttributes& attrs) |
| 87 { |
| 88 WebGLContextAttributes attributes = toWebGLContextAttributes(attrs); |
| 89 OwnPtr<WebGraphicsContext3DProvider> contextProvider(createWebGraphicsContex
t3DProvider(scriptState, attributes, 1)); |
| 90 if (!createHelper(contextProvider.get())) |
| 91 return nullptr; |
| 92 |
| 93 WebGLRenderingContext* renderingContext = new WebGLRenderingContext(offscree
nCanvas, contextProvider.release(), attributes); |
| 94 if (!renderingContext->drawingBuffer()) |
| 95 return nullptr; |
| 96 renderingContext->initializeNewContext(); |
| 97 renderingContext->registerContextExtensions(); |
| 98 |
| 99 return renderingContext; |
| 100 } |
| 101 |
| 69 CanvasRenderingContext* WebGLRenderingContext::Factory::create(HTMLCanvasElement
* canvas, const CanvasContextCreationAttributes& attrs, Document&) | 102 CanvasRenderingContext* WebGLRenderingContext::Factory::create(HTMLCanvasElement
* canvas, const CanvasContextCreationAttributes& attrs, Document&) |
| 70 { | 103 { |
| 71 WebGLContextAttributes attributes = toWebGLContextAttributes(attrs); | 104 WebGLContextAttributes attributes = toWebGLContextAttributes(attrs); |
| 72 OwnPtr<WebGraphicsContext3DProvider> contextProvider(createWebGraphicsContex
t3DProvider(canvas, attributes, 1)); | 105 OwnPtr<WebGraphicsContext3DProvider> contextProvider(createWebGraphicsContex
t3DProvider(canvas, attributes, 1)); |
| 73 if (!contextProvider) | 106 if (!createHelper(contextProvider.get())) |
| 74 return nullptr; | 107 return nullptr; |
| 75 gpu::gles2::GLES2Interface* gl = contextProvider->contextGL(); | |
| 76 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(gl); | |
| 77 if (!extensionsUtil) | |
| 78 return nullptr; | |
| 79 if (extensionsUtil->supportsExtension("GL_EXT_debug_marker")) { | |
| 80 String contextLabel(String::format("WebGLRenderingContext-%p", contextPr
ovider.get())); | |
| 81 gl->PushGroupMarkerEXT(0, contextLabel.ascii().data()); | |
| 82 } | |
| 83 | 108 |
| 84 WebGLRenderingContext* renderingContext = new WebGLRenderingContext(canvas,
contextProvider.release(), attributes); | 109 WebGLRenderingContext* renderingContext = new WebGLRenderingContext(canvas,
contextProvider.release(), attributes); |
| 85 | |
| 86 if (!renderingContext->drawingBuffer()) { | 110 if (!renderingContext->drawingBuffer()) { |
| 87 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.")); |
| 88 return nullptr; | 112 return nullptr; |
| 89 } | 113 } |
| 90 | |
| 91 renderingContext->initializeNewContext(); | 114 renderingContext->initializeNewContext(); |
| 92 renderingContext->registerContextExtensions(); | 115 renderingContext->registerContextExtensions(); |
| 93 | 116 |
| 94 return renderingContext; | 117 return renderingContext; |
| 95 } | 118 } |
| 96 | 119 |
| 97 void WebGLRenderingContext::Factory::onError(HTMLCanvasElement* canvas, const St
ring& error) | 120 void WebGLRenderingContext::Factory::onError(HTMLCanvasElement* canvas, const St
ring& error) |
| 98 { | 121 { |
| 99 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontext
creationerror, false, true, error)); | 122 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontext
creationerror, false, true, error)); |
| 100 } | 123 } |
| 101 | 124 |
| 102 WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, Pa
ssOwnPtr<WebGraphicsContext3DProvider> contextProvider, const WebGLContextAttrib
utes& requestedAttributes) | 125 WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, Pa
ssOwnPtr<WebGraphicsContext3DProvider> contextProvider, const WebGLContextAttrib
utes& requestedAttributes) |
| 103 : WebGLRenderingContextBase(passedCanvas, contextProvider, requestedAttribut
es) | 126 : WebGLRenderingContextBase(passedCanvas, contextProvider, requestedAttribut
es) |
| 104 { | 127 { |
| 105 } | 128 } |
| 106 | 129 |
| 130 WebGLRenderingContext::WebGLRenderingContext(OffscreenCanvas* passedOffscreenCan
vas, PassOwnPtr<WebGraphicsContext3DProvider> contextProvider, const WebGLContex
tAttributes& requestedAttributes) |
| 131 : WebGLRenderingContextBase(passedOffscreenCanvas, contextProvider, requeste
dAttributes) |
| 132 { |
| 133 } |
| 134 |
| 107 WebGLRenderingContext::~WebGLRenderingContext() | 135 WebGLRenderingContext::~WebGLRenderingContext() |
| 108 { | 136 { |
| 109 } | 137 } |
| 110 | 138 |
| 111 void WebGLRenderingContext::setCanvasGetContextResult(RenderingContext& result) | 139 void WebGLRenderingContext::setCanvasGetContextResult(RenderingContext& result) |
| 112 { | 140 { |
| 113 result.setWebGLRenderingContext(this); | 141 result.setWebGLRenderingContext(this); |
| 114 } | 142 } |
| 115 | 143 |
| 144 void WebGLRenderingContext::setOffscreenCanvasGetContextResult(OffscreenRenderin
gContext& result) |
| 145 { |
| 146 result.setWebGLRenderingContext(this); |
| 147 } |
| 148 |
| 149 ImageBitmap* WebGLRenderingContext::transferToImageBitmap(ExceptionState& except
ionState) |
| 150 { |
| 151 NOTIMPLEMENTED(); |
| 152 return nullptr; |
| 153 } |
| 154 |
| 116 void WebGLRenderingContext::registerContextExtensions() | 155 void WebGLRenderingContext::registerContextExtensions() |
| 117 { | 156 { |
| 118 // Register extensions. | 157 // Register extensions. |
| 119 static const char* const bothPrefixes[] = { "", "WEBKIT_", 0, }; | 158 static const char* const bothPrefixes[] = { "", "WEBKIT_", 0, }; |
| 120 | 159 |
| 121 registerExtension<ANGLEInstancedArrays>(m_angleInstancedArrays); | 160 registerExtension<ANGLEInstancedArrays>(m_angleInstancedArrays); |
| 122 registerExtension<CHROMIUMSubscribeUniform>(m_chromiumSubscribeUniform); | 161 registerExtension<CHROMIUMSubscribeUniform>(m_chromiumSubscribeUniform); |
| 123 registerExtension<EXTBlendMinMax>(m_extBlendMinMax); | 162 registerExtension<EXTBlendMinMax>(m_extBlendMinMax); |
| 124 registerExtension<EXTDisjointTimerQuery>(m_extDisjointTimerQuery); | 163 registerExtension<EXTDisjointTimerQuery>(m_extDisjointTimerQuery); |
| 125 registerExtension<EXTFragDepth>(m_extFragDepth); | 164 registerExtension<EXTFragDepth>(m_extFragDepth); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 visitor->trace(m_webglCompressedTextureASTC); | 208 visitor->trace(m_webglCompressedTextureASTC); |
| 170 visitor->trace(m_webglCompressedTextureATC); | 209 visitor->trace(m_webglCompressedTextureATC); |
| 171 visitor->trace(m_webglCompressedTextureETC1); | 210 visitor->trace(m_webglCompressedTextureETC1); |
| 172 visitor->trace(m_webglCompressedTexturePVRTC); | 211 visitor->trace(m_webglCompressedTexturePVRTC); |
| 173 visitor->trace(m_webglCompressedTextureS3TC); | 212 visitor->trace(m_webglCompressedTextureS3TC); |
| 174 visitor->trace(m_webglDepthTexture); | 213 visitor->trace(m_webglDepthTexture); |
| 175 WebGLRenderingContextBase::trace(visitor); | 214 WebGLRenderingContextBase::trace(visitor); |
| 176 } | 215 } |
| 177 | 216 |
| 178 } // namespace blink | 217 } // namespace blink |
| OLD | NEW |