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
This commit is contained in:
Andy McFadden 2014-03-05 15:06:53 -08:00
parent c0c6a0cd4c
commit 6ef57d7b36
37 changed files with 261 additions and 73 deletions

View File

@ -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

View File

@ -52,8 +52,8 @@
#include <EGL/egl.h>
#include <GLES/gl.h>
#include <ui/FramebufferNativeWindow.h>
#include "EGLUtils.h"
#include <EGLUtils.h>
#include <WindowSurface.h>
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;

View File

@ -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)

View File

@ -25,8 +25,8 @@
#include <GLES/glext.h>
#include <utils/StopWatch.h>
#include <ui/FramebufferNativeWindow.h>
#include "EGLUtils.h"
#include <WindowSurface.h>
#include <EGLUtils.h>
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);

View File

@ -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)

View File

@ -5,8 +5,8 @@
#include <GLES/gl.h>
#include <GLES/glext.h>
#include <ui/FramebufferNativeWindow.h>
#include "EGLUtils.h"
#include <WindowSurface.h>
#include <EGLUtils.h>
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;
}

View File

@ -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)

View File

@ -26,8 +26,8 @@
#include <utils/Timers.h>
#include <ui/FramebufferNativeWindow.h>
#include "EGLUtils.h"
#include <WindowSurface.h>
#include <EGLUtils.h>
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);

View File

@ -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)

View File

@ -26,8 +26,8 @@
#include <utils/Timers.h>
#include <ui/FramebufferNativeWindow.h>
#include "EGLUtils.h"
#include <WindowSurface.h>
#include <EGLUtils.h>
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);

View File

@ -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)

View File

@ -26,8 +26,8 @@
#include <utils/Timers.h>
#include <ui/FramebufferNativeWindow.h>
#include "EGLUtils.h"
#include <WindowSurface.h>
#include <EGLUtils.h>
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) {

View File

@ -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)

View File

@ -27,9 +27,9 @@
#include <utils/Timers.h>
#include <ui/FramebufferNativeWindow.h>
#include <WindowSurface.h>
#include <ui/GraphicBuffer.h>
#include "EGLUtils.h"
#include <EGLUtils.h>
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);

View File

@ -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)

View File

@ -5,8 +5,8 @@
#include <GLES/gl.h>
#include <GLES/glext.h>
#include <ui/FramebufferNativeWindow.h>
#include "EGLUtils.h"
#include <WindowSurface.h>
#include <EGLUtils.h>
#include <stdio.h>
@ -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,

View File

@ -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)

View File

@ -26,8 +26,8 @@
#include <utils/Timers.h>
#include <ui/FramebufferNativeWindow.h>
#include "EGLUtils.h"
#include <WindowSurface.h>
#include <EGLUtils.h>
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);

View File

@ -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)

View File

@ -27,9 +27,9 @@
#include <utils/Timers.h>
#include <ui/FramebufferNativeWindow.h>
#include <WindowSurface.h>
#include <ui/GraphicBuffer.h>
#include "EGLUtils.h"
#include <EGLUtils.h>
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);

View File

@ -85,7 +85,6 @@
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <ui/FramebufferNativeWindow.h>
#include <ui/GraphicBuffer.h>
#define LOG_TAG "hwcColorEquivTest"

View File

@ -96,7 +96,6 @@
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <ui/FramebufferNativeWindow.h>
#include <ui/GraphicBuffer.h>
#define LOG_TAG "hwcCommitTest"

View File

@ -104,7 +104,6 @@
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <ui/FramebufferNativeWindow.h>
#include <ui/GraphicBuffer.h>
#define LOG_TAG "hwcRectsTest"

View File

@ -101,7 +101,6 @@
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <ui/FramebufferNativeWindow.h>
#include <ui/GraphicBuffer.h>
#define LOG_TAG "hwcStressTest"

View File

@ -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);

View File

@ -27,7 +27,6 @@
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <ui/FramebufferNativeWindow.h>
#include <ui/GraphicBuffer.h>
#include <utils/Log.h>

View File

@ -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 <gui/SurfaceControl.h>
#include <EGL/egl.h>
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<SurfaceControl> mSurfaceControl;
};
} // namespace android
#endif /* OPENGL_TESTS_WINDOWSURFACE_H */

View File

@ -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 \

View File

@ -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 <WindowSurface.h>
#include <gui/SurfaceComposerClient.h>
#include <gui/ISurfaceComposer.h>
#include <gui/Surface.h>
#include <ui/DisplayInfo.h>
using namespace android;
WindowSurface::WindowSurface() {
status_t err;
sp<SurfaceComposerClient> surfaceComposerClient = new SurfaceComposerClient;
err = surfaceComposerClient->initCheck();
if (err != NO_ERROR) {
fprintf(stderr, "SurfaceComposerClient::initCheck error: %#x\n", err);
return;
}
// Get main display parameters.
sp<IBinder> 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<SurfaceControl> 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<ANativeWindow> anw = mSurfaceControl->getSurface();
return (EGLNativeWindowType) anw.get();
}

View File

@ -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)

View File

@ -15,8 +15,6 @@
** limitations under the License.
*/
#define LOG_TAG "fillrate"
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
@ -26,8 +24,8 @@
#include <GLES/glext.h>
#include <utils/StopWatch.h>
#include <ui/FramebufferNativeWindow.h>
#include "EGLUtils.h"
#include <WindowSurface.h>
#include <EGLUtils.h>
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);

View File

@ -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)

View File

@ -23,8 +23,8 @@
#include <GLES/glext.h>
#include <utils/StopWatch.h>
#include <ui/FramebufferNativeWindow.h>
#include "EGLUtils.h"
#include <WindowSurface.h>
#include <EGLUtils.h>
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);

View File

@ -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)

View File

@ -22,8 +22,8 @@
#include <GLES/gl.h>
#include <GLES/glext.h>
#include <ui/FramebufferNativeWindow.h>
#include "EGLUtils.h"
#include <WindowSurface.h>
#include <EGLUtils.h>
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;
}

View File

@ -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)

View File

@ -8,8 +8,8 @@
#include <GLES/gl.h>
#include <GLES/glext.h>
#include <ui/FramebufferNativeWindow.h>
#include "EGLUtils.h"
#include <WindowSurface.h>
#include <EGLUtils.h>
#include <stdio.h>
#include <stdlib.h>
@ -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,