Return a ref for FBO attachment image indexes.

This cleans up the syntax somewhat. Also place some more of the
helper methods in the header.

BUG=angleproject:963

Change-Id: I62419095a7b65486f54d74791027594e8e595e48
Reviewed-on: https://chromium-review.googlesource.com/263629
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/validationES.cpp b/src/libANGLE/validationES.cpp
index d267cbf..8de5ca4 100644
--- a/src/libANGLE/validationES.cpp
+++ b/src/libANGLE/validationES.cpp
@@ -573,7 +573,7 @@
             {
                 FramebufferAttachment *readColorAttachment = readFramebuffer->getReadColorbuffer();
                 if (!readColorAttachment ||
-                    (!(readColorAttachment->type() == GL_TEXTURE && readColorAttachment->getTextureImageIndex()->type == GL_TEXTURE_2D) &&
+                    (!(readColorAttachment->type() == GL_TEXTURE && readColorAttachment->getTextureImageIndex().type == GL_TEXTURE_2D) &&
                     readColorAttachment->type() != GL_RENDERBUFFER &&
                     readColorAttachment->type() != GL_FRAMEBUFFER_DEFAULT))
                 {
@@ -588,7 +588,7 @@
                         FramebufferAttachment *attachment = drawFramebuffer->getColorbuffer(colorAttachment);
                         ASSERT(attachment);
 
-                        if (!(attachment->type() == GL_TEXTURE && attachment->getTextureImageIndex()->type == GL_TEXTURE_2D) &&
+                        if (!(attachment->type() == GL_TEXTURE && attachment->getTextureImageIndex().type == GL_TEXTURE_2D) &&
                             attachment->type() != GL_RENDERBUFFER &&
                             attachment->type() != GL_FRAMEBUFFER_DEFAULT)
                         {