disable font smoothing if screen resolution < 8bpp

svn path=/trunk/; revision=7241
This commit is contained in:
Thomas Bluemel 2003-12-26 00:31:22 +00:00
parent 0705f303d0
commit ed3497f42e
4 changed files with 93 additions and 13 deletions

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: bitblt.c,v 1.35 2003/12/25 10:49:30 navaraf Exp $ /* $Id: bitblt.c,v 1.36 2003/12/26 00:31:22 weiden Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -1001,8 +1001,12 @@ EngMaskBitBlt(SURFOBJ *DestObj,
switch(clippingType) switch(clippingType)
{ {
case DC_TRIVIAL: case DC_TRIVIAL:
if(Mask->iBitmapFormat == BMF_8BPP)
Ret = AlphaBltMask(OutputObj, OutputGDI, InputObj, InputGDI, Mask, DestColorTranslation, SourceColorTranslation, Ret = AlphaBltMask(OutputObj, OutputGDI, InputObj, InputGDI, Mask, DestColorTranslation, SourceColorTranslation,
&OutputRect, &InputPoint, MaskOrigin, Brush, BrushOrigin); &OutputRect, &InputPoint, MaskOrigin, Brush, BrushOrigin);
else
Ret = BltMask(OutputObj, OutputGDI, InputObj, InputGDI, Mask, DestColorTranslation,
&OutputRect, &InputPoint, MaskOrigin, Brush, BrushOrigin, 0xAACC);
break; break;
case DC_RECT: case DC_RECT:
// Clip the blt to the clip rectangle // Clip the blt to the clip rectangle
@ -1013,8 +1017,12 @@ EngMaskBitBlt(SURFOBJ *DestObj,
EngIntersectRect(&CombinedRect, &OutputRect, &ClipRect); EngIntersectRect(&CombinedRect, &OutputRect, &ClipRect);
Pt.x = InputPoint.x + CombinedRect.left - OutputRect.left; Pt.x = InputPoint.x + CombinedRect.left - OutputRect.left;
Pt.y = InputPoint.y + CombinedRect.top - OutputRect.top; Pt.y = InputPoint.y + CombinedRect.top - OutputRect.top;
if(Mask->iBitmapFormat == BMF_8BPP)
Ret = AlphaBltMask(OutputObj, OutputGDI, InputObj, InputGDI, Mask, DestColorTranslation, SourceColorTranslation, Ret = AlphaBltMask(OutputObj, OutputGDI, InputObj, InputGDI, Mask, DestColorTranslation, SourceColorTranslation,
&CombinedRect, &Pt, MaskOrigin, Brush, BrushOrigin); &CombinedRect, &Pt, MaskOrigin, Brush, BrushOrigin);
else
Ret = BltMask(OutputObj, OutputGDI, InputObj, InputGDI, Mask, DestColorTranslation,
&CombinedRect, &Pt, MaskOrigin, Brush, BrushOrigin, 0xAACC);
break; break;
case DC_COMPLEX: case DC_COMPLEX:
Ret = TRUE; Ret = TRUE;
@ -1047,9 +1055,12 @@ EngMaskBitBlt(SURFOBJ *DestObj,
EngIntersectRect(&CombinedRect, &OutputRect, &ClipRect); EngIntersectRect(&CombinedRect, &OutputRect, &ClipRect);
Pt.x = InputPoint.x + CombinedRect.left - OutputRect.left; Pt.x = InputPoint.x + CombinedRect.left - OutputRect.left;
Pt.y = InputPoint.y + CombinedRect.top - OutputRect.top; Pt.y = InputPoint.y + CombinedRect.top - OutputRect.top;
if(Mask->iBitmapFormat == BMF_8BPP)
Ret = AlphaBltMask(OutputObj, OutputGDI, InputObj, InputGDI, Mask, DestColorTranslation, SourceColorTranslation, Ret = AlphaBltMask(OutputObj, OutputGDI, InputObj, InputGDI, Mask, DestColorTranslation, SourceColorTranslation,
&CombinedRect, &Pt, MaskOrigin, Brush, BrushOrigin) && &CombinedRect, &Pt, MaskOrigin, Brush, BrushOrigin) && Ret;
Ret; else
Ret = BltMask(OutputObj, OutputGDI, InputObj, InputGDI, Mask, DestColorTranslation,
&CombinedRect, &Pt, MaskOrigin, Brush, BrushOrigin, 0xAACC) && Ret;
} }
} }
while(EnumMore); while(EnumMore);

View file

@ -2,5 +2,8 @@
#define _WIN32K_TEXT_H #define _WIN32K_TEXT_H
BOOL FASTCALL InitFontSupport(VOID); BOOL FASTCALL InitFontSupport(VOID);
BOOL FASTCALL IntIsFontRenderingEnabled(VOID);
BOOL FASTCALL IntIsFontRenderingEnabled(VOID);
VOID FASTCALL IntEnableFontRendering(BOOL Enable);
#endif /* _WIN32K_TEXT_H */ #endif /* _WIN32K_TEXT_H */

View file

@ -1,4 +1,4 @@
/* $Id: misc.c,v 1.38 2003/12/25 21:14:24 weiden Exp $ /* $Id: misc.c,v 1.39 2003/12/26 00:31:22 weiden Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -25,6 +25,7 @@
#include <include/clipboard.h> #include <include/clipboard.h>
#include <include/msgqueue.h> #include <include/msgqueue.h>
#include <include/desktop.h> #include <include/desktop.h>
#include <include/text.h>
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
@ -540,6 +541,33 @@ NtUserSystemParametersInfo(
} }
return TRUE; return TRUE;
} }
case SPI_SETFONTSMOOTHING:
{
BOOL Enable;
Status = MmCopyFromCaller(&Enable, pvParam, sizeof(BOOL));
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
return FALSE;
}
IntEnableFontRendering(Enable);
return TRUE;
}
case SPI_GETFONTSMOOTHING:
{
BOOL Enabled = IntIsFontRenderingEnabled();
Status = MmCopyToCaller(pvParam, &Enabled, sizeof(BOOL));
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
return FALSE;
}
return TRUE;
}
} }
return FALSE; return FALSE;
} }

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: text.c,v 1.66 2003/12/25 00:28:09 weiden Exp $ */ /* $Id: text.c,v 1.67 2003/12/26 00:31:22 weiden Exp $ */
#undef WIN32_LEAN_AND_MEAN #undef WIN32_LEAN_AND_MEAN
@ -29,6 +29,7 @@
#include <win32k/text.h> #include <win32k/text.h>
#include <win32k/kapi.h> #include <win32k/kapi.h>
#include <include/error.h> #include <include/error.h>
#include <include/desktop.h>
#include <ft2build.h> #include <ft2build.h>
#include FT_FREETYPE_H #include FT_FREETYPE_H
#include <freetype/tttables.h> #include <freetype/tttables.h>
@ -55,6 +56,33 @@ typedef struct _FONT_ENTRY {
static LIST_ENTRY FontListHead; static LIST_ENTRY FontListHead;
static FAST_MUTEX FontListLock; static FAST_MUTEX FontListLock;
static INT FontsLoaded = 0; /* number of all fonts loaded (including private fonts */ static INT FontsLoaded = 0; /* number of all fonts loaded (including private fonts */
static BOOL RenderingEnabled = TRUE;
BOOL FASTCALL
IntIsFontRenderingEnabled(VOID)
{
BOOL Ret;
HDC hDC;
PDC dc;
PSURFOBJ SurfObj;
Ret = RenderingEnabled;
hDC = IntGetScreenDC();
if(hDC)
{
dc = DC_LockDc(hDC);
SurfObj = (PSURFOBJ)AccessUserObject((ULONG) dc->Surface);
if(SurfObj)
Ret = (SurfObj->iBitmapFormat >= BMF_8BPP);
DC_UnlockDc(hDC);
}
return Ret;
}
VOID FASTCALL
IntEnableFontRendering(BOOL Enable)
{
RenderingEnabled = Enable;
}
FT_Render_Mode FASTCALL FT_Render_Mode FASTCALL
IntGetFontRenderMode(LOGFONTW *logfont) IntGetFontRenderMode(LOGFONTW *logfont)
@ -1497,6 +1525,8 @@ NtGdiTextOut(HDC hDC,
PPALGDI PalDestGDI; PPALGDI PalDestGDI;
PXLATEOBJ XlateObj, XlateObj2; PXLATEOBJ XlateObj, XlateObj2;
ULONG Mode; ULONG Mode;
FT_Render_Mode RenderMode;
BOOL Render;
dc = DC_LockDc(hDC); dc = DC_LockDc(hDC);
if( !dc ) if( !dc )
@ -1537,6 +1567,14 @@ NtGdiTextOut(HDC hDC,
if (error) DPRINT1("WARNING: Could not set the charmap!\n"); if (error) DPRINT1("WARNING: Could not set the charmap!\n");
} }
Render = IntIsFontRenderingEnabled();
if(Render)
RenderMode = IntGetFontRenderMode(&TextObj->logfont);
else
RenderMode = FT_RENDER_MODE_MONO;
error = FT_Set_Pixel_Sizes(face, error = FT_Set_Pixel_Sizes(face,
/* FIXME should set character height if neg */ /* FIXME should set character height if neg */
(TextObj->logfont.lfHeight < 0 ? (TextObj->logfont.lfHeight < 0 ?
@ -1595,7 +1633,7 @@ NtGdiTextOut(HDC hDC,
for(i=0; i<Count; i++) for(i=0; i<Count; i++)
{ {
glyph_index = FT_Get_Char_Index(face, *String); glyph_index = FT_Get_Char_Index(face, *String);
error = FT_Load_Glyph(face, glyph_index, FT_LOAD_RENDER); error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);
if(error) { if(error) {
EngDeleteXlate(XlateObj); EngDeleteXlate(XlateObj);
EngDeleteXlate(XlateObj2); EngDeleteXlate(XlateObj2);
@ -1614,7 +1652,7 @@ NtGdiTextOut(HDC hDC,
if (glyph->format == ft_glyph_format_outline) if (glyph->format == ft_glyph_format_outline)
{ {
error = FT_Render_Glyph(glyph, IntGetFontRenderMode(&TextObj->logfont)); error = FT_Render_Glyph(glyph, RenderMode);
if(error) { if(error) {
EngDeleteXlate(XlateObj); EngDeleteXlate(XlateObj);
EngDeleteXlate(XlateObj2); EngDeleteXlate(XlateObj2);
@ -1660,7 +1698,7 @@ NtGdiTextOut(HDC hDC,
// Then use memset with 0 to clear it and sourcerect to limit the work of the transbitblt // Then use memset with 0 to clear it and sourcerect to limit the work of the transbitblt
HSourceGlyph = EngCreateBitmap(bitSize, pitch, (glyph->bitmap.pixel_mode == ft_pixel_mode_grays) ? BMF_8BPP : BMF_1BPP, 0, glyph->bitmap.buffer); HSourceGlyph = EngCreateBitmap(bitSize, pitch, (glyph->bitmap.pixel_mode == ft_pixel_mode_grays) ? BMF_8BPP : BMF_1BPP, 0, glyph->bitmap.buffer);
SourceGlyphSurf = (PSURFOBJ)AccessUserObject((ULONG) HSourceGlyph); SourceGlyphSurf = (PSURFOBJ)AccessUserObject((ULONG) HSourceGlyph);
DPRINT1("glyph->bitmap.palette_mode == 0x%x (0x%x)\n", glyph->bitmap.palette_mode, glyph->bitmap.num_grays);
// Use the font data as a mask to paint onto the DCs surface using a brush // Use the font data as a mask to paint onto the DCs surface using a brush
IntEngMaskBlt ( IntEngMaskBlt (
SurfObj, SurfObj,