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
diff --git a/Makefile b/Makefile
index 4decd28..26a1580 100644
--- a/Makefile
+++ b/Makefile
@@ -20,6 +20,8 @@
 	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))
diff --git a/include/config/SkUserConfig.h b/include/config/SkUserConfig.h
index 498eb8f..2d51204 100644
--- a/include/config/SkUserConfig.h
+++ b/include/config/SkUserConfig.h
@@ -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,
diff --git a/include/core/SkMask.h b/include/core/SkMask.h
index 780b277..8c041e4 100644
--- a/include/core/SkMask.h
+++ b/include/core/SkMask.h
@@ -99,7 +99,7 @@
         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);
 
diff --git a/samplecode/SampleLCD.cpp b/samplecode/SampleLCD.cpp
new file mode 100644
index 0000000..098958f
--- /dev/null
+++ b/samplecode/SampleLCD.cpp
@@ -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);
+
diff --git a/src/core/SkBlitter_ARGB32.cpp b/src/core/SkBlitter_ARGB32.cpp
index e2614c2..247e255 100644
--- a/src/core/SkBlitter_ARGB32.cpp
+++ b/src/core/SkBlitter_ARGB32.cpp
@@ -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 @@
     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 @@
     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 @@
 
         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 @@
 #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)
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index 95448c9..b136733 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -1126,7 +1126,7 @@
     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
diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp
index 57a3b35..eab015a 100644
--- a/src/core/SkScalerContext.cpp
+++ b/src/core/SkScalerContext.cpp
@@ -75,7 +75,7 @@
     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));
 
diff --git a/src/core/core_files.mk b/src/core/core_files.mk
index 94e19d7..736f7fd 100644
--- a/src/core/core_files.mk
+++ b/src/core/core_files.mk
@@ -14,6 +14,7 @@
     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 @@
     SkFlattenable.cpp \
     SkFloat.cpp \
     SkFloatBits.cpp \
+    SkFontHost.cpp \
     SkGeometry.cpp \
     SkGlobals.cpp \
     SkGlyphCache.cpp \
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
index 5367439..fa10362 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -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 @@
     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 @@
 #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 @@
             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.
diff --git a/xcode/core/core.xcodeproj/project.pbxproj b/xcode/core/core.xcodeproj/project.pbxproj
index cd8711a..a730f4d 100644
--- a/xcode/core/core.xcodeproj/project.pbxproj
+++ b/xcode/core/core.xcodeproj/project.pbxproj
@@ -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;
 		};