encode current LCD orientation and order into font-cache-key
authorreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 18 May 2011 19:00:53 +0000 (19:00 +0000)
committerreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 18 May 2011 19:00:53 +0000 (19:00 +0000)
git-svn-id: http://skia.googlecode.com/svn/trunk@1368 2bbb7eff-a529-9590-31e7-b0007b416f81

include/core/SkScalerContext.h
src/core/SkPaint.cpp

index 55dfcef..3f818a3 100644 (file)
@@ -179,6 +179,9 @@ public:
         kEmbolden_Flag      = 0x80,
         kSubpixelPositioning_Flag = 0x100,
         kAutohinting_Flag   = 0x200,
+        // these should only ever be set if fMaskFormat is LCD
+        kLCD_Vertical_Flag  = 0x400,    // else Horizontal
+        kLCD_BGROrder_Flag  = 0x800,    // else RGB order
     };
 private:
     enum {
index 14c0397..311ec7d 100644 (file)
@@ -1292,18 +1292,35 @@ void SkScalerContext::MakeRec(const SkPaint& paint,
         rec->fStrokeJoin = 0;
     }
 
-    rec->fMaskFormat = SkToU8(computeMaskFormat(paint));
-    rec->fFlags = SkToU8(flags);
     rec->setHinting(computeHinting(paint));
+    rec->fMaskFormat = SkToU8(computeMaskFormat(paint));
+
+    if (SkMask::kLCD16_Format == rec->fMaskFormat) {
+        SkFontHost::LCDOrder order = SkFontHost::GetSubpixelOrder();
+        SkFontHost::LCDOrientation orient = SkFontHost::GetSubpixelOrientation();
+        if (SkFontHost::kNONE_LCDOrder == order) {
+            // eeek, can't support LCD
+            rec->fMaskFormat = SkMask::kA8_Format;
+        } else {
+            if (SkFontHost::kVertical_LCDOrientation == orient) {
+                flags |= SkScalerContext::kLCD_Vertical_Flag;
+            }
+            if (SkFontHost::kBGR_LCDOrder == order) {
+                flags |= SkScalerContext::kLCD_BGROrder_Flag;
+            }
+        }
+    }
+
     if (paint.isEmbeddedBitmapText()) {
-        rec->fFlags |= SkScalerContext::kEmbeddedBitmapText_Flag;
+        flags |= SkScalerContext::kEmbeddedBitmapText_Flag;
     }
     if (paint.isSubpixelText()) {
-        rec->fFlags |= SkScalerContext::kSubpixelPositioning_Flag;
+        flags |= SkScalerContext::kSubpixelPositioning_Flag;
     }
     if (paint.isAutohinted()) {
-        rec->fFlags |= SkScalerContext::kAutohinting_Flag;
+        flags |= SkScalerContext::kAutohinting_Flag;
     }
+    rec->fFlags = SkToU16(flags);
 
     /*  Allow the fonthost to modify our rec before we use it as a key into the
         cache. This way if we're asking for something that they will ignore,