Changes in / [455241b:b39441a] in mainline


Ignore:
Files:
2 added
34 edited

Legend:

Unmodified
Added
Removed
  • boot/arch/riscv64/src/asm.S

    r455241b rb39441a  
    108108        or t0, t0, t1
    109109
    110         csrw sptbr, t0
     110        csrw satp, t0
    111111
    112112        /* Jump to supervisor mode */
  • kernel/arch/riscv64/src/mm/page.c

    r455241b rb39441a  
    8585
    8686        asm volatile (
    87             "csrw sptbr, %[satp]\n"
    88             :: [satp] "r" (satp)
     87            "csrw satp, %[satpv]\n"
     88            :: [satpv] "r" (satp)
    8989        );
    9090}
  • tools/toolchain.sh

    r455241b rb39441a  
    3131BINUTILS_GDB_GIT="https://github.com/HelenOS/binutils-gdb.git"
    3232
    33 BINUTILS_BRANCH="binutils-2_41-helenos"
    34 BINUTILS_VERSION="2.41"
     33BINUTILS_BRANCH="binutils-2_43-helenos"
     34BINUTILS_VERSION="2.43"
    3535
    3636GDB_BRANCH="gdb-13.2-helenos"
     
    3838
    3939GCC_GIT="https://github.com/HelenOS/gcc.git"
    40 GCC_BRANCH="13_2_0-helenos"
    41 GCC_VERSION="13.2"
     40GCC_BRANCH="14_2_0-helenos"
     41GCC_VERSION="14.2"
    4242
    4343BASEDIR="$PWD"
     
    419419                --enable-languages=c,c++,go \
    420420                --enable-lto \
     421                --enable-obsolete \
    421422                --disable-shared \
    422423                --disable-werror \
  • uspace/app/shutdown-dlg/shutdown-dlg.c

    r455241b rb39441a  
    11/*
    2  * Copyright (c) 2024 Jiri Svoboda
     2 * Copyright (c) 2025 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4141#include <ui/fixed.h>
    4242#include <ui/label.h>
     43#include <ui/msgdialog.h>
    4344#include <ui/resource.h>
    4445#include <ui/ui.h>
     
    4849static void wnd_close(ui_window_t *, void *);
    4950static errno_t bg_wnd_paint(ui_window_t *, void *);
     51static void shutdown_progress_destroy(shutdown_progress_t *);
     52static errno_t shutdown_confirm_msg_create(shutdown_dlg_t *);
     53static errno_t shutdown_failed_msg_create(shutdown_dlg_t *);
     54static errno_t shutdown_start(shutdown_dlg_t *);
    5055
    5156static ui_window_cb_t bg_window_cb = {
     
    6469        .shutdown_complete = sd_shutdown_complete,
    6570        .shutdown_failed = sd_shutdown_failed
     71};
     72
     73static void shutdown_confirm_msg_button(ui_msg_dialog_t *, void *, unsigned);
     74static void shutdown_confirm_msg_close(ui_msg_dialog_t *, void *);
     75
     76static ui_msg_dialog_cb_t shutdown_confirm_msg_cb = {
     77        .button = shutdown_confirm_msg_button,
     78        .close = shutdown_confirm_msg_close
     79};
     80
     81static void shutdown_failed_msg_button(ui_msg_dialog_t *, void *, unsigned);
     82static void shutdown_failed_msg_close(ui_msg_dialog_t *, void *);
     83
     84static ui_msg_dialog_cb_t shutdown_failed_msg_cb = {
     85        .button = shutdown_failed_msg_button,
     86        .close = shutdown_failed_msg_close
    6687};
    6788
     
    90111
    91112        ui_lock(sddlg->ui);
    92         (void)ui_label_set_text(sddlg->progress->label, "Shutdown failed.");
    93         (void)ui_window_paint(sddlg->progress->window);
     113        shutdown_progress_destroy(sddlg->progress);
     114        sddlg->progress = NULL;
     115        ui_window_destroy(sddlg->bgwindow);
     116        sddlg->bgwindow = NULL;
     117        (void)shutdown_failed_msg_create(sddlg);
    94118        ui_unlock(sddlg->ui);
    95119}
     
    135159
    136160        return EOK;
     161}
     162
     163/** Create shutdown confirmation dialog.
     164 *
     165 * @param sddlg Shutdown dialog
     166 * @return EOK on success or an error code
     167 */
     168static errno_t shutdown_confirm_msg_create(shutdown_dlg_t *sddlg)
     169{
     170        ui_msg_dialog_params_t params;
     171        ui_msg_dialog_t *dialog;
     172        errno_t rc;
     173
     174        ui_msg_dialog_params_init(&params);
     175        params.caption = "Shutdown";
     176        params.text = "Do you want to shut the system down?";
     177        params.choice = umdc_ok_cancel;
     178        params.flags |= umdf_topmost | umdf_center;
     179
     180        rc = ui_msg_dialog_create(sddlg->ui, &params, &dialog);
     181        if (rc != EOK)
     182                return rc;
     183
     184        ui_msg_dialog_set_cb(dialog, &shutdown_confirm_msg_cb, sddlg);
     185
     186        return EOK;
     187}
     188
     189/** Create 'shutdown failed' message dialog.
     190 *
     191 * @param sddlg Shutdown dialog
     192 * @return EOK on success or an error code
     193 */
     194static errno_t shutdown_failed_msg_create(shutdown_dlg_t *sddlg)
     195{
     196        ui_msg_dialog_params_t params;
     197        ui_msg_dialog_t *dialog;
     198        errno_t rc;
     199
     200        ui_msg_dialog_params_init(&params);
     201        params.caption = "Shutdown failed";
     202        params.text = "The system failed to shut down properly.";
     203
     204        rc = ui_msg_dialog_create(sddlg->ui, &params, &dialog);
     205        if (rc != EOK)
     206                return rc;
     207
     208        ui_msg_dialog_set_cb(dialog, &shutdown_failed_msg_cb, sddlg);
     209
     210        return EOK;
     211}
     212
     213/** Shutdown confirm message dialog button press.
     214 *
     215 * @param dialog Message dialog
     216 * @param arg Argument (ui_demo_t *)
     217 * @param bnum Button number
     218 */
     219static void shutdown_confirm_msg_button(ui_msg_dialog_t *dialog,
     220    void *arg, unsigned bnum)
     221{
     222        shutdown_dlg_t *sddlg = (shutdown_dlg_t *) arg;
     223
     224        ui_msg_dialog_destroy(dialog);
     225
     226        if (bnum == 0)
     227                shutdown_start(sddlg);
     228        else
     229                ui_quit(sddlg->ui);
     230}
     231
     232/** Shutdown confirm message dialog close request.
     233 *
     234 * @param dialog Message dialog
     235 * @param arg Argument (ui_demo_t *)
     236 */
     237static void shutdown_confirm_msg_close(ui_msg_dialog_t *dialog, void *arg)
     238{
     239        shutdown_dlg_t *sddlg = (shutdown_dlg_t *) arg;
     240
     241        ui_msg_dialog_destroy(dialog);
     242        ui_quit(sddlg->ui);
     243}
     244
     245/** Shutdown faield message dialog button press.
     246 *
     247 * @param dialog Message dialog
     248 * @param arg Argument (ui_demo_t *)
     249 * @param bnum Button number
     250 */
     251static void shutdown_failed_msg_button(ui_msg_dialog_t *dialog,
     252    void *arg, unsigned bnum)
     253{
     254        shutdown_dlg_t *sddlg = (shutdown_dlg_t *) arg;
     255
     256        ui_msg_dialog_destroy(dialog);
     257        ui_quit(sddlg->ui);
     258}
     259
     260/** Shutdown failed message dialog close request.
     261 *
     262 * @param dialog Message dialog
     263 * @param arg Argument (ui_demo_t *)
     264 */
     265static void shutdown_failed_msg_close(ui_msg_dialog_t *dialog, void *arg)
     266{
     267        shutdown_dlg_t *sddlg = (shutdown_dlg_t *) arg;
     268
     269        ui_msg_dialog_destroy(dialog);
     270        ui_quit(sddlg->ui);
    137271}
    138272
     
    162296                params.rect.p0.x = 0;
    163297                params.rect.p0.y = 0;
    164                 params.rect.p1.x = 24;
     298                params.rect.p1.x = 64;
    165299                params.rect.p1.y = 5;
    166300        } else {
     
    245379static void shutdown_progress_destroy(shutdown_progress_t *progress)
    246380{
     381        if (progress == NULL)
     382                return;
     383
    247384        ui_window_destroy(progress->window);
    248385        free(progress);
    249386}
    250387
     388static errno_t shutdown_start(shutdown_dlg_t *sddlg)
     389{
     390        errno_t rc;
     391
     392        rc = shutdown_progress_create(sddlg, &sddlg->progress);
     393        if (rc != EOK)
     394                return rc;
     395
     396        rc = system_open(SYSTEM_DEFAULT, &sd_system_cb, sddlg, &sddlg->system);
     397        if (rc != EOK) {
     398                printf("Failed opening system control service.\n");
     399                goto error;
     400        }
     401
     402        rc = system_shutdown(sddlg->system);
     403        if (rc != EOK) {
     404                printf("Failed requesting system shutdown.\n");
     405                goto error;
     406        }
     407
     408        return EOK;
     409error:
     410        return rc;
     411}
     412
    251413/** Run shutdown dialog on display. */
    252414static errno_t shutdown_dlg(const char *display_spec)
    253415{
    254416        ui_t *ui = NULL;
     417        shutdown_dlg_t sddlg;
    255418        ui_wnd_params_t params;
    256         ui_window_t *window = NULL;
    257         shutdown_dlg_t sddlg;
    258419        errno_t rc;
    259420
     
    265426                goto error;
    266427        }
     428
     429        sddlg.ui = ui;
    267430
    268431        ui_wnd_params_init(&params);
     
    271434        params.placement = ui_wnd_place_full_screen;
    272435        params.flags |= ui_wndf_topmost | ui_wndf_nofocus;
    273         if (ui_is_textmode(ui)) {
    274                 params.rect.p0.x = 0;
    275                 params.rect.p0.y = 0;
    276                 params.rect.p1.x = 24;
    277                 params.rect.p1.y = 5;
     436        /*
     437         * params.rect.p0.x = 0;
     438         * params.rect.p0.y = 0;
     439         * params.rect.p1.x = 1;
     440         * params.rect.p1.y = 1;
     441         */
     442
     443        rc = ui_window_create(sddlg.ui, &params, &sddlg.bgwindow);
     444        if (rc != EOK) {
     445                printf("Error creating window.\n");
     446                goto error;
     447        }
     448
     449        ui_window_set_cb(sddlg.bgwindow, &bg_window_cb, (void *)&sddlg);
     450
     451        if (ui_is_textmode(sddlg.ui)) {
     452                rc = gfx_color_new_ega(0x17, &sddlg.bg_color);
     453                if (rc != EOK) {
     454                        printf("Error allocating color.\n");
     455                        goto error;
     456                }
    278457        } else {
    279                 params.rect.p0.x = 0;
    280                 params.rect.p0.y = 0;
    281                 params.rect.p1.x = 300;
    282                 params.rect.p1.y = 60;
    283         }
    284 
    285         sddlg.ui = ui;
    286 
    287         rc = ui_window_create(ui, &params, &window);
    288         if (rc != EOK) {
    289                 printf("Error creating window.\n");
    290                 goto error;
    291         }
    292 
    293         ui_window_set_cb(window, &bg_window_cb, (void *) &sddlg);
    294         sddlg.bgwindow = window;
    295 
    296         rc = gfx_color_new_rgb_i16(0x8000, 0xc800, 0xffff, &sddlg.bg_color);
    297         if (rc != EOK) {
    298                 printf("Error allocating color.\n");
    299                 goto error;
    300         }
    301 
    302         rc = ui_window_paint(window);
     458                rc = gfx_color_new_rgb_i16(0x8000, 0xc800, 0xffff, &sddlg.bg_color);
     459                if (rc != EOK) {
     460                        printf("Error allocating color.\n");
     461                        goto error;
     462                }
     463        }
     464
     465        rc = ui_window_paint(sddlg.bgwindow);
    303466        if (rc != EOK) {
    304467                printf("Error painting window.\n");
     
    306469        }
    307470
    308         rc = shutdown_progress_create(&sddlg, &sddlg.progress);
    309         if (rc != EOK)
    310                 return rc;
    311 
    312         rc = system_open(SYSTEM_DEFAULT, &sd_system_cb, &sddlg, &sddlg.system);
    313         if (rc != EOK) {
    314                 printf("Failed opening system control service.\n");
    315                 goto error;
    316         }
    317 
    318         rc = system_shutdown(sddlg.system);
    319         if (rc != EOK) {
    320                 printf("Failed requesting system shutdown.\n");
    321                 goto error;
    322         }
     471        (void)shutdown_confirm_msg_create(&sddlg);
    323472
    324473        ui_run(ui);
    325474
    326475        shutdown_progress_destroy(sddlg.progress);
    327         ui_window_destroy(window);
    328         system_close(sddlg.system);
     476        if (sddlg.bgwindow != NULL)
     477                ui_window_destroy(sddlg.bgwindow);
     478        if (sddlg.system != NULL)
     479                system_close(sddlg.system);
    329480        gfx_color_delete(sddlg.bg_color);
    330481        ui_destroy(ui);
     
    336487        if (sddlg.bg_color != NULL)
    337488                gfx_color_delete(sddlg.bg_color);
    338         if (window != NULL)
    339                 ui_window_destroy(window);
     489        if (sddlg.bgwindow != NULL)
     490                ui_window_destroy(sddlg.bgwindow);
    340491        if (ui != NULL)
    341492                ui_destroy(ui);
  • uspace/app/taskbar/taskbar.sif

    r455241b rb39441a  
    2525<entry caption="~D~isplay Configuration" cmd="/app/display-cfg -d %d" terminal="n">
    2626</entry>
    27 <entry caption="Ta~s~kbar Configuration" cmd="/app/taskbar-cfg -d %d" terminal="n">
     27<entry caption="Taskba~r~ Configuration" cmd="/app/taskbar-cfg -d %d" terminal="n">
    2828</entry>
    2929<entry separator="y">
     
    3737<entry caption="~A~bout HelenOS" cmd="/app/aboutos -d %d" terminal="n">
    3838</entry>
     39<entry caption="~S~hut Down..." cmd="/app/shutdown-dlg -d %d" terminal="n">
     40</entry>
    3941</entries>
    4042</sif>
  • uspace/drv/block/virtio-blk/virtio-blk.c

    r455241b rb39441a  
    365365        }
    366366
    367         vdev->queues = calloc(sizeof(virtq_t), num_queues);
     367        vdev->queues = calloc(num_queues, sizeof(virtq_t));
    368368        if (!vdev->queues) {
    369369                rc = ENOMEM;
  • uspace/drv/nic/virtio-net/virtio-net.c

    r455241b rb39441a  
    221221        }
    222222
    223         vdev->queues = calloc(sizeof(virtq_t), num_queues);
     223        vdev->queues = calloc(num_queues, sizeof(virtq_t));
    224224        if (!vdev->queues) {
    225225                rc = ENOMEM;
  • uspace/lib/ata/src/ata.c

    r455241b rb39441a  
    260260                if (rc != EOK) {
    261261                        ata_msg_error(chan, "Unable to remove device %d.", i);
    262                         break;
     262                        fibril_mutex_unlock(&chan->lock);
     263                        return rc;
    263264                }
    264265        }
     
    266267        ata_bd_fini_irq(chan);
    267268        fibril_mutex_unlock(&chan->lock);
     269        free(chan);
    268270
    269271        return rc;
  • uspace/lib/c/arch/arm32/src/atomic.c

    r455241b rb39441a  
    8686}
    8787
     88unsigned char __atomic_exchange_1(volatile void *mem0, unsigned char val,
     89    int model)
     90{
     91        volatile unsigned char *mem = mem0;
     92
     93        (void) model;
     94
     95        unsigned ret;
     96
     97        /*
     98         * The following instructions between labels 1 and 2 constitute a
     99         * Restartable Atomic Seqeunce. Should the sequence be non-atomic,
     100         * the kernel will restart it.
     101         */
     102        asm volatile (
     103            "1:\n"
     104            "   adr %[ret], 1b\n"
     105            "   str %[ret], %[rp0]\n"
     106            "   adr %[ret], 2f\n"
     107            "   str %[ret], %[rp1]\n"
     108            "   ldrb %[ret], %[addr]\n"
     109            "   strb %[imm], %[addr]\n"
     110            "2:\n"
     111            : [ret] "=&r" (ret),
     112              [rp0] "=m" (ras_page[0]),
     113              [rp1] "=m" (ras_page[1]),
     114              [addr] "+m" (*mem)
     115            : [imm] "r" (val)
     116        );
     117
     118        ras_page[0] = 0;
     119        ras_page[1] = 0xffffffff;
     120
     121        return ret;
     122}
     123
     124unsigned short __atomic_exchange_2(volatile void *mem0, unsigned short val,
     125    int model)
     126{
     127        volatile unsigned short *mem = mem0;
     128
     129        (void) model;
     130
     131        unsigned ret;
     132
     133        /*
     134         * The following instructions between labels 1 and 2 constitute a
     135         * Restartable Atomic Seqeunce. Should the sequence be non-atomic,
     136         * the kernel will restart it.
     137         */
     138        asm volatile (
     139            "1:\n"
     140            "   adr %[ret], 1b\n"
     141            "   str %[ret], %[rp0]\n"
     142            "   adr %[ret], 2f\n"
     143            "   str %[ret], %[rp1]\n"
     144            "   ldrh %[ret], %[addr]\n"
     145            "   strh %[imm], %[addr]\n"
     146            "2:\n"
     147            : [ret] "=&r" (ret),
     148              [rp0] "=m" (ras_page[0]),
     149              [rp1] "=m" (ras_page[1]),
     150              [addr] "+m" (*mem)
     151            : [imm] "r" (val)
     152        );
     153
     154        ras_page[0] = 0;
     155        ras_page[1] = 0xffffffff;
     156
     157        return ret;
     158}
     159
     160unsigned __atomic_exchange_4(volatile void *mem0, unsigned val, int model)
     161{
     162        volatile unsigned *mem = mem0;
     163
     164        (void) model;
     165
     166        unsigned ret;
     167
     168        /*
     169         * The following instructions between labels 1 and 2 constitute a
     170         * Restartable Atomic Seqeunce. Should the sequence be non-atomic,
     171         * the kernel will restart it.
     172         */
     173        asm volatile (
     174            "1:\n"
     175            "   adr %[ret], 1b\n"
     176            "   str %[ret], %[rp0]\n"
     177            "   adr %[ret], 2f\n"
     178            "   str %[ret], %[rp1]\n"
     179            "   ldr %[ret], %[addr]\n"
     180            "   str %[imm], %[addr]\n"
     181            "2:\n"
     182            : [ret] "=&r" (ret),
     183              [rp0] "=m" (ras_page[0]),
     184              [rp1] "=m" (ras_page[1]),
     185              [addr] "+m" (*mem)
     186            : [imm] "r" (val)
     187        );
     188
     189        ras_page[0] = 0;
     190        ras_page[1] = 0xffffffff;
     191
     192        return ret;
     193}
     194
    88195unsigned short __atomic_fetch_add_2(volatile void *mem0, unsigned short val,
    89196    int model)
     
    164271}
    165272
     273bool __atomic_test_and_set(volatile void *ptr, int memorder)
     274{
     275        volatile unsigned char *b = ptr;
     276
     277        unsigned char orig = __atomic_exchange_n(b, (unsigned char) true, memorder);
     278        return orig != 0;
     279}
     280
    166281void __sync_synchronize(void)
    167282{
  • uspace/lib/c/generic/rtld/module.c

    r455241b rb39441a  
    398398         * be correct, "zero" offset (i.e. the total size) must be aligned
    399399         * to the strictest alignment present.
    400          * Note that the padding is actually in front of the TLS data,
    401          * not after it.
    402400         */
    403401        rtld->tls_size = ALIGN_UP(rtld->tls_size, rtld->tls_align);
    404402
    405         /* Space for the TCB. */
     403        /*
     404         * Space for the TCB.
     405         * Later, the TLS zero offset is equal to the pointer to tcb_t, so
     406         * adding the sizeof(tcb_t) block AFTER we calculated the alignment
     407         * of the remainder above is correct.
     408         */
    406409        rtld->tls_size += sizeof(tcb_t);
    407410#endif
  • uspace/lib/c/generic/thread/fibril_synch.c

    r455241b rb39441a  
    263263        futex_lock(&fibril_synch_futex);
    264264
    265         if (!frw->writers) {
     265        if (!frw->writers && list_empty(&frw->waiters)) {
    266266                /* Consider the first reader the owner. */
    267267                if (frw->readers++ == 0)
  • uspace/lib/c/generic/thread/tls.c

    r455241b rb39441a  
    5959#endif
    6060
    61 static ptrdiff_t _tcb_data_offset(void)
     61static ptrdiff_t _tcb_data_offset(const void *elf)
    6262{
    6363        const elf_segment_header_t *tls =
    64             elf_get_phdr(__progsymbols.elfstart, PT_TLS);
     64            elf_get_phdr(elf, PT_TLS);
    6565
    6666        size_t tls_align = tls ? tls->p_align : 1;
     
    8080        assert(runtime_env == NULL);
    8181#endif
    82         return (uint8_t *)__tcb_get() + _tcb_data_offset();
     82        return (uint8_t *)__tcb_get() + _tcb_data_offset(__progsymbols.elfstart);
    8383}
    8484
    8585static tcb_t *tls_make_generic(const void *elf, void *(*alloc)(size_t, size_t))
    8686{
     87        /*
     88         * See also rtld/module.c -> modules_process_tls(), where we have less
     89         * messy code for the dynamic-linking version of this.
     90         */
    8791        assert(!elf_get_phdr(elf, PT_DYNAMIC));
    8892#ifdef CONFIG_RTLD
     
    100104        assert(tls_align <= PAGE_SIZE);
    101105
     106        /*
     107         * FIXME: the calculation of alloc_size shouldn't include the alignment
     108         * of tcb_t (at least in Variant II)
     109         * See https://github.com/HelenOS/helenos/pull/240/files/4ef27ebf98a0656e09889b7d00efdec03343f1aa#r1929592924
     110         * (you will also need to fix _tcb_data_offset)
     111         */
     112
    102113#ifdef CONFIG_TLS_VARIANT_1
    103114        size_t alloc_size =
     
    114125#ifdef CONFIG_TLS_VARIANT_1
    115126        tcb_t *tcb = area;
    116         uint8_t *data = (uint8_t *)tcb + _tcb_data_offset();
     127        uint8_t *data = (uint8_t *)tcb + _tcb_data_offset(elf);
    117128        memset(tcb, 0, sizeof(*tcb));
    118129#else
    119130        uint8_t *data = area;
    120         tcb_t *tcb = (tcb_t *) (data - _tcb_data_offset());
     131        tcb_t *tcb = (tcb_t *) (data - _tcb_data_offset(elf));
    121132        memset(tcb, 0, sizeof(tcb_t));
    122133        tcb->self = tcb;
  • uspace/lib/cpp/include/__bits/io/ios.hpp

    r455241b rb39441a  
    403403                delete[] parray_;
    404404                parray_size_ = rhs.parray_size_;
    405                 parray_ = new long[parray_size_];
     405                parray_ = new void *[parray_size_];
    406406
    407407                for (size_t i = 0; i < parray_size_; ++i)
  • uspace/lib/gfxfont/src/glyph_bmp.c

    r455241b rb39441a  
    293293
    294294        /* Allocate new pixel array */
    295         npixels = calloc(sizeof(int), 1);
     295        npixels = calloc(1, sizeof(int));
    296296        if (npixels == NULL)
    297297                return ENOMEM;
     
    332332
    333333        /* Allocate new pixel array */
    334         npixels = calloc(sizeof(int), (nrect.p1.x - nrect.p0.x) *
    335             (nrect.p1.y - nrect.p0.y));
     334        npixels = calloc((nrect.p1.x - nrect.p0.x) *
     335            (nrect.p1.y - nrect.p0.y), sizeof(int));
    336336        if (npixels == NULL)
    337337                return ENOMEM;
  • uspace/lib/gfxfont/test/font.c

    r455241b rb39441a  
    3434#include "../private/font.h"
    3535#include "../private/typeface.h"
     36#include "../private/testgc.h"
    3637
    3738PCUT_INIT;
    3839
    3940PCUT_TEST_SUITE(font);
    40 
    41 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *);
    42 static errno_t testgc_set_color(void *, gfx_color_t *);
    43 static errno_t testgc_fill_rect(void *, gfx_rect_t *);
    44 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,
    45     gfx_bitmap_alloc_t *, void **);
    46 static errno_t testgc_bitmap_destroy(void *);
    47 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);
    48 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);
    49 
    50 static gfx_context_ops_t test_ops = {
    51         .set_clip_rect = testgc_set_clip_rect,
    52         .set_color = testgc_set_color,
    53         .fill_rect = testgc_fill_rect,
    54         .bitmap_create = testgc_bitmap_create,
    55         .bitmap_destroy = testgc_bitmap_destroy,
    56         .bitmap_render = testgc_bitmap_render,
    57         .bitmap_get_alloc = testgc_bitmap_get_alloc
    58 };
    59 
    60 typedef struct {
    61         gfx_bitmap_params_t bm_params;
    62         void *bm_pixels;
    63         gfx_rect_t bm_srect;
    64         gfx_coord2_t bm_offs;
    65 } test_gc_t;
    66 
    67 typedef struct {
    68         test_gc_t *tgc;
    69         gfx_bitmap_alloc_t alloc;
    70         bool myalloc;
    71 } testgc_bitmap_t;
    7241
    7342/** Test creating and destroying font */
     
    509478        height = 10;
    510479
    511         pixels = calloc(sizeof(uint32_t), width * height);
     480        pixels = calloc(width * height, sizeof(uint32_t));
    512481        PCUT_ASSERT_NOT_NULL(pixels);
    513482
     
    556525        }
    557526
    558         pixels = calloc(sizeof(uint32_t), width * height);
     527        pixels = calloc(width * height, sizeof(uint32_t));
    559528        PCUT_ASSERT_NOT_NULL(pixels);
    560529
     
    572541}
    573542
    574 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect)
    575 {
    576         return EOK;
    577 }
    578 
    579 static errno_t testgc_set_color(void *arg, gfx_color_t *color)
    580 {
    581         return EOK;
    582 }
    583 
    584 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)
    585 {
    586         return EOK;
    587 }
    588 
    589 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,
    590     gfx_bitmap_alloc_t *alloc, void **rbm)
    591 {
    592         test_gc_t *tgc = (test_gc_t *) arg;
    593         testgc_bitmap_t *tbm;
    594 
    595         tbm = calloc(1, sizeof(testgc_bitmap_t));
    596         if (tbm == NULL)
    597                 return ENOMEM;
    598 
    599         if (alloc == NULL) {
    600                 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) *
    601                     sizeof(uint32_t);
    602                 tbm->alloc.off0 = 0;
    603                 tbm->alloc.pixels = calloc(sizeof(uint32_t),
    604                     tbm->alloc.pitch * (params->rect.p1.y - params->rect.p0.y));
    605                 tbm->myalloc = true;
    606                 if (tbm->alloc.pixels == NULL) {
    607                         free(tbm);
    608                         return ENOMEM;
    609                 }
    610         } else {
    611                 tbm->alloc = *alloc;
    612         }
    613 
    614         tbm->tgc = tgc;
    615         tgc->bm_params = *params;
    616         tgc->bm_pixels = tbm->alloc.pixels;
    617         *rbm = (void *)tbm;
    618         return EOK;
    619 }
    620 
    621 static errno_t testgc_bitmap_destroy(void *bm)
    622 {
    623         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    624         if (tbm->myalloc)
    625                 free(tbm->alloc.pixels);
    626         free(tbm);
    627         return EOK;
    628 }
    629 
    630 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,
    631     gfx_coord2_t *offs)
    632 {
    633         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    634         tbm->tgc->bm_srect = *srect;
    635         tbm->tgc->bm_offs = *offs;
    636         return EOK;
    637 }
    638 
    639 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)
    640 {
    641         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    642         *alloc = tbm->alloc;
    643         return EOK;
    644 }
    645 
    646543PCUT_EXPORT(font);
  • uspace/lib/gfxfont/test/glyph.c

    r455241b rb39441a  
    3838#include <str.h>
    3939#include "../private/glyph.h"
     40#include "../private/testgc.h"
    4041
    4142PCUT_INIT;
    4243
    4344PCUT_TEST_SUITE(glyph);
    44 
    45 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *);
    46 static errno_t testgc_set_color(void *, gfx_color_t *);
    47 static errno_t testgc_fill_rect(void *, gfx_rect_t *);
    48 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,
    49     gfx_bitmap_alloc_t *, void **);
    50 static errno_t testgc_bitmap_destroy(void *);
    51 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);
    52 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);
    53 
    54 static gfx_context_ops_t test_ops = {
    55         .set_clip_rect = testgc_set_clip_rect,
    56         .set_color = testgc_set_color,
    57         .fill_rect = testgc_fill_rect,
    58         .bitmap_create = testgc_bitmap_create,
    59         .bitmap_destroy = testgc_bitmap_destroy,
    60         .bitmap_render = testgc_bitmap_render,
    61         .bitmap_get_alloc = testgc_bitmap_get_alloc
    62 };
    63 
    64 typedef struct {
    65         gfx_bitmap_params_t bm_params;
    66         void *bm_pixels;
    67         gfx_rect_t bm_srect;
    68         gfx_coord2_t bm_offs;
    69 } test_gc_t;
    70 
    71 typedef struct {
    72         test_gc_t *tgc;
    73         gfx_bitmap_alloc_t alloc;
    74         bool myalloc;
    75 } testgc_bitmap_t;
    7645
    7746/** Test creating and destroying glyph */
     
    571540}
    572541
    573 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect)
    574 {
    575         return EOK;
    576 }
    577 
    578 static errno_t testgc_set_color(void *arg, gfx_color_t *color)
    579 {
    580         return EOK;
    581 }
    582 
    583 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)
    584 {
    585         return EOK;
    586 }
    587 
    588 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,
    589     gfx_bitmap_alloc_t *alloc, void **rbm)
    590 {
    591         test_gc_t *tgc = (test_gc_t *) arg;
    592         testgc_bitmap_t *tbm;
    593 
    594         tbm = calloc(1, sizeof(testgc_bitmap_t));
    595         if (tbm == NULL)
    596                 return ENOMEM;
    597 
    598         if (alloc == NULL) {
    599                 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) *
    600                     sizeof(uint32_t);
    601                 tbm->alloc.off0 = 0;
    602                 tbm->alloc.pixels = calloc(sizeof(uint32_t),
    603                     tbm->alloc.pitch * (params->rect.p1.y - params->rect.p0.y));
    604                 tbm->myalloc = true;
    605                 if (tbm->alloc.pixels == NULL) {
    606                         free(tbm);
    607                         return ENOMEM;
    608                 }
    609         } else {
    610                 tbm->alloc = *alloc;
    611         }
    612 
    613         tbm->tgc = tgc;
    614         tgc->bm_params = *params;
    615         tgc->bm_pixels = tbm->alloc.pixels;
    616         *rbm = (void *)tbm;
    617         return EOK;
    618 }
    619 
    620 static errno_t testgc_bitmap_destroy(void *bm)
    621 {
    622         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    623         if (tbm->myalloc)
    624                 free(tbm->alloc.pixels);
    625         free(tbm);
    626         return EOK;
    627 }
    628 
    629 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,
    630     gfx_coord2_t *offs)
    631 {
    632         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    633         tbm->tgc->bm_srect = *srect;
    634         tbm->tgc->bm_offs = *offs;
    635         return EOK;
    636 }
    637 
    638 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)
    639 {
    640         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    641         *alloc = tbm->alloc;
    642         return EOK;
    643 }
    644 
    645542PCUT_EXPORT(glyph);
  • uspace/lib/gfxfont/test/glyph_bmp.c

    r455241b rb39441a  
    3434#include <pcut/pcut.h>
    3535#include "../private/glyph_bmp.h"
     36#include "../private/testgc.h"
    3637
    3738PCUT_INIT;
    3839
    3940PCUT_TEST_SUITE(glyph_bmp);
    40 
    41 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *);
    42 static errno_t testgc_set_color(void *, gfx_color_t *);
    43 static errno_t testgc_fill_rect(void *, gfx_rect_t *);
    44 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,
    45     gfx_bitmap_alloc_t *, void **);
    46 static errno_t testgc_bitmap_destroy(void *);
    47 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);
    48 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);
    49 
    50 static gfx_context_ops_t test_ops = {
    51         .set_clip_rect = testgc_set_clip_rect,
    52         .set_color = testgc_set_color,
    53         .fill_rect = testgc_fill_rect,
    54         .bitmap_create = testgc_bitmap_create,
    55         .bitmap_destroy = testgc_bitmap_destroy,
    56         .bitmap_render = testgc_bitmap_render,
    57         .bitmap_get_alloc = testgc_bitmap_get_alloc
    58 };
    59 
    60 typedef struct {
    61         gfx_bitmap_params_t bm_params;
    62         void *bm_pixels;
    63         gfx_rect_t bm_srect;
    64         gfx_coord2_t bm_offs;
    65 } test_gc_t;
    66 
    67 typedef struct {
    68         test_gc_t *tgc;
    69         gfx_bitmap_alloc_t alloc;
    70         bool myalloc;
    71 } testgc_bitmap_t;
    7241
    7342/** Test opening and closing glyph bitmap */
     
    585554}
    586555
    587 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect)
    588 {
    589         return EOK;
    590 }
    591 
    592 static errno_t testgc_set_color(void *arg, gfx_color_t *color)
    593 {
    594         return EOK;
    595 }
    596 
    597 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)
    598 {
    599         return EOK;
    600 }
    601 
    602 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,
    603     gfx_bitmap_alloc_t *alloc, void **rbm)
    604 {
    605         test_gc_t *tgc = (test_gc_t *) arg;
    606         testgc_bitmap_t *tbm;
    607 
    608         tbm = calloc(1, sizeof(testgc_bitmap_t));
    609         if (tbm == NULL)
    610                 return ENOMEM;
    611 
    612         if (alloc == NULL) {
    613                 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) *
    614                     sizeof(uint32_t);
    615                 tbm->alloc.off0 = 0;
    616                 tbm->alloc.pixels = calloc(sizeof(uint32_t),
    617                     tbm->alloc.pitch * (params->rect.p1.y - params->rect.p0.y));
    618                 tbm->myalloc = true;
    619                 if (tbm->alloc.pixels == NULL) {
    620                         free(tbm);
    621                         return ENOMEM;
    622                 }
    623         } else {
    624                 tbm->alloc = *alloc;
    625         }
    626 
    627         tbm->tgc = tgc;
    628         tgc->bm_params = *params;
    629         tgc->bm_pixels = tbm->alloc.pixels;
    630         *rbm = (void *)tbm;
    631         return EOK;
    632 }
    633 
    634 static errno_t testgc_bitmap_destroy(void *bm)
    635 {
    636         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    637         if (tbm->myalloc)
    638                 free(tbm->alloc.pixels);
    639         free(tbm);
    640         return EOK;
    641 }
    642 
    643 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,
    644     gfx_coord2_t *offs)
    645 {
    646         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    647         tbm->tgc->bm_srect = *srect;
    648         tbm->tgc->bm_offs = *offs;
    649         return EOK;
    650 }
    651 
    652 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)
    653 {
    654         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    655         *alloc = tbm->alloc;
    656         return EOK;
    657 }
    658 
    659556PCUT_EXPORT(glyph_bmp);
  • uspace/lib/gfxfont/test/text.c

    r455241b rb39441a  
    3636#include "../private/font.h"
    3737#include "../private/typeface.h"
     38#include "../private/testgc.h"
    3839
    3940PCUT_INIT;
    4041
    4142PCUT_TEST_SUITE(text);
    42 
    43 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *);
    44 static errno_t testgc_set_color(void *, gfx_color_t *);
    45 static errno_t testgc_fill_rect(void *, gfx_rect_t *);
    46 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,
    47     gfx_bitmap_alloc_t *, void **);
    48 static errno_t testgc_bitmap_destroy(void *);
    49 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);
    50 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);
    51 
    52 static gfx_context_ops_t test_ops = {
    53         .set_clip_rect = testgc_set_clip_rect,
    54         .set_color = testgc_set_color,
    55         .fill_rect = testgc_fill_rect,
    56         .bitmap_create = testgc_bitmap_create,
    57         .bitmap_destroy = testgc_bitmap_destroy,
    58         .bitmap_render = testgc_bitmap_render,
    59         .bitmap_get_alloc = testgc_bitmap_get_alloc
    60 };
    61 
    62 typedef struct {
    63         gfx_bitmap_params_t bm_params;
    64         void *bm_pixels;
    65         gfx_rect_t bm_srect;
    66         gfx_coord2_t bm_offs;
    67 } test_gc_t;
    68 
    69 typedef struct {
    70         test_gc_t *tgc;
    71         gfx_bitmap_alloc_t alloc;
    72         bool myalloc;
    73 } testgc_bitmap_t;
    7443
    7544/** Test text width computation with a dummy font */
     
    454423}
    455424
    456 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect)
    457 {
    458         return EOK;
    459 }
    460 
    461 static errno_t testgc_set_color(void *arg, gfx_color_t *color)
    462 {
    463         return EOK;
    464 }
    465 
    466 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)
    467 {
    468         return EOK;
    469 }
    470 
    471 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,
    472     gfx_bitmap_alloc_t *alloc, void **rbm)
    473 {
    474         test_gc_t *tgc = (test_gc_t *) arg;
    475         testgc_bitmap_t *tbm;
    476 
    477         tbm = calloc(1, sizeof(testgc_bitmap_t));
    478         if (tbm == NULL)
    479                 return ENOMEM;
    480 
    481         if (alloc == NULL) {
    482                 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) *
    483                     sizeof(uint32_t);
    484                 tbm->alloc.off0 = 0;
    485                 tbm->alloc.pixels = calloc(sizeof(uint32_t),
    486                     tbm->alloc.pitch * (params->rect.p1.y - params->rect.p0.y));
    487                 tbm->myalloc = true;
    488                 if (tbm->alloc.pixels == NULL) {
    489                         free(tbm);
    490                         return ENOMEM;
    491                 }
    492         } else {
    493                 tbm->alloc = *alloc;
    494         }
    495 
    496         tbm->tgc = tgc;
    497         tgc->bm_params = *params;
    498         tgc->bm_pixels = tbm->alloc.pixels;
    499         *rbm = (void *)tbm;
    500         return EOK;
    501 }
    502 
    503 static errno_t testgc_bitmap_destroy(void *bm)
    504 {
    505         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    506         if (tbm->myalloc)
    507                 free(tbm->alloc.pixels);
    508         free(tbm);
    509         return EOK;
    510 }
    511 
    512 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,
    513     gfx_coord2_t *offs)
    514 {
    515         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    516         tbm->tgc->bm_srect = *srect;
    517         tbm->tgc->bm_offs = *offs;
    518         return EOK;
    519 }
    520 
    521 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)
    522 {
    523         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    524         *alloc = tbm->alloc;
    525         return EOK;
    526 }
    527 
    528425PCUT_EXPORT(text);
  • uspace/lib/gfxfont/test/tpf.c

    r455241b rb39441a  
    3636#include "../private/font.h"
    3737#include "../private/typeface.h"
     38#include "../private/testgc.h"
    3839
    3940PCUT_INIT;
    4041
    4142PCUT_TEST_SUITE(tpf);
    42 
    43 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *);
    44 static errno_t testgc_set_color(void *, gfx_color_t *);
    45 static errno_t testgc_fill_rect(void *, gfx_rect_t *);
    46 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,
    47     gfx_bitmap_alloc_t *, void **);
    48 static errno_t testgc_bitmap_destroy(void *);
    49 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);
    50 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);
    51 
    52 static gfx_context_ops_t test_ops = {
    53         .set_clip_rect = testgc_set_clip_rect,
    54         .set_color = testgc_set_color,
    55         .fill_rect = testgc_fill_rect,
    56         .bitmap_create = testgc_bitmap_create,
    57         .bitmap_destroy = testgc_bitmap_destroy,
    58         .bitmap_render = testgc_bitmap_render,
    59         .bitmap_get_alloc = testgc_bitmap_get_alloc
    60 };
    61 
    62 typedef struct {
    63         gfx_bitmap_params_t bm_params;
    64         void *bm_pixels;
    65         gfx_rect_t bm_srect;
    66         gfx_coord2_t bm_offs;
    67 } test_gc_t;
    68 
    69 typedef struct {
    70         test_gc_t *tgc;
    71         gfx_bitmap_alloc_t alloc;
    72         bool myalloc;
    73 } testgc_bitmap_t;
    7443
    7544static const gfx_font_flags_t test_font_flags = gff_bold_italic;
     
    211180}
    212181
    213 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect)
    214 {
    215         return EOK;
    216 }
    217 
    218 static errno_t testgc_set_color(void *arg, gfx_color_t *color)
    219 {
    220         return EOK;
    221 }
    222 
    223 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)
    224 {
    225         return EOK;
    226 }
    227 
    228 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,
    229     gfx_bitmap_alloc_t *alloc, void **rbm)
    230 {
    231         test_gc_t *tgc = (test_gc_t *) arg;
    232         testgc_bitmap_t *tbm;
    233 
    234         tbm = calloc(1, sizeof(testgc_bitmap_t));
    235         if (tbm == NULL)
    236                 return ENOMEM;
    237 
    238         if (alloc == NULL) {
    239                 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) *
    240                     sizeof(uint32_t);
    241                 tbm->alloc.off0 = 0;
    242                 tbm->alloc.pixels = calloc(sizeof(uint32_t),
    243                     tbm->alloc.pitch * (params->rect.p1.y - params->rect.p0.y));
    244                 tbm->myalloc = true;
    245                 if (tbm->alloc.pixels == NULL) {
    246                         free(tbm);
    247                         return ENOMEM;
    248                 }
    249         } else {
    250                 tbm->alloc = *alloc;
    251         }
    252 
    253         tbm->tgc = tgc;
    254         tgc->bm_params = *params;
    255         tgc->bm_pixels = tbm->alloc.pixels;
    256         *rbm = (void *)tbm;
    257         return EOK;
    258 }
    259 
    260 static errno_t testgc_bitmap_destroy(void *bm)
    261 {
    262         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    263         if (tbm->myalloc)
    264                 free(tbm->alloc.pixels);
    265         free(tbm);
    266         return EOK;
    267 }
    268 
    269 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,
    270     gfx_coord2_t *offs)
    271 {
    272         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    273         tbm->tgc->bm_srect = *srect;
    274         tbm->tgc->bm_offs = *offs;
    275         return EOK;
    276 }
    277 
    278 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)
    279 {
    280         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    281         *alloc = tbm->alloc;
    282         return EOK;
    283 }
    284 
    285182PCUT_EXPORT(tpf);
  • uspace/lib/gfxfont/test/typeface.c

    r455241b rb39441a  
    3232#include <pcut/pcut.h>
    3333#include "../private/typeface.h"
     34#include "../private/testgc.h"
    3435
    3536PCUT_INIT;
    3637
    3738PCUT_TEST_SUITE(typeface);
    38 
    39 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *);
    40 static errno_t testgc_set_color(void *, gfx_color_t *);
    41 static errno_t testgc_fill_rect(void *, gfx_rect_t *);
    42 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,
    43     gfx_bitmap_alloc_t *, void **);
    44 static errno_t testgc_bitmap_destroy(void *);
    45 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);
    46 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);
    47 
    48 static gfx_context_ops_t test_ops = {
    49         .set_clip_rect = testgc_set_clip_rect,
    50         .set_color = testgc_set_color,
    51         .fill_rect = testgc_fill_rect,
    52         .bitmap_create = testgc_bitmap_create,
    53         .bitmap_destroy = testgc_bitmap_destroy,
    54         .bitmap_render = testgc_bitmap_render,
    55         .bitmap_get_alloc = testgc_bitmap_get_alloc
    56 };
    57 
    58 typedef struct {
    59         gfx_bitmap_params_t bm_params;
    60         void *bm_pixels;
    61         gfx_rect_t bm_srect;
    62         gfx_coord2_t bm_offs;
    63 } test_gc_t;
    64 
    65 typedef struct {
    66         test_gc_t *tgc;
    67         gfx_bitmap_alloc_t alloc;
    68         bool myalloc;
    69 } testgc_bitmap_t;
    7039
    7140/** Test creating and destroying typeface */
     
    9867}
    9968
    100 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect)
    101 {
    102         return EOK;
    103 }
    104 
    105 static errno_t testgc_set_color(void *arg, gfx_color_t *color)
    106 {
    107         return EOK;
    108 }
    109 
    110 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)
    111 {
    112         return EOK;
    113 }
    114 
    115 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,
    116     gfx_bitmap_alloc_t *alloc, void **rbm)
    117 {
    118         test_gc_t *tgc = (test_gc_t *) arg;
    119         testgc_bitmap_t *tbm;
    120 
    121         tbm = calloc(1, sizeof(testgc_bitmap_t));
    122         if (tbm == NULL)
    123                 return ENOMEM;
    124 
    125         if (alloc == NULL) {
    126                 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) *
    127                     sizeof(uint32_t);
    128                 tbm->alloc.off0 = 0;
    129                 tbm->alloc.pixels = calloc(sizeof(uint32_t),
    130                     tbm->alloc.pitch * (params->rect.p1.y - params->rect.p0.y));
    131                 tbm->myalloc = true;
    132                 if (tbm->alloc.pixels == NULL) {
    133                         free(tbm);
    134                         return ENOMEM;
    135                 }
    136         } else {
    137                 tbm->alloc = *alloc;
    138         }
    139 
    140         tbm->tgc = tgc;
    141         tgc->bm_params = *params;
    142         tgc->bm_pixels = tbm->alloc.pixels;
    143         *rbm = (void *)tbm;
    144         return EOK;
    145 }
    146 
    147 static errno_t testgc_bitmap_destroy(void *bm)
    148 {
    149         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    150         if (tbm->myalloc)
    151                 free(tbm->alloc.pixels);
    152         free(tbm);
    153         return EOK;
    154 }
    155 
    156 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,
    157     gfx_coord2_t *offs)
    158 {
    159         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    160         tbm->tgc->bm_srect = *srect;
    161         tbm->tgc->bm_offs = *offs;
    162         return EOK;
    163 }
    164 
    165 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)
    166 {
    167         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    168         *alloc = tbm->alloc;
    169         return EOK;
    170 }
    171 
    17269PCUT_EXPORT(typeface);
  • uspace/lib/trackmod/protracker.c

    r455241b rb39441a  
    146146
    147147        cells = module->channels * protracker_pattern_rows;
    148         buf = calloc(sizeof(uint32_t), cells);
     148        buf = calloc(cells, sizeof(uint32_t));
    149149
    150150        if (buf == NULL) {
     
    156156                module->pattern[i].rows = protracker_pattern_rows;
    157157                module->pattern[i].channels = module->channels;
    158                 module->pattern[i].data = calloc(sizeof(trackmod_cell_t), cells);
     158                module->pattern[i].data = calloc(cells, sizeof(trackmod_cell_t));
    159159                if (module->pattern[i].data == NULL) {
    160160                        rc = ENOMEM;
     
    326326
    327327        module->instrs = samples;
    328         module->instr = calloc(sizeof(trackmod_instr_t), samples);
     328        module->instr = calloc(samples, sizeof(trackmod_instr_t));
    329329        if (module->instr == NULL) {
    330330                printf("Out of memory.\n");
     
    334334
    335335        module->patterns = patterns;
    336         module->pattern = calloc(sizeof(trackmod_pattern_t), patterns);
     336        module->pattern = calloc(patterns, sizeof(trackmod_pattern_t));
    337337        if (module->pattern == NULL) {
    338338                printf("Out of memory.\n");
     
    343343        /* Order list */
    344344        module->ord_list_len = order_list->order_list_len;
    345         module->ord_list = calloc(sizeof(size_t), module->ord_list_len);
     345        module->ord_list = calloc(module->ord_list_len, sizeof(size_t));
    346346        if (module->ord_list == NULL) {
    347347                printf("Out of memory.\n");
  • uspace/lib/trackmod/xm.c

    r455241b rb39441a  
    6666        }
    6767
    68         module->ord_list = calloc(sizeof(size_t), module->ord_list_len);
     68        module->ord_list = calloc(module->ord_list_len, sizeof(size_t));
    6969        if (module->ord_list == NULL) {
    7070                printf("Out of memory.\n");
     
    176176        int ret;
    177177
    178         module->pattern = calloc(sizeof(trackmod_pattern_t), module->patterns);
     178        module->pattern = calloc(module->patterns, sizeof(trackmod_pattern_t));
    179179        if (module->pattern == NULL) {
    180180                rc = ENOMEM;
     
    208208                module->pattern[i].rows = rows;
    209209                module->pattern[i].channels = module->channels;
    210                 module->pattern[i].data = calloc(sizeof(trackmod_cell_t),
    211                     rows * module->channels);
     210                module->pattern[i].data = calloc(rows * module->channels,
     211                    sizeof(trackmod_cell_t));
    212212
    213213                if (module->pattern[i].data == NULL) {
  • uspace/lib/ui/include/types/ui/msgdialog.h

    r455241b rb39441a  
    5858} ui_msg_dialog_choice_t;
    5959
     60/** Message dialog flags */
     61typedef enum {
     62        /** Topmost window */
     63        umdf_topmost = 0x1,
     64        /** Place to the center of the screen */
     65        umdf_center = 0x2
     66} ui_msg_dialog_flags_t;
     67
    6068/** Message dialog parameters */
    6169typedef struct {
     
    6674        /** The choice that the user is given */
    6775        ui_msg_dialog_choice_t choice;
     76        /** Flags */
     77        ui_msg_dialog_flags_t flags;
    6878} ui_msg_dialog_params_t;
    6979
  • uspace/lib/ui/src/dummygc.c

    r455241b rb39441a  
    181181                    sizeof(uint32_t);
    182182                tbm->alloc.off0 = 0;
    183                 tbm->alloc.pixels = calloc(sizeof(uint32_t),
     183                tbm->alloc.pixels = calloc(
    184184                    (params->rect.p1.x - params->rect.p0.x) *
    185                     (params->rect.p1.y - params->rect.p0.y));
     185                    (params->rect.p1.y - params->rect.p0.y),
     186                    sizeof(uint32_t));
    186187                tbm->myalloc = true;
    187188                if (tbm->alloc.pixels == NULL) {
  • uspace/lib/ui/src/msgdialog.c

    r455241b rb39441a  
    111111        ui_wnd_params_init(&wparams);
    112112        wparams.caption = params->caption;
     113        if ((params->flags & umdf_topmost) != 0)
     114                wparams.flags |= wndf_topmost;
     115        if ((params->flags & umdf_center) != 0)
     116                wparams.placement = ui_wnd_place_center;
    113117
    114118        /* FIXME: Auto layout */
  • uspace/lib/ui/test/checkbox.c

    r455241b rb39441a  
    3636#include <ui/resource.h>
    3737#include "../private/checkbox.h"
     38#include "../private/testgc.h"
    3839
    3940PCUT_INIT;
    4041
    4142PCUT_TEST_SUITE(checkbox);
    42 
    43 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *);
    44 static errno_t testgc_set_color(void *, gfx_color_t *);
    45 static errno_t testgc_fill_rect(void *, gfx_rect_t *);
    46 static errno_t testgc_update(void *);
    47 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,
    48     gfx_bitmap_alloc_t *, void **);
    49 static errno_t testgc_bitmap_destroy(void *);
    50 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);
    51 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);
    52 
    53 static gfx_context_ops_t ops = {
    54         .set_clip_rect = testgc_set_clip_rect,
    55         .set_color = testgc_set_color,
    56         .fill_rect = testgc_fill_rect,
    57         .update = testgc_update,
    58         .bitmap_create = testgc_bitmap_create,
    59         .bitmap_destroy = testgc_bitmap_destroy,
    60         .bitmap_render = testgc_bitmap_render,
    61         .bitmap_get_alloc = testgc_bitmap_get_alloc
    62 };
    6343
    6444static void test_checkbox_switched(ui_checkbox_t *, void *, bool);
     
    7050static ui_checkbox_cb_t dummy_checkbox_cb = {
    7151};
    72 
    73 typedef struct {
    74         bool bm_created;
    75         bool bm_destroyed;
    76         gfx_bitmap_params_t bm_params;
    77         void *bm_pixels;
    78         gfx_rect_t bm_srect;
    79         gfx_coord2_t bm_offs;
    80         bool bm_rendered;
    81         bool bm_got_alloc;
    82 } test_gc_t;
    83 
    84 typedef struct {
    85         test_gc_t *tgc;
    86         gfx_bitmap_alloc_t alloc;
    87         bool myalloc;
    88 } testgc_bitmap_t;
    8952
    9053typedef struct {
     
    549512}
    550513
    551 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect)
    552 {
    553         (void) arg;
    554         (void) rect;
    555         return EOK;
    556 }
    557 
    558 static errno_t testgc_set_color(void *arg, gfx_color_t *color)
    559 {
    560         (void) arg;
    561         (void) color;
    562         return EOK;
    563 }
    564 
    565 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)
    566 {
    567         (void) arg;
    568         (void) rect;
    569         return EOK;
    570 }
    571 
    572 static errno_t testgc_update(void *arg)
    573 {
    574         (void) arg;
    575         return EOK;
    576 }
    577 
    578 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,
    579     gfx_bitmap_alloc_t *alloc, void **rbm)
    580 {
    581         test_gc_t *tgc = (test_gc_t *) arg;
    582         testgc_bitmap_t *tbm;
    583 
    584         tbm = calloc(1, sizeof(testgc_bitmap_t));
    585         if (tbm == NULL)
    586                 return ENOMEM;
    587 
    588         if (alloc == NULL) {
    589                 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) *
    590                     sizeof(uint32_t);
    591                 tbm->alloc.off0 = 0;
    592                 tbm->alloc.pixels = calloc(sizeof(uint32_t),
    593                     (params->rect.p1.x - params->rect.p0.x) *
    594                     (params->rect.p1.y - params->rect.p0.y));
    595                 tbm->myalloc = true;
    596                 if (tbm->alloc.pixels == NULL) {
    597                         free(tbm);
    598                         return ENOMEM;
    599                 }
    600         } else {
    601                 tbm->alloc = *alloc;
    602         }
    603 
    604         tbm->tgc = tgc;
    605         tgc->bm_created = true;
    606         tgc->bm_params = *params;
    607         tgc->bm_pixels = tbm->alloc.pixels;
    608         *rbm = (void *)tbm;
    609         return EOK;
    610 }
    611 
    612 static errno_t testgc_bitmap_destroy(void *bm)
    613 {
    614         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    615         if (tbm->myalloc)
    616                 free(tbm->alloc.pixels);
    617         tbm->tgc->bm_destroyed = true;
    618         free(tbm);
    619         return EOK;
    620 }
    621 
    622 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,
    623     gfx_coord2_t *offs)
    624 {
    625         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    626         tbm->tgc->bm_rendered = true;
    627         tbm->tgc->bm_srect = *srect;
    628         tbm->tgc->bm_offs = *offs;
    629         return EOK;
    630 }
    631 
    632 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)
    633 {
    634         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    635         *alloc = tbm->alloc;
    636         tbm->tgc->bm_got_alloc = true;
    637         return EOK;
    638 }
    639 
    640514static void test_checkbox_switched(ui_checkbox_t *checkbox, void *arg,
    641515    bool checked)
  • uspace/lib/ui/test/label.c

    r455241b rb39441a  
    3636#include <ui/resource.h>
    3737#include "../private/label.h"
     38#include "../private/testgc.h"
    3839
    3940PCUT_INIT;
    4041
    4142PCUT_TEST_SUITE(label);
    42 
    43 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *);
    44 static errno_t testgc_set_color(void *, gfx_color_t *);
    45 static errno_t testgc_fill_rect(void *, gfx_rect_t *);
    46 static errno_t testgc_update(void *);
    47 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,
    48     gfx_bitmap_alloc_t *, void **);
    49 static errno_t testgc_bitmap_destroy(void *);
    50 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);
    51 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);
    52 
    53 static gfx_context_ops_t ops = {
    54         .set_clip_rect = testgc_set_clip_rect,
    55         .set_color = testgc_set_color,
    56         .fill_rect = testgc_fill_rect,
    57         .update = testgc_update,
    58         .bitmap_create = testgc_bitmap_create,
    59         .bitmap_destroy = testgc_bitmap_destroy,
    60         .bitmap_render = testgc_bitmap_render,
    61         .bitmap_get_alloc = testgc_bitmap_get_alloc
    62 };
    63 
    64 typedef struct {
    65         bool bm_created;
    66         bool bm_destroyed;
    67         gfx_bitmap_params_t bm_params;
    68         void *bm_pixels;
    69         gfx_rect_t bm_srect;
    70         gfx_coord2_t bm_offs;
    71         bool bm_rendered;
    72         bool bm_got_alloc;
    73 } test_gc_t;
    74 
    75 typedef struct {
    76         test_gc_t *tgc;
    77         gfx_bitmap_alloc_t alloc;
    78         bool myalloc;
    79 } testgc_bitmap_t;
    8043
    8144typedef struct {
     
    213176}
    214177
    215 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect)
    216 {
    217         (void) arg;
    218         (void) rect;
    219         return EOK;
    220 }
    221 
    222 static errno_t testgc_set_color(void *arg, gfx_color_t *color)
    223 {
    224         (void) arg;
    225         (void) color;
    226         return EOK;
    227 }
    228 
    229 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)
    230 {
    231         (void) arg;
    232         (void) rect;
    233         return EOK;
    234 }
    235 
    236 static errno_t testgc_update(void *arg)
    237 {
    238         (void) arg;
    239         return EOK;
    240 }
    241 
    242 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,
    243     gfx_bitmap_alloc_t *alloc, void **rbm)
    244 {
    245         test_gc_t *tgc = (test_gc_t *) arg;
    246         testgc_bitmap_t *tbm;
    247 
    248         tbm = calloc(1, sizeof(testgc_bitmap_t));
    249         if (tbm == NULL)
    250                 return ENOMEM;
    251 
    252         if (alloc == NULL) {
    253                 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) *
    254                     sizeof(uint32_t);
    255                 tbm->alloc.off0 = 0;
    256                 tbm->alloc.pixels = calloc(sizeof(uint32_t),
    257                     (params->rect.p1.x - params->rect.p0.x) *
    258                     (params->rect.p1.y - params->rect.p0.y));
    259                 tbm->myalloc = true;
    260                 if (tbm->alloc.pixels == NULL) {
    261                         free(tbm);
    262                         return ENOMEM;
    263                 }
    264         } else {
    265                 tbm->alloc = *alloc;
    266         }
    267 
    268         tbm->tgc = tgc;
    269         tgc->bm_created = true;
    270         tgc->bm_params = *params;
    271         tgc->bm_pixels = tbm->alloc.pixels;
    272         *rbm = (void *)tbm;
    273         return EOK;
    274 }
    275 
    276 static errno_t testgc_bitmap_destroy(void *bm)
    277 {
    278         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    279         if (tbm->myalloc)
    280                 free(tbm->alloc.pixels);
    281         tbm->tgc->bm_destroyed = true;
    282         free(tbm);
    283         return EOK;
    284 }
    285 
    286 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,
    287     gfx_coord2_t *offs)
    288 {
    289         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    290         tbm->tgc->bm_rendered = true;
    291         tbm->tgc->bm_srect = *srect;
    292         tbm->tgc->bm_offs = *offs;
    293         return EOK;
    294 }
    295 
    296 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)
    297 {
    298         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    299         *alloc = tbm->alloc;
    300         tbm->tgc->bm_got_alloc = true;
    301         return EOK;
    302 }
    303 
    304178PCUT_EXPORT(label);
  • uspace/lib/ui/test/paint.c

    r455241b rb39441a  
    3434#include <ui/paint.h>
    3535#include <ui/resource.h>
     36#include "../private/testgc.h"
    3637
    3738PCUT_INIT;
    3839
    3940PCUT_TEST_SUITE(paint);
    40 
    41 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *);
    42 static errno_t testgc_set_color(void *, gfx_color_t *);
    43 static errno_t testgc_fill_rect(void *, gfx_rect_t *);
    44 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,
    45     gfx_bitmap_alloc_t *, void **);
    46 static errno_t testgc_bitmap_destroy(void *);
    47 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);
    48 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);
    49 
    50 static gfx_context_ops_t ops = {
    51         .set_clip_rect = testgc_set_clip_rect,
    52         .set_color = testgc_set_color,
    53         .fill_rect = testgc_fill_rect,
    54         .bitmap_create = testgc_bitmap_create,
    55         .bitmap_destroy = testgc_bitmap_destroy,
    56         .bitmap_render = testgc_bitmap_render,
    57         .bitmap_get_alloc = testgc_bitmap_get_alloc
    58 };
    59 
    60 typedef struct {
    61         bool bm_created;
    62         bool bm_destroyed;
    63         gfx_bitmap_params_t bm_params;
    64         void *bm_pixels;
    65         gfx_rect_t bm_srect;
    66         gfx_coord2_t bm_offs;
    67         bool bm_rendered;
    68         bool bm_got_alloc;
    69 } test_gc_t;
    70 
    71 typedef struct {
    72         test_gc_t *tgc;
    73         gfx_bitmap_alloc_t alloc;
    74         bool myalloc;
    75 } testgc_bitmap_t;
    7641
    7742/** Test box characters */
     
    591556}
    592557
    593 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect)
    594 {
    595         (void) arg;
    596         (void) rect;
    597         return EOK;
    598 }
    599 
    600 static errno_t testgc_set_color(void *arg, gfx_color_t *color)
    601 {
    602         (void) arg;
    603         (void) color;
    604         return EOK;
    605 }
    606 
    607 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)
    608 {
    609         (void) arg;
    610         (void) rect;
    611         return EOK;
    612 }
    613 
    614 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,
    615     gfx_bitmap_alloc_t *alloc, void **rbm)
    616 {
    617         test_gc_t *tgc = (test_gc_t *) arg;
    618         testgc_bitmap_t *tbm;
    619 
    620         tbm = calloc(1, sizeof(testgc_bitmap_t));
    621         if (tbm == NULL)
    622                 return ENOMEM;
    623 
    624         if (alloc == NULL) {
    625                 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) *
    626                     sizeof(uint32_t);
    627                 tbm->alloc.off0 = 0;
    628                 tbm->alloc.pixels = calloc(sizeof(uint32_t),
    629                     (params->rect.p1.x - params->rect.p0.x) *
    630                     (params->rect.p1.y - params->rect.p0.y));
    631                 tbm->myalloc = true;
    632                 if (tbm->alloc.pixels == NULL) {
    633                         free(tbm);
    634                         return ENOMEM;
    635                 }
    636         } else {
    637                 tbm->alloc = *alloc;
    638         }
    639 
    640         tbm->tgc = tgc;
    641         tgc->bm_created = true;
    642         tgc->bm_params = *params;
    643         tgc->bm_pixels = tbm->alloc.pixels;
    644         *rbm = (void *)tbm;
    645         return EOK;
    646 }
    647 
    648 static errno_t testgc_bitmap_destroy(void *bm)
    649 {
    650         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    651         if (tbm->myalloc)
    652                 free(tbm->alloc.pixels);
    653         tbm->tgc->bm_destroyed = true;
    654         free(tbm);
    655         return EOK;
    656 }
    657 
    658 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,
    659     gfx_coord2_t *offs)
    660 {
    661         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    662         tbm->tgc->bm_rendered = true;
    663         tbm->tgc->bm_srect = *srect;
    664         tbm->tgc->bm_offs = *offs;
    665         return EOK;
    666 }
    667 
    668 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)
    669 {
    670         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    671         *alloc = tbm->alloc;
    672         tbm->tgc->bm_got_alloc = true;
    673         return EOK;
    674 }
    675 
    676558PCUT_EXPORT(paint);
  • uspace/lib/ui/test/pbutton.c

    r455241b rb39441a  
    3636#include <ui/resource.h>
    3737#include "../private/pbutton.h"
     38#include "../private/testgc.h"
    3839
    3940PCUT_INIT;
    4041
    4142PCUT_TEST_SUITE(pbutton);
    42 
    43 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *);
    44 static errno_t testgc_set_color(void *, gfx_color_t *);
    45 static errno_t testgc_fill_rect(void *, gfx_rect_t *);
    46 static errno_t testgc_update(void *);
    47 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,
    48     gfx_bitmap_alloc_t *, void **);
    49 static errno_t testgc_bitmap_destroy(void *);
    50 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);
    51 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);
    52 
    53 static gfx_context_ops_t ops = {
    54         .set_clip_rect = testgc_set_clip_rect,
    55         .set_color = testgc_set_color,
    56         .fill_rect = testgc_fill_rect,
    57         .update = testgc_update,
    58         .bitmap_create = testgc_bitmap_create,
    59         .bitmap_destroy = testgc_bitmap_destroy,
    60         .bitmap_render = testgc_bitmap_render,
    61         .bitmap_get_alloc = testgc_bitmap_get_alloc
    62 };
    6343
    6444static void test_pbutton_clicked(ui_pbutton_t *, void *);
     
    7454static ui_pbutton_cb_t dummy_pbutton_cb = {
    7555};
    76 
    77 typedef struct {
    78         bool bm_created;
    79         bool bm_destroyed;
    80         gfx_bitmap_params_t bm_params;
    81         void *bm_pixels;
    82         gfx_rect_t bm_srect;
    83         gfx_coord2_t bm_offs;
    84         bool bm_rendered;
    85         bool bm_got_alloc;
    86 } test_gc_t;
    87 
    88 typedef struct {
    89         test_gc_t *tgc;
    90         gfx_bitmap_alloc_t alloc;
    91         bool myalloc;
    92 } testgc_bitmap_t;
    9356
    9457typedef struct {
     
    625588}
    626589
    627 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect)
    628 {
    629         (void) arg;
    630         (void) rect;
    631         return EOK;
    632 }
    633 
    634 static errno_t testgc_set_color(void *arg, gfx_color_t *color)
    635 {
    636         (void) arg;
    637         (void) color;
    638         return EOK;
    639 }
    640 
    641 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)
    642 {
    643         (void) arg;
    644         (void) rect;
    645         return EOK;
    646 }
    647 
    648 static errno_t testgc_update(void *arg)
    649 {
    650         (void) arg;
    651         return EOK;
    652 }
    653 
    654 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,
    655     gfx_bitmap_alloc_t *alloc, void **rbm)
    656 {
    657         test_gc_t *tgc = (test_gc_t *) arg;
    658         testgc_bitmap_t *tbm;
    659 
    660         tbm = calloc(1, sizeof(testgc_bitmap_t));
    661         if (tbm == NULL)
    662                 return ENOMEM;
    663 
    664         if (alloc == NULL) {
    665                 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) *
    666                     sizeof(uint32_t);
    667                 tbm->alloc.off0 = 0;
    668                 tbm->alloc.pixels = calloc(sizeof(uint32_t),
    669                     (params->rect.p1.x - params->rect.p0.x) *
    670                     (params->rect.p1.y - params->rect.p0.y));
    671                 tbm->myalloc = true;
    672                 if (tbm->alloc.pixels == NULL) {
    673                         free(tbm);
    674                         return ENOMEM;
    675                 }
    676         } else {
    677                 tbm->alloc = *alloc;
    678         }
    679 
    680         tbm->tgc = tgc;
    681         tgc->bm_created = true;
    682         tgc->bm_params = *params;
    683         tgc->bm_pixels = tbm->alloc.pixels;
    684         *rbm = (void *)tbm;
    685         return EOK;
    686 }
    687 
    688 static errno_t testgc_bitmap_destroy(void *bm)
    689 {
    690         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    691         if (tbm->myalloc)
    692                 free(tbm->alloc.pixels);
    693         tbm->tgc->bm_destroyed = true;
    694         free(tbm);
    695         return EOK;
    696 }
    697 
    698 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,
    699     gfx_coord2_t *offs)
    700 {
    701         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    702         tbm->tgc->bm_rendered = true;
    703         tbm->tgc->bm_srect = *srect;
    704         tbm->tgc->bm_offs = *offs;
    705         return EOK;
    706 }
    707 
    708 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)
    709 {
    710         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    711         *alloc = tbm->alloc;
    712         tbm->tgc->bm_got_alloc = true;
    713         return EOK;
    714 }
    715 
    716590static void test_pbutton_clicked(ui_pbutton_t *pbutton, void *arg)
    717591{
  • uspace/lib/ui/test/rbutton.c

    r455241b rb39441a  
    3636#include <ui/resource.h>
    3737#include "../private/rbutton.h"
     38#include "../private/testgc.h"
    3839
    3940PCUT_INIT;
    4041
    4142PCUT_TEST_SUITE(rbutton);
    42 
    43 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *);
    44 static errno_t testgc_set_color(void *, gfx_color_t *);
    45 static errno_t testgc_fill_rect(void *, gfx_rect_t *);
    46 static errno_t testgc_update(void *);
    47 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,
    48     gfx_bitmap_alloc_t *, void **);
    49 static errno_t testgc_bitmap_destroy(void *);
    50 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);
    51 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);
    52 
    53 static gfx_context_ops_t ops = {
    54         .set_clip_rect = testgc_set_clip_rect,
    55         .set_color = testgc_set_color,
    56         .fill_rect = testgc_fill_rect,
    57         .update = testgc_update,
    58         .bitmap_create = testgc_bitmap_create,
    59         .bitmap_destroy = testgc_bitmap_destroy,
    60         .bitmap_render = testgc_bitmap_render,
    61         .bitmap_get_alloc = testgc_bitmap_get_alloc
    62 };
    6343
    6444static void test_rbutton_select(ui_rbutton_group_t *, void *, void *);
     
    7050static ui_rbutton_group_cb_t dummy_rbutton_group_cb = {
    7151};
    72 
    73 typedef struct {
    74         bool bm_created;
    75         bool bm_destroyed;
    76         gfx_bitmap_params_t bm_params;
    77         void *bm_pixels;
    78         gfx_rect_t bm_srect;
    79         gfx_coord2_t bm_offs;
    80         bool bm_rendered;
    81         bool bm_got_alloc;
    82 } test_gc_t;
    83 
    84 typedef struct {
    85         test_gc_t *tgc;
    86         gfx_bitmap_alloc_t alloc;
    87         bool myalloc;
    88 } testgc_bitmap_t;
    8952
    9053typedef struct {
     
    592555}
    593556
    594 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect)
    595 {
    596         (void) arg;
    597         (void) rect;
    598         return EOK;
    599 }
    600 
    601 static errno_t testgc_set_color(void *arg, gfx_color_t *color)
    602 {
    603         (void) arg;
    604         (void) color;
    605         return EOK;
    606 }
    607 
    608 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)
    609 {
    610         (void) arg;
    611         (void) rect;
    612         return EOK;
    613 }
    614 
    615 static errno_t testgc_update(void *arg)
    616 {
    617         (void) arg;
    618         return EOK;
    619 }
    620 
    621 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,
    622     gfx_bitmap_alloc_t *alloc, void **rbm)
    623 {
    624         test_gc_t *tgc = (test_gc_t *) arg;
    625         testgc_bitmap_t *tbm;
    626 
    627         tbm = calloc(1, sizeof(testgc_bitmap_t));
    628         if (tbm == NULL)
    629                 return ENOMEM;
    630 
    631         if (alloc == NULL) {
    632                 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) *
    633                     sizeof(uint32_t);
    634                 tbm->alloc.off0 = 0;
    635                 tbm->alloc.pixels = calloc(sizeof(uint32_t),
    636                     (params->rect.p1.x - params->rect.p0.x) *
    637                     (params->rect.p1.y - params->rect.p0.y));
    638                 tbm->myalloc = true;
    639                 if (tbm->alloc.pixels == NULL) {
    640                         free(tbm);
    641                         return ENOMEM;
    642                 }
    643         } else {
    644                 tbm->alloc = *alloc;
    645         }
    646 
    647         tbm->tgc = tgc;
    648         tgc->bm_created = true;
    649         tgc->bm_params = *params;
    650         tgc->bm_pixels = tbm->alloc.pixels;
    651         *rbm = (void *)tbm;
    652         return EOK;
    653 }
    654 
    655 static errno_t testgc_bitmap_destroy(void *bm)
    656 {
    657         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    658         if (tbm->myalloc)
    659                 free(tbm->alloc.pixels);
    660         tbm->tgc->bm_destroyed = true;
    661         free(tbm);
    662         return EOK;
    663 }
    664 
    665 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,
    666     gfx_coord2_t *offs)
    667 {
    668         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    669         tbm->tgc->bm_rendered = true;
    670         tbm->tgc->bm_srect = *srect;
    671         tbm->tgc->bm_offs = *offs;
    672         return EOK;
    673 }
    674 
    675 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)
    676 {
    677         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    678         *alloc = tbm->alloc;
    679         tbm->tgc->bm_got_alloc = true;
    680         return EOK;
    681 }
    682 
    683557static void test_rbutton_select(ui_rbutton_group_t *group, void *arg,
    684558    void *barg)
  • uspace/lib/ui/test/resource.c

    r455241b rb39441a  
    3333#include <ui/resource.h>
    3434#include "../private/resource.h"
     35#include "../private/testgc.h"
    3536
    3637PCUT_INIT;
     
    3839PCUT_TEST_SUITE(resource);
    3940
    40 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,
    41     gfx_bitmap_alloc_t *, void **);
    42 static errno_t testgc_bitmap_destroy(void *);
    43 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);
    44 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);
    45 
    4641static void test_expose(void *);
    47 
    48 static gfx_context_ops_t ops = {
    49         .bitmap_create = testgc_bitmap_create,
    50         .bitmap_destroy = testgc_bitmap_destroy,
    51         .bitmap_render = testgc_bitmap_render,
    52         .bitmap_get_alloc = testgc_bitmap_get_alloc
    53 };
    54 
    55 typedef struct {
    56         bool bm_created;
    57         bool bm_destroyed;
    58         gfx_bitmap_params_t bm_params;
    59         void *bm_pixels;
    60         gfx_rect_t bm_srect;
    61         gfx_coord2_t bm_offs;
    62         bool bm_rendered;
    63         bool bm_got_alloc;
    64 } test_gc_t;
    65 
    66 typedef struct {
    67         test_gc_t *tgc;
    68         gfx_bitmap_alloc_t alloc;
    69         bool myalloc;
    70 } testgc_bitmap_t;
    7142
    7243typedef struct {
     
    240211}
    241212
    242 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,
    243     gfx_bitmap_alloc_t *alloc, void **rbm)
    244 {
    245         test_gc_t *tgc = (test_gc_t *) arg;
    246         testgc_bitmap_t *tbm;
    247 
    248         tbm = calloc(1, sizeof(testgc_bitmap_t));
    249         if (tbm == NULL)
    250                 return ENOMEM;
    251 
    252         if (alloc == NULL) {
    253                 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) *
    254                     sizeof(uint32_t);
    255                 tbm->alloc.off0 = 0;
    256                 tbm->alloc.pixels = calloc(sizeof(uint32_t),
    257                     (params->rect.p1.x - params->rect.p0.x) *
    258                     (params->rect.p1.y - params->rect.p0.y));
    259                 tbm->myalloc = true;
    260                 if (tbm->alloc.pixels == NULL) {
    261                         free(tbm);
    262                         return ENOMEM;
    263                 }
    264         } else {
    265                 tbm->alloc = *alloc;
    266         }
    267 
    268         tbm->tgc = tgc;
    269         tgc->bm_created = true;
    270         tgc->bm_params = *params;
    271         tgc->bm_pixels = tbm->alloc.pixels;
    272         *rbm = (void *)tbm;
    273         return EOK;
    274 }
    275 
    276 static errno_t testgc_bitmap_destroy(void *bm)
    277 {
    278         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    279         if (tbm->myalloc)
    280                 free(tbm->alloc.pixels);
    281         tbm->tgc->bm_destroyed = true;
    282         free(tbm);
    283         return EOK;
    284 }
    285 
    286 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,
    287     gfx_coord2_t *offs)
    288 {
    289         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    290         tbm->tgc->bm_rendered = true;
    291         tbm->tgc->bm_srect = *srect;
    292         tbm->tgc->bm_offs = *offs;
    293         return EOK;
    294 }
    295 
    296 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)
    297 {
    298         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    299         *alloc = tbm->alloc;
    300         tbm->tgc->bm_got_alloc = true;
    301         return EOK;
    302 }
    303 
    304213static void test_expose(void *arg)
    305214{
  • uspace/lib/ui/test/slider.c

    r455241b rb39441a  
    3636#include <ui/resource.h>
    3737#include "../private/slider.h"
     38#include "../private/testgc.h"
    3839
    3940PCUT_INIT;
    4041
    4142PCUT_TEST_SUITE(slider);
    42 
    43 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *);
    44 static errno_t testgc_set_color(void *, gfx_color_t *);
    45 static errno_t testgc_fill_rect(void *, gfx_rect_t *);
    46 static errno_t testgc_update(void *);
    47 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,
    48     gfx_bitmap_alloc_t *, void **);
    49 static errno_t testgc_bitmap_destroy(void *);
    50 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);
    51 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);
    52 
    53 static gfx_context_ops_t ops = {
    54         .set_clip_rect = testgc_set_clip_rect,
    55         .set_color = testgc_set_color,
    56         .fill_rect = testgc_fill_rect,
    57         .update = testgc_update,
    58         .bitmap_create = testgc_bitmap_create,
    59         .bitmap_destroy = testgc_bitmap_destroy,
    60         .bitmap_render = testgc_bitmap_render,
    61         .bitmap_get_alloc = testgc_bitmap_get_alloc
    62 };
    6343
    6444static void test_slider_moved(ui_slider_t *, void *, gfx_coord_t);
     
    7050static ui_slider_cb_t dummy_slider_cb = {
    7151};
    72 
    73 typedef struct {
    74         bool bm_created;
    75         bool bm_destroyed;
    76         gfx_bitmap_params_t bm_params;
    77         void *bm_pixels;
    78         gfx_rect_t bm_srect;
    79         gfx_coord2_t bm_offs;
    80         bool bm_rendered;
    81         bool bm_got_alloc;
    82 } test_gc_t;
    83 
    84 typedef struct {
    85         test_gc_t *tgc;
    86         gfx_bitmap_alloc_t alloc;
    87         bool myalloc;
    88 } testgc_bitmap_t;
    8952
    9053typedef struct {
     
    462425}
    463426
    464 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect)
    465 {
    466         (void) arg;
    467         (void) rect;
    468         return EOK;
    469 }
    470 
    471 static errno_t testgc_set_color(void *arg, gfx_color_t *color)
    472 {
    473         (void) arg;
    474         (void) color;
    475         return EOK;
    476 }
    477 
    478 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)
    479 {
    480         (void) arg;
    481         (void) rect;
    482         return EOK;
    483 }
    484 
    485 static errno_t testgc_update(void *arg)
    486 {
    487         (void) arg;
    488         return EOK;
    489 }
    490 
    491 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,
    492     gfx_bitmap_alloc_t *alloc, void **rbm)
    493 {
    494         test_gc_t *tgc = (test_gc_t *) arg;
    495         testgc_bitmap_t *tbm;
    496 
    497         tbm = calloc(1, sizeof(testgc_bitmap_t));
    498         if (tbm == NULL)
    499                 return ENOMEM;
    500 
    501         if (alloc == NULL) {
    502                 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) *
    503                     sizeof(uint32_t);
    504                 tbm->alloc.off0 = 0;
    505                 tbm->alloc.pixels = calloc(sizeof(uint32_t),
    506                     (params->rect.p1.x - params->rect.p0.x) *
    507                     (params->rect.p1.y - params->rect.p0.y));
    508                 tbm->myalloc = true;
    509                 if (tbm->alloc.pixels == NULL) {
    510                         free(tbm);
    511                         return ENOMEM;
    512                 }
    513         } else {
    514                 tbm->alloc = *alloc;
    515         }
    516 
    517         tbm->tgc = tgc;
    518         tgc->bm_created = true;
    519         tgc->bm_params = *params;
    520         tgc->bm_pixels = tbm->alloc.pixels;
    521         *rbm = (void *)tbm;
    522         return EOK;
    523 }
    524 
    525 static errno_t testgc_bitmap_destroy(void *bm)
    526 {
    527         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    528         if (tbm->myalloc)
    529                 free(tbm->alloc.pixels);
    530         tbm->tgc->bm_destroyed = true;
    531         free(tbm);
    532         return EOK;
    533 }
    534 
    535 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,
    536     gfx_coord2_t *offs)
    537 {
    538         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    539         tbm->tgc->bm_rendered = true;
    540         tbm->tgc->bm_srect = *srect;
    541         tbm->tgc->bm_offs = *offs;
    542         return EOK;
    543 }
    544 
    545 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)
    546 {
    547         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    548         *alloc = tbm->alloc;
    549         tbm->tgc->bm_got_alloc = true;
    550         return EOK;
    551 }
    552 
    553427static void test_slider_moved(ui_slider_t *slider, void *arg, gfx_coord_t pos)
    554428{
  • uspace/lib/ui/test/wdecor.c

    r455241b rb39441a  
    3737#include <ui/wdecor.h>
    3838#include "../private/wdecor.h"
     39#include "../private/testgc.h"
    3940
    4041PCUT_INIT;
    4142
    4243PCUT_TEST_SUITE(wdecor);
    43 
    44 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *);
    45 static errno_t testgc_set_color(void *, gfx_color_t *);
    46 static errno_t testgc_fill_rect(void *, gfx_rect_t *);
    47 static errno_t testgc_update(void *);
    48 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,
    49     gfx_bitmap_alloc_t *, void **);
    50 static errno_t testgc_bitmap_destroy(void *);
    51 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);
    52 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);
    53 
    54 static gfx_context_ops_t ops = {
    55         .set_clip_rect = testgc_set_clip_rect,
    56         .set_color = testgc_set_color,
    57         .fill_rect = testgc_fill_rect,
    58         .update = testgc_update,
    59         .bitmap_create = testgc_bitmap_create,
    60         .bitmap_destroy = testgc_bitmap_destroy,
    61         .bitmap_render = testgc_bitmap_render,
    62         .bitmap_get_alloc = testgc_bitmap_get_alloc
    63 };
    6444
    6545static void test_wdecor_sysmenu_open(ui_wdecor_t *, void *, sysarg_t);
     
    9373static ui_wdecor_cb_t dummy_wdecor_cb = {
    9474};
    95 
    96 typedef struct {
    97         bool bm_created;
    98         bool bm_destroyed;
    99         gfx_bitmap_params_t bm_params;
    100         void *bm_pixels;
    101         gfx_rect_t bm_srect;
    102         gfx_coord2_t bm_offs;
    103         bool bm_rendered;
    104         bool bm_got_alloc;
    105 } test_gc_t;
    106 
    107 typedef struct {
    108         test_gc_t *tgc;
    109         gfx_bitmap_alloc_t alloc;
    110         bool myalloc;
    111 } testgc_bitmap_t;
    11275
    11376typedef struct {
     
    15671530}
    15681531
    1569 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect)
    1570 {
    1571         (void) arg;
    1572         (void) rect;
    1573         return EOK;
    1574 }
    1575 
    1576 static errno_t testgc_set_color(void *arg, gfx_color_t *color)
    1577 {
    1578         (void) arg;
    1579         (void) color;
    1580         return EOK;
    1581 }
    1582 
    1583 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)
    1584 {
    1585         (void) arg;
    1586         (void) rect;
    1587         return EOK;
    1588 }
    1589 
    1590 static errno_t testgc_update(void *arg)
    1591 {
    1592         (void) arg;
    1593         return EOK;
    1594 }
    1595 
    1596 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,
    1597     gfx_bitmap_alloc_t *alloc, void **rbm)
    1598 {
    1599         test_gc_t *tgc = (test_gc_t *) arg;
    1600         testgc_bitmap_t *tbm;
    1601 
    1602         tbm = calloc(1, sizeof(testgc_bitmap_t));
    1603         if (tbm == NULL)
    1604                 return ENOMEM;
    1605 
    1606         if (alloc == NULL) {
    1607                 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) *
    1608                     sizeof(uint32_t);
    1609                 tbm->alloc.off0 = 0;
    1610                 tbm->alloc.pixels = calloc(sizeof(uint32_t),
    1611                     (params->rect.p1.x - params->rect.p0.x) *
    1612                     (params->rect.p1.y - params->rect.p0.y));
    1613                 tbm->myalloc = true;
    1614                 if (tbm->alloc.pixels == NULL) {
    1615                         free(tbm);
    1616                         return ENOMEM;
    1617                 }
    1618         } else {
    1619                 tbm->alloc = *alloc;
    1620         }
    1621 
    1622         tbm->tgc = tgc;
    1623         tgc->bm_created = true;
    1624         tgc->bm_params = *params;
    1625         tgc->bm_pixels = tbm->alloc.pixels;
    1626         *rbm = (void *)tbm;
    1627         return EOK;
    1628 }
    1629 
    1630 static errno_t testgc_bitmap_destroy(void *bm)
    1631 {
    1632         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    1633         if (tbm->myalloc)
    1634                 free(tbm->alloc.pixels);
    1635         tbm->tgc->bm_destroyed = true;
    1636         free(tbm);
    1637         return EOK;
    1638 }
    1639 
    1640 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,
    1641     gfx_coord2_t *offs)
    1642 {
    1643         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    1644         tbm->tgc->bm_rendered = true;
    1645         tbm->tgc->bm_srect = *srect;
    1646         tbm->tgc->bm_offs = *offs;
    1647         return EOK;
    1648 }
    1649 
    1650 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)
    1651 {
    1652         testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
    1653         *alloc = tbm->alloc;
    1654         tbm->tgc->bm_got_alloc = true;
    1655         return EOK;
    1656 }
    1657 
    16581532static void test_wdecor_sysmenu_open(ui_wdecor_t *wdecor, void *arg,
    16591533    sysarg_t idev_id)
  • uspace/srv/vfs/vfs_register.c

    r455241b rb39441a  
    369369        }
    370370
    371         fstypes->fstypes = calloc(sizeof(char *), count);
     371        fstypes->fstypes = calloc(count, sizeof(char *));
    372372        if (fstypes->fstypes == NULL) {
    373373                free(fstypes->buf);
Note: See TracChangeset for help on using the changeset viewer.