This source file includes following definitions.
- create
- getAWebGraphicsContext3D
- addContext
- removeContext
- removeObject
- addObject
- detachAndRemoveAllObjects
- loseContextGroup
#include "config.h"
#include "core/html/canvas/WebGLContextGroup.h"
#include "core/html/canvas/WebGLSharedObject.h"
namespace WebCore {
PassRefPtr<WebGLContextGroup> WebGLContextGroup::create()
{
RefPtr<WebGLContextGroup> contextGroup = adoptRef(new WebGLContextGroup());
return contextGroup.release();
}
WebGLContextGroup::WebGLContextGroup()
{
}
WebGLContextGroup::~WebGLContextGroup()
{
detachAndRemoveAllObjects();
}
blink::WebGraphicsContext3D* WebGLContextGroup::getAWebGraphicsContext3D()
{
ASSERT(!m_contexts.isEmpty());
HashSet<WebGLRenderingContextBase*>::iterator it = m_contexts.begin();
return (*it)->webGraphicsContext3D();
}
void WebGLContextGroup::addContext(WebGLRenderingContextBase* context)
{
m_contexts.add(context);
}
void WebGLContextGroup::removeContext(WebGLRenderingContextBase* context)
{
if (m_contexts.size() == 1 && m_contexts.contains(context))
detachAndRemoveAllObjects();
m_contexts.remove(context);
}
void WebGLContextGroup::removeObject(WebGLSharedObject* object)
{
m_groupObjects.remove(object);
}
void WebGLContextGroup::addObject(WebGLSharedObject* object)
{
m_groupObjects.add(object);
}
void WebGLContextGroup::detachAndRemoveAllObjects()
{
while (!m_groupObjects.isEmpty()) {
HashSet<WebGLSharedObject*>::iterator it = m_groupObjects.begin();
(*it)->detachContextGroup();
}
}
void WebGLContextGroup::loseContextGroup(WebGLRenderingContextBase::LostContextMode mode)
{
detachAndRemoveAllObjects();
for (HashSet<WebGLRenderingContextBase*>::iterator it = m_contexts.begin(); it != m_contexts.end(); ++it)
(*it)->loseContextImpl(mode);
}
}