⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 polyreg.c

📁 linux下的一款播放器
💻 C
📖 第 1 页 / 共 2 页
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: polyreg.c,v 1.2.12.1 2004/07/09 01:59:28 hubbe Exp $ *  * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved. *  * The contents of this file, and the files included with this file, * are subject to the current version of the RealNetworks Public * Source License (the "RPSL") available at * http://www.helixcommunity.org/content/rpsl unless you have licensed * the file under the current version of the RealNetworks Community * Source License (the "RCSL") available at * http://www.helixcommunity.org/content/rcsl, in which case the RCSL * will apply. You may also obtain the license terms directly from * RealNetworks.  You may not use this file except in compliance with * the RPSL or, if you have a valid RCSL with RealNetworks applicable * to this file, the RCSL.  Please see the applicable RPSL or RCSL for * the rights, obligations and limitations governing use of the * contents of the file. *  * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL") in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your version of * this file only under the terms of the GPL, and not to allow others * to use your version of this file under the terms of either the RPSL * or RCSL, indicate your decision by deleting the provisions above * and replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient may * use your version of this file under the terms of any one of the * RPSL, the RCSL or the GPL. *  * This file is part of the Helix DNA Technology. RealNetworks is the * developer and/or licensor of the Original Code and owns the * copyrights in the portions it created. *  * This file, and the files included with this file, is distributed * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET * ENJOYMENT OR NON-INFRINGEMENT. *  * Technology Compatibility Kit Test Suite(s) Location: *    http://www.helixcommunity.org/content/tck *  * Contributor(s): *  * ***** END LICENSE BLOCK ***** *//************************************************************************Copyright (c) 1987  X ConsortiumPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THEX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER INAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR INCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.Except as contained in this notice, the name of the X Consortium shall not beused in advertising or otherwise to promote the sale, use or other dealingsin this Software without prior written authorization from the X Consortium.Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.                        All Rights ReservedPermission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and thatboth that copyright notice and this permission notice appear in supporting documentation, and that the name of Digital not beused in advertising or publicity pertaining to distribution of thesoftware without specific, written prior permission.  DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDINGALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALLDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ORANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THISSOFTWARE.************************************************************************/#define LARGE_COORDINATE 1000000#define SMALL_COORDINATE -LARGE_COORDINATE#include "poly.h"#include "hlxclib/stdlib.h"#include "hlxclib/memory.h"/* *     InsertEdgeInET * *     Insert the given edge into the edge table. *     First we must find the correct bucket in the *     Edge table, then find the right slot in the *     bucket.  Finally, we can insert it. * */static void InsertEdgeInET( EdgeTable *ET,                            EdgeTableEntry *ETE,                            int scanline,                            ScanLineListBlock **SLLBlock,                            int *iSLLBlock                            ){    register EdgeTableEntry *start, *prev;    register ScanLineList *pSLL, *pPrevSLL;    ScanLineListBlock *tmpSLLBlock;    /*     * find the right bucket to put the edge into     */    pPrevSLL = &ET->scanlines;    pSLL = pPrevSLL->next;    while (pSLL && (pSLL->scanline < scanline))     {        pPrevSLL = pSLL;        pSLL = pSLL->next;    }    /*     * reassign pSLL (pointer to ScanLineList) if necessary     */    if ((!pSLL) || (pSLL->scanline > scanline))     {        if (*iSLLBlock > SLLSPERBLOCK-1)         {            tmpSLLBlock =                   (ScanLineListBlock *)malloc(sizeof(ScanLineListBlock));            (*SLLBlock)->next = tmpSLLBlock;            tmpSLLBlock->next = (ScanLineListBlock *)NULL;            *SLLBlock = tmpSLLBlock;            *iSLLBlock = 0;        }        pSLL = &((*SLLBlock)->SLLs[(*iSLLBlock)++]);        pSLL->next = pPrevSLL->next;        pSLL->edgelist = (EdgeTableEntry *)NULL;        pPrevSLL->next = pSLL;    }    pSLL->scanline = scanline;    /*     * now insert the edge in the right bucket     */    prev = (EdgeTableEntry *)NULL;    start = pSLL->edgelist;    while (start && (start->bres.minor_axis < ETE->bres.minor_axis))     {        prev = start;        start = start->next;    }    ETE->next = start;    if (prev)        prev->next = ETE;    else        pSLL->edgelist = ETE;}/* *     CreateEdgeTable * *     This routine creates the edge table for *     scan converting polygons.  *     The Edge Table (ET) looks like: * *    EdgeTable *     -------- *    |  ymax  |        ScanLineLists *    |scanline|-->------------>-------------->... *     --------   |scanline|   |scanline| *                |edgelist|   |edgelist| *                ---------    --------- *                    |             | *                    |             | *                    V             V *              list of ETEs   list of ETEs * *     where ETE is an EdgeTableEntry data structure, *     and there is one ScanLineList per scanline at *     which an edge is initially entered. * */static void CreateETandAET( register int count,                            register HXxPoint *pts,                            EdgeTable *ET,                            EdgeTableEntry *AET,                            register EdgeTableEntry *pETEs,                            ScanLineListBlock   *pSLLBlock                            ){    HXxPoint *top;    HXxPoint *bottom;    HXxPoint *PrevPt;    HXxPoint *CurrPt;    int iSLLBlock = 0;    int dy;    if (count < 2)  return;    /*     *  initialize the Active Edge Table     */    AET->next = (EdgeTableEntry *)NULL;    AET->back = (EdgeTableEntry *)NULL;    AET->nextWETE = (EdgeTableEntry *)NULL;    AET->bres.minor_axis = SMALL_COORDINATE;    /*     *  initialize the Edge Table.     */    ET->scanlines.next = (ScanLineList *)NULL;    ET->ymax = SMALL_COORDINATE;    ET->ymin = LARGE_COORDINATE;    pSLLBlock->next = (ScanLineListBlock *)NULL;    PrevPt = &pts[count-1];    /*     *  for each vertex in the array of points.     *  In this loop we are dealing with two vertices at     *  a time -- these make up one edge of the polygon.     */    while (count--)     {        CurrPt = pts++;        /*         *  find out which point is above and which is below.         */        if (PrevPt->y > CurrPt->y)         {            bottom = PrevPt, top = CurrPt;            pETEs->ClockWise = 0;        }        else         {            bottom = CurrPt, top = PrevPt;            pETEs->ClockWise = 1;        }        /*         * don't add horizontal edges to the Edge table.         */        if (bottom->y != top->y)         {            pETEs->ymax = bottom->y-1;  /* -1 so we don't get last scanline */            /*             *  initialize integer edge algorithm             */            dy = bottom->y - top->y;            BRESINITPGONSTRUCT(dy, top->x, bottom->x, pETEs->bres);            InsertEdgeInET(ET, pETEs, top->y, &pSLLBlock, &iSLLBlock);            if (PrevPt->y > ET->ymax)                ET->ymax = PrevPt->y;            if (PrevPt->y < ET->ymin)                ET->ymin = PrevPt->y;            pETEs++;        }        PrevPt = CurrPt;    }}/* *     loadAET * *     This routine moves EdgeTableEntries from the *     EdgeTable into the Active Edge Table, *     leaving them sorted by smaller x coordinate. * */static void loadAET( register EdgeTableEntry* AET,                     register EdgeTableEntry* ETEs                     ){    register EdgeTableEntry *pPrevAET;    register EdgeTableEntry *tmp;    pPrevAET = AET;    AET = AET->next;    while (ETEs)     {        while (AET && (AET->bres.minor_axis < ETEs->bres.minor_axis))         {            pPrevAET = AET;            AET = AET->next;        }        tmp = ETEs->next;        ETEs->next = AET;        if (AET)            AET->back = ETEs;        ETEs->back = pPrevAET;        pPrevAET->next = ETEs;        pPrevAET = ETEs;        ETEs = tmp;    }}/* *     computeWAET * *     This routine links the AET by the *     nextWETE (winding EdgeTableEntry) link for *     use by the winding number rule.  The final  *     Active Edge Table (AET) might look something *     like: * *     AET *     ----------  ---------   --------- *     |ymax    |  |ymax    |  |ymax    |  *     | ...    |  |...     |  |...     | *     |next    |->|next    |->|next    |->... *     |nextWETE|  |nextWETE|  |nextWETE| *     ---------   ---------   ^-------- *         |                   |       | *         V------------------->       V---> ... * */static void computeWAET( register EdgeTableEntry *AET){

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -