亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? gcache.c

?? ttfdump源代碼
?? C
字號(hào):
/* * gcache.c -- Provide the cache mechanicsm for outlines * Copyright (C) 1996 Li-Da Lho, All right reserved * * This file is a little bit more complicated, the structure of the cache is  * described as fellow: * Basically the cache can be divided onto two parts, the first one is a  * linear part which is a least recently utilitied list (LRU),  * the second part is the nonlinear one which is a binary serach tree.  * Normally each cache element is one the LRU as well as on the BST. * Those glyph elements are allocated at once as an array of glyph cache  * elements at the init phase of glyph cache. * * font->gcache-- *              | *      ________| *     | *     v  * ------------------------------------------------------------------ * |element 0|   1   |   2   |  3   |   4   |   5   |   6   |   7   | ... * ------------------------------------------------------------------  * The first element of the glyph cache array serves as a dummy header * for two purposes, one is for the head and tail of the LRU, the other is * to point to the root of the BST. As a pointer to the root of the * BST, the right subtree points to the root of the BST while the left one is  * not used and arbitrarly points to itself. * * After initialization, all the glyph cache element are on the LRU but * none of them is on the BST. *                                      *  |-----------------------------------------------------------| *  |   -------------         ------                  ------    | *  |-> |head & tail| <-----> |    |<-----> ...<----->|    | <--| *      -------------         ------                  ------  *         /  \                /  \                    /  \ *        /    \              /    \                  /    \ * left=self right=root    left  right             left  right * * The cached data are pointed by the entries of the glyph cache element * in a strait forward fashion. * *  |-----------------------------------------------------------| *  |   -------------         ------                  ------    | *  |-> |head & tail| <-----> |    |<-----> ...<----->|    | <--| *      -------------         ------                  ------  *       |  |     -------------|--|--------------------------------  *       |  |---->|            |  |->  array for flag, instruction| *       |        -------------|-----------------------------------  *       |        -------------|----------------------------------- *       |------->|            |---->  xcoordinates,  ycoordinates| *                ------------------------------------------------- * Implementation in this way is effecient for the reason that when we * need to free the cache, we only need to do the two things * 1. free the data pointed by the entries in the dummy header * 2. free the dummy header * * Every time a glyph outline is required and ttfLoadGlyphCached is called,  * the glyph is searched on the BST with its offset as a key. * If the glyph is on the BST then the address of the glyph cache is returned * and the glyph cache is moved to the tail of the LRU such that the order of  * LRU is mantained. * When the glyph required is not on the BST, something more complicated should * be done. *  1. Remove the first element on the LRU from the BST. *  2. Load the glyph data to the cache element. *  3. Insert the element back to the BST. *  4. Move the element to the tail of the LRU. * * The only problem remain is how to deal with composite components.  * The asnwer simply is not to support cache for composite components at the  * current stage for the two reasons: *  1. It will makes the code an order of magnitude more complicate to support *     composite glyf cache. *  2. The space occupied by composite glyf is not very much * * It is not clear right now if it is wise to add tree balancing code.  * The overhaed introduced by BST seems minimal for 256 elements cache. */#include <stdio.h>#include <stdlib.h>#include <string.h>#include "config.h"#include "ttf.h"#include "ttfutil.h"#ifdef MEMCHECK#include <dmalloc.h>#endif/* 	$Id: gcache.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $	 */#ifndef lintstatic char vcid[] = "$Id: gcache.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";#endif /* lint */static GlyphCachePtr ttfAllocCache(TTFontPtr font);static void ttfInitCache(TTFontPtr font);static void ttfFreeCache(TTFontPtr font);static void ttfRotateCache(TTFontPtr font);static void ttfAllocCacheData(TTFontPtr font);static void ttfInitCacheData(TTFontPtr font);static void ttfFreeCacheData(TTFontPtr font);static void ttfInsertBST(TTFontPtr font,GlyphCachePtr gcache);static GlyphCachePtr ttfSearchBST(TTFontPtr font,ULONG offset);static void ttfDeleteBST(TTFontPtr font,ULONG offset);static void merge(GlyphCachePtr *root);static void copy(GlyphCachePtr *root);void ttfInitGlyphCache(TTFontPtr font){    /* this should be made configurable */    if (font->maxp->numGlyphs > 256)	font->numCacheElements = 128;    else	font->numCacheElements = 64;    font->gcache = ttfAllocCache(font);    ttfInitCache(font);    ttfAllocCacheData(font);    ttfInitCacheData(font);}void ttfCleanUpGlyphCache(TTFontPtr font){    ttfFreeCacheData(font);    ttfFreeCache(font);    }/* provide cache mechanism for glyph */GLYFPtr ttfLoadGlyphCached(TTFontPtr font,ULONG offset){#ifdef OLDCODE    GLYFPtr glyf;        glyf = &(font->gcache->next->glyf);    font->gcache->next->offset = offset;    ttfRotateCache(font);    ttfLoadGLYF(font->fp,glyf,offset);       return glyf;#else    GlyphCachePtr gcache;    if ((gcache = ttfSearchBST(font,offset)) == NULL)	{	    /* if the glyph is not in the cache */	    ttfDeleteBST(font,font->gcache->next->offset);	    gcache = font->gcache->next;	    font->gcache->next->offset = offset;	    ttfRotateCache(font);	    ttfLoadGLYF(font->fp,&gcache->glyf,offset);	    ttfInsertBST(font,gcache);	}    return &gcache->glyf;#endif}/* alloc GlyphCache headers */static GlyphCachePtr ttfAllocCache(TTFontPtr font){    USHORT numCache = font->numCacheElements+1;    GlyphCachePtr gcache;    if ((gcache = (GlyphCachePtr) calloc(numCache,sizeof(GlyphCache))) == NULL)	{	    ttfError("Out of Memory");	    return NULL;	}    return gcache;}/* threading glyph cache headers */static void ttfInitCache(TTFontPtr font){    USHORT i,numCache = font->numCacheElements;    GlyphCachePtr cur,tmp;    cur = tmp = font->gcache;        tmp++;    /* there are numGlyph+1 of cache header, the first one is for     * mark as the head and tail of the queue */    for (i=0;i<numCache;i++)	{	    cur->right = cur->left = NULL;	    cur->next = tmp;	    tmp->prev = cur;	    cur = tmp;	    tmp++;	}    /* make the LRU circular */    cur->next = font->gcache;    font->gcache->prev = cur;    /* make the dummy header point to it self on the BST */    font->gcache->left = font->gcache;    font->gcache->offset = 0;}static void ttfFreeCache(TTFontPtr font){    free(font->gcache);}/* move the first element on the LRU the the tail */static void ttfRotateCache(TTFontPtr font){    GlyphCachePtr gcache = font->gcache, tmp = font->gcache->next;    /* remove the first element */    gcache->next = tmp->next;    tmp->next->prev = gcache;    /* add the element to the tail */    tmp->next = gcache;    tmp->prev = gcache->prev;    gcache->prev->next = tmp;    gcache->prev = tmp;}static void ttfAllocCacheData(TTFontPtr font){    USHORT numCache = font->numCacheElements+1;    USHORT maxPoints = font->maxp->maxPoints;    USHORT maxContours = font->maxp->maxContours;    USHORT insLength = font->maxp->maxSizeOfInstructions;          font->gcache->glyf.endPtsOfContours = (USHORT *) calloc(numCache*maxContours,							    sizeof(USHORT));    font->gcache->glyf.instructions = (BYTE *) calloc(numCache*insLength,						      sizeof(BYTE));    font->gcache->glyf.flags = (BYTE *) calloc(numCache*maxPoints,					       sizeof(BYTE));    font->gcache->glyf.xCoordinates = (SHORT *) calloc(numCache*maxPoints,						       sizeof(SHORT));    font->gcache->glyf.yCoordinates = (SHORT *) calloc(numCache*maxPoints,						       sizeof(SHORT));    font->gcache->glyf.comp = NULL;}static void ttfInitCacheData(TTFontPtr font){    USHORT i;    USHORT numCache = font->numCacheElements;    USHORT maxPoints = font->maxp->maxPoints;    USHORT maxContours = font->maxp->maxContours;    USHORT insLength = font->maxp->maxSizeOfInstructions;    GlyphCachePtr cur,tmp;       tmp = font->gcache;    cur = font->gcache->next;    for (i=0;i<numCache;i++)	{	    /* makes the pointer in the cache element point to correct	     * addresses in the data area */	    cur->glyf.endPtsOfContours = tmp->glyf.endPtsOfContours + maxContours;	    cur->glyf.instructions = tmp->glyf.instructions + insLength;	    cur->glyf.flags = tmp->glyf.flags + maxPoints;	    cur->glyf.xCoordinates = tmp->glyf.xCoordinates + maxPoints;	    cur->glyf.yCoordinates = tmp->glyf.yCoordinates + maxPoints;	    tmp = cur;	    cur = cur++;	}}static void ttfFreeCacheData(TTFontPtr font){    USHORT i,numCache = font->numCacheElements;    GlyphCachePtr cur = font->gcache+1;    /* free components of composite glyfs */    for (i=0;i<numCache;i++)	{	    ttfFreeGLYF(&cur->glyf);	    cur++;	}    free(font->gcache->glyf.endPtsOfContours);    free(font->gcache->glyf.instructions);    free(font->gcache->glyf.flags);    free(font->gcache->glyf.xCoordinates);    free(font->gcache->glyf.yCoordinates);}/* code to deal with nonlinear part of glyph cache */static void ttfInsertBST(TTFontPtr font,GlyphCachePtr gcache){    GlyphCachePtr root,parent;        parent = font->gcache;    root = parent->right;    while (root) 	{	    parent = root;	    if (root->offset > gcache->offset)		root = root->left;	    else		root = root->right;	}    if (parent->offset > gcache->offset)	parent->left = gcache;    else	parent->right = gcache;}static GlyphCachePtr ttfSearchBST(TTFontPtr font,ULONG offset){    GlyphCachePtr root = font->gcache->right;    while (root)	{	    if (root->offset == offset)		return root;	    if (root->offset > offset)		root = root->left;	    else		root = root->right;	}    return NULL;    }/* Deleting a node form a BST is a little bit tricky. * Basically, there are three different situations for deleteing a node *   1. The node to delete is a leaf, then just delete the node and make the *      node's parent point to null. *   2. The node has one subtree, the let the node's parent adopt it. *   3. The node has both subtrees, in this situation, there are two  *      alternatives *     a. let the parent adopt one of the subtree and the subtree adopt the  *        other. (delete by merge) *     b. replace the node with its precedeer, and leave the topology almost *        unchanged. */static void ttfDeleteBST(TTFontPtr font,ULONG offset){    GlyphCachePtr root,parent;    parent = font->gcache;    root = parent->right;    /* find the node to delete */    while (root) 	{	    if (root->offset == offset)		break;	    parent = root;	    if (root->offset > offset)		root = root->left;	    else		root = root->right;	}    if (root != NULL)	{	    /* the node to be deleted is on the tree */	    if (root->glyf.numberOfContours < 0)		/* a composite glyf with components */		ttfFreeGLYF(&root->glyf);#ifdef MERGEDELETE	    if (parent == font->gcache)		/* delete root */		merge(&parent->right);	    else if (parent->left == root)		merge(&parent->left);	    else 		merge(&parent->right);#else	    if (parent == font->gcache)		/* delete root */		copy(&parent->right);	    else if (parent->left == root)		copy(&parent->left);	    else 		copy(&parent->right);#endif	    root->left = root->right = NULL;	}    else	; /* the tree is empty or the node is not on the tree */    }static void merge(GlyphCachePtr *root){    GlyphCachePtr tmp;        if ((*root)->right == NULL)	*root = (*root)->left;    else if ((*root)->left == NULL)	*root = (*root)->right;    else	{	    /* the node to be attached has both left and right	     * subtrees */	    tmp = (*root)->left;	    while (tmp->right)		{		    tmp = tmp->right;		}	    tmp->right = (*root)->right;	    *root = (*root)->left;	}}static void copy(GlyphCachePtr *root){    GlyphCachePtr tmp, parent;        if ((*root)->right == NULL)	*root = (*root)->left;    else if ((*root)->left == NULL)	*root = (*root)->right;    else	{	    tmp = (*root)->left;	    parent = *root;	    while (tmp->right)		{		    parent = tmp;		    tmp = tmp->right;		}	    tmp->right = (*root)->right;	    if (parent != *root)		{		    parent->right = tmp->left;		    tmp->left = parent;		}	    *root = tmp;	}}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美丰满少妇xxxbbb| 从欧美一区二区三区| 欧美区在线观看| 午夜国产精品影院在线观看| 欧美日韩第一区日日骚| 日本少妇一区二区| 久久夜色精品国产欧美乱极品| 狠狠色丁香婷婷综合久久片| 亚洲精品一线二线三线| 成人中文字幕在线| 一区二区三区在线观看网站| 欧美男女性生活在线直播观看| 美女精品一区二区| 亚洲国产精品二十页| 色婷婷久久久亚洲一区二区三区| 日韩电影免费一区| 欧美激情在线一区二区| 欧美制服丝袜第一页| 日韩福利电影在线| 国产精品视频一区二区三区不卡| 91福利精品视频| 美女免费视频一区| 亚洲人成网站在线| 欧美一级国产精品| 91视频在线观看免费| 天天影视色香欲综合网老头| 欧美国产综合一区二区| 欧美午夜精品电影| 国产成人综合亚洲网站| 亚洲国产综合人成综合网站| 2欧美一区二区三区在线观看视频| 91日韩精品一区| 免费高清不卡av| 亚洲欧美激情一区二区| 欧美精品一区二区三| 在线看国产一区| 国产福利一区二区| 免费看欧美女人艹b| 亚洲精品一卡二卡| 国产欧美日韩激情| 91精品国产色综合久久| 99久久精品国产精品久久| 久久se精品一区二区| 亚洲综合免费观看高清完整版在线 | 国产精品色呦呦| 欧美精品色一区二区三区| 99视频有精品| 国产综合成人久久大片91| 天天色天天操综合| 亚洲天堂2016| 欧美国产日韩亚洲一区| 日韩一区二区三区av| 欧美三级日韩在线| 91视视频在线观看入口直接观看www | 久久久国产综合精品女国产盗摄| 欧美日韩一区二区在线观看视频| 99国产精品国产精品毛片| 国产精品一卡二| 国产原创一区二区三区| 青青草视频一区| 污片在线观看一区二区| 亚洲一级二级三级| 夜夜嗨av一区二区三区四季av| 中文字幕视频一区二区三区久| 中文字幕免费不卡在线| 久久久不卡网国产精品二区| wwww国产精品欧美| 精品国产乱码久久久久久老虎 | 精品久久久久久亚洲综合网| 欧美电影在线免费观看| 欧美日韩你懂得| 欧美日韩一区视频| 欧美男男青年gay1069videost| 欧美日精品一区视频| 在线观看视频91| 欧美性大战久久久久久久蜜臀 | 欧美日韩国产综合视频在线观看| 在线日韩一区二区| 欧美日韩一区二区三区免费看| 在线观看欧美日本| 欧美精品丝袜中出| 欧美一区二区成人| 精品三级在线观看| 精品国产免费一区二区三区四区 | 在线观看区一区二| 欧美色综合网站| 欧美一区二区三区人| 欧美一区二区三区小说| 精品国产亚洲一区二区三区在线观看| 日韩久久久久久| 国产三级精品三级在线专区| 欧美国产视频在线| 亚洲另类色综合网站| 亚洲国产精品一区二区久久恐怖片| 亚洲一区二区三区自拍| 全国精品久久少妇| 国产91丝袜在线播放| www.色综合.com| 欧美酷刑日本凌虐凌虐| 精品国产一区二区三区四区四| 国产丝袜美腿一区二区三区| 亚洲婷婷在线视频| 日本成人在线看| 国产成人综合网| 日本久久精品电影| 精品少妇一区二区三区日产乱码 | 丰满白嫩尤物一区二区| 色嗨嗨av一区二区三区| 欧美一区二区三区色| 中文字幕免费一区| 日韩精品电影一区亚洲| 国产一区二区三区精品视频| 91视频在线观看| 精品国产91九色蝌蚪| 亚洲激情五月婷婷| 狠狠久久亚洲欧美| 欧美专区在线观看一区| 精品嫩草影院久久| 亚洲女同ⅹxx女同tv| 精品一区二区三区视频 | 国产精品一区二区在线看| 色综合久久综合| 日韩精品综合一本久道在线视频| 国产亚洲精品中文字幕| 亚洲成人www| 成人午夜免费视频| 91精品国产欧美一区二区| |精品福利一区二区三区| 美女视频黄频大全不卡视频在线播放| 99re6这里只有精品视频在线观看 99re8在线精品视频免费播放 | 久久久综合网站| 亚洲国产精品精华液网站| 国产乱人伦偷精品视频不卡| 欧美吻胸吃奶大尺度电影| 中文字幕乱码亚洲精品一区| 美国av一区二区| 欧美日韩精品一区二区三区 | 亚洲综合成人网| 国产不卡在线视频| 欧美成人乱码一区二区三区| 亚洲色图.com| 国产精品中文字幕一区二区三区| 欧美另类久久久品| 亚洲午夜国产一区99re久久| 91在线观看美女| 国产女人水真多18毛片18精品视频 | 91麻豆免费视频| 久久久久免费观看| 久久草av在线| 欧美成人女星排名| 日韩不卡免费视频| 欧美精选午夜久久久乱码6080| 亚洲欧美激情一区二区| av在线不卡免费看| 国产亚洲欧美在线| 国产激情一区二区三区桃花岛亚洲| 911精品国产一区二区在线| 亚洲影视在线观看| 欧美亚洲日本国产| 一级精品视频在线观看宜春院| av综合在线播放| 综合久久国产九一剧情麻豆| 99在线精品观看| 亚洲欧洲中文日韩久久av乱码| www.亚洲人| 中文字幕在线不卡国产视频| 丁香另类激情小说| 中文字幕一区三区| 色系网站成人免费| 亚洲国产一区二区a毛片| 欧美日韩亚洲不卡| 欧美a级理论片| 日韩欧美国产一区在线观看| 久久99精品国产麻豆不卡| 久久在线免费观看| 国产乱码精品一品二品| 中文在线资源观看网站视频免费不卡| 国产91丝袜在线18| 亚洲欧美国产高清| 欧美年轻男男videosbes| 美女视频黄免费的久久| 久久综合色天天久久综合图片| 国产大片一区二区| 中文字幕一区二区在线播放| 在线日韩av片| 七七婷婷婷婷精品国产| 久久久久久毛片| 91视频观看免费| 日韩国产欧美在线视频| 26uuu精品一区二区在线观看| 国产成人精品亚洲777人妖| 综合网在线视频| 欧美日韩国产高清一区二区| 全部av―极品视觉盛宴亚洲| 久久久久久久免费视频了| 色悠悠亚洲一区二区| 蜜桃精品视频在线观看| 国产精品嫩草久久久久| 欧美日韩黄色影视| 懂色av中文一区二区三区|