diff options
Diffstat (limited to 'gfx/graphite2/src/inc')
-rw-r--r-- | gfx/graphite2/src/inc/Bidi.h | 126 | ||||
-rw-r--r-- | gfx/graphite2/src/inc/GlyphFaceCache.h | 103 | ||||
-rw-r--r-- | gfx/graphite2/src/inc/Shrinker.h | 119 |
3 files changed, 0 insertions, 348 deletions
diff --git a/gfx/graphite2/src/inc/Bidi.h b/gfx/graphite2/src/inc/Bidi.h deleted file mode 100644 index 9593c7e14..000000000 --- a/gfx/graphite2/src/inc/Bidi.h +++ /dev/null @@ -1,126 +0,0 @@ -/* GRAPHITE2 LICENSING - - Copyright 2013, 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, the contents of this file may be used under the terms of the -Mozilla Public License (http://mozilla.org/MPL) or the GNU General Public -License, as published by the Free Software Foundation, either version 2 -of the License or (at your option) any later version. -*/ -#pragma once - -namespace graphite2 -{ - -class BracketPair -{ -public: - BracketPair(uint16 g, Slot *s, uint8 b, BracketPair *p, BracketPair *l) : _open(s), _close(0), _parent(p), _next(0), _prev(l), _gid(g), _mask(0), _before(b) {}; - uint16 gid() const { return _gid; } - Slot *open() const { return _open; } - Slot *close() const { return _close; } - uint8 mask() const { return _mask; } - int8 before() const { return _before; } - BracketPair *parent() const { return _parent; } - void close(Slot *s) { _close = s; } - BracketPair *next() const { return _next; } - BracketPair *prev() const { return _prev; } - void next(BracketPair *n) { _next = n; } - void orin(uint8 m) { _mask |= m; } -private: - Slot * _open; // Slot of opening paren - Slot * _close; // Slot of closing paren - BracketPair * _parent; // pair this pair is in or NULL - BracketPair * _next; // next pair along the string - BracketPair * _prev; // pair that closed last before we opened - uint16 _gid; // gid of closing paren - uint8 _mask; // bitmap (2 bits) of directions within the pair - int8 _before; // most recent strong type (L, R, OPP, CPP) -}; - -class BracketPairStack -{ -public: - BracketPairStack(int s) : _stack(grzeroalloc<BracketPair>(s)), _ip(_stack - 1), _top(0), _last(0), _lastclose(0), _size(s) {} - ~BracketPairStack() { free(_stack); } - -public: - BracketPair *scan(uint16 gid); - void close(BracketPair *tos, Slot *s); - BracketPair *push(uint16 gid, Slot *pos, uint8 before, int prevopen); - void orin(uint8 mask); - void clear() { _ip = _stack - 1; _top = 0; _last = 0; _lastclose = 0; } - int size() const { return _size; } - BracketPair *start() const { return _stack; } - - CLASS_NEW_DELETE - -private: - - BracketPair *_stack; // start of storage - BracketPair *_ip; // where to add the next pair - BracketPair *_top; // current parent - BracketPair *_last; // end of next() chain - BracketPair *_lastclose; // last pair to close - int _size; // capacity -}; - -inline BracketPair *BracketPairStack::scan(uint16 gid) -{ - BracketPair *res = _top; - while (res >= _stack) - { - if (res->gid() == gid) - return res; - res = res->parent(); - } - return 0; -} - -inline void BracketPairStack::close(BracketPair *tos, Slot *s) -{ - for ( ; _last && _last != tos && !_last->close(); _last = _last->parent()) - { } - tos->close(s); - _last->next(NULL); - _lastclose = tos; - _top = tos->parent(); -} - -inline BracketPair *BracketPairStack::push(uint16 gid, Slot *pos, uint8 before, int prevopen) -{ - if (++_ip - _stack < _size && _stack) - { - ::new (_ip) BracketPair(gid, pos, before, _top, prevopen ? _last : _lastclose); - if (_last) _last->next(_ip); - _last = _ip; - } - _top = _ip; - return _ip; -} - -inline void BracketPairStack::orin(uint8 mask) -{ - BracketPair *t = _top; - for ( ; t; t = t->parent()) - t->orin(mask); -} - -} diff --git a/gfx/graphite2/src/inc/GlyphFaceCache.h b/gfx/graphite2/src/inc/GlyphFaceCache.h deleted file mode 100644 index 4afdfbe01..000000000 --- a/gfx/graphite2/src/inc/GlyphFaceCache.h +++ /dev/null @@ -1,103 +0,0 @@ -/* 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, the contents of this file may be used under the terms of the -Mozilla Public License (http://mozilla.org/MPL) or the GNU General Public -License, as published by the Free Software Foundation, either version 2 -of the License or (at your option) any later version. -*/ -#pragma once - -#include "inc/GlyphFace.h" -#include "graphite2/Font.h" - -namespace graphite2 { - -class Segment; -class Face; -class FeatureVal; - - -class GlyphFaceCacheHeader -{ -public: - bool initialize(const Face & face, const bool dumb_font); //return result indicates success. Do not use if failed. - unsigned short numGlyphs() const { return m_nGlyphs; } - unsigned short numAttrs() const { return m_numAttrs; } - -private: -friend class Face; -friend class GlyphFace; - const byte* m_pHead, - * m_pHHea, - * m_pHmtx, - * m_pGlat, - * m_pGloc, - * m_pGlyf, - * m_pLoca; - size_t m_lHmtx, - m_lGlat, - m_lGlyf, - m_lLoca; - - uint32 m_fGlat; - unsigned short m_numAttrs, // number of glyph attributes per glyph - m_nGlyphsWithGraphics, //i.e. boundary box and advance - m_nGlyphsWithAttributes, - m_nGlyphs; // number of glyphs in the font. Max of the above 2. - bool m_locFlagsUse32Bit; -}; - -class GlyphFaceCache : public GlyphFaceCacheHeader -{ -public: - static GlyphFaceCache* makeCache(const GlyphFaceCacheHeader& hdr /*, EGlyphCacheStrategy requested */); - - GlyphFaceCache(const GlyphFaceCacheHeader& hdr); - ~GlyphFaceCache(); - - const GlyphFace *glyphSafe(unsigned short glyphid) const { return glyphid<numGlyphs()?glyph(glyphid):NULL; } - uint16 glyphAttr(uint16 gid, uint8 gattr) const { if (gattr>=numAttrs()) return 0; const GlyphFace*p=glyphSafe(gid); return p?p->getAttr(gattr):0; } - - void * operator new (size_t s, const GlyphFaceCacheHeader& hdr) - { - return malloc(s + sizeof(GlyphFace*)*hdr.numGlyphs()); - } - // delete in case an exception is thrown in constructor - void operator delete(void* p, const GlyphFaceCacheHeader& ) throw() - { - free(p); - } - - const GlyphFace *glyph(unsigned short glyphid) const; //result may be changed by subsequent call with a different glyphid - void loadAllGlyphs(); - - CLASS_NEW_DELETE - -private: - GlyphFace **glyphPtrDirect(unsigned short glyphid) const { return (GlyphFace **)((const char*)(this)+sizeof(GlyphFaceCache)+sizeof(GlyphFace*)*glyphid);} - -private: //defensive - GlyphFaceCache(const GlyphFaceCache&); - GlyphFaceCache& operator=(const GlyphFaceCache&); -}; - -} // namespace graphite2 diff --git a/gfx/graphite2/src/inc/Shrinker.h b/gfx/graphite2/src/inc/Shrinker.h deleted file mode 100644 index e4db2f135..000000000 --- a/gfx/graphite2/src/inc/Shrinker.h +++ /dev/null @@ -1,119 +0,0 @@ -/* Copyright (c) 2012, Siyuan Fu <fusiyuan2010@gmail.com> - Copyright (c) 2015, SIL International - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -#pragma once - -#include <cassert> -#include <cstddef> -#include <cstring> - -#include <iterator> - -//the code from LZ4 -#if (GCC_VERSION >= 302) || (__INTEL_COMPILER >= 800) || defined(__clang__) -# define expect(expr,value) (__builtin_expect ((expr),(value)) ) -#else -# define expect(expr,value) (expr) -#endif -#define likely(expr) expect((expr) != 0, 1) -#define unlikely(expr) expect((expr) != 0, 0) -//////////////////// - - -namespace -{ - -#if defined(_MSC_VER) -typedef unsigned __int8 u8; -typedef unsigned __int16 u16; -typedef unsigned __int32 u32; -typedef unsigned __int64 u64; -#else -#include <stdint.h> -typedef uint8_t u8; -typedef uint16_t u16; -typedef uint32_t u32; -typedef uint64_t u64; -#endif - -ptrdiff_t const MINMATCH = 4; - -template<int S> -inline -void unaligned_copy(void * d, void const * s) { - ::memcpy(d, s, S); -} - -inline -u8 * memcpy_nooverlap(u8 * d, u8 const * s, size_t n) { - size_t const WS = sizeof(unsigned long); - u8 const * e = s + n; - do - { - unaligned_copy<WS>(d, s); - d += WS; - s += WS; - } - while (s < e); - d-=(s-e); - - return d; -} - - -inline -u8 * memcpy_nooverlap_surpass(u8 * d, u8 const * s, size_t n) { - size_t const WS = sizeof(unsigned long); - size_t wn = n/WS; - while (wn--) - { - unaligned_copy<WS>(d, s); - d += WS; - s += WS; - } - n &= WS-1; - while (n--) {*d++ = *s++; } - - return d; -} - - -inline -u8 * memcpy_(u8 * d, u8 const * s, size_t n) { - if (likely(d>s+sizeof(unsigned long))) - return memcpy_nooverlap(d,s,n); - else while (n--) *d++ = *s++; - return d; -} - -} // end of anonymous namespace - - |