Created
November 26, 2013 22:45
-
-
Save steven676/7667680 to your computer and use it in GitHub Desktop.
[PATCH 6/6] Allow targets to avoid requesting pbuffer support from the EGL implementation (against android-4.4_r1.2 frameworks/native)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 85ca158d9ccc332c73b68632b4a76a11ca9f8371 Mon Sep 17 00:00:00 2001 | |
From: Steven Luo <[email protected]> | |
Date: Sun, 3 Nov 2013 20:43:42 -0800 | |
Subject: [PATCH 6/6] Allow targets to avoid requesting pbuffer support from | |
the EGL implementation | |
Change-Id: Ie77bc1417acef0912ef8a6da23e8b0b44e2154ac | |
--- | |
services/surfaceflinger/Android.mk | 4 ++ | |
.../RenderEngine/GLES11RenderEngine.cpp | 5 ++- | |
.../RenderEngine/GLES11RenderEngine.h | 2 + | |
.../RenderEngine/GLES20RenderEngine.cpp | 5 ++- | |
.../RenderEngine/GLES20RenderEngine.h | 2 + | |
.../surfaceflinger/RenderEngine/RenderEngine.cpp | 46 ++++++++++++++------ | |
.../surfaceflinger/RenderEngine/RenderEngine.h | 4 ++ | |
services/surfaceflinger/SurfaceFlinger.cpp | 5 +++ | |
8 files changed, 57 insertions(+), 16 deletions(-) | |
diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk | |
index 6a496f3..716312d 100644 | |
--- a/services/surfaceflinger/Android.mk | |
+++ b/services/surfaceflinger/Android.mk | |
@@ -55,6 +55,10 @@ ifeq ($(TARGET_DISABLE_SURFACEFLINGER_GLES2),true) | |
LOCAL_CFLAGS += -DTARGET_DISABLE_SURFACEFLINGER_GLES2 | |
endif | |
+ifeq ($(TARGET_DISABLE_SURFACEFLINGER_PBUFFERS),true) | |
+ LOCAL_CFLAGS += -DTARGET_DISABLE_SURFACEFLINGER_PBUFFERS | |
+endif | |
+ | |
ifneq ($(NUM_FRAMEBUFFER_SURFACE_BUFFERS),) | |
LOCAL_CFLAGS += -DNUM_FRAMEBUFFER_SURFACE_BUFFERS=$(NUM_FRAMEBUFFER_SURFACE_BUFFERS) | |
endif | |
diff --git a/services/surfaceflinger/RenderEngine/GLES11RenderEngine.cpp b/services/surfaceflinger/RenderEngine/GLES11RenderEngine.cpp | |
index da69965..777a542 100644 | |
--- a/services/surfaceflinger/RenderEngine/GLES11RenderEngine.cpp | |
+++ b/services/surfaceflinger/RenderEngine/GLES11RenderEngine.cpp | |
@@ -28,8 +28,9 @@ | |
namespace android { | |
// --------------------------------------------------------------------------- | |
-GLES11RenderEngine::GLES11RenderEngine() { | |
+GLES11RenderEngine::GLES11RenderEngine() { } | |
+void GLES11RenderEngine::initializeGL() { | |
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize); | |
glGetIntegerv(GL_MAX_VIEWPORT_DIMS, mMaxViewportDims); | |
@@ -55,6 +56,8 @@ GLES11RenderEngine::GLES11RenderEngine() { | |
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); | |
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, | |
GL_RGB, GL_UNSIGNED_SHORT_5_6_5, protTexData); | |
+ | |
+ logEGLInfo(); | |
} | |
GLES11RenderEngine::~GLES11RenderEngine() { | |
diff --git a/services/surfaceflinger/RenderEngine/GLES11RenderEngine.h b/services/surfaceflinger/RenderEngine/GLES11RenderEngine.h | |
index 6e4c46e..4d2763c 100644 | |
--- a/services/surfaceflinger/RenderEngine/GLES11RenderEngine.h | |
+++ b/services/surfaceflinger/RenderEngine/GLES11RenderEngine.h | |
@@ -48,6 +48,8 @@ public: | |
protected: | |
virtual ~GLES11RenderEngine(); | |
+ virtual void initializeGL(); | |
+ | |
virtual void dump(String8& result); | |
virtual void setViewportAndProjection(size_t vpw, size_t vph, size_t w, size_t h, bool yswap); | |
virtual void setupLayerBlending(bool premultipliedAlpha, bool opaque, int alpha); | |
diff --git a/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp b/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp | |
index ada3ab0..5038db6 100644 | |
--- a/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp | |
+++ b/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp | |
@@ -36,8 +36,9 @@ namespace android { | |
// --------------------------------------------------------------------------- | |
GLES20RenderEngine::GLES20RenderEngine() : | |
- mVpWidth(0), mVpHeight(0) { | |
+ mVpWidth(0), mVpHeight(0) { } | |
+void GLES20RenderEngine::initializeGL() { | |
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize); | |
glGetIntegerv(GL_MAX_VIEWPORT_DIMS, mMaxViewportDims); | |
@@ -61,6 +62,8 @@ GLES20RenderEngine::GLES20RenderEngine() : | |
GL_RGB, GL_UNSIGNED_SHORT_5_6_5, protTexData); | |
//mColorBlindnessCorrection = M; | |
+ | |
+ logEGLInfo(); | |
} | |
GLES20RenderEngine::~GLES20RenderEngine() { | |
diff --git a/services/surfaceflinger/RenderEngine/GLES20RenderEngine.h b/services/surfaceflinger/RenderEngine/GLES20RenderEngine.h | |
index d5c5b5d..2d91163 100644 | |
--- a/services/surfaceflinger/RenderEngine/GLES20RenderEngine.h | |
+++ b/services/surfaceflinger/RenderEngine/GLES20RenderEngine.h | |
@@ -64,6 +64,8 @@ public: | |
protected: | |
virtual ~GLES20RenderEngine(); | |
+ virtual void initializeGL(); | |
+ | |
virtual void dump(String8& result); | |
virtual void setViewportAndProjection(size_t vpw, size_t vph, size_t w, size_t h, bool yswap); | |
virtual void setupLayerBlending(bool premultipliedAlpha, bool opaque, int alpha); | |
diff --git a/services/surfaceflinger/RenderEngine/RenderEngine.cpp b/services/surfaceflinger/RenderEngine/RenderEngine.cpp | |
index 8a8ee56..53aa85b 100644 | |
--- a/services/surfaceflinger/RenderEngine/RenderEngine.cpp | |
+++ b/services/surfaceflinger/RenderEngine/RenderEngine.cpp | |
@@ -63,6 +63,19 @@ RenderEngine* RenderEngine::create(EGLDisplay display, EGLConfig config) { | |
LOG_ALWAYS_FATAL_IF(ctxt==EGL_NO_CONTEXT, "EGLContext creation failed"); | |
+ RenderEngine* engine = NULL; | |
+#ifdef TARGET_DISABLE_SURFACEFLINGER_PBUFFERS | |
+ // XXX Assume that we got the GL version we requested | |
+ switch (contextClientVersion) { | |
+ case 1: | |
+ // XXX Assume that it's GLES 1.1 and not 1.0 | |
+ engine = new GLES11RenderEngine(); | |
+ break; | |
+ case 2: | |
+ engine = new GLES20RenderEngine(); | |
+ break; | |
+ } | |
+#else | |
// now figure out what version of GL did we actually get | |
// NOTE: a dummy surface is not needed if KHR_create_context is supported | |
@@ -81,9 +94,6 @@ RenderEngine* RenderEngine::create(EGLDisplay display, EGLConfig config) { | |
GlesVersion version = parseGlesVersion( extensions.getVersion() ); | |
- // initialize the renderer while GL is current | |
- | |
- RenderEngine* engine = NULL; | |
switch (version) { | |
case GLES_VERSION_1_0: | |
engine = new GLES10RenderEngine(); | |
@@ -96,18 +106,9 @@ RenderEngine* RenderEngine::create(EGLDisplay display, EGLConfig config) { | |
engine = new GLES20RenderEngine(); | |
break; | |
} | |
- engine->setEGLContext(ctxt); | |
- | |
- ALOGI("OpenGL ES informations:"); | |
- ALOGI("vendor : %s", extensions.getVendor()); | |
- ALOGI("renderer : %s", extensions.getRenderer()); | |
- ALOGI("version : %s", extensions.getVersion()); | |
- ALOGI("extensions: %s", extensions.getExtension()); | |
- ALOGI("GL_MAX_TEXTURE_SIZE = %d", engine->getMaxTextureSize()); | |
- ALOGI("GL_MAX_VIEWPORT_DIMS = %d", engine->getMaxViewportDims()); | |
+#endif | |
- eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); | |
- eglDestroySurface(display, dummy); | |
+ engine->setEGLContext(ctxt); | |
return engine; | |
} | |
@@ -118,6 +119,23 @@ RenderEngine::RenderEngine() : mEGLContext(EGL_NO_CONTEXT) { | |
RenderEngine::~RenderEngine() { | |
} | |
+void RenderEngine::logEGLInfo() { | |
+ GLExtensions& extensions(GLExtensions::getInstance()); | |
+ extensions.initWithGLStrings( | |
+ glGetString(GL_VENDOR), | |
+ glGetString(GL_RENDERER), | |
+ glGetString(GL_VERSION), | |
+ glGetString(GL_EXTENSIONS)); | |
+ | |
+ ALOGI("OpenGL ES informations:"); | |
+ ALOGI("vendor : %s", extensions.getVendor()); | |
+ ALOGI("renderer : %s", extensions.getRenderer()); | |
+ ALOGI("version : %s", extensions.getVersion()); | |
+ ALOGI("extensions: %s", extensions.getExtension()); | |
+ ALOGI("GL_MAX_TEXTURE_SIZE = %d", getMaxTextureSize()); | |
+ ALOGI("GL_MAX_VIEWPORT_DIMS = %d", getMaxViewportDims()); | |
+} | |
+ | |
void RenderEngine::setEGLContext(EGLContext ctxt) { | |
mEGLContext = ctxt; | |
} | |
diff --git a/services/surfaceflinger/RenderEngine/RenderEngine.h b/services/surfaceflinger/RenderEngine/RenderEngine.h | |
index e69b914..4ff83c0 100644 | |
--- a/services/surfaceflinger/RenderEngine/RenderEngine.h | |
+++ b/services/surfaceflinger/RenderEngine/RenderEngine.h | |
@@ -54,9 +54,13 @@ protected: | |
RenderEngine(); | |
virtual ~RenderEngine() = 0; | |
+ void logEGLInfo(); | |
+ | |
public: | |
static RenderEngine* create(EGLDisplay display, EGLConfig config); | |
+ virtual void initializeGL() = 0; | |
+ | |
// dump the extension strings. always call the base class. | |
virtual void dump(String8& result); | |
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp | |
index 3b5fa6f..4d850d3 100644 | |
--- a/services/surfaceflinger/SurfaceFlinger.cpp | |
+++ b/services/surfaceflinger/SurfaceFlinger.cpp | |
@@ -416,7 +416,11 @@ status_t SurfaceFlinger::selectEGLConfig(EGLDisplay display, EGLint nativeVisual | |
if (renderableType) { | |
attribs[EGL_RENDERABLE_TYPE] = renderableType; | |
attribs[EGL_RECORDABLE_ANDROID] = EGL_TRUE; | |
+#ifdef TARGET_DISABLE_SURFACEFLINGER_PBUFFERS | |
+ attribs[EGL_SURFACE_TYPE] = EGL_WINDOW_BIT; | |
+#else | |
attribs[EGL_SURFACE_TYPE] = EGL_WINDOW_BIT|EGL_PBUFFER_BIT; | |
+#endif | |
attribs[EGL_FRAMEBUFFER_TARGET_ANDROID] = EGL_TRUE; | |
attribs[EGL_RED_SIZE] = 8; | |
attribs[EGL_GREEN_SIZE] = 8; | |
@@ -639,6 +643,7 @@ void SurfaceFlinger::init() { | |
// make the GLContext current so that we can create textures when creating Layers | |
// (which may happens before we render something) | |
getDefaultDisplayDevice()->makeCurrent(mEGLDisplay, mEGLContext); | |
+ mRenderEngine->initializeGL(); | |
// start the EventThread | |
sp<VSyncSource> vsyncSrc = new DispSyncSource(&mPrimaryDispSync, | |
-- | |
1.7.10.4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment