Refactor SF. Move all GL operations in their own class.

this is the first step to add support for GLES 2.x, this
change breaks the dependency of SF on GLES 1.x by moving
all operation into their own class.

Bug: 8679321

Change-Id: I0d2741eca2cefe67dfd9cf837cac10c4d126928b
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 089c265..c0815f8 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -21,7 +21,7 @@
 #include <sys/types.h>
 
 #include <EGL/egl.h>
-#include <GLES/gl.h>
+#include <GLES/gl.h>        // needed for GLuint
 
 #include <cutils/compiler.h>
 
@@ -62,6 +62,7 @@
 class Layer;
 class LayerDim;
 class Surface;
+class RenderEngine;
 
 // ---------------------------------------------------------------------------
 
@@ -72,13 +73,6 @@
     eTransactionMask          = 0x07
 };
 
-enum GlesVersion {
-    GLES_VERSION_1_0    = 0x10000,
-    GLES_VERSION_1_1    = 0x10001,
-    GLES_VERSION_2_0    = 0x20000,
-    GLES_VERSION_3_0    = 0x30000,
-};
-
 class SurfaceFlinger : public BinderService<SurfaceFlinger>,
                        public BnSurfaceComposer,
                        private IBinder::DeathRecipient,
@@ -128,9 +122,8 @@
     // TODO: this should be made accessible only to HWComposer
     const Vector< sp<Layer> >& getLayerSortedByZForHwcDisplay(int id);
 
-    // return the version of the OpenGL ES composition context
-    GlesVersion getGlesVersion() const {
-        return mGlesVersion;
+    RenderEngine& getRenderEngine() const {
+        return *mRenderEngine;
     }
 
 private:
@@ -319,10 +312,8 @@
     static status_t selectConfigForAttribute(EGLDisplay dpy,
         EGLint const* attrs, EGLint attribute, EGLint value, EGLConfig* outConfig);
     static EGLConfig selectEGLConfig(EGLDisplay disp, EGLint visualId);
-    static EGLContext createGLContext(EGLDisplay disp, EGLConfig config);
-    void initializeGL(EGLDisplay display);
-    uint32_t getMaxTextureSize() const;
-    uint32_t getMaxViewportDims() const;
+    size_t getMaxTextureSize() const;
+    size_t getMaxViewportDims() const;
 
     /* ------------------------------------------------------------------------
      * Display and layer stack management
@@ -378,9 +369,6 @@
     void postFramebuffer();
     void drawWormhole(const sp<const DisplayDevice>& hw,
             const Region& region) const;
-    GLuint getProtectedTexName() const {
-        return mProtectedTexName;
-    }
 
     /* ------------------------------------------------------------------------
      * Display management
@@ -423,17 +411,14 @@
 
     // constant members (no synchronization needed for access)
     HWComposer* mHwc;
-    GLuint mProtectedTexName;
+    RenderEngine* mRenderEngine;
     nsecs_t mBootTime;
     bool mGpuToCpuSupported;
     sp<EventThread> mEventThread;
-    GLint mMaxViewportDims[2];
-    GLint mMaxTextureSize;
     EGLContext mEGLContext;
     EGLConfig mEGLConfig;
     EGLDisplay mEGLDisplay;
     EGLint mEGLNativeVisualId;
-    GlesVersion mGlesVersion;
     sp<IBinder> mBuiltinDisplays[DisplayDevice::NUM_DISPLAY_TYPES];
 
     // Can only accessed from the main thread, these members