store luminance in a new field
authorreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 7 Feb 2012 21:25:33 +0000 (21:25 +0000)
committerreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 7 Feb 2012 21:25:33 +0000 (21:25 +0000)
Review URL: https://codereview.appspot.com/5644047

git-svn-id: http://skia.googlecode.com/svn/trunk@3149 2bbb7eff-a529-9590-31e7-b0007b416f81

include/core/SkScalerContext.h

index 2e4d59412224f9e0ecc5df72dec925a7e4475116..b2f6a57de627b04e8627cfc3c5cd8e6cfa204ecb 100644 (file)
@@ -154,6 +154,8 @@ struct SkGlyph {
     void toMask(SkMask* mask) const;
 };
 
+//#define USE_NEW_LUMINANCE
+
 class SkScalerContext {
 public:
     enum Flags {
@@ -179,16 +181,22 @@ public:
         // Perhaps we can store this (instead) in fMaskFormat, in hight bit?
         kGenA8FromLCD_Flag        = 0x0800,
 
+#ifdef USE_NEW_LUMINANCE
+        kLuminance_Bits           = 3,
+#else
         // luminance : 0 for black text, kLuminance_Max for white text
         kLuminance_Shift          = 13, // shift to land in the high 3-bits of Flags
         kLuminance_Bits           = 3,  // ensure Flags doesn't exceed 16bits
+#endif
     };
     
     // computed values
     enum {
         kHinting_Mask   = kHintingBit1_Flag | kHintingBit2_Flag,
         kLuminance_Max  = (1 << kLuminance_Bits) - 1,
+#ifndef USE_NEW_LUMINANCE
         kLuminance_Mask = kLuminance_Max << kLuminance_Shift,
+#endif
     };
 
     struct Rec {
@@ -197,6 +205,9 @@ public:
         SkScalar    fTextSize, fPreScaleX, fPreSkewX;
         SkScalar    fPost2x2[2][2];
         SkScalar    fFrameWidth, fMiterLimit;
+#ifdef USE_NEW_LUMINANCE
+        uint32_t    fLumBits;
+#endif
         uint8_t     fMaskFormat;
         uint8_t     fStrokeJoin;
         uint16_t    fFlags;
@@ -217,7 +228,21 @@ public:
         void setHinting(SkPaint::Hinting hinting) {
             fFlags = (fFlags & ~kHinting_Mask) | (hinting << kHinting_Shift);
         }
-
+        
+        SkMask::Format getFormat() const {
+            return static_cast<SkMask::Format>(fMaskFormat);
+        }
+        
+#ifdef USE_NEW_LUMINANCE
+        unsigned getLuminanceBits() const {
+            return fLumBits;
+        }
+        
+        void setLuminanceBits(unsigned lum) {
+            SkASSERT(lum <= kLuminance_Max);
+            fLumBits = lum;
+        }
+#else
         unsigned getLuminanceBits() const {
             return (fFlags & kLuminance_Mask) >> kLuminance_Shift;
         }
@@ -226,6 +251,7 @@ public:
             SkASSERT(lum <= kLuminance_Max);
             fFlags = (fFlags & ~kLuminance_Mask) | (lum << kLuminance_Shift);
         }
+#endif
 
         U8CPU getLuminanceByte() const {
             SkASSERT(3 == kLuminance_Bits);
@@ -234,10 +260,6 @@ public:
             lum |= (lum << kLuminance_Bits*2);
             return lum >> (4*kLuminance_Bits - 8);
         }
-
-        SkMask::Format getFormat() const {
-            return static_cast<SkMask::Format>(fMaskFormat);
-        }
     };
 
     SkScalerContext(const SkDescriptor* desc);