Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 1 | /* 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 | /* |
| 14 | * Contains core-side framebuffer service that sends framebuffer updates |
| 15 | * to the UI connected to the core. |
| 16 | */ |
| 17 | |
| 18 | #include "console.h" |
| 19 | #include "framebuffer.h" |
| 20 | #include "android/looper.h" |
| 21 | #include "android/display-core.h" |
| 22 | #include "android/async-utils.h" |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 23 | #include "android/protocol/fb-updates.h" |
| 24 | #include "android/protocol/fb-updates-proxy.h" |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 25 | #include "android/utils/system.h" |
| 26 | #include "android/utils/debug.h" |
| 27 | |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 28 | /* Descriptor for the Core-side implementation of the "framebufer" service. |
| 29 | */ |
| 30 | struct ProxyFramebuffer { |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 31 | /* Writer used to send FB update notification messages. */ |
Vladimir Chtchetkine | 8acf4e2 | 2010-12-21 07:14:17 -0800 | [diff] [blame] | 32 | AsyncWriter fb_update_writer; |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 33 | |
Vladimir Chtchetkine | ac389ae | 2011-01-20 14:35:55 -0800 | [diff] [blame] | 34 | /* Reader used to read FB requests from the client. */ |
| 35 | AsyncReader fb_req_reader; |
| 36 | |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 37 | /* I/O associated with this descriptor. */ |
Vladimir Chtchetkine | 8acf4e2 | 2010-12-21 07:14:17 -0800 | [diff] [blame] | 38 | LoopIo io; |
| 39 | |
| 40 | /* Framebuffer used for this service. */ |
| 41 | QFrameBuffer* fb; |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 42 | |
| 43 | /* Looper used to communicate framebuffer updates. */ |
| 44 | Looper* looper; |
| 45 | |
| 46 | /* Head of the list of pending FB update notifications. */ |
| 47 | struct FBUpdateNotify* fb_update_head; |
| 48 | |
| 49 | /* Tail of the list of pending FB update notifications. */ |
| 50 | struct FBUpdateNotify* fb_update_tail; |
| 51 | |
| 52 | /* Socket used to communicate framebuffer updates. */ |
| 53 | int sock; |
Vladimir Chtchetkine | ac389ae | 2011-01-20 14:35:55 -0800 | [diff] [blame] | 54 | |
| 55 | /* Framebuffer request header. */ |
| 56 | FBRequestHeader fb_req_header; |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 57 | }; |
| 58 | |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 59 | /* Framebuffer update notification descriptor. */ |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 60 | typedef struct FBUpdateNotify { |
| 61 | /* Links all pending FB update notifications. */ |
| 62 | struct FBUpdateNotify* next_fb_update; |
| 63 | |
| 64 | /* Core framebuffer instance that owns the message. */ |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 65 | ProxyFramebuffer* proxy_fb; |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 66 | |
| 67 | /* Size of the message to transfer. */ |
| 68 | size_t message_size; |
| 69 | |
| 70 | /* Update message. */ |
| 71 | FBUpdateMessage message; |
| 72 | } FBUpdateNotify; |
| 73 | |
| 74 | /* |
| 75 | * Gets pointer in framebuffer's pixels for the given pixel. |
| 76 | * Param: |
| 77 | * fb Framebuffer containing pixels. |
| 78 | * x, and y identify the pixel to get pointer for. |
| 79 | * Return: |
| 80 | * Pointer in framebuffer's pixels for the given pixel. |
| 81 | */ |
| 82 | static const uint8_t* |
| 83 | _pixel_offset(const QFrameBuffer* fb, int x, int y) |
| 84 | { |
| 85 | return (const uint8_t*)fb->pixels + y * fb->pitch + x * fb->bytes_per_pixel; |
| 86 | } |
| 87 | |
| 88 | /* |
| 89 | * Copies pixels from a framebuffer rectangle. |
| 90 | * Param: |
| 91 | * rect - Buffer where to copy pixel. |
| 92 | * fb - Framebuffer containing the rectangle to copy. |
| 93 | * x, y, w, and h - dimensions of the rectangle to copy. |
| 94 | */ |
| 95 | static void |
| 96 | _copy_fb_rect(uint8_t* rect, const QFrameBuffer* fb, int x, int y, int w, int h) |
| 97 | { |
| 98 | const uint8_t* start = _pixel_offset(fb, x, y); |
| 99 | for (; h > 0; h--) { |
| 100 | memcpy(rect, start, w * fb->bytes_per_pixel); |
| 101 | start += fb->pitch; |
| 102 | rect += w * fb->bytes_per_pixel; |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | /* |
| 107 | * Allocates and initializes framebuffer update notification descriptor. |
| 108 | * Param: |
| 109 | * ds - Display state for the framebuffer. |
| 110 | * fb Framebuffer containing pixels. |
| 111 | * x, y, w, and h identify the rectangle that is being updated. |
| 112 | * Return: |
| 113 | * Initialized framebuffer update notification descriptor. |
| 114 | */ |
| 115 | static FBUpdateNotify* |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 116 | fbupdatenotify_create(ProxyFramebuffer* proxy_fb, const QFrameBuffer* fb, |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 117 | int x, int y, int w, int h) |
| 118 | { |
| 119 | const size_t rect_size = w * h * fb->bytes_per_pixel; |
| 120 | FBUpdateNotify* ret = malloc(sizeof(FBUpdateNotify) + rect_size); |
| 121 | |
| 122 | ret->next_fb_update = NULL; |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 123 | ret->proxy_fb = proxy_fb; |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 124 | ret->message_size = sizeof(FBUpdateMessage) + rect_size; |
| 125 | ret->message.x = x; |
| 126 | ret->message.y = y; |
| 127 | ret->message.w = w; |
| 128 | ret->message.h = h; |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 129 | _copy_fb_rect(ret->message.rect, fb, x, y, w, h); |
| 130 | return ret; |
| 131 | } |
| 132 | |
| 133 | /* |
| 134 | * Deletes FBUpdateNotify descriptor, created with fbupdatenotify_create. |
| 135 | * Param: |
| 136 | * desc - Descreptor to delete. |
| 137 | */ |
| 138 | static void |
| 139 | fbupdatenotify_delete(FBUpdateNotify* desc) |
| 140 | { |
| 141 | if (desc != NULL) { |
| 142 | free(desc); |
| 143 | } |
| 144 | } |
| 145 | |
Vladimir Chtchetkine | 6ee1c4e | 2011-01-20 11:22:32 -0800 | [diff] [blame] | 146 | /* Implemented in android/console.c */ |
| 147 | extern void destroy_control_fb_client(void); |
| 148 | |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 149 | /* |
Vladimir Chtchetkine | ac389ae | 2011-01-20 14:35:55 -0800 | [diff] [blame] | 150 | * Asynchronous write I/O callback launched when writing framebuffer |
| 151 | * notifications to the socket. |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 152 | * Param: |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 153 | * proxy_fb - ProxyFramebuffer instance. |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 154 | */ |
| 155 | static void |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 156 | _proxyFb_io_write(ProxyFramebuffer* proxy_fb) |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 157 | { |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 158 | while (proxy_fb->fb_update_head != NULL) { |
| 159 | FBUpdateNotify* current_update = proxy_fb->fb_update_head; |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 160 | // Lets continue writing of the current notification. |
| 161 | const AsyncStatus status = |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 162 | asyncWriter_write(&proxy_fb->fb_update_writer, &proxy_fb->io); |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 163 | switch (status) { |
| 164 | case ASYNC_COMPLETE: |
| 165 | // Done with the current update. Move on to the next one. |
| 166 | break; |
| 167 | case ASYNC_ERROR: |
| 168 | // Done with the current update. Move on to the next one. |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 169 | loopIo_dontWantWrite(&proxy_fb->io); |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 170 | break; |
| 171 | |
| 172 | case ASYNC_NEED_MORE: |
| 173 | // Transfer will eventually come back into this routine. |
| 174 | return; |
| 175 | } |
| 176 | |
| 177 | // Advance the list of updates |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 178 | proxy_fb->fb_update_head = current_update->next_fb_update; |
| 179 | if (proxy_fb->fb_update_head == NULL) { |
| 180 | proxy_fb->fb_update_tail = NULL; |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 181 | } |
| 182 | fbupdatenotify_delete(current_update); |
| 183 | |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 184 | if (proxy_fb->fb_update_head != NULL) { |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 185 | // Schedule the next one. |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 186 | asyncWriter_init(&proxy_fb->fb_update_writer, |
| 187 | &proxy_fb->fb_update_head->message, |
| 188 | proxy_fb->fb_update_head->message_size, |
| 189 | &proxy_fb->io); |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 190 | } |
| 191 | } |
| 192 | } |
| 193 | |
Vladimir Chtchetkine | ac389ae | 2011-01-20 14:35:55 -0800 | [diff] [blame] | 194 | /* |
| 195 | * Asynchronous read I/O callback launched when reading framebuffer requests |
| 196 | * from the socket. |
| 197 | * Param: |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 198 | * proxy_fb - ProxyFramebuffer instance. |
Vladimir Chtchetkine | ac389ae | 2011-01-20 14:35:55 -0800 | [diff] [blame] | 199 | */ |
| 200 | static void |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 201 | _proxyFb_io_read(ProxyFramebuffer* proxy_fb) |
Vladimir Chtchetkine | ac389ae | 2011-01-20 14:35:55 -0800 | [diff] [blame] | 202 | { |
| 203 | // Read the request header. |
| 204 | const AsyncStatus status = |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 205 | asyncReader_read(&proxy_fb->fb_req_reader, &proxy_fb->io); |
Vladimir Chtchetkine | ac389ae | 2011-01-20 14:35:55 -0800 | [diff] [blame] | 206 | switch (status) { |
| 207 | case ASYNC_COMPLETE: |
| 208 | // Request header is received |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 209 | switch (proxy_fb->fb_req_header.request_type) { |
Vladimir Chtchetkine | ac389ae | 2011-01-20 14:35:55 -0800 | [diff] [blame] | 210 | case AFB_REQUEST_REFRESH: |
| 211 | // Force full screen update to be sent |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 212 | proxyFb_update(proxy_fb, proxy_fb->fb, |
| 213 | 0, 0, proxy_fb->fb->width, |
| 214 | proxy_fb->fb->height); |
Vladimir Chtchetkine | ac389ae | 2011-01-20 14:35:55 -0800 | [diff] [blame] | 215 | break; |
| 216 | default: |
| 217 | derror("Unknown framebuffer request %d\n", |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 218 | proxy_fb->fb_req_header.request_type); |
Vladimir Chtchetkine | ac389ae | 2011-01-20 14:35:55 -0800 | [diff] [blame] | 219 | break; |
| 220 | } |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 221 | proxy_fb->fb_req_header.request_type = -1; |
| 222 | asyncReader_init(&proxy_fb->fb_req_reader, &proxy_fb->fb_req_header, |
| 223 | sizeof(proxy_fb->fb_req_header), &proxy_fb->io); |
Vladimir Chtchetkine | ac389ae | 2011-01-20 14:35:55 -0800 | [diff] [blame] | 224 | break; |
| 225 | case ASYNC_ERROR: |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 226 | loopIo_dontWantRead(&proxy_fb->io); |
Vladimir Chtchetkine | ac389ae | 2011-01-20 14:35:55 -0800 | [diff] [blame] | 227 | if (errno == ECONNRESET) { |
| 228 | // UI has exited. We need to destroy framebuffer service. |
| 229 | destroy_control_fb_client(); |
| 230 | } |
| 231 | break; |
| 232 | |
| 233 | case ASYNC_NEED_MORE: |
| 234 | // Transfer will eventually come back into this routine. |
| 235 | return; |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | /* |
| 240 | * Asynchronous I/O callback launched when writing framebuffer notifications |
| 241 | * to the socket. |
| 242 | * Param: |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 243 | * opaque - ProxyFramebuffer instance. |
Vladimir Chtchetkine | ac389ae | 2011-01-20 14:35:55 -0800 | [diff] [blame] | 244 | */ |
| 245 | static void |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 246 | _proxyFb_io_fun(void* opaque, int fd, unsigned events) |
Vladimir Chtchetkine | ac389ae | 2011-01-20 14:35:55 -0800 | [diff] [blame] | 247 | { |
| 248 | if (events & LOOP_IO_READ) { |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 249 | _proxyFb_io_read((ProxyFramebuffer*)opaque); |
Vladimir Chtchetkine | ac389ae | 2011-01-20 14:35:55 -0800 | [diff] [blame] | 250 | } else if (events & LOOP_IO_WRITE) { |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 251 | _proxyFb_io_write((ProxyFramebuffer*)opaque); |
Vladimir Chtchetkine | ac389ae | 2011-01-20 14:35:55 -0800 | [diff] [blame] | 252 | } |
| 253 | } |
| 254 | |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 255 | ProxyFramebuffer* |
| 256 | proxyFb_create(int sock, const char* protocol, QFrameBuffer* fb) |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 257 | { |
| 258 | // At this point we're implementing the -raw protocol only. |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 259 | ProxyFramebuffer* ret; |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 260 | ANEW0(ret); |
| 261 | ret->sock = sock; |
| 262 | ret->looper = looper_newCore(); |
Vladimir Chtchetkine | 8acf4e2 | 2010-12-21 07:14:17 -0800 | [diff] [blame] | 263 | ret->fb = fb; |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 264 | ret->fb_update_head = NULL; |
| 265 | ret->fb_update_tail = NULL; |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 266 | loopIo_init(&ret->io, ret->looper, sock, _proxyFb_io_fun, ret); |
Vladimir Chtchetkine | ac389ae | 2011-01-20 14:35:55 -0800 | [diff] [blame] | 267 | asyncReader_init(&ret->fb_req_reader, &ret->fb_req_header, |
| 268 | sizeof(ret->fb_req_header), &ret->io); |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 269 | return ret; |
| 270 | } |
| 271 | |
| 272 | void |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 273 | proxyFb_destroy(ProxyFramebuffer* proxy_fb) |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 274 | { |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 275 | if (proxy_fb != NULL) { |
| 276 | if (proxy_fb->looper != NULL) { |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 277 | // Stop all I/O that may still be going on. |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 278 | loopIo_done(&proxy_fb->io); |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 279 | // Delete all pending frame updates. |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 280 | while (proxy_fb->fb_update_head != NULL) { |
| 281 | FBUpdateNotify* pending_update = proxy_fb->fb_update_head; |
| 282 | proxy_fb->fb_update_head = pending_update->next_fb_update; |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 283 | fbupdatenotify_delete(pending_update); |
| 284 | } |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 285 | proxy_fb->fb_update_tail = NULL; |
| 286 | looper_free(proxy_fb->looper); |
| 287 | proxy_fb->looper = NULL; |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 288 | } |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | void |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 293 | proxyFb_update(ProxyFramebuffer* proxy_fb, |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 294 | struct QFrameBuffer* fb, int x, int y, int w, int h) |
| 295 | { |
| 296 | AsyncStatus status; |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 297 | FBUpdateNotify* descr = fbupdatenotify_create(proxy_fb, fb, x, y, w, h); |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 298 | |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 299 | // Lets see if we should list it behind other pending updates. |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 300 | if (proxy_fb->fb_update_tail != NULL) { |
| 301 | proxy_fb->fb_update_tail->next_fb_update = descr; |
| 302 | proxy_fb->fb_update_tail = descr; |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 303 | return; |
| 304 | } |
| 305 | |
| 306 | // We're first in the list. Just send it now. |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 307 | proxy_fb->fb_update_head = proxy_fb->fb_update_tail = descr; |
| 308 | asyncWriter_init(&proxy_fb->fb_update_writer, |
| 309 | &proxy_fb->fb_update_head->message, |
| 310 | proxy_fb->fb_update_head->message_size, &proxy_fb->io); |
| 311 | status = asyncWriter_write(&proxy_fb->fb_update_writer, &proxy_fb->io); |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 312 | switch (status) { |
| 313 | case ASYNC_COMPLETE: |
| 314 | fbupdatenotify_delete(descr); |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 315 | proxy_fb->fb_update_head = proxy_fb->fb_update_tail = NULL; |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 316 | return; |
| 317 | case ASYNC_ERROR: |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 318 | fbupdatenotify_delete(descr); |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 319 | proxy_fb->fb_update_head = proxy_fb->fb_update_tail = NULL; |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 320 | return; |
| 321 | case ASYNC_NEED_MORE: |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 322 | // Update transfer will eventually complete in _proxyFb_io_fun |
Vladimir Chtchetkine | e95660a | 2010-12-20 08:28:03 -0800 | [diff] [blame] | 323 | return; |
| 324 | } |
| 325 | } |
Vladimir Chtchetkine | 8acf4e2 | 2010-12-21 07:14:17 -0800 | [diff] [blame] | 326 | |
| 327 | int |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 328 | proxyFb_get_bits_per_pixel(ProxyFramebuffer* proxy_fb) |
Vladimir Chtchetkine | 8acf4e2 | 2010-12-21 07:14:17 -0800 | [diff] [blame] | 329 | { |
Vladimir Chtchetkine | 94a2fba | 2011-01-31 10:49:06 -0800 | [diff] [blame^] | 330 | return (proxy_fb != NULL && proxy_fb->fb != NULL) ? |
| 331 | proxy_fb->fb->bits_per_pixel : -1; |
Vladimir Chtchetkine | 8acf4e2 | 2010-12-21 07:14:17 -0800 | [diff] [blame] | 332 | } |