Make ProgramBinary a refcount object and use Binding pointers to maintain it's lifetime on context and program.

Trac #21270
Bug=351
Signed-off-by: Nicolas Capens

This fixes the underlying bug since it allows the context to keep the program binary alive, after a relink has occurred.



git-svn-id: https://angleproject.googlecode.com/svn/trunk@1242 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/Context.cpp b/src/libGLESv2/Context.cpp
index 2037045..970ee12 100644
--- a/src/libGLESv2/Context.cpp
+++ b/src/libGLESv2/Context.cpp
@@ -141,7 +141,7 @@
     bindRenderbuffer(0);
 
     mState.currentProgram = 0;
-    mCurrentProgramBinary = NULL;
+    mCurrentProgramBinary.set(NULL);
 
     mState.packAlignment = 4;
     mState.unpackAlignment = 4;
@@ -186,7 +186,7 @@
         }
         mState.currentProgram = 0;
     }
-    mCurrentProgramBinary = NULL;
+    mCurrentProgramBinary.set(NULL);
 
     while (!mFramebufferMap.empty())
     {
@@ -1147,13 +1147,13 @@
     {
         Program *newProgram = mResourceManager->getProgram(program);
         Program *oldProgram = mResourceManager->getProgram(priorProgram);
-        mCurrentProgramBinary = NULL;
+        mCurrentProgramBinary.set(NULL);
         mDxUniformsDirty = true;
 
         if (newProgram)
         {
             newProgram->addRef();
-            mCurrentProgramBinary = newProgram->getProgramBinary();
+            mCurrentProgramBinary.set(newProgram->getProgramBinary());
         }
         
         if (oldProgram)
@@ -1173,7 +1173,7 @@
     // need to install the new executables
     if (linked && program == mState.currentProgram)
     {
-        mCurrentProgramBinary = programObject->getProgramBinary();
+        mCurrentProgramBinary.set(programObject->getProgramBinary());
         mDxUniformsDirty = true;
     }
 }
@@ -1188,7 +1188,7 @@
     // need to install the new executables
     if (loaded && program == mState.currentProgram)
     {
-        mCurrentProgramBinary = programObject->getProgramBinary();
+        mCurrentProgramBinary.set(programObject->getProgramBinary());
         mDxUniformsDirty = true;
     }
 
@@ -1358,7 +1358,7 @@
 
 ProgramBinary *Context::getCurrentProgramBinary()
 {
-    return mCurrentProgramBinary;
+    return mCurrentProgramBinary.get();
 }
 
 Texture2D *Context::getTexture2D()