[045186b] | 1 | /*
|
---|
[bd2fab5] | 2 | * Copyright (c) 2023 Jiri Svoboda
|
---|
[045186b] | 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
| 29 | /** @addtogroup gfxdemo
|
---|
| 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file Graphic demo
|
---|
| 33 | */
|
---|
| 34 |
|
---|
[a3f63ac] | 35 | #include <congfx/console.h>
|
---|
[c8cf261] | 36 | #include <display.h>
|
---|
[9259d20] | 37 | #include <fibril.h>
|
---|
[e0545de] | 38 | #include <gfx/bitmap.h>
|
---|
[045186b] | 39 | #include <gfx/color.h>
|
---|
| 40 | #include <gfx/render.h>
|
---|
[8fa65af0] | 41 | #include <gfx/font.h>
|
---|
| 42 | #include <gfx/text.h>
|
---|
| 43 | #include <gfx/typeface.h>
|
---|
[9259d20] | 44 | #include <io/console.h>
|
---|
[e0545de] | 45 | #include <io/pixelmap.h>
|
---|
[b3c185b6] | 46 | #include <stdbool.h>
|
---|
[9259d20] | 47 | #include <stdlib.h>
|
---|
[00e8290] | 48 | #include <str.h>
|
---|
[5bded44] | 49 | #include <task.h>
|
---|
[b93ec7c0] | 50 | #include <ui/ui.h>
|
---|
| 51 | #include <ui/window.h>
|
---|
| 52 | #include <ui/wdecor.h>
|
---|
[9adae25] | 53 | #include "gfxdemo.h"
|
---|
[045186b] | 54 |
|
---|
[338d0935] | 55 | static void wnd_close_event(void *);
|
---|
[b3c185b6] | 56 | static void wnd_kbd_event(void *, kbd_event_t *);
|
---|
| 57 |
|
---|
| 58 | static display_wnd_cb_t wnd_cb = {
|
---|
[338d0935] | 59 | .close_event = wnd_close_event,
|
---|
[b3c185b6] | 60 | .kbd_event = wnd_kbd_event
|
---|
| 61 | };
|
---|
| 62 |
|
---|
[b93ec7c0] | 63 | static void uiwnd_close_event(ui_window_t *, void *);
|
---|
| 64 | static void uiwnd_kbd_event(ui_window_t *, void *, kbd_event_t *);
|
---|
| 65 |
|
---|
| 66 | static ui_window_cb_t ui_window_cb = {
|
---|
| 67 | .close = uiwnd_close_event,
|
---|
| 68 | .kbd = uiwnd_kbd_event
|
---|
| 69 | };
|
---|
| 70 |
|
---|
[082feff] | 71 | static void demo_kbd_event(kbd_event_t *);
|
---|
| 72 |
|
---|
[b3c185b6] | 73 | static bool quit = false;
|
---|
[af967ef9] | 74 | static FIBRIL_MUTEX_INITIALIZE(quit_lock);
|
---|
| 75 | static FIBRIL_CONDVAR_INITIALIZE(quit_cv);
|
---|
[8dbd13d] | 76 | static gfx_typeface_t *tface;
|
---|
| 77 | static gfx_font_t *font;
|
---|
| 78 | static gfx_coord_t vpad;
|
---|
[082feff] | 79 | static console_ctrl_t *con = NULL;
|
---|
[9adae25] | 80 | static ui_t *ui;
|
---|
[b3c185b6] | 81 |
|
---|
[bc52b5b] | 82 | /** Determine if we are running in text mode.
|
---|
| 83 | *
|
---|
| 84 | * @param w Screen width
|
---|
| 85 | * @param h Screen height
|
---|
| 86 | * @return @c true iff we are running in text mode
|
---|
| 87 | */
|
---|
| 88 | static bool demo_is_text(gfx_coord_t w, gfx_coord_t h)
|
---|
| 89 | {
|
---|
| 90 | // XXX Need a proper way to determine text mode
|
---|
| 91 | return w <= 80;
|
---|
| 92 | }
|
---|
| 93 |
|
---|
[af967ef9] | 94 | /** Sleep until timeout or quit request.
|
---|
| 95 | *
|
---|
| 96 | * @param msec Number of microseconds to sleep for
|
---|
| 97 | */
|
---|
| 98 | static void demo_msleep(unsigned msec)
|
---|
| 99 | {
|
---|
[082feff] | 100 | errno_t rc;
|
---|
| 101 | usec_t usec;
|
---|
| 102 | cons_event_t cevent;
|
---|
[af967ef9] | 103 |
|
---|
[9adae25] | 104 | if (ui != NULL)
|
---|
| 105 | ui_unlock(ui);
|
---|
[082feff] | 106 | fibril_mutex_lock(&quit_lock);
|
---|
[af967ef9] | 107 | if (!quit) {
|
---|
[082feff] | 108 | if (con != NULL) {
|
---|
| 109 | usec = (usec_t)msec * 1000;
|
---|
| 110 | while (usec > 0 && !quit) {
|
---|
| 111 | rc = console_get_event_timeout(con, &cevent, &usec);
|
---|
| 112 | if (rc == EOK) {
|
---|
| 113 | if (cevent.type == CEV_KEY) {
|
---|
| 114 | fibril_mutex_unlock(&quit_lock);
|
---|
| 115 | demo_kbd_event(&cevent.ev.key);
|
---|
| 116 | fibril_mutex_lock(&quit_lock);
|
---|
| 117 | }
|
---|
| 118 | }
|
---|
| 119 | }
|
---|
| 120 | } else {
|
---|
| 121 | (void) fibril_condvar_wait_timeout(&quit_cv, &quit_lock,
|
---|
| 122 | (usec_t)msec * 1000);
|
---|
| 123 | }
|
---|
[af967ef9] | 124 | }
|
---|
| 125 | fibril_mutex_unlock(&quit_lock);
|
---|
[9adae25] | 126 | if (ui != NULL)
|
---|
| 127 | ui_lock(ui);
|
---|
[af967ef9] | 128 | }
|
---|
| 129 |
|
---|
[587b4cb] | 130 | /** Clear screen.
|
---|
| 131 | *
|
---|
| 132 | * @param gc Graphic context
|
---|
| 133 | * @param w Screen width
|
---|
| 134 | * @param h Screen height
|
---|
| 135 | */
|
---|
| 136 | static errno_t clear_scr(gfx_context_t *gc, gfx_coord_t w, gfx_coord_t h)
|
---|
| 137 | {
|
---|
| 138 | gfx_color_t *color = NULL;
|
---|
| 139 | gfx_rect_t rect;
|
---|
| 140 | errno_t rc;
|
---|
| 141 |
|
---|
| 142 | rc = gfx_color_new_rgb_i16(0, 0, 0, &color);
|
---|
| 143 | if (rc != EOK)
|
---|
| 144 | goto error;
|
---|
| 145 |
|
---|
| 146 | rc = gfx_set_color(gc, color);
|
---|
| 147 | if (rc != EOK)
|
---|
| 148 | goto error;
|
---|
| 149 |
|
---|
| 150 | rect.p0.x = 0;
|
---|
| 151 | rect.p0.y = 0;
|
---|
| 152 | rect.p1.x = w;
|
---|
| 153 | rect.p1.y = h;
|
---|
| 154 |
|
---|
| 155 | rc = gfx_fill_rect(gc, &rect);
|
---|
| 156 | if (rc != EOK)
|
---|
| 157 | goto error;
|
---|
| 158 |
|
---|
| 159 | gfx_color_delete(color);
|
---|
| 160 | return EOK;
|
---|
| 161 | error:
|
---|
| 162 | if (color != NULL)
|
---|
| 163 | gfx_color_delete(color);
|
---|
| 164 | return rc;
|
---|
| 165 | }
|
---|
| 166 |
|
---|
[8dbd13d] | 167 | /** Initialize demo font.
|
---|
| 168 | *
|
---|
| 169 | * @param gc Graphic context
|
---|
| 170 | * @param w Width
|
---|
| 171 | * @param h Height
|
---|
| 172 | * @return EOK on success or an error code
|
---|
| 173 | */
|
---|
| 174 | static errno_t demo_font_init(gfx_context_t *gc, gfx_coord_t w, gfx_coord_t h)
|
---|
| 175 | {
|
---|
| 176 | gfx_font_info_t *finfo;
|
---|
| 177 | errno_t rc;
|
---|
| 178 |
|
---|
| 179 | if (quit)
|
---|
| 180 | return EOK;
|
---|
| 181 |
|
---|
| 182 | /* XXX Crude way of detecting text mode */
|
---|
| 183 | if (w < 256) {
|
---|
| 184 | /* Create dummy font for text mode */
|
---|
| 185 | rc = gfx_typeface_create(gc, &tface);
|
---|
| 186 | if (rc != EOK) {
|
---|
| 187 | printf("Error creating typeface\n");
|
---|
| 188 | goto error;
|
---|
| 189 | }
|
---|
| 190 |
|
---|
| 191 | rc = gfx_font_create_textmode(tface, &font);
|
---|
| 192 | if (rc != EOK) {
|
---|
| 193 | printf("Error creating font\n");
|
---|
| 194 | goto error;
|
---|
| 195 | }
|
---|
| 196 |
|
---|
| 197 | vpad = 0;
|
---|
| 198 | } else {
|
---|
| 199 | /* Load font */
|
---|
| 200 | rc = gfx_typeface_open(gc, "/data/font/helena.tpf", &tface);
|
---|
| 201 | if (rc != EOK) {
|
---|
| 202 | printf("Error opening typeface\n");
|
---|
| 203 | goto error;
|
---|
| 204 | }
|
---|
| 205 |
|
---|
| 206 | finfo = gfx_typeface_first_font(tface);
|
---|
| 207 | if (finfo == NULL) {
|
---|
| 208 | printf("Typeface contains no font.\n");
|
---|
| 209 | rc = ENOENT;
|
---|
| 210 | goto error;
|
---|
| 211 | }
|
---|
| 212 |
|
---|
| 213 | rc = gfx_font_open(finfo, &font);
|
---|
| 214 | if (rc != EOK) {
|
---|
| 215 | printf("Error opening font.\n");
|
---|
| 216 | goto error;
|
---|
| 217 | }
|
---|
| 218 |
|
---|
| 219 | vpad = 5;
|
---|
| 220 | }
|
---|
| 221 |
|
---|
| 222 | return EOK;
|
---|
| 223 | error:
|
---|
| 224 | if (tface != NULL)
|
---|
| 225 | gfx_typeface_destroy(tface);
|
---|
| 226 | return rc;
|
---|
| 227 | }
|
---|
| 228 |
|
---|
| 229 | /** Finalize demo font. */
|
---|
| 230 | static void demo_font_fini(void)
|
---|
| 231 | {
|
---|
| 232 | if (font == NULL)
|
---|
| 233 | return;
|
---|
| 234 |
|
---|
| 235 | gfx_font_close(font);
|
---|
| 236 | font = NULL;
|
---|
| 237 |
|
---|
| 238 | gfx_typeface_destroy(tface);
|
---|
| 239 | tface = NULL;
|
---|
| 240 | }
|
---|
| 241 |
|
---|
| 242 | /** Start a new demo screen.
|
---|
| 243 | *
|
---|
| 244 | * Clear the screen, display a status line and set up clipping.
|
---|
| 245 | *
|
---|
| 246 | * @param gc Graphic context
|
---|
| 247 | * @param w Width
|
---|
| 248 | * @param h Height
|
---|
| 249 | * @param text Demo screen description
|
---|
| 250 | * @return EOK on success or an error code
|
---|
| 251 | */
|
---|
| 252 | static errno_t demo_begin(gfx_context_t *gc, gfx_coord_t w, gfx_coord_t h,
|
---|
| 253 | const char *text)
|
---|
| 254 | {
|
---|
| 255 | gfx_text_fmt_t fmt;
|
---|
| 256 | gfx_font_metrics_t metrics;
|
---|
| 257 | gfx_coord2_t pos;
|
---|
| 258 | gfx_color_t *color;
|
---|
| 259 | gfx_rect_t rect;
|
---|
| 260 | gfx_coord_t height;
|
---|
| 261 | errno_t rc;
|
---|
| 262 |
|
---|
| 263 | rc = gfx_set_clip_rect(gc, NULL);
|
---|
| 264 | if (rc != EOK)
|
---|
| 265 | return rc;
|
---|
| 266 |
|
---|
| 267 | rc = clear_scr(gc, w, h);
|
---|
| 268 | if (rc != EOK)
|
---|
| 269 | return rc;
|
---|
| 270 |
|
---|
| 271 | if (font != NULL) {
|
---|
[bc52b5b] | 272 | if (demo_is_text(w, h)) {
|
---|
| 273 | rc = gfx_color_new_ega(0x1e, &color);
|
---|
| 274 | if (rc != EOK)
|
---|
| 275 | goto error;
|
---|
| 276 | } else {
|
---|
| 277 | rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff, &color);
|
---|
| 278 | if (rc != EOK)
|
---|
| 279 | goto error;
|
---|
| 280 | }
|
---|
[8dbd13d] | 281 |
|
---|
| 282 | gfx_text_fmt_init(&fmt);
|
---|
[4583015] | 283 | fmt.font = font;
|
---|
[8dbd13d] | 284 | fmt.color = color;
|
---|
| 285 | fmt.halign = gfx_halign_center;
|
---|
| 286 | fmt.valign = gfx_valign_bottom;
|
---|
| 287 |
|
---|
| 288 | pos.x = w / 2;
|
---|
[901b302] | 289 | pos.y = h;
|
---|
[4583015] | 290 | rc = gfx_puttext(&pos, &fmt, text);
|
---|
[8dbd13d] | 291 | if (rc != EOK) {
|
---|
| 292 | printf("Error rendering text.\n");
|
---|
| 293 | gfx_color_delete(color);
|
---|
| 294 | goto error;
|
---|
| 295 | }
|
---|
| 296 |
|
---|
| 297 | gfx_color_delete(color);
|
---|
| 298 |
|
---|
| 299 | gfx_font_get_metrics(font, &metrics);
|
---|
| 300 | height = metrics.ascent + metrics.descent + 1;
|
---|
| 301 | } else {
|
---|
| 302 | height = 0;
|
---|
| 303 | }
|
---|
| 304 |
|
---|
| 305 | rect.p0.x = 0;
|
---|
| 306 | rect.p0.y = 0;
|
---|
| 307 | rect.p1.x = w;
|
---|
| 308 | rect.p1.y = h - height - vpad;
|
---|
| 309 | rc = gfx_set_clip_rect(gc, &rect);
|
---|
| 310 | if (rc != EOK)
|
---|
| 311 | return rc;
|
---|
| 312 |
|
---|
| 313 | return EOK;
|
---|
| 314 | error:
|
---|
| 315 | return rc;
|
---|
| 316 | }
|
---|
| 317 |
|
---|
[00e8290] | 318 | /** Run rectangle demo on a graphic context.
|
---|
| 319 | *
|
---|
| 320 | * @param gc Graphic context
|
---|
[e0545de] | 321 | * @param w Width
|
---|
| 322 | * @param h Height
|
---|
[00e8290] | 323 | */
|
---|
[1822545] | 324 | static errno_t demo_rects(gfx_context_t *gc, gfx_coord_t w, gfx_coord_t h)
|
---|
[045186b] | 325 | {
|
---|
[9259d20] | 326 | gfx_color_t *color = NULL;
|
---|
| 327 | gfx_rect_t rect;
|
---|
[e0545de] | 328 | int i, j;
|
---|
[9259d20] | 329 | errno_t rc;
|
---|
| 330 |
|
---|
[4f64b7b8] | 331 | if (quit)
|
---|
| 332 | return EOK;
|
---|
| 333 |
|
---|
[8dbd13d] | 334 | rc = demo_begin(gc, w, h, "Rectangle rendering");
|
---|
[587b4cb] | 335 | if (rc != EOK)
|
---|
| 336 | return rc;
|
---|
| 337 |
|
---|
[e0545de] | 338 | for (j = 0; j < 10; j++) {
|
---|
[9259d20] | 339 | rc = gfx_color_new_rgb_i16(rand() % 0x10000, rand() % 0x10000,
|
---|
| 340 | rand() % 0x10000, &color);
|
---|
| 341 | if (rc != EOK)
|
---|
[00e8290] | 342 | return rc;
|
---|
[9259d20] | 343 |
|
---|
| 344 | rc = gfx_set_color(gc, color);
|
---|
| 345 | if (rc != EOK)
|
---|
[00e8290] | 346 | return rc;
|
---|
[9259d20] | 347 |
|
---|
| 348 | for (i = 0; i < 10; i++) {
|
---|
[00e8290] | 349 | rect.p0.x = rand() % (w - 1);
|
---|
| 350 | rect.p0.y = rand() % (h - 1);
|
---|
| 351 | rect.p1.x = rect.p0.x + rand() % (w - 1 - rect.p0.x);
|
---|
| 352 | rect.p1.y = rect.p0.y + rand() % (h - 1 - rect.p0.y);
|
---|
[9259d20] | 353 |
|
---|
| 354 | rc = gfx_fill_rect(gc, &rect);
|
---|
| 355 | if (rc != EOK)
|
---|
[00e8290] | 356 | return rc;
|
---|
[9259d20] | 357 | }
|
---|
| 358 |
|
---|
| 359 | gfx_color_delete(color);
|
---|
| 360 |
|
---|
[af967ef9] | 361 | demo_msleep(500);
|
---|
[b3c185b6] | 362 | if (quit)
|
---|
| 363 | break;
|
---|
[9259d20] | 364 | }
|
---|
[e0545de] | 365 |
|
---|
| 366 | return EOK;
|
---|
| 367 | }
|
---|
| 368 |
|
---|
[587b4cb] | 369 | /** Fill bitmap with tartan pattern.
|
---|
| 370 | *
|
---|
| 371 | * @param bitmap Bitmap
|
---|
| 372 | * @param w Bitmap width
|
---|
| 373 | * @param h Bitmap height
|
---|
| 374 | * @return EOK on success or an error code
|
---|
| 375 | */
|
---|
| 376 | static errno_t bitmap_tartan(gfx_bitmap_t *bitmap, gfx_coord_t w, gfx_coord_t h)
|
---|
| 377 | {
|
---|
| 378 | int i, j;
|
---|
| 379 | pixelmap_t pixelmap;
|
---|
| 380 | gfx_bitmap_alloc_t alloc;
|
---|
| 381 | errno_t rc;
|
---|
| 382 |
|
---|
| 383 | rc = gfx_bitmap_get_alloc(bitmap, &alloc);
|
---|
| 384 | if (rc != EOK)
|
---|
| 385 | return rc;
|
---|
| 386 |
|
---|
| 387 | /* In absence of anything else, use pixelmap */
|
---|
| 388 | pixelmap.width = w;
|
---|
| 389 | pixelmap.height = h;
|
---|
| 390 | pixelmap.data = alloc.pixels;
|
---|
| 391 |
|
---|
| 392 | for (i = 0; i < w; i++) {
|
---|
| 393 | for (j = 0; j < h; j++) {
|
---|
| 394 | pixelmap_put_pixel(&pixelmap, i, j,
|
---|
[6a87f28] | 395 | PIXEL(0, (i % 30) < 3 ? 255 : 0,
|
---|
[587b4cb] | 396 | (j % 30) < 3 ? 255 : 0, i / 2));
|
---|
| 397 | }
|
---|
| 398 | }
|
---|
| 399 |
|
---|
| 400 | return EOK;
|
---|
| 401 | }
|
---|
| 402 |
|
---|
| 403 | /** Fill bitmap with moire pattern.
|
---|
| 404 | *
|
---|
| 405 | * @param bitmap Bitmap
|
---|
| 406 | * @param w Bitmap width
|
---|
| 407 | * @param h Bitmap height
|
---|
| 408 | * @return EOK on success or an error code
|
---|
| 409 | */
|
---|
| 410 | static errno_t bitmap_moire(gfx_bitmap_t *bitmap, gfx_coord_t w, gfx_coord_t h)
|
---|
| 411 | {
|
---|
| 412 | int i, j;
|
---|
| 413 | int k;
|
---|
| 414 | pixelmap_t pixelmap;
|
---|
| 415 | gfx_bitmap_alloc_t alloc;
|
---|
| 416 | errno_t rc;
|
---|
| 417 |
|
---|
| 418 | rc = gfx_bitmap_get_alloc(bitmap, &alloc);
|
---|
| 419 | if (rc != EOK)
|
---|
| 420 | return rc;
|
---|
| 421 |
|
---|
| 422 | /* In absence of anything else, use pixelmap */
|
---|
| 423 | pixelmap.width = w;
|
---|
| 424 | pixelmap.height = h;
|
---|
| 425 | pixelmap.data = alloc.pixels;
|
---|
| 426 |
|
---|
| 427 | for (i = 0; i < w; i++) {
|
---|
| 428 | for (j = 0; j < h; j++) {
|
---|
| 429 | k = i * i + j * j;
|
---|
| 430 | pixelmap_put_pixel(&pixelmap, i, j,
|
---|
[6a87f28] | 431 | PIXEL(0, k, k, k));
|
---|
[587b4cb] | 432 | }
|
---|
| 433 | }
|
---|
| 434 |
|
---|
| 435 | return EOK;
|
---|
| 436 | }
|
---|
| 437 |
|
---|
[bea947f] | 438 | /** Render circle to a bitmap.
|
---|
| 439 | *
|
---|
| 440 | * @param bitmap Bitmap
|
---|
| 441 | * @param w Bitmap width
|
---|
| 442 | * @param h Bitmap height
|
---|
| 443 | * @return EOK on success or an error code
|
---|
| 444 | */
|
---|
| 445 | static errno_t bitmap_circle(gfx_bitmap_t *bitmap, gfx_coord_t w, gfx_coord_t h)
|
---|
| 446 | {
|
---|
| 447 | int i, j;
|
---|
| 448 | int k;
|
---|
| 449 | pixelmap_t pixelmap;
|
---|
| 450 | gfx_bitmap_alloc_t alloc;
|
---|
| 451 | errno_t rc;
|
---|
| 452 |
|
---|
| 453 | rc = gfx_bitmap_get_alloc(bitmap, &alloc);
|
---|
| 454 | if (rc != EOK)
|
---|
| 455 | return rc;
|
---|
| 456 |
|
---|
| 457 | /* In absence of anything else, use pixelmap */
|
---|
| 458 | pixelmap.width = w;
|
---|
| 459 | pixelmap.height = h;
|
---|
| 460 | pixelmap.data = alloc.pixels;
|
---|
| 461 |
|
---|
| 462 | for (i = 0; i < w; i++) {
|
---|
| 463 | for (j = 0; j < h; j++) {
|
---|
| 464 | k = i * i + j * j;
|
---|
| 465 | pixelmap_put_pixel(&pixelmap, i, j,
|
---|
[6a87f28] | 466 | k < w * w / 2 ? PIXEL(0, 0, 255, 0) :
|
---|
[bea947f] | 467 | PIXEL(0, 255, 0, 255));
|
---|
| 468 | }
|
---|
| 469 | }
|
---|
| 470 |
|
---|
| 471 | return EOK;
|
---|
| 472 | }
|
---|
| 473 |
|
---|
[e0545de] | 474 | /** Run bitmap demo on a graphic context.
|
---|
| 475 | *
|
---|
| 476 | * @param gc Graphic context
|
---|
| 477 | * @param w Width
|
---|
| 478 | * @param h Height
|
---|
| 479 | */
|
---|
[1822545] | 480 | static errno_t demo_bitmap(gfx_context_t *gc, gfx_coord_t w, gfx_coord_t h)
|
---|
[e0545de] | 481 | {
|
---|
| 482 | gfx_bitmap_t *bitmap;
|
---|
| 483 | gfx_bitmap_params_t params;
|
---|
| 484 | int i, j;
|
---|
| 485 | gfx_coord2_t offs;
|
---|
| 486 | gfx_rect_t srect;
|
---|
| 487 | errno_t rc;
|
---|
[587b4cb] | 488 |
|
---|
[4f64b7b8] | 489 | if (quit)
|
---|
| 490 | return EOK;
|
---|
| 491 |
|
---|
[8dbd13d] | 492 | rc = demo_begin(gc, w, h, "Bitmap rendering without offset");
|
---|
[587b4cb] | 493 | if (rc != EOK)
|
---|
| 494 | return rc;
|
---|
[e0545de] | 495 |
|
---|
[a8eed5f] | 496 | gfx_bitmap_params_init(¶ms);
|
---|
[e0545de] | 497 | params.rect.p0.x = 0;
|
---|
| 498 | params.rect.p0.y = 0;
|
---|
| 499 | params.rect.p1.x = w;
|
---|
| 500 | params.rect.p1.y = h;
|
---|
| 501 |
|
---|
| 502 | rc = gfx_bitmap_create(gc, ¶ms, NULL, &bitmap);
|
---|
| 503 | if (rc != EOK)
|
---|
| 504 | return rc;
|
---|
| 505 |
|
---|
[587b4cb] | 506 | rc = bitmap_tartan(bitmap, w, h);
|
---|
[e0545de] | 507 | if (rc != EOK)
|
---|
[587b4cb] | 508 | goto error;
|
---|
[e0545de] | 509 |
|
---|
| 510 | for (j = 0; j < 10; j++) {
|
---|
| 511 | for (i = 0; i < 5; i++) {
|
---|
| 512 | srect.p0.x = rand() % (w - 40);
|
---|
[d18f3b7] | 513 | srect.p0.y = rand() % (h - 20);
|
---|
[e0545de] | 514 | srect.p1.x = srect.p0.x + rand() % (w - srect.p0.x);
|
---|
| 515 | srect.p1.y = srect.p0.y + rand() % (h - srect.p0.y);
|
---|
| 516 | offs.x = 0;
|
---|
| 517 | offs.y = 0;
|
---|
| 518 |
|
---|
[0008c0f] | 519 | rc = gfx_bitmap_render(bitmap, &srect, &offs);
|
---|
| 520 | if (rc != EOK)
|
---|
| 521 | goto error;
|
---|
[b3c185b6] | 522 |
|
---|
[af967ef9] | 523 | demo_msleep(250);
|
---|
[b3c185b6] | 524 | if (quit)
|
---|
[4f64b7b8] | 525 | goto out;
|
---|
[587b4cb] | 526 | }
|
---|
| 527 | }
|
---|
| 528 |
|
---|
[4f64b7b8] | 529 | out:
|
---|
[587b4cb] | 530 | gfx_bitmap_destroy(bitmap);
|
---|
| 531 |
|
---|
| 532 | return EOK;
|
---|
| 533 | error:
|
---|
| 534 | gfx_bitmap_destroy(bitmap);
|
---|
| 535 | return rc;
|
---|
| 536 | }
|
---|
| 537 |
|
---|
| 538 | /** Run second bitmap demo on a graphic context.
|
---|
| 539 | *
|
---|
| 540 | * @param gc Graphic context
|
---|
| 541 | * @param w Width
|
---|
| 542 | * @param h Height
|
---|
| 543 | */
|
---|
| 544 | static errno_t demo_bitmap2(gfx_context_t *gc, gfx_coord_t w, gfx_coord_t h)
|
---|
| 545 | {
|
---|
| 546 | gfx_bitmap_t *bitmap;
|
---|
| 547 | gfx_bitmap_params_t params;
|
---|
| 548 | int i, j;
|
---|
| 549 | gfx_coord2_t offs;
|
---|
| 550 | errno_t rc;
|
---|
| 551 |
|
---|
[4f64b7b8] | 552 | if (quit)
|
---|
| 553 | return EOK;
|
---|
| 554 |
|
---|
[8dbd13d] | 555 | rc = demo_begin(gc, w, h, "Bitmap rendering with offset");
|
---|
[587b4cb] | 556 | if (rc != EOK)
|
---|
| 557 | return rc;
|
---|
| 558 |
|
---|
[b3b00b6] | 559 | gfx_bitmap_params_init(¶ms);
|
---|
[587b4cb] | 560 | params.rect.p0.x = 0;
|
---|
| 561 | params.rect.p0.y = 0;
|
---|
| 562 | params.rect.p1.x = 40;
|
---|
| 563 | params.rect.p1.y = 20;
|
---|
| 564 |
|
---|
| 565 | rc = gfx_bitmap_create(gc, ¶ms, NULL, &bitmap);
|
---|
| 566 | if (rc != EOK)
|
---|
| 567 | return rc;
|
---|
| 568 |
|
---|
| 569 | rc = bitmap_moire(bitmap, 40, 20);
|
---|
| 570 | if (rc != EOK)
|
---|
| 571 | goto error;
|
---|
| 572 |
|
---|
| 573 | for (j = 0; j < 10; j++) {
|
---|
| 574 | for (i = 0; i < 10; i++) {
|
---|
| 575 | offs.x = rand() % (w - 40);
|
---|
| 576 | offs.y = rand() % (h - 20);
|
---|
| 577 |
|
---|
| 578 | rc = gfx_bitmap_render(bitmap, NULL, &offs);
|
---|
| 579 | if (rc != EOK)
|
---|
| 580 | goto error;
|
---|
[e0545de] | 581 | }
|
---|
[587b4cb] | 582 |
|
---|
[af967ef9] | 583 | demo_msleep(500);
|
---|
[b3c185b6] | 584 | if (quit)
|
---|
| 585 | break;
|
---|
[e0545de] | 586 | }
|
---|
| 587 |
|
---|
| 588 | gfx_bitmap_destroy(bitmap);
|
---|
| 589 |
|
---|
| 590 | return EOK;
|
---|
[0008c0f] | 591 | error:
|
---|
| 592 | gfx_bitmap_destroy(bitmap);
|
---|
| 593 | return rc;
|
---|
[e0545de] | 594 | }
|
---|
[8fa65af0] | 595 |
|
---|
[bea947f] | 596 | /** Run bitmap color key demo on a graphic context.
|
---|
| 597 | *
|
---|
| 598 | * @param gc Graphic context
|
---|
| 599 | * @param w Width
|
---|
| 600 | * @param h Height
|
---|
| 601 | */
|
---|
| 602 | static errno_t demo_bitmap_kc(gfx_context_t *gc, gfx_coord_t w, gfx_coord_t h)
|
---|
| 603 | {
|
---|
| 604 | gfx_bitmap_t *bitmap;
|
---|
| 605 | gfx_bitmap_params_t params;
|
---|
| 606 | int i, j;
|
---|
| 607 | gfx_coord2_t offs;
|
---|
| 608 | errno_t rc;
|
---|
| 609 |
|
---|
[4f64b7b8] | 610 | if (quit)
|
---|
| 611 | return EOK;
|
---|
| 612 |
|
---|
[8dbd13d] | 613 | rc = demo_begin(gc, w, h, "Bitmap rendering with color key");
|
---|
[bea947f] | 614 | if (rc != EOK)
|
---|
| 615 | return rc;
|
---|
| 616 |
|
---|
[b3b00b6] | 617 | gfx_bitmap_params_init(¶ms);
|
---|
[bea947f] | 618 | params.rect.p0.x = 0;
|
---|
| 619 | params.rect.p0.y = 0;
|
---|
| 620 | params.rect.p1.x = 40;
|
---|
| 621 | params.rect.p1.y = 40;
|
---|
| 622 | params.flags = bmpf_color_key;
|
---|
| 623 | params.key_color = PIXEL(0, 255, 0, 255);
|
---|
| 624 |
|
---|
| 625 | rc = gfx_bitmap_create(gc, ¶ms, NULL, &bitmap);
|
---|
| 626 | if (rc != EOK)
|
---|
| 627 | return rc;
|
---|
| 628 |
|
---|
| 629 | rc = bitmap_circle(bitmap, 40, 40);
|
---|
| 630 | if (rc != EOK)
|
---|
| 631 | goto error;
|
---|
| 632 |
|
---|
| 633 | for (j = 0; j < 10; j++) {
|
---|
| 634 | for (i = 0; i < 10; i++) {
|
---|
| 635 | offs.x = j * 20 + i * 20;
|
---|
| 636 | offs.y = i * 20;
|
---|
| 637 |
|
---|
| 638 | rc = gfx_bitmap_render(bitmap, NULL, &offs);
|
---|
| 639 | if (rc != EOK)
|
---|
| 640 | goto error;
|
---|
| 641 | }
|
---|
| 642 |
|
---|
[af967ef9] | 643 | demo_msleep(500);
|
---|
[bea947f] | 644 | if (quit)
|
---|
| 645 | break;
|
---|
| 646 | }
|
---|
| 647 |
|
---|
| 648 | gfx_bitmap_destroy(bitmap);
|
---|
| 649 |
|
---|
| 650 | return EOK;
|
---|
| 651 | error:
|
---|
| 652 | gfx_bitmap_destroy(bitmap);
|
---|
| 653 | return rc;
|
---|
| 654 | }
|
---|
[e0545de] | 655 |
|
---|
[8fa65af0] | 656 | /** Run text demo on a graphic context.
|
---|
| 657 | *
|
---|
| 658 | * @param gc Graphic context
|
---|
| 659 | * @param w Width
|
---|
| 660 | * @param h Height
|
---|
| 661 | */
|
---|
| 662 | static errno_t demo_text(gfx_context_t *gc, gfx_coord_t w, gfx_coord_t h)
|
---|
| 663 | {
|
---|
| 664 | gfx_color_t *color = NULL;
|
---|
| 665 | gfx_rect_t rect;
|
---|
| 666 | gfx_coord2_t pos;
|
---|
| 667 | gfx_text_fmt_t fmt;
|
---|
| 668 | int i;
|
---|
| 669 | errno_t rc;
|
---|
| 670 |
|
---|
[4f64b7b8] | 671 | if (quit)
|
---|
| 672 | return EOK;
|
---|
| 673 |
|
---|
[8dbd13d] | 674 | rc = demo_begin(gc, w, h, "Text rendering");
|
---|
[8fa65af0] | 675 | if (rc != EOK)
|
---|
| 676 | goto error;
|
---|
| 677 |
|
---|
| 678 | /* Vertical bars */
|
---|
| 679 |
|
---|
| 680 | for (i = 0; i < 20; i++) {
|
---|
| 681 | rc = gfx_color_new_rgb_i16(0, 0x8000 * i / 20,
|
---|
| 682 | 0x8000 * i / 20, &color);
|
---|
| 683 | if (rc != EOK)
|
---|
| 684 | goto error;
|
---|
| 685 |
|
---|
| 686 | rc = gfx_set_color(gc, color);
|
---|
| 687 | if (rc != EOK)
|
---|
| 688 | goto error;
|
---|
| 689 |
|
---|
| 690 | rect.p0.x = w * i / 20;
|
---|
| 691 | rect.p0.y = 0;
|
---|
| 692 | rect.p1.x = w * (i + 1) / 20;
|
---|
| 693 | rect.p1.y = h;
|
---|
| 694 |
|
---|
| 695 | rc = gfx_fill_rect(gc, &rect);
|
---|
| 696 | if (rc != EOK)
|
---|
| 697 | goto error;
|
---|
| 698 |
|
---|
| 699 | gfx_color_delete(color);
|
---|
| 700 | }
|
---|
| 701 |
|
---|
| 702 | rc = gfx_color_new_rgb_i16(0, 0, 0x8000, &color);
|
---|
| 703 | if (rc != EOK)
|
---|
| 704 | goto error;
|
---|
| 705 |
|
---|
| 706 | rc = gfx_set_color(gc, color);
|
---|
| 707 | if (rc != EOK)
|
---|
| 708 | goto error;
|
---|
| 709 |
|
---|
| 710 | rect.p0.x = w / 20;
|
---|
[8dbd13d] | 711 | rect.p0.y = 1 * h / 15;
|
---|
[8fa65af0] | 712 | rect.p1.x = w - w / 20;
|
---|
[8dbd13d] | 713 | rect.p1.y = 4 * h / 15;
|
---|
[8fa65af0] | 714 |
|
---|
| 715 | rc = gfx_fill_rect(gc, &rect);
|
---|
| 716 | if (rc != EOK)
|
---|
| 717 | goto error;
|
---|
| 718 |
|
---|
| 719 | gfx_color_delete(color);
|
---|
| 720 |
|
---|
[f7c12b3] | 721 | if (demo_is_text(w, h)) {
|
---|
| 722 | rc = gfx_color_new_ega(0x1f, &color);
|
---|
| 723 | if (rc != EOK)
|
---|
| 724 | goto error;
|
---|
| 725 | } else {
|
---|
| 726 | rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff, &color);
|
---|
| 727 | if (rc != EOK)
|
---|
| 728 | goto error;
|
---|
| 729 | }
|
---|
[8fa65af0] | 730 |
|
---|
| 731 | gfx_text_fmt_init(&fmt);
|
---|
[4583015] | 732 | fmt.font = font;
|
---|
[b433f68] | 733 | fmt.color = color;
|
---|
[8fa65af0] | 734 |
|
---|
| 735 | pos.x = rect.p0.x;
|
---|
| 736 | pos.y = rect.p0.y;
|
---|
[4583015] | 737 | rc = gfx_puttext(&pos, &fmt, "Top left");
|
---|
[8fa65af0] | 738 | if (rc != EOK) {
|
---|
| 739 | printf("Error rendering text.\n");
|
---|
| 740 | goto error;
|
---|
| 741 | }
|
---|
| 742 |
|
---|
[8bf9058] | 743 | pos.x = (rect.p0.x + rect.p1.x - 1) / 2;
|
---|
[8fa65af0] | 744 | pos.y = rect.p0.y;
|
---|
| 745 | fmt.halign = gfx_halign_center;
|
---|
[4583015] | 746 | rc = gfx_puttext(&pos, &fmt, "Top center");
|
---|
[8fa65af0] | 747 | if (rc != EOK)
|
---|
| 748 | goto error;
|
---|
| 749 |
|
---|
[400a16d] | 750 | pos.x = rect.p1.x;
|
---|
[8fa65af0] | 751 | pos.y = rect.p0.y;
|
---|
| 752 | fmt.halign = gfx_halign_right;
|
---|
[4583015] | 753 | rc = gfx_puttext(&pos, &fmt, "Top right");
|
---|
[8fa65af0] | 754 | if (rc != EOK)
|
---|
| 755 | goto error;
|
---|
| 756 |
|
---|
| 757 | fmt.valign = gfx_valign_center;
|
---|
| 758 |
|
---|
| 759 | pos.x = rect.p0.x;
|
---|
[8bf9058] | 760 | pos.y = (rect.p0.y + rect.p1.y - 1) / 2;
|
---|
[8fa65af0] | 761 | fmt.halign = gfx_halign_left;
|
---|
[4583015] | 762 | rc = gfx_puttext(&pos, &fmt, "Center left");
|
---|
[8fa65af0] | 763 | if (rc != EOK)
|
---|
| 764 | goto error;
|
---|
| 765 |
|
---|
[8bf9058] | 766 | pos.x = (rect.p0.x + rect.p1.x - 1) / 2;
|
---|
| 767 | pos.y = (rect.p0.y + rect.p1.y - 1) / 2;
|
---|
[8fa65af0] | 768 | fmt.halign = gfx_halign_center;
|
---|
[4583015] | 769 | rc = gfx_puttext(&pos, &fmt, "Center");
|
---|
[8fa65af0] | 770 | if (rc != EOK)
|
---|
| 771 | goto error;
|
---|
| 772 |
|
---|
[400a16d] | 773 | pos.x = rect.p1.x;
|
---|
[8bf9058] | 774 | pos.y = (rect.p0.y + rect.p1.y - 1) / 2;
|
---|
[8fa65af0] | 775 | fmt.halign = gfx_halign_right;
|
---|
[4583015] | 776 | rc = gfx_puttext(&pos, &fmt, "Center right");
|
---|
[8fa65af0] | 777 | if (rc != EOK)
|
---|
| 778 | goto error;
|
---|
| 779 |
|
---|
| 780 | fmt.valign = gfx_valign_bottom;
|
---|
| 781 |
|
---|
| 782 | pos.x = rect.p0.x;
|
---|
[8bf9058] | 783 | pos.y = rect.p1.y - 1;
|
---|
[8fa65af0] | 784 | fmt.halign = gfx_halign_left;
|
---|
[4583015] | 785 | rc = gfx_puttext(&pos, &fmt, "Bottom left");
|
---|
[8fa65af0] | 786 | if (rc != EOK)
|
---|
| 787 | goto error;
|
---|
| 788 |
|
---|
[8bf9058] | 789 | pos.x = (rect.p0.x + rect.p1.x - 1) / 2;
|
---|
[400a16d] | 790 | pos.y = rect.p1.y;
|
---|
[8fa65af0] | 791 | fmt.halign = gfx_halign_center;
|
---|
[4583015] | 792 | rc = gfx_puttext(&pos, &fmt, "Bottom center");
|
---|
[8fa65af0] | 793 | if (rc != EOK)
|
---|
| 794 | goto error;
|
---|
| 795 |
|
---|
[400a16d] | 796 | pos.x = rect.p1.x;
|
---|
| 797 | pos.y = rect.p1.y;
|
---|
[8fa65af0] | 798 | fmt.halign = gfx_halign_right;
|
---|
[4583015] | 799 | rc = gfx_puttext(&pos, &fmt, "Bottom right");
|
---|
[8fa65af0] | 800 | if (rc != EOK)
|
---|
| 801 | goto error;
|
---|
| 802 |
|
---|
[0d62c10] | 803 | gfx_color_delete(color);
|
---|
| 804 |
|
---|
[8fa65af0] | 805 | gfx_text_fmt_init(&fmt);
|
---|
[4583015] | 806 | fmt.font = font;
|
---|
[8fa65af0] | 807 |
|
---|
| 808 | for (i = 0; i < 8; i++) {
|
---|
[bc52b5b] | 809 | if (demo_is_text(w, h)) {
|
---|
[f7c12b3] | 810 | rc = gfx_color_new_ega(i != 0 ? i : 0x10, &color);
|
---|
[bc52b5b] | 811 | if (rc != EOK)
|
---|
| 812 | goto error;
|
---|
| 813 | } else {
|
---|
| 814 | rc = gfx_color_new_rgb_i16((i & 4) ? 0xffff : 0,
|
---|
| 815 | (i & 2) ? 0xffff : 0, (i & 1) ? 0xffff : 0, &color);
|
---|
| 816 | if (rc != EOK)
|
---|
| 817 | goto error;
|
---|
| 818 | }
|
---|
[0d62c10] | 819 |
|
---|
[b433f68] | 820 | fmt.color = color;
|
---|
[5c27e77] | 821 | fmt.underline = !fmt.underline;
|
---|
[0d62c10] | 822 |
|
---|
[8fa65af0] | 823 | pos.x = w / 20;
|
---|
[8dbd13d] | 824 | pos.y = (6 + i) * h / 15;
|
---|
[4583015] | 825 | rc = gfx_puttext(&pos, &fmt, "The quick brown fox jumps over the lazy dog.");
|
---|
[8fa65af0] | 826 | if (rc != EOK)
|
---|
| 827 | goto error;
|
---|
[0d62c10] | 828 |
|
---|
| 829 | gfx_color_delete(color);
|
---|
[8fa65af0] | 830 | }
|
---|
| 831 |
|
---|
| 832 | for (i = 0; i < 10; i++) {
|
---|
[af967ef9] | 833 | demo_msleep(500);
|
---|
[8fa65af0] | 834 | if (quit)
|
---|
| 835 | break;
|
---|
| 836 | }
|
---|
| 837 |
|
---|
| 838 | return EOK;
|
---|
| 839 | error:
|
---|
| 840 | return rc;
|
---|
| 841 | }
|
---|
| 842 |
|
---|
[901b302] | 843 | /** Run text abbreviation demo on a graphic context.
|
---|
| 844 | *
|
---|
| 845 | * @param gc Graphic context
|
---|
| 846 | * @param w Width
|
---|
| 847 | * @param h Height
|
---|
| 848 | */
|
---|
| 849 | static errno_t demo_text_abbr(gfx_context_t *gc, gfx_coord_t w, gfx_coord_t h)
|
---|
| 850 | {
|
---|
| 851 | gfx_color_t *color = NULL;
|
---|
| 852 | gfx_rect_t rect;
|
---|
| 853 | gfx_coord2_t pos;
|
---|
| 854 | gfx_text_fmt_t fmt;
|
---|
| 855 | int i;
|
---|
| 856 | errno_t rc;
|
---|
| 857 |
|
---|
| 858 | if (quit)
|
---|
| 859 | return EOK;
|
---|
| 860 |
|
---|
| 861 | rc = demo_begin(gc, w, h, "Text abbreviation");
|
---|
| 862 | if (rc != EOK)
|
---|
| 863 | goto error;
|
---|
| 864 |
|
---|
| 865 | for (i = 0; i < 11; i++) {
|
---|
| 866 |
|
---|
| 867 | rc = gfx_color_new_rgb_i16(0, 0, 0x8000, &color);
|
---|
| 868 | if (rc != EOK)
|
---|
| 869 | goto error;
|
---|
| 870 |
|
---|
| 871 | rc = gfx_set_color(gc, color);
|
---|
| 872 | if (rc != EOK)
|
---|
| 873 | goto error;
|
---|
| 874 |
|
---|
| 875 | rect.p0.x = w / 20;
|
---|
| 876 | rect.p0.y = (2 + 2 * i) * h / 25;
|
---|
| 877 | rect.p1.x = w - w / 20 - w * i / 12;
|
---|
| 878 | rect.p1.y = (3 + 2 * i) * h / 25;
|
---|
| 879 |
|
---|
| 880 | rc = gfx_fill_rect(gc, &rect);
|
---|
| 881 | if (rc != EOK)
|
---|
| 882 | goto error;
|
---|
| 883 |
|
---|
| 884 | gfx_color_delete(color);
|
---|
| 885 |
|
---|
| 886 | if (demo_is_text(w, h)) {
|
---|
| 887 | rc = gfx_color_new_ega(0x1f, &color);
|
---|
| 888 | if (rc != EOK)
|
---|
| 889 | goto error;
|
---|
| 890 | } else {
|
---|
| 891 | rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff,
|
---|
| 892 | &color);
|
---|
| 893 | if (rc != EOK)
|
---|
| 894 | goto error;
|
---|
| 895 | }
|
---|
| 896 |
|
---|
| 897 | gfx_text_fmt_init(&fmt);
|
---|
| 898 | fmt.font = font;
|
---|
| 899 | fmt.color = color;
|
---|
| 900 | fmt.abbreviate = true;
|
---|
| 901 | fmt.width = rect.p1.x - rect.p0.x;
|
---|
| 902 |
|
---|
| 903 | pos.x = rect.p0.x;
|
---|
| 904 | pos.y = rect.p0.y;
|
---|
| 905 | rc = gfx_puttext(&pos, &fmt,
|
---|
| 906 | "The quick brow fox jumps over the lazy dog!");
|
---|
| 907 | if (rc != EOK) {
|
---|
| 908 | printf("Error rendering text.\n");
|
---|
| 909 | goto error;
|
---|
| 910 | }
|
---|
| 911 | }
|
---|
| 912 |
|
---|
| 913 | for (i = 0; i < 10; i++) {
|
---|
[af967ef9] | 914 | demo_msleep(500);
|
---|
[901b302] | 915 | if (quit)
|
---|
| 916 | break;
|
---|
| 917 | }
|
---|
| 918 |
|
---|
| 919 | return EOK;
|
---|
| 920 | error:
|
---|
| 921 | return rc;
|
---|
| 922 | }
|
---|
| 923 |
|
---|
[1167ad34] | 924 | /** Run clipping demo on a graphic context.
|
---|
| 925 | *
|
---|
| 926 | * @param gc Graphic context
|
---|
| 927 | * @param w Width
|
---|
| 928 | * @param h Height
|
---|
| 929 | */
|
---|
| 930 | static errno_t demo_clip(gfx_context_t *gc, gfx_coord_t w, gfx_coord_t h)
|
---|
| 931 | {
|
---|
| 932 | gfx_bitmap_t *bitmap;
|
---|
| 933 | gfx_color_t *color;
|
---|
| 934 | gfx_bitmap_params_t params;
|
---|
| 935 | int i, j;
|
---|
| 936 | gfx_coord2_t offs;
|
---|
| 937 | gfx_rect_t rect;
|
---|
| 938 | errno_t rc;
|
---|
| 939 |
|
---|
| 940 | if (quit)
|
---|
| 941 | return EOK;
|
---|
| 942 |
|
---|
[8dbd13d] | 943 | rc = demo_begin(gc, w, h, "Clipping demonstration");
|
---|
[1167ad34] | 944 | if (rc != EOK)
|
---|
| 945 | return rc;
|
---|
| 946 |
|
---|
| 947 | gfx_bitmap_params_init(¶ms);
|
---|
| 948 | params.rect.p0.x = 0;
|
---|
| 949 | params.rect.p0.y = 0;
|
---|
| 950 | params.rect.p1.x = 40;
|
---|
| 951 | params.rect.p1.y = 20;
|
---|
| 952 |
|
---|
| 953 | rc = gfx_bitmap_create(gc, ¶ms, NULL, &bitmap);
|
---|
| 954 | if (rc != EOK)
|
---|
| 955 | return rc;
|
---|
| 956 |
|
---|
| 957 | rc = bitmap_moire(bitmap, 40, 20);
|
---|
| 958 | if (rc != EOK)
|
---|
| 959 | goto error;
|
---|
| 960 |
|
---|
| 961 | for (j = 0; j < 10; j++) {
|
---|
| 962 | rect.p0.x = w / 8;
|
---|
| 963 | rect.p0.y = h / 8;
|
---|
| 964 | rect.p1.x = w * 7 / 8;
|
---|
| 965 | rect.p1.y = h * 3 / 8;
|
---|
| 966 |
|
---|
| 967 | rc = gfx_set_clip_rect(gc, &rect);
|
---|
| 968 | if (rc != EOK)
|
---|
| 969 | return rc;
|
---|
| 970 |
|
---|
| 971 | rc = gfx_color_new_rgb_i16(rand() % 0x10000, rand() % 0x10000,
|
---|
| 972 | rand() % 0x10000, &color);
|
---|
| 973 | if (rc != EOK)
|
---|
| 974 | return rc;
|
---|
| 975 |
|
---|
| 976 | rc = gfx_set_color(gc, color);
|
---|
| 977 | if (rc != EOK)
|
---|
| 978 | return rc;
|
---|
| 979 |
|
---|
| 980 | for (i = 0; i < 10; i++) {
|
---|
| 981 | rect.p0.x = rand() % (w - 1);
|
---|
| 982 | rect.p0.y = rand() % (h - 1);
|
---|
| 983 | rect.p1.x = rect.p0.x + rand() % (w - 1 - rect.p0.x);
|
---|
| 984 | rect.p1.y = rect.p0.y + rand() % (h - 1 - rect.p0.y);
|
---|
| 985 |
|
---|
| 986 | rc = gfx_fill_rect(gc, &rect);
|
---|
| 987 | if (rc != EOK)
|
---|
| 988 | return rc;
|
---|
| 989 | }
|
---|
| 990 |
|
---|
| 991 | gfx_color_delete(color);
|
---|
| 992 |
|
---|
| 993 | rect.p0.x = w / 8;
|
---|
| 994 | rect.p0.y = h * 5 / 8;
|
---|
| 995 | rect.p1.x = w * 7 / 8;
|
---|
| 996 | rect.p1.y = h * 7 / 8;
|
---|
| 997 |
|
---|
| 998 | rc = gfx_set_clip_rect(gc, &rect);
|
---|
| 999 | if (rc != EOK)
|
---|
| 1000 | return rc;
|
---|
| 1001 |
|
---|
| 1002 | for (i = 0; i < 10; i++) {
|
---|
| 1003 | offs.x = rand() % (w - 40);
|
---|
| 1004 | offs.y = rand() % (h - 20);
|
---|
| 1005 |
|
---|
| 1006 | rc = gfx_bitmap_render(bitmap, NULL, &offs);
|
---|
| 1007 | if (rc != EOK)
|
---|
| 1008 | goto error;
|
---|
| 1009 | }
|
---|
| 1010 |
|
---|
[af967ef9] | 1011 | demo_msleep(500);
|
---|
[1167ad34] | 1012 | if (quit)
|
---|
| 1013 | break;
|
---|
| 1014 | }
|
---|
| 1015 |
|
---|
| 1016 | (void) gfx_set_clip_rect(gc, NULL);
|
---|
| 1017 | gfx_bitmap_destroy(bitmap);
|
---|
| 1018 | return EOK;
|
---|
| 1019 | error:
|
---|
| 1020 | (void) gfx_set_clip_rect(gc, NULL);
|
---|
| 1021 | gfx_bitmap_destroy(bitmap);
|
---|
| 1022 | return rc;
|
---|
| 1023 | }
|
---|
| 1024 |
|
---|
[e0545de] | 1025 | /** Run demo loop on a graphic context.
|
---|
| 1026 | *
|
---|
| 1027 | * @param gc Graphic context
|
---|
| 1028 | * @param w Width
|
---|
| 1029 | * @param h Height
|
---|
| 1030 | */
|
---|
[1822545] | 1031 | static errno_t demo_loop(gfx_context_t *gc, gfx_coord_t w, gfx_coord_t h)
|
---|
[e0545de] | 1032 | {
|
---|
| 1033 | errno_t rc;
|
---|
| 1034 |
|
---|
[8dbd13d] | 1035 | (void) demo_font_init(gc, w, h);
|
---|
| 1036 |
|
---|
[b3c185b6] | 1037 | while (!quit) {
|
---|
[e0545de] | 1038 | rc = demo_rects(gc, w, h);
|
---|
| 1039 | if (rc != EOK)
|
---|
[8dbd13d] | 1040 | goto error;
|
---|
[e0545de] | 1041 |
|
---|
| 1042 | rc = demo_bitmap(gc, w, h);
|
---|
| 1043 | if (rc != EOK)
|
---|
[8dbd13d] | 1044 | goto error;
|
---|
[587b4cb] | 1045 |
|
---|
| 1046 | rc = demo_bitmap2(gc, w, h);
|
---|
| 1047 | if (rc != EOK)
|
---|
[8dbd13d] | 1048 | goto error;
|
---|
[bea947f] | 1049 |
|
---|
| 1050 | rc = demo_bitmap_kc(gc, w, h);
|
---|
| 1051 | if (rc != EOK)
|
---|
[8dbd13d] | 1052 | goto error;
|
---|
[8fa65af0] | 1053 |
|
---|
| 1054 | rc = demo_text(gc, w, h);
|
---|
| 1055 | if (rc != EOK)
|
---|
[8dbd13d] | 1056 | goto error;
|
---|
[1167ad34] | 1057 |
|
---|
[901b302] | 1058 | rc = demo_text_abbr(gc, w, h);
|
---|
| 1059 | if (rc != EOK)
|
---|
| 1060 | goto error;
|
---|
| 1061 |
|
---|
[1167ad34] | 1062 | rc = demo_clip(gc, w, h);
|
---|
| 1063 | if (rc != EOK)
|
---|
[8dbd13d] | 1064 | goto error;
|
---|
[e0545de] | 1065 | }
|
---|
[b3c185b6] | 1066 |
|
---|
[8dbd13d] | 1067 | demo_font_fini();
|
---|
[b3c185b6] | 1068 | return EOK;
|
---|
[8dbd13d] | 1069 | error:
|
---|
| 1070 | demo_font_fini();
|
---|
| 1071 | return rc;
|
---|
[00e8290] | 1072 | }
|
---|
| 1073 |
|
---|
| 1074 | /** Run demo on console. */
|
---|
| 1075 | static errno_t demo_console(void)
|
---|
| 1076 | {
|
---|
| 1077 | console_gc_t *cgc = NULL;
|
---|
| 1078 | gfx_context_t *gc;
|
---|
[c0efb2e] | 1079 | sysarg_t cols, rows;
|
---|
[00e8290] | 1080 | errno_t rc;
|
---|
| 1081 |
|
---|
| 1082 | con = console_init(stdin, stdout);
|
---|
| 1083 | if (con == NULL)
|
---|
| 1084 | return EIO;
|
---|
| 1085 |
|
---|
[c0efb2e] | 1086 | rc = console_get_size(con, &cols, &rows);
|
---|
| 1087 | if (rc != EOK)
|
---|
| 1088 | return rc;
|
---|
| 1089 |
|
---|
[00e8290] | 1090 | rc = console_gc_create(con, stdout, &cgc);
|
---|
| 1091 | if (rc != EOK)
|
---|
| 1092 | return rc;
|
---|
| 1093 |
|
---|
| 1094 | gc = console_gc_get_ctx(cgc);
|
---|
| 1095 |
|
---|
[c0efb2e] | 1096 | rc = demo_loop(gc, cols, rows);
|
---|
[00e8290] | 1097 | if (rc != EOK)
|
---|
| 1098 | return rc;
|
---|
[9259d20] | 1099 |
|
---|
[9be2358] | 1100 | rc = console_gc_delete(cgc);
|
---|
| 1101 | if (rc != EOK)
|
---|
[00e8290] | 1102 | return rc;
|
---|
| 1103 |
|
---|
| 1104 | return EOK;
|
---|
| 1105 | }
|
---|
| 1106 |
|
---|
[9adae25] | 1107 | static errno_t demo_ui_fibril(void *arg)
|
---|
| 1108 | {
|
---|
| 1109 | demo_ui_args_t *args = (demo_ui_args_t *)arg;
|
---|
| 1110 | errno_t rc;
|
---|
| 1111 |
|
---|
| 1112 | ui_lock(args->ui);
|
---|
| 1113 | rc = demo_loop(args->gc, args->dims.x, args->dims.y);
|
---|
| 1114 | ui_unlock(args->ui);
|
---|
| 1115 | ui_quit(args->ui);
|
---|
| 1116 | return rc;
|
---|
| 1117 | }
|
---|
| 1118 |
|
---|
[b93ec7c0] | 1119 | /** Run demo on UI. */
|
---|
| 1120 | static errno_t demo_ui(const char *display_spec)
|
---|
[00e8290] | 1121 | {
|
---|
[b93ec7c0] | 1122 | ui_wnd_params_t params;
|
---|
| 1123 | ui_window_t *window = NULL;
|
---|
[00e8290] | 1124 | gfx_context_t *gc;
|
---|
[b93ec7c0] | 1125 | gfx_rect_t rect;
|
---|
| 1126 | gfx_rect_t wrect;
|
---|
| 1127 | gfx_coord2_t off;
|
---|
[788c76e3] | 1128 | gfx_rect_t ui_rect;
|
---|
| 1129 | gfx_coord2_t dims;
|
---|
[9adae25] | 1130 | demo_ui_args_t args;
|
---|
| 1131 | fid_t fid;
|
---|
[00e8290] | 1132 | errno_t rc;
|
---|
| 1133 |
|
---|
[b93ec7c0] | 1134 | rc = ui_create(display_spec, &ui);
|
---|
| 1135 | if (rc != EOK) {
|
---|
| 1136 | printf("Error initializing UI (%s)\n", display_spec);
|
---|
| 1137 | goto error;
|
---|
[00e8290] | 1138 | }
|
---|
| 1139 |
|
---|
[788c76e3] | 1140 | rc = ui_get_rect(ui, &ui_rect);
|
---|
| 1141 | if (rc != EOK) {
|
---|
| 1142 | printf("Error getting display size.\n");
|
---|
| 1143 | goto error;
|
---|
| 1144 | }
|
---|
| 1145 |
|
---|
[b93ec7c0] | 1146 | rect.p0.x = 0;
|
---|
| 1147 | rect.p0.y = 0;
|
---|
| 1148 | rect.p1.x = 400;
|
---|
| 1149 | rect.p1.y = 300;
|
---|
[00e8290] | 1150 |
|
---|
[b93ec7c0] | 1151 | ui_wnd_params_init(¶ms);
|
---|
| 1152 | params.caption = "GFX Demo";
|
---|
[00e8290] | 1153 |
|
---|
[f1ce7ff] | 1154 | /* Do not decorate the window in fullscreen mode */
|
---|
| 1155 | if (ui_is_fullscreen(ui))
|
---|
| 1156 | params.style &= ~ui_wds_decorated;
|
---|
| 1157 |
|
---|
[b93ec7c0] | 1158 | /*
|
---|
| 1159 | * Compute window rectangle such that application area corresponds
|
---|
| 1160 | * to rect
|
---|
| 1161 | */
|
---|
[266ec54] | 1162 | ui_wdecor_rect_from_app(params.style, &rect, &wrect);
|
---|
[b93ec7c0] | 1163 | off = wrect.p0;
|
---|
| 1164 | gfx_rect_rtranslate(&off, &wrect, ¶ms.rect);
|
---|
[00e8290] | 1165 |
|
---|
[788c76e3] | 1166 | gfx_rect_dims(&ui_rect, &dims);
|
---|
| 1167 |
|
---|
| 1168 | /* Make sure window is not larger than the entire screen */
|
---|
| 1169 | if (params.rect.p1.x > dims.x)
|
---|
| 1170 | params.rect.p1.x = dims.x;
|
---|
| 1171 | if (params.rect.p1.y > dims.y)
|
---|
| 1172 | params.rect.p1.y = dims.y;
|
---|
| 1173 |
|
---|
[b93ec7c0] | 1174 | rc = ui_window_create(ui, ¶ms, &window);
|
---|
| 1175 | if (rc != EOK) {
|
---|
| 1176 | printf("Error creating window.\n");
|
---|
| 1177 | goto error;
|
---|
[00e8290] | 1178 | }
|
---|
| 1179 |
|
---|
[b93ec7c0] | 1180 | ui_window_set_cb(window, &ui_window_cb, NULL);
|
---|
[00e8290] | 1181 |
|
---|
[b93ec7c0] | 1182 | rc = ui_window_get_app_gc(window, &gc);
|
---|
| 1183 | if (rc != EOK) {
|
---|
| 1184 | printf("Error creating graphic context.\n");
|
---|
| 1185 | goto error;
|
---|
| 1186 | }
|
---|
[00e8290] | 1187 |
|
---|
[788c76e3] | 1188 | ui_window_get_app_rect(window, &rect);
|
---|
| 1189 | gfx_rect_dims(&rect, &dims);
|
---|
| 1190 |
|
---|
| 1191 | if (!ui_is_fullscreen(ui))
|
---|
| 1192 | task_retval(0);
|
---|
[5bded44] | 1193 |
|
---|
[9adae25] | 1194 | args.gc = gc;
|
---|
| 1195 | args.dims = dims;
|
---|
| 1196 | args.ui = ui;
|
---|
| 1197 |
|
---|
| 1198 | fid = fibril_create(demo_ui_fibril, (void *)&args);
|
---|
| 1199 | if (fid == 0) {
|
---|
| 1200 | rc = ENOMEM;
|
---|
[b93ec7c0] | 1201 | goto error;
|
---|
[9adae25] | 1202 | }
|
---|
| 1203 |
|
---|
| 1204 | fibril_add_ready(fid);
|
---|
[00e8290] | 1205 |
|
---|
[9adae25] | 1206 | ui_run(ui);
|
---|
[b93ec7c0] | 1207 | ui_window_destroy(window);
|
---|
| 1208 | ui_destroy(ui);
|
---|
[00e8290] | 1209 |
|
---|
| 1210 | return EOK;
|
---|
[b93ec7c0] | 1211 | error:
|
---|
| 1212 | if (window != NULL)
|
---|
| 1213 | ui_window_destroy(window);
|
---|
| 1214 | if (ui != NULL)
|
---|
| 1215 | ui_destroy(ui);
|
---|
| 1216 | return rc;
|
---|
[00e8290] | 1217 | }
|
---|
| 1218 |
|
---|
[c8cf261] | 1219 | /** Run demo on display server. */
|
---|
[fd11144] | 1220 | static errno_t demo_display(const char *display_svc)
|
---|
[c8cf261] | 1221 | {
|
---|
| 1222 | display_t *display = NULL;
|
---|
| 1223 | gfx_context_t *gc;
|
---|
[4d9c807] | 1224 | display_wnd_params_t params;
|
---|
[c8cf261] | 1225 | display_window_t *window = NULL;
|
---|
| 1226 | errno_t rc;
|
---|
| 1227 |
|
---|
[fd11144] | 1228 | rc = display_open(display_svc, &display);
|
---|
[c8cf261] | 1229 | if (rc != EOK) {
|
---|
| 1230 | printf("Error opening display.\n");
|
---|
| 1231 | return rc;
|
---|
| 1232 | }
|
---|
| 1233 |
|
---|
[4d9c807] | 1234 | display_wnd_params_init(¶ms);
|
---|
| 1235 | params.rect.p0.x = 0;
|
---|
| 1236 | params.rect.p0.y = 0;
|
---|
| 1237 | params.rect.p1.x = 400;
|
---|
| 1238 | params.rect.p1.y = 300;
|
---|
[7cc30e9] | 1239 | params.caption = "GFX Demo";
|
---|
[4d9c807] | 1240 |
|
---|
| 1241 | rc = display_window_create(display, ¶ms, &wnd_cb, NULL, &window);
|
---|
[c8cf261] | 1242 | if (rc != EOK) {
|
---|
| 1243 | printf("Error creating window.\n");
|
---|
| 1244 | return rc;
|
---|
| 1245 | }
|
---|
| 1246 |
|
---|
| 1247 | rc = display_window_get_gc(window, &gc);
|
---|
| 1248 | if (rc != EOK) {
|
---|
| 1249 | printf("Error getting graphics context.\n");
|
---|
[32dde7e8] | 1250 | return rc;
|
---|
[c8cf261] | 1251 | }
|
---|
| 1252 |
|
---|
[5bded44] | 1253 | task_retval(0);
|
---|
| 1254 |
|
---|
[e0545de] | 1255 | rc = demo_loop(gc, 400, 300);
|
---|
[c8cf261] | 1256 | if (rc != EOK)
|
---|
| 1257 | return rc;
|
---|
| 1258 |
|
---|
| 1259 | rc = gfx_context_delete(gc);
|
---|
| 1260 | if (rc != EOK)
|
---|
| 1261 | return rc;
|
---|
| 1262 |
|
---|
[e49b7997] | 1263 | display_window_destroy(window);
|
---|
| 1264 | display_close(display);
|
---|
| 1265 |
|
---|
[c8cf261] | 1266 | return EOK;
|
---|
| 1267 | }
|
---|
| 1268 |
|
---|
[af967ef9] | 1269 | static void demo_quit(void)
|
---|
[338d0935] | 1270 | {
|
---|
[af967ef9] | 1271 | fibril_mutex_lock(&quit_lock);
|
---|
[338d0935] | 1272 | quit = true;
|
---|
[af967ef9] | 1273 | fibril_mutex_unlock(&quit_lock);
|
---|
| 1274 | fibril_condvar_broadcast(&quit_cv);
|
---|
| 1275 | }
|
---|
| 1276 |
|
---|
| 1277 | static void wnd_close_event(void *arg)
|
---|
| 1278 | {
|
---|
| 1279 | demo_quit();
|
---|
[338d0935] | 1280 | }
|
---|
| 1281 |
|
---|
[f9ae472] | 1282 | static void demo_kbd_event(kbd_event_t *event)
|
---|
| 1283 | {
|
---|
| 1284 | if (event->type == KEY_PRESS) {
|
---|
| 1285 | /* Ctrl-Q */
|
---|
| 1286 | if ((event->mods & KM_CTRL) != 0 &&
|
---|
| 1287 | (event->mods & KM_ALT) == 0 &&
|
---|
| 1288 | (event->mods & KM_SHIFT) == 0 &&
|
---|
| 1289 | event->key == KC_Q) {
|
---|
| 1290 | demo_quit();
|
---|
| 1291 | }
|
---|
| 1292 |
|
---|
| 1293 | /* Escape */
|
---|
| 1294 | if ((event->mods & KM_CTRL) == 0 &&
|
---|
| 1295 | (event->mods & KM_ALT) == 0 &&
|
---|
| 1296 | (event->mods & KM_SHIFT) == 0 &&
|
---|
| 1297 | event->key == KC_ESCAPE) {
|
---|
| 1298 | demo_quit();
|
---|
| 1299 | }
|
---|
| 1300 | }
|
---|
| 1301 | }
|
---|
| 1302 |
|
---|
[b3c185b6] | 1303 | static void wnd_kbd_event(void *arg, kbd_event_t *event)
|
---|
| 1304 | {
|
---|
[f9ae472] | 1305 | (void)arg;
|
---|
| 1306 | demo_kbd_event(event);
|
---|
[b3c185b6] | 1307 | }
|
---|
| 1308 |
|
---|
[b93ec7c0] | 1309 | static void uiwnd_close_event(ui_window_t *window, void *arg)
|
---|
| 1310 | {
|
---|
[af967ef9] | 1311 | demo_quit();
|
---|
[b93ec7c0] | 1312 | }
|
---|
| 1313 |
|
---|
| 1314 | static void uiwnd_kbd_event(ui_window_t *window, void *arg, kbd_event_t *event)
|
---|
| 1315 | {
|
---|
[f9ae472] | 1316 | (void)window;
|
---|
| 1317 | (void)arg;
|
---|
| 1318 | demo_kbd_event(event);
|
---|
[b93ec7c0] | 1319 | }
|
---|
| 1320 |
|
---|
[00e8290] | 1321 | static void print_syntax(void)
|
---|
| 1322 | {
|
---|
[bac8acab] | 1323 | printf("Syntax: gfxdemo [-d <display>] {console|display|ui}\n");
|
---|
[00e8290] | 1324 | }
|
---|
| 1325 |
|
---|
| 1326 | int main(int argc, char *argv[])
|
---|
| 1327 | {
|
---|
| 1328 | errno_t rc;
|
---|
[fd11144] | 1329 | const char *display_svc = DISPLAY_DEFAULT;
|
---|
[9e240c1] | 1330 | const char *ui_display_spec = UI_ANY_DEFAULT;
|
---|
[fd11144] | 1331 | int i;
|
---|
| 1332 |
|
---|
| 1333 | i = 1;
|
---|
| 1334 | while (i < argc && argv[i][0] == '-') {
|
---|
| 1335 | if (str_cmp(argv[i], "-d") == 0) {
|
---|
| 1336 | ++i;
|
---|
| 1337 | if (i >= argc) {
|
---|
| 1338 | printf("Argument missing.\n");
|
---|
| 1339 | print_syntax();
|
---|
| 1340 | return 1;
|
---|
| 1341 | }
|
---|
| 1342 |
|
---|
[232bf2c] | 1343 | display_svc = ui_display_spec = argv[i++];
|
---|
[fd11144] | 1344 | } else {
|
---|
| 1345 | printf("Invalid option '%s'.\n", argv[i]);
|
---|
| 1346 | print_syntax();
|
---|
| 1347 | return 1;
|
---|
| 1348 | }
|
---|
| 1349 | }
|
---|
[00e8290] | 1350 |
|
---|
[fd11144] | 1351 | if (i >= argc || str_cmp(argv[i], "display") == 0) {
|
---|
| 1352 | rc = demo_display(display_svc);
|
---|
[0b63dc2] | 1353 | if (rc != EOK)
|
---|
| 1354 | return 1;
|
---|
[fd11144] | 1355 | } else if (str_cmp(argv[i], "console") == 0) {
|
---|
[00e8290] | 1356 | rc = demo_console();
|
---|
| 1357 | if (rc != EOK)
|
---|
| 1358 | return 1;
|
---|
[b93ec7c0] | 1359 | } else if (str_cmp(argv[i], "ui") == 0) {
|
---|
[232bf2c] | 1360 | rc = demo_ui(ui_display_spec);
|
---|
[00e8290] | 1361 | if (rc != EOK)
|
---|
| 1362 | return 1;
|
---|
| 1363 | } else {
|
---|
| 1364 | print_syntax();
|
---|
| 1365 | return 1;
|
---|
| 1366 | }
|
---|
[045186b] | 1367 | }
|
---|
| 1368 |
|
---|
| 1369 | /** @}
|
---|
| 1370 | */
|
---|