Move some more code around
authorBehdad Esfahbod <behdad@behdad.org>
Thu, 28 Oct 2010 02:37:59 +0000 (22:37 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Tue, 2 Nov 2010 23:12:59 +0000 (19:12 -0400)
src/hb-ot-layout-gdef-private.hh
src/hb-ot-layout-private.hh
src/hb-ot-layout.cc

index 209f00a..4172a7c 100644 (file)
@@ -374,6 +374,27 @@ struct GDEF
        && (version < 0x00010002 || markGlyphSetsDef[0].sanitize (c, this));
   }
 
+
+  /* glyph_props is a 16-bit integer where the lower 8-bit have bits representing
+   * glyph class and other bits, and high 8-bit gthe mark attachment type (if any).
+   * Not to be confused with lookup_props which is very similar. */
+  inline unsigned int get_glyph_props (hb_codepoint_t glyph) const
+  {
+    unsigned int klass = get_glyph_class (glyph);
+
+    switch (klass) {
+    default:
+    case UnclassifiedGlyph:    return HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED;
+    case BaseGlyph:            return HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH;
+    case LigatureGlyph:                return HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE;
+    case ComponentGlyph:       return HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT;
+    case MarkGlyph:
+         klass = get_mark_attachment_type (glyph);
+         return HB_OT_LAYOUT_GLYPH_CLASS_MARK | (klass << 8);
+    }
+  }
+
+
   private:
   FixedVersion version;                /* Version of the GDEF table--currently
                                         * 0x00010002 */
index d9d65a5..4513676 100644 (file)
@@ -46,11 +46,11 @@ HB_BEGIN_DECLS
 #define cursive_chain() var.i16[1] /* character to which this connects, may be positive or negative */
 
 typedef enum {
+  HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED        = 0x0001,
   HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH  = 0x0002,
   HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE    = 0x0004,
   HB_OT_LAYOUT_GLYPH_CLASS_MARK                = 0x0008,
-  HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT   = 0x0010,
-  HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED        = 0x0020
+  HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT   = 0x0010
 } hb_ot_layout_glyph_class_t;
 
 
@@ -94,17 +94,36 @@ _hb_ot_layout_free (hb_ot_layout_t *layout);
  * GDEF
  */
 
+HB_INTERNAL unsigned int
+_hb_ot_layout_get_glyph_property (hb_face_t       *face,
+                                 hb_glyph_info_t *info);
+
 HB_INTERNAL hb_bool_t
 _hb_ot_layout_check_glyph_property (hb_face_t    *face,
                                    hb_glyph_info_t *ginfo,
                                    unsigned int  lookup_props,
                                    unsigned int *property);
 
-HB_INTERNAL hb_bool_t
+static inline hb_bool_t
 _hb_ot_layout_skip_mark (hb_face_t    *face,
                         hb_glyph_info_t *ginfo,
                         unsigned int  lookup_props,
-                        unsigned int *property);
+                        unsigned int *property_out)
+{
+  unsigned int property;
+
+  property = _hb_ot_layout_get_glyph_property (face, ginfo);
+  if (property_out)
+    *property_out = property;
+
+  /* If it's a mark, skip it we don't accept it. */
+  if (property & HB_OT_LAYOUT_GLYPH_CLASS_MARK)
+    return !_hb_ot_layout_check_glyph_property (face, ginfo, lookup_props, NULL);
+
+  /* If not a mark, don't skip. */
+  return false;
+}
+
 
 
 HB_END_DECLS
index ca13a4d..98004e9 100644 (file)
@@ -73,19 +73,19 @@ _hb_ot_layout_free (hb_ot_layout_t *layout)
   free (layout);
 }
 
-static const GDEF&
+static inline const GDEF&
 _get_gdef (hb_face_t *face)
 {
   return likely (face->ot_layout && face->ot_layout->gdef) ? *face->ot_layout->gdef : Null(GDEF);
 }
 
-static const GSUB&
+static inline const GSUB&
 _get_gsub (hb_face_t *face)
 {
   return likely (face->ot_layout && face->ot_layout->gsub) ? *face->ot_layout->gsub : Null(GSUB);
 }
 
-static const GPOS&
+static inline const GPOS&
 _get_gpos (hb_face_t *face)
 {
   return likely (face->ot_layout && face->ot_layout->gpos) ? *face->ot_layout->gpos : Null(GPOS);
@@ -102,35 +102,15 @@ hb_ot_layout_has_glyph_classes (hb_face_t *face)
   return _get_gdef (face).has_glyph_classes ();
 }
 
-static unsigned int
-_hb_ot_layout_get_glyph_property_from_gdef (hb_face_t       *face,
-                                           hb_glyph_info_t *info)
-{
-  hb_codepoint_t glyph = info->codepoint;
-
-  unsigned int klass;
-  const GDEF &gdef = _get_gdef (face);
-
-  klass = gdef.get_glyph_class (glyph);
-
-  switch (klass) {
-  default:
-  case GDEF::UnclassifiedGlyph:        return HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED;
-  case GDEF::BaseGlyph:                return HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH;
-  case GDEF::LigatureGlyph:    return HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE;
-  case GDEF::ComponentGlyph:   return HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT;
-  case GDEF::MarkGlyph:
-       klass = gdef.get_mark_attachment_type (glyph);
-       return HB_OT_LAYOUT_GLYPH_CLASS_MARK | (klass << 8);
-  }
-}
-
-static inline unsigned int
+unsigned int
 _hb_ot_layout_get_glyph_property (hb_face_t       *face,
                                  hb_glyph_info_t *info)
 {
   if (!info->gproperty())
-    info->gproperty() = _hb_ot_layout_get_glyph_property_from_gdef (face, info);
+  {
+    const GDEF &gdef = _get_gdef (face);
+    info->gproperty() = gdef.get_glyph_props (info->codepoint);
+  }
 
   return info->gproperty();
 }
@@ -172,26 +152,6 @@ _hb_ot_layout_check_glyph_property (hb_face_t    *face,
   return true;
 }
 
-hb_bool_t
-_hb_ot_layout_skip_mark (hb_face_t    *face,
-                        hb_glyph_info_t *ginfo,
-                        unsigned int  lookup_props,
-                        unsigned int *property_out)
-{
-  unsigned int property;
-
-  property = _hb_ot_layout_get_glyph_property (face, ginfo);
-  if (property_out)
-    *property_out = property;
-
-  /* If it's a mark, skip it we don't accept it. */
-  if (property & HB_OT_LAYOUT_GLYPH_CLASS_MARK)
-    return !_hb_ot_layout_check_glyph_property (face, ginfo, lookup_props, NULL);
-
-  /* If not a mark, don't skip. */
-  return false;
-}
-
 unsigned int
 hb_ot_layout_get_attach_points (hb_face_t      *face,
                                hb_codepoint_t  glyph,