Create shared contexts.
TRAC #12498
Signed-off-by: Shannon Woods
Signed-off-by: Daniel Koch
Author: Andrew Lewycky
git-svn-id: https://angleproject.googlecode.com/svn/trunk@363 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/Context.cpp b/src/libGLESv2/Context.cpp
index c619ec6..eab929e 100644
--- a/src/libGLESv2/Context.cpp
+++ b/src/libGLESv2/Context.cpp
@@ -34,7 +34,7 @@
namespace gl
{
-Context::Context(const egl::Config *config)
+Context::Context(const egl::Config *config, const gl::Context *shareContext)
: mConfig(config)
{
setClearColor(0.0f, 0.0f, 0.0f, 0.0f);
@@ -104,8 +104,15 @@
mState.colorMaskAlpha = true;
mState.depthMask = true;
- // FIXME: Resource managers should get managed with context sharing
- mResourceManager = new ResourceManager();
+ if (shareContext != NULL)
+ {
+ mResourceManager = shareContext->mResourceManager;
+ mResourceManager->addRef();
+ }
+ else
+ {
+ mResourceManager = new ResourceManager();
+ }
// [OpenGL ES 2.0.24] section 3.7 page 83:
// In the initial state, TEXTURE_2D and TEXTURE_CUBE_MAP have twodimensional
@@ -200,8 +207,7 @@
mMaskedClearSavedState->Release();
}
- // FIXME: Context should not be responsible for resource manager deallocation
- delete mResourceManager;
+ mResourceManager->release();
}
void Context::makeCurrent(egl::Display *display, egl::Surface *surface)
@@ -277,6 +283,12 @@
mScissorStateDirty = true;
mSampleStateDirty = true;
mDitherStateDirty = true;
+ mFrontFaceDirty = true;
+
+ if (mBufferBackEnd != NULL)
+ {
+ mBufferBackEnd->invalidate();
+ }
}
void Context::setClearColor(float red, float green, float blue, float alpha)
@@ -2803,9 +2815,9 @@
extern "C"
{
-gl::Context *glCreateContext(const egl::Config *config)
+gl::Context *glCreateContext(const egl::Config *config, const gl::Context *shareContext)
{
- return new gl::Context(config);
+ return new gl::Context(config, shareContext);
}
void glDestroyContext(gl::Context *context)