Changeset 9be2358 in mainline


Ignore:
Timestamp:
2019-09-23T13:05:52Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
00e8290
Parents:
3e828ea
git-author:
Jiri Svoboda <jiri@…> (2019-09-22 13:04:48)
git-committer:
Jiri Svoboda <jiri@…> (2019-09-23 13:05:52)
Message:

Caller needs entire console GC to be able to destroy it properly

Location:
uspace
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/gfxdemo/gfxdemo.c

    r3e828ea r9be2358  
    4444        console_ctrl_t *con = NULL;
    4545        gfx_color_t *color = NULL;
    46         gfx_context_t *gc = NULL;
     46        console_gc_t *cgc = NULL;
     47        gfx_context_t *gc;
    4748        gfx_rect_t rect;
    4849        int i;
     
    5556
    5657        printf("Create console GC\n");
    57         rc = console_gc_create(con, stdout, &gc);
     58        rc = console_gc_create(con, stdout, &cgc);
    5859        if (rc != EOK)
    5960                return 1;
     61
     62        gc = console_gc_get_ctx(cgc);
    6063
    6164        while (true) {
     
    8588        }
    8689
    87         // TODO How will we free GC subclass?
    88 
    89         // rc = gfx_context_delete(gc);
    90         // if (rc != EOK)
    91         //      return 1;
     90        rc = console_gc_delete(cgc);
     91        if (rc != EOK)
     92                return 1;
    9293
    9394        return 0;
  • uspace/lib/gfx/include/gfx/backend/console.h

    r3e828ea r9be2358  
    4545extern gfx_context_ops_t console_gc_ops;
    4646
    47 extern errno_t console_gc_create(console_ctrl_t *, FILE *, gfx_context_t **);
     47extern errno_t console_gc_create(console_ctrl_t *, FILE *, console_gc_t **);
     48extern errno_t console_gc_delete(console_gc_t *);
     49extern gfx_context_t *console_gc_get_ctx(console_gc_t *);
    4850
    4951#endif
  • uspace/lib/gfx/private/backend/console.h

    r3e828ea r9be2358  
    4040#include <io/console.h>
    4141#include <stdio.h>
     42#include "../context.h"
    4243
    4344/** Actual structure of graphics context.
     
    4647 */
    4748struct console_gc {
     49        /** Base graphic context */
     50        gfx_context_t *gc;
    4851        /** Console control structure */
    4952        console_ctrl_t *con;
  • uspace/lib/gfx/src/backend/console.c

    r3e828ea r9be2358  
    115115 */
    116116errno_t console_gc_create(console_ctrl_t *con, FILE *fout,
    117     gfx_context_t **rgc)
     117    console_gc_t **rgc)
    118118{
    119119        console_gc_t *cgc = NULL;
     
    131131                goto error;
    132132
     133        cgc->gc = gc;
    133134        cgc->con = con;
    134135        cgc->fout = fout;
    135         *rgc = gc;
     136        *rgc = cgc;
    136137        return EOK;
    137138error:
     
    142143}
    143144
     145/** Delete console GC.
     146 *
     147 * @param cgc Console GC
     148 */
     149errno_t console_gc_delete(console_gc_t *cgc)
     150{
     151        errno_t rc;
     152
     153        rc = gfx_context_delete(cgc->gc);
     154        if (rc != EOK)
     155                return rc;
     156
     157        free(cgc);
     158        return EOK;
     159}
     160
     161/** Get generic graphic context from console GC.
     162 *
     163 * @param cgc Console GC
     164 * @return Graphic context
     165 */
     166gfx_context_t *console_gc_get_ctx(console_gc_t *cgc)
     167{
     168        return cgc->gc;
     169}
     170
    144171/** @}
    145172 */
Note: See TracChangeset for help on using the changeset viewer.