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

Side by Side Diff: Source/core/html/canvas/WebGLContextGroup.cpp

Issue 17230006: Implement WEBGL_shared_resources Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 months 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 | Annotate | Revision Log
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 return (*it)->graphicsContext3D(); 54 return (*it)->graphicsContext3D();
55 } 55 }
56 56
57 void WebGLContextGroup::addContext(WebGLRenderingContext* context) 57 void WebGLContextGroup::addContext(WebGLRenderingContext* context)
58 { 58 {
59 m_contexts.add(context); 59 m_contexts.add(context);
60 } 60 }
61 61
62 void WebGLContextGroup::removeContext(WebGLRenderingContext* context) 62 void WebGLContextGroup::removeContext(WebGLRenderingContext* context)
63 { 63 {
64 // Release all the resources this context has acquired.
65 for (HashSet<WebGLSharedObject*>::iterator it = m_groupObjects.begin(); it ! = m_groupObjects.end(); ++it) {
66 (*it)->release(context);
67 (*it)->cancelAllPendingRequestsForContext(context);
68 }
69
64 // We must call detachAndRemoveAllObjects before removing the last context. 70 // We must call detachAndRemoveAllObjects before removing the last context.
65 if (m_contexts.size() == 1 && m_contexts.contains(context)) 71 if (m_contexts.size() == 1 && m_contexts.contains(context))
66 detachAndRemoveAllObjects(); 72 detachAndRemoveAllObjects();
67 73
68 m_contexts.remove(context); 74 m_contexts.remove(context);
69 } 75 }
70 76
71 void WebGLContextGroup::removeObject(WebGLSharedObject* object) 77 void WebGLContextGroup::removeObject(WebGLSharedObject* object)
72 { 78 {
73 m_groupObjects.remove(object); 79 m_groupObjects.remove(object);
(...skipping 15 matching lines...) Expand all
89 void WebGLContextGroup::loseContextGroup(WebGLRenderingContext::LostContextMode mode) 95 void WebGLContextGroup::loseContextGroup(WebGLRenderingContext::LostContextMode mode)
90 { 96 {
91 // Detach must happen before loseContextImpl, which destroys the GraphicsCon text3D 97 // Detach must happen before loseContextImpl, which destroys the GraphicsCon text3D
92 // and prevents groupObjects from being properly deleted. 98 // and prevents groupObjects from being properly deleted.
93 detachAndRemoveAllObjects(); 99 detachAndRemoveAllObjects();
94 100
95 for (HashSet<WebGLRenderingContext*>::iterator it = m_contexts.begin(); it ! = m_contexts.end(); ++it) 101 for (HashSet<WebGLRenderingContext*>::iterator it = m_contexts.begin(); it ! = m_contexts.end(); ++it)
96 (*it)->loseContextImpl(mode); 102 (*it)->loseContextImpl(mode);
97 } 103 }
98 104
105 void WebGLContextGroup::cancelAcquireSharedResource(const WebGLRenderingContext* context, long id)
106 {
107 for (HashSet<WebGLSharedObject*>::iterator it = m_groupObjects.begin(); it ! = m_groupObjects.end(); ++it) {
108 if ((*it)->cancelAcquireRequest(context, id)) {
109 break;
110 }
111 }
112 }
113
99 } // namespace WebCore 114 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/canvas/WebGLContextGroup.h ('k') | Source/core/html/canvas/WebGLContextObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698