Commit e305bd0d authored by Robert Sprowson's avatar Robert Sprowson
Browse files

Add support for background blended text and text areas

Files saved by !Draw 1.24 or later can opt to have transparent background colour to me use the blending font manager. This is the corresponding change to the renderer.
Ordinary text will not be plotted if the *foreground* colour is transparent - this seems to have been a discrepancy between !Draw and DrawFile, DrawFile used to render it in the background colour instead, imagining that this was like a shadow. The spirit of the draw file spec is that the background colour is an optional hint, however.
The state flags that end up on Service_DrawObjectRender no longer contain the DrawFile modules internal flags, only those documented.

Version 1.58. Tagged as 'DrawFile-1_58'
parent 11533ce8
No preview for this file type
/* (1.57)
/* (1.58)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 1.57
#define Module_MajorVersion_CMHG 1.58
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 10 Jan 2012
#define Module_Date_CMHG 22 Jul 2013
#define Module_MajorVersion "1.57"
#define Module_Version 157
#define Module_MajorVersion "1.58"
#define Module_Version 158
#define Module_MinorVersion ""
#define Module_Date "10 Jan 2012"
#define Module_Date "22 Jul 2013"
#define Module_ApplicationDate "10-Jan-12"
#define Module_ApplicationDate "22-Jul-13"
#define Module_ComponentName "DrawFile"
#define Module_ComponentPath "castle/RiscOS/Sources/Video/Render/DrawFile"
#define Module_FullVersion "1.57"
#define Module_HelpVersion "1.57 (10 Jan 2012)"
#define Module_LibraryVersionInfo "1:57"
#define Module_FullVersion "1.58"
#define Module_HelpVersion "1.58 (22 Jul 2013)"
#define Module_LibraryVersionInfo "1:58"
......@@ -96,13 +96,6 @@ static os_trfm Identity =
callback_l main_verification_callback = NULL, main_render_callback = NULL, main_declaration_callback = NULL;
#ifdef USE_ATEXIT
/*------------------------------------------------------------------------*/
static void Exit(void)
{
(void) main_terminate(SKIP, SKIP, SKIP);
}
#endif
/*------------------------------------------------------------------------*/
static os_error *Create_List(Association table[], int count,
callback_l * l_out)
......@@ -200,10 +193,6 @@ _kernel_oserror *main_initialise(char *tail, int podule_base,
COUNT(Declaration_Table), &main_declaration_callback)) != NULL)
goto finish;
#ifdef USE_ATEXIT
atexit(&Exit);
#endif
finish:
if (error != NULL)
{
......
......@@ -68,6 +68,8 @@
/* The value '0' here (which allows the Draw module to use a
default of its own choice) results in poor rendering. */
osbool render_can_blend;
/*------------------------------------------------------------------------*/
static os_error *Sprite(osspriteop_header * header, os_trfm * trfm)
......@@ -317,8 +319,12 @@ os_error *render(bits flags, drawfile_diagram * diagram, int size,
drawfile_render_state state;
os_box inv_clip;
osbool can_clip, unclaimed;
int version;
tracef("render\n");
xfont_cache_addr(&version, NULL, NULL);
render_can_blend = version >= 335; /* FontManager does background blending */
can_clip = clip != NULL && trfm_det(trfm) != 0;
if (can_clip)
......@@ -488,6 +494,7 @@ os_error *render_text(void *null, void *s, osbool * unclaimed)
drawfile_text *text = &state->object->data AS text;
char *font_name;
osbool done_find_font = FALSE;
font_string_flags blend;
font_f f;
os_trfm trfm;
os_coord base;
......@@ -541,6 +548,9 @@ os_error *render_text(void *null, void *s, osbool * unclaimed)
trfm_point(&base, state->trfm, &text->base);
blend = (render_can_blend &&
(text->bg_hint == os_COLOUR_TRANSPARENT)) ? font_BLEND_FONT : 0;
/* Paint the text. */
tracef("painting \"%s\" at (%d, %d) through ((%d, %d), "
"(%d, %d), (%d, %d))\n" _
......@@ -549,7 +559,7 @@ os_error *render_text(void *null, void *s, osbool * unclaimed)
trfm.entries[1][0] _ trfm.entries[1][1] _
trfm.entries[2][0] _ trfm.entries[2][1]);
if ((error = xfont_paint(f, text->text, font_OS_UNITS |
font_GIVEN_TRFM | font_GIVEN_FONT | (state->flags & font_BLEND_FONT), base.x / draw_OS_UNIT,
font_GIVEN_TRFM | font_GIVEN_FONT | blend, base.x / draw_OS_UNIT,
base.y / draw_OS_UNIT, SKIP, &trfm, SKIP)) != NULL)
goto finish;
}
......@@ -1032,6 +1042,7 @@ os_error *render_trfm_text(void *null, void *s, osbool * unclaimed)
drawfile_trfm_text *trfm_text = &state->object->data AS trfm_text;
char *font_name;
osbool done_find_font = FALSE;
font_string_flags blend;
font_f f;
os_trfm trfm;
os_coord base;
......@@ -1085,6 +1096,9 @@ os_error *render_trfm_text(void *null, void *s, osbool * unclaimed)
trfm_point(&base, state->trfm, &trfm_text->base);
blend = (render_can_blend &&
(trfm_text->bg_hint == os_COLOUR_TRANSPARENT)) ? font_BLEND_FONT : 0;
/* Paint the text. */
text = trfm_text->text;
if ((trfm_text->flags & drawfile_TEXT_UNDERLINE) != NONE)
......@@ -1098,7 +1112,7 @@ os_error *render_trfm_text(void *null, void *s, osbool * unclaimed)
tracef("painting \"%s\" at (%d, %d)\n" _ text _
trfm_text->base.x _ trfm_text->base.y);
error = xfont_paint(f, text, font_OS_UNITS | font_GIVEN_TRFM |
font_GIVEN_FONT | (state->flags & font_BLEND_FONT)
font_GIVEN_FONT | blend
| ((trfm_text->flags & drawfile_TEXT_KERN)
!= NONE ? font_KERN : NONE) | ((trfm_text->flags &
drawfile_TEXT_RIGHT_TO_LEFT) != NONE ? font_RIGHT_TO_LEFT :
......
......@@ -38,6 +38,7 @@
/*Local */
#include "drawfile.h"
#include "main.h"
#include "render.h"
#include "textarea.h"
#include "verify.h"
......@@ -55,12 +56,6 @@ typedef enum
}
Flush_Type;
typedef struct
{
byte r, g, b;
}
Triplet;
/*Type of a text area control sequence. |Tag| is either a character from the
text area, or one of the command codes disjoined with 0x100.
*/
......@@ -111,7 +106,7 @@ struct
osbool version_given; /* had a \! command yet? */
Align align; /* \A command */
int font_no; /* \<digits> command */
Triplet fill, bg_hint; /* \C, \B commands */
os_colour fill, bg_hint; /* \C, \B commands */
struct
{
byte position, thickness;
......@@ -235,8 +230,9 @@ static os_error *Lex_Next(Esc * esc)
case 'B':
case 'C':
{ /* Three integer arguments
expected. */
expected, or -1's for transparent */
int i;
osbool transparent = TRUE;
if (sscanf(Next_Char, "%d %d %d%n", &esc->data AS argv[0],
&esc->data AS argv[1], &esc->data AS argv[2],
......@@ -249,7 +245,11 @@ static os_error *Lex_Next(Esc * esc)
Next_Char += n + 1;
for (i = 0; i < 3; i++)
Range_Check(&esc->data AS argv[i], 0, 255);
if (esc->data AS argv[i] != os_COLOUR_TRANSPARENT) transparent = FALSE;
if (!transparent)
for (i = 0; i < 3; i++)
Range_Check(&esc->data AS argv[i], 0, 255);
esc->tag |= 0x100;
}
......@@ -716,29 +716,22 @@ static os_error *Flush(State * state, Flush_Type flush_type)
individual text columns, it will be necessary to keep track of the
state of the font number, colours, sizes, y-offset etc, in the same
way we do already for underlining. */
#if 1
if ((state->flags & drawfile_RENDER_SUPPRESS) == NONE)
if (((state->flags & drawfile_RENDER_SUPPRESS) == NONE) &&
(state->fill != os_COLOUR_TRANSPARENT))
{
font_string_flags blend;
char tmp; /* 'coz |font_GIVEN_LENGTH|
doesn't work with pdrivers! */
blend = (render_can_blend && (state->bg_hint == os_COLOUR_TRANSPARENT)) ? font_BLEND_FONT : 0;
tmp = text[line_end - text], text[line_end - text] = '\0';
if ((error = xfont_paint(0, text, font_GIVEN_BLOCK |
font_GIVEN_TRFM | font_GIVEN_LENGTH | (state->flags & font_BLEND_FONT),
pt.x, pt.y, &paint_block, state->hom_trfm, line_end - text))
!= NULL)
font_GIVEN_TRFM | font_GIVEN_LENGTH | blend,
pt.x, pt.y, &paint_block, state->hom_trfm, line_end - text))
!= NULL)
goto finish;
text[line_end - text] = tmp;
}
#else
if ((state->flags & drawfile_RENDER_SUPPRESS) == NONE)
if ((error = xfont_paint(0, text, font_GIVEN_BLOCK |
font_GIVEN_TRFM | font_GIVEN_LENGTH | (state->flags & font_BLEND_FONT), pt.x, pt.y,
&paint_block, state->hom_trfm, line_end - text)) != NULL)
goto finish;
#endif
state->underline.position = position;
state->underline.thickness = thickness;
state->ymove += ymove;
......@@ -934,6 +927,7 @@ os_error *textarea_render(drawfile_object * object, os_trfm * trfm,
State state;
os_trfm local_trfm;
drawfile_object *o;
byte r, g, b;
tracef("textarea_render\n");
......@@ -1004,12 +998,8 @@ os_error *textarea_render(drawfile_object * object, os_trfm * trfm,
state.version_given = FALSE;
state.align = Align_Left;
state.font_no = -1; /* no font selected initially */
state.fill.r = area_text->fill >> 8;
state.fill.g = area_text->fill >> 16;
state.fill.b = area_text->fill >> 24;
state.bg_hint.r = area_text->bg_hint >> 8;
state.bg_hint.g = area_text->bg_hint >> 16;
state.bg_hint.b = area_text->bg_hint >> 24;
state.fill = area_text->fill;
state.bg_hint = area_text->bg_hint;
state.underline.position = 0;
state.underline.thickness = 0;
state.ymove = 0;
......@@ -1056,25 +1046,33 @@ os_error *textarea_render(drawfile_object * object, os_trfm * trfm,
break;
case 'B' | 0x100:
r = esc.data AS argv[0];
g = esc.data AS argv[1];
b = esc.data AS argv[2];
if ((error = EmitS(&state, font_COMMAND_TRUE_COLOURS,
esc.data AS argv[0], esc.data AS argv[1],
esc.data AS argv[2], state.fill.r, state.fill.g,
state.fill.b, 14)) != NULL)
r, g, b,
state.fill >> 8, state.fill >> 16, state.fill >> 24,
14)) != NULL)
goto finish;
state.bg_hint.r = esc.data AS argv[0];
state.bg_hint.g = esc.data AS argv[1];
state.bg_hint.b = esc.data AS argv[2];
if (esc.data AS argv[0] == os_COLOUR_TRANSPARENT)
state.bg_hint = os_COLOUR_TRANSPARENT;
else
state.bg_hint = (r << 8) | (g << 16) | (b << 24);
break;
case 'C' | 0x100:
r = esc.data AS argv[0];
g = esc.data AS argv[1];
b = esc.data AS argv[2];
if ((error = EmitS(&state, font_COMMAND_TRUE_COLOURS,
state.bg_hint.r, state.bg_hint.g, state.bg_hint.b,
esc.data AS argv[0], esc.data AS argv[1],
esc.data AS argv[2], 14)) != NULL)
state.bg_hint >> 8, state.bg_hint >> 16, state.bg_hint >> 24,
r, g, b,
14)) != NULL)
goto finish;
state.fill.r = esc.data AS argv[0];
state.fill.g = esc.data AS argv[1];
state.fill.b = esc.data AS argv[2];
if (esc.data AS argv[0] == os_COLOUR_TRANSPARENT)
state.fill = os_COLOUR_TRANSPARENT;
else
state.fill = (r << 8) | (g << 16) | (b << 24);
break;
case 'F' | 0x100:
......
......@@ -34,9 +34,7 @@ extern callback_l main_verification_callback, main_render_callback,
extern _kernel_oserror *main_initialise (char *, int, void *);
#ifndef USE_ATEXIT
extern _kernel_oserror *main_terminate (int, int, void *);
#endif
extern _kernel_oserror *main_swi (int, _kernel_swi_regs *, void *);
......
......@@ -29,6 +29,8 @@
#include "callback.h"
#endif
extern osbool render_can_blend;
extern os_error *render (bits, drawfile_diagram *, int, os_trfm *,
os_box *, int);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment