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

📄 qblackraster.c

📁 qt-x11-opensource-src-4.1.4.tar.gz源码
💻 C
📖 第 1 页 / 共 5 页
字号:
    base[6].x = base[3].x;    c = base[1].x;    d = base[2].x;    base[1].x = a = ( base[0].x + c + 1 ) >> 1;    base[5].x = b = ( base[3].x + d + 1 ) >> 1;    c = ( c + d + 1 ) >> 1;    base[2].x = a = ( a + c + 1 ) >> 1;    base[4].x = b = ( b + c + 1 ) >> 1;    base[3].x = ( a + b + 1 ) >> 1;    base[6].y = base[3].y;    c = base[1].y;    d = base[2].y;    base[1].y = a = ( base[0].y + c + 1 ) >> 1;    base[5].y = b = ( base[3].y + d + 1 ) >> 1;    c = ( c + d + 1 ) >> 1;    base[2].y = a = ( a + c + 1 ) >> 1;    base[4].y = b = ( b + c + 1 ) >> 1;    base[3].y = ( a + b + 1 ) >> 1;}/*************************************************************************//*                                                                       *//* <Function>                                                            *//*    Line_Up                                                            *//*                                                                       *//* <Description>                                                         *//*    Computes the x-coordinates of an ascending line segment and stores *//*    them in the render pool.                                           *//*                                                                       *//* <Input>                                                               *//*    x1   :: The x-coordinate of the segment's start point.             *//*                                                                       *//*    y1   :: The y-coordinate of the segment's start point.             *//*                                                                       *//*    x2   :: The x-coordinate of the segment's end point.               *//*                                                                       *//*    y2   :: The y-coordinate of the segment's end point.               *//*                                                                       *//*    miny :: A lower vertical clipping bound value.                     *//*                                                                       *//*    maxy :: An upper vertical clipping bound value.                    *//*                                                                       *//* <Return>                                                              *//*    SUCCESS on success, FAILURE on render pool overflow.               *//*                                                                       */static BoolLine_Up( TRaster_Instance*  raster, Long  x1,         Long  y1,         Long  x2,         Long  y2,         Long  miny,         Long  maxy ){    Long   Dx, Dy;    Int    e1, e2, f1, size;     /* XXX: is `Short' sufficient? */    Long   Ix, Rx, Ax;    Int clipped;    PLong  top;    clipped = 0;    Dx = x2 - x1;    Dy = y2 - y1;    if ( Dy <= 0 || y2 < miny || y1 > maxy )        return SUCCESS;    if ( y1 < miny )    {        /* Take care: miny-y1 can be a very large value; we use     */        /*            a slow MulDiv function to avoid clipping bugs */        x1 += SMulDiv( Dx, miny - y1, Dy );        e1  = (Int)TRUNC( CEILING(miny) );        f1  = 0;        clipped = 1;    }    else    {        e1 = (Int)TRUNC( CEILING(y1) );        f1 = (Int)FRAC( y1 );    }    if ( y2 > maxy )    {        /* x2 += FMulDiv( Dx, maxy - y2, Dy );  UNNECESSARY */        e2  = (Int)TRUNC( FLOOR(maxy) );    }    else    {        e2 = (Int)TRUNC( FLOOR(y2) );        if (FRAC(y2) == 0 && ras.cProfile->flow == Flow_Up)            --e2;    }    QT_FT_TRACE6("Line_Up y1=%f, y2=%f, e1=%d, e2=%d f1=%d\n", y1/64.,  y2/64., e1, e2, f1);    if ( f1 > 0 )    {        x1 += FMulDiv( Dx, precision - f1, Dy );    } else if (ras.cProfile->flow == Flow_Down && !clipped ) {        e1++;        x1 += FMulDiv( Dx, precision, Dy);    }    if ( ras.fresh )    {        ras.cProfile->start = e1;        ras.fresh           = FALSE;    }    QT_FT_TRACE6("e1 = start=%d, e2=%d\n", e1, e2);    size = e2 - e1 + 1;    if ( ras.top + size >= ras.maxBuff )    {        ras.error = Raster_Err_Overflow;        return FAILURE;    }    if ( Dx > 0 )    {        Ix = (Long) ((precision * ((qint64)Dx)) / Dy);        Rx = (Long) ((precision * ((qint64)Dx)) % Dy);        Dx = 1;    }    else    {        Ix = (Long) -(precision * ((qint64)-Dx) / Dy);        Rx = (Long)  (precision * ((qint64)-Dx) % Dy);        Dx = -1;    }    Ax  = -Dy;    top = ras.top;    QT_FT_TRACE6("line_up (%f/%f)->(%f/%f), flow=%s\n",              x1/64., y1/64., x2/64., y2/64.,              ras.cProfile->flow == Flow_Up ? "Flow_Up" : "Flow_Down");    while ( size > 0 )    {        *top++ = x1;        QT_FT_TRACE6("    x=%f y=%d\n", x1/64., e2+1-size);        x1 += Ix;        Ax += Rx;        if ( Ax >= 0 )        {            Ax -= Dy;            x1 += Dx;        }        size--;    }    ras.top = top;    return SUCCESS;}/*************************************************************************//*                                                                       *//* <Function>                                                            *//*    Line_Down                                                          *//*                                                                       *//* <Description>                                                         *//*    Computes the x-coordinates of an descending line segment and       *//*    stores them in the render pool.                                    *//*                                                                       *//* <Input>                                                               *//*    x1   :: The x-coordinate of the segment's start point.             *//*                                                                       *//*    y1   :: The y-coordinate of the segment's start point.             *//*                                                                       *//*    x2   :: The x-coordinate of the segment's end point.               *//*                                                                       *//*    y2   :: The y-coordinate of the segment's end point.               *//*                                                                       *//*    miny :: A lower vertical clipping bound value.                     *//*                                                                       *//*    maxy :: An upper vertical clipping bound value.                    *//*                                                                       *//* <Return>                                                              *//*    SUCCESS on success, FAILURE on render pool overflow.               *//*                                                                       */static BoolLine_Down( TRaster_Instance*  raster, Long  x1,           Long  y1,           Long  x2,           Long  y2,           Long  miny,           Long  maxy ){    Bool  result, fresh;    fresh  = ras.fresh;    result = Line_Up( raster, x1, -y1, x2, -y2, -maxy, -miny );    if ( fresh && !ras.fresh )        ras.cProfile->start = -ras.cProfile->start;    return result;}/* A function type describing the functions used to split Bezier arcs */typedef void  (*TSplitter)( TPoint*  base );/*************************************************************************//*                                                                       *//* <Function>                                                            *//*    Bezier_Up                                                          *//*                                                                       *//* <Description>                                                         *//*    Computes the x-coordinates of an ascending Bezier arc and stores   *//*    them in the render pool.                                           *//*                                                                       *//* <Input>                                                               *//*    degree   :: The degree of the Bezier arc (either 2 or 3).          *//*                                                                       *//*    splitter :: The function to split Bezier arcs.                     *//*                                                                       *//*    miny     :: A lower vertical clipping bound value.                 *//*                                                                       *//*    maxy     :: An upper vertical clipping bound value.                *//*                                                                       *//* <Return>                                                              *//*    SUCCESS on success, FAILURE on render pool overflow.               *//*                                                                       */static BoolBezier_Up( TRaster_Instance*  raster, Int        degree,           TSplitter  splitter,           Long       miny,           Long       maxy ){    Long   y1, y2, e, e2;    TPoint*  arc;    TPoint*  start_arc;    PLong top;    arc = ras.arc;    y1  = arc[degree].y;    y2  = arc[0].y;    top = ras.top;    if ( y2 < miny || y1 > maxy )        goto Fin;    if ( y2 > maxy ) {        e2 = FLOOR(maxy);    } else {        e2 = FLOOR( y2 );        if (FRAC(y2) == 0  && ras.cProfile->flow == Flow_Up)            e2 -= precision;    }    if ( y1 < miny ) {        e = CEILING(miny);    } else {        e  = CEILING(y1);        if (FRAC(y1) == 0 && ras.cProfile->flow == Flow_Down)            e += precision;    }    if ( ras.fresh )    {        ras.cProfile->start = TRUNC( e );        ras.fresh = FALSE;    }    QT_FT_TRACE6("bezier_up: y1=%f, y2=%f, e1=%f, e2=%f\n", y1/64.,  y2/64., e/64., e2/64.);    if ( e2 < e )        goto Fin;    if ( ( top + TRUNC( e2 - e ) + 1 ) >= ras.maxBuff )    {        ras.top   = top;        ras.error = Raster_Err_Overflow;        return FAILURE;    }    QT_FT_TRACE6("       Flow = %s start=%ld, e=%f, e2=%f y1=%f, y2=%f\n",              ras.cProfile->flow == Flow_Up ? "Flow_Up" : "Flow_Down",              ras.cProfile->start, e/64., e2/64.,y1/64.,y2/64.);    start_arc = arc;    while ( arc >= start_arc && e <= e2 )    {        y2 = arc[0].y;        if ( y2 > e )        {            y1 = arc[degree].y;            if ( y2 - y1 >= precision_step )            {                splitter( arc );                arc += degree;            }            else            {                *top++ = arc[degree].x + FMulDiv( arc[0].x-arc[degree].x,                                                  e - y1, y2 - y1 );                QT_FT_TRACE6("  x=%f y=%f\n",                          (arc[degree].x + FMulDiv( arc[0].x-arc[degree].x,                                                    e - y1, y2 - y1 ))/64., e/64.);                arc -= degree;                e   += precision;            }        }        else        {            if ( y2 == e )            {                *top++     = arc[0].x;                QT_FT_TRACE6("  x=%f y=%f\n", arc[0].x/64., e/64.);                e += precision;            }            arc -= degree;        }    }Fin:    ras.top  = top;    ras.arc -= degree;    QT_FT_TRACE6("    currently %d points in profile, start=%ld top=%p\n", (int)(ras.top - ras.cProfile->offset), ras.cProfile->start, ras.top);    return SUCCESS;}/*************************************************************************//*                                                                       *//* <Function>                                                            *//*    Bezier_Down                                                        *//*                                                                       *//* <Description>                                                         *//*    Computes the x-coordinates of an descending Bezier arc and stores  *//*    them in the render pool.                                           *//*                                                                       *//* <Input>                                                               *//*    degree   :: The degree of the Bezier arc (either 2 or 3).          *//*                                                                       *//*    splitter :: The function to split Bezier arcs.                     *//*                                                                       *//*    miny     :: A lower vertical clipping bound value.                 *//*                                                                       *//*    maxy     :: An upper vertical clipping bound value.                *//*                                                                       *//* <Return>                                                              */

⌨️ 快捷键说明

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