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/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp
index b001bdb..2eae9c2 100644
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -29,18 +29,14 @@
#include <gui/Surface.h>
-#include <GLES/gl.h>
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-
#include <hardware/gralloc.h>
#include "DisplayHardware/DisplaySurface.h"
#include "DisplayHardware/HWComposer.h"
+#include "RenderEngine/RenderEngine.h"
#include "clz.h"
#include "DisplayDevice.h"
-#include "GLExtensions.h"
#include "SurfaceFlinger.h"
#include "Layer.h"
@@ -48,20 +44,6 @@
using namespace android;
// ----------------------------------------------------------------------------
-static __attribute__((noinline))
-void checkGLErrors()
-{
- do {
- // there could be more than one error flag
- GLenum error = glGetError();
- if (error == GL_NO_ERROR)
- break;
- ALOGE("GL error 0x%04x", int(error));
- } while(true);
-}
-
-// ----------------------------------------------------------------------------
-
/*
* Initialize the display to the specified values.
*
@@ -189,7 +171,7 @@
void DisplayDevice::flip(const Region& dirty) const
{
- checkGLErrors();
+ mFlinger->getRenderEngine().checkErrors();
EGLDisplay dpy = mDisplay;
EGLSurface surface = mSurface;
@@ -246,28 +228,22 @@
return mFlags;
}
-EGLBoolean DisplayDevice::makeCurrent(EGLDisplay dpy,
- const sp<const DisplayDevice>& hw, EGLContext ctx) {
+EGLBoolean DisplayDevice::makeCurrent(EGLDisplay dpy, EGLContext ctx) const {
EGLBoolean result = EGL_TRUE;
EGLSurface sur = eglGetCurrentSurface(EGL_DRAW);
- if (sur != hw->mSurface) {
- result = eglMakeCurrent(dpy, hw->mSurface, hw->mSurface, ctx);
+ if (sur != mSurface) {
+ result = eglMakeCurrent(dpy, mSurface, mSurface, ctx);
if (result == EGL_TRUE) {
- setViewportAndProjection(hw);
+ setViewportAndProjection();
}
}
return result;
}
-void DisplayDevice::setViewportAndProjection(const sp<const DisplayDevice>& hw) {
- GLsizei w = hw->mDisplayWidth;
- GLsizei h = hw->mDisplayHeight;
- glViewport(0, 0, w, h);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- // put the origin in the left-bottom corner
- glOrthof(0, w, 0, h, 0, 1); // l=0, r=w ; b=0, t=h
- glMatrixMode(GL_MODELVIEW);
+void DisplayDevice::setViewportAndProjection() const {
+ size_t w = mDisplayWidth;
+ size_t h = mDisplayHeight;
+ mFlinger->getRenderEngine().setViewportAndProjection(w, h);
}
// ----------------------------------------------------------------------------