Patch by Andrej Spielmann (GSoC):

* Simplified the subpixel related methods for the AGG "pixel format" template
  interface, the ones for the solid cover simply pass through the existing
  methods, so only one subpixel blending function is left which does the actual
  work (this removes a lot of the previously added code)
* Implemented a new rasterizer based on the original AGG rasterizer which
  implements subpixel anti-aliasing for any generic AGG vector pipelines. It
  is now optionally used in Painter and AGGTextRenderer (for vector fonts, ie
  rotated, sheared or big enough fonts) depending on the global subpixel
  setting.
* Put all subpixel variables into the new GlobalSubpixelSettings.h|cpp
* Simplified DesktopSettings related classes a bit and renamed previous
  FontSubpixelAntialiasing to just SubpixelAntialiasing.
* The private libbe functions for subpixel related settings moved from Font.cpp
  to InterfaceDefs.cpp where other such functions live. They are not related
  to fonts only anymore.
* Removed the subpixel related settings again from the Fonts preflet and added
  them to the Appearance preflet instead.

All of the above implements subpixel anti-aliasing on a global scale, which
to my knowledge no other OS is doing at the moment. Any vector rendering
can optionally use subpixel anti-aliasing in Haiku now. The bitmap cached fonts
are still affected by the Freetype complile time #define to enable the patented
subpixel rasterization (three times wide glyphs). Vector fonts and shapes are
not affected though at the moment.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26755 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2008-08-03 13:40:41 +00:00
parent 826df7bec8
commit 59e13a3f06
63 changed files with 3131 additions and 2555 deletions
+114 -41
View File
@@ -15,6 +15,7 @@
#include "FontCache.h"
#include "FontCacheEntry.h"
#include "FontManager.h"
#include "GlobalSubpixelSettings.h"
#include "ServerConfig.h"
#include <DefaultColors.h>
@@ -73,10 +74,10 @@ DesktopSettingsPrivate::_SetDefaults()
memcpy(fShared.colors, BPrivate::kDefaultColors, sizeof(rgb_color) * kNumColors);
fFontSubpixelAntialiasing = false;
FontCacheEntry::SetDefaultRenderType(glyph_ren_native_gray8);
fHinting = true;
FontCacheEntry::SetDefaultHinting(true);
gSubpixelAntialiasing = false;
gDefaultHinting = true;
gSubpixelAverageWeight = 120;
gSubpixelOrderingRGB = true;
}
@@ -144,7 +145,6 @@ 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
@@ -168,14 +168,8 @@ 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);
gDefaultHinting = hinting;
}
gFontManager->Unlock();
}
@@ -233,8 +227,26 @@ DesktopSettingsPrivate::_Load()
fMenuInfo.click_to_open = clickToOpen;
bool triggersAlwaysShown;
if (settings.FindBool("triggers always shown", &triggersAlwaysShown) == B_OK)
if (settings.FindBool("triggers always shown", &triggersAlwaysShown)
== B_OK) {
fMenuInfo.triggers_always_shown = triggersAlwaysShown;
}
bool subpix;
if (settings.FindBool("subpixel antialiasing", &subpix) == B_OK)
gSubpixelAntialiasing = subpix;
int8 averageWeight;
if (settings.FindInt8("subpixel average weight", &averageWeight)
== B_OK) {
gSubpixelAverageWeight = averageWeight;
}
bool subpixelOrdering;
if (settings.FindBool("subpixel ordering", &subpixelOrdering)
== B_OK) {
gSubpixelOrderingRGB = subpixelOrdering;
}
for (int32 i = 0; i < kNumColors; i++) {
char colorName[12];
@@ -269,7 +281,8 @@ DesktopSettingsPrivate::Save(uint32 mask)
}
BFile file;
status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE | B_READ_WRITE);
status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE
| B_READ_WRITE);
if (status == B_OK) {
status = settings.Flatten(&file, NULL);
}
@@ -293,11 +306,11 @@ 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);
settings.AddBool("hinting", gDefaultHinting);
BFile file;
status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE | B_READ_WRITE);
status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE
| B_READ_WRITE);
if (status == B_OK) {
status = settings.Flatten(&file, NULL);
}
@@ -311,7 +324,8 @@ DesktopSettingsPrivate::Save(uint32 mask)
settings.AddInt32("mode", (int32)fMouseMode);
BFile file;
status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE | B_READ_WRITE);
status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE
| B_READ_WRITE);
if (status == B_OK) {
status = settings.Flatten(&file, NULL);
}
@@ -325,7 +339,8 @@ DesktopSettingsPrivate::Save(uint32 mask)
settings.AddBool("show", fShowAllDraggers);
BFile file;
status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE | B_READ_WRITE);
status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE
| B_READ_WRITE);
if (status == B_OK) {
status = settings.Flatten(&file, NULL);
}
@@ -339,10 +354,16 @@ DesktopSettingsPrivate::Save(uint32 mask)
settings.AddFloat("font size", fMenuInfo.font_size);
settings.AddString("font family", fMenuInfo.f_family);
settings.AddString("font style", fMenuInfo.f_style);
settings.AddInt32("bg color", (const int32&)fMenuInfo.background_color);
settings.AddInt32("bg color",
(const int32&)fMenuInfo.background_color);
settings.AddInt32("separator", fMenuInfo.separator);
settings.AddBool("click to open", fMenuInfo.click_to_open);
settings.AddBool("triggers always shown", fMenuInfo.triggers_always_shown);
settings.AddBool("triggers always shown",
fMenuInfo.triggers_always_shown);
settings.AddBool("subpixel antialiasing", gSubpixelAntialiasing);
settings.AddInt8("subpixel average weight", gSubpixelAverageWeight);
settings.AddBool("subpixel ordering", gSubpixelOrderingRGB);
for (int32 i = 0; i < kNumColors; i++) {
char colorName[12];
@@ -352,7 +373,8 @@ DesktopSettingsPrivate::Save(uint32 mask)
}
BFile file;
status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE | B_READ_WRITE);
status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE
| B_READ_WRITE);
if (status == B_OK) {
status = settings.Flatten(&file, NULL);
}
@@ -544,39 +566,62 @@ DesktopSettingsPrivate::UIColor(color_which which) const
void
DesktopSettingsPrivate::SetFontSubpixelAntialiasing(bool subpix)
DesktopSettingsPrivate::SetSubpixelAntialiasing(bool subpix)
{
if (fFontSubpixelAntialiasing != subpix) {
fFontSubpixelAntialiasing = subpix;
FontCacheEntry::SetDefaultRenderType(
(subpix)?glyph_ren_subpix:glyph_ren_native_gray8);
Save(kFontSettings);
}
gSubpixelAntialiasing = subpix;
Save(kAppearanceSettings);
}
bool
DesktopSettingsPrivate::FontSubpixelAntialiasing() const
DesktopSettingsPrivate::SubpixelAntialiasing() const
{
return fFontSubpixelAntialiasing;
return gSubpixelAntialiasing;
}
void
DesktopSettingsPrivate::SetHinting(bool hinting)
{
if (fHinting != hinting) {
fHinting = hinting;
FontCacheEntry::SetDefaultHinting(hinting);
Save(kFontSettings);
}
gDefaultHinting = hinting;
Save(kFontSettings);
}
bool
DesktopSettingsPrivate::Hinting() const
{
return fHinting;
return gDefaultHinting;
}
void
DesktopSettingsPrivate::SetSubpixelAverageWeight(uint8 averageWeight)
{
gSubpixelAverageWeight = averageWeight;
Save(kAppearanceSettings);
}
uint8
DesktopSettingsPrivate::SubpixelAverageWeight() const
{
return gSubpixelAverageWeight;
}
void
DesktopSettingsPrivate::SetSubpixelOrderingRegular(bool subpixelOrdering)
{
gSubpixelOrderingRGB = subpixelOrdering;
Save(kAppearanceSettings);
}
bool
DesktopSettingsPrivate::IsSubpixelOrderingRegular() const
{
return gSubpixelOrderingRGB;
}
// #pragma mark - read access
@@ -672,9 +717,9 @@ DesktopSettings::UIColor(color_which which) const
bool
DesktopSettings::FontSubpixelAntialiasing() const
DesktopSettings::SubpixelAntialiasing() const
{
return fSettings->FontSubpixelAntialiasing();
return fSettings->SubpixelAntialiasing();
}
@@ -684,6 +729,21 @@ DesktopSettings::Hinting() const
return fSettings->Hinting();
}
uint8
DesktopSettings::SubpixelAverageWeight() const
{
return fSettings->SubpixelAverageWeight();
}
bool
DesktopSettings::IsSubpixelOrderingRegular() const
{
// True corresponds to RGB, false means BGR
return fSettings->IsSubpixelOrderingRegular();
}
// #pragma mark - write access
@@ -763,9 +823,9 @@ LockedDesktopSettings::SetUIColor(color_which which, const rgb_color color)
void
LockedDesktopSettings::SetFontSubpixelAntialiasing(bool subpix)
LockedDesktopSettings::SetSubpixelAntialiasing(bool subpix)
{
fSettings->SetFontSubpixelAntialiasing(subpix);
fSettings->SetSubpixelAntialiasing(subpix);
}
@@ -775,3 +835,16 @@ LockedDesktopSettings::SetHinting(bool hinting)
fSettings->SetHinting(hinting);
}
void
LockedDesktopSettings::SetSubpixelAverageWeight(uint8 averageWeight)
{
fSettings->SetSubpixelAverageWeight(averageWeight);
}
void
LockedDesktopSettings::SetSubpixelOrderingRegular(bool subpixelOrdering)
{
fSettings->SetSubpixelOrderingRegular(subpixelOrdering);
}