[HarfBuzz] harfbuzz: Branch 'master' - 2 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Mon Aug 11 15:41:45 PDT 2014
src/hb-buffer-private.hh | 4 +---
src/hb-buffer.cc | 4 ++--
src/hb-common.h | 5 +++--
test/api/test-buffer.c | 15 ++++++++++++---
4 files changed, 18 insertions(+), 10 deletions(-)
New commits:
commit b5fbc3b8f560235d014c62e49220574ffcf89349
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon Aug 11 18:40:01 2014 -0400
API: Do not clear buffer-flags in hb_buffer_clear_contents()
After 763e5466c0a03a7c27020e1e2598e488612529a7, one doesn't
need to set flags for different pieces of text. The flags now
are something the client sets up once, depending on how it
actually uses the buffer. As such, don't clear it in
clear_contents().
Tests updated.
diff --git a/src/hb-buffer-private.hh b/src/hb-buffer-private.hh
index 68e6fc6..069f925 100644
--- a/src/hb-buffer-private.hh
+++ b/src/hb-buffer-private.hh
@@ -48,15 +48,13 @@ struct hb_buffer_t {
ASSERT_POD ();
/* Information about how the text in the buffer should be treated */
-
hb_unicode_funcs_t *unicode; /* Unicode functions */
- hb_segment_properties_t props; /* Script, language, direction */
hb_buffer_flags_t flags; /* BOT / EOT / etc. */
hb_codepoint_t replacement; /* U+FFFD or something else. */
/* Buffer contents */
-
hb_buffer_content_type_t content_type;
+ hb_segment_properties_t props; /* Script, language, direction */
bool in_error; /* Allocation failed */
bool have_output; /* Whether we have an output buffer going on */
diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc
index 2377ba4..74ae273 100644
--- a/src/hb-buffer.cc
+++ b/src/hb-buffer.cc
@@ -178,6 +178,7 @@ hb_buffer_t::reset (void)
hb_unicode_funcs_destroy (unicode);
unicode = hb_unicode_funcs_get_default ();
+ flags = HB_BUFFER_FLAG_DEFAULT;
replacement = HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT;
clear ();
@@ -191,7 +192,6 @@ hb_buffer_t::clear (void)
hb_segment_properties_t default_props = HB_SEGMENT_PROPERTIES_DEFAULT;
props = default_props;
- flags = HB_BUFFER_FLAG_DEFAULT;
content_type = HB_BUFFER_CONTENT_TYPE_INVALID;
in_error = false;
@@ -702,11 +702,11 @@ hb_buffer_get_empty (void)
HB_OBJECT_HEADER_STATIC,
const_cast<hb_unicode_funcs_t *> (&_hb_unicode_funcs_nil),
- HB_SEGMENT_PROPERTIES_DEFAULT,
HB_BUFFER_FLAG_DEFAULT,
HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT,
HB_BUFFER_CONTENT_TYPE_INVALID,
+ HB_SEGMENT_PROPERTIES_DEFAULT,
true, /* in_error */
true, /* have_output */
true /* have_positions */
diff --git a/test/api/test-buffer.c b/test/api/test-buffer.c
index af73c3f..17607f1 100644
--- a/test/api/test-buffer.c
+++ b/test/api/test-buffer.c
@@ -110,7 +110,6 @@ test_buffer_properties (fixture_t *fixture, gconstpointer user_data)
g_assert (hb_buffer_get_direction (b) == HB_DIRECTION_INVALID);
g_assert (hb_buffer_get_script (b) == HB_SCRIPT_INVALID);
g_assert (hb_buffer_get_language (b) == NULL);
- g_assert (hb_buffer_get_flags (b) == HB_BUFFER_FLAG_DEFAULT);
/* test property changes are retained */
@@ -131,9 +130,11 @@ test_buffer_properties (fixture_t *fixture, gconstpointer user_data)
hb_buffer_set_flags (b, HB_BUFFER_FLAG_BOT);
g_assert (hb_buffer_get_flags (b) == HB_BUFFER_FLAG_BOT);
+ hb_buffer_set_replacement_codepoint (b, (unsigned int) -1);
+ g_assert (hb_buffer_get_replacement_codepoint (b) == (unsigned int) -1);
- /* test clear clears all properties but unicode_funcs */
+ /* test clear_contents clears all these properties: */
hb_buffer_clear_contents (b);
@@ -141,7 +142,11 @@ test_buffer_properties (fixture_t *fixture, gconstpointer user_data)
g_assert (hb_buffer_get_direction (b) == HB_DIRECTION_INVALID);
g_assert (hb_buffer_get_script (b) == HB_SCRIPT_INVALID);
g_assert (hb_buffer_get_language (b) == NULL);
- g_assert (hb_buffer_get_flags (b) == HB_BUFFER_FLAGS_DEFAULT);
+
+ /* but not these: */
+
+ g_assert (hb_buffer_get_flags (b) != HB_BUFFER_FLAGS_DEFAULT);
+ g_assert (hb_buffer_get_replacement_codepoint (b) != HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT);
/* test reset clears all properties */
@@ -158,6 +163,9 @@ test_buffer_properties (fixture_t *fixture, gconstpointer user_data)
hb_buffer_set_flags (b, HB_BUFFER_FLAG_BOT);
g_assert (hb_buffer_get_flags (b) == HB_BUFFER_FLAG_BOT);
+ hb_buffer_set_replacement_codepoint (b, (unsigned int) -1);
+ g_assert (hb_buffer_get_replacement_codepoint (b) == (unsigned int) -1);
+
hb_buffer_reset (b);
g_assert (hb_buffer_get_unicode_funcs (b) == hb_unicode_funcs_get_default ());
@@ -165,6 +173,7 @@ test_buffer_properties (fixture_t *fixture, gconstpointer user_data)
g_assert (hb_buffer_get_script (b) == HB_SCRIPT_INVALID);
g_assert (hb_buffer_get_language (b) == NULL);
g_assert (hb_buffer_get_flags (b) == HB_BUFFER_FLAGS_DEFAULT);
+ g_assert (hb_buffer_get_replacement_codepoint (b) == HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT);
}
static void
commit 104484cefeca03d95837bba5f39178693c86ce8a
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon Aug 11 18:23:43 2014 -0400
Minor
diff --git a/src/hb-common.h b/src/hb-common.h
index f5141b9..b6ce3f7 100644
--- a/src/hb-common.h
+++ b/src/hb-common.h
@@ -123,12 +123,13 @@ hb_direction_from_string (const char *str, int len);
const char *
hb_direction_to_string (hb_direction_t direction);
+#define HB_DIRECTION_IS_VALID(dir) ((((unsigned int) (dir)) & ~3U) == 4)
+/* Direction must be valid for the following */
#define HB_DIRECTION_IS_HORIZONTAL(dir) ((((unsigned int) (dir)) & ~1U) == 4)
#define HB_DIRECTION_IS_VERTICAL(dir) ((((unsigned int) (dir)) & ~1U) == 6)
#define HB_DIRECTION_IS_FORWARD(dir) ((((unsigned int) (dir)) & ~2U) == 4)
#define HB_DIRECTION_IS_BACKWARD(dir) ((((unsigned int) (dir)) & ~2U) == 5)
-#define HB_DIRECTION_IS_VALID(dir) ((((unsigned int) (dir)) & ~3U) == 4)
-#define HB_DIRECTION_REVERSE(dir) ((hb_direction_t) (((unsigned int) (dir)) ^ 1)) /* Direction must be valid */
+#define HB_DIRECTION_REVERSE(dir) ((hb_direction_t) (((unsigned int) (dir)) ^ 1))
/* hb_language_t */
More information about the HarfBuzz
mailing list