Changes in uspace/srv/hid/rfb/main.c [4c6fd56:0d62c10] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/rfb/main.c
r4c6fd56 r0d62c10 1 1 /* 2 * Copyright (c) 2023 Jiri Svoboda3 2 * Copyright (c) 2013 Martin Sucha 4 3 * All rights reserved. … … 51 50 static errno_t rfb_ddev_get_info(void *, ddev_info_t *); 52 51 53 static errno_t rfb_gc_set_clip_rect(void *, gfx_rect_t *);54 52 static errno_t rfb_gc_set_color(void *, gfx_color_t *); 55 53 static errno_t rfb_gc_fill_rect(void *, gfx_rect_t *); … … 68 66 rfb_t rfb; 69 67 pixel_t color; 70 gfx_rect_t rect;71 gfx_rect_t clip_rect;72 68 } rfb_gc_t; 73 69 … … 82 78 83 79 static gfx_context_ops_t rfb_gc_ops = { 84 .set_clip_rect = rfb_gc_set_clip_rect,85 80 .set_color = rfb_gc_set_color, 86 81 .fill_rect = rfb_gc_fill_rect, … … 139 134 } 140 135 141 /** Create RFB GC.142 *143 * @param rrgb Place to store pointer to new RFB GC144 * @return EOK on success, ENOMEM if out of memory145 */146 static errno_t rgb_gc_create(rfb_gc_t **rrfb)147 {148 rfb_gc_t *rfb;149 150 rfb = calloc(1, sizeof(rfb_gc_t));151 if (rfb == NULL)152 return ENOMEM;153 154 *rrfb = rfb;155 return EOK;156 }157 158 /** Destroy RFB GC.159 *160 * @param rfb RFB GC161 */162 static void rfb_gc_destroy(rfb_gc_t *rfb)163 {164 free(rfb);165 }166 167 /** Set clipping rectangle on RFB.168 *169 * @param arg RFB170 * @param rect Rectangle or @c NULL171 *172 * @return EOK on success or an error code173 */174 static errno_t rfb_gc_set_clip_rect(void *arg, gfx_rect_t *rect)175 {176 rfb_gc_t *rfb = (rfb_gc_t *) arg;177 178 if (rect != NULL)179 gfx_rect_clip(rect, &rfb->rect, &rfb->clip_rect);180 else181 rfb->clip_rect = rfb->rect;182 183 return EOK;184 }185 186 136 /** Set color on RFB. 187 137 * … … 213 163 { 214 164 rfb_gc_t *rfb = (rfb_gc_t *) arg; 215 gfx_rect_t crect;216 165 gfx_coord_t x, y; 217 166 218 gfx_rect_clip(rect, &rfb->clip_rect, &crect);219 220 for (y = crect.p0.y; y < crect.p1.y; y++) {221 for (x = crect.p0.x; x < crect.p1.x; x++) {167 // XXX We should handle p0.x > p1.x and p0.y > p1.y 168 169 for (y = rect->p0.y; y < rect->p1.y; y++) { 170 for (x = rect->p0.x; x < rect->p1.x; x++) { 222 171 pixelmap_put_pixel(&rfb->rfb.framebuffer, x, y, 223 172 rfb->color); … … 225 174 } 226 175 227 rfb_gc_invalidate_rect(rfb, &crect);176 rfb_gc_invalidate_rect(rfb, rect); 228 177 229 178 return EOK; … … 309 258 gfx_rect_t srect; 310 259 gfx_rect_t drect; 311 gfx_rect_t crect;312 260 gfx_coord2_t offs; 313 261 gfx_coord2_t bmdim; … … 331 279 /* Destination rectangle */ 332 280 gfx_rect_translate(&offs, &srect, &drect); 333 gfx_rect_clip(&drect, &rfbbm->rfb->clip_rect, &crect); 334 gfx_coord2_subtract(&crect.p1, &crect.p0, &dim); 281 gfx_coord2_subtract(&drect.p1, &drect.p0, &dim); 335 282 gfx_coord2_subtract(&rfbbm->rect.p1, &rfbbm->rect.p0, &bmdim); 336 283 … … 373 320 } 374 321 375 rfb_gc_invalidate_rect(rfbbm->rfb, & crect);322 rfb_gc_invalidate_rect(rfbbm->rfb, &drect); 376 323 377 324 return EOK; … … 399 346 { 400 347 rfb_t *rfb = (rfb_t *) arg; 401 rfb_gc_t *rfbgc;402 348 ddev_srv_t srv; 403 349 sysarg_t svc_id; … … 416 362 ddev_conn(icall, &srv); 417 363 } else { 418 rc = rgb_gc_create(&rfbgc);364 rc = gfx_context_new(&rfb_gc_ops, (void *) rfb, &gc); 419 365 if (rc != EOK) { 420 366 async_answer_0(icall, ENOMEM); … … 422 368 } 423 369 424 rfbgc->rect.p0.x = 0;425 rfbgc->rect.p0.y = 0;426 rfbgc->rect.p1.x = rfb->width;427 rfbgc->rect.p1.y = rfb->height;428 rfbgc->clip_rect = rfbgc->rect;429 430 rc = gfx_context_new(&rfb_gc_ops, (void *) rfbgc, &gc);431 if (rc != EOK) {432 rfb_gc_destroy(rfbgc);433 async_answer_0(icall, ENOMEM);434 return;435 }436 437 370 /* GC connection */ 438 371 gc_conn(icall, gc); … … 443 376 { 444 377 rfb_t rfb; 445 loc_srv_t *srv;446 378 447 379 log_init(NAME); … … 483 415 async_set_fallback_port_handler(client_connection, &rfb); 484 416 485 errno_t rc = loc_server_register(NAME , &srv);417 errno_t rc = loc_server_register(NAME); 486 418 if (rc != EOK) { 487 419 printf("%s: Unable to register server.\n", NAME); … … 498 430 service_id_t service_id; 499 431 500 rc = loc_service_register(s rv, service_name, &service_id);432 rc = loc_service_register(service_name, &service_id); 501 433 if (rc != EOK) { 502 434 printf(NAME ": Unable to register service %s.\n", service_name); … … 513 445 } 514 446 515 rc = loc_service_add_to_cat(s rv, service_id, ddev_cid);447 rc = loc_service_add_to_cat(service_id, ddev_cid); 516 448 if (rc != EOK) { 517 449 fprintf(stderr, NAME ": Unable to add service to display device category.\n");
Note:
See TracChangeset
for help on using the changeset viewer.