Add destroy hooks for several GL objects.

These hooks allow the back-end renderer to free object resources
without having to store pointers to shared device handles for
each and every object. This will allow us to save memory on
back-ends that really care about memory overhead.

There is a downside in that there is more boilerplate in passing
gl::Context handles around everywhere.

BUG=angleproject:1684

Change-Id: I89463bba8d23f92920e8956650cb73c7fc6d66b7
Reviewed-on: https://chromium-review.googlesource.com/426401
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/Program.h b/src/libANGLE/Program.h
index 319255b..5a638df 100644
--- a/src/libANGLE/Program.h
+++ b/src/libANGLE/Program.h
@@ -263,6 +263,7 @@
   public:
     Program(rx::GLImplFactory *factory, ShaderProgramManager *manager, GLuint handle);
     ~Program();
+    void destroy(const Context *context);
 
     GLuint id() const { return mHandle; }
 
@@ -272,7 +273,7 @@
     rx::ProgramImpl *getImplementation() const { return mProgram; }
 
     void attachShader(Shader *shader);
-    bool detachShader(Shader *shader);
+    bool detachShader(const Context *context, Shader *shader);
     int getAttachedShadersCount() const;
 
     const Shader *getAttachedVertexShader() const { return mState.mAttachedVertexShader; }
@@ -384,7 +385,7 @@
     static bool linkValidateInterfaceBlockFields(InfoLog &infoLog, const std::string &uniformName, const sh::InterfaceBlockField &vertexUniform, const sh::InterfaceBlockField &fragmentUniform);
 
     void addRef();
-    void release();
+    void release(const Context *context);
     unsigned int getRefCount() const;
     void flagForDeletion();
     bool isFlaggedForDeletion() const;
@@ -430,7 +431,7 @@
 
     using MergedVaryings = std::map<std::string, VaryingRef>;
 
-    void unlink(bool destroy = false);
+    void unlink();
     void resetUniformBlockBindings();
 
     bool linkAttributes(const ContextState &data, InfoLog &infoLog);