| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google 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 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| 11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
| 12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
| 13 * | 13 * |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
| 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef WebGLExtension_h | 26 #ifndef WebGLExtension_h |
| 27 #define WebGLExtension_h | 27 #define WebGLExtension_h |
| 28 | 28 |
| 29 #include "core/html/canvas/WebGLRenderingContext.h" | 29 #include "core/html/canvas/WebGLRenderingContext.h" |
| 30 #include "wtf/RefCounted.h" |
| 30 | 31 |
| 31 namespace WebCore { | 32 namespace WebCore { |
| 32 | 33 |
| 33 class WebGLExtension { | 34 class WebGLExtension : public RefCounted<WebGLExtension> { |
| 34 WTF_MAKE_FAST_ALLOCATED; | 35 WTF_MAKE_FAST_ALLOCATED; |
| 35 public: | 36 public: |
| 36 // Extension names are needed to properly wrap instances in JavaScript objec
ts. | 37 // Extension names are needed to properly wrap instances in JavaScript objec
ts. |
| 37 enum ExtensionName { | 38 enum ExtensionName { |
| 38 EXTFragDepthName, | 39 EXTFragDepthName, |
| 39 EXTTextureFilterAnisotropicName, | 40 EXTTextureFilterAnisotropicName, |
| 40 OESElementIndexUintName, | 41 OESElementIndexUintName, |
| 41 OESStandardDerivativesName, | 42 OESStandardDerivativesName, |
| 42 OESTextureFloatLinearName, | 43 OESTextureFloatLinearName, |
| 43 OESTextureFloatName, | 44 OESTextureFloatName, |
| 44 OESTextureHalfFloatLinearName, | 45 OESTextureHalfFloatLinearName, |
| 45 OESTextureHalfFloatName, | 46 OESTextureHalfFloatName, |
| 46 OESVertexArrayObjectName, | 47 OESVertexArrayObjectName, |
| 47 WebGLCompressedTextureATCName, | 48 WebGLCompressedTextureATCName, |
| 48 WebGLCompressedTexturePVRTCName, | 49 WebGLCompressedTexturePVRTCName, |
| 49 WebGLCompressedTextureS3TCName, | 50 WebGLCompressedTextureS3TCName, |
| 50 WebGLDebugRendererInfoName, | 51 WebGLDebugRendererInfoName, |
| 51 WebGLDebugShadersName, | 52 WebGLDebugShadersName, |
| 52 WebGLDepthTextureName, | 53 WebGLDepthTextureName, |
| 53 WebGLDrawBuffersName, | 54 WebGLDrawBuffersName, |
| 54 WebGLLoseContextName, | 55 WebGLLoseContextName, |
| 55 }; | 56 }; |
| 56 | 57 |
| 57 void ref() { m_context->ref(); } | |
| 58 void deref() { m_context->deref(); } | |
| 59 WebGLRenderingContext* context() { return m_context; } | 58 WebGLRenderingContext* context() { return m_context; } |
| 60 | 59 |
| 61 virtual ~WebGLExtension(); | 60 virtual ~WebGLExtension(); |
| 62 virtual ExtensionName getName() const = 0; | 61 virtual ExtensionName getName() const = 0; |
| 63 | 62 |
| 63 // Lose this extension. Passing true = force loss. Some extensions |
| 64 // like WEBGL_lose_context are not normally lost when the context |
| 65 // is lost but must be lost when destroying their WebGLRenderingContext. |
| 66 virtual void lose(bool) |
| 67 { |
| 68 m_context = 0; |
| 69 } |
| 70 |
| 71 bool isLost() |
| 72 { |
| 73 return !m_context; |
| 74 } |
| 75 |
| 64 protected: | 76 protected: |
| 65 WebGLExtension(WebGLRenderingContext*); | 77 WebGLExtension(WebGLRenderingContext*); |
| 78 |
| 66 WebGLRenderingContext* m_context; | 79 WebGLRenderingContext* m_context; |
| 67 }; | 80 }; |
| 68 | 81 |
| 69 } // namespace WebCore | 82 } // namespace WebCore |
| 70 | 83 |
| 71 #endif // WebGLExtension_h | 84 #endif // WebGLExtension_h |
| OLD | NEW |