📄 render_rend.c.svn-base
字号:
point2=&line2[start]; if (!grad->g_has_alpha) {#ifdef FULL_AA if (start == end) { dist2 = ((X>>16)*(X>>16))+((Y>>16)*(Y>>16)); if ((unsigned long)dist2 >= 65536) { r = 255; } else { r = SQRT[dist2]; } if((((unsigned long)(point2)-(unsigned long)(currentmaskpointer))>0)&&(((unsigned long)(point2)-(unsigned long)(currentmaskpointer))<canvassize)) *point2=1; // *point1 = mix_alpha(*point, (TYPE)ramp[r].pixel, start_alpha + end_alpha - 255); // *point1=*point; } else { if (start_alpha < 255) { dist2 = ((X>>16)*(X>>16))+((Y>>16)*(Y>>16)); if ((unsigned long)dist2 >= 65536) { r = 255; } else { r = SQRT[dist2]; } if((((unsigned long)(point2)-(unsigned long)(currentmaskpointer))>0)&&(((unsigned long)(point2)-(unsigned long)(currentmaskpointer))<canvassize)) *point2=1; // *point1 = mix_alpha(*point, (TYPE)ramp[r].pixel, start_alpha); //*point1=*point; //point++; point2++; X += dx; Y += dy; n--; }#endif /* FULL_AA */ while (n>0) { dist2 = ((X>>16)*(X>>16))+((Y>>16)*(Y>>16)); if ((unsigned long)dist2 >= 65536) { r = 255; } else { r= SQRT[dist2]; } if((((unsigned long)(point2)-(unsigned long)(currentmaskpointer))>0)&&(((unsigned long)(point2)-(unsigned long)(currentmaskpointer))<canvassize)) *point2=1; //*point1 = (TYPE)ramp[r].pixel; //*point1=*point; //point++; point2++; X += dx; Y += dy; n--; }#ifdef FULL_AA if (end_alpha > 0) { dist2 = ((X>>16)*(X>>16))+((Y>>16)*(Y>>16)); if ((unsigned long)dist2 >= 65536) { r = 255; } else { r= SQRT[dist2]; } if((((unsigned long)(point2)-(unsigned long)(currentmaskpointer))>0)&&(((unsigned long)(point2)-(unsigned long)(currentmaskpointer))<canvassize)) *point2=1; // *point1 = mix_alpha(*point, (TYPE)ramp[r].pixel, end_alpha); //*point1=*point; } }#endif /* FULL_AA */ } else { while (n--) { dist2 = ((X>>16)*(X>>16))+((Y>>16)*(Y>>16)); if ((unsigned long)dist2 >= 65536) { r = 255; } else { r= SQRT[dist2]; } cp = &ramp[r]; if((((unsigned long)(point2)-(unsigned long)(currentmaskpointer))>0)&&(((unsigned long)(point2)-(unsigned long)(currentmaskpointer))<canvassize)) *point2=1; // *point1 = mix_alpha(*point, cp->pixel, cp->Alpha); //*point1=*point; //point++; point2++; X += dx; Y += dy; } } } }}void RenderPrepare(GraphicDevice *gd1,FlashDisplay *fd) { gd1->flashDisplay = fd; gd1->bgInitialized = 0; // Reset flash refresh flag fd->flash_refresh = 0; /* 16 bits, RGB565 */ gd1->redMask = 0xF800; gd1->greenMask = 0x07E0; gd1->blueMask = 0x001F; /* should be the actual window size */ gd1->targetWidth = fd->width; gd1->targetHeight = fd->height; gd1->bpl = fd->bpl; canvassize=(fd->height*fd->bpl)/2;#if PRINT //printf("Target Width = %d\n", targetWidth); //printf("Target Height = %d\n", targetHeight);#endif gd1->zoom = FRAC; gd1->movieWidth = gd1->targetWidth; gd1->movieHeight = gd1->targetHeight; gd1->viewPort.Xmin = 0; gd1->viewPort.Xmax = gd1->targetWidth-1; gd1->viewPort.Ymin = 0; gd1->viewPort.Ymax = gd1->targetHeight-1; gd1->canvasBuffer = (unsigned char *) (fd->pixels); gd1->adjust = (Matrix *)malloc(sizeof(Matrix)); MatrixPrepare(gd1->adjust); gd1->foregroundColor.Red = 0; gd1->foregroundColor.Green = 0; gd1->foregroundColor.Blue = 0; gd1->foregroundColor.Alpha = ALPHA_OPAQUE; gd1->backgroundColor.Red = 255; gd1->backgroundColor.Green = 255; gd1->backgroundColor.Blue = 255; gd1->backgroundColor.Alpha = ALPHA_OPAQUE; gd1->showMore = 0; setClipping(gd1,0); // Reset setClipping(gd1,1); /* polygon rasterizer : handle memory errors ! */ gd1->thisheight = gd1->targetHeight; // gd1->thissegs = (Segment **)malloc(gd1->thisheight * sizeof(Segment *)); gd1->thissegs1 = (Segment **)malloc(16000 * sizeof(Segment *)); gd1->thissegs=&(gd1->thissegs1[8000]); // memset(gd1->thissegs, 0, gd1->thisheight * sizeof(Segment *)); memset(gd1->thissegs1, 0, 16000 * sizeof(Segment *)); gd1->thisymin = 8000;//gd1->thisheight; gd1->thisymax = -8000; gd1->scan_line_func=NULL; gd1->seg_pool = (Segment *)malloc(NB_SEGMENT_MAX * sizeof(Segment)); gd1->seg_pool_cur = gd1->seg_pool; //other /*gd1->cmap=NULL; gd1->alpha_table=NULL; gd1->gradientrend=NULL; gd1->bitmaprend=NULL;*/ BackgroundColorCopy.Red=1; BackgroundColorCopy.Green=1; BackgroundColorCopy.Blue=1;}Color *getColormap(GraphicDevice *gd1,Color *old, long n, Cxform *cxform) { long i=0; Color *newCmp; newCmp =(Color *)malloc(n*sizeof(Color)); if (newCmp == NULL) return NULL; if (cxform) { for( i = 0; i < n; i++) { newCmp[i] = getColor(cxform,old[i]); newCmp[i].pixel = allocColor16(gd1,newCmp[i]); } } else { //printf("cxform is null\n"); for( i = 0; i < n; i++) { newCmp[i] = old[i]; newCmp[i].pixel = allocColor16(gd1,old[i]); } } return newCmp;}longgetHeight(GraphicDevice *gd1) { return gd1->targetHeight;}longgetWidth(GraphicDevice *gd1) { return gd1->targetWidth;}ColorgetForegroundColor(GraphicDevice *gd1) { return gd1->foregroundColor;}voidsetForegroundColor(GraphicDevice *gd1,Color color) { gd1->foregroundColor = color;}ColorgetBackgroundColor(GraphicDevice *gd1) { gd1->backgroundColor.Red=BackgroundColor.Red; gd1->backgroundColor.Green=BackgroundColor.Green; gd1->backgroundColor.Blue=BackgroundColor.Blue; return gd1->backgroundColor;}intsetBackgroundColor( struct GraphicDevice *gd1,struct RGBA color) { if (gd1->bgInitialized == 0) { gd1->backgroundColor = color; clearCanvas16(gd1,1); gd1->bgInitialized = 1; return 1; } return 0;}voidsetMovieDimension(GraphicDevice *gd1,long width, long height) { float xAdjust, yAdjust; gd1->movieWidth = width; gd1->movieHeight = height; MatrixPrepare(gd1->adjust); xAdjust = (float)(gd1->targetWidth)*(gd1->zoom)/(float)width; yAdjust = (float)(gd1->targetHeight)*(gd1->zoom)/(float)height; //printf("xadjust is %f yadjust is %f \n",xAdjust ,yAdjust); if (xAdjust < yAdjust) { gd1->adjust->ScaleX = xAdjust; gd1->adjust->ScaleY = xAdjust; gd1->adjust->TranslateY = ((gd1->targetHeight*gd1->zoom) - (long)(height * xAdjust))/2; gd1->viewPort.Ymin = gd1->adjust->TranslateY/gd1->zoom; gd1->viewPort.Ymax = gd1->targetHeight-gd1->viewPort.Ymin-1; } else { gd1->adjust->ScaleX = yAdjust; gd1->adjust->ScaleY = yAdjust; gd1->adjust->TranslateX = ((gd1->targetWidth*gd1->zoom) - (long)(width * yAdjust))/2; gd1->viewPort.Xmin = gd1->adjust->TranslateX/gd1->zoom; gd1->viewPort.Xmax = gd1->targetWidth-gd1->viewPort.Xmin-1; } if (gd1->viewPort.Xmin < 0) gd1->viewPort.Xmin = 0; if (gd1->viewPort.Ymin < 0) gd1->viewPort.Ymin = 0; if (gd1->viewPort.Xmax >= gd1->targetWidth) gd1->viewPort.Xmax = gd1->targetWidth-1; if (gd1->viewPort.Ymax >= gd1->targetHeight) gd1->viewPort.Ymax = gd1->targetHeight-1; //printf("scalexset is %f,scaley is %f,rotateskew0 is %f,rotateskew1 is %f,translatex is %ld,translatey is %ld,\n",gd1->adjust->ScaleX,gd1->adjust->ScaleY,gd1->adjust->RotateSkew0,gd1->adjust->RotateSkew1,gd1->adjust->TranslateX,gd1->adjust->TranslateY);}voidsetMovieZoom(GraphicDevice *gd1,int z) { z *= FRAC; if (z <= 0 || z > 100) return; gd1->zoom = z; setMovieDimension(gd1,gd1->movieWidth,gd1->movieHeight);}voidsetMovieOffset(GraphicDevice *gd1,long x, long y) { gd1->adjust->TranslateX = -(gd1->zoom)*x; gd1->adjust->TranslateY = -(gd1->zoom)*y;}longclip(GraphicDevice *gd1,long *y, long *start, long *end) { long xmin,xend; if (*y < gd1->clip_rect.Ymin || *y >= gd1->clip_rect.Ymax) return 1; if (end <= start) return 1; xmin = gd1->clip_rect.Xmin * FRAC; xend = gd1->clip_rect.Xmax * FRAC; if (*end <= xmin || *start >= xend) return 1; if (*start < xmin) *start = xmin; if (*end > xend) *end = xend; return 0;}/* polygon rasteriser */Segment *allocSeg(GraphicDevice *gd1) { Segment *seg; //printf("nbsegment is %ld\n",gd1->seg_pool_cur - gd1->seg_pool); if ( (gd1->seg_pool_cur - gd1->seg_pool) >= NB_SEGMENT_MAX ) return NULL; seg = gd1->seg_pool_cur++; return seg;}voidaddSegment(GraphicDevice *gd,long x1, long y1, long x2, long y2, FillStyleDef *f0, FillStyleDef *f1, int aa) { Segment *seg,**segs; long dX, X, Y, ymin, ymax, tmp; FillStyleDef *ff; //printf("in addsegment\n"); if ( y1 == y2 ) { return; } if (y1 < y2) { ymin = y1; ymax = y2; ff = f0; f0 = f1; f1 = ff; } else { ymin = y2; ymax = y1; tmp = x1; x1 = x2; x2 = tmp; } // if (ymax>>FRAC_BITS < gd->clip_rect.Ymin) { // return; // } //if (ymin>>FRAC_BITS > gd->clip_rect.Ymax) { // return; // } X = x1 << SEGFRAC; dX = ((x2 - x1)<<SEGFRAC)/(ymax-ymin); // if (ymin < 0) { // X += dX * (-ymin); // ymin = 0; // } Y = (ymin + (FRAC-1)) & ~(FRAC-1); if (Y > ymax) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -