Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType Demo Programs
Commits:
-
faa5c9af
by Alexei Podtelezhnikov at 2021-01-26T13:30:03-05:00
-
12d9a546
by Alexei Podtelezhnikov at 2021-01-26T13:32:49-05:00
-
3f3293da
by Alexei Podtelezhnikov at 2021-01-26T14:00:34-05:00
9 changed files:
- ChangeLog
- graph/graph.h
- graph/grblit.c
- graph/grdevice.c
- graph/grfont.c
- src/ftcommon.c
- src/ftdiff.c
- src/ftgrid.c
- src/ftmulti.c
Changes:
1 |
+2021-01-26 Alexei Podtelezhnikov <apodtele@gmail.com>
|
|
2 |
+ |
|
3 |
+ [graph] Decouple the legacy and alpha blenders.
|
|
4 |
+ |
|
5 |
+ * graph/grblit.c (grBlitGlyphToBitmap): Do not call
|
|
6 |
+ `grBlitGlyphToSurface'.
|
|
7 |
+ * src/*: s/grBlitGlyphToBitmap/grBlitGlyphToSurface/.
|
|
8 |
+ |
|
9 |
+2021-01-26 Alexei Podtelezhnikov <apodtele@gmail.com>
|
|
10 |
+ |
|
11 |
+ * graph/grfont.c (gr_charcell): Minor.
|
|
12 |
+ |
|
1 | 13 |
2021-01-25 Alexei Podtelezhnikov <apodtele@gmail.com>
|
2 | 14 |
|
3 | 15 |
[graph] Handle mono bitmaps in the main blender.
|
... | ... | @@ -96,7 +96,6 @@ |
96 | 96 |
} grBitmap;
|
97 | 97 |
|
98 | 98 |
|
99 |
- |
|
100 | 99 |
typedef long grPos;
|
101 | 100 |
typedef char grBool;
|
102 | 101 |
|
... | ... | @@ -108,6 +107,23 @@ |
108 | 107 |
} grVector;
|
109 | 108 |
|
110 | 109 |
|
110 |
+ /*********************************************************************
|
|
111 |
+ *
|
|
112 |
+ * <Union>
|
|
113 |
+ * grColor
|
|
114 |
+ *
|
|
115 |
+ * <Description>
|
|
116 |
+ * a generic color pixel with arbitrary depth up to 32 bits.
|
|
117 |
+ *
|
|
118 |
+ * <Fields>
|
|
119 |
+ * value :: for colors represented using bitfields
|
|
120 |
+ * chroma :: for colors in a particular byte order
|
|
121 |
+ *
|
|
122 |
+ * <Note>
|
|
123 |
+ * Use grFindColor to set grColor corresponding to grBitmap.
|
|
124 |
+ *
|
|
125 |
+ ********************************************************************/
|
|
126 |
+ |
|
111 | 127 |
typedef union grColor_
|
112 | 128 |
{
|
113 | 129 |
uint32_t value;
|
... | ... | @@ -116,6 +132,30 @@ |
116 | 132 |
} grColor;
|
117 | 133 |
|
118 | 134 |
|
135 |
+ /**********************************************************************
|
|
136 |
+ *
|
|
137 |
+ * <Function>
|
|
138 |
+ * grFindColor
|
|
139 |
+ *
|
|
140 |
+ * <Description>
|
|
141 |
+ * return grColor pixel appropriate for a target mode.
|
|
142 |
+ *
|
|
143 |
+ * <Input>
|
|
144 |
+ * target :: used to match the pixel mode
|
|
145 |
+ * red :: red value in 0..255 range
|
|
146 |
+ * green :: green value in 0..255 range
|
|
147 |
+ * blue :: blue value in 0..255 range
|
|
148 |
+ * alpha :: alpha value in 0..255 range
|
|
149 |
+ *
|
|
150 |
+ ********************************************************************/
|
|
151 |
+ extern grColor
|
|
152 |
+ grFindColor( grBitmap* target,
|
|
153 |
+ int red,
|
|
154 |
+ int green,
|
|
155 |
+ int blue,
|
|
156 |
+ int alpha );
|
|
157 |
+ |
|
158 |
+ |
|
119 | 159 |
/**********************************************************************
|
120 | 160 |
*
|
121 | 161 |
* <Function>
|
... | ... | @@ -181,7 +221,7 @@ |
181 | 221 |
* bitmap with fewer levels of grays, as this would much probably
|
182 | 222 |
* give unpleasant results..
|
183 | 223 |
*
|
184 |
- * This function performs clipping
|
|
224 |
+ * This function performs clipping.
|
|
185 | 225 |
*
|
186 | 226 |
**********************************************************************/
|
187 | 227 |
|
... | ... | @@ -193,32 +233,22 @@ |
193 | 233 |
grColor color );
|
194 | 234 |
|
195 | 235 |
|
196 |
- /* values must be in 0..255 range */
|
|
197 |
- extern grColor
|
|
198 |
- grFindColor( grBitmap* target,
|
|
199 |
- int red,
|
|
200 |
- int green,
|
|
201 |
- int blue,
|
|
202 |
- int alpha );
|
|
203 |
- |
|
204 |
- |
|
205 | 236 |
/**********************************************************************
|
206 | 237 |
*
|
207 | 238 |
* <Function>
|
208 | 239 |
* grWriteCellChar
|
209 | 240 |
*
|
210 | 241 |
* <Description>
|
211 |
- * The graphics sub-system contains an internal CP437 8x8 font
|
|
212 |
- * which can be used to display simple strings of text without
|
|
213 |
- * using FreeType.
|
|
242 |
+ * The graphics sub-system contains an internal CP437 font which can
|
|
243 |
+ * be used to display simple strings of text without using FreeType.
|
|
214 | 244 |
*
|
215 |
- * This function writes a single 8x8 character on the target bitmap.
|
|
245 |
+ * This function writes a single character on the target bitmap.
|
|
216 | 246 |
*
|
217 | 247 |
* <Input>
|
218 | 248 |
* target :: handle to target surface
|
219 | 249 |
* x :: x pixel position of character cell's top left corner
|
220 | 250 |
* y :: y pixel position of character cell's top left corner
|
221 |
- * charcode :: Latin-1 character code
|
|
251 |
+ * charcode :: CP437 character code
|
|
222 | 252 |
* color :: color to be used to draw the character
|
223 | 253 |
*
|
224 | 254 |
**********************************************************************/
|
... | ... | @@ -237,17 +267,16 @@ |
237 | 267 |
* grWriteCellString
|
238 | 268 |
*
|
239 | 269 |
* <Description>
|
240 |
- * The graphics sub-system contains an internal CP437 8x8 font
|
|
241 |
- * which can be used to display simple strings of text without
|
|
242 |
- * using FreeType.
|
|
270 |
+ * The graphics sub-system contains an internal CP437 font which can
|
|
271 |
+ * be used to display simple strings of text without using FreeType.
|
|
243 | 272 |
*
|
244 |
- * This function writes a string with the internal font
|
|
273 |
+ * This function writes a string with the internal font.
|
|
245 | 274 |
*
|
246 | 275 |
* <Input>
|
247 | 276 |
* target :: handle to target bitmap
|
248 | 277 |
* x :: x pixel position of string's top left corner
|
249 | 278 |
* y :: y pixel position of string's top left corner
|
250 |
- * string :: Latin-1 text string
|
|
279 |
+ * string :: CP437 text string
|
|
251 | 280 |
* color :: color to be used to draw the character
|
252 | 281 |
*
|
253 | 282 |
**********************************************************************/
|
... | ... | @@ -551,6 +580,44 @@ |
551 | 580 |
extern void grRefreshSurface( grSurface* surface );
|
552 | 581 |
|
553 | 582 |
|
583 |
+ /**********************************************************************
|
|
584 |
+ *
|
|
585 |
+ * <Function>
|
|
586 |
+ * grBlitGlyphToSurface
|
|
587 |
+ *
|
|
588 |
+ * <Description>
|
|
589 |
+ * writes a given glyph bitmap to a target surface.
|
|
590 |
+ *
|
|
591 |
+ * <Input>
|
|
592 |
+ * surface :: handle to surface
|
|
593 |
+ * glyph :: handle to source glyph bitmap
|
|
594 |
+ * x :: position of left-most pixel of glyph image in target surface
|
|
595 |
+ * y :: position of top-most pixel of glyph image in target surface
|
|
596 |
+ * color :: color to be used to draw a monochrome glyph
|
|
597 |
+ *
|
|
598 |
+ * <Return>
|
|
599 |
+ * Error code. 0 means success
|
|
600 |
+ *
|
|
601 |
+ * <Note>
|
|
602 |
+ * The function performs gamma-corrected alpha blending using the source
|
|
603 |
+ * bitmap as an alpha channel(s), which can be specified for each pixel
|
|
604 |
+ * as 8-bit (gray) bitmaps, or for individual color channels in various
|
|
605 |
+ * LCD arrangements.
|
|
606 |
+ *
|
|
607 |
+ * It also handles mono and BGRA bitmaps as special cases.
|
|
608 |
+ *
|
|
609 |
+ * This function performs clipping.
|
|
610 |
+ *
|
|
611 |
+ **********************************************************************/
|
|
612 |
+ |
|
613 |
+ extern int
|
|
614 |
+ grBlitGlyphToSurface( grSurface* surface,
|
|
615 |
+ grBitmap* glyph,
|
|
616 |
+ grPos x,
|
|
617 |
+ grPos y,
|
|
618 |
+ grColor color );
|
|
619 |
+ |
|
620 |
+ |
|
554 | 621 |
/**********************************************************************
|
555 | 622 |
*
|
556 | 623 |
* <Function>
|
... | ... | @@ -560,17 +627,16 @@ |
560 | 627 |
* This function is equivalent to calling grWriteCellChar on the
|
561 | 628 |
* surface's bitmap, then invoking grRefreshRectangle.
|
562 | 629 |
*
|
563 |
- * The graphics sub-system contains an internal CP437 8x8 font
|
|
564 |
- * which can be used to display simple strings of text without
|
|
565 |
- * using FreeType.
|
|
630 |
+ * The graphics sub-system contains an internal CP437 font which can
|
|
631 |
+ * be used to display simple strings of text without using FreeType.
|
|
566 | 632 |
*
|
567 |
- * This function writes a single 8x8 character on the target bitmap.
|
|
633 |
+ * This function writes a single character on the target bitmap.
|
|
568 | 634 |
*
|
569 | 635 |
* <Input>
|
570 | 636 |
* target :: handle to target surface
|
571 | 637 |
* x :: x pixel position of character cell's top left corner
|
572 | 638 |
* y :: y pixel position of character cell's top left corner
|
573 |
- * charcode :: Latin-1 character code
|
|
639 |
+ * charcode :: CP437 character code
|
|
574 | 640 |
* color :: color to be used to draw the character
|
575 | 641 |
*
|
576 | 642 |
**********************************************************************/
|
... | ... | @@ -592,17 +658,16 @@ |
592 | 658 |
* This function is equivalent to calling grWriteCellString on the
|
593 | 659 |
* surface's bitmap, then invoking grRefreshRectangle.
|
594 | 660 |
*
|
595 |
- * The graphics sub-system contains an internal CP437 8x8 font
|
|
596 |
- * which can be used to display simple strings of text without
|
|
597 |
- * using FreeType.
|
|
661 |
+ * The graphics sub-system contains an internal CP437 font which can
|
|
662 |
+ * be used to display simple strings of text without using FreeType.
|
|
598 | 663 |
*
|
599 |
- * This function writes a string with the internal font
|
|
664 |
+ * This function writes a string with the internal font.
|
|
600 | 665 |
*
|
601 | 666 |
* <Input>
|
602 | 667 |
* target :: handle to target bitmap
|
603 | 668 |
* x :: x pixel position of string's top left corner
|
604 | 669 |
* y :: y pixel position of string's top left corner
|
605 |
- * string :: Latin-1 text string
|
|
670 |
+ * string :: CP437 text string
|
|
606 | 671 |
* color :: color to be used to draw the character
|
607 | 672 |
*
|
608 | 673 |
**********************************************************************/
|
... | ... | @@ -673,7 +738,7 @@ |
673 | 738 |
* event :: the returned event
|
674 | 739 |
*
|
675 | 740 |
* <Note>
|
676 |
- * XXX : For now, only keypresses are supported.
|
|
741 |
+ * Only keypresses and resizing events are supported.
|
|
677 | 742 |
*
|
678 | 743 |
**********************************************************************/
|
679 | 744 |
|
... | ... | @@ -10,7 +10,6 @@ |
10 | 10 |
/****************************************************************************/
|
11 | 11 |
|
12 | 12 |
#include "grblit.h"
|
13 |
-#include "gblblit.h"
|
|
14 | 13 |
|
15 | 14 |
#define GRAY8
|
16 | 15 |
|
... | ... | @@ -1800,15 +1799,6 @@ |
1800 | 1799 |
return 0;
|
1801 | 1800 |
}
|
1802 | 1801 |
|
1803 |
- /* short cut to alpha blender for certain glyph types */
|
|
1804 |
- switch ( grBlitGlyphToSurface( (grSurface*)target, glyph, x, y, color ) )
|
|
1805 |
- {
|
|
1806 |
- case 1:
|
|
1807 |
- return 1;
|
|
1808 |
- case 0:
|
|
1809 |
- return 0;
|
|
1810 |
- }
|
|
1811 |
- |
|
1812 | 1802 |
/* set up blitter and compute clipping. Return immediately if needed */
|
1813 | 1803 |
blit.source = *glyph;
|
1814 | 1804 |
blit.target = *target;
|
... | ... | @@ -218,17 +218,16 @@ |
218 | 218 |
* This function is equivalent to calling grWriteCellChar on the
|
219 | 219 |
* surface's bitmap, then invoking grRefreshRectangle.
|
220 | 220 |
*
|
221 |
- * The graphics sub-system contains an internal CP437 8x8 font
|
|
222 |
- * which can be used to display simple strings of text without
|
|
223 |
- * using FreeType.
|
|
221 |
+ * The graphics sub-system contains an internal CP437 font which can
|
|
222 |
+ * be used to display simple strings of text without using FreeType.
|
|
224 | 223 |
*
|
225 |
- * This function writes a single 8x8 character on the target bitmap.
|
|
224 |
+ * This function writes a single character on the target bitmap.
|
|
226 | 225 |
*
|
227 | 226 |
* <Input>
|
228 | 227 |
* target :: handle to target surface
|
229 | 228 |
* x :: x pixel position of character cell's top left corner
|
230 | 229 |
* y :: y pixel position of character cell's top left corner
|
231 |
- * charcode :: Latin-1 character code
|
|
230 |
+ * charcode :: CP437 character code
|
|
232 | 231 |
* color :: color to be used to draw the character
|
233 | 232 |
*
|
234 | 233 |
**********************************************************************/
|
... | ... | @@ -255,9 +254,8 @@ |
255 | 254 |
* This function is equivalent to calling grWriteCellString on the
|
256 | 255 |
* surface's bitmap, then invoking grRefreshRectangle.
|
257 | 256 |
*
|
258 |
- * The graphics sub-system contains an internal CP437 8x8 font
|
|
259 |
- * which can be used to display simple strings of text without
|
|
260 |
- * using FreeType.
|
|
257 |
+ * The graphics sub-system contains an internal CP437 font which can
|
|
258 |
+ * be used to display simple strings of text without using FreeType.
|
|
261 | 259 |
*
|
262 | 260 |
* This function writes a string with the internal font
|
263 | 261 |
*
|
... | ... | @@ -265,7 +263,7 @@ |
265 | 263 |
* target :: handle to target bitmap
|
266 | 264 |
* x :: x pixel position of string's top left corner
|
267 | 265 |
* y :: y pixel position of string's top left corner
|
268 |
- * string :: Latin-1 text string
|
|
266 |
+ * string :: CP437 text string
|
|
269 | 267 |
* color :: color to be used to draw the character
|
270 | 268 |
*
|
271 | 269 |
**********************************************************************/
|
... | ... | @@ -544,7 +544,7 @@ |
544 | 544 |
8, /* width */
|
545 | 545 |
1, /* pitch */
|
546 | 546 |
gr_pixel_mode_mono, /* mode */
|
547 |
- 0, /* grays */
|
|
547 |
+ 2, /* grays */
|
|
548 | 548 |
NULL /* buffer */
|
549 | 549 |
};
|
550 | 550 |
|
... | ... | @@ -1693,8 +1693,8 @@ |
1693 | 1693 |
return error;
|
1694 | 1694 |
|
1695 | 1695 |
/* now render the bitmap into the display surface */
|
1696 |
- grBlitGlyphToBitmap( display->bitmap, &bit3, *pen_x + left,
|
|
1697 |
- *pen_y - top, display->fore_color );
|
|
1696 |
+ grBlitGlyphToSurface( display->surface, &bit3, *pen_x + left,
|
|
1697 |
+ *pen_y - top, display->fore_color );
|
|
1698 | 1698 |
|
1699 | 1699 |
if ( glyf )
|
1700 | 1700 |
FT_Done_Glyph( glyf );
|
... | ... | @@ -1728,8 +1728,8 @@ |
1728 | 1728 |
}
|
1729 | 1729 |
|
1730 | 1730 |
/* now render the bitmap into the display surface */
|
1731 |
- grBlitGlyphToBitmap( display->bitmap, &bit3, *pen_x + left,
|
|
1732 |
- *pen_y - top, color );
|
|
1731 |
+ grBlitGlyphToSurface( display->surface, &bit3, *pen_x + left,
|
|
1732 |
+ *pen_y - top, color );
|
|
1733 | 1733 |
|
1734 | 1734 |
if ( glyf )
|
1735 | 1735 |
FT_Done_Glyph( glyf );
|
... | ... | @@ -2060,8 +2060,8 @@ |
2060 | 2060 |
top = display->bitmap->rows - top;
|
2061 | 2061 |
|
2062 | 2062 |
/* now render the bitmap into the display surface */
|
2063 |
- grBlitGlyphToBitmap( display->bitmap, &bit3, left, top,
|
|
2064 |
- display->fore_color );
|
|
2063 |
+ grBlitGlyphToSurface( display->surface, &bit3, left, top,
|
|
2064 |
+ display->fore_color );
|
|
2065 | 2065 |
|
2066 | 2066 |
if ( glyf )
|
2067 | 2067 |
FT_Done_Glyph( glyf );
|
... | ... | @@ -1090,8 +1090,8 @@ |
1090 | 1090 |
else if ( mode == DISPLAY_MODE_LCD )
|
1091 | 1091 |
glyph.mode = gr_pixel_mode_lcd;
|
1092 | 1092 |
|
1093 |
- grBlitGlyphToBitmap( display->bitmap, &glyph,
|
|
1094 |
- x, y, display->fore_color );
|
|
1093 |
+ grBlitGlyphToSurface( display->surface, &glyph,
|
|
1094 |
+ x, y, display->fore_color );
|
|
1095 | 1095 |
}
|
1096 | 1096 |
|
1097 | 1097 |
|
... | ... | @@ -579,9 +579,9 @@ |
579 | 579 |
{
|
580 | 580 |
bitmap_scale( st, &bitg, scale );
|
581 | 581 |
|
582 |
- grBlitGlyphToBitmap( display->bitmap, &bitg,
|
|
583 |
- ox + left * scale, oy - top * scale,
|
|
584 |
- st->axis_color );
|
|
582 |
+ grBlitGlyphToSurface( display->surface, &bitg,
|
|
583 |
+ ox + left * scale, oy - top * scale,
|
|
584 |
+ st->axis_color );
|
|
585 | 585 |
|
586 | 586 |
free( bitg.buffer );
|
587 | 587 |
|
... | ... | @@ -345,8 +345,8 @@ |
345 | 345 |
x_top = x_offset + glyph->bitmap_left;
|
346 | 346 |
y_top = y_offset - glyph->bitmap_top;
|
347 | 347 |
|
348 |
- grBlitGlyphToBitmap( bit, &bit3,
|
|
349 |
- x_top, y_top, fore_color );
|
|
348 |
+ grBlitGlyphToSurface( surface, &bit3,
|
|
349 |
+ x_top, y_top, fore_color );
|
|
350 | 350 |
|
351 | 351 |
return 0;
|
352 | 352 |
}
|