gonzopi

git clone https://git.tarina.org/gonzopi
Log | Files | Refs | README | LICENSE

vgfont.h (6191B)


      1 /*
      2 Copyright (c) 2012, Broadcom Europe Ltd
      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 are met:
      7     * Redistributions of source code must retain the above copyright
      8       notice, this list of conditions and the following disclaimer.
      9     * Redistributions in binary form must reproduce the above copyright
     10       notice, this list of conditions and the following disclaimer in the
     11       documentation and/or other materials provided with the distribution.
     12     * Neither the name of the copyright holder nor the
     13       names of its contributors may be used to endorse or promote products
     14       derived from this software without specific prior written permission.
     15 
     16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
     17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
     20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     26 */
     27 
     28 // Font handling for graphicsx
     29 
     30 #ifndef VCFTLIB_H
     31 #define VCFTLIB_H
     32 
     33 #include <stdint.h>
     34 #include "interface/vmcs_host/vc_dispservice_x_defs.h"
     35 #include "interface/vctypes/vc_image_types.h"
     36 #include "interface/vcos/vcos.h"
     37 
     38 //Definitions which in certain functions can be used to mean the actual width and height of a resource, without
     39 //having to know the data implicitly.
     40 #define GRAPHICS_RESOURCE_WIDTH  0xFFFF
     41 #define GRAPHICS_RESOURCE_HEIGHT 0xFFFF
     42 
     43 #define R_888_MASK      (0x00FF0000)
     44 #define G_888_MASK      (0x0000FF00)
     45 #define B_888_MASK      (0x000000FF)
     46 #define ALPHA_888_MASK  (0xFF000000)
     47 #define GRAPHICS_RGBA32( r, g, b, a ) GRAPHICS_RGBA888( r, g, b, a )
     48 #define GRAPHICS_RGBA888( r, g, b, a ) ( (((a) << (8+8+8)) & ALPHA_888_MASK) | (((b) << (8+8)) & R_888_MASK) | (((g) << 8) & G_888_MASK) | ((r) & B_888_MASK) )
     49 #define GRAPHICS_TRANSPARENT_COLOUR 0x00000001UL
     50 
     51 //resource defs
     52 
     53 typedef enum
     54 {
     55    GRAPHICS_RESOURCE_HANDLE_TYPE_MIN,
     56 
     57    GRAPHICS_RESOURCE_RGB565,
     58    GRAPHICS_RESOURCE_RGB888, /*  888 format is ONLY used when loading bitmaps
     59                                  - you can't create or delete bitmaps with this format */
     60    GRAPHICS_RESOURCE_RGBA32,
     61    GRAPHICS_RESOURCE_TF_RGB32A,
     62    GRAPHICS_RESOURCE_TF_RGB565,
     63    GRAPHICS_RESOURCE_YUV420,
     64 
     65    GRAPHICS_RESOURCE_HANDLE_TYPE_MAX
     66 
     67 } GRAPHICS_RESOURCE_TYPE_T;
     68 
     69 
     70 typedef struct GRAPHICS_RESOURCE_HANDLE_TABLE_T *GRAPHICS_RESOURCE_HANDLE;
     71 
     72 VCOS_STATUS_T gx_graphics_init(const char *font_dir);
     73 int32_t graphics_delete_resource( GRAPHICS_RESOURCE_HANDLE res );
     74 VCOS_STATUS_T gx_create_window( uint32_t screen_id,
     75                                 uint32_t width,
     76                                 uint32_t height,
     77                                 GRAPHICS_RESOURCE_TYPE_T image_type,
     78                                 GRAPHICS_RESOURCE_HANDLE *resource_handle );
     79 
     80 int32_t graphics_display_resource( GRAPHICS_RESOURCE_HANDLE res,
     81                                    const uint16_t screen_number,
     82                                    const int16_t z_order,
     83                                    const uint16_t offset_x,
     84                                    const uint16_t offset_y,
     85                                    const uint16_t dest_width,
     86                                    const uint16_t dest_height,
     87                                    const VC_DISPMAN_TRANSFORM_T transform,
     88                                    const uint8_t display );
     89 
     90 int32_t graphics_resource_fill(GRAPHICS_RESOURCE_HANDLE res,
     91                                uint32_t x,
     92                                uint32_t y,
     93                                uint32_t width,
     94                                uint32_t height,
     95                                uint32_t fill_colour );
     96 
     97 int32_t graphics_update_displayed_resource(GRAPHICS_RESOURCE_HANDLE res,
     98                                            const uint32_t x_offset,
     99                                            const uint32_t y_offset,
    100                                            const uint32_t width,
    101                                            const uint32_t height );
    102 
    103 int32_t graphics_resource_render_text_ext( GRAPHICS_RESOURCE_HANDLE res,
    104                                            const int32_t x,
    105                                            const int32_t y,
    106                                            const uint32_t width,
    107                                            const uint32_t height,
    108                                            const uint32_t fg_colour,
    109                                            const uint32_t bg_colour,
    110                                            const char *text,
    111                                            const uint32_t text_length,
    112                                            const uint32_t text_size );
    113 
    114 int32_t graphics_resource_text_dimensions_ext(GRAPHICS_RESOURCE_HANDLE res,
    115                                               const char *text,
    116                                               const uint32_t text_length,
    117                                               uint32_t *width,
    118                                               uint32_t *height,
    119                                               const uint32_t text_size );
    120 
    121 int32_t graphics_get_resource_size(
    122    const GRAPHICS_RESOURCE_HANDLE res,
    123    uint32_t *w,
    124    uint32_t *h);
    125 
    126 int32_t graphics_update_start(void);
    127 
    128 int32_t graphics_update_end( void );
    129 
    130 int32_t graphics_resource_text_dimensions( GRAPHICS_RESOURCE_HANDLE resource_handle,
    131                                            const char *text,
    132                                            const uint32_t text_length,
    133                                            uint32_t *width,
    134                                            uint32_t *height );
    135 
    136 #endif