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 55dfcef049c22688e85381b524932a2a22b9edab..3f818a31124d5c881a122462df80868f0ebe78ea 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 14c03971993400f945b033f193293b1e6c87103a..311ec7d1188115939b01f59ba0011ba30ec71e74 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,