Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: third_party/harfbuzz-ng/src/hb-buffer.cc

Issue 1867053004: Roll HarfBuzz to 1.2.6 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Roll to 1.2.6 instead Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright © 1998-2004 David Turner and Werner Lemberg 2 * Copyright © 1998-2004 David Turner and Werner Lemberg
3 * Copyright © 2004,2007,2009,2010 Red Hat, Inc. 3 * Copyright © 2004,2007,2009,2010 Red Hat, Inc.
4 * Copyright © 2011,2012 Google, Inc. 4 * Copyright © 2011,2012 Google, Inc.
5 * 5 *
6 * This is part of HarfBuzz, a text shaping library. 6 * This is part of HarfBuzz, a text shaping library.
7 * 7 *
8 * Permission is hereby granted, without written agreement and without 8 * Permission is hereby granted, without written agreement and without
9 * license or royalty fees, to use, copy, modify, and distribute this 9 * license or royalty fees, to use, copy, modify, and distribute this
10 * software and its documentation for any purpose, provided that the 10 * software and its documentation for any purpose, provided that the
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 in_error = false; 235 in_error = false;
236 have_output = false; 236 have_output = false;
237 have_positions = false; 237 have_positions = false;
238 238
239 idx = 0; 239 idx = 0;
240 len = 0; 240 len = 0;
241 out_len = 0; 241 out_len = 0;
242 out_info = info; 242 out_info = info;
243 243
244 serial = 0; 244 serial = 0;
245 memset (allocated_var_bytes, 0, sizeof allocated_var_bytes);
246 memset (allocated_var_owner, 0, sizeof allocated_var_owner);
247 245
248 memset (context, 0, sizeof context); 246 memset (context, 0, sizeof context);
249 memset (context_len, 0, sizeof context_len); 247 memset (context_len, 0, sizeof context_len);
248
249 deallocate_var_all ();
250 } 250 }
251 251
252 void 252 void
253 hb_buffer_t::add (hb_codepoint_t codepoint, 253 hb_buffer_t::add (hb_codepoint_t codepoint,
254 unsigned int cluster) 254 unsigned int cluster)
255 { 255 {
256 hb_glyph_info_t *glyph; 256 hb_glyph_info_t *glyph;
257 257
258 if (unlikely (!ensure (len + 1))) return; 258 if (unlikely (!ensure (len + 1))) return;
259 259
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 } 654 }
655 655
656 /* If language is not set, use default language from locale */ 656 /* If language is not set, use default language from locale */
657 if (props.language == HB_LANGUAGE_INVALID) { 657 if (props.language == HB_LANGUAGE_INVALID) {
658 /* TODO get_default_for_script? using $LANGUAGE */ 658 /* TODO get_default_for_script? using $LANGUAGE */
659 props.language = hb_language_get_default (); 659 props.language = hb_language_get_default ();
660 } 660 }
661 } 661 }
662 662
663 663
664 static inline void
665 dump_var_allocation (const hb_buffer_t *buffer)
666 {
667 char buf[80];
668 for (unsigned int i = 0; i < 8; i++)
669 buf[i] = '0' + buffer->allocated_var_bytes[7 - i];
670 buf[8] = '\0';
671 DEBUG_MSG (BUFFER, buffer,
672 "Current var allocation: %s",
673 buf);
674 }
675
676 void hb_buffer_t::allocate_var (unsigned int byte_i, unsigned int count, const c har *owner)
677 {
678 assert (byte_i < 8 && byte_i + count <= 8);
679
680 if (DEBUG_ENABLED (BUFFER))
681 dump_var_allocation (this);
682 DEBUG_MSG (BUFFER, this,
683 "Allocating var bytes %d..%d for %s",
684 byte_i, byte_i + count - 1, owner);
685
686 for (unsigned int i = byte_i; i < byte_i + count; i++) {
687 assert (!allocated_var_bytes[i]);
688 allocated_var_bytes[i]++;
689 allocated_var_owner[i] = owner;
690 }
691 }
692
693 void hb_buffer_t::deallocate_var (unsigned int byte_i, unsigned int count, const char *owner)
694 {
695 if (DEBUG_ENABLED (BUFFER))
696 dump_var_allocation (this);
697
698 DEBUG_MSG (BUFFER, this,
699 "Deallocating var bytes %d..%d for %s",
700 byte_i, byte_i + count - 1, owner);
701
702 assert (byte_i < 8 && byte_i + count <= 8);
703 for (unsigned int i = byte_i; i < byte_i + count; i++) {
704 assert (allocated_var_bytes[i]);
705 assert (0 == strcmp (allocated_var_owner[i], owner));
706 allocated_var_bytes[i]--;
707 }
708 }
709
710 void hb_buffer_t::assert_var (unsigned int byte_i, unsigned int count, const cha r *owner)
711 {
712 if (DEBUG_ENABLED (BUFFER))
713 dump_var_allocation (this);
714
715 DEBUG_MSG (BUFFER, this,
716 "Asserting var bytes %d..%d for %s",
717 byte_i, byte_i + count - 1, owner);
718
719 assert (byte_i < 8 && byte_i + count <= 8);
720 for (unsigned int i = byte_i; i < byte_i + count; i++) {
721 assert (allocated_var_bytes[i]);
722 assert (0 == strcmp (allocated_var_owner[i], owner));
723 }
724 }
725
726 void hb_buffer_t::deallocate_var_all (void)
727 {
728 memset (allocated_var_bytes, 0, sizeof (allocated_var_bytes));
729 memset (allocated_var_owner, 0, sizeof (allocated_var_owner));
730 }
731
732 /* Public API */ 664 /* Public API */
733 665
734 /** 666 /**
735 * hb_buffer_create: (Xconstructor) 667 * hb_buffer_create: (Xconstructor)
736 * 668 *
737 * Creates a new #hb_buffer_t with all properties to defaults. 669 * Creates a new #hb_buffer_t with all properties to defaults.
738 * 670 *
739 * Return value: (transfer full): 671 * Return value: (transfer full):
740 * A newly allocated #hb_buffer_t with a reference count of 1. The initial 672 * A newly allocated #hb_buffer_t with a reference count of 1. The initial
741 * reference count should be released with hb_buffer_destroy() when you are done 673 * reference count should be released with hb_buffer_destroy() when you are done
(...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1869 } 1801 }
1870 } 1802 }
1871 1803
1872 bool 1804 bool
1873 hb_buffer_t::message_impl (hb_font_t *font, const char *fmt, va_list ap) 1805 hb_buffer_t::message_impl (hb_font_t *font, const char *fmt, va_list ap)
1874 { 1806 {
1875 char buf[100]; 1807 char buf[100];
1876 vsnprintf (buf, sizeof (buf), fmt, ap); 1808 vsnprintf (buf, sizeof (buf), fmt, ap);
1877 return (bool) this->message_func (this, font, buf, this->message_data); 1809 return (bool) this->message_func (this, font, buf, this->message_data);
1878 } 1810 }
OLDNEW
« no previous file with comments | « third_party/harfbuzz-ng/README.chromium ('k') | third_party/harfbuzz-ng/src/hb-buffer-private.hh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698