Revert "Support subpixel text when FreeType is built without such support."

This reverts commit r291. It will be replaced with another solution in the next
commit.


git-svn-id: http://skia.googlecode.com/svn/trunk@292 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
agl@chromium.org 2009-07-28 18:38:04 +00:00
parent ac3011c6d4
commit 5ebd88eb24

View File

@ -27,7 +27,6 @@
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_CONFIG_OPTIONS_H
#if 0
// Also include the files by name for build tools which require this.
@ -36,16 +35,10 @@
namespace skia_freetype_support {
#if defined(FT_CONFIG_OPTION_SUBPIXEL_RENDERING)
static const int kFilterBorderWidth = 3;
#else
static const int kFilterBorderWidth = 0;
#endif
void CopyFreetypeBitmapToLCDMask(const SkGlyph& dest, const FT_Bitmap& source)
{
// |source| has three alpha values per pixel and has an extra column at the
// left and right edges (if FT_CONFIG_OPTION_SUBPIXEL_RENDERING).
// left and right edges.
// ----- <--- a single pixel in the output
// source .oOo.. |.oO|o..
@ -54,15 +47,15 @@ void CopyFreetypeBitmapToLCDMask(const SkGlyph& dest, const FT_Bitmap& source)
// .oO o..
uint8_t* output = reinterpret_cast<uint8_t*>(dest.fImage);
const unsigned outputPitch = SkAlign4((source.width - 2 * kFilterBorderWidth) / 3);
const unsigned outputPitch = SkAlign4((source.width / 3) - 2);
const uint8_t* input = source.buffer;
// First we calculate the A8 mask.
for (int y = 0; y < source.rows; ++y) {
const uint8_t* inputRow = input;
uint8_t* outputRow = output;
inputRow += kFilterBorderWidth; // skip the extra column on the left
for (int x = kFilterBorderWidth; x < source.width - kFilterBorderWidth; x += 3) {
inputRow += 3; // skip the extra column on the left
for (int x = 3; x < source.width - 3; x += 3) {
const uint8_t averageAlpha = (static_cast<unsigned>(inputRow[0]) + inputRow[1] + inputRow[2] + 1) / 3;
*outputRow++ = averageAlpha;
inputRow += 3;
@ -81,8 +74,6 @@ void CopyFreetypeBitmapToLCDMask(const SkGlyph& dest, const FT_Bitmap& source)
for (int y = 0; y < source.rows; ++y) {
const uint8_t* inputRow = input;
if (!kFilterBorderWidth)
*output32++ = SkPackARGB32(0, 0, 0, 0);
for (int x = 0; x < source.width; x += 3) {
const uint8_t alphaRed = isBGR ? inputRow[2] : inputRow[0];
const uint8_t alphaGreen = inputRow[1];
@ -92,8 +83,6 @@ void CopyFreetypeBitmapToLCDMask(const SkGlyph& dest, const FT_Bitmap& source)
inputRow += 3;
}
if (!kFilterBorderWidth)
*output32++ = SkPackARGB32(0, 0, 0, 0);
input += source.pitch;
}
@ -102,7 +91,7 @@ void CopyFreetypeBitmapToLCDMask(const SkGlyph& dest, const FT_Bitmap& source)
void CopyFreetypeBitmapToVerticalLCDMask(const SkGlyph& dest, const FT_Bitmap& source)
{
// |source| has three times as many rows as normal, and an extra triple on the
// top and bottom (if FT_CONFIG_OPTION_SUBPIXEL_RENDERING).
// top and bottom.
// source .oOo.. |.|oOo..
// .OOO.. --> |.|OOO..
@ -115,8 +104,8 @@ void CopyFreetypeBitmapToVerticalLCDMask(const SkGlyph& dest, const FT_Bitmap& s
const uint8_t* input = source.buffer;
// First we calculate the A8 mask.
input += kFilterBorderWidth * source.pitch; // skip the extra at the beginning
for (int y = kFilterBorderWidth; y < source.rows - kFilterBorderWidth; y += 3) {
input += 3 * source.pitch; // skip the extra at the beginning
for (int y = 3; y < source.rows - 3; y += 3) {
const uint8_t* inputRow = input;
uint8_t* outputRow = output;
for (int x = 0; x < source.width; ++x) {
@ -136,11 +125,6 @@ void CopyFreetypeBitmapToVerticalLCDMask(const SkGlyph& dest, const FT_Bitmap& s
const int isBGR = SkFontHost::GetSubpixelOrder() == SkFontHost::kBGR_LCDOrder;
input = source.buffer;
if (!kFilterBorderWidth) {
for (int x = 0; x < source.width; ++x)
*output32++ = SkPackARGB32(0, 0, 0, 0);
}
for (int y = 0; y < source.rows; y += 3) {
const uint8_t* inputRow = input;
for (int x = 0; x < source.width; ++x) {
@ -154,11 +138,6 @@ void CopyFreetypeBitmapToVerticalLCDMask(const SkGlyph& dest, const FT_Bitmap& s
input += source.pitch * 3;
}
if (!kFilterBorderWidth) {
for (int x = 0; x < source.width; ++x)
*output32++ = SkPackARGB32(0, 0, 0, 0);
}
}
} // namespace skia_freetype_support