Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGLContextGroup.cpp

Issue 2558853003: Use strong references from WebGLContextGroup to WebGLRenderingContextBase. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLContextGroup.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // It's possible that all of the WebGLRenderingContextBases (currently 33 DCHECK(!m_contexts.isEmpty());
34 // only one) referenced weakly by this WebGLContextGroup are GC'd before
35 // the (shared) WebGLObjects that it created. Since the calling code
36 // handles this gracefully, and since the graphical resources will have
37 // been implicitly reclaimed by the deletion of the context, explicitly
38 // test for this possibility.
39 if (m_contexts.isEmpty())
40 return nullptr;
41
42 // Weak processing removes dead entries from the HeapHashSet, so it's
43 // guaranteed that this will not return null for the reason that a
44 // WeakMember was nulled out.
45 return (*m_contexts.begin())->contextGL(); 34 return (*m_contexts.begin())->contextGL();
46 } 35 }
47 36
48 void WebGLContextGroup::addContext(WebGLRenderingContextBase* context) { 37 void WebGLContextGroup::addContext(WebGLRenderingContextBase* context) {
49 m_contexts.add(context); 38 m_contexts.add(TraceWrapperMember<WebGLRenderingContextBase>(this, context));
50 ScriptWrappableVisitor::writeBarrier(this, context);
51 } 39 }
52 40
53 void WebGLContextGroup::loseContextGroup( 41 void WebGLContextGroup::loseContextGroup(
54 WebGLRenderingContextBase::LostContextMode mode, 42 WebGLRenderingContextBase::LostContextMode mode,
55 WebGLRenderingContextBase::AutoRecoveryMethod autoRecoveryMethod) { 43 WebGLRenderingContextBase::AutoRecoveryMethod autoRecoveryMethod) {
56 ++m_numberOfContextLosses; 44 ++m_numberOfContextLosses;
57 for (WebGLRenderingContextBase* const context : m_contexts) 45 for (WebGLRenderingContextBase* const context : m_contexts)
58 context->loseContextImpl(mode, autoRecoveryMethod); 46 context->loseContextImpl(mode, autoRecoveryMethod);
59 } 47 }
60 48
61 uint32_t WebGLContextGroup::numberOfContextLosses() const { 49 uint32_t WebGLContextGroup::numberOfContextLosses() const {
62 return m_numberOfContextLosses; 50 return m_numberOfContextLosses;
63 } 51 }
64 52
65 DEFINE_TRACE_WRAPPERS(WebGLContextGroup) { 53 DEFINE_TRACE_WRAPPERS(WebGLContextGroup) {
66 // TODO(kbr, mlippautz): need to use the manual write barrier since we
67 // need to use weak members to get the desired semantics in Oilpan, but
68 // no such TraceWrapperMember (like TraceWrapperWeakMember) exists yet.
69 for (auto context : m_contexts) { 54 for (auto context : m_contexts) {
70 visitor->traceWrappersWithManualWriteBarrier(context); 55 visitor->traceWrappers(context);
71 } 56 }
72 } 57 }
73 58
74 } // namespace blink 59 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLContextGroup.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698