| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 64 |
| 65 namespace blink { | 65 namespace blink { |
| 66 | 66 |
| 67 PassOwnPtrWillBeRawPtr<CanvasRenderingContext> WebGLRenderingContext::Factory::c
reate(HTMLCanvasElement* canvas, const CanvasContextCreationAttributes& attrs, D
ocument&) | 67 PassOwnPtrWillBeRawPtr<CanvasRenderingContext> WebGLRenderingContext::Factory::c
reate(HTMLCanvasElement* canvas, ScriptState* scriptState, const CanvasContextCr
eationAttributes& attrs, Document&) |
| 68 { | 68 { |
| 69 WebGLContextAttributes attributes = toWebGLContextAttributes(attrs); | 69 WebGLContextAttributes attributes = toWebGLContextAttributes(attrs); |
| 70 OwnPtr<WebGraphicsContext3D> context(createWebGraphicsContext3D(canvas, attr
ibutes, 1)); | 70 OwnPtr<WebGraphicsContext3D> context(createWebGraphicsContext3D(canvas, attr
ibutes, 1)); |
| 71 if (!context) | 71 if (!context) |
| 72 return nullptr; | 72 return nullptr; |
| 73 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(context.g
et()); | 73 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(context.g
et()); |
| 74 if (!extensionsUtil) | 74 if (!extensionsUtil) |
| 75 return nullptr; | 75 return nullptr; |
| 76 if (extensionsUtil->supportsExtension("GL_EXT_debug_marker")) { | 76 if (extensionsUtil->supportsExtension("GL_EXT_debug_marker")) { |
| 77 String contextLabel(String::format("WebGLRenderingContext-%p", context.g
et())); | 77 String contextLabel(String::format("WebGLRenderingContext-%p", context.g
et())); |
| 78 context->pushGroupMarkerEXT(contextLabel.ascii().data()); | 78 context->pushGroupMarkerEXT(contextLabel.ascii().data()); |
| 79 } | 79 } |
| 80 | 80 |
| 81 OwnPtrWillBeRawPtr<WebGLRenderingContext> renderingContext = adoptPtrWillBeN
oop(new WebGLRenderingContext(canvas, context.release(), attributes)); | 81 OwnPtrWillBeRawPtr<WebGLRenderingContext> renderingContext = adoptPtrWillBeN
oop(new WebGLRenderingContext(canvas, scriptState, context.release(), attributes
)); |
| 82 | 82 |
| 83 if (!renderingContext->drawingBuffer()) { | 83 if (!renderingContext->drawingBuffer()) { |
| 84 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "Could not create a WebGL context.")); | 84 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "Could not create a WebGL context.")); |
| 85 return nullptr; | 85 return nullptr; |
| 86 } | 86 } |
| 87 | 87 |
| 88 renderingContext->initializeNewContext(); | 88 renderingContext->initializeNewContext(); |
| 89 renderingContext->registerContextExtensions(); | 89 renderingContext->registerContextExtensions(); |
| 90 | 90 |
| 91 return renderingContext.release(); | 91 return renderingContext.release(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void WebGLRenderingContext::Factory::onError(HTMLCanvasElement* canvas, const St
ring& error) | 94 void WebGLRenderingContext::Factory::onError(HTMLCanvasElement* canvas, const St
ring& error) |
| 95 { | 95 { |
| 96 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontext
creationerror, false, true, error)); | 96 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontext
creationerror, false, true, error)); |
| 97 } | 97 } |
| 98 | 98 |
| 99 WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, Pa
ssOwnPtr<WebGraphicsContext3D> context, const WebGLContextAttributes& requestedA
ttributes) | 99 WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, Sc
riptState* scriptState, PassOwnPtr<WebGraphicsContext3D> context, const WebGLCon
textAttributes& requestedAttributes) |
| 100 : WebGLRenderingContextBase(passedCanvas, context, requestedAttributes) | 100 : WebGLRenderingContextBase(passedCanvas, scriptState, context, requestedAtt
ributes) |
| 101 { | 101 { |
| 102 } | 102 } |
| 103 | 103 |
| 104 WebGLRenderingContext::~WebGLRenderingContext() | 104 WebGLRenderingContext::~WebGLRenderingContext() |
| 105 { | 105 { |
| 106 } | 106 } |
| 107 | 107 |
| 108 void WebGLRenderingContext::registerContextExtensions() | 108 void WebGLRenderingContext::registerContextExtensions() |
| 109 { | 109 { |
| 110 // Register extensions. | 110 // Register extensions. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 visitor->trace(m_webglCompressedTextureASTC); | 161 visitor->trace(m_webglCompressedTextureASTC); |
| 162 visitor->trace(m_webglCompressedTextureATC); | 162 visitor->trace(m_webglCompressedTextureATC); |
| 163 visitor->trace(m_webglCompressedTextureETC1); | 163 visitor->trace(m_webglCompressedTextureETC1); |
| 164 visitor->trace(m_webglCompressedTexturePVRTC); | 164 visitor->trace(m_webglCompressedTexturePVRTC); |
| 165 visitor->trace(m_webglCompressedTextureS3TC); | 165 visitor->trace(m_webglCompressedTextureS3TC); |
| 166 visitor->trace(m_webglDepthTexture); | 166 visitor->trace(m_webglDepthTexture); |
| 167 WebGLRenderingContextBase::trace(visitor); | 167 WebGLRenderingContextBase::trace(visitor); |
| 168 } | 168 } |
| 169 | 169 |
| 170 } // namespace blink | 170 } // namespace blink |
| OLD | NEW |