rename SK_BUILD_SUBPIXEL to SK_SUPPORT_LCDTEXT to better match the name of the

feature (since we already have subpixel text support)

fix some debug-compile problems

update Makefile for lcd files



git-svn-id: http://skia.googlecode.com/svn/trunk@282 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
reed@android.com 2009-07-22 19:21:01 +00:00
parent 01f82da73b
commit f549369fcd
10 changed files with 91 additions and 15 deletions

View File

@ -20,6 +20,8 @@ else
DEFINES += -DSK_RELEASE
endif
DEFINES += -DSK_SUPPORT_LCDTEXT
# start with the core (required)
include src/core/core_files.mk
SRC_LIST := $(addprefix src/core/, $(SOURCE))

View File

@ -112,6 +112,10 @@
*/
//#define SkDebugf(...) MyFunction(__VA_ARGS__)
/* To enable additional blitters (and fontscaler code) to support separate
alpha channels for R G B channels, define SK_SUPPORT_LCDTEXT
*/
#define SK_SUPPORT_LCDTEXT
/* If SK_DEBUG is defined, then you can optionally define SK_SUPPORT_UNITTEST
which will run additional self-tests at startup. These can take a long time,

View File

@ -99,7 +99,7 @@ struct SkMask {
for the given position.
*/
const uint32_t* getAddrLCD(int x, int y) const {
SkASSERT(fFormat == kHorizontanLCD_Format || fFormat == kVerticalLCD_Format);
SkASSERT(fFormat == kHorizontalLCD_Format || fFormat == kVerticalLCD_Format);
SkASSERT(fBounds.contains(x, y));
SkASSERT(fImage != NULL);

61
samplecode/SampleLCD.cpp Normal file
View File

@ -0,0 +1,61 @@
#include "SampleCode.h"
#include "SkView.h"
#include "SkCanvas.h"
#include "SkDevice.h"
#include "SkPaint.h"
#include "SkShader.h"
class LCDView : public SkView {
public:
LCDView() {}
protected:
// overrides from SkEventSink
virtual bool onQuery(SkEvent* evt) {
if (SampleCode::TitleQ(*evt)) {
SampleCode::TitleR(evt, "LCD Text");
return true;
}
return this->INHERITED::onQuery(evt);
}
void drawBG(SkCanvas* canvas) {
canvas->drawColor(SK_ColorWHITE);
}
virtual void onDraw(SkCanvas* canvas) {
this->drawBG(canvas);
SkPaint paint;
paint.setAntiAlias(true);
SkScalar textSize = SkIntToScalar(6);
SkScalar delta = SK_Scalar1;
const char* text = "HHHamburgefonts iii";
size_t len = strlen(text);
SkScalar x0 = SkIntToScalar(10);
SkScalar x1 = SkIntToScalar(310);
SkScalar y = SkIntToScalar(20);
for (int i = 0; i < 20; i++) {
paint.setTextSize(textSize);
textSize += delta;
paint.setLCDRenderText(false);
canvas->drawText(text, len, x0, y, paint);
paint.setLCDRenderText(true);
canvas->drawText(text, len, x1, y, paint);
y += paint.getFontSpacing();
}
}
private:
typedef SkView INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
static SkView* MyFactory() { return new LCDView; }
static SkViewRegister reg(MyFactory);

View File

@ -21,7 +21,7 @@
#include "SkUtils.h"
#include "SkXfermode.h"
#if defined(SK_BUILD_SUBPIXEL)
#if defined(SK_SUPPORT_LCDTEXT)
namespace skia_blitter_support {
// subpixel helper functions from SkBlitter_ARGB32_Subpixel.cpp
extern uint32_t BlendLCDPixelWithColor(const uint32_t alphaPixel, const uint32_t originalPixel,
@ -216,7 +216,7 @@ void SkARGB32_Opaque_Blitter::blitMask(const SkMask& mask,
int width = clip.width();
int height = clip.height();
#if defined(SK_BUILD_SUBPIXEL)
#if defined(SK_SUPPORT_LCDTEXT)
const bool lcdMode = mask.fFormat == SkMask::kHorizontalLCD_Format;
const bool verticalLCDMode = mask.fFormat == SkMask::kVerticalLCD_Format;
#else
@ -227,7 +227,7 @@ void SkARGB32_Opaque_Blitter::blitMask(const SkMask& mask,
uint32_t* device = fDevice.getAddr32(x - lcdMode, y - verticalLCDMode);
uint32_t srcColor = fPMColor;
#if defined(SK_BUILD_SUBPIXEL)
#if defined(SK_SUPPORT_LCDTEXT)
if (lcdMode || verticalLCDMode) {
const uint32_t* alpha32 = mask.getAddrLCD(clip.fLeft, clip.fTop);
@ -348,7 +348,7 @@ void SkARGB32_Black_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) {
SkARGB32_BlitBW(fDevice, mask, clip, black);
} else {
#if defined(SK_BUILD_SUBPIXEL)
#if defined(SK_SUPPORT_LCDTEXT)
const bool lcdMode = mask.fFormat == SkMask::kHorizontalLCD_Format;
const bool verticalLCDMode = mask.fFormat == SkMask::kVerticalLCD_Format;
#else
@ -356,16 +356,15 @@ void SkARGB32_Black_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) {
#endif
// In LCD mode the masks have either an extra couple of rows or columns on the edges.
uint32_t* device = fDevice.getAddr32(clip.fLeft - lcdMode, clip.fTop - verticalLCDMode);
uint32_t* device = fDevice.getAddr32(clip.fLeft - lcdMode,
clip.fTop - verticalLCDMode);
unsigned width = clip.width();
unsigned height = clip.height();
SkASSERT((int)height > 0);
SkASSERT((int)width > 0);
SkASSERT((int)deviceRB >= 0);
SkASSERT((int)maskRB >= 0);
#if defined(SK_BUILD_SUBPIXEL)
#if defined(SK_SUPPORT_LCDTEXT)
if (lcdMode || verticalLCDMode) {
const uint32_t* alpha32 = mask.getAddrLCD(clip.fLeft, clip.fTop);
if (lcdMode)

View File

@ -1126,7 +1126,7 @@ static SkMask::Format computeMaskFormat(const SkPaint& paint)
uint32_t flags = paint.getFlags();
if (flags & SkPaint::kLCDRenderText_Flag)
#if defined(SK_BUILD_SUBPIXEL)
#if defined(SK_SUPPORT_LCDTEXT)
return SkFontHost::GetSubpixelOrientation() == SkFontHost::kHorizontal_LCDOrientation ?
SkMask::kHorizontalLCD_Format : SkMask::kVerticalLCD_Format;
#else

View File

@ -75,7 +75,7 @@ void SkGlyph::expandA8ToLCD() const {
SkASSERT(fMaskFormat == SkMask::kHorizontalLCD_Format ||
fMaskFormat == SkMask::kVerticalLCD_Format);
#if defined(SK_BUILD_SUBPIXEL)
#if defined(SK_SUPPORT_LCDTEXT)
uint8_t* input = reinterpret_cast<uint8_t*>(fImage);
uint32_t* output = reinterpret_cast<uint32_t*>(input + SkAlign4(rowBytes() * fHeight));

View File

@ -14,6 +14,7 @@ SOURCE := \
SkBlitter_A1.cpp \
SkBlitter_A8.cpp \
SkBlitter_ARGB32.cpp \
SkBlitter_ARGB32_Subpixel.cpp \
SkBlitter_RGB16.cpp \
SkBlitter_Sprite.cpp \
SkBuffer.cpp \
@ -36,6 +37,7 @@ SOURCE := \
SkFlattenable.cpp \
SkFloat.cpp \
SkFloatBits.cpp \
SkFontHost.cpp \
SkGeometry.cpp \
SkGlobals.cpp \
SkGlyphCache.cpp \

View File

@ -34,7 +34,7 @@
#include FT_SIZES_H
#include FT_TRUETYPE_TABLES_H
#if defined(SK_BUILD_SUBPIXEL)
#if defined(SK_SUPPORT_LCDTEXT)
#include FT_LCD_FILTER_H
#endif
@ -82,7 +82,7 @@ InitFreetype() {
if (err)
return false;
#if defined(SK_BUILD_SUBPIXEL)
#if defined(SK_SUPPORT_LCDTEXT)
// Setup LCD filtering. This reduces colour fringes for LCD rendered
// glyphs.
err = FT_Library_SetLcdFilter(gFTLibrary, FT_LCD_FILTER_DEFAULT);
@ -562,7 +562,7 @@ void SkScalerContext_FreeType::generateMetrics(SkGlyph* glyph) {
#endif
}
#if defined(SK_BUILD_SUBPIXEL)
#if defined(SK_SUPPORT_LCDTEXT)
namespace skia_freetype_support {
// extern functions from SkFontHost_FreeType_Subpixel
extern void CopyFreetypeBitmapToLCDMask(const SkGlyph& dest, const FT_Bitmap& source);
@ -618,7 +618,7 @@ void SkScalerContext_FreeType::generateImage(const SkGlyph& glyph) {
FT_Outline_Translate(outline, dx - ((bbox.xMin + dx) & ~63),
dy - ((bbox.yMin + dy) & ~63));
#if defined(SK_BUILD_SUBPIXEL)
#if defined(SK_SUPPORT_LCDTEXT)
if (lcdRenderMode) {
// FT_Outline_Get_Bitmap cannot render LCD glyphs. In this case
// we have to call FT_Render_Glyph and memcpy the image out.

View File

@ -9,6 +9,8 @@
/* Begin PBXBuildFile section */
002884C80EFAB8B90083E387 /* SkMMapStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 002884C70EFAB8B90083E387 /* SkMMapStream.cpp */; };
002884D50EFAB8F80083E387 /* SkStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 002884D40EFAB8F80083E387 /* SkStream.cpp */; };
005DC79910179ACD00F00DFB /* SkBlitter_ARGB32_Subpixel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 005DC79810179ACD00F00DFB /* SkBlitter_ARGB32_Subpixel.cpp */; };
005DC79B10179AE000F00DFB /* SkFontHost.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 005DC79A10179AE000F00DFB /* SkFontHost.cpp */; };
005F256F0EF94F7900582A90 /* ARGB32_Clamp_Bilinear_BitmapShader.h in Headers */ = {isa = PBXBuildFile; fileRef = 005F24F60EF94F7900582A90 /* ARGB32_Clamp_Bilinear_BitmapShader.h */; };
005F25700EF94F7900582A90 /* Sk64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 005F24F70EF94F7900582A90 /* Sk64.cpp */; };
005F25710EF94F7900582A90 /* SkAlphaRuns.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 005F24F80EF94F7900582A90 /* SkAlphaRuns.cpp */; };
@ -131,6 +133,8 @@
/* Begin PBXFileReference section */
002884C70EFAB8B90083E387 /* SkMMapStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SkMMapStream.cpp; path = ../../src/core/SkMMapStream.cpp; sourceTree = SOURCE_ROOT; };
002884D40EFAB8F80083E387 /* SkStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SkStream.cpp; path = ../../src/core/SkStream.cpp; sourceTree = SOURCE_ROOT; };
005DC79810179ACD00F00DFB /* SkBlitter_ARGB32_Subpixel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SkBlitter_ARGB32_Subpixel.cpp; path = ../../src/core/SkBlitter_ARGB32_Subpixel.cpp; sourceTree = SOURCE_ROOT; };
005DC79A10179AE000F00DFB /* SkFontHost.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SkFontHost.cpp; path = ../../src/core/SkFontHost.cpp; sourceTree = SOURCE_ROOT; };
005F24F60EF94F7900582A90 /* ARGB32_Clamp_Bilinear_BitmapShader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ARGB32_Clamp_Bilinear_BitmapShader.h; path = ../../src/core/ARGB32_Clamp_Bilinear_BitmapShader.h; sourceTree = SOURCE_ROOT; };
005F24F70EF94F7900582A90 /* Sk64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Sk64.cpp; path = ../../src/core/Sk64.cpp; sourceTree = SOURCE_ROOT; };
005F24F80EF94F7900582A90 /* SkAlphaRuns.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SkAlphaRuns.cpp; path = ../../src/core/SkAlphaRuns.cpp; sourceTree = SOURCE_ROOT; };
@ -292,6 +296,8 @@
08FB7795FE84155DC02AAC07 /* src */ = {
isa = PBXGroup;
children = (
005DC79A10179AE000F00DFB /* SkFontHost.cpp */,
005DC79810179ACD00F00DFB /* SkBlitter_ARGB32_Subpixel.cpp */,
009CC7910F5DAF4B002185BE /* SkCubicClipper.cpp */,
007C78690F3B4D5F0004B142 /* SkQuadClipper.cpp */,
002884D40EFAB8F80083E387 /* SkStream.cpp */,
@ -600,6 +606,8 @@
007C786A0F3B4D5F0004B142 /* SkQuadClipper.cpp in Sources */,
009CC7920F5DAF4B002185BE /* SkCubicClipper.cpp in Sources */,
0096586E0FC7205100C3AE15 /* SkShape.cpp in Sources */,
005DC79910179ACD00F00DFB /* SkBlitter_ARGB32_Subpixel.cpp in Sources */,
005DC79B10179AE000F00DFB /* SkFontHost.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};