Make the EGL surface class abstract.

gl::Surface is now the pure abstract interface for egl::Surface, which
can be used by libGLESv2 without requiring typeinfo.

Bug chromium:732667
Bug swiftshader:31

Change-Id: I7d8a5892c5b6186541f84c3cf39e72ac1d6c613d
Reviewed-on: https://swiftshader-review.googlesource.com/10129
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/Main/FrameBufferX11.cpp b/src/Main/FrameBufferX11.cpp
index 60e0e73..12b83e4 100644
--- a/src/Main/FrameBufferX11.cpp
+++ b/src/Main/FrameBufferX11.cpp
@@ -12,10 +12,6 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-// Surface.cpp: Implements the egl::Surface class, representing a drawing surface
-// such as the client area of a window, including any back buffers.
-// Implements EGLSurface and related functionality. [EGL 1.4] section 2.2 page 3.
-
 #include "FrameBufferX11.hpp"
 
 #include "libX11.hpp"
diff --git a/src/Main/FrameBufferX11.hpp b/src/Main/FrameBufferX11.hpp
index e76c81e..ab0c205 100644
--- a/src/Main/FrameBufferX11.hpp
+++ b/src/Main/FrameBufferX11.hpp
@@ -12,10 +12,6 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-// Surface.cpp: Implements the egl::Surface class, representing a drawing surface
-// such as the client area of a window, including any back buffers.
-// Implements EGLSurface and related functionality. [EGL 1.4] section 2.2 page 3.
-
 #ifndef sw_FrameBufferX11_hpp
 #define sw_FrameBufferX11_hpp
 
diff --git a/src/OpenGL/common/Surface.hpp b/src/OpenGL/common/Surface.hpp
new file mode 100644
index 0000000..50a9d00
--- /dev/null
+++ b/src/OpenGL/common/Surface.hpp
@@ -0,0 +1,52 @@
+// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Surface.hpp: Defines the gl::Surface class, which is the abstract interface
+// for an EGL surface as viewed by the GL implementation.
+
+#ifndef INCLUDE_SURFACE_H_
+#define INCLUDE_SURFACE_H_
+
+#include "Renderer/Surface.hpp"
+
+#include <EGL/egl.h>
+
+namespace egl
+{
+class Texture;
+class Image;
+}
+
+namespace gl
+{
+class [[clang::lto_visibility_public]] Surface
+{
+protected:
+	Surface();
+	virtual ~Surface() = 0;
+
+public:
+	virtual egl::Image *getRenderTarget() = 0;
+	virtual egl::Image *getDepthStencil() = 0;
+
+	virtual sw::Format getInternalFormat() const = 0;
+
+	virtual EGLint getWidth() const = 0;
+	virtual EGLint getHeight() const = 0;
+
+	virtual void setBoundTexture(egl::Texture *texture) = 0;
+};
+}
+
+#endif   // INCLUDE_SURFACE_H_
diff --git a/src/OpenGL/libEGL/Android.mk b/src/OpenGL/libEGL/Android.mk
index d756685..00c41f4 100644
--- a/src/OpenGL/libEGL/Android.mk
+++ b/src/OpenGL/libEGL/Android.mk
@@ -19,7 +19,7 @@
 COMMON_SRC_FILES := \
 	Config.cpp \
 	Display.cpp \
-	EGLSurface.cpp \
+	Surface.cpp \
 	libEGL.cpp \
 	main.cpp
 
diff --git a/src/OpenGL/libEGL/BUILD.gn b/src/OpenGL/libEGL/BUILD.gn
index 979fd23..fcd609b 100644
--- a/src/OpenGL/libEGL/BUILD.gn
+++ b/src/OpenGL/libEGL/BUILD.gn
@@ -56,7 +56,7 @@
     "../common/Object.cpp",
     "Config.cpp",
     "Display.cpp",
-    "EGLSurface.cpp",
+    "Surface.cpp",
     "libEGL.cpp",
     "libEGL.def",
     "libEGL.rc",
diff --git a/src/OpenGL/libEGL/Context.hpp b/src/OpenGL/libEGL/Context.hpp
index 70a47a6..acf06ce 100644
--- a/src/OpenGL/libEGL/Context.hpp
+++ b/src/OpenGL/libEGL/Context.hpp
@@ -20,19 +20,18 @@
 #include <EGL/egl.h>
 #include <GLES/gl.h>
 
+namespace gl { class Surface; }
+
 namespace egl
 {
 class Display;
-class Surface;
 class Image;
 
 class [[clang::lto_visibility_public]] Context : public gl::Object
 {
 public:
-	Context(egl::Display *display) : display(display) {}
-
-	virtual void makeCurrent(Surface *surface) = 0;
-	virtual void bindTexImage(Surface *surface) = 0;
+	virtual void makeCurrent(gl::Surface *surface) = 0;
+	virtual void bindTexImage(gl::Surface *surface) = 0;
 	virtual EGLenum validateSharedImage(EGLenum target, GLuint name, GLuint textureLevel) = 0;
 	virtual Image *createSharedImage(EGLenum target, GLuint name, GLuint textureLevel) = 0;
 	virtual EGLint getClientVersion() const = 0;
@@ -40,6 +39,7 @@
 	virtual void finish() = 0;
 
 protected:
+	Context(egl::Display *display) : display(display) {}
 	virtual ~Context() {};
 
 	egl::Display *const display;
diff --git a/src/OpenGL/libEGL/Display.cpp b/src/OpenGL/libEGL/Display.cpp
index 6a5dffe..a4aacfd 100644
--- a/src/OpenGL/libEGL/Display.cpp
+++ b/src/OpenGL/libEGL/Display.cpp
@@ -19,7 +19,7 @@
 #include "Display.h"
 
 #include "main.h"
-#include "libEGL/EGLSurface.h"
+#include "libEGL/Surface.hpp"
 #include "libEGL/Context.hpp"
 #include "common/Image.hpp"
 #include "common/debug.h"
diff --git a/src/OpenGL/libEGL/EGLSurface.cpp b/src/OpenGL/libEGL/Surface.cpp
similarity index 98%
rename from src/OpenGL/libEGL/EGLSurface.cpp
rename to src/OpenGL/libEGL/Surface.cpp
index f47cacb..d195b46 100644
--- a/src/OpenGL/libEGL/EGLSurface.cpp
+++ b/src/OpenGL/libEGL/Surface.cpp
@@ -16,7 +16,7 @@
 // such as the client area of a window, including any back buffers.
 // Implements EGLSurface and related functionality. [EGL 1.4] section 2.2 page 3.
 
-#include "EGLSurface.h"
+#include "Surface.hpp"
 
 #include "main.h"
 #include "Display.h"
@@ -36,9 +36,19 @@
 
 #include <algorithm>
 
+namespace gl
+{
+Surface::Surface()
+{
+}
+
+Surface::~Surface()
+{
+}
+}
+
 namespace egl
 {
-
 Surface::Surface(const Display *display, const Config *config) : display(display), config(config)
 {
 	backBuffer = nullptr;
diff --git a/src/OpenGL/libEGL/EGLSurface.h b/src/OpenGL/libEGL/Surface.hpp
similarity index 87%
rename from src/OpenGL/libEGL/EGLSurface.h
rename to src/OpenGL/libEGL/Surface.hpp
index c5026e2..e140a8e 100644
--- a/src/OpenGL/libEGL/EGLSurface.h
+++ b/src/OpenGL/libEGL/Surface.hpp
@@ -12,15 +12,17 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-// Surface.h: Defines the egl::Surface class, representing a drawing surface
+// Surface.hpp: Defines the egl::Surface class, representing a rendering surface
 // such as the client area of a window, including any back buffers.
 // Implements EGLSurface and related functionality. [EGL 1.4] section 2.2 page 3.
 
-#ifndef INCLUDE_SURFACE_H_
-#define INCLUDE_SURFACE_H_
+#ifndef INCLUDE_EGL_SURFACE_H_
+#define INCLUDE_EGL_SURFACE_H_
+
+#include "common/Object.hpp"
+#include "common/Surface.hpp"
 
 #include "Main/FrameBuffer.hpp"
-#include "common/Object.hpp"
 
 #include <EGL/egl.h>
 
@@ -28,27 +30,25 @@
 {
 class Display;
 class Config;
-class Texture;
-class Image;
 
-class [[clang::lto_visibility_public]] Surface : public gl::Object
+class Surface : public gl::Surface, public gl::Object
 {
 public:
 	virtual bool initialize();
 	virtual void swap() = 0;
 
-	virtual egl::Image *getRenderTarget();
-	virtual egl::Image *getDepthStencil();
+	egl::Image *getRenderTarget() override;
+	egl::Image *getDepthStencil() override;
 
 	void setSwapBehavior(EGLenum swapBehavior);
 	void setSwapInterval(EGLint interval);
 
 	virtual EGLint getConfigID() const;
 	virtual EGLenum getSurfaceType() const;
-	virtual sw::Format getInternalFormat() const;
+	sw::Format getInternalFormat() const override;
 
-	virtual EGLint getWidth() const;
-	virtual EGLint getHeight() const;
+	EGLint getWidth() const override;
+	EGLint getHeight() const override;
 	virtual EGLint getPixelAspectRatio() const;
 	virtual EGLenum getRenderBuffer() const;
 	virtual EGLenum getSwapBehavior() const;
@@ -57,7 +57,7 @@
 	virtual EGLBoolean getLargestPBuffer() const;
 	virtual EGLNativeWindowType getWindowHandle() const = 0;
 
-	virtual void setBoundTexture(egl::Texture *texture);
+	void setBoundTexture(egl::Texture *texture) override;
 	virtual egl::Texture *getBoundTexture() const;
 
 	virtual bool isWindowSurface() const { return false; }
@@ -66,7 +66,7 @@
 protected:
 	Surface(const Display *display, const Config *config);
 
-	virtual ~Surface();
+	~Surface() override;
 
 	virtual void deleteResources();
 
@@ -134,4 +134,4 @@
 };
 }
 
-#endif   // INCLUDE_SURFACE_H_
+#endif   // INCLUDE_EGL_SURFACE_H_
diff --git a/src/OpenGL/libEGL/libEGL.cpp b/src/OpenGL/libEGL/libEGL.cpp
index 2072e24..979691e 100644
--- a/src/OpenGL/libEGL/libEGL.cpp
+++ b/src/OpenGL/libEGL/libEGL.cpp
@@ -16,7 +16,7 @@
 
 #include "main.h"
 #include "Display.h"
-#include "EGLSurface.h"
+#include "Surface.hpp"
 #include "Texture.hpp"
 #include "Context.hpp"
 #include "common/Image.hpp"
diff --git a/src/OpenGL/libEGL/libEGL.vcxproj b/src/OpenGL/libEGL/libEGL.vcxproj
index 795d598..01ef9cb 100644
--- a/src/OpenGL/libEGL/libEGL.vcxproj
+++ b/src/OpenGL/libEGL/libEGL.vcxproj
@@ -319,13 +319,14 @@
     <ClCompile Include="Display.cpp" />

     <ClCompile Include="libEGL.cpp" />

     <ClCompile Include="main.cpp" />

-    <ClCompile Include="EGLSurface.cpp" />

+    <ClCompile Include="Surface.cpp" />

   </ItemGroup>

   <ItemGroup>

     <ClInclude Include="..\common\debug.h" />

     <ClInclude Include="..\common\Image.hpp" />

     <ClInclude Include="..\common\NameSpace.hpp" />

     <ClInclude Include="..\common\Object.hpp" />

+    <ClInclude Include="..\common\Surface.hpp" />

     <ClInclude Include="..\include\EGL\egl.h" />

     <ClInclude Include="..\include\EGL\eglext.h" />

     <ClInclude Include="..\include\EGL\eglplatform.h" />

@@ -335,7 +336,7 @@
     <ClInclude Include="libEGL.hpp" />

     <ClInclude Include="main.h" />

     <ClInclude Include="resource.h" />

-    <ClInclude Include="EGLSurface.h" />

+    <ClInclude Include="Surface.hpp" />

     <ClInclude Include="Sync.hpp" />

     <ClInclude Include="Texture.hpp" />

   </ItemGroup>

diff --git a/src/OpenGL/libEGL/libEGL.vcxproj.filters b/src/OpenGL/libEGL/libEGL.vcxproj.filters
index 6c99d0b..7e4fcb1 100644
--- a/src/OpenGL/libEGL/libEGL.vcxproj.filters
+++ b/src/OpenGL/libEGL/libEGL.vcxproj.filters
@@ -29,7 +29,7 @@
     <ClCompile Include="..\common\Object.cpp">

       <Filter>Source Files</Filter>

     </ClCompile>

-    <ClCompile Include="EGLSurface.cpp">

+    <ClCompile Include="Surface.cpp">

       <Filter>Source Files</Filter>

     </ClCompile>

   </ItemGroup>

@@ -79,7 +79,10 @@
     <ClInclude Include="..\common\NameSpace.hpp">

       <Filter>Header Files</Filter>

     </ClInclude>

-    <ClInclude Include="EGLSurface.h">

+    <ClInclude Include="..\common\Surface.hpp">

+      <Filter>Header Files</Filter>

+    </ClInclude>

+    <ClInclude Include="Surface.hpp">

       <Filter>Header Files</Filter>

     </ClInclude>

   </ItemGroup>

diff --git a/src/OpenGL/libEGL/main.cpp b/src/OpenGL/libEGL/main.cpp
index 77ec248..8aa9582 100644
--- a/src/OpenGL/libEGL/main.cpp
+++ b/src/OpenGL/libEGL/main.cpp
@@ -18,7 +18,7 @@
 
 #include "libEGL.hpp"
 #include "Context.hpp"
-#include "EGLSurface.h"
+#include "Surface.hpp"
 
 #include "resource.h"
 #include "Common/Thread.hpp"
diff --git a/src/OpenGL/libEGL/main.h b/src/OpenGL/libEGL/main.h
index f3231f0..25b9ecf 100644
--- a/src/OpenGL/libEGL/main.h
+++ b/src/OpenGL/libEGL/main.h
@@ -28,6 +28,8 @@
 	class Display;
 	class Context;
 	class Surface;
+	class Config;
+	class Image;
 
 	struct Current
 	{
@@ -76,12 +78,6 @@
 
 		return returnValue;
 	}
-
-	class Config;
-	class Surface;
-	class Display;
-	class Context;
-	class Image;
 }
 
 extern LibGLES_CM libGLES_CM;
diff --git a/src/OpenGL/libGLES_CM/Context.cpp b/src/OpenGL/libGLES_CM/Context.cpp
index 78fcec5..5e09b65 100644
--- a/src/OpenGL/libGLES_CM/Context.cpp
+++ b/src/OpenGL/libGLES_CM/Context.cpp
@@ -28,7 +28,7 @@
 #include "VertexDataManager.h"
 #include "IndexDataManager.h"
 #include "libEGL/Display.h"
-#include "libEGL/EGLSurface.h"
+#include "common/Surface.hpp"
 #include "Common/Half.hpp"
 
 #include <EGL/eglext.h>
@@ -281,7 +281,7 @@
 	delete device;
 }
 
-void Context::makeCurrent(egl::Surface *surface)
+void Context::makeCurrent(gl::Surface *surface)
 {
 	if(!mHasBeenCurrent)
 	{
@@ -3095,7 +3095,7 @@
 	mVertexDataManager->dirtyCurrentValue(index);
 }
 
-void Context::bindTexImage(egl::Surface *surface)
+void Context::bindTexImage(gl::Surface *surface)
 {
 	es1::Texture2D *textureObject = getTexture2D();
 
diff --git a/src/OpenGL/libGLES_CM/Context.h b/src/OpenGL/libGLES_CM/Context.h
index 63efb74..ab169be 100644
--- a/src/OpenGL/libGLES_CM/Context.h
+++ b/src/OpenGL/libGLES_CM/Context.h
@@ -33,10 +33,11 @@
 #include <map>
 #include <string>
 
+namespace gl { class Surface; }
+
 namespace egl
 {
 class Display;
-class Surface;
 class Config;
 }
 
@@ -296,7 +297,7 @@
 public:
 	Context(egl::Display *display, const Context *shareContext, const egl::Config *config);
 
-	void makeCurrent(egl::Surface *surface) override;
+	void makeCurrent(gl::Surface *surface) override;
 	EGLint getClientVersion() const override;
 	EGLint getConfigID() const override;
 
@@ -508,9 +509,9 @@
 
 	static int getSupportedMultisampleCount(int requested);
 
-	virtual void bindTexImage(egl::Surface *surface);
-	virtual EGLenum validateSharedImage(EGLenum target, GLuint name, GLuint textureLevel);
-	virtual egl::Image *createSharedImage(EGLenum target, GLuint name, GLuint textureLevel);
+	void bindTexImage(gl::Surface *surface) override;
+	EGLenum validateSharedImage(EGLenum target, GLuint name, GLuint textureLevel) override;
+	egl::Image *createSharedImage(EGLenum target, GLuint name, GLuint textureLevel) override;
 	egl::Image *getSharedImage(GLeglImageOES image);
 
 	Device *getDevice();
@@ -579,7 +580,7 @@
 	void setPointFadeThresholdSize(float threshold);
 
 private:
-	virtual ~Context();
+	~Context() override;
 
 	bool applyRenderTarget();
 	void applyState(GLenum drawMode);
diff --git a/src/OpenGL/libGLES_CM/Texture.cpp b/src/OpenGL/libGLES_CM/Texture.cpp
index d54885c..e2e8400 100644
--- a/src/OpenGL/libGLES_CM/Texture.cpp
+++ b/src/OpenGL/libGLES_CM/Texture.cpp
@@ -23,7 +23,7 @@
 #include "Framebuffer.h"
 #include "Device.hpp"
 #include "libEGL/Display.h"
-#include "libEGL/EGLSurface.h"
+#include "common/Surface.hpp"
 #include "common/debug.h"
 
 #include <algorithm>
@@ -474,7 +474,7 @@
 	Texture::setImage(format, type, unpackAlignment, pixels, image[level]);
 }
 
-void Texture2D::bindTexImage(egl::Surface *surface)
+void Texture2D::bindTexImage(gl::Surface *surface)
 {
 	GLenum format;
 
diff --git a/src/OpenGL/libGLES_CM/Texture.h b/src/OpenGL/libGLES_CM/Texture.h
index ba0c4d5..82e4b33 100644
--- a/src/OpenGL/libGLES_CM/Texture.h
+++ b/src/OpenGL/libGLES_CM/Texture.h
@@ -29,11 +29,8 @@
 
 #include <vector>
 
-namespace egl
-{
-class Surface;
-class Config;
-}
+namespace gl { class Surface; }
+namespace egl { class Config; }
 
 namespace es1
 {
@@ -155,7 +152,7 @@
 	virtual bool isSamplerComplete() const;
 	virtual bool isCompressed(GLenum target, GLint level) const;
 	virtual bool isDepth(GLenum target, GLint level) const;
-	virtual void bindTexImage(egl::Surface *surface);
+	virtual void bindTexImage(gl::Surface *surface);
 	virtual void releaseTexImage();
 
 	virtual void generateMipmaps();
@@ -174,7 +171,7 @@
 
 	egl::Image *image[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
 
-	egl::Surface *mSurface;
+	gl::Surface *mSurface;
 
 	// A specific internal reference count is kept for colorbuffer proxy references,
 	// because, as the renderbuffer acting as proxy will maintain a binding pointer
diff --git a/src/OpenGL/libGLES_CM/main.cpp b/src/OpenGL/libGLES_CM/main.cpp
index 036147f..f9b3cbd 100644
--- a/src/OpenGL/libGLES_CM/main.cpp
+++ b/src/OpenGL/libGLES_CM/main.cpp
@@ -18,7 +18,7 @@
 
 #include "libGLES_CM.hpp"
 #include "Framebuffer.h"
-#include "libEGL/EGLSurface.h"
+#include "common/Surface.hpp"
 #include "Common/Thread.hpp"
 #include "Common/SharedLibrary.hpp"
 #include "common/debug.h"
diff --git a/src/OpenGL/libGLESv2/Context.cpp b/src/OpenGL/libGLESv2/Context.cpp
index 445973b..976f66b 100644
--- a/src/OpenGL/libGLESv2/Context.cpp
+++ b/src/OpenGL/libGLESv2/Context.cpp
@@ -35,7 +35,7 @@
 #include "VertexDataManager.h"
 #include "IndexDataManager.h"
 #include "libEGL/Display.h"
-#include "libEGL/EGLSurface.h"
+#include "common/Surface.hpp"
 #include "Common/Half.hpp"
 
 #include <EGL/eglext.h>
@@ -265,7 +265,7 @@
 	delete device;
 }
 
-void Context::makeCurrent(egl::Surface *surface)
+void Context::makeCurrent(gl::Surface *surface)
 {
 	if(!mHasBeenCurrent)
 	{
@@ -4138,7 +4138,7 @@
 	}
 }
 
-void Context::bindTexImage(egl::Surface *surface)
+void Context::bindTexImage(gl::Surface *surface)
 {
 	es2::Texture2D *textureObject = getTexture2D();
 
diff --git a/src/OpenGL/libGLESv2/Context.h b/src/OpenGL/libGLESv2/Context.h
index a8e450a..3930603 100644
--- a/src/OpenGL/libGLESv2/Context.h
+++ b/src/OpenGL/libGLESv2/Context.h
@@ -37,7 +37,6 @@
 namespace egl
 {
 class Display;
-class Surface;
 class Config;
 }
 
@@ -431,7 +430,7 @@
 public:
 	Context(egl::Display *display, const Context *shareContext, EGLint clientVersion, const egl::Config *config);
 
-	void makeCurrent(egl::Surface *surface) override;
+	void makeCurrent(gl::Surface *surface) override;
 	EGLint getClientVersion() const override;
 	EGLint getConfigID() const override;
 
@@ -691,7 +690,7 @@
 	                     GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
 	                     GLbitfield mask, bool filter, bool allowPartialDepthStencilBlit);
 
-	void bindTexImage(egl::Surface *surface) override;
+	void bindTexImage(gl::Surface *surface) override;
 	EGLenum validateSharedImage(EGLenum target, GLuint name, GLuint textureLevel) override;
 	egl::Image *createSharedImage(EGLenum target, GLuint name, GLuint textureLevel) override;
 	egl::Image *getSharedImage(GLeglImageOES image);
@@ -701,7 +700,7 @@
 	const GLubyte *getExtensions(GLuint index, GLuint *numExt = nullptr) const;
 
 private:
-	virtual ~Context();
+	~Context() override;
 
 	void applyScissor(int width, int height);
 	bool applyRenderTarget();
diff --git a/src/OpenGL/libGLESv2/Texture.cpp b/src/OpenGL/libGLESv2/Texture.cpp
index 40c8ed4..e7d894d 100644
--- a/src/OpenGL/libGLESv2/Texture.cpp
+++ b/src/OpenGL/libGLESv2/Texture.cpp
@@ -23,7 +23,7 @@
 #include "Framebuffer.h"
 #include "Device.hpp"
 #include "libEGL/Display.h"
-#include "libEGL/EGLSurface.h"
+#include "common/Surface.hpp"
 #include "common/debug.h"
 
 #include <algorithm>
@@ -650,7 +650,7 @@
 	Texture::setImage(format, type, unpackInfo, pixels, image[level]);
 }
 
-void Texture2D::bindTexImage(egl::Surface *surface)
+void Texture2D::bindTexImage(gl::Surface *surface)
 {
 	GLenum format;
 
@@ -1611,7 +1611,7 @@
 	Texture::setImage(format, type, unpackInfo, pixels, image[level]);
 }
 
-void Texture3D::bindTexImage(egl::Surface *surface)
+void Texture3D::bindTexImage(gl::Surface *surface)
 {
 	GLenum format;
 
diff --git a/src/OpenGL/libGLESv2/Texture.h b/src/OpenGL/libGLESv2/Texture.h
index a97f168..f01e0f2 100644
--- a/src/OpenGL/libGLESv2/Texture.h
+++ b/src/OpenGL/libGLESv2/Texture.h
@@ -29,11 +29,8 @@
 
 #include <vector>
 
-namespace egl
-{
-class Surface;
-class Config;
-}
+namespace gl { class Surface; }
+namespace egl { class Config; }
 
 namespace es2
 {
@@ -180,7 +177,7 @@
 	virtual bool isSamplerComplete() const;
 	virtual bool isCompressed(GLenum target, GLint level) const;
 	virtual bool isDepth(GLenum target, GLint level) const;
-	virtual void bindTexImage(egl::Surface *surface);
+	virtual void bindTexImage(gl::Surface *surface);
 	virtual void releaseTexImage();
 
 	virtual void generateMipmaps();
@@ -198,7 +195,7 @@
 
 	egl::Image *image[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
 
-	egl::Surface *mSurface;
+	gl::Surface *mSurface;
 
 	// A specific internal reference count is kept for colorbuffer proxy references,
 	// because, as the renderbuffer acting as proxy will maintain a binding pointer
@@ -300,7 +297,7 @@
 	virtual bool isSamplerComplete() const;
 	virtual bool isCompressed(GLenum target, GLint level) const;
 	virtual bool isDepth(GLenum target, GLint level) const;
-	virtual void bindTexImage(egl::Surface *surface);
+	virtual void bindTexImage(gl::Surface *surface);
 	virtual void releaseTexImage();
 
 	virtual void generateMipmaps();
@@ -318,7 +315,7 @@
 
 	egl::Image *image[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
 
-	egl::Surface *mSurface;
+	gl::Surface *mSurface;
 
 	// A specific internal reference count is kept for colorbuffer proxy references,
 	// because, as the renderbuffer acting as proxy will maintain a binding pointer
diff --git a/src/OpenGL/libGLESv2/libGLESv2.vcxproj b/src/OpenGL/libGLESv2/libGLESv2.vcxproj
index 5750080..bbb16a9 100644
--- a/src/OpenGL/libGLESv2/libGLESv2.vcxproj
+++ b/src/OpenGL/libGLESv2/libGLESv2.vcxproj
@@ -365,6 +365,7 @@
     <ClInclude Include="..\common\Image.hpp" />

     <ClInclude Include="..\common\NameSpace.hpp" />

     <ClInclude Include="..\common\Object.hpp" />

+    <ClInclude Include="..\common\Surface.hpp" />

     <ClInclude Include="..\include\GLES2\gl2.h" />

     <ClInclude Include="..\include\GLES2\gl2ext.h" />

     <ClInclude Include="..\include\GLES2\gl2platform.h" />

diff --git a/src/OpenGL/libGLESv2/libGLESv2.vcxproj.filters b/src/OpenGL/libGLESv2/libGLESv2.vcxproj.filters
index 1a1aa6b..e297714 100644
--- a/src/OpenGL/libGLESv2/libGLESv2.vcxproj.filters
+++ b/src/OpenGL/libGLESv2/libGLESv2.vcxproj.filters
@@ -163,6 +163,9 @@
     <ClInclude Include="..\common\Image.hpp">

       <Filter>Header Files</Filter>

     </ClInclude>

+    <ClInclude Include="..\common\Surface.hpp">

+      <Filter>Header Files</Filter>

+    </ClInclude>

   </ItemGroup>

   <ItemGroup>

     <ResourceCompile Include="libGLESv2.rc" />

diff --git a/src/OpenGL/libGLESv2/main.cpp b/src/OpenGL/libGLESv2/main.cpp
index de3e7e1..348f361 100644
--- a/src/OpenGL/libGLESv2/main.cpp
+++ b/src/OpenGL/libGLESv2/main.cpp
@@ -19,7 +19,7 @@
 #include "libGLESv2.hpp"
 #include "Framebuffer.h"
 #include "libEGL/main.h"
-#include "libEGL/EGLSurface.h"
+#include "common/Surface.hpp"
 #include "Common/Thread.hpp"
 #include "Common/SharedLibrary.hpp"
 #include "common/debug.h"