xref: /aosp_15_r20/external/mesa3d/src/gallium/auxiliary/hud/font.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1*61046927SAndroid Build Coastguard Worker /**************************************************************************
2*61046927SAndroid Build Coastguard Worker  *
3*61046927SAndroid Build Coastguard Worker  * Copyright 2013 Marek Olšák <[email protected]>
4*61046927SAndroid Build Coastguard Worker  * All Rights Reserved.
5*61046927SAndroid Build Coastguard Worker  *
6*61046927SAndroid Build Coastguard Worker  * Permission is hereby granted, free of charge, to any person obtaining a
7*61046927SAndroid Build Coastguard Worker  * copy of this software and associated documentation files (the
8*61046927SAndroid Build Coastguard Worker  * "Software"), to deal in the Software without restriction, including
9*61046927SAndroid Build Coastguard Worker  * without limitation the rights to use, copy, modify, merge, publish,
10*61046927SAndroid Build Coastguard Worker  * distribute, sub license, and/or sell copies of the Software, and to
11*61046927SAndroid Build Coastguard Worker  * permit persons to whom the Software is furnished to do so, subject to
12*61046927SAndroid Build Coastguard Worker  * the following conditions:
13*61046927SAndroid Build Coastguard Worker  *
14*61046927SAndroid Build Coastguard Worker  * The above copyright notice and this permission notice (including the
15*61046927SAndroid Build Coastguard Worker  * next paragraph) shall be included in all copies or substantial portions
16*61046927SAndroid Build Coastguard Worker  * of the Software.
17*61046927SAndroid Build Coastguard Worker  *
18*61046927SAndroid Build Coastguard Worker  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19*61046927SAndroid Build Coastguard Worker  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20*61046927SAndroid Build Coastguard Worker  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21*61046927SAndroid Build Coastguard Worker  * IN NO EVENT SHALL THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR
22*61046927SAndroid Build Coastguard Worker  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23*61046927SAndroid Build Coastguard Worker  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24*61046927SAndroid Build Coastguard Worker  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25*61046927SAndroid Build Coastguard Worker  *
26*61046927SAndroid Build Coastguard Worker  **************************************************************************/
27*61046927SAndroid Build Coastguard Worker 
28*61046927SAndroid Build Coastguard Worker #ifndef FONT_H
29*61046927SAndroid Build Coastguard Worker #define FONT_H
30*61046927SAndroid Build Coastguard Worker 
31*61046927SAndroid Build Coastguard Worker #include "util/compiler.h"
32*61046927SAndroid Build Coastguard Worker 
33*61046927SAndroid Build Coastguard Worker struct pipe_resource;
34*61046927SAndroid Build Coastguard Worker struct pipe_context;
35*61046927SAndroid Build Coastguard Worker 
36*61046927SAndroid Build Coastguard Worker enum util_font_name {
37*61046927SAndroid Build Coastguard Worker    UTIL_FONT_FIXED_8X13
38*61046927SAndroid Build Coastguard Worker };
39*61046927SAndroid Build Coastguard Worker 
40*61046927SAndroid Build Coastguard Worker /* The font is stored in a 2D texture. There are 256 glyphs
41*61046927SAndroid Build Coastguard Worker  * drawn in a 16x16 matrix. The texture coordinates of a glyph
42*61046927SAndroid Build Coastguard Worker  * within the matrix should be calculated as follows:
43*61046927SAndroid Build Coastguard Worker  *
44*61046927SAndroid Build Coastguard Worker  *    x1 = (glyph % 16) * glyph_width;
45*61046927SAndroid Build Coastguard Worker  *    y1 = (glyph / 16) * glyph_height;
46*61046927SAndroid Build Coastguard Worker  *    x2 = x1 + glyph_width;
47*61046927SAndroid Build Coastguard Worker  *    y2 = y1 + glyph_height;
48*61046927SAndroid Build Coastguard Worker  */
49*61046927SAndroid Build Coastguard Worker struct util_font {
50*61046927SAndroid Build Coastguard Worker    struct pipe_resource *texture;
51*61046927SAndroid Build Coastguard Worker    unsigned glyph_width;
52*61046927SAndroid Build Coastguard Worker    unsigned glyph_height;
53*61046927SAndroid Build Coastguard Worker };
54*61046927SAndroid Build Coastguard Worker 
55*61046927SAndroid Build Coastguard Worker bool
56*61046927SAndroid Build Coastguard Worker util_font_create(struct pipe_context *pipe, enum util_font_name name,
57*61046927SAndroid Build Coastguard Worker                          struct util_font *out_font);
58*61046927SAndroid Build Coastguard Worker 
59*61046927SAndroid Build Coastguard Worker #endif
60