From 523df13207814f376bec03ced04571b97aae86f4 Mon Sep 17 00:00:00 2001 From: Austin Yuan Date: Thu, 7 Mar 2013 10:52:11 +0800 Subject: [PATCH] vaPutSurface test on Android: fix build isste on Android JB Change-Id: Ibfb3d6a653f9af924422edb052e751b84015ffd0 Signed-off-by: Austin Yuan --- test/android_winsys.cpp | 59 ----------------------- test/basic/Android.mk | 22 ++++----- test/common/va_display_android.cpp | 57 ++++++++++++++--------- test/decode/Android.mk | 2 +- test/putsurface/putsurface_android.cpp | 85 ++++++++++++++++++++++------------ 5 files changed, 102 insertions(+), 123 deletions(-) delete mode 100644 test/android_winsys.cpp diff --git a/test/android_winsys.cpp b/test/android_winsys.cpp deleted file mode 100644 index 21df279..0000000 --- a/test/android_winsys.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2012 Intel Corporation. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -#include - -namespace android { -}; - -#define min(a,b) (a dtoken(SurfaceComposerClient::getBuiltInDisplay( \ - ISurfaceComposer::eDisplayIdMain)); \ - client->getDisplayInfo(dtoken, &info); \ - /*w = min(win_width, info.w);*/ \ - /*h = min(win_height, info.h);*/ \ - w = win_width, h = win_height; \ - \ - surface_ctrl = client->createSurface(String8("libVA"), w, h, PIXEL_FORMAT_RGB_888); \ - android_surface = surface_ctrl->getSurface(); \ - \ - SurfaceComposerClient::openGlobalTransaction(); \ - surface_ctrl->setLayer(0x7FFFFFFF); \ - surface_ctrl->show(); \ - SurfaceComposerClient::closeGlobalTransaction(); \ - \ - SurfaceComposerClient::openGlobalTransaction(); \ - surface_ctrl->setPosition(0, 0); \ - SurfaceComposerClient::closeGlobalTransaction(); \ - \ - SurfaceComposerClient::openGlobalTransaction(); \ - surface_ctrl->setSize(w, h); \ - SurfaceComposerClient::closeGlobalTransaction(); \ -} while (0) - - diff --git a/test/basic/Android.mk b/test/basic/Android.mk index 708d98f..2b4255c 100755 --- a/test/basic/Android.mk +++ b/test/basic/Android.mk @@ -18,7 +18,7 @@ LOCAL_C_INCLUDES += \ LOCAL_MODULE_TAGS := optional LOCAL_MODULE := test_001 -LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client +LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger include $(BUILD_EXECUTABLE) @@ -39,7 +39,7 @@ LOCAL_C_INCLUDES += \ LOCAL_MODULE_TAGS := optional LOCAL_MODULE := test_02_android -LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client +LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger include $(BUILD_EXECUTABLE) @@ -60,7 +60,7 @@ LOCAL_C_INCLUDES += \ LOCAL_MODULE_TAGS := optional LOCAL_MODULE := test_03_android -LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client +LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger include $(BUILD_EXECUTABLE) @@ -81,7 +81,7 @@ LOCAL_C_INCLUDES += \ LOCAL_MODULE_TAGS := optional LOCAL_MODULE := test_04_android -LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client +LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger include $(BUILD_EXECUTABLE) @@ -102,7 +102,7 @@ LOCAL_C_INCLUDES += \ LOCAL_MODULE_TAGS := optional LOCAL_MODULE := test_05_android -LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client +LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger include $(BUILD_EXECUTABLE) @@ -123,7 +123,7 @@ LOCAL_C_INCLUDES += \ LOCAL_MODULE_TAGS := optional LOCAL_MODULE := test_06_android -LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client +LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger include $(BUILD_EXECUTABLE) @@ -144,7 +144,7 @@ LOCAL_C_INCLUDES += \ LOCAL_MODULE_TAGS := optional LOCAL_MODULE := test_07_android -LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client +LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger include $(BUILD_EXECUTABLE) @@ -165,7 +165,7 @@ LOCAL_C_INCLUDES += \ LOCAL_MODULE_TAGS := optional LOCAL_MODULE := test_08_android -LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client +LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger include $(BUILD_EXECUTABLE) @@ -186,7 +186,7 @@ LOCAL_C_INCLUDES += \ LOCAL_MODULE_TAGS := optional LOCAL_MODULE := test_09_android -LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client +LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger include $(BUILD_EXECUTABLE) @@ -207,7 +207,7 @@ LOCAL_C_INCLUDES += \ LOCAL_MODULE_TAGS := optional LOCAL_MODULE := test_10_android -LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client +LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger include $(BUILD_EXECUTABLE) @@ -228,7 +228,7 @@ LOCAL_C_INCLUDES += \ LOCAL_MODULE_TAGS := optional LOCAL_MODULE := test_11_android -LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client +LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger include $(BUILD_EXECUTABLE) diff --git a/test/common/va_display_android.cpp b/test/common/va_display_android.cpp index 82c05a3..b05a47a 100644 --- a/test/common/va_display_android.cpp +++ b/test/common/va_display_android.cpp @@ -25,26 +25,17 @@ #include #include "va_display.h" -#include -#include -#include -#include #include #include #include -#include -#include -#include static unsigned int fake_display = 0xdeada01d; using namespace android; -sp client; -sp android_surface; -sp android_isurface; -sp surface_ctrl; -#include "../android_winsys.cpp" +static sp client = NULL; +static sp surface_ctr = NULL; +static sp anw = NULL; static VADisplay va_open_display_android(void) @@ -57,6 +48,34 @@ va_close_display_android(VADisplay va_dpy) { } +static int create_window(int x, int y, int width, int height) +{ + client = new SurfaceComposerClient(); + + surface_ctr = client->createSurface( + String8("Test Surface"), + width, height, + PIXEL_FORMAT_RGB_888, 0); + + SurfaceComposerClient::openGlobalTransaction(); + surface_ctr->setLayer(0x7FFFFFFF); + surface_ctr->show(); + SurfaceComposerClient::closeGlobalTransaction(); + + SurfaceComposerClient::openGlobalTransaction(); + surface_ctr->setPosition(x, y); + SurfaceComposerClient::closeGlobalTransaction(); + + SurfaceComposerClient::openGlobalTransaction(); + surface_ctr->setSize(width, height); + SurfaceComposerClient::closeGlobalTransaction(); + + anw = surface_ctr->getSurface(); + + return 0; +} + + static VAStatus va_put_surface_android( VADisplay va_dpy, @@ -65,18 +84,10 @@ va_put_surface_android( const VARectangle *dst_rect ) { - //sp proc(ProcessState::self()); - //ProcessState::self()->startThreadPool(); - - printf("Create window0 for thread0\n"); - SURFACE_CREATE( - client, - surface_ctrl, - android_surface, - android_isurface, - dst_rect->x, dst_rect->y, dst_rect->width, dst_rect->height); + if (anw == NULL) + create_window(dst_rect->x, dst_rect->y, dst_rect->width, dst_rect->height); - return vaPutSurface(va_dpy, surface, android_isurface, + return vaPutSurface(va_dpy, surface, anw, src_rect->x, src_rect->y, src_rect->width, src_rect->height, dst_rect->x, dst_rect->y, diff --git a/test/decode/Android.mk b/test/decode/Android.mk index d1053b7..52f7bfd 100755 --- a/test/decode/Android.mk +++ b/test/decode/Android.mk @@ -21,7 +21,7 @@ LOCAL_C_INCLUDES += \ LOCAL_MODULE_TAGS := optional LOCAL_MODULE := mpeg2vldemo -LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libgui +LOCAL_SHARED_LIBRARIES := libva libva-android libdl libdrm libcutils libutils libgui include $(BUILD_EXECUTABLE) diff --git a/test/putsurface/putsurface_android.cpp b/test/putsurface/putsurface_android.cpp index 8b70480..b4e0a92 100644 --- a/test/putsurface/putsurface_android.cpp +++ b/test/putsurface/putsurface_android.cpp @@ -24,39 +24,30 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include #include #include -static int android_display=0; - using namespace android; -#include "../android_winsys.cpp" -sp client; -sp android_surface; -sp android_isurface; -sp surface_ctrl; +static int android_display=0; + +static sp client0 = NULL; +static sp surface_ctrl0 = NULL; +static sp anw0 = NULL; -sp client1; -sp android_surface1; -sp android_isurface1; -sp surface_ctrl1; +static sp client1 = NULL; +static sp surface_ctrl1 = NULL; +static sp anw1 = NULL; static void *open_display(void); static void close_display(void *win_display); static int create_window(void *win_display, int x, int y, int width, int height); static int check_window_event(void *x11_display, void *win, int *width, int *height, int *quit); -#define CAST_DRAWABLE(a) static_cast((void *)(*(unsigned int *)a)) +#define CAST_DRAWABLE(a) static_cast((void *)(*(unsigned int *)a)) #include "putsurface_common.c" static void *open_display() @@ -71,20 +62,56 @@ static void close_display(void *win_display) static int create_window(void *win_display, int x, int y, int width, int height) { - sp proc(ProcessState::self()); - ProcessState::self()->startThreadPool(); + client0 = new SurfaceComposerClient(); + + surface_ctrl0 = client1->createSurface( + String8("Test Surface"), + width, height, + PIXEL_FORMAT_RGB_888, 0); - printf("Create window0 for thread0\n"); - SURFACE_CREATE(client,surface_ctrl,android_surface, android_isurface, x, y, width, height); + SurfaceComposerClient::openGlobalTransaction(); + surface_ctrl0->setLayer(0x7FFFFFFF); + surface_ctrl0->show(); + SurfaceComposerClient::closeGlobalTransaction(); + + SurfaceComposerClient::openGlobalTransaction(); + surface_ctrl0->setPosition(x, y); + SurfaceComposerClient::closeGlobalTransaction(); + + SurfaceComposerClient::openGlobalTransaction(); + surface_ctrl0->setSize(width, height); + SurfaceComposerClient::closeGlobalTransaction(); + + anw0 = surface_ctrl0->getSurface(); - drawable_thread0 = static_cast(&android_isurface); + drawable_thread0 = static_cast(&anw0); if (multi_thread == 0) return 0; printf("Create window1 for thread1\n"); - /* need to modify here jgl*/ - SURFACE_CREATE(client1,surface_ctrl1,android_surface1, android_isurface1, x, y, width, height); - drawable_thread1 = static_cast(&android_isurface); + client1 = new SurfaceComposerClient(); + + surface_ctrl1 = client1->createSurface( + String8("Test Surface"), + width, height, + PIXEL_FORMAT_RGB_888, 0); + + SurfaceComposerClient::openGlobalTransaction(); + surface_ctrl1->setLayer(0x7FFFFFFF); + surface_ctrl1->show(); + SurfaceComposerClient::closeGlobalTransaction(); + + SurfaceComposerClient::openGlobalTransaction(); + surface_ctrl1->setPosition(x*2, y*2); + SurfaceComposerClient::closeGlobalTransaction(); + + SurfaceComposerClient::openGlobalTransaction(); + surface_ctrl1->setSize(width, height); + SurfaceComposerClient::closeGlobalTransaction(); + + anw1 = surface_ctrl1->getSurface(); + + drawable_thread1 = static_cast(&anw1); return 0; } -- 2.11.0