Changeset 8ce56a6 in mainline


Ignore:
Timestamp:
2021-09-07T08:53:42Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ebb3538
Parents:
a0aeb8f
git-author:
Jiri Svoboda <jiri@…> (2021-09-06 17:53:32)
git-committer:
Jiri Svoboda <jiri@…> (2021-09-07 08:53:42)
Message:

Translate window rendering in console/SSR with translation GC

In full-screen mode (such as text/console) and server-side rendering
we need other mechanism than memory GC to translate the coordinates
while rendering. We use a translation GC (xlategc).

Note the extensively elaborate testing of this very simple GC seems
quite overboard. At least the very elaborate test_gc_t could be hoisted
into a library and used wherever a test GC is required.

Location:
uspace/lib
Files:
5 added
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/memgfx/meson.build

    ra0aeb8f r8ce56a6  
    11#
    2 # Copyright (c) 2020 Jiri Svoboda
     2# Copyright (c) 2021 Jiri Svoboda
    33# All rights reserved.
    44#
     
    2929deps = [ 'gfx' ]
    3030src = files(
    31         'src/memgc.c'
     31        'src/memgc.c',
     32        'src/xlategc.c'
    3233)
    3334
     
    3536        'test/main.c',
    3637        'test/memgfx.c',
     38        'test/xlategc.c'
    3739)
  • uspace/lib/memgfx/private/memgc.h

    ra0aeb8f r8ce56a6  
    2727 */
    2828
    29 /** @addtogroup libguigfx
     29/** @addtogroup libmemgfx
    3030 * @{
    3131 */
     
    6363/** Bitmap in memory GC */
    6464typedef struct {
    65         /** Containing canvas GC */
     65        /** Containing memory GC */
    6666        struct mem_gc *mgc;
    6767        /** Allocation info */
  • uspace/lib/memgfx/test/main.c

    ra0aeb8f r8ce56a6  
    11/*
    2  * Copyright (c) 2020 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3232
    3333PCUT_IMPORT(memgfx);
     34PCUT_IMPORT(xlategc);
    3435
    3536PCUT_MAIN();
  • uspace/lib/ui/private/window.h

    ra0aeb8f r8ce56a6  
    4646#include <io/pos_event.h>
    4747#include <memgfx/memgc.h>
     48#include <memgfx/xlategc.h>
    4849#include <types/ui/cursor.h>
    4950#include <types/ui/window.h>
     
    7071        /** Window memory GC (if client-side rendering) */
    7172        mem_gc_t *mgc;
     73        /** Translating GC (if full screen & server-side rendering) */
     74        xlate_gc_t *xgc;
    7275        /** Real window GC (if client-side rendering) */
    7376        gfx_context_t *realgc;
  • uspace/lib/ui/src/ui.c

    ra0aeb8f r8ce56a6  
    248248        case CEV_POS:
    249249                pos = event->ev.pos;
    250 #ifdef CONFIG_UI_CS_RENDER
    251                 /*
    252                  * TODO Enable translation for server-side rendering
    253                  * once we can translate rendering operations in this
    254                  * case.
    255                  */
     250                /* Translate event to window-relative coordinates */
    256251                pos.hpos -= awnd->dpos.x;
    257252                pos.vpos -= awnd->dpos.y;
    258 #endif
    259253
    260254                claim = ui_wdecor_pos_event(awnd->wdecor, &pos);
  • uspace/lib/ui/src/window.c

    ra0aeb8f r8ce56a6  
    205205        gfx_bitmap_alloc_t alloc;
    206206        gfx_bitmap_t *bmp = NULL;
     207        gfx_coord2_t off;
    207208        mem_gc_t *memgc = NULL;
     209        xlate_gc_t *xgc = NULL;
    208210        errno_t rc;
    209211
     
    297299        window->gc = mem_gc_get_ctx(memgc);
    298300        window->realgc = gc;
     301        (void) off;
    299302#else
     303        /* Server-side rendering */
     304
     305        /* Full-screen mode? */
     306        if (ui->display == NULL) {
     307                /* Create translating GC to translate window contents */
     308                off.x = 0;
     309                off.y = 0;
     310                rc = xlate_gc_create(&off, gc, &xgc);
     311                if (rc != EOK)
     312                        goto error;
     313
     314                window->xgc = xgc;
     315                window->gc = xlate_gc_get_ctx(xgc);
     316                window->realgc = gc;
     317        } else {
     318                window->gc = gc;
     319        }
     320
    300321        (void) ui_window_mem_gc_cb;
    301322        (void) alloc;
    302323        (void) bparams;
    303         window->gc = gc;
    304324#endif
    305         if (ui->display == NULL)
     325        if (ui->display == NULL) {
    306326                ui_window_place(window, &ui->rect, params, &window->dpos);
     327                FILE *f = fopen("/tmp/x", "at");
     328                fprintf(f, "xlate_gc_set_off: %d,%d\n",
     329                    window->dpos.x, window->dpos.y);
     330                fclose(f);
     331
     332                if (window->xgc != NULL)
     333                        xlate_gc_set_off(window->xgc, &window->dpos);
     334        }
    307335
    308336        rc = ui_resource_create(window->gc, ui_is_textmode(ui), &res);
     
    335363        if (memgc != NULL)
    336364                mem_gc_delete(memgc);
     365        if (xgc != NULL)
     366                xlate_gc_delete(xgc);
    337367        if (bmp != NULL)
    338368                gfx_bitmap_destroy(bmp);
Note: See TracChangeset for help on using the changeset viewer.