[HarfBuzz] harfbuzz: Branch 'master' - 2 commits

Behdad Esfahbod behdad at kemper.freedesktop.org
Wed Nov 13 11:51:36 PST 2013


 src/hb-buffer-private.hh |    3 ++-
 src/hb-buffer.cc         |   10 +++++-----
 src/hb-coretext.cc       |    5 ++---
 src/hb-graphite2.cc      |    2 +-
 src/hb-uniscribe.cc      |   30 ++++++++++++++----------------
 5 files changed, 24 insertions(+), 26 deletions(-)

New commits:
commit 061cb4649342b005fb1de93abae25e889cc560bd
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Nov 13 14:50:25 2013 -0500

    Use long alignment for scratch buffer
    
    Fixes last of scratch alignment warnings in hb-coretext.

diff --git a/src/hb-buffer-private.hh b/src/hb-buffer-private.hh
index 478bad0..d3ed449 100644
--- a/src/hb-buffer-private.hh
+++ b/src/hb-buffer-private.hh
@@ -186,7 +186,7 @@ struct hb_buffer_t {
   HB_INTERNAL bool make_room_for (unsigned int num_in, unsigned int num_out);
   HB_INTERNAL bool shift_forward (unsigned int count);
 
-  typedef int scratch_buffer_t;
+  typedef long scratch_buffer_t;
   HB_INTERNAL scratch_buffer_t *get_scratch_buffer (unsigned int *size);
 
   inline void clear_context (unsigned int side) { context_len[side] = 0; }
diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc
index df2ad73..bbf8ea0 100644
--- a/src/hb-buffer.cc
+++ b/src/hb-buffer.cc
@@ -161,9 +161,9 @@ hb_buffer_t::get_scratch_buffer (unsigned int *size)
   out_len = 0;
   out_info = info;
 
-  ASSERT_STATIC (sizeof (pos[0]) % sizeof (scratch_buffer_t) == 0);
+  assert ((uintptr_t) pos % sizeof (scratch_buffer_t) == 0);
   *size = allocated * sizeof (pos[0]) / sizeof (scratch_buffer_t);
-  return (scratch_buffer_t *) pos;
+  return (scratch_buffer_t *) (void *) pos;
 }
 
 
commit 68c372ed2eac76a6d347811293fe2ba2fd6a1eed
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Nov 13 14:44:01 2013 -0500

    More scratch-buffer cleanup

diff --git a/src/hb-buffer-private.hh b/src/hb-buffer-private.hh
index 4647b9b..478bad0 100644
--- a/src/hb-buffer-private.hh
+++ b/src/hb-buffer-private.hh
@@ -186,7 +186,8 @@ struct hb_buffer_t {
   HB_INTERNAL bool make_room_for (unsigned int num_in, unsigned int num_out);
   HB_INTERNAL bool shift_forward (unsigned int count);
 
-  HB_INTERNAL int *get_scratch_buffer (unsigned int *int_size);
+  typedef int scratch_buffer_t;
+  HB_INTERNAL scratch_buffer_t *get_scratch_buffer (unsigned int *size);
 
   inline void clear_context (unsigned int side) { context_len[side] = 0; }
 };
diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc
index c5a74c3..df2ad73 100644
--- a/src/hb-buffer.cc
+++ b/src/hb-buffer.cc
@@ -152,8 +152,8 @@ hb_buffer_t::shift_forward (unsigned int count)
   return true;
 }
 
-int *
-hb_buffer_t::get_scratch_buffer (unsigned int *int_size)
+hb_buffer_t::scratch_buffer_t *
+hb_buffer_t::get_scratch_buffer (unsigned int *size)
 {
   have_output = false;
   have_positions = false;
@@ -161,9 +161,9 @@ hb_buffer_t::get_scratch_buffer (unsigned int *int_size)
   out_len = 0;
   out_info = info;
 
-  ASSERT_STATIC (sizeof (pos[0]) % sizeof (int) == 0);
-  *int_size = allocated * (sizeof (pos[0]) / sizeof (int));
-  return (int *) pos;
+  ASSERT_STATIC (sizeof (pos[0]) % sizeof (scratch_buffer_t) == 0);
+  *size = allocated * sizeof (pos[0]) / sizeof (scratch_buffer_t);
+  return (scratch_buffer_t *) pos;
 }
 
 
diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc
index eafa68e..ba80136 100644
--- a/src/hb-coretext.cc
+++ b/src/hb-coretext.cc
@@ -553,7 +553,7 @@ _hb_coretext_shape (hb_shape_plan_t    *shape_plan,
   } HB_STMT_END;
 
   unsigned int scratch_size;
-  int *scratch = buffer->get_scratch_buffer (&scratch_size);
+  hb_buffer_t::scratch_buffer_t *scratch = buffer->get_scratch_buffer (&scratch_size);
 
 #define ALLOCATE_ARRAY(Type, name, len) \
   Type *name = (Type *) scratch; \
@@ -657,8 +657,7 @@ _hb_coretext_shape (hb_shape_plan_t    *shape_plan,
 
     buffer->ensure (buffer->len + num_glyphs);
 
-    unsigned int scratch_size;
-    int *scratch = buffer->get_scratch_buffer (&scratch_size);
+    scratch = buffer->get_scratch_buffer (&scratch_size);
 
     /* Testing indicates that CTRunGetGlyphsPtr, etc (almost?) always
      * succeed, and so copying data to our own buffer will be rare. */
diff --git a/src/hb-graphite2.cc b/src/hb-graphite2.cc
index d1cd1dc..60d68d6 100644
--- a/src/hb-graphite2.cc
+++ b/src/hb-graphite2.cc
@@ -243,7 +243,7 @@ _hb_graphite2_shape (hb_shape_plan_t    *shape_plan,
   float curradvx = 0., curradvy = 0.;
 
   unsigned int scratch_size;
-  int *scratch = buffer->get_scratch_buffer (&scratch_size);
+  hb_buffer_t::scratch_buffer_t *scratch = buffer->get_scratch_buffer (&scratch_size);
 
   uint32_t *chars = (uint32_t *) scratch;
 
diff --git a/src/hb-uniscribe.cc b/src/hb-uniscribe.cc
index 4a93db8..fcb1aa6 100644
--- a/src/hb-uniscribe.cc
+++ b/src/hb-uniscribe.cc
@@ -729,13 +729,21 @@ _hb_uniscribe_shape (hb_shape_plan_t    *shape_plan,
 retry:
 
   unsigned int scratch_size;
-  int *scratch = buffer->get_scratch_buffer (&scratch_size);
+  hb_buffer_t::scratch_buffer_t *scratch = buffer->get_scratch_buffer (&scratch_size);
 
-  /* Allocate char buffers; they all fit */
+#define ALLOCATE_ARRAY(Type, name, len) \
+  Type *name = (Type *) scratch; \
+  { \
+    unsigned int _consumed = DIV_CEIL ((len) * sizeof (Type), sizeof (*scratch)); \
+    assert (_consumed <= scratch_size); \
+    scratch += _consumed; \
+    scratch_size -= _consumed; \
+  }
 
 #define utf16_index() var1.u32
 
-  WCHAR *pchars = (WCHAR *) scratch;
+  ALLOCATE_ARRAY (WCHAR, pchars, buffer->len * 2);
+
   unsigned int chars_len = 0;
   for (unsigned int i = 0; i < buffer->len; i++)
   {
@@ -751,16 +759,6 @@ retry:
     }
   }
 
-#define ALLOCATE_ARRAY(Type, name, len) \
-  Type *name = (Type *) scratch; \
-  { \
-    unsigned int _consumed = DIV_CEIL ((len) * sizeof (Type), sizeof (*scratch)); \
-    assert (_consumed <= scratch_size); \
-    scratch += _consumed; \
-    scratch_size -= _consumed; \
-  }
-
-  ALLOCATE_ARRAY (WCHAR, wchars, chars_len);
   ALLOCATE_ARRAY (WORD, log_clusters, chars_len);
   ALLOCATE_ARRAY (SCRIPT_CHARPROP, char_props, chars_len);
 
@@ -817,7 +815,7 @@ retry:
   bidi_state.uBidiLevel = HB_DIRECTION_IS_FORWARD (buffer->props.direction) ? 0 : 1;
   bidi_state.fOverrideDirection = 1;
 
-  hr = funcs->ScriptItemizeOpenType (wchars,
+  hr = funcs->ScriptItemizeOpenType (pchars,
 				     chars_len,
 				     MAX_ITEMS,
 				     &bidi_control,
@@ -892,7 +890,7 @@ retry:
 				     range_char_counts.array,
 				     range_properties.array,
 				     range_properties.len,
-				     wchars + chars_offset,
+				     pchars + chars_offset,
 				     item_chars_len,
 				     glyphs_size - glyphs_offset,
 				     /* out */
@@ -934,7 +932,7 @@ retry:
 				     range_char_counts.array,
 				     range_properties.array,
 				     range_properties.len,
-				     wchars + chars_offset,
+				     pchars + chars_offset,
 				     log_clusters + chars_offset,
 				     char_props + chars_offset,
 				     item_chars_len,



More information about the HarfBuzz mailing list