vaPutSurface test on Android: fix build isste on Android JB
authorAustin Yuan <shengquan.yuan@gmail.com>
Thu, 7 Mar 2013 02:52:11 +0000 (10:52 +0800)
committerAustin Yuan <shengquan.yuan@gmail.com>
Thu, 14 Mar 2013 02:07:28 +0000 (10:07 +0800)
Change-Id: Ibfb3d6a653f9af924422edb052e751b84015ffd0
Signed-off-by: Austin Yuan <shengquan.yuan@gmail.com>
test/android_winsys.cpp [deleted file]
test/basic/Android.mk
test/common/va_display_android.cpp
test/decode/Android.mk
test/putsurface/putsurface_android.cpp
test/putsurface/putsurface_common.c

diff --git a/test/android_winsys.cpp b/test/android_winsys.cpp
deleted file mode 100644 (file)
index 21df279..0000000
+++ /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 <ui/DisplayInfo.h>
-
-namespace android {
-};
-
-#define min(a,b) (a<b?a:b)
-#define SURFACE_CREATE(client,surface_ctrl,android_surface, android_isurface, x, y, win_width, win_height) \
-do {                                                                    \
-    client = new SurfaceComposerClient();                               \
-    android::DisplayInfo info;                                          \
-    int w, h;                                                           \
-    sp<IBinder> 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)
-
-
index 708d98f..2b4255c 100755 (executable)
@@ -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)
 
index 82c05a3..b05a47a 100644 (file)
 #include <va/va_android.h>
 #include "va_display.h"
 
-#include <binder/IPCThreadState.h>
-#include <binder/ProcessState.h>
-#include <binder/IServiceManager.h>
-#include <utils/Log.h>
 #include <gui/Surface.h>
 #include <gui/SurfaceComposerClient.h>
 #include <gui/ISurfaceComposer.h>
-#include <ui/PixelFormat.h>
-#include <ui/DisplayInfo.h>
-#include <binder/MemoryHeapBase.h>
 
 static unsigned int fake_display = 0xdeada01d;
 
 using namespace android;
 
-sp<SurfaceComposerClient> client;
-sp<Surface> android_surface;
-sp<ISurface> android_isurface;
-sp<SurfaceControl> surface_ctrl;
-#include "../android_winsys.cpp"
+static sp<SurfaceComposerClient> client = NULL;
+static sp<SurfaceControl> surface_ctr = NULL;
+static sp<ANativeWindow> 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<ProcessState> 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,
index d1053b7..52f7bfd 100755 (executable)
@@ -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)
 
index 8b70480..b4e0a92 100644 (file)
 #include <stdio.h>
 #include <va/va.h>
 #include <va/va_android.h>
-#include <binder/IPCThreadState.h>
-#include <binder/ProcessState.h>
-#include <binder/IServiceManager.h>
-#include <utils/Log.h>
-#include <surfaceflinger/ISurfaceComposer.h>
-#include <surfaceflinger/Surface.h>
-#include <surfaceflinger/ISurface.h>
-#include <surfaceflinger/SurfaceComposerClient.h>
-#include <binder/MemoryHeapBase.h>
+#include <gui/Surface.h>
+#include <gui/SurfaceComposerClient.h>
+#include <gui/ISurfaceComposer.h>
 #include <assert.h>
 #include <pthread.h>
 
-static  int android_display=0;
-
 using namespace android;
-#include "../android_winsys.cpp"
 
-sp<SurfaceComposerClient> client;
-sp<Surface> android_surface;
-sp<ISurface> android_isurface;
-sp<SurfaceControl> surface_ctrl;
+static  int android_display=0;
+
+static sp<SurfaceComposerClient> client0 = NULL;
+static sp<SurfaceControl> surface_ctrl0 = NULL;
+static sp<ANativeWindow> anw0 = NULL;
 
-sp<SurfaceComposerClient> client1;
-sp<Surface> android_surface1;
-sp<ISurface> android_isurface1;
-sp<SurfaceControl> surface_ctrl1;
+static sp<SurfaceComposerClient> client1 = NULL;
+static sp<SurfaceControl> surface_ctrl1 = NULL;
+static sp<ANativeWindow> 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<ISurface*>((void *)(*(unsigned int *)a))
+#define CAST_DRAWABLE(a)  static_cast<ANativeWindow *>((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<ProcessState> 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<void*>(&android_isurface);
+    drawable_thread0 = static_cast<void*>(&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<void *>(&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<void *>(&anw1);
     
     return 0;
 }
index 1fddbbe..2bef579 100755 (executable)
@@ -78,13 +78,13 @@ static  int box_width = 32;
 static  int multi_thread = 0;
 static  int verbose = 0;
 static  int test_color_conversion = 0;
-static  int csc_src_fourcc = 0, csc_dst_fourcc = 0;
+static  unsigned int csc_src_fourcc = 0, csc_dst_fourcc = 0;
 static  VAImage csc_dst_fourcc_image;
 static  VASurfaceID csc_render_surface;
 
 
 typedef struct {
-    char* fmt_str;
+    char * fmt_str;
     unsigned int fourcc;
 } fourcc_map;
 fourcc_map va_fourcc_map[] = {
@@ -99,7 +99,7 @@ fourcc_map va_fourcc_map[] = {
 };
 unsigned int map_str_to_vafourcc (char * str)
 {
-    int i;
+    unsigned int i;
     for (i=0; i< sizeof(va_fourcc_map)/sizeof(fourcc_map); i++) {
         if (!strcmp(va_fourcc_map[i].fmt_str, str)) {
             return va_fourcc_map[i].fourcc;
@@ -112,7 +112,7 @@ unsigned int map_str_to_vafourcc (char * str)
 char* map_vafourcc_to_str (unsigned int format)
 {
     static char unknown_format[] = "unknown-format";
-    int i;
+    unsigned int i;
     for (i=0; i< sizeof(va_fourcc_map)/sizeof(fourcc_map); i++) {
         if (va_fourcc_map[i].fourcc == format) {
             return va_fourcc_map[i].fmt_str;
@@ -346,7 +346,7 @@ static void* putsurface_thread(void *data)
                                     0, 0, surface_width, surface_height, 
                                     0, 0, surface_width, surface_height);
             CHECK_VASTATUS(vaStatus,"vaPutImage");
-            
+
             // render the temp surface, it should be same with original surface without color conversion test
             vaStatus = vaPutSurface(va_dpy, csc_render_surface, CAST_DRAWABLE(drawable),
                                     0,0,surface_width,surface_height,
@@ -355,7 +355,6 @@ static void* putsurface_thread(void *data)
                                     (test_clip==0)?0:2,
                                     display_field);
             CHECK_VASTATUS(vaStatus,"vaPutSurface");
-    
         }
         else {
             vaStatus = vaPutSurface(va_dpy, surface_id, CAST_DRAWABLE(drawable),