Changeset 8ce56a6 in mainline for uspace/lib/ui/src/window.c


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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.