| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef WebGLContextGroup_h | 26 #ifndef WebGLContextGroup_h |
| 27 #define WebGLContextGroup_h | 27 #define WebGLContextGroup_h |
| 28 | 28 |
| 29 #include "bindings/core/v8/ScriptWrappable.h" |
| 29 #include "modules/webgl/WebGLRenderingContextBase.h" | 30 #include "modules/webgl/WebGLRenderingContextBase.h" |
| 30 #include "wtf/HashSet.h" | 31 #include "wtf/HashSet.h" |
| 31 #include "wtf/PassRefPtr.h" | 32 #include "wtf/PassRefPtr.h" |
| 32 #include "wtf/RefCounted.h" | 33 #include "wtf/RefCounted.h" |
| 33 | 34 |
| 34 namespace blink { | 35 namespace blink { |
| 35 | 36 |
| 36 class WebGLSharedObject; | |
| 37 class WebGLRenderingContextBase; | |
| 38 | |
| 39 typedef int ExceptionCode; | 37 typedef int ExceptionCode; |
| 40 | 38 |
| 41 class WebGLContextGroup final : public RefCounted<WebGLContextGroup> { | 39 class WebGLContextGroup final : public GarbageCollected<WebGLContextGroup>, |
| 40 public TraceWrapperBase { |
| 41 WTF_MAKE_NONCOPYABLE(WebGLContextGroup); |
| 42 |
| 42 public: | 43 public: |
| 43 static PassRefPtr<WebGLContextGroup> create(); | 44 WebGLContextGroup(); |
| 44 ~WebGLContextGroup(); | |
| 45 | 45 |
| 46 void addContext(WebGLRenderingContextBase*); | 46 void addContext(WebGLRenderingContextBase*); |
| 47 void removeContext(WebGLRenderingContextBase*); | |
| 48 | 47 |
| 49 void addObject(WebGLSharedObject*); | 48 // There's no point in having a removeContext method any more now that |
| 50 void removeObject(WebGLSharedObject*); | 49 // the context group is GarbageCollected. The only time it would be |
| 50 // called would be during WebGLRenderingContext destruction, and at that |
| 51 // time, the context is not allowed to refer back to the context group |
| 52 // since both are on the Oilpan heap. |
| 51 | 53 |
| 52 gpu::gles2::GLES2Interface* getAGLInterface(); | 54 gpu::gles2::GLES2Interface* getAGLInterface(); |
| 53 | 55 |
| 54 void loseContextGroup(WebGLRenderingContextBase::LostContextMode, | 56 void loseContextGroup(WebGLRenderingContextBase::LostContextMode, |
| 55 WebGLRenderingContextBase::AutoRecoveryMethod); | 57 WebGLRenderingContextBase::AutoRecoveryMethod); |
| 56 | 58 |
| 59 // This counter gets incremented every time context loss is |
| 60 // triggered. Because there's no longer any explicit enumeration of |
| 61 // the objects in a given context group upon context loss, each |
| 62 // object needs to keep track of the context loss count when it was |
| 63 // created, in order to validate itself. |
| 64 uint32_t numberOfContextLosses() const; |
| 65 |
| 66 DEFINE_INLINE_TRACE() { visitor->trace(m_contexts); } |
| 67 |
| 68 DECLARE_VIRTUAL_TRACE_WRAPPERS(); |
| 69 |
| 57 private: | 70 private: |
| 58 friend class WebGLObject; | 71 friend class WebGLObject; |
| 59 | 72 |
| 60 WebGLContextGroup(); | 73 uint32_t m_numberOfContextLosses; |
| 61 | 74 |
| 62 void detachAndRemoveAllObjects(); | 75 // Note: ideally this would use a TraceWrapperMember subclass, but |
| 63 | 76 // that doesn't seem to exist for weak members yet. |
| 64 // FIXME: Oilpan: this object is not on the heap, but keeps untraced | 77 HeapHashSet<WeakMember<WebGLRenderingContextBase>> m_contexts; |
| 65 // pointers to on-heap objects in the two hash sets below. | |
| 66 // The objects are responsible for managing their | |
| 67 // registration with WebGLContextGroup, and vice versa, the | |
| 68 // WebGLContextGroup takes care of detaching the group objects if | |
| 69 // the set of WebGLRenderingContextBase contexts becomes empty. | |
| 70 HashSet<UntracedMember<WebGLRenderingContextBase>> m_contexts; | |
| 71 HashSet<UntracedMember<WebGLSharedObject>> m_groupObjects; | |
| 72 }; | 78 }; |
| 73 | 79 |
| 74 } // namespace blink | 80 } // namespace blink |
| 75 | 81 |
| 76 #endif // WebGLContextGroup_h | 82 #endif // WebGLContextGroup_h |
| OLD | NEW |