зеркало из https://github.com/github/putty.git
Substantial overhaul of colour handling in do_text(). Highlights include:
* No more mucking about with transfer modes. We always set up the foreground and background sensibly, EraseRect the whole lot and use srcOr. Apple Tech Note QD505 suggests that this should be faster than srcCopy. * Always use the Palette Manager if we've got Color QuickDraw, even in 1bpp modes. * Apply the cursor colours _after_ all the other stuff, rather than trying to get them through everything else intact. Unfortunately, this doesn't make much difference to the speed. [originally from svn r2259]
This commit is contained in:
Родитель
f520d663c9
Коммит
a8e0271b8d
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: macterm.c,v 1.11 2002/11/24 00:38:44 ben Exp $ */
|
/* $Id: macterm.c,v 1.12 2002/11/26 01:32:51 ben Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1999 Simon Tatham
|
* Copyright (c) 1999 Simon Tatham
|
||||||
* Copyright (c) 1999, 2002 Ben Harris
|
* Copyright (c) 1999, 2002 Ben Harris
|
||||||
|
@ -793,7 +793,6 @@ static void mac_drawgrowicon(Session *s) {
|
||||||
struct do_text_args {
|
struct do_text_args {
|
||||||
Session *s;
|
Session *s;
|
||||||
Rect textrect;
|
Rect textrect;
|
||||||
Rect leadrect;
|
|
||||||
char *text;
|
char *text;
|
||||||
int len;
|
int len;
|
||||||
unsigned long attr;
|
unsigned long attr;
|
||||||
|
@ -827,12 +826,6 @@ void do_text(Context ctx, int x, int y, char *text, int len,
|
||||||
a.len = len;
|
a.len = len;
|
||||||
a.attr = attr;
|
a.attr = attr;
|
||||||
a.lattr = lattr;
|
a.lattr = lattr;
|
||||||
if (s->font_leading > 0)
|
|
||||||
SetRect(&a.leadrect,
|
|
||||||
a.textrect.left, a.textrect.bottom - s->font_leading,
|
|
||||||
a.textrect.right, a.textrect.bottom);
|
|
||||||
else
|
|
||||||
SetRect(&a.leadrect, 0, 0, 0, 0);
|
|
||||||
SetPort(s->window);
|
SetPort(s->window);
|
||||||
TextFont(s->fontnum);
|
TextFont(s->fontnum);
|
||||||
if (s->cfg.fontisbold || (attr & ATTR_BOLD) && !s->cfg.bold_colour)
|
if (s->cfg.fontisbold || (attr & ATTR_BOLD) && !s->cfg.bold_colour)
|
||||||
|
@ -841,6 +834,7 @@ void do_text(Context ctx, int x, int y, char *text, int len,
|
||||||
style |= underline;
|
style |= underline;
|
||||||
TextFace(style);
|
TextFace(style);
|
||||||
TextSize(s->cfg.fontheight);
|
TextSize(s->cfg.fontheight);
|
||||||
|
TextMode(srcOr);
|
||||||
SetFractEnable(FALSE); /* We want characters on pixel boundaries */
|
SetFractEnable(FALSE); /* We want characters on pixel boundaries */
|
||||||
if (HAVE_COLOR_QD())
|
if (HAVE_COLOR_QD())
|
||||||
if (style & bold) {
|
if (style & bold) {
|
||||||
|
@ -864,55 +858,53 @@ void do_text(Context ctx, int x, int y, char *text, int len,
|
||||||
static pascal void do_text_for_device(short depth, short devflags,
|
static pascal void do_text_for_device(short depth, short devflags,
|
||||||
GDHandle device, long cookie) {
|
GDHandle device, long cookie) {
|
||||||
struct do_text_args *a;
|
struct do_text_args *a;
|
||||||
int bgcolour, fgcolour, bright;
|
int bgcolour, fgcolour, bright, reverse, tmp;
|
||||||
|
|
||||||
a = (struct do_text_args *)cookie;
|
a = (struct do_text_args *)cookie;
|
||||||
|
|
||||||
bright = (a->attr & ATTR_BOLD) && a->s->cfg.bold_colour;
|
bright = (a->attr & ATTR_BOLD) && a->s->cfg.bold_colour;
|
||||||
|
reverse = a->attr & ATTR_REVERSE;
|
||||||
|
|
||||||
TextMode(a->attr & ATTR_REVERSE ? notSrcCopy : srcCopy);
|
if (depth == 1 && (a->attr & TATTR_ACTCURS))
|
||||||
|
reverse = !reverse;
|
||||||
|
|
||||||
switch (depth) {
|
if (HAVE_COLOR_QD()) {
|
||||||
case 1:
|
if (depth > 2) {
|
||||||
/* XXX This should be done with a _little_ more configurability */
|
|
||||||
ForeColor(whiteColor);
|
|
||||||
BackColor(blackColor);
|
|
||||||
if (a->attr & TATTR_ACTCURS)
|
|
||||||
TextMode(a->attr & ATTR_REVERSE ? srcCopy : notSrcCopy);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
if (a->attr & TATTR_ACTCURS) {
|
|
||||||
PmForeColor(CURSOR_FG);
|
|
||||||
PmBackColor(CURSOR_BG);
|
|
||||||
TextMode(srcCopy);
|
|
||||||
} else {
|
|
||||||
PmForeColor(bright ? DEFAULT_FG_BOLD : DEFAULT_FG);
|
|
||||||
PmBackColor(DEFAULT_BG);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (a->attr & TATTR_ACTCURS) {
|
|
||||||
fgcolour = CURSOR_FG;
|
|
||||||
bgcolour = CURSOR_BG;
|
|
||||||
TextMode(srcCopy);
|
|
||||||
} else {
|
|
||||||
fgcolour = ((a->attr & ATTR_FGMASK) >> ATTR_FGSHIFT) * 2;
|
fgcolour = ((a->attr & ATTR_FGMASK) >> ATTR_FGSHIFT) * 2;
|
||||||
bgcolour = ((a->attr & ATTR_BGMASK) >> ATTR_BGSHIFT) * 2;
|
bgcolour = ((a->attr & ATTR_BGMASK) >> ATTR_BGSHIFT) * 2;
|
||||||
if (bright)
|
} else {
|
||||||
if (a->attr & ATTR_REVERSE)
|
/*
|
||||||
bgcolour++;
|
* NB: bold reverse in 2bpp breaks with the usual PuTTY model and
|
||||||
else
|
* boldens the background, because that's all we can do.
|
||||||
fgcolour++;
|
*/
|
||||||
|
fgcolour = bright ? DEFAULT_FG_BOLD : DEFAULT_FG;
|
||||||
|
bgcolour = DEFAULT_BG;
|
||||||
|
}
|
||||||
|
if (reverse) {
|
||||||
|
tmp = fgcolour;
|
||||||
|
fgcolour = bgcolour;
|
||||||
|
bgcolour = tmp;
|
||||||
|
}
|
||||||
|
if (bright && depth > 2)
|
||||||
|
fgcolour++;
|
||||||
|
if ((a->attr & TATTR_ACTCURS) && depth > 1) {
|
||||||
|
fgcolour = CURSOR_FG;
|
||||||
|
bgcolour = CURSOR_BG;
|
||||||
}
|
}
|
||||||
PmForeColor(fgcolour);
|
PmForeColor(fgcolour);
|
||||||
PmBackColor(bgcolour);
|
PmBackColor(bgcolour);
|
||||||
break;
|
} else { /* No Color Quickdraw */
|
||||||
|
/* XXX This should be done with a _little_ more configurability */
|
||||||
|
if (reverse) {
|
||||||
|
ForeColor(blackColor);
|
||||||
|
BackColor(whiteColor);
|
||||||
|
} else {
|
||||||
|
ForeColor(whiteColor);
|
||||||
|
BackColor(blackColor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a->attr & ATTR_REVERSE)
|
EraseRect(&a->textrect);
|
||||||
PaintRect(&a->leadrect);
|
|
||||||
else
|
|
||||||
EraseRect(&a->leadrect);
|
|
||||||
MoveTo(a->textrect.left, a->textrect.top + a->s->font_ascent);
|
MoveTo(a->textrect.left, a->textrect.top + a->s->font_ascent);
|
||||||
/* FIXME: Sort out bold width adjustments on Original QuickDraw. */
|
/* FIXME: Sort out bold width adjustments on Original QuickDraw. */
|
||||||
DrawText(a->text, 0, a->len);
|
DrawText(a->text, 0, a->len);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче