blob: 0cfd98d32897d957201dfc95dd5f6f2f6fd83299 [file] [log] [blame]
David 'Digit' Turner055ae422010-07-27 11:34:16 -07001/* Copyright (C) 2010 The Android Open Source Project
2**
3** This software is licensed under the terms of the GNU General Public
4** License version 2, as published by the Free Software Foundation, and
5** may be copied, distributed, and modified under those terms.
6**
7** This program is distributed in the hope that it will be useful,
8** but WITHOUT ANY WARRANTY; without even the implied warranty of
9** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10** GNU General Public License for more details.
11*/
12
13/* Initialization of the Android-specific DisplayState.
14 * Read docs/DISPLAY-STATE.TXT to understand what this
15 * is supposed to do.
16 */
17#include "android/display.h"
18
19/*
20
21TECHNICAL NOTE:
22
23DisplayState <--> QFrameBuffer <--> QEmulator/SDL
24
25*/
26
27/* QFrameBuffer producer callbacks */
28
29/* this is called periodically by the GUI timer to check for updates
30 * and poll user events. Use vga_hw_update().
31 */
32static void
33android_display_producer_check(void *opaque)
34{
35 /* core: call vga_hw_update(). this will eventually
36 * lead to calls to android_display_update()
37 */
38 (void)opaque;
39 vga_hw_update();
40}
41
42static void
43android_display_producer_invalidate(void *opaque)
44{
45 (void)opaque;
46 vga_hw_invalidate();
47}
48
49/* QFrameBuffer client callbacks */
50
51/* this is called from dpy_update() each time a hardware framebuffer
52 * rectangular update was detected. Send this to the QFrameBuffer.
53 */
54static void
55android_display_update(DisplayState *ds, int x, int y, int w, int h)
56{
57 QFrameBuffer* qfbuff = ds->opaque;
58 qframebuffer_update(qfbuff, x, y, w, h);
59}
60
61static void
62android_display_resize(DisplayState *ds)
63{
64 QFrameBuffer* qfbuff = ds->opaque;
65 qframebuffer_rotate(qfbuff, 0);
66}
67
68static void
69android_display_refresh(DisplayState *ds)
70{
71 QFrameBuffer* qfbuff = ds->opaque;
72 qframebuffer_poll(qfbuff);
73}
74
75
76void android_display_init(DisplayState* ds, QFrameBuffer* qf)
77{
78 DisplayChangeListener* dcl;
79
80 qframebuffer_set_producer(qf, ds,
81 android_display_producer_check,
82 android_display_producer_invalidate,
83 NULL); // detach
84
85 /* Replace the display surface with one with the right dimensions */
86 qemu_free_displaysurface(ds);
87 ds->opaque = qf;
88 ds->surface = qemu_create_displaysurface_from(qf->width,
89 qf->height,
90 16,
91 qf->pitch,
92 qf->pixels);
93
94 /* Register a change listener for it */
95 dcl = (DisplayChangeListener *) qemu_mallocz(sizeof(DisplayChangeListener));
96 dcl->dpy_update = android_display_update;
97 dcl->dpy_resize = android_display_resize;
98 dcl->dpy_refresh = android_display_refresh;
99 dcl->dpy_text_cursor = NULL;
100
101 register_displaychangelistener(ds, dcl);
102}