Chromium Code Reviews| 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 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 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 #include "modules/webgl/WebGLContextGroup.h" | 26 #include "modules/webgl/WebGLContextGroup.h" |
| 27 | 27 |
| 28 namespace blink { | 28 namespace blink { |
| 29 | 29 |
| 30 WebGLContextGroup::WebGLContextGroup() : m_numberOfContextLosses(0) {} | 30 WebGLContextGroup::WebGLContextGroup() : m_numberOfContextLosses(0) {} |
| 31 | 31 |
| 32 gpu::gles2::GLES2Interface* WebGLContextGroup::getAGLInterface() { | 32 gpu::gles2::GLES2Interface* WebGLContextGroup::getAGLInterface() { |
| 33 ASSERT(!m_contexts.isEmpty()); | 33 // During an Oilpan GC where WebGL objects become unreachable at the same |
| 34 // time the context does, the m_contexts set can be fully cleared out | |
| 35 // before WebGLObjects' destructors run. Since the calling code handles | |
| 36 // this gracefully, explicitly test for this possibility. | |
| 37 if (m_contexts.isEmpty()) | |
|
haraken
2016/12/05 01:31:10
Hmm, I'm not sure if this works.
If A's destructo
Ken Russell (switch to Gerrit)
2016/12/05 01:38:13
m_contexts is a HeapHashSet containing WeakMembers
haraken
2016/12/05 01:47:25
Remember that if both WebGLObject and WebGLContext
Ken Russell (switch to Gerrit)
2016/12/05 01:59:37
When exactly in Oilpan's GC cycle does weak proces
| |
| 38 return nullptr; | |
| 39 | |
| 34 // Weak processing removes dead entries from the HeapHashSet, so it's | 40 // Weak processing removes dead entries from the HeapHashSet, so it's |
| 35 // guaranteed that this will not return null for the reason that a | 41 // guaranteed that this will not return null for the reason that a |
| 36 // WeakMember was nulled out. | 42 // WeakMember was nulled out. |
| 37 return (*m_contexts.begin())->contextGL(); | 43 return (*m_contexts.begin())->contextGL(); |
| 38 } | 44 } |
| 39 | 45 |
| 40 void WebGLContextGroup::addContext(WebGLRenderingContextBase* context) { | 46 void WebGLContextGroup::addContext(WebGLRenderingContextBase* context) { |
| 41 m_contexts.add(context); | 47 m_contexts.add(context); |
| 42 } | 48 } |
| 43 | 49 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 56 DEFINE_TRACE_WRAPPERS(WebGLContextGroup) { | 62 DEFINE_TRACE_WRAPPERS(WebGLContextGroup) { |
| 57 // TODO(kbr, mlippautz): need to use the manual write barrier since we | 63 // TODO(kbr, mlippautz): need to use the manual write barrier since we |
| 58 // need to use weak members to get the desired semantics in Oilpan, but | 64 // need to use weak members to get the desired semantics in Oilpan, but |
| 59 // no such TraceWrapperMember (like TraceWrapperWeakMember) exists yet. | 65 // no such TraceWrapperMember (like TraceWrapperWeakMember) exists yet. |
| 60 for (auto context : m_contexts) { | 66 for (auto context : m_contexts) { |
| 61 visitor->traceWrappersWithManualWriteBarrier(context); | 67 visitor->traceWrappersWithManualWriteBarrier(context); |
| 62 } | 68 } |
| 63 } | 69 } |
| 64 | 70 |
| 65 } // namespace blink | 71 } // namespace blink |
| OLD | NEW |