| 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/HTMLCanvasElement.h" |
| 29 #include "core/html/canvas/WebGLExtensionName.h" | 30 #include "core/html/canvas/WebGLExtensionName.h" |
| 30 #include "core/html/canvas/WebGLRenderingContextBase.h" | 31 #include "core/html/canvas/WebGLRenderingContextBase.h" |
| 31 #include "platform/heap/Handle.h" | 32 #include "platform/heap/Handle.h" |
| 32 #include "wtf/RefCounted.h" | 33 #include "wtf/RefCounted.h" |
| 33 | 34 |
| 34 namespace blink { | 35 namespace blink { |
| 35 | 36 |
| 37 class WebGLExtensionScopedContext : public NoBaseWillBeGarbageCollectedFinalized
<WebGLExtensionScopedContext> { |
| 38 WTF_MAKE_NONCOPYABLE(WebGLExtensionScopedContext); |
| 39 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; |
| 40 public: |
| 41 WebGLExtensionScopedContext(WebGLExtension*); |
| 42 virtual ~WebGLExtensionScopedContext(); |
| 43 |
| 44 bool isLost() { return !m_context; } |
| 45 WebGLRenderingContextBase* context() const { return m_context.get(); } |
| 46 |
| 47 virtual void trace(Visitor*); |
| 48 |
| 49 private: |
| 50 RefPtrWillBeMember<WebGLRenderingContextBase> m_context; |
| 51 }; |
| 52 |
| 36 class WebGLExtension : public RefCountedWillBeGarbageCollectedFinalized<WebGLExt
ension> { | 53 class WebGLExtension : public RefCountedWillBeGarbageCollectedFinalized<WebGLExt
ension> { |
| 37 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; | 54 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; |
| 38 public: | 55 public: |
| 39 WebGLRenderingContextBase* context() { return m_context; } | |
| 40 | |
| 41 virtual ~WebGLExtension(); | 56 virtual ~WebGLExtension(); |
| 42 virtual WebGLExtensionName name() const = 0; | 57 virtual WebGLExtensionName name() const = 0; |
| 43 | 58 |
| 44 // Lose this extension. Passing true = force loss. Some extensions | 59 // Lose this extension. Passing true = force loss. Some extensions |
| 45 // like WEBGL_lose_context are not normally lost when the context | 60 // like WEBGL_lose_context are not normally lost when the context |
| 46 // is lost but must be lost when destroying their WebGLRenderingContextBase. | 61 // is lost but must be lost when destroying their WebGLRenderingContextBase. |
| 47 virtual void lose(bool) | 62 virtual void lose(bool) |
| 48 { | 63 { |
| 49 m_context = nullptr; | 64 m_context = nullptr; |
| 50 } | 65 } |
| 51 | 66 |
| 52 bool isLost() | 67 bool isLost() { return !m_context; } |
| 53 { | |
| 54 return !m_context; | |
| 55 } | |
| 56 | 68 |
| 57 virtual void trace(Visitor*); | 69 virtual void trace(Visitor*); |
| 58 | 70 |
| 59 protected: | 71 protected: |
| 60 explicit WebGLExtension(WebGLRenderingContextBase*); | 72 explicit WebGLExtension(WebGLRenderingContextBase*); |
| 61 | 73 |
| 74 private: |
| 75 friend WebGLExtensionScopedContext; |
| 76 |
| 62 RawPtrWillBeWeakMember<WebGLRenderingContextBase> m_context; | 77 RawPtrWillBeWeakMember<WebGLRenderingContextBase> m_context; |
| 63 }; | 78 }; |
| 64 | 79 |
| 65 } // namespace blink | 80 } // namespace blink |
| 66 | 81 |
| 67 #endif // WebGLExtension_h | 82 #endif // WebGLExtension_h |
| OLD | NEW |