aboutsummaryrefslogtreecommitdiffstats
path: root/android/protocol
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@android.com>2011-02-02 12:12:53 -0800
committerAndroid Code Review <code-review@android.com>2011-02-02 12:12:53 -0800
commitd6eda1d7b357746ad8d9a4c80dc0235ef56c40e0 (patch)
treeb669e7b99c01bd8aafd2079321c8cb80302454e0 /android/protocol
parentce747472342237e882369e486254684ab7708362 (diff)
parent07db34976ba1dd045a51c4ab2c7f52479cddcc57 (diff)
downloadexternal_qemu-d6eda1d7b357746ad8d9a4c80dc0235ef56c40e0.zip
external_qemu-d6eda1d7b357746ad8d9a4c80dc0235ef56c40e0.tar.gz
external_qemu-d6eda1d7b357746ad8d9a4c80dc0235ef56c40e0.tar.bz2
Merge changes Icd076267,I6d5ad6ec
* changes: Simplify UI-only sources. Simplify core framebuffer management.
Diffstat (limited to 'android/protocol')
-rw-r--r--android/protocol/fb-updates-proxy.c70
-rw-r--r--android/protocol/fb-updates-proxy.h13
-rw-r--r--android/protocol/ui-commands-impl.c4
3 files changed, 45 insertions, 42 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
diff --git a/android/protocol/ui-commands-impl.c b/android/protocol/ui-commands-impl.c
index f265514..2ca4194 100644
--- a/android/protocol/ui-commands-impl.c
+++ b/android/protocol/ui-commands-impl.c
@@ -124,7 +124,7 @@ _uiCmdImpl_io_read(void* opaque)
status = read(uicmd->sock, uicmd->reader_buffer + uicmd->reader_offset,
uicmd->reader_bytes - uicmd->reader_offset);
if (status == 0) {
- /* Disconnection, meaning that the core process got termonated. */
+ /* Disconnection, meaning that the core process got terminated. */
fprintf(stderr, "core-ui-control service got disconnected\n");
uiCmdImpl_destroy();
return;
@@ -201,7 +201,7 @@ uiCmdImpl_create(SockAddress* console_socket)
return -1;
}
- // Initialze UI command reader.
+ // Initialize UI command reader.
_uiCmdImpl.sock = core_connection_get_socket(_uiCmdImpl.core_connection);
if (qemu_set_fd_handler(_uiCmdImpl.sock, _uiCmdImpl_io_read, NULL,
&_uiCmdImpl)) {