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

📄 render_shape.c.svn-base

📁 A Flash Player with ActionScript support. Write in C and C++. It have two part, one is Player and an
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
        if (shapeAction == ShapeDraw) {            prepareStyles(gd2, matrix, cxform, curFillStyle, curNbFillStyles);        }    }    l = 0;    f0 = 0;    f1 = 0;    firstPoint = 1;    lastX = 0;    lastY = 0;    sp->curPath.nb_edges = 0;    sp->first_line = NULL;    sp->last_line = NULL;    sr=shape->ShapeRecordsP;//->NextP;    for(;sr;sr=sr->NextP) {        if(sr->Flags==TCurvedEdge) {            // Handle Bezier Curves !!!            stc=(struct CurvedEdgeRecord *)sr;            if (firstPoint) {                newPath(sp, 0, 0);                firstPoint = 0;            }            {                long newX,newY,ctrlX,ctrlY;                ctrlX = lastX+stc->ControlDeltaX;                ctrlY = lastY+stc->ControlDeltaY;                newX = ctrlX+stc->AnchorDeltaX;                newY = ctrlY+stc->AnchorDeltaY;#if 1                addBezier(sp, ctrlX, ctrlY, newX, newY, f0 , f1, l);#else                addLine(sp, newX, newY, f0, f1, l);#endif                lastX = newX;                lastY = newY;            }            continue;        }        if(sr->Flags==TStraightEdge) {            sts=(struct StraightEdgeRecord *)sr;            if (firstPoint) {                newPath(sp, 0, 0);                firstPoint = 0;            }            if(sts->StraightLineFlag) {                // printf("deltax is %ld ,deltay is %ld\n",sts->StraightLineDeltaX,sts->StraightLineDeltaY);                lastX += sts->StraightLineDeltaX;                lastY += sts->StraightLineDeltaY;            } else {                if(sts->VertLineFlag) {                    lastX +=0;                    lastY += sts->VertLineDeltaY;                } else {                    lastX +=sts->HorLineDeltaX;                    lastY +=0;                }            }            addLine(sp, lastX, lastY, f0, f1, l);#if PRINT            //printf(" X, Y  = %4d,%4d\n", lastX/20, lastY/20);#endif            continue;        }        if (sr->Flags&0x10) {            st=(struct StyleChangeRecord *)sr;            sl =  (StyleList*)malloc(sizeof(StyleList));            sl->next = sp->style_list;            curNbFillStyles=st->FillStylesP->count;            if (curNbFillStyles > 0) {                curFillStyle=(FillStyleDef *)malloc(curNbFillStyles*sizeof(FillStyleDef));                if (curFillStyle == NULL)                    return;                for(loop=0;loop<curNbFillStyles;loop++)                    curFillStyle[loop]=st->FillStylesP->FillStyles[loop];            }            if (curNbFillStyles == 0)                curFillStyle=0;            curNbLineStyles=st->LineStylesP->count;            if (curNbLineStyles > 0) {                curLineStyle=(LineStyleDef *)malloc(curNbLineStyles*sizeof(LineStyleDef));                if (curLineStyle == NULL)                    return;                for(loop=0;loop<curNbLineStyles;loop++) {                    curLineStyle[loop]=st->LineStylesP->LineStyles[loop];                    curLineStyle[loop].RendColor=curLineStyle[loop].ColorRGB;                    if (cxform)                        curLineStyle[loop].RendColor = getColor(cxform,curLineStyle[loop].RendColor);                    curLineStyle[loop].RendColor.pixel=allocColor16(gd2,curLineStyle[loop].RendColor);                }            };            if (curNbLineStyles == 0)                curLineStyle=0;            sl->newFillStyles = curFillStyle;            sl->nbNewFillStyles = curNbFillStyles;            sl->newLineStyles = curLineStyle;            sl->nbNewLineStyles = curNbLineStyles;            sp->style_list = sl;            if (shapeAction == ShapeDraw) {                prepareStyles(gd2, matrix, cxform, curFillStyle, curNbFillStyles);            }        }        if (sr->Flags&0x02) {            {                st=(struct StyleChangeRecord *)sr;                if (st->FillStyle0) {                    if (curFillStyle) {                        f0 = &curFillStyle[st->FillStyle0-1];                    } else {//printf("to defaultfillstyle0\n");                        f0 = &shapedef->defaultFillStyle;                    }                } else {                    f0 = 0;                }            }        }        if (sr->Flags&0x04) { //printf("to fillstyle1\n");            {st=(struct StyleChangeRecord *)sr;                if (st->FillStyle1) {                    if (curFillStyle) {//printf("fillstyle1 is %ld\n",st->FillStyle1);                        f1 = &curFillStyle[st->FillStyle1-1];                    } else {                        f1 = &shapedef->defaultFillStyle;                    }                } else {                    f1 = 0;                }            }        }        if (sr->Flags&0x08) {            {                st=(struct StyleChangeRecord *)sr;                if (st->LineStyle) {                    l = &curLineStyle[st->LineStyle-1];                } else {                    l = 0;                }            }        }        if (sr->Flags&0x01) {            {                st=(struct StyleChangeRecord *)sr;                if (sp->curPath.nb_edges == 0) {                    flushPaths(sp);                }                newPath(sp, st->MoveDeltaX, st->MoveDeltaY);                firstPoint = 0;                lastX = st->MoveDeltaX;                lastY = st->MoveDeltaY;#if PRINT                //printf("---------\nX,Y    = %4d,%4d\n", sr->x/20, sr->y/20);#endif            }        }    }    /* XXX: should test if there is something to draw */    flushPaths(sp);    //printf("drawshape over\n");    /* free the styles */    while (sp->style_list) {        StyleList *sl;        sl=sp->style_list;        sp->style_list = sl->next;        if (shapeAction == ShapeDraw) {            clearStyles(gd2, sl->newFillStyles, sl->nbNewFillStyles);        }        if(sl->newFillStyles)            free(sl->newFillStyles);        if(sl->newLineStyles)            free(sl->newLineStyles);        free(sl);    }}voidprepareStyles(GraphicDevice *gd2, Matrix *matrix, Cxform *cxform,              FillStyleDef *ftab, long n) {    long fs;    FillStyleDef *f;    static Matrix cc;    static int bb;    if (n == 0) {        printf("kongsin \n");    };    for(fs = 0; fs < n; fs++) {        f = ftab + fs;        //printf(" to prepre styles\n");        switch (f->FillStyleType) {        case f_None:            printf("to kongsin \n");            break;        case f_Solid:            printf("to solid \n");            if (cxform) {                f->Color = getColor(cxform,f->Color);            }            f->Color.pixel = allocColor16(gd2,f->Color);            break;        case f_LinearGradient:        case f_RadialGradient: {                Matrix mat;                int  n,r,l;                long red, green, blue, alpha;                long dRed, dGreen, dBlue, dAlpha;                long min,max;                Matrix *m;                mat = MatrixMulti((matrix),&(f->GradientMatrix));                f->GradientP->imat = invert(&mat);                m=&f->GradientP->imat;                if (f->FillStyleType == f_LinearGradient) {                    m->ScaleX = m->ScaleX * FRAC * (1/128.0) * 65536.0;                    m->RotateSkew0 = m->RotateSkew0 * FRAC * (1/128.0) * 65536.0;                    m->TranslateX = (long) ((m->TranslateX + 16384) * (1/128.0) * 65536.0);                } else {                    m->ScaleX = m->ScaleX * FRAC * (1/64.0) * 65536.0;                    m->RotateSkew0 = m->RotateSkew0 * FRAC * (1/64.0) * 65536.0;                    m->RotateSkew1 = m->RotateSkew1 * FRAC * (1/64.0) * 65536.0;                    m->ScaleY = m->ScaleY * FRAC * (1/64.0) * 65536.0;                    m->TranslateX = (long) (m->TranslateX * (1/64.0) * 65536.0);                    m->TranslateY = (long) (m->TranslateY * (1/64.0) * 65536.0);                }                // Reset translation in inverted matrix                f->GradientP->g_has_alpha = 0;                // Build a 256 color ramp                f->GradientP->g_ramp = (Color *)malloc(256*sizeof(Color));                if (f->GradientP->g_ramp == NULL) {                    // Invalidate fill style                    f->FillStyleType = f_None;                    continue;                }                // Store min and max                min = f->GradientP->GradientRecords[0].Ratio;                max = f->GradientP->GradientRecords[f->GradientP->NumGradients-1].Ratio;                for(r=0; r < f->GradientP->NumGradients-1; r++) {                    Color start,end;                    l = f->GradientP->GradientRecords[r+1].Ratio-f->GradientP->GradientRecords[r].Ratio;                    if (l == 0)                        continue;                    if (cxform) {                        printf("lg    cxform is true\n");                        start = getColor(cxform,f->GradientP->GradientRecords[r].Color);                        end   = getColor(cxform,f->GradientP->GradientRecords[r+1].Color);                    } else {                        printf("lg    cxform is  not true\n");                        start = f->GradientP->GradientRecords[r].Color;                        end   = f->GradientP->GradientRecords[r+1].Color;                    }                    //printf("startalpha is %d\n",start.Alpha);                    if (start.Alpha != ALPHA_OPAQUE ||                            end.Alpha != ALPHA_OPAQUE) {                        f->GradientP->g_has_alpha = 1;                    }                    dRed   = end.Red - start.Red;                    dGreen = end.Green - start.Green;                    dBlue  = end.Blue - start.Blue;                    dAlpha = end.Alpha - start.Alpha;                    dRed   = (dRed<<16)/l;                    dGreen = (dGreen<<16)/l;                    dBlue  = (dBlue<<16)/l;                    dAlpha  = (dAlpha<<16)/l;                    red   = start.Red <<16;                    green = start.Green <<16;                    blue  = start.Blue <<16;                    alpha  = start.Alpha <<16;                    for (n=f->GradientP->GradientRecords[r].Ratio; n<=f->GradientP->GradientRecords[r+1].Ratio; n++) {                        f->GradientP->g_ramp[n].Red = red>>16;                        f->GradientP->g_ramp[n].Green = green>>16;                        f->GradientP->g_ramp[n].Blue = blue>>16;                        f->GradientP->g_ramp[n].Alpha = alpha>>16;                        f->GradientP->g_ramp[n].pixel = allocColor16(gd2,f->GradientP->g_ramp[n]);                        red += dRed;                        green += dGreen;                        blue += dBlue;                        alpha += dAlpha;                    }                }                for(n=0; n<min; n++) {                    f->GradientP->g_ramp[n] = f->GradientP->g_ramp[min];                }                for(n=max; n<256; n++) {                    f->GradientP->g_ramp[n] = f->GradientP->g_ramp[max];                }            }            break;        case f_TiledBitmap:        case f_clippedBitmap: {                int coun;                Matrix *m;                if(f->BitmapId==65535) {                    continue;                }                if (f->BitmapId) {                    struct DefineBitsJPEG  *tbitmap;                    if(player_p->_level0_p->dict_p->dict[f->BitmapId]->CharacterType==CharBitsJPEG) {                        tbitmap=(struct DefineBitsJPEG *)(player_p->_level0_p->dict_p->dict[f->BitmapId]);                    }                    if(player_p->_level0_p->dict_p->dict[f->BitmapId]->CharacterType==CharBitsOne) {                        tbitmap=(struct DefineBitsJPEG *)(player_p->_level0_p->dict_p->dict[f->BitmapId]);                    }                    if(player_p->_level0_p->dict_p->dict[f->BitmapId]->CharacterType==CharBitsLosslessOne) {                        tbitmap=(struct DefineBitsJPEG *)(player_p->_level0_p->dict_p->dict[f->BitmapId]);                    }                    tbitmap=(struct DefineBitsJPEG *)(player_p->_level0_p->dict_p->dict[f->BitmapId]);                    f->cmap = getColormap(gd2,tbitmap->ColormapP, tbitmap->Colors, cxform);                    if (f->cmap == NULL) {                        f->cmap = tbitmap->ColormapP;                    }                    f->BitmapMatrix = MatrixMulti((matrix),&(f->BitmapMatrix));                    f->BitmapMatrix = invert(&(f->BitmapMatrix));                    m=&f->BitmapMatrix;                    m->ScaleX = m->ScaleX* FRAC * 65536.0;                    m->RotateSkew0 = m->RotateSkew0 * FRAC * 65536.0;                    m->RotateSkew1 = m->RotateSkew1 * FRAC * 65536.0;                    m->ScaleY= m->ScaleY * FRAC * 65536.0;                    m->TranslateX = (long) (m->TranslateX * 65536.0);                    m->TranslateY = (long) (m->TranslateY * 65536.0);                    f->alpha_table = NULL;                    if (tbitmap->Alpha_bufP && cxform) {                        unsigned char *alpha_table;                        int i;                        alpha_table = (unsigned char *)malloc (256);                        if (alpha_table != NULL) {                            for(i=0;i<256;i++) {                                alpha_table[i] = getAlpha(cxform,i);                            }                        }                        f->alpha_table = alpha_table;                    }                }            }            break;        }    }}voidclearStyles(GraphicDevice *gd2, FillStyleDef *ftab, long n) {    long fs;    FillStyleDef *f;    for(fs = 0; fs < n; fs++) {        f = ftab + fs;        switch (f->FillStyleType) {        case f_Solid:            break;        case f_LinearGradient:        case f_RadialGradient: {                if(f->GradientP->g_ramp)                    free(f->GradientP->g_ramp);            }            break;        case f_TiledBitmap:        case f_clippedBitmap: {                struct DefineBitsJPEG  *tbitmap;                if(f->BitmapId==65535)                    continue;                tbitmap=(struct DefineBitsJPEG *)(player_p->_level0_p->dict_p->dict[f->BitmapId]);                if(f->cmap&&(f->cmap!=tbitmap->ColormapP)) {                    free(f->cmap);                }                if (f->alpha_table)                    free(f->alpha_table);            }            break;        case f_None:            break;        }    }}

⌨️ 快捷键说明

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