cscg24-guacamole

CSCG 2024 Challenge 'Guacamole Mashup'
git clone https://git.sinitax.com/sinitax/cscg24-guacamole
Log | Files | Refs | sfeed.txt

glyph.h (6935B)


      1/*
      2 * Licensed to the Apache Software Foundation (ASF) under one
      3 * or more contributor license agreements.  See the NOTICE file
      4 * distributed with this work for additional information
      5 * regarding copyright ownership.  The ASF licenses this file
      6 * to you under the Apache License, Version 2.0 (the
      7 * "License"); you may not use this file except in compliance
      8 * with the License.  You may obtain a copy of the License at
      9 *
     10 *   http://www.apache.org/licenses/LICENSE-2.0
     11 *
     12 * Unless required by applicable law or agreed to in writing,
     13 * software distributed under the License is distributed on an
     14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     15 * KIND, either express or implied.  See the License for the
     16 * specific language governing permissions and limitations
     17 * under the License.
     18 */
     19
     20#ifndef GUAC_RDP_GLYPH_H
     21#define GUAC_RDP_GLYPH_H
     22
     23#include "config.h"
     24
     25#include <cairo/cairo.h>
     26#include <freerdp/freerdp.h>
     27#include <freerdp/graphics.h>
     28#include <winpr/wtypes.h>
     29
     30#ifdef FREERDP_GLYPH_CALLBACKS_ACCEPT_INT32
     31/**
     32 * FreeRDP 2.0.0-rc4 and newer requires INT32 for all integer arguments of
     33 * glyph callbacks.
     34 */
     35#define GLYPH_CALLBACK_INT32 INT32
     36#else
     37/**
     38 * FreeRDP 2.0.0-rc3 and older requires UINT32 for all integer arguments of
     39 * glyph callbacks.
     40 */
     41#define GLYPH_CALLBACK_INT32 UINT32
     42#endif
     43
     44/**
     45 * Guacamole-specific rdpGlyph data.
     46 */
     47typedef struct guac_rdp_glyph {
     48
     49    /**
     50     * FreeRDP glyph data - MUST GO FIRST.
     51     */
     52    rdpGlyph glyph;
     53
     54    /**
     55     * Cairo surface layer containing cached image data.
     56     */
     57    cairo_surface_t* surface;
     58
     59} guac_rdp_glyph;
     60
     61/**
     62 * Caches the given glyph. Note that this caching currently only occurs server-
     63 * side, as it is more efficient to transmit the text as PNG.
     64 *
     65 * @param context
     66 *     The rdpContext associated with the current RDP session.
     67 *
     68 * @param glyph
     69 *     The glyph to cache.
     70 *
     71 * @return
     72 *     TRUE if successful, FALSE otherwise.
     73 */
     74BOOL guac_rdp_glyph_new(rdpContext* context, const rdpGlyph* glyph);
     75
     76/**
     77 * Draws a previously-cached glyph at the given coordinates within the current
     78 * drawing surface.
     79 *
     80 * @param context
     81 *     The rdpContext associated with the current RDP session.
     82 *
     83 * @param glyph
     84 *     The cached glyph to draw.
     85 *
     86 * @param x
     87 *     The destination X coordinate of the upper-left corner of the glyph.
     88 *
     89 * @param y
     90 *     The destination Y coordinate of the upper-left corner of the glyph.
     91 *
     92 * @param w
     93 *     The width of the glyph being drawn.
     94 *
     95 * @param h
     96 *     The height of the glyph being drawn.
     97 *
     98 * @param sx
     99 *     The X coordinate of the upper-left corner of the glyph within the source
    100 *     cache surface containing the glyph.
    101 *
    102 * @param sy
    103 *     The Y coordinate of the upper-left corner of the glyph within the source
    104 *     cache surface containing the glyph.
    105 *
    106 * @param redundant
    107 *     Whether the background rectangle specified is redundant (transparent).
    108 *
    109 * @return
    110 *     TRUE if successful, FALSE otherwise.
    111 */
    112BOOL guac_rdp_glyph_draw(rdpContext* context, const rdpGlyph* glyph,
    113        GLYPH_CALLBACK_INT32 x, GLYPH_CALLBACK_INT32 y,
    114        GLYPH_CALLBACK_INT32 w, GLYPH_CALLBACK_INT32 h,
    115        GLYPH_CALLBACK_INT32 sx, GLYPH_CALLBACK_INT32 sy,
    116        BOOL redundant);
    117
    118/**
    119 * Frees any Guacamole-specific data associated with the given glyph, such that
    120 * it can be safely freed by FreeRDP.
    121 *
    122 * @param context
    123 *     The rdpContext associated with the current RDP session.
    124 *
    125 * @param glyph
    126 *     The cached glyph to free.
    127 */
    128void guac_rdp_glyph_free(rdpContext* context, rdpGlyph* glyph);
    129
    130/**
    131 * Called just prior to rendering a series of glyphs. After this function is
    132 * called, the glyphs will be individually rendered by calls to
    133 * guac_rdp_glyph_draw().
    134 *
    135 * @param context
    136 *     The rdpContext associated with the current RDP session.
    137 *
    138 * @param x
    139 *     The X coordinate of the upper-left corner of the background rectangle of
    140 *     the drawing operation, or 0 if the background is transparent.
    141 *
    142 * @param y
    143 *     The Y coordinate of the upper-left corner of the background rectangle of
    144 *     the drawing operation, or 0 if the background is transparent.
    145 *
    146 * @param width
    147 *     The width of the background rectangle of the drawing operation, or 0 if
    148 *     the background is transparent.
    149 *
    150 * @param height 
    151 *     The height of the background rectangle of the drawing operation, or 0 if
    152 *     the background is transparent.
    153 *
    154 * @param fgcolor
    155 *     The foreground color of each glyph. This color will be in the colorspace
    156 *     of the RDP session, and may even be a palette index, and must be
    157 *     translated via guac_rdp_convert_color().
    158 *
    159 * @param bgcolor
    160 *     The background color of the drawing area. This color will be in the
    161 *     colorspace of the RDP session, and may even be a palette index, and must
    162 *     be translated via guac_rdp_convert_color(). If the background is
    163 *     transparent, this value is undefined.
    164 *
    165 * @param redundant
    166 *     Whether the background rectangle specified is redundant (transparent).
    167 *
    168 * @return
    169 *     TRUE if successful, FALSE otherwise.
    170 */
    171BOOL guac_rdp_glyph_begindraw(rdpContext* context,
    172        GLYPH_CALLBACK_INT32 x, GLYPH_CALLBACK_INT32 y,
    173        GLYPH_CALLBACK_INT32 width, GLYPH_CALLBACK_INT32 height,
    174        UINT32 fgcolor, UINT32 bgcolor, BOOL redundant);
    175
    176/**
    177 * Called immediately after rendering a series of glyphs. Unlike
    178 * guac_rdp_glyph_begindraw(), there is no way to detect through any invocation
    179 * of this function whether the background color is opaque or transparent. We
    180 * currently do NOT implement this function.
    181 *
    182 * @param context
    183 *     The rdpContext associated with the current RDP session.
    184 *
    185 * @param x
    186 *     The X coordinate of the upper-left corner of the background rectangle of
    187 *     the drawing operation.
    188 *
    189 * @param y
    190 *     The Y coordinate of the upper-left corner of the background rectangle of
    191 *     the drawing operation.
    192 *
    193 * @param width
    194 *     The width of the background rectangle of the drawing operation.
    195 *
    196 * @param height 
    197 *     The height of the background rectangle of the drawing operation.
    198 *
    199 * @param fgcolor
    200 *     The foreground color of each glyph. This color will be in the colorspace
    201 *     of the RDP session, and may even be a palette index, and must be
    202 *     translated via guac_rdp_convert_color().
    203 *
    204 * @param bgcolor
    205 *     The background color of the drawing area. This color will be in the
    206 *     colorspace of the RDP session, and may even be a palette index, and must
    207 *     be translated via guac_rdp_convert_color(). If the background is
    208 *     transparent, this value is undefined.
    209 *
    210 * @return
    211 *     TRUE if successful, FALSE otherwise.
    212 */
    213BOOL guac_rdp_glyph_enddraw(rdpContext* context,
    214        GLYPH_CALLBACK_INT32 x, GLYPH_CALLBACK_INT32 y,
    215        GLYPH_CALLBACK_INT32 width, GLYPH_CALLBACK_INT32 height,
    216        UINT32 fgcolor, UINT32 bgcolor);
    217
    218#endif