From 6ef57d7b368ebbac5f2b27c36a9032fee1cda8b1 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Wed, 5 Mar 2014 15:06:53 -0800 Subject: [PATCH] Restore old OpenGL tests These tests call android_createDisplaySurface() to get a FramebufferNativeWindow that is passed to EGL. This relies on the existence of the framebuffer HAL, which is not supported on many recent devices. This change adds a new "window surface" object that the tests can use to get a window from SurfaceFlinger instead. All tests except for the HWC tests now appear to do things. The HWC tests don't do anything useful, but they no longer depend on the android_createDisplaySurface() function. Bug 13323813 Change-Id: I2cbfbacb3452fb658c29e945b0c7ae7c94c1a4ba --- opengl/tests/angeles/Android.mk | 3 +- opengl/tests/angeles/app-linux.cpp | 11 +-- opengl/tests/fillrate/Android.mk | 5 +- opengl/tests/fillrate/fillrate.cpp | 7 +- opengl/tests/filter/Android.mk | 6 +- opengl/tests/filter/filter.cpp | 9 ++- opengl/tests/finish/Android.mk | 5 +- opengl/tests/finish/finish.cpp | 7 +- opengl/tests/gl2_basic/Android.mk | 6 +- opengl/tests/gl2_basic/gl2_basic.cpp | 7 +- opengl/tests/gl2_copyTexImage/Android.mk | 6 +- .../gl2_copyTexImage/gl2_copyTexImage.cpp | 7 +- opengl/tests/gl2_yuvtex/Android.mk | 6 +- opengl/tests/gl2_yuvtex/gl2_yuvtex.cpp | 7 +- opengl/tests/gl_basic/Android.mk | 6 +- opengl/tests/gl_basic/gl_basic.cpp | 13 ++-- opengl/tests/gl_perf/Android.mk | 6 +- opengl/tests/gl_perf/gl2_perf.cpp | 7 +- opengl/tests/gl_yuvtex/Android.mk | 5 +- opengl/tests/gl_yuvtex/gl_yuvtex.cpp | 7 +- opengl/tests/hwc/hwcColorEquiv.cpp | 1 - opengl/tests/hwc/hwcCommit.cpp | 1 - opengl/tests/hwc/hwcRects.cpp | 1 - opengl/tests/hwc/hwcStress.cpp | 1 - opengl/tests/hwc/hwcTestLib.cpp | 6 +- opengl/tests/hwc/hwcTestLib.h | 1 - opengl/tests/include/WindowSurface.h | 49 ++++++++++++ opengl/tests/lib/Android.mk | 2 +- opengl/tests/lib/WindowSurface.cpp | 75 +++++++++++++++++++ opengl/tests/linetex/Android.mk | 6 +- opengl/tests/linetex/linetex.cpp | 9 +-- opengl/tests/swapinterval/Android.mk | 5 +- opengl/tests/swapinterval/swapinterval.cpp | 7 +- opengl/tests/textures/Android.mk | 6 +- opengl/tests/textures/textures.cpp | 9 ++- opengl/tests/tritex/Android.mk | 6 +- opengl/tests/tritex/tritex.cpp | 13 ++-- 37 files changed, 261 insertions(+), 73 deletions(-) create mode 100644 opengl/tests/include/WindowSurface.h create mode 100644 opengl/tests/lib/WindowSurface.cpp diff --git a/opengl/tests/angeles/Android.mk b/opengl/tests/angeles/Android.mk index ae4f76d91..c78224ee1 100644 --- a/opengl/tests/angeles/Android.mk +++ b/opengl/tests/angeles/Android.mk @@ -3,7 +3,8 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES:= app-linux.cpp demo.c.arm -LOCAL_SHARED_LIBRARIES := libEGL libGLESv1_CM libui +LOCAL_SHARED_LIBRARIES := libEGL libGLESv1_CM libui libgui libutils +LOCAL_STATIC_LIBRARIES += libglTest LOCAL_C_INCLUDES += $(call include-path-for, opengl-tests-includes) LOCAL_MODULE:= angeles LOCAL_MODULE_TAGS := optional diff --git a/opengl/tests/angeles/app-linux.cpp b/opengl/tests/angeles/app-linux.cpp index 6ac68a2ae..e490351d5 100644 --- a/opengl/tests/angeles/app-linux.cpp +++ b/opengl/tests/angeles/app-linux.cpp @@ -52,8 +52,8 @@ #include #include -#include -#include "EGLUtils.h" +#include +#include using namespace android; @@ -118,7 +118,7 @@ static void checkEGLErrors() fprintf(stderr, "EGL Error: 0x%04x\n", (int)error); } -static int initGraphics(unsigned samples) +static int initGraphics(unsigned samples, const WindowSurface& windowSurface) { EGLint configAttribs[] = { EGL_DEPTH_SIZE, 16, @@ -135,7 +135,7 @@ static int initGraphics(unsigned samples) EGLint w, h; EGLDisplay dpy; - EGLNativeWindowType window = android_createDisplaySurface(); + EGLNativeWindowType window = windowSurface.getSurface(); dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); eglInitialize(dpy, &majorVersion, &minorVersion); @@ -193,7 +193,8 @@ int main(int argc, char *argv[]) printf("Multisample enabled: GL_SAMPLES = %u\n", samples); } - if (!initGraphics(samples)) + WindowSurface windowSurface; + if (!initGraphics(samples, windowSurface)) { fprintf(stderr, "Graphics initialization failed.\n"); return EXIT_FAILURE; diff --git a/opengl/tests/fillrate/Android.mk b/opengl/tests/fillrate/Android.mk index 4dade214b..21ff52a9a 100644 --- a/opengl/tests/fillrate/Android.mk +++ b/opengl/tests/fillrate/Android.mk @@ -9,7 +9,10 @@ LOCAL_SHARED_LIBRARIES := \ libutils \ libEGL \ libGLESv1_CM \ - libui + libui \ + libgui + +LOCAL_STATIC_LIBRARIES += libglTest LOCAL_C_INCLUDES += $(call include-path-for, opengl-tests-includes) diff --git a/opengl/tests/fillrate/fillrate.cpp b/opengl/tests/fillrate/fillrate.cpp index a708647a9..1d9b02612 100644 --- a/opengl/tests/fillrate/fillrate.cpp +++ b/opengl/tests/fillrate/fillrate.cpp @@ -25,8 +25,8 @@ #include #include -#include -#include "EGLUtils.h" +#include +#include using namespace android; @@ -45,7 +45,8 @@ int main(int argc, char** argv) EGLint w, h; EGLDisplay dpy; - EGLNativeWindowType window = android_createDisplaySurface(); + WindowSurface windowSurface; + EGLNativeWindowType window = windowSurface.getSurface(); dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); eglInitialize(dpy, &majorVersion, &minorVersion); diff --git a/opengl/tests/filter/Android.mk b/opengl/tests/filter/Android.mk index d3e4d3877..4cf9c962d 100644 --- a/opengl/tests/filter/Android.mk +++ b/opengl/tests/filter/Android.mk @@ -8,7 +8,11 @@ LOCAL_SHARED_LIBRARIES := \ libcutils \ libEGL \ libGLESv1_CM \ - libui + libui \ + libgui \ + libutils + +LOCAL_STATIC_LIBRARIES += libglTest LOCAL_C_INCLUDES += $(call include-path-for, opengl-tests-includes) diff --git a/opengl/tests/filter/filter.cpp b/opengl/tests/filter/filter.cpp index 006732755..289e6cc58 100644 --- a/opengl/tests/filter/filter.cpp +++ b/opengl/tests/filter/filter.cpp @@ -5,8 +5,8 @@ #include #include -#include -#include "EGLUtils.h" +#include +#include using namespace android; @@ -40,8 +40,10 @@ int main(int argc, char** argv) EGLDisplay dpy; EGLNativeWindowType window = 0; + WindowSurface* windowSurface = NULL; if (!usePbuffer) { - window = android_createDisplaySurface(); + windowSurface = new WindowSurface(); + window = windowSurface->getSurface(); } dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); @@ -186,5 +188,6 @@ int main(int argc, char** argv) } eglTerminate(dpy); + delete windowSurface; return 0; } diff --git a/opengl/tests/finish/Android.mk b/opengl/tests/finish/Android.mk index aa8adca79..0b9b7ea25 100644 --- a/opengl/tests/finish/Android.mk +++ b/opengl/tests/finish/Android.mk @@ -9,7 +9,10 @@ LOCAL_SHARED_LIBRARIES := \ libutils \ libEGL \ libGLESv1_CM \ - libui + libui \ + libgui + +LOCAL_STATIC_LIBRARIES += libglTest LOCAL_C_INCLUDES += $(call include-path-for, opengl-tests-includes) diff --git a/opengl/tests/finish/finish.cpp b/opengl/tests/finish/finish.cpp index 11f0c22c3..ea3a60f51 100644 --- a/opengl/tests/finish/finish.cpp +++ b/opengl/tests/finish/finish.cpp @@ -26,8 +26,8 @@ #include -#include -#include "EGLUtils.h" +#include +#include using namespace android; @@ -46,7 +46,8 @@ int main(int argc, char** argv) EGLint w, h; EGLDisplay dpy; - EGLNativeWindowType window = android_createDisplaySurface(); + WindowSurface windowSurface; + EGLNativeWindowType window = windowSurface.getSurface(); dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); eglInitialize(dpy, &majorVersion, &minorVersion); diff --git a/opengl/tests/gl2_basic/Android.mk b/opengl/tests/gl2_basic/Android.mk index d7819a147..520395c04 100644 --- a/opengl/tests/gl2_basic/Android.mk +++ b/opengl/tests/gl2_basic/Android.mk @@ -8,7 +8,11 @@ LOCAL_SHARED_LIBRARIES := \ libcutils \ libEGL \ libGLESv2 \ - libui + libui \ + libgui \ + libutils + +LOCAL_STATIC_LIBRARIES += libglTest LOCAL_C_INCLUDES += $(call include-path-for, opengl-tests-includes) diff --git a/opengl/tests/gl2_basic/gl2_basic.cpp b/opengl/tests/gl2_basic/gl2_basic.cpp index 7007871da..cdbf1cfca 100644 --- a/opengl/tests/gl2_basic/gl2_basic.cpp +++ b/opengl/tests/gl2_basic/gl2_basic.cpp @@ -26,8 +26,8 @@ #include -#include -#include "EGLUtils.h" +#include +#include using namespace android; @@ -298,7 +298,8 @@ int main(int argc, char** argv) { checkEglError("printEGLConfigurations"); - EGLNativeWindowType window = android_createDisplaySurface(); + WindowSurface windowSurface; + EGLNativeWindowType window = windowSurface.getSurface(); returnValue = EGLUtils::selectConfigForNativeWindow(dpy, s_configAttribs, window, &myConfig); if (returnValue) { printf("EGLUtils::selectConfigForNativeWindow() returned %d", returnValue); diff --git a/opengl/tests/gl2_copyTexImage/Android.mk b/opengl/tests/gl2_copyTexImage/Android.mk index 005c38307..ff43558d3 100644 --- a/opengl/tests/gl2_copyTexImage/Android.mk +++ b/opengl/tests/gl2_copyTexImage/Android.mk @@ -8,7 +8,11 @@ LOCAL_SHARED_LIBRARIES := \ libcutils \ libEGL \ libGLESv2 \ - libui + libui \ + libgui \ + libutils + +LOCAL_STATIC_LIBRARIES += libglTest LOCAL_C_INCLUDES += $(call include-path-for, opengl-tests-includes) diff --git a/opengl/tests/gl2_copyTexImage/gl2_copyTexImage.cpp b/opengl/tests/gl2_copyTexImage/gl2_copyTexImage.cpp index 988d7ac0f..405a3f029 100644 --- a/opengl/tests/gl2_copyTexImage/gl2_copyTexImage.cpp +++ b/opengl/tests/gl2_copyTexImage/gl2_copyTexImage.cpp @@ -26,8 +26,8 @@ #include -#include -#include "EGLUtils.h" +#include +#include using namespace android; @@ -406,7 +406,8 @@ int main(int argc, char** argv) { checkEglError("printEGLConfigurations"); - EGLNativeWindowType window = android_createDisplaySurface(); + WindowSurface windowSurface; + EGLNativeWindowType window = windowSurface.getSurface(); EGLint numConfigs = -1, n = 0; eglChooseConfig(dpy, s_configAttribs, 0, 0, &numConfigs); if (numConfigs) { diff --git a/opengl/tests/gl2_yuvtex/Android.mk b/opengl/tests/gl2_yuvtex/Android.mk index bb3cc0ce7..42cf771f1 100644 --- a/opengl/tests/gl2_yuvtex/Android.mk +++ b/opengl/tests/gl2_yuvtex/Android.mk @@ -9,7 +9,11 @@ LOCAL_SHARED_LIBRARIES := \ libEGL \ libGLESv2 \ libutils \ - libui + libui \ + libgui \ + libutils + +LOCAL_STATIC_LIBRARIES += libglTest LOCAL_C_INCLUDES += $(call include-path-for, opengl-tests-includes) diff --git a/opengl/tests/gl2_yuvtex/gl2_yuvtex.cpp b/opengl/tests/gl2_yuvtex/gl2_yuvtex.cpp index d3e493263..98d8aa8cb 100644 --- a/opengl/tests/gl2_yuvtex/gl2_yuvtex.cpp +++ b/opengl/tests/gl2_yuvtex/gl2_yuvtex.cpp @@ -27,9 +27,9 @@ #include -#include +#include #include -#include "EGLUtils.h" +#include using namespace android; @@ -364,7 +364,8 @@ int main(int argc, char** argv) { return 0; } - EGLNativeWindowType window = android_createDisplaySurface(); + WindowSurface windowSurface; + EGLNativeWindowType window = windowSurface.getSurface(); returnValue = EGLUtils::selectConfigForNativeWindow(dpy, s_configAttribs, window, &myConfig); if (returnValue) { printf("EGLUtils::selectConfigForNativeWindow() returned %d", returnValue); diff --git a/opengl/tests/gl_basic/Android.mk b/opengl/tests/gl_basic/Android.mk index 46bcc605b..7f2259e8e 100644 --- a/opengl/tests/gl_basic/Android.mk +++ b/opengl/tests/gl_basic/Android.mk @@ -8,7 +8,11 @@ LOCAL_SHARED_LIBRARIES := \ libcutils \ libEGL \ libGLESv1_CM \ - libui + libui \ + libgui \ + libutils + +LOCAL_STATIC_LIBRARIES += libglTest LOCAL_C_INCLUDES += $(call include-path-for, opengl-tests-includes) diff --git a/opengl/tests/gl_basic/gl_basic.cpp b/opengl/tests/gl_basic/gl_basic.cpp index 23ce93480..e50d88fab 100644 --- a/opengl/tests/gl_basic/gl_basic.cpp +++ b/opengl/tests/gl_basic/gl_basic.cpp @@ -5,8 +5,8 @@ #include #include -#include -#include "EGLUtils.h" +#include +#include #include @@ -23,7 +23,7 @@ GLuint texture; #define FIXED_ONE 0x10000 #define ITERATIONS 50 -int init_gl_surface(void); +int init_gl_surface(const WindowSurface& windowSurface); void free_gl_surface(void); void init_scene(void); void render(); @@ -194,7 +194,8 @@ int main(int argc, char **argv) int q; int start, end; printf("Initializing EGL...\n"); - if(!init_gl_surface()) + WindowSurface windowSurface; + if(!init_gl_surface(windowSurface)) { printf("GL initialisation failed - exiting\n"); return 0; @@ -209,7 +210,7 @@ int main(int argc, char **argv) return 0; } -int init_gl_surface(void) +int init_gl_surface(const WindowSurface& windowSurface) { EGLint numConfigs = 1; EGLConfig myConfig = {0}; @@ -236,7 +237,7 @@ int init_gl_surface(void) return 0; } - EGLNativeWindowType window = android_createDisplaySurface(); + EGLNativeWindowType window = windowSurface.getSurface(); EGLUtils::selectConfigForNativeWindow(eglDisplay, attrib, window, &myConfig); if ( (eglSurface = eglCreateWindowSurface(eglDisplay, myConfig, diff --git a/opengl/tests/gl_perf/Android.mk b/opengl/tests/gl_perf/Android.mk index b0f825c10..9a93fab9d 100644 --- a/opengl/tests/gl_perf/Android.mk +++ b/opengl/tests/gl_perf/Android.mk @@ -10,7 +10,11 @@ LOCAL_SHARED_LIBRARIES := \ liblog \ libEGL \ libGLESv2 \ - libui + libui \ + libgui \ + libutils + +LOCAL_STATIC_LIBRARIES += libglTest LOCAL_C_INCLUDES += $(call include-path-for, opengl-tests-includes) diff --git a/opengl/tests/gl_perf/gl2_perf.cpp b/opengl/tests/gl_perf/gl2_perf.cpp index 224acafa7..35df84fc0 100644 --- a/opengl/tests/gl_perf/gl2_perf.cpp +++ b/opengl/tests/gl_perf/gl2_perf.cpp @@ -26,8 +26,8 @@ #include -#include -#include "EGLUtils.h" +#include +#include using namespace android; @@ -86,7 +86,8 @@ int main(int argc, char** argv) { return 0; } - EGLNativeWindowType window = android_createDisplaySurface(); + WindowSurface windowSurface; + EGLNativeWindowType window = windowSurface.getSurface(); returnValue = EGLUtils::selectConfigForNativeWindow(dpy, s_configAttribs, window, &myConfig); if (returnValue) { printf("EGLUtils::selectConfigForNativeWindow() returned %d", returnValue); diff --git a/opengl/tests/gl_yuvtex/Android.mk b/opengl/tests/gl_yuvtex/Android.mk index e0e2c168b..7f2020ab6 100644 --- a/opengl/tests/gl_yuvtex/Android.mk +++ b/opengl/tests/gl_yuvtex/Android.mk @@ -9,7 +9,10 @@ LOCAL_SHARED_LIBRARIES := \ libEGL \ libGLESv1_CM \ libutils \ - libui + libui \ + libgui + +LOCAL_STATIC_LIBRARIES += libglTest LOCAL_C_INCLUDES += $(call include-path-for, opengl-tests-includes) diff --git a/opengl/tests/gl_yuvtex/gl_yuvtex.cpp b/opengl/tests/gl_yuvtex/gl_yuvtex.cpp index 7a00f76f8..c923b0736 100644 --- a/opengl/tests/gl_yuvtex/gl_yuvtex.cpp +++ b/opengl/tests/gl_yuvtex/gl_yuvtex.cpp @@ -27,9 +27,9 @@ #include -#include +#include #include -#include "EGLUtils.h" +#include using namespace android; @@ -254,7 +254,8 @@ int main(int argc, char** argv) { return 0; } - EGLNativeWindowType window = android_createDisplaySurface(); + WindowSurface windowSurface; + EGLNativeWindowType window = windowSurface.getSurface(); returnValue = EGLUtils::selectConfigForNativeWindow(dpy, s_configAttribs, window, &myConfig); if (returnValue) { printf("EGLUtils::selectConfigForNativeWindow() returned %d", returnValue); diff --git a/opengl/tests/hwc/hwcColorEquiv.cpp b/opengl/tests/hwc/hwcColorEquiv.cpp index 160906ddb..c4624d2d3 100644 --- a/opengl/tests/hwc/hwcColorEquiv.cpp +++ b/opengl/tests/hwc/hwcColorEquiv.cpp @@ -85,7 +85,6 @@ #include #include -#include #include #define LOG_TAG "hwcColorEquivTest" diff --git a/opengl/tests/hwc/hwcCommit.cpp b/opengl/tests/hwc/hwcCommit.cpp index 3681fbbe9..1bd5fdf3a 100644 --- a/opengl/tests/hwc/hwcCommit.cpp +++ b/opengl/tests/hwc/hwcCommit.cpp @@ -96,7 +96,6 @@ #include #include -#include #include #define LOG_TAG "hwcCommitTest" diff --git a/opengl/tests/hwc/hwcRects.cpp b/opengl/tests/hwc/hwcRects.cpp index ec0403f6e..9b5762392 100644 --- a/opengl/tests/hwc/hwcRects.cpp +++ b/opengl/tests/hwc/hwcRects.cpp @@ -104,7 +104,6 @@ #include #include -#include #include #define LOG_TAG "hwcRectsTest" diff --git a/opengl/tests/hwc/hwcStress.cpp b/opengl/tests/hwc/hwcStress.cpp index dfaa6c120..b1d6c764f 100644 --- a/opengl/tests/hwc/hwcStress.cpp +++ b/opengl/tests/hwc/hwcStress.cpp @@ -101,7 +101,6 @@ #include #include -#include #include #define LOG_TAG "hwcStressTest" diff --git a/opengl/tests/hwc/hwcTestLib.cpp b/opengl/tests/hwc/hwcTestLib.cpp index 9b224e2e2..7fae5e598 100644 --- a/opengl/tests/hwc/hwcTestLib.cpp +++ b/opengl/tests/hwc/hwcTestLib.cpp @@ -80,7 +80,11 @@ void hwcTestInitDisplay(bool verbose, EGLDisplay *dpy, EGLSurface *surface, exit(71); } - EGLNativeWindowType window = android_createDisplaySurface(); + // The tests want to stop the framework and play with the hardware + // composer, which means it doesn't make sense to use WindowSurface + // here. android_createDisplaySurface() is going away, so just + // politely fail here. + EGLNativeWindowType window = NULL; //android_createDisplaySurface(); if (window == NULL) { testPrintE("android_createDisplaySurface failed"); exit(72); diff --git a/opengl/tests/hwc/hwcTestLib.h b/opengl/tests/hwc/hwcTestLib.h index d403308a6..a942c10e3 100644 --- a/opengl/tests/hwc/hwcTestLib.h +++ b/opengl/tests/hwc/hwcTestLib.h @@ -27,7 +27,6 @@ #include #include -#include #include #include diff --git a/opengl/tests/include/WindowSurface.h b/opengl/tests/include/WindowSurface.h new file mode 100644 index 000000000..0ec140455 --- /dev/null +++ b/opengl/tests/include/WindowSurface.h @@ -0,0 +1,49 @@ +/* + * Copyright 2014 The Android Open Source Project + * + * 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. + */ + +#ifndef OPENGL_TESTS_WINDOWSURFACE_H +#define OPENGL_TESTS_WINDOWSURFACE_H + +#include + +#include + +namespace android { + +/* + * A window that covers the entire display surface. + * + * The window is destroyed when this object is destroyed, so don't try + * to use the surface after that point. + */ +class WindowSurface { +public: + // Creates the window. + WindowSurface(); + + // Retrieves a handle to the window. + EGLNativeWindowType getSurface() const; + +private: + WindowSurface(const WindowSurface&); + WindowSurface& operator=(const WindowSurface&); + + sp mSurfaceControl; +}; + +} // namespace android + +#endif /* OPENGL_TESTS_WINDOWSURFACE_H */ diff --git a/opengl/tests/lib/Android.mk b/opengl/tests/lib/Android.mk index 0352a370a..a2752cd9f 100644 --- a/opengl/tests/lib/Android.mk +++ b/opengl/tests/lib/Android.mk @@ -17,7 +17,7 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE_TAGS := tests LOCAL_MODULE:= libglTest -LOCAL_SRC_FILES:= glTestLib.cpp +LOCAL_SRC_FILES:= glTestLib.cpp WindowSurface.cpp LOCAL_C_INCLUDES += system/extras/tests/include \ bionic \ bionic/libstdc++/include \ diff --git a/opengl/tests/lib/WindowSurface.cpp b/opengl/tests/lib/WindowSurface.cpp new file mode 100644 index 000000000..7b57dfd54 --- /dev/null +++ b/opengl/tests/lib/WindowSurface.cpp @@ -0,0 +1,75 @@ +/* + * Copyright 2014 The Android Open Source Project + * + * 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. + */ + +#include + +#include +#include +#include +#include + +using namespace android; + +WindowSurface::WindowSurface() { + status_t err; + + sp surfaceComposerClient = new SurfaceComposerClient; + err = surfaceComposerClient->initCheck(); + if (err != NO_ERROR) { + fprintf(stderr, "SurfaceComposerClient::initCheck error: %#x\n", err); + return; + } + + // Get main display parameters. + sp mainDpy = SurfaceComposerClient::getBuiltInDisplay( + ISurfaceComposer::eDisplayIdMain); + DisplayInfo mainDpyInfo; + err = SurfaceComposerClient::getDisplayInfo(mainDpy, &mainDpyInfo); + if (err != NO_ERROR) { + fprintf(stderr, "ERROR: unable to get display characteristics\n"); + return; + } + + sp sc = surfaceComposerClient->createSurface( + String8("Benchmark"), mainDpyInfo.w, mainDpyInfo.h, + PIXEL_FORMAT_RGBA_8888, ISurfaceComposerClient::eOpaque); + if (sc == NULL || !sc->isValid()) { + fprintf(stderr, "Failed to create SurfaceControl\n"); + return; + } + + SurfaceComposerClient::openGlobalTransaction(); + err = sc->setLayer(0x7FFFFFFF); // always on top + if (err != NO_ERROR) { + fprintf(stderr, "SurfaceComposer::setLayer error: %#x\n", err); + return; + } + + err = sc->show(); + if (err != NO_ERROR) { + fprintf(stderr, "SurfaceComposer::show error: %#x\n", err); + return; + } + SurfaceComposerClient::closeGlobalTransaction(); + + mSurfaceControl = sc; +} + +EGLNativeWindowType WindowSurface::getSurface() const { + sp anw = mSurfaceControl->getSurface(); + return (EGLNativeWindowType) anw.get(); +} + diff --git a/opengl/tests/linetex/Android.mk b/opengl/tests/linetex/Android.mk index 5b6384e4d..968756a73 100644 --- a/opengl/tests/linetex/Android.mk +++ b/opengl/tests/linetex/Android.mk @@ -8,7 +8,11 @@ LOCAL_SHARED_LIBRARIES := \ libcutils \ libEGL \ libGLESv1_CM \ - libui + libui \ + libgui \ + libutils + +LOCAL_STATIC_LIBRARIES += libglTest LOCAL_C_INCLUDES += $(call include-path-for, opengl-tests-includes) diff --git a/opengl/tests/linetex/linetex.cpp b/opengl/tests/linetex/linetex.cpp index 86694921c..7921f8096 100644 --- a/opengl/tests/linetex/linetex.cpp +++ b/opengl/tests/linetex/linetex.cpp @@ -15,8 +15,6 @@ ** limitations under the License. */ -#define LOG_TAG "fillrate" - #include #include #include @@ -26,8 +24,8 @@ #include #include -#include -#include "EGLUtils.h" +#include +#include using namespace android; @@ -46,7 +44,8 @@ int main(int argc, char** argv) EGLint w, h; EGLDisplay dpy; - EGLNativeWindowType window = android_createDisplaySurface(); + WindowSurface windowSurface; + EGLNativeWindowType window = windowSurface.getSurface(); dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); eglInitialize(dpy, &majorVersion, &minorVersion); diff --git a/opengl/tests/swapinterval/Android.mk b/opengl/tests/swapinterval/Android.mk index 5517f602e..b0b15ebec 100644 --- a/opengl/tests/swapinterval/Android.mk +++ b/opengl/tests/swapinterval/Android.mk @@ -9,7 +9,10 @@ LOCAL_SHARED_LIBRARIES := \ libutils \ libEGL \ libGLESv1_CM \ - libui + libui \ + libgui + +LOCAL_STATIC_LIBRARIES += libglTest LOCAL_C_INCLUDES += $(call include-path-for, opengl-tests-includes) diff --git a/opengl/tests/swapinterval/swapinterval.cpp b/opengl/tests/swapinterval/swapinterval.cpp index a0f4bc466..3a8a8a184 100644 --- a/opengl/tests/swapinterval/swapinterval.cpp +++ b/opengl/tests/swapinterval/swapinterval.cpp @@ -23,8 +23,8 @@ #include #include -#include -#include "EGLUtils.h" +#include +#include using namespace android; @@ -45,7 +45,8 @@ int main(int argc, char** argv) EGLDisplay dpy; - EGLNativeWindowType window = android_createDisplaySurface(); + WindowSurface windowSurface; + EGLNativeWindowType window = windowSurface.getSurface(); dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); eglInitialize(dpy, &majorVersion, &minorVersion); diff --git a/opengl/tests/textures/Android.mk b/opengl/tests/textures/Android.mk index 97697d72a..bee61f94e 100644 --- a/opengl/tests/textures/Android.mk +++ b/opengl/tests/textures/Android.mk @@ -8,7 +8,11 @@ LOCAL_SHARED_LIBRARIES := \ libcutils \ libEGL \ libGLESv1_CM \ - libui + libui \ + libgui \ + libutils + +LOCAL_STATIC_LIBRARIES += libglTest LOCAL_C_INCLUDES += $(call include-path-for, opengl-tests-includes) diff --git a/opengl/tests/textures/textures.cpp b/opengl/tests/textures/textures.cpp index 5d3d94e7d..1e55db0e0 100644 --- a/opengl/tests/textures/textures.cpp +++ b/opengl/tests/textures/textures.cpp @@ -22,8 +22,8 @@ #include #include -#include -#include "EGLUtils.h" +#include +#include using namespace android; @@ -42,7 +42,8 @@ int main(int argc, char** argv) EGLint w, h; EGLDisplay dpy; - EGLNativeWindowType window = android_createDisplaySurface(); + WindowSurface windowSurface; + EGLNativeWindowType window = windowSurface.getSurface(); dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); eglInitialize(dpy, &majorVersion, &minorVersion); @@ -114,5 +115,7 @@ int main(int argc, char** argv) glDrawTexiOES(dim/2, dim/2, 0, dim/2, dim/2); eglSwapBuffers(dpy, surface); + + sleep(2); // so you have a chance to admire it return 0; } diff --git a/opengl/tests/tritex/Android.mk b/opengl/tests/tritex/Android.mk index 89faa878b..64382edd3 100644 --- a/opengl/tests/tritex/Android.mk +++ b/opengl/tests/tritex/Android.mk @@ -8,7 +8,11 @@ LOCAL_SHARED_LIBRARIES := \ libcutils \ libEGL \ libGLESv1_CM \ - libui + libui \ + libgui \ + libutils + +LOCAL_STATIC_LIBRARIES += libglTest LOCAL_C_INCLUDES += $(call include-path-for, opengl-tests-includes) diff --git a/opengl/tests/tritex/tritex.cpp b/opengl/tests/tritex/tritex.cpp index f18348367..2db73ef13 100644 --- a/opengl/tests/tritex/tritex.cpp +++ b/opengl/tests/tritex/tritex.cpp @@ -8,8 +8,8 @@ #include #include -#include -#include "EGLUtils.h" +#include +#include #include #include @@ -25,7 +25,7 @@ GLuint texture; #define FIXED_ONE 0x10000 #define ITERATIONS 50 -int init_gl_surface(void); +int init_gl_surface(const WindowSurface&); void free_gl_surface(void); void init_scene(void); void render(int quads); @@ -98,7 +98,8 @@ int main(int argc, char **argv) printf("Initializing EGL...\n"); - if(!init_gl_surface()) + WindowSurface windowSurface; + if(!init_gl_surface(windowSurface)) { printf("GL initialisation failed - exiting\n"); return 0; @@ -117,7 +118,7 @@ int main(int argc, char **argv) return 0; } -int init_gl_surface(void) +int init_gl_surface(const WindowSurface& windowSurface) { EGLint numConfigs = 1; EGLConfig myConfig = {0}; @@ -140,7 +141,7 @@ int init_gl_surface(void) return 0; } - EGLNativeWindowType window = android_createDisplaySurface(); + EGLNativeWindowType window = windowSurface.getSurface(); EGLUtils::selectConfigForNativeWindow(eglDisplay, attrib, window, &myConfig); if ( (eglSurface = eglCreateWindowSurface(eglDisplay, myConfig,