aboutsummaryrefslogtreecommitdiffstats
path: root/android/protocol
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@android.com>2011-02-02 15:58:45 +0100
committerDavid 'Digit' Turner <digit@android.com>2011-02-02 21:09:41 +0100
commit7a5ee57895822a769f48ab40e590711a2459e2d1 (patch)
tree1c4ff6ef3cc7bd0c944b65385bba8782de35c875 /android/protocol
parentce747472342237e882369e486254684ab7708362 (diff)
downloadexternal_qemu-7a5ee57895822a769f48ab40e590711a2459e2d1.zip
external_qemu-7a5ee57895822a769f48ab40e590711a2459e2d1.tar.gz
external_qemu-7a5ee57895822a769f48ab40e590711a2459e2d1.tar.bz2
Simplify core framebuffer management.
Remove one layer of indirection between the core's DisplayState and a ProxyFramebuffer object. The main ideas behind this patch are that: - We don't need a QFrameBuffer object when in the core process, each proxy can receive display updates directly from QEMU. - The DisplayChangeListener is really lame: its can't dissociate between several listeners that use the same callback pointers, so introduce DisplayUpdateListener in console.h to work around this. This is preferably to modifying DisplayChangeListener which is going to introduce conflicts with upstream. - Simplify a lot the console code and display-core. Note that we can have several framebuffer clients at the same time now. Note that QFrameBuffer is still used by both the UI program and the standalone emulator. Change-Id: I6d5ad6ecd9b34b9d9d1a30ea5000e875c285e84e
Diffstat (limited to 'android/protocol')
-rw-r--r--android/protocol/fb-updates-proxy.c70
-rw-r--r--android/protocol/fb-updates-proxy.h13
2 files changed, 43 insertions, 40 deletions
diff --git a/android/protocol/fb-updates-proxy.c b/android/protocol/fb-updates-proxy.c
index 359c942..ec7414d 100644
--- a/android/protocol/fb-updates-proxy.c
+++ b/android/protocol/fb-updates-proxy.c
@@ -16,7 +16,6 @@
*/
#include "console.h"
-#include "android/framebuffer.h"
#include "android/looper.h"
#include "android/display-core.h"
#include "android/async-utils.h"
@@ -37,8 +36,9 @@ struct ProxyFramebuffer {
/* I/O associated with this descriptor. */
LoopIo io;
- /* Framebuffer used for this service. */
- QFrameBuffer* fb;
+ /* Display state used for this service */
+ DisplayState* ds;
+ DisplayUpdateListener* ds_listener;
/* Looper used to communicate framebuffer updates. */
Looper* looper;
@@ -80,9 +80,9 @@ typedef struct FBUpdateNotify {
* Pointer in framebuffer's pixels for the given pixel.
*/
static const uint8_t*
-_pixel_offset(const QFrameBuffer* fb, int x, int y)
+_pixel_offset(const DisplaySurface* dsu, int x, int y)
{
- return (const uint8_t*)fb->pixels + y * fb->pitch + x * fb->bytes_per_pixel;
+ return (const uint8_t*)dsu->data + y * dsu->linesize + x * dsu->pf.bytes_per_pixel;
}
/*
@@ -93,13 +93,13 @@ _pixel_offset(const QFrameBuffer* fb, int x, int y)
* x, y, w, and h - dimensions of the rectangle to copy.
*/
static void
-_copy_fb_rect(uint8_t* rect, const QFrameBuffer* fb, int x, int y, int w, int h)
+_copy_fb_rect(uint8_t* rect, const DisplaySurface* dsu, int x, int y, int w, int h)
{
- const uint8_t* start = _pixel_offset(fb, x, y);
+ const uint8_t* start = _pixel_offset(dsu, x, y);
for (; h > 0; h--) {
- memcpy(rect, start, w * fb->bytes_per_pixel);
- start += fb->pitch;
- rect += w * fb->bytes_per_pixel;
+ memcpy(rect, start, w * dsu->pf.bytes_per_pixel);
+ start += dsu->linesize;
+ rect += w * dsu->pf.bytes_per_pixel;
}
}
@@ -113,10 +113,10 @@ _copy_fb_rect(uint8_t* rect, const QFrameBuffer* fb, int x, int y, int w, int h)
* Initialized framebuffer update notification descriptor.
*/
static FBUpdateNotify*
-fbupdatenotify_create(ProxyFramebuffer* proxy_fb, const QFrameBuffer* fb,
+fbupdatenotify_create(ProxyFramebuffer* proxy_fb,
int x, int y, int w, int h)
{
- const size_t rect_size = w * h * fb->bytes_per_pixel;
+ const size_t rect_size = w * h * proxy_fb->ds->surface->pf.bytes_per_pixel;
FBUpdateNotify* ret = malloc(sizeof(FBUpdateNotify) + rect_size);
ret->next_fb_update = NULL;
@@ -126,7 +126,7 @@ fbupdatenotify_create(ProxyFramebuffer* proxy_fb, const QFrameBuffer* fb,
ret->message.y = y;
ret->message.w = w;
ret->message.h = h;
- _copy_fb_rect(ret->message.rect, fb, x, y, w, h);
+ _copy_fb_rect(ret->message.rect, proxy_fb->ds->surface, x, y, w, h);
return ret;
}
@@ -143,9 +143,6 @@ fbupdatenotify_delete(FBUpdateNotify* desc)
}
}
-/* Implemented in android/console.c */
-extern void destroy_control_fb_client(void);
-
/*
* Asynchronous write I/O callback launched when writing framebuffer
* notifications to the socket.
@@ -191,6 +188,8 @@ _proxyFb_io_write(ProxyFramebuffer* proxy_fb)
}
}
+static void proxyFb_update(void* opaque, int x, int y, int w, int h);
+
/*
* Asynchronous read I/O callback launched when reading framebuffer requests
* from the socket.
@@ -201,6 +200,7 @@ static void
_proxyFb_io_read(ProxyFramebuffer* proxy_fb)
{
// Read the request header.
+ DisplaySurface* dsu;
const AsyncStatus status =
asyncReader_read(&proxy_fb->fb_req_reader, &proxy_fb->io);
switch (status) {
@@ -209,9 +209,9 @@ _proxyFb_io_read(ProxyFramebuffer* proxy_fb)
switch (proxy_fb->fb_req_header.request_type) {
case AFB_REQUEST_REFRESH:
// Force full screen update to be sent
- proxyFb_update(proxy_fb, proxy_fb->fb,
- 0, 0, proxy_fb->fb->width,
- proxy_fb->fb->height);
+ dsu = proxy_fb->ds->surface;
+ proxyFb_update(proxy_fb,
+ 0, 0, dsu->width, dsu->height);
break;
default:
derror("Unknown framebuffer request %d\n",
@@ -226,7 +226,7 @@ _proxyFb_io_read(ProxyFramebuffer* proxy_fb)
loopIo_dontWantRead(&proxy_fb->io);
if (errno == ECONNRESET) {
// UI has exited. We need to destroy framebuffer service.
- destroy_control_fb_client();
+ proxyFb_destroy(proxy_fb);
}
break;
@@ -253,14 +253,24 @@ _proxyFb_io_fun(void* opaque, int fd, unsigned events)
}
ProxyFramebuffer*
-proxyFb_create(int sock, const char* protocol, QFrameBuffer* fb)
+proxyFb_create(int sock, const char* protocol)
{
// At this point we're implementing the -raw protocol only.
ProxyFramebuffer* ret;
+ DisplayState* ds = get_displaystate();
+ DisplayUpdateListener* dul;
+
ANEW0(ret);
ret->sock = sock;
ret->looper = looper_newCore();
- ret->fb = fb;
+ ret->ds = ds;
+
+ ANEW0(dul);
+ dul->opaque = ret;
+ dul->dpy_update = proxyFb_update;
+ register_displayupdatelistener(ds, dul);
+ ret->ds_listener = dul;
+
ret->fb_update_head = NULL;
ret->fb_update_tail = NULL;
loopIo_init(&ret->io, ret->looper, sock, _proxyFb_io_fun, ret);
@@ -273,6 +283,7 @@ void
proxyFb_destroy(ProxyFramebuffer* proxy_fb)
{
if (proxy_fb != NULL) {
+ unregister_displayupdatelistener(proxy_fb->ds, proxy_fb->ds_listener);
if (proxy_fb->looper != NULL) {
// Stop all I/O that may still be going on.
loopIo_done(&proxy_fb->io);
@@ -286,15 +297,16 @@ proxyFb_destroy(ProxyFramebuffer* proxy_fb)
looper_free(proxy_fb->looper);
proxy_fb->looper = NULL;
}
+ AFREE(proxy_fb);
}
}
-void
-proxyFb_update(ProxyFramebuffer* proxy_fb,
- struct QFrameBuffer* fb, int x, int y, int w, int h)
+static void
+proxyFb_update(void* opaque, int x, int y, int w, int h)
{
+ ProxyFramebuffer* proxy_fb = opaque;
AsyncStatus status;
- FBUpdateNotify* descr = fbupdatenotify_create(proxy_fb, fb, x, y, w, h);
+ FBUpdateNotify* descr = fbupdatenotify_create(proxy_fb, x, y, w, h);
// Lets see if we should list it behind other pending updates.
if (proxy_fb->fb_update_tail != NULL) {
@@ -327,6 +339,8 @@ proxyFb_update(ProxyFramebuffer* proxy_fb,
int
proxyFb_get_bits_per_pixel(ProxyFramebuffer* proxy_fb)
{
- return (proxy_fb != NULL && proxy_fb->fb != NULL) ?
- proxy_fb->fb->bits_per_pixel : -1;
+ if (proxy_fb == NULL || proxy_fb->ds == NULL)
+ return -1;
+
+ return proxy_fb->ds->surface->pf.bits_per_pixel;
}
diff --git a/android/protocol/fb-updates-proxy.h b/android/protocol/fb-updates-proxy.h
index e750f1a..15b1d5b 100644
--- a/android/protocol/fb-updates-proxy.h
+++ b/android/protocol/fb-updates-proxy.h
@@ -29,11 +29,10 @@ typedef struct ProxyFramebuffer ProxyFramebuffer;
* supported values ar:
* -raw Transfers the updating rectangle buffer over the socket.
* -shared Used a shared memory to transfer the updating rectangle buffer.
- * fb - Framebuffer descriptor for this service.
* Return:
* Framebuffer service descriptor.
*/
-ProxyFramebuffer* proxyFb_create(int sock, const char* protocol, struct QFrameBuffer* fb);
+ProxyFramebuffer* proxyFb_create(int sock, const char* protocol);
/*
* Destroys framebuffer service created with proxyFb_create.
@@ -43,16 +42,6 @@ ProxyFramebuffer* proxyFb_create(int sock, const char* protocol, struct QFrameBu
void proxyFb_destroy(ProxyFramebuffer* core_fb);
/*
- * Notifies framebuffer client about changes in framebuffer.
- * Param:
- * core_fb - Framebuffer service descriptor created with proxyFb_create
- * fb Framebuffer containing pixels.
- * x, y, w, and h identify the rectangle that has benn changed.
- */
-void proxyFb_update(ProxyFramebuffer* core_fb, struct QFrameBuffer* fb,
- int x, int y, int w, int h);
-
-/*
* Gets number of bits used to encode a single pixel.
* Param:
* core_fb - Framebuffer service descriptor created with proxyFb_create