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 21 matching lines...) Expand all Loading... |
32 | 32 |
33 namespace WebCore { | 33 namespace WebCore { |
34 | 34 |
35 PassRefPtr<WebGLContextGroup> WebGLContextGroup::create() | 35 PassRefPtr<WebGLContextGroup> WebGLContextGroup::create() |
36 { | 36 { |
37 RefPtr<WebGLContextGroup> contextGroup = adoptRef(new WebGLContextGroup()); | 37 RefPtr<WebGLContextGroup> contextGroup = adoptRef(new WebGLContextGroup()); |
38 return contextGroup.release(); | 38 return contextGroup.release(); |
39 } | 39 } |
40 | 40 |
41 WebGLContextGroup::WebGLContextGroup() | 41 WebGLContextGroup::WebGLContextGroup() |
| 42 : m_contextCreationCount(0) |
| 43 , m_acquireRequestCount(0) |
42 { | 44 { |
43 } | 45 } |
44 | 46 |
45 WebGLContextGroup::~WebGLContextGroup() | 47 WebGLContextGroup::~WebGLContextGroup() |
46 { | 48 { |
47 detachAndRemoveAllObjects(); | 49 detachAndRemoveAllObjects(); |
48 } | 50 } |
49 | 51 |
50 GraphicsContext3D* WebGLContextGroup::getAGraphicsContext3D() | 52 GraphicsContext3D* WebGLContextGroup::getAGraphicsContext3D() |
51 { | 53 { |
52 ASSERT(!m_contexts.isEmpty()); | 54 ASSERT(!m_contexts.isEmpty()); |
53 HashSet<WebGLRenderingContext*>::iterator it = m_contexts.begin(); | 55 HashSet<WebGLRenderingContext*>::iterator it = m_contexts.begin(); |
54 return (*it)->graphicsContext3D(); | 56 return (*it)->graphicsContext3D(); |
55 } | 57 } |
56 | 58 |
57 void WebGLContextGroup::addContext(WebGLRenderingContext* context) | 59 unsigned WebGLContextGroup::addContext(WebGLRenderingContext* context) |
58 { | 60 { |
59 m_contexts.add(context); | 61 m_contexts.add(context); |
| 62 return m_contextCreationCount++; |
60 } | 63 } |
61 | 64 |
62 void WebGLContextGroup::removeContext(WebGLRenderingContext* context) | 65 void WebGLContextGroup::removeContext(WebGLRenderingContext* context) |
63 { | 66 { |
| 67 // Release all the resources this context has acquired. |
| 68 for (HashSet<WebGLSharedObject*>::iterator it = m_groupObjects.begin(); it !
= m_groupObjects.end(); ++it) { |
| 69 (*it)->release(context); |
| 70 } |
| 71 |
64 // We must call detachAndRemoveAllObjects before removing the last context. | 72 // We must call detachAndRemoveAllObjects before removing the last context. |
65 if (m_contexts.size() == 1 && m_contexts.contains(context)) | 73 if (m_contexts.size() == 1 && m_contexts.contains(context)) |
66 detachAndRemoveAllObjects(); | 74 detachAndRemoveAllObjects(); |
67 | 75 |
68 m_contexts.remove(context); | 76 m_contexts.remove(context); |
69 } | 77 } |
70 | 78 |
71 void WebGLContextGroup::removeObject(WebGLSharedObject* object) | 79 void WebGLContextGroup::removeObject(WebGLSharedObject* object) |
72 { | 80 { |
73 m_groupObjects.remove(object); | 81 m_groupObjects.remove(object); |
(...skipping 13 matching lines...) Expand all Loading... |
87 } | 95 } |
88 | 96 |
89 void WebGLContextGroup::loseContextGroup(WebGLRenderingContext::LostContextMode
mode) | 97 void WebGLContextGroup::loseContextGroup(WebGLRenderingContext::LostContextMode
mode) |
90 { | 98 { |
91 for (HashSet<WebGLRenderingContext*>::iterator it = m_contexts.begin(); it !
= m_contexts.end(); ++it) | 99 for (HashSet<WebGLRenderingContext*>::iterator it = m_contexts.begin(); it !
= m_contexts.end(); ++it) |
92 (*it)->loseContextImpl(mode); | 100 (*it)->loseContextImpl(mode); |
93 | 101 |
94 detachAndRemoveAllObjects(); | 102 detachAndRemoveAllObjects(); |
95 } | 103 } |
96 | 104 |
| 105 long WebGLContextGroup::generateAcquireRequestId() |
| 106 { |
| 107 return ++m_acquireRequestCount; |
| 108 } |
| 109 |
| 110 void WebGLContextGroup::cancelAcquireSharedResource(const WebGLRenderingContext*
context, long id) |
| 111 { |
| 112 for (HashSet<WebGLSharedObject*>::iterator it = m_groupObjects.begin(); it !
= m_groupObjects.end(); ++it) { |
| 113 if ((*it)->cancelAcquireRequest(context, id)) { |
| 114 break; |
| 115 } |
| 116 } |
| 117 } |
| 118 |
97 } // namespace WebCore | 119 } // namespace WebCore |
OLD | NEW |