Revert "Merge the ProgramBinary class into Program."

Issues appeared on the FYI waterfall, content_gl_tests hangs.

This reverts commit 2195a6d6032883ed05468d5ecd019e7cb9a27bce.

Change-Id: I9fe1a53cf40887ae5a98fd77b4872f41085fcea7
Reviewed-on: https://chromium-review.googlesource.com/232386
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Tested-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/State.cpp b/src/libANGLE/State.cpp
index 0b1cab5..dae55b4 100644
--- a/src/libANGLE/State.cpp
+++ b/src/libANGLE/State.cpp
@@ -138,7 +138,8 @@
     mActiveQueries[GL_ANY_SAMPLES_PASSED_CONSERVATIVE].set(NULL);
     mActiveQueries[GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN].set(NULL);
 
-    mProgram = NULL;
+    mCurrentProgramId = 0;
+    mCurrentProgramBinary.set(NULL);
 
     mReadFramebuffer = NULL;
     mDrawFramebuffer = NULL;
@@ -162,12 +163,6 @@
     mArrayBuffer.set(NULL);
     mRenderbuffer.set(NULL);
 
-    if (mProgram)
-    {
-        mProgram->release();
-    }
-    mProgram = NULL;
-
     mTransformFeedback.set(NULL);
 
     for (State::ActiveQueryMap::iterator i = mActiveQueries.begin(); i != mActiveQueries.end(); i++)
@@ -192,8 +187,6 @@
 
     mPack.pixelBuffer.set(NULL);
     mUnpack.pixelBuffer.set(NULL);
-
-    mProgram = NULL;
 }
 
 const RasterizerState &State::getRasterizerState() const
@@ -852,27 +845,31 @@
     return false;
 }
 
-void State::setProgram(Program *newProgram)
+void State::setCurrentProgram(GLuint programId, Program *newProgram)
 {
-    if (mProgram != newProgram)
+    mCurrentProgramId = programId; // set new ID before trying to delete program binary; otherwise it will only be flagged for deletion
+    mCurrentProgramBinary.set(NULL);
+
+    if (newProgram)
     {
-        if (mProgram)
-        {
-            mProgram->release();
-        }
-
-        mProgram = newProgram;
-
-        if (mProgram)
-        {
-            newProgram->addRef();
-        }
+        newProgram->addRef();
+        mCurrentProgramBinary.set(newProgram->getProgramBinary());
     }
 }
 
-Program *State::getProgram() const
+void State::setCurrentProgramBinary(ProgramBinary *binary)
 {
-    return mProgram;
+    mCurrentProgramBinary.set(binary);
+}
+
+GLuint State::getCurrentProgramId() const
+{
+    return mCurrentProgramId;
+}
+
+ProgramBinary *State::getCurrentProgramBinary() const
+{
+    return mCurrentProgramBinary.get();
 }
 
 void State::setTransformFeedbackBinding(TransformFeedback *transformFeedback)
@@ -1217,7 +1214,7 @@
       case GL_READ_FRAMEBUFFER_BINDING_ANGLE:           *params = mReadFramebuffer->id();                         break;
       case GL_RENDERBUFFER_BINDING:                     *params = mRenderbuffer.id();                             break;
       case GL_VERTEX_ARRAY_BINDING:                     *params = mVertexArray->id();                             break;
-      case GL_CURRENT_PROGRAM:                          *params = mProgram ? mProgram->id() : 0;                  break;
+      case GL_CURRENT_PROGRAM:                          *params = mCurrentProgramId;                              break;
       case GL_PACK_ALIGNMENT:                           *params = mPack.alignment;                                break;
       case GL_PACK_REVERSE_ROW_ORDER_ANGLE:             *params = mPack.reverseRowOrder;                          break;
       case GL_UNPACK_ALIGNMENT:                         *params = mUnpack.alignment;                              break;