1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-02 16:48:55 +00:00

HarfBuzz: Update to version 6.0.0

This commit is contained in:
bruvzg
2022-12-17 00:19:09 +02:00
parent 2e657e51f8
commit d4fbe1ef06
152 changed files with 6779 additions and 4547 deletions

View File

@@ -35,7 +35,7 @@
template <typename Type,
bool sorted=false>
struct hb_vector_t : std::conditional<sorted, hb_vector_t<Type, false>, hb_empty_t>::type
struct hb_vector_t
{
typedef Type item_t;
static constexpr unsigned item_size = hb_static_size (Type);
@@ -53,9 +53,10 @@ struct hb_vector_t : std::conditional<sorted, hb_vector_t<Type, false>, hb_empty
hb_requires (hb_is_iterable (Iterable))>
hb_vector_t (const Iterable &o) : hb_vector_t ()
{
if (hb_iter (o).is_random_access_iterator)
alloc (hb_len (hb_iter (o)));
hb_copy (o, *this);
auto iter = hb_iter (o);
if (iter.is_random_access_iterator)
alloc (hb_len (iter));
hb_copy (iter, *this);
}
hb_vector_t (const hb_vector_t &o) : hb_vector_t ()
{
@@ -83,6 +84,9 @@ struct hb_vector_t : std::conditional<sorted, hb_vector_t<Type, false>, hb_empty
allocated = length = 0;
arrayZ = nullptr;
}
void init0 ()
{
}
void fini ()
{
@@ -94,7 +98,11 @@ struct hb_vector_t : std::conditional<sorted, hb_vector_t<Type, false>, hb_empty
void reset ()
{
if (unlikely (in_error ()))
allocated = length; // Big hack!
/* Big Hack! We don't know the true allocated size before
* an allocation failure happened. But we know it was at
* least as big as length. Restore it to that and continue
* as if error did not happen. */
allocated = length;
resize (0);
}
@@ -122,7 +130,7 @@ struct hb_vector_t : std::conditional<sorted, hb_vector_t<Type, false>, hb_empty
}
hb_bytes_t as_bytes () const
{ return hb_bytes_t ((const char *) arrayZ, length * item_size); }
{ return hb_bytes_t ((const char *) arrayZ, get_size ()); }
bool operator == (const hb_vector_t &o) const { return as_array () == o.as_array (); }
bool operator != (const hb_vector_t &o) const { return !(*this == o); }
@@ -164,14 +172,10 @@ struct hb_vector_t : std::conditional<sorted, hb_vector_t<Type, false>, hb_empty
operator iter_t () const { return iter (); }
operator writer_t () { return writer (); }
c_array_t sub_array (unsigned int start_offset, unsigned int count) const
{ return as_array ().sub_array (start_offset, count); }
c_array_t sub_array (unsigned int start_offset, unsigned int *count = nullptr /* IN/OUT */) const
{ return as_array ().sub_array (start_offset, count); }
array_t sub_array (unsigned int start_offset, unsigned int count)
{ return as_array ().sub_array (start_offset, count); }
array_t sub_array (unsigned int start_offset, unsigned int *count = nullptr /* IN/OUT */)
{ return as_array ().sub_array (start_offset, count); }
/* Faster range-based for loop. */
Type *begin () const { return arrayZ; }
Type *end () const { return arrayZ + length; }
hb_sorted_array_t<Type> as_sorted_array ()
{ return hb_sorted_array (arrayZ, length); }
@@ -240,12 +244,11 @@ struct hb_vector_t : std::conditional<sorted, hb_vector_t<Type, false>, hb_empty
if (likely (new_array))
{
for (unsigned i = 0; i < length; i++)
{
new (std::addressof (new_array[i])) Type ();
for (unsigned i = 0; i < (unsigned) length; i++)
new_array[i] = std::move (arrayZ[i]);
unsigned old_length = length;
shrink_vector (0);
length = old_length;
arrayZ[i].~Type ();
}
hb_free (arrayZ);
}
return new_array;
@@ -277,7 +280,14 @@ struct hb_vector_t : std::conditional<sorted, hb_vector_t<Type, false>, hb_empty
copy_vector (const hb_vector_t &other)
{
length = other.length;
hb_memcpy ((void *) arrayZ, (const void *) other.arrayZ, length * item_size);
#ifndef HB_OPTIMIZE_SIZE
if (sizeof (T) >= sizeof (long long))
/* This runs faster because of alignment. */
for (unsigned i = 0; i < length; i++)
arrayZ[i] = other.arrayZ[i];
else
#endif
hb_memcpy ((void *) arrayZ, (const void *) other.arrayZ, length * item_size);
}
template <typename T = Type,
hb_enable_if (!hb_is_trivially_copyable (T) &&
@@ -309,15 +319,6 @@ struct hb_vector_t : std::conditional<sorted, hb_vector_t<Type, false>, hb_empty
}
}
template <typename T = Type,
hb_enable_if (hb_is_trivially_destructible(T))>
void
shrink_vector (unsigned size)
{
length = size;
}
template <typename T = Type,
hb_enable_if (!hb_is_trivially_destructible(T))>
void
shrink_vector (unsigned size)
{
@@ -328,17 +329,6 @@ struct hb_vector_t : std::conditional<sorted, hb_vector_t<Type, false>, hb_empty
}
}
template <typename T = Type,
hb_enable_if (hb_is_trivially_copy_assignable(T))>
void
shift_down_vector (unsigned i)
{
memmove (static_cast<void *> (&arrayZ[i - 1]),
static_cast<void *> (&arrayZ[i]),
(length - i) * sizeof (Type));
}
template <typename T = Type,
hb_enable_if (!hb_is_trivially_copy_assignable(T))>
void
shift_down_vector (unsigned i)
{
@@ -381,16 +371,22 @@ struct hb_vector_t : std::conditional<sorted, hb_vector_t<Type, false>, hb_empty
return true;
}
bool resize (int size_)
bool resize (int size_, bool initialize = true)
{
unsigned int size = size_ < 0 ? 0u : (unsigned int) size_;
if (!alloc (size))
return false;
if (size > length)
grow_vector (size);
{
if (initialize)
grow_vector (size);
}
else if (size < length)
shrink_vector (size);
{
if (initialize)
shrink_vector (size);
}
length = size;
return true;
@@ -399,13 +395,13 @@ struct hb_vector_t : std::conditional<sorted, hb_vector_t<Type, false>, hb_empty
Type pop ()
{
if (!length) return Null (Type);
Type v = arrayZ[length - 1];
Type v {std::move (arrayZ[length - 1])};
arrayZ[length - 1].~Type ();
length--;
return v;
}
void remove (unsigned int i)
void remove_ordered (unsigned int i)
{
if (unlikely (i >= length))
return;
@@ -414,6 +410,18 @@ struct hb_vector_t : std::conditional<sorted, hb_vector_t<Type, false>, hb_empty
length--;
}
template <bool Sorted = sorted,
hb_enable_if (!Sorted)>
void remove_unordered (unsigned int i)
{
if (unlikely (i >= length))
return;
if (i != length - 1)
arrayZ[i] = std::move (arrayZ[length - 1]);
arrayZ[length - 1].~Type ();
length--;
}
void shrink (int size_)
{
unsigned int size = size_ < 0 ? 0u : (unsigned int) size_;
@@ -425,10 +433,8 @@ struct hb_vector_t : std::conditional<sorted, hb_vector_t<Type, false>, hb_empty
/* Sorting API. */
void qsort (int (*cmp)(const void*, const void*))
void qsort (int (*cmp)(const void*, const void*) = Type::cmp)
{ as_array ().qsort (cmp); }
void qsort (unsigned int start = 0, unsigned int end = (unsigned int) -1)
{ as_array ().qsort (start, end); }
/* Unsorted search API. */
template <typename T>