| 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 PassOwnPtrWillBeRawPtr<CanvasRenderingContext> WebGLRenderingContext::Factory::c
reate(HTMLCanvasElement* canvas, const CanvasContextCreationAttributes& attrs, D
ocument&) | 69 RawPtr<CanvasRenderingContext> WebGLRenderingContext::Factory::create(HTMLCanvas
Element* canvas, const CanvasContextCreationAttributes& attrs, Document&) |
| 70 { | 70 { |
| 71 WebGLContextAttributes attributes = toWebGLContextAttributes(attrs); | 71 WebGLContextAttributes attributes = toWebGLContextAttributes(attrs); |
| 72 OwnPtr<WebGraphicsContext3DProvider> contextProvider(createWebGraphicsContex
t3DProvider(canvas, attributes, 1)); | 72 OwnPtr<WebGraphicsContext3DProvider> contextProvider(createWebGraphicsContex
t3DProvider(canvas, attributes, 1)); |
| 73 if (!contextProvider) | 73 if (!contextProvider) |
| 74 return nullptr; | 74 return nullptr; |
| 75 gpu::gles2::GLES2Interface* gl = contextProvider->contextGL(); | 75 gpu::gles2::GLES2Interface* gl = contextProvider->contextGL(); |
| 76 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(gl); | 76 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(gl); |
| 77 if (!extensionsUtil) | 77 if (!extensionsUtil) |
| 78 return nullptr; | 78 return nullptr; |
| 79 if (extensionsUtil->supportsExtension("GL_EXT_debug_marker")) { | 79 if (extensionsUtil->supportsExtension("GL_EXT_debug_marker")) { |
| 80 String contextLabel(String::format("WebGLRenderingContext-%p", contextPr
ovider.get())); | 80 String contextLabel(String::format("WebGLRenderingContext-%p", contextPr
ovider.get())); |
| 81 gl->PushGroupMarkerEXT(0, contextLabel.ascii().data()); | 81 gl->PushGroupMarkerEXT(0, contextLabel.ascii().data()); |
| 82 } | 82 } |
| 83 | 83 |
| 84 OwnPtrWillBeRawPtr<WebGLRenderingContext> renderingContext = adoptPtrWillBeN
oop(new WebGLRenderingContext(canvas, contextProvider.release(), attributes)); | 84 RawPtr<WebGLRenderingContext> renderingContext = new WebGLRenderingContext(c
anvas, contextProvider.release(), attributes); |
| 85 | 85 |
| 86 if (!renderingContext->drawingBuffer()) { | 86 if (!renderingContext->drawingBuffer()) { |
| 87 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "Could not create a WebGL context.")); | 87 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "Could not create a WebGL context.")); |
| 88 return nullptr; | 88 return nullptr; |
| 89 } | 89 } |
| 90 | 90 |
| 91 renderingContext->initializeNewContext(); | 91 renderingContext->initializeNewContext(); |
| 92 renderingContext->registerContextExtensions(); | 92 renderingContext->registerContextExtensions(); |
| 93 | 93 |
| 94 return renderingContext.release(); | 94 return renderingContext.release(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void WebGLRenderingContext::Factory::onError(HTMLCanvasElement* canvas, const St
ring& error) | 97 void WebGLRenderingContext::Factory::onError(HTMLCanvasElement* canvas, const St
ring& error) |
| 98 { | 98 { |
| 99 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontext
creationerror, false, true, error)); | 99 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontext
creationerror, false, true, error)); |
| 100 } | 100 } |
| 101 | 101 |
| 102 WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, Pa
ssOwnPtr<WebGraphicsContext3DProvider> contextProvider, const WebGLContextAttrib
utes& requestedAttributes) | 102 WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, Pa
ssOwnPtr<WebGraphicsContext3DProvider> contextProvider, const WebGLContextAttrib
utes& requestedAttributes) |
| 103 : WebGLRenderingContextBase(passedCanvas, contextProvider, requestedAttribut
es) | 103 : WebGLRenderingContextBase(passedCanvas, contextProvider, requestedAttribut
es) |
| 104 { | 104 { |
| 105 } | 105 } |
| 106 | 106 |
| 107 WebGLRenderingContext::~WebGLRenderingContext() | 107 WebGLRenderingContext::~WebGLRenderingContext() |
| 108 { | 108 { |
| 109 } | 109 } |
| 110 | 110 |
| 111 void WebGLRenderingContext::setCanvasGetContextResult(RenderingContext& result) | 111 void WebGLRenderingContext::setCanvasGetContextResult(RenderingContext& result) |
| 112 { | 112 { |
| 113 result.setWebGLRenderingContext(PassRefPtrWillBeRawPtr<WebGLRenderingContext
>(this)); | 113 result.setWebGLRenderingContext(RawPtr<WebGLRenderingContext>(this)); |
| 114 } | 114 } |
| 115 | 115 |
| 116 void WebGLRenderingContext::registerContextExtensions() | 116 void WebGLRenderingContext::registerContextExtensions() |
| 117 { | 117 { |
| 118 // Register extensions. | 118 // Register extensions. |
| 119 static const char* const bothPrefixes[] = { "", "WEBKIT_", 0, }; | 119 static const char* const bothPrefixes[] = { "", "WEBKIT_", 0, }; |
| 120 | 120 |
| 121 registerExtension<ANGLEInstancedArrays>(m_angleInstancedArrays); | 121 registerExtension<ANGLEInstancedArrays>(m_angleInstancedArrays); |
| 122 registerExtension<CHROMIUMSubscribeUniform>(m_chromiumSubscribeUniform); | 122 registerExtension<CHROMIUMSubscribeUniform>(m_chromiumSubscribeUniform); |
| 123 registerExtension<EXTBlendMinMax>(m_extBlendMinMax); | 123 registerExtension<EXTBlendMinMax>(m_extBlendMinMax); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 visitor->trace(m_webglCompressedTextureASTC); | 169 visitor->trace(m_webglCompressedTextureASTC); |
| 170 visitor->trace(m_webglCompressedTextureATC); | 170 visitor->trace(m_webglCompressedTextureATC); |
| 171 visitor->trace(m_webglCompressedTextureETC1); | 171 visitor->trace(m_webglCompressedTextureETC1); |
| 172 visitor->trace(m_webglCompressedTexturePVRTC); | 172 visitor->trace(m_webglCompressedTexturePVRTC); |
| 173 visitor->trace(m_webglCompressedTextureS3TC); | 173 visitor->trace(m_webglCompressedTextureS3TC); |
| 174 visitor->trace(m_webglDepthTexture); | 174 visitor->trace(m_webglDepthTexture); |
| 175 WebGLRenderingContextBase::trace(visitor); | 175 WebGLRenderingContextBase::trace(visitor); |
| 176 } | 176 } |
| 177 | 177 |
| 178 } // namespace blink | 178 } // namespace blink |
| OLD | NEW |