From a85ea4fdf56c662970de14b3ece6cde82c137f5f Mon Sep 17 00:00:00 2001 From: Jonathan Kew Date: Wed, 20 Jan 2016 08:50:32 +0000 Subject: [PATCH] Bug 1240007 - Update graphite2 library to release 1.3.5. r=jdaggett --- gfx/graphite2/COPYING | 26 ++++++++++++++++++++++++++ gfx/graphite2/README.mozilla | 9 +++------ gfx/graphite2/include/graphite2/Font.h | 2 +- gfx/graphite2/src/SegCacheEntry.cpp | 7 +++---- gfx/graphite2/src/Segment.cpp | 16 +++++++++------- gfx/graphite2/src/inc/Segment.h | 4 ++-- 6 files changed, 44 insertions(+), 20 deletions(-) create mode 100644 gfx/graphite2/COPYING diff --git a/gfx/graphite2/COPYING b/gfx/graphite2/COPYING new file mode 100644 index 000000000000..d40f2d845879 --- /dev/null +++ b/gfx/graphite2/COPYING @@ -0,0 +1,26 @@ +/* GRAPHITE2 LICENSING + + Copyright 2010, SIL International + All rights reserved. + + This library is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should also have received a copy of the GNU Lesser General Public + License along with this library in the file named "LICENSE". + If not, write to the Free Software Foundation, 51 Franklin Street, + Suite 500, Boston, MA 02110-1335, USA or visit their web page on the + internet at http://www.fsf.org/licenses/lgpl.html. + + Alternatively, you may use this library under the terms of the Mozilla + Public License (http://mozilla.org/MPL) or under the GNU General Public + License, as published by the Free Sofware Foundation; either version + 2 of the license or (at your option) any later version. +*/ diff --git a/gfx/graphite2/README.mozilla b/gfx/graphite2/README.mozilla index 8edf83bcc6e9..9630ee7d5b00 100644 --- a/gfx/graphite2/README.mozilla +++ b/gfx/graphite2/README.mozilla @@ -1,6 +1,3 @@ -This directory contains the Graphite2 library release 1.3.4 from -https://github.com/silnrsi/graphite/releases/download/1.3.4/graphite2-minimal-1.3.4.tgz -See ./gfx/graphite2/moz-gr-update.sh for update procedure. - -Bug 1223002: Updated to upstream commit 6106dcbd5bc4df2e6ef6a7c632c69ca71ba2b518 -to fix recently-discovered fuzzbugs. +This directory contains the Graphite2 library release 1.3.5 from +https://github.com/silnrsi/graphite/releases/download/1.3.5/graphite2-minimal-1.3.5.tgz +See gfx/graphite2/moz-gr-update.sh for update procedure. diff --git a/gfx/graphite2/include/graphite2/Font.h b/gfx/graphite2/include/graphite2/Font.h index e5b9aec2a6c1..8c96ec3cc7b1 100644 --- a/gfx/graphite2/include/graphite2/Font.h +++ b/gfx/graphite2/include/graphite2/Font.h @@ -30,7 +30,7 @@ #define GR2_VERSION_MAJOR 1 #define GR2_VERSION_MINOR 3 -#define GR2_VERSION_BUGFIX 4 +#define GR2_VERSION_BUGFIX 5 #ifdef __cplusplus extern "C" diff --git a/gfx/graphite2/src/SegCacheEntry.cpp b/gfx/graphite2/src/SegCacheEntry.cpp index 9dc4c386b351..d35912d5aedb 100644 --- a/gfx/graphite2/src/SegCacheEntry.cpp +++ b/gfx/graphite2/src/SegCacheEntry.cpp @@ -61,8 +61,7 @@ SegCacheEntry::SegCacheEntry(const uint16* cmapGlyphs, size_t length, Segment * } const Slot * slot = seg->first(); m_glyph = new Slot[glyphCount]; - int attrSize = seg->numAttrs() + (seg->hasCollisionInfo() ? (sizeof(SlotCollision) + 1) / 2 : 0); - m_attr = gralloc(glyphCount * attrSize); + m_attr = gralloc(glyphCount * seg->numAttrs()); if (!m_glyph || (!m_attr && seg->numAttrs())) return; m_glyphLength = glyphCount; Slot * slotCopy = m_glyph; @@ -71,9 +70,9 @@ SegCacheEntry::SegCacheEntry(const uint16* cmapGlyphs, size_t length, Segment * uint16 pos = 0; while (slot) { - slotCopy->userAttrs(m_attr + pos * attrSize); + slotCopy->userAttrs(m_attr + pos * seg->numAttrs()); slotCopy->m_justs = m_justs ? reinterpret_cast(m_justs + justs_pos++ * sizeof_sjust) : 0; - slotCopy->set(*slot, -static_cast(charOffset), attrSize, seg->silf()->numJustLevels(), length); + slotCopy->set(*slot, -static_cast(charOffset), seg->numAttrs(), seg->silf()->numJustLevels(), length); slotCopy->index(pos); if (slot->firstChild()) slotCopy->m_child = m_glyph + slot->firstChild()->index(); diff --git a/gfx/graphite2/src/Segment.cpp b/gfx/graphite2/src/Segment.cpp index dd565acb6491..980f68c3cbc4 100644 --- a/gfx/graphite2/src/Segment.cpp +++ b/gfx/graphite2/src/Segment.cpp @@ -46,6 +46,7 @@ Segment::Segment(unsigned int numchars, const Face* face, uint32 script, int tex : m_freeSlots(NULL), m_freeJustifies(NULL), m_charinfo(new CharInfo[numchars]), + m_collisions(NULL), m_face(face), m_silf(face->chooseSilf(script)), m_first(NULL), @@ -71,6 +72,7 @@ Segment::~Segment() for (JustifyRope::iterator i = m_justifies.begin(); i != m_justifies.end(); ++i) free(*i); delete[] m_charinfo; + free(m_collisions); } #ifndef GRAPHITE2_NSEGCACHE @@ -175,8 +177,7 @@ Slot *Segment::newSlot() if (m_face->logger()) ++numUser; #endif Slot *newSlots = grzeroalloc(m_bufSize); - int attrSize = numUser + (hasCollisionInfo() ? ((sizeof(SlotCollision) + 1) / 2) : 0); - int16 *newAttrs = grzeroalloc(m_bufSize * attrSize); + int16 *newAttrs = grzeroalloc(m_bufSize * numUser); if (!newSlots || !newAttrs) { free(newSlots); @@ -185,7 +186,7 @@ Slot *Segment::newSlot() } for (size_t i = 0; i < m_bufSize; i++) { - ::new (newSlots + i) Slot(newAttrs + i * attrSize); + ::new (newSlots + i) Slot(newAttrs + i * numUser); newSlots[i].next(newSlots + i + 1); } newSlots[m_bufSize - 1].next(NULL); @@ -214,8 +215,7 @@ void Segment::freeSlot(Slot *aSlot) } // reset the slot incase it is reused ::new (aSlot) Slot(aSlot->userAttrs()); - int attrSize = m_silf->numUser() + (hasCollisionInfo() ? ((sizeof(SlotCollision) + 1) / 2) : 0); - memset(aSlot->userAttrs(), 0, attrSize * sizeof(int16)); + memset(aSlot->userAttrs(), 0, m_silf->numUser() * sizeof(int16)); // Update generation counter for debug #if !defined GRAPHITE2_NTRACING if (m_face->logger()) @@ -304,14 +304,13 @@ void Segment::splice(size_t offset, size_t length, Slot * const startSlot, assert(offset + numChars <= m_numCharinfo); Slot * indexmap[eMaxSpliceSize*3]; assert(numGlyphs < sizeof indexmap/sizeof *indexmap); - int attrSize = m_silf->numUser() + (hasCollisionInfo() ? ((sizeof(SlotCollision) + 1) / 2) : 0); Slot * slot = startSlot; for (uint16 i=0; i < numGlyphs; slot = slot->next(), ++i) indexmap[i] = slot; for (slot = startSlot; slot != endSlot; slot = slot->next(), srcSlot = srcSlot->next()) { - slot->set(*srcSlot, offset, attrSize, m_silf->numJustLevels(), numChars); + slot->set(*srcSlot, offset, m_silf->numUser(), m_silf->numJustLevels(), numChars); if (srcSlot->attachedTo()) slot->attachTo(indexmap[srcSlot->attachedTo()->index()]); if (srcSlot->nextSibling()) slot->m_sibling = indexmap[srcSlot->nextSibling()->index()]; if (srcSlot->firstChild()) slot->m_child = indexmap[srcSlot->firstChild()->index()]; @@ -523,6 +522,9 @@ void Segment::doMirror(uint16 aMirror) bool Segment::initCollisions() { + m_collisions = grzeroalloc(slotCount()); + if (!m_collisions) return false; + for (Slot *p = m_first; p; p = p->next()) ::new (collisionInfo(p)) SlotCollision(this, p); return true; diff --git a/gfx/graphite2/src/inc/Segment.h b/gfx/graphite2/src/inc/Segment.h index bbeecef8bf56..7d72f98eda4d 100644 --- a/gfx/graphite2/src/inc/Segment.h +++ b/gfx/graphite2/src/inc/Segment.h @@ -160,8 +160,7 @@ public: bool isWhitespace(const int cid) const; bool hasCollisionInfo() const { return (m_flags & SEG_HASCOLLISIONS); } - SlotCollision *collisionInfo(const Slot *s) const { return hasCollisionInfo() ? reinterpret_cast(s->userAttrs() + m_silf->numUser()) : 0; } - + SlotCollision *collisionInfo(const Slot *s) const { return m_collisions ? m_collisions + s->index() : 0; } CLASS_NEW_DELETE public: //only used by: GrSegment* makeAndInitialize(const GrFont *font, const GrFace *face, uint32 script, const FeaturesHandle& pFeats/*must not be IsNull*/, encform enc, const void* pStart, size_t nChars, int dir); @@ -179,6 +178,7 @@ private: Slot * m_freeSlots; // linked list of free slots SlotJustify * m_freeJustifies; // Slot justification blocks free list CharInfo * m_charinfo; // character info, one per input character + SlotCollision * m_collisions; const Face * m_face; // GrFace const Silf * m_silf; Slot * m_first; // first slot in segment