Commit 20574567 authored by Austin Yuan's avatar Austin Yuan

test/putsurface: more cleanup, remove #ifdef ANDROID from putsurface_common.c

Signed-off-by: default avatarAustin Yuan <shengquan.yuan@gmail.com>
parent 2f5f0962
...@@ -9,7 +9,7 @@ namespace android { ...@@ -9,7 +9,7 @@ namespace android {
}; };
#define SURFACE_CREATE(client,surface_ctrl,android_surface, android_isurface, win_width, win_height) \ #define SURFACE_CREATE(client,surface_ctrl,android_surface, android_isurface, win_width, win_height) \
{\ do {\
client = new SurfaceComposerClient();\ client = new SurfaceComposerClient();\
surface_ctrl = client->createSurface(getpid(), 0, win_width, win_height, PIXEL_FORMAT_RGB_565, ISurfaceComposer::ePushBuffers);\ surface_ctrl = client->createSurface(getpid(), 0, win_width, win_height, PIXEL_FORMAT_RGB_565, ISurfaceComposer::ePushBuffers);\
android_surface = surface_ctrl->getSurface();\ android_surface = surface_ctrl->getSurface();\
...@@ -27,6 +27,6 @@ namespace android { ...@@ -27,6 +27,6 @@ namespace android {
surface_ctrl->setLayer(0x100000);\ surface_ctrl->setLayer(0x100000);\
client->closeTransaction();\ client->closeTransaction();\
\ \
}\ } while (0) \
...@@ -77,7 +77,6 @@ static int display_surface(int frame_id, int *exit_encode); ...@@ -77,7 +77,6 @@ static int display_surface(int frame_id, int *exit_encode);
static int upload_source_YUV_once_for_all() static int upload_source_YUV_once_for_all()
{ {
VAImage surface_image;
void *surface_p=NULL, *U_start,*V_start; void *surface_p=NULL, *U_start,*V_start;
VAStatus va_status; VAStatus va_status;
int box_width=8; int box_width=8;
......
...@@ -36,9 +36,7 @@ ...@@ -36,9 +36,7 @@
#include <assert.h> #include <assert.h>
#include <pthread.h> #include <pthread.h>
#define Display unsigned int static int android_display=0;
static int win_thread0 = 0, win_thread1 = 0;
static int multi_thread = 0;
using namespace android; using namespace android;
#include "../android_winsys.cpp" #include "../android_winsys.cpp"
...@@ -53,8 +51,25 @@ sp<Surface> android_surface1; ...@@ -53,8 +51,25 @@ sp<Surface> android_surface1;
sp<ISurface> android_isurface1; sp<ISurface> android_isurface1;
sp<SurfaceControl> surface_ctrl1; sp<SurfaceControl> surface_ctrl1;
static void *open_display(void);
static void close_display(void *win_display);
static int create_window(void *win_display, int width, int height);
static int check_window_event(void *x11_display, void *win, int *width, int *height, int *quit);
static int create_window(int width, int height) #define CAST_DRAWABLE(a) static_cast<ISurface*>((void *)(*(unsigned int *)a))
#include "putsurface_common.c"
static void *open_display()
{
return &android_display;
}
static void close_display(void *win_display)
{
return;
}
static int create_window(void *win_display, int width, int height)
{ {
sp<ProcessState> proc(ProcessState::self()); sp<ProcessState> proc(ProcessState::self());
ProcessState::self()->startThreadPool(); ProcessState::self()->startThreadPool();
...@@ -62,16 +77,21 @@ static int create_window(int width, int height) ...@@ -62,16 +77,21 @@ static int create_window(int width, int height)
printf("Create window0 for thread0\n"); printf("Create window0 for thread0\n");
SURFACE_CREATE(client,surface_ctrl,android_surface, android_isurface, width, height); SURFACE_CREATE(client,surface_ctrl,android_surface, android_isurface, width, height);
win_thread0 = 1; drawable_thread0 = static_cast<void*>(&android_isurface);
if (multi_thread == 0) if (multi_thread == 0)
return 0; return 0;
printf("Create window1 for thread1\n"); printf("Create window1 for thread1\n");
/* need to modify here jgl*/ /* need to modify here jgl*/
SURFACE_CREATE(client1,surface_ctrl1,android_surface1, android_isurface1, width, height); SURFACE_CREATE(client1,surface_ctrl1,android_surface1, android_isurface1, width, height);
drawable_thread1 = static_cast<void *>(&android_isurface);
win_thread1 = 2;
return 0; return 0;
} }
#include "putsurface_common.c" int check_window_event(void *win_display, void *drawble, int *width, int *height, int *quit)
{
return 0;
}
This diff is collapsed.
...@@ -26,16 +26,32 @@ ...@@ -26,16 +26,32 @@
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <va/va_x11.h> #include <va/va_x11.h>
static Window win_thread0, win_thread1; static Window window_thread0, window_thread1;
static int multi_thread = 0;
static Pixmap pixmap_thread0, pixmap_thread1;
static GC context_thread0, context_thread1; static GC context_thread0, context_thread1;
static pthread_mutex_t gmutex; static pthread_mutex_t gmutex;
static void *open_display(void);
static void close_display(void *win_display);
static int create_window(void *win_display, int width, int height);
static int check_window_event(void *x11_display, void *drawable, int *width, int *height, int *quit);
#define CAST_DRAWABLE(a) (Drawable)(a)
#include "putsurface_common.c" #include "putsurface_common.c"
static Pixmap create_pixmap(int width, int height) static void *open_display(void)
{
return XOpenDisplay(":0.0");
}
static void close_display(void *win_display)
{
XCloseDisplay(win_display);
}
static Pixmap create_pixmap(void *win_display, int width, int height)
{ {
Display *x11_display = (Display *)win_display;
int screen = DefaultScreen(x11_display); int screen = DefaultScreen(x11_display);
Window root; Window root;
Pixmap pixmap; Pixmap pixmap;
...@@ -52,17 +68,18 @@ static Pixmap create_pixmap(int width, int height) ...@@ -52,17 +68,18 @@ static Pixmap create_pixmap(int width, int height)
return pixmap; return pixmap;
} }
static int create_window(int width, int height) static int create_window(void *win_display, int width, int height)
{ {
Display *x11_display = (Display *)win_display;
int screen = DefaultScreen(x11_display); int screen = DefaultScreen(x11_display);
Window root, win; Window root, win;
root = RootWindow(x11_display, screen); root = RootWindow(x11_display, screen);
printf("Create window0 for thread0\n"); printf("Create window0 for thread0\n");
win_thread0 = win = XCreateSimpleWindow(x11_display, root, 0, 0, width, height, drawable_thread0 = (void *)XCreateSimpleWindow(x11_display, root, 0, 0, width, height,
0, 0, WhitePixel(x11_display, 0)); 0, 0, WhitePixel(x11_display, 0));
if (win) { if (drawable_thread0) {
XSizeHints sizehints; XSizeHints sizehints;
sizehints.width = width; sizehints.width = width;
sizehints.height = height; sizehints.height = height;
...@@ -77,17 +94,19 @@ static int create_window(int width, int height) ...@@ -77,17 +94,19 @@ static int create_window(int width, int height)
XSelectInput(x11_display, win, KeyPressMask | StructureNotifyMask); XSelectInput(x11_display, win, KeyPressMask | StructureNotifyMask);
XSync(x11_display, False); XSync(x11_display, False);
if (put_pixmap) if (put_pixmap) {
pixmap_thread0 = create_pixmap(width, height); window_thread0 = (Window)drawable_thread0;
drawable_thread0 = (void *)create_pixmap(x11_display, width, height);
}
if (multi_thread == 0) if (multi_thread == 0)
return 0; return 0;
printf("Create window1 for thread1\n"); printf("Create window1 for thread1\n");
win_thread1 = win = XCreateSimpleWindow(x11_display, root, width, 0, width, height, drawable_thread1 = (void *)XCreateSimpleWindow(x11_display, root, width, 0, width, height,
0, 0, WhitePixel(x11_display, 0)); 0, 0, WhitePixel(x11_display, 0));
if (win) { if (drawable_thread1) {
XSizeHints sizehints; XSizeHints sizehints;
sizehints.width = width; sizehints.width = width;
sizehints.height = height; sizehints.height = height;
...@@ -98,8 +117,10 @@ static int create_window(int width, int height) ...@@ -98,8 +117,10 @@ static int create_window(int width, int height)
XMapWindow(x11_display, win); XMapWindow(x11_display, win);
} }
if (put_pixmap) if (put_pixmap) {
pixmap_thread1 = create_pixmap(width, height); window_thread1 = (Window)drawable_thread1;
drawable_thread1 = (void *)create_pixmap(x11_display, width, height);
}
context_thread1 = XCreateGC(x11_display, win, 0, 0); context_thread1 = XCreateGC(x11_display, win, 0, 0);
XSelectInput(x11_display, win, KeyPressMask | StructureNotifyMask); XSelectInput(x11_display, win, KeyPressMask | StructureNotifyMask);
...@@ -107,3 +128,40 @@ static int create_window(int width, int height) ...@@ -107,3 +128,40 @@ static int create_window(int width, int height)
return 0; return 0;
} }
static int check_window_event(void *win_display, void *drawable, int *width, int *height, int *quit)
{
int is_event = 0;
XEvent event;
Window win = (Window)drawable;
Display *x11_display = (Display *)win_display;
if (check_event == 0)
return 0;
pthread_mutex_lock(&gmutex);
is_event = XCheckWindowEvent(x11_display, win, StructureNotifyMask|KeyPressMask,&event);
pthread_mutex_unlock(&gmutex);
if (is_event == 0)
return 0;
/* bail on any focused key press */
if(event.type == KeyPress) {
*quit = 1;
return 0;
}
#if 0
/* rescale the video to fit the window */
if(event.type == ConfigureNotify) {
*width = event.xconfigure.width;
*height = event.xconfigure.height;
printf("Scale window to %dx%d\n", width, height);
}
#endif
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment