Patch by Andrej Spielmann (GSOC):

* Extend the app_server protocol by configuration options to turn
  subpixel font rendering on/off and also make the glyph hinting optional
  (aligning of glyph shapes to the pixel grid).
* Implement the setting in the app_server and also handle the persistency.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26362 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2008-07-10 08:29:50 +00:00
parent fa6a00c628
commit b09e2f6f4b
8 changed files with 171 additions and 7 deletions

View File

@ -6,6 +6,7 @@
* DarkWyrm <bpmagic@columbus.rr.com>
* Jérôme Duval, jerome.duval@free.fr
* Axel Dörfler, axeld@pinc-software.de
* Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk>
*/
#ifndef APP_SERVER_PROTOCOL_H
#define APP_SERVER_PROTOCOL_H
@ -188,6 +189,11 @@ enum {
AS_GET_SHOW_ALL_DRAGGERS,
AS_SET_SHOW_ALL_DRAGGERS,
AS_SET_FONT_SUBPIXEL_ANTIALIASING,
AS_GET_FONT_SUBPIXEL_ANTIALIASING,
AS_SET_HINTING,
AS_GET_HINTING,
// Graphics calls
AS_SET_HIGH_COLOR,
AS_SET_LOW_COLOR,

View File

@ -6,6 +6,7 @@
* Adrian Oanca <adioanca@cotty.iren.ro>
* Stephan Aßmus <superstippi@gmx.de>
* Axel Dörfler, axeld@pinc-software.de
* Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk>
*/
/*! Class used to encapsulate desktop management */
@ -2461,6 +2462,14 @@ Desktop::MarkDirty(BRegion& region)
}
void
Desktop::Redraw()
{
BRegion dirty(fVirtualScreen.Frame());
MarkDirty(dirty);
}
void
Desktop::_RebuildClippingForAllWindows(BRegion& stillAvailableOnScreen)
{

View File

@ -6,6 +6,7 @@
* Adrian Oanca <adioanca@cotty.iren.ro>
* Stephan Aßmus <superstippi@gmx.de>
* Axel Dörfler, axeld@pinc-software.de
* Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk>
*/
#ifndef DESKTOP_H
#define DESKTOP_H
@ -190,6 +191,7 @@ class Desktop : public MessageLooper, public ScreenOwner {
#endif // USE_MULTI_LOCKER
void MarkDirty(BRegion& region);
void Redraw();
BRegion& BackgroundRegion()
{ return fBackgroundRegion; }

View File

@ -5,12 +5,15 @@
* Authors:
* Stephan Aßmus <superstippi@gmx.de>
* Axel Dörfler, axeld@pinc-software.de
* Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk>
*/
#include "DesktopSettings.h"
#include "DesktopSettingsPrivate.h"
#include "Desktop.h"
#include "FontCache.h"
#include "FontCacheEntry.h"
#include "FontManager.h"
#include "ServerConfig.h"
@ -60,7 +63,7 @@ DesktopSettingsPrivate::_SetDefaults()
strlcpy(fMenuInfo.f_style, fPlainFont.Style(), B_FONT_STYLE_LENGTH);
fMenuInfo.font_size = fPlainFont.Size();
fMenuInfo.background_color.set_to(216, 216, 216);
fMenuInfo.separator = 0;
// look of the separator (R5: (0, 1, 2), default 0)
fMenuInfo.click_to_open = true; // always true
@ -69,6 +72,11 @@ DesktopSettingsPrivate::_SetDefaults()
fWorkspacesCount = 4;
memcpy(fShared.colors, BPrivate::kDefaultColors, sizeof(rgb_color) * kNumColors);
fFontSubpixelAntialiasing = false;
FontCacheEntry::SetDefaultRenderType(glyph_ren_native_gray8);
fHinting = true;
FontCacheEntry::SetDefaultHinting(true);
}
@ -101,7 +109,7 @@ DesktopSettingsPrivate::_Load()
BPath path(basePath);
path.Append("workspaces");
BFile file;
status = file.SetTo(path.Path(), B_READ_ONLY);
if (status == B_OK) {
@ -127,7 +135,7 @@ DesktopSettingsPrivate::_Load()
path = basePath;
path.Append("fonts");
status = file.SetTo(path.Path(), B_READ_ONLY);
if (status == B_OK) {
BMessage settings;
@ -136,6 +144,8 @@ DesktopSettingsPrivate::_Load()
const char* family;
const char* style;
float size;
bool subpix;
bool hinting;
if (settings.FindString("plain family", &family) == B_OK
&& settings.FindString("plain style", &style) == B_OK
&& settings.FindFloat("plain size", &size) == B_OK) {
@ -158,6 +168,15 @@ DesktopSettingsPrivate::_Load()
fFixedFont.SetStyle(fontStyle);
fFixedFont.SetSize(size);
}
if (settings.FindBool("font subpix", &subpix) == B_OK) {
fFontSubpixelAntialiasing = subpix;
FontCacheEntry::SetDefaultRenderType(
(subpix) ? glyph_ren_subpix : glyph_ren_native_gray8);
}
if (settings.FindBool("hinting", &hinting) == B_OK) {
fHinting = hinting;
FontCacheEntry::SetDefaultHinting(fHinting);
}
gFontManager->Unlock();
}
}
@ -166,7 +185,7 @@ DesktopSettingsPrivate::_Load()
path = basePath;
path.Append("mouse");
status = file.SetTo(path.Path(), B_READ_ONLY);
if (status == B_OK) {
BMessage settings;
@ -183,7 +202,7 @@ DesktopSettingsPrivate::_Load()
path = basePath;
path.Append("appearance");
status = file.SetTo(path.Path(), B_READ_ONLY);
if (status == B_OK) {
BMessage settings;
@ -192,7 +211,7 @@ DesktopSettingsPrivate::_Load()
float fontSize;
if (settings.FindFloat("font size", &fontSize) == B_OK)
fMenuInfo.font_size = fontSize;
const char* fontFamily;
if (settings.FindString("font family", &fontFamily) == B_OK)
strlcpy(fMenuInfo.f_family, fontFamily, B_FONT_FAMILY_LENGTH);
@ -274,6 +293,9 @@ DesktopSettingsPrivate::Save(uint32 mask)
settings.AddString("fixed style", fFixedFont.Style());
settings.AddFloat("fixed size", fFixedFont.Size());
settings.AddBool("font subpix",fFontSubpixelAntialiasing);
settings.AddBool("hinting",fHinting);
BFile file;
status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE | B_READ_WRITE);
if (status == B_OK) {
@ -521,6 +543,42 @@ DesktopSettingsPrivate::UIColor(color_which which) const
}
void
DesktopSettingsPrivate::SetFontSubpixelAntialiasing(bool subpix)
{
if (fFontSubpixelAntialiasing != subpix) {
fFontSubpixelAntialiasing = subpix;
FontCacheEntry::SetDefaultRenderType(
(subpix)?glyph_ren_subpix:glyph_ren_native_gray8);
Save(kFontSettings);
}
}
bool
DesktopSettingsPrivate::FontSubpixelAntialiasing() const
{
return fFontSubpixelAntialiasing;
}
void
DesktopSettingsPrivate::SetHinting(bool hinting)
{
if (fHinting != hinting) {
fHinting = hinting;
FontCacheEntry::SetDefaultHinting(hinting);
Save(kFontSettings);
}
}
bool
DesktopSettingsPrivate::Hinting() const
{
return fHinting;
}
// #pragma mark - read access
@ -613,6 +671,19 @@ DesktopSettings::UIColor(color_which which) const
}
bool
DesktopSettings::FontSubpixelAntialiasing() const
{
return fSettings->FontSubpixelAntialiasing();
}
bool
DesktopSettings::Hinting() const
{
return fSettings->Hinting();
}
// #pragma mark - write access
@ -691,3 +762,16 @@ LockedDesktopSettings::SetUIColor(color_which which, const rgb_color color)
}
void
LockedDesktopSettings::SetFontSubpixelAntialiasing(bool subpix)
{
fSettings->SetFontSubpixelAntialiasing(subpix);
}
void
LockedDesktopSettings::SetHinting(bool hinting)
{
fSettings->SetHinting(hinting);
}

View File

@ -4,6 +4,7 @@
*
* Authors:
* Axel Dörfler, axeld@pinc-software.de
* Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk>
*/
#ifndef DESKTOP_SETTINGS_H
#define DESKTOP_SETTINGS_H
@ -52,6 +53,9 @@ class DesktopSettings {
rgb_color UIColor(color_which which) const;
bool FontSubpixelAntialiasing() const;
bool Hinting() const;
protected:
DesktopSettingsPrivate* fSettings;
};
@ -74,6 +78,9 @@ class LockedDesktopSettings : public DesktopSettings {
void SetUIColor(color_which which, const rgb_color color);
void SetFontSubpixelAntialiasing(bool subpix);
void SetHinting(bool hinting);
private:
Desktop* fDesktop;
};

View File

@ -4,6 +4,7 @@
*
* Authors:
* Axel Dörfler, axeld@pinc-software.de
* Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk>
*/
#ifndef DESKTOP_SETTINGS_PRIVATE_H
#define DESKTOP_SETTINGS_PRIVATE_H
@ -54,6 +55,12 @@ class DesktopSettingsPrivate {
void SetUIColor(color_which which, const rgb_color color);
rgb_color UIColor(color_which which) const;
void SetFontSubpixelAntialiasing(bool subpix);
bool FontSubpixelAntialiasing() const;
void SetHinting(bool hinting);
bool Hinting() const;
private:
void _SetDefaults();
status_t _Load();
@ -70,6 +77,9 @@ class DesktopSettingsPrivate {
int32 fWorkspacesCount;
BMessage fWorkspaceMessages[kMaxWorkspaces];
bool fFontSubpixelAntialiasing;
bool fHinting;
server_read_only_memory& fShared;
};

View File

@ -9,7 +9,7 @@
#include "ProfileMessageSupport.h"
#include "ServerProtocol.h"
#include <ServerProtocol.h>
void
@ -174,6 +174,11 @@ string_for_message_code(uint32 code, BString& string)
case AS_GET_DECORATOR_SETTINGS: string = "AS_GET_DECORATOR_SETTINGS"; break;
case AS_GET_SHOW_ALL_DRAGGERS: string = "AS_GET_SHOW_ALL_DRAGGERS"; break;
case AS_SET_SHOW_ALL_DRAGGERS: string = "AS_SET_SHOW_ALL_DRAGGERS"; break;
case AS_SET_FONT_SUBPIXEL_ANTIALIASING: string = "AS_SET_FONT_SUBPIXEL_ANTIALIASING"; break;
case AS_GET_FONT_SUBPIXEL_ANTIALIASING: string = "AS_GET_FONT_SUBPIXEL_ANTIALIASING"; break;
case AS_SET_HINTING: string = "AS_SET_HINTING"; break;
case AS_GET_HINTING: string = "AS_GET_HINTING"; break;
// Graphics calls
case AS_SET_HIGH_COLOR: string = "AS_SET_HIGH_COLOR"; break;

View File

@ -9,6 +9,7 @@
* Stefano Ceccherini (burton666@libero.it)
* Axel Dörfler, axeld@pinc-software.de
* Jérôme Duval, jerome.duval@free.fr
* Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk>
*/
/*!
@ -2535,6 +2536,46 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
break;
}
case AS_SET_FONT_SUBPIXEL_ANTIALIASING:
{
bool subpix;
if (link.Read<bool>(&subpix) == B_OK) {
LockedDesktopSettings settings(fDesktop);
settings.SetFontSubpixelAntialiasing(subpix);
}
fDesktop->Redraw();
break;
}
case AS_GET_FONT_SUBPIXEL_ANTIALIASING:
{
DesktopSettings settings(fDesktop);
fLink.StartMessage(B_OK);
fLink.Attach<bool>(settings.FontSubpixelAntialiasing());
fLink.Flush();
break;
}
case AS_SET_HINTING:
{
bool hinting;
if (link.Read<bool>(&hinting) == B_OK) {
LockedDesktopSettings settings(fDesktop);
settings.SetHinting(hinting);
}
fDesktop->Redraw();
break;
}
case AS_GET_HINTING:
{
DesktopSettings settings(fDesktop);
fLink.StartMessage(B_OK);
fLink.Attach<bool>(settings.Hinting());
fLink.Flush();
break;
}
default:
printf("ServerApp %s received unhandled message code %ld\n",
Signature(), code);