Code refactoring for getters and setters.

The entry point should call into Context at first for getters and setters.

BUG=angleproject:1922

Change-Id: Ibc8f726298cf334a6dafd6402e39c4dcd7e6d333
Reviewed-on: https://chromium-review.googlesource.com/450028
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/Context.cpp b/src/libANGLE/Context.cpp
index 89e0b04..d3e4366 100644
--- a/src/libANGLE/Context.cpp
+++ b/src/libANGLE/Context.cpp
@@ -1652,6 +1652,62 @@
     }
 }
 
+void Context::getBufferParameteriv(GLenum target, GLenum pname, GLint *params)
+{
+    Buffer *buffer = mGLState.getTargetBuffer(target);
+    QueryBufferParameteriv(buffer, pname, params);
+}
+
+void Context::getFramebufferAttachmentParameteriv(GLenum target,
+                                                  GLenum attachment,
+                                                  GLenum pname,
+                                                  GLint *params)
+{
+    const Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target);
+    QueryFramebufferAttachmentParameteriv(framebuffer, attachment, pname, params);
+}
+
+void Context::getRenderbufferParameteriv(GLenum target, GLenum pname, GLint *params)
+{
+    Renderbuffer *renderbuffer = mGLState.getCurrentRenderbuffer();
+    QueryRenderbufferiv(this, renderbuffer, pname, params);
+}
+
+void Context::getTexParameterfv(GLenum target, GLenum pname, GLfloat *params)
+{
+    Texture *texture = getTargetTexture(target);
+    QueryTexParameterfv(texture, pname, params);
+}
+
+void Context::getTexParameteriv(GLenum target, GLenum pname, GLint *params)
+{
+    Texture *texture = getTargetTexture(target);
+    QueryTexParameteriv(texture, pname, params);
+}
+void Context::texParameterf(GLenum target, GLenum pname, GLfloat param)
+{
+    Texture *texture = getTargetTexture(target);
+    SetTexParameterf(texture, pname, param);
+}
+
+void Context::texParameterfv(GLenum target, GLenum pname, const GLfloat *params)
+{
+    Texture *texture = getTargetTexture(target);
+    SetTexParameterfv(texture, pname, params);
+}
+
+void Context::texParameteri(GLenum target, GLenum pname, GLint param)
+{
+    Texture *texture = getTargetTexture(target);
+    SetTexParameteri(texture, pname, param);
+}
+
+void Context::texParameteriv(GLenum target, GLenum pname, const GLint *params)
+{
+    Texture *texture = getTargetTexture(target);
+    SetTexParameteriv(texture, pname, params);
+}
+
 void Context::drawArrays(GLenum mode, GLint first, GLsizei count)
 {
     syncRendererState();
diff --git a/src/libANGLE/Context.h b/src/libANGLE/Context.h
index c96e27a..408bc20 100644
--- a/src/libANGLE/Context.h
+++ b/src/libANGLE/Context.h
@@ -163,6 +163,20 @@
 
     void setVertexAttribDivisor(GLuint index, GLuint divisor);
 
+    void getBufferParameteriv(GLenum target, GLenum pname, GLint *params);
+    void getFramebufferAttachmentParameteriv(GLenum target,
+                                             GLenum attachment,
+                                             GLenum pname,
+                                             GLint *params);
+    void getRenderbufferParameteriv(GLenum target, GLenum pname, GLint *params);
+
+    void getTexParameterfv(GLenum target, GLenum pname, GLfloat *params);
+    void getTexParameteriv(GLenum target, GLenum pname, GLint *params);
+    void texParameterf(GLenum target, GLenum pname, GLfloat param);
+    void texParameterfv(GLenum target, GLenum pname, const GLfloat *params);
+    void texParameteri(GLenum target, GLenum pname, GLint param);
+    void texParameteriv(GLenum target, GLenum pname, const GLint *params);
+
     void samplerParameteri(GLuint sampler, GLenum pname, GLint param);
     void samplerParameteriv(GLuint sampler, GLenum pname, const GLint *param);
     void samplerParameterf(GLuint sampler, GLenum pname, GLfloat param);
diff --git a/src/libGLESv2/entry_points_gles_2_0.cpp b/src/libGLESv2/entry_points_gles_2_0.cpp
index c4bc80c..79a3448 100644
--- a/src/libGLESv2/entry_points_gles_2_0.cpp
+++ b/src/libGLESv2/entry_points_gles_2_0.cpp
@@ -1149,8 +1149,7 @@
             return;
         }
 
-        Buffer *buffer = context->getGLState().getTargetBuffer(target);
-        QueryBufferParameteriv(buffer, pname, params);
+        context->getBufferParameteriv(target, pname, params);
     }
 }
 
@@ -1209,8 +1208,7 @@
             return;
         }
 
-        const Framebuffer *framebuffer = context->getGLState().getTargetFramebuffer(target);
-        QueryFramebufferAttachmentParameteriv(framebuffer, attachment, pname, params);
+        context->getFramebufferAttachmentParameteriv(target, attachment, pname, params);
     }
 }
 
@@ -1296,8 +1294,7 @@
             return;
         }
 
-        Renderbuffer *renderbuffer = context->getGLState().getCurrentRenderbuffer();
-        QueryRenderbufferiv(context, renderbuffer, pname, params);
+        context->getRenderbufferParameteriv(target, pname, params);
     }
 }
 
@@ -1472,8 +1469,7 @@
             return;
         }
 
-        Texture *texture = context->getTargetTexture(target);
-        QueryTexParameterfv(texture, pname, params);
+        context->getTexParameterfv(target, pname, params);
     }
 }
 
@@ -1490,8 +1486,7 @@
             return;
         }
 
-        Texture *texture = context->getTargetTexture(target);
-        QueryTexParameteriv(texture, pname, params);
+        context->getTexParameteriv(target, pname, params);
     }
 }
 
@@ -2226,8 +2221,7 @@
             return;
         }
 
-        Texture *texture = context->getTargetTexture(target);
-        SetTexParameterf(texture, pname, param);
+        context->texParameterf(target, pname, param);
     }
 }
 
@@ -2244,8 +2238,7 @@
             return;
         }
 
-        Texture *texture = context->getTargetTexture(target);
-        SetTexParameterfv(texture, pname, params);
+        context->texParameterfv(target, pname, params);
     }
 }
 
@@ -2261,8 +2254,7 @@
             return;
         }
 
-        Texture *texture = context->getTargetTexture(target);
-        SetTexParameteri(texture, pname, param);
+        context->texParameteri(target, pname, param);
     }
 }
 
@@ -2279,8 +2271,7 @@
             return;
         }
 
-        Texture *texture = context->getTargetTexture(target);
-        SetTexParameteriv(texture, pname, params);
+        context->texParameteriv(target, pname, params);
     }
 }