1/*
2 * Copyright (c) 2008-2009 Intel Corporation. All Rights Reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sub license, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
14 * of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
20 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24#include <stdio.h>
25#include <va/va.h>
26#include <va/va_android.h>
27#include <gui/Surface.h>
28#include <gui/SurfaceComposerClient.h>
29#include <gui/ISurfaceComposer.h>
30#include <assert.h>
31#include <pthread.h>
32
33using namespace android;
34
35static  int android_display=0;
36
37static sp<SurfaceComposerClient> client0 = NULL;
38static sp<SurfaceControl> surface_ctrl0 = NULL;
39static sp<ANativeWindow> anw0 = NULL;
40
41static sp<SurfaceComposerClient> client1 = NULL;
42static sp<SurfaceControl> surface_ctrl1 = NULL;
43static sp<ANativeWindow> anw1 = NULL;
44
45static void *open_display(void);
46static void close_display(void *win_display);
47static int create_window(void *win_display, int x, int y, int width, int height);
48static int check_window_event(void *x11_display, void *win, int *width, int *height, int *quit);
49
50#define CAST_DRAWABLE(a)  static_cast<ANativeWindow *>((void *)(*(unsigned int *)a))
51#include "putsurface_common.c"
52
53static void *open_display()
54{
55    return &android_display;
56}
57
58static void close_display(void *win_display)
59{
60    return;
61}
62
63static int create_window(void *win_display, int x, int y, int width, int height)
64{
65    client0 = new SurfaceComposerClient();
66
67    surface_ctrl0 = client1->createSurface(
68        String8("Test Surface"),
69        width, height,
70        PIXEL_FORMAT_RGB_888, 0);
71
72    SurfaceComposerClient::openGlobalTransaction();
73    surface_ctrl0->setLayer(0x7FFFFFFF);
74    surface_ctrl0->show();
75    SurfaceComposerClient::closeGlobalTransaction();
76
77    SurfaceComposerClient::openGlobalTransaction();
78    surface_ctrl0->setPosition(x, y);
79    SurfaceComposerClient::closeGlobalTransaction();
80
81    SurfaceComposerClient::openGlobalTransaction();
82    surface_ctrl0->setSize(width, height);
83    SurfaceComposerClient::closeGlobalTransaction();
84
85    anw0 = surface_ctrl0->getSurface();
86
87    drawable_thread0 = static_cast<void*>(&anw0);
88    if (multi_thread == 0)
89        return 0;
90
91    printf("Create window1 for thread1\n");
92    client1 = new SurfaceComposerClient();
93
94    surface_ctrl1 = client1->createSurface(
95        String8("Test Surface"),
96        width, height,
97        PIXEL_FORMAT_RGB_888, 0);
98
99    SurfaceComposerClient::openGlobalTransaction();
100    surface_ctrl1->setLayer(0x7FFFFFFF);
101    surface_ctrl1->show();
102    SurfaceComposerClient::closeGlobalTransaction();
103
104    SurfaceComposerClient::openGlobalTransaction();
105    surface_ctrl1->setPosition(x*2, y*2);
106    SurfaceComposerClient::closeGlobalTransaction();
107
108    SurfaceComposerClient::openGlobalTransaction();
109    surface_ctrl1->setSize(width, height);
110    SurfaceComposerClient::closeGlobalTransaction();
111
112    anw1 = surface_ctrl1->getSurface();
113
114    drawable_thread1 = static_cast<void *>(&anw1);
115
116    return 0;
117}
118
119int check_window_event(void *win_display, void *drawble, int *width, int *height, int *quit)
120{
121    return 0;
122}
123
124
125