From: Laszlo T. <ave...@us...> - 2004-08-05 17:25:18
|
Update of /cvsroot/gemrb/gemrb/gemrb/plugins/SDLVideo In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12565/SDLVideo Modified Files: SDLVideoDriver.cpp SDLVideoDriver.h Log Message: Optimized polygon importing (removed double allocating of polygons) Index: SDLVideoDriver.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/SDLVideo/SDLVideoDriver.h,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** SDLVideoDriver.h 3 Aug 2004 20:21:58 -0000 1.34 --- SDLVideoDriver.h 5 Aug 2004 17:25:07 -0000 1.35 *************** *** 109,113 **** } /** */ ! Sprite2D* PrecalculatePolygon(Point* points, int count, Color& color); void SetFadePercent(int percent); --- 109,114 ---- } /** */ ! Sprite2D* PrecalculatePolygon(Gem_Polygon *poly, Color& color); ! //Point* points, int count, Color& color, Region& BBox); void SetFadePercent(int percent); Index: SDLVideoDriver.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/SDLVideo/SDLVideoDriver.cpp,v retrieving revision 1.78 retrieving revision 1.79 diff -C2 -d -r1.78 -r1.79 *** SDLVideoDriver.cpp 3 Aug 2004 20:21:58 -0000 1.78 --- SDLVideoDriver.cpp 5 Aug 2004 17:25:07 -0000 1.79 *************** *** 1288,1294 **** } ! Sprite2D* SDLVideoDriver::PrecalculatePolygon(Point* points, int count, ! Color& color) { short minX = 20000, maxX = 0, minY = 20000, maxY = 0; for (int i = 0; i < count; i++) { --- 1288,1295 ---- } ! Sprite2D* SDLVideoDriver::PrecalculatePolygon(Gem_Polygon *poly, Color &color) ! //Point* points, int count, Color& color, Region& BBox) { + /* we don't need this, the BBox is already stored in the area short minX = 20000, maxX = 0, minY = 20000, maxY = 0; for (int i = 0; i < count; i++) { *************** *** 1304,1318 **** short width = maxX - minX; short height = maxY - minY; ! void* pixels = malloc( width* height ); ! memset( pixels, 0, width * height ); unsigned char * ptr = ( unsigned char * ) pixels; ! Gem_Polygon* poly = new Gem_Polygon( points, count ); ! for (int y = 0; y < height; y++) { ! for (int x = 0; x < width; x++) { ! if (poly->PointIn( x + minX, y + minY )) *ptr = 1; ptr++; --- 1305,1320 ---- short width = maxX - minX; short height = maxY - minY; + */ ! void* pixels = malloc( poly->BBox.w * poly->BBox.h ); ! memset( pixels, 0, poly->BBox.w * poly->BBox.h ); unsigned char * ptr = ( unsigned char * ) pixels; ! // Gem_Polygon* poly = new Gem_Polygon( points, count, BBox ); ! for (int y = 0; y < poly->BBox.h; y++) { ! for (int x = 0; x < poly->BBox.w; x++) { ! if (poly->PointIn( poly->BBox.x + x, poly->BBox.y + y )) *ptr = 1; ptr++; *************** *** 1320,1324 **** } ! delete( poly ); Color palette[2]; --- 1322,1326 ---- } ! // delete( poly ); Color palette[2]; *************** *** 1333,1346 **** Sprite2D* spr = new Sprite2D(); ! void* p = SDL_CreateRGBSurfaceFrom( pixels, width, height, 8, width, 0, 0, ! 0, 0 ); ! SDL_SetPalette( ( SDL_Surface * ) p, SDL_LOGPAL, ( SDL_Color * ) palette, ! 0, 2 ); spr->vptr = p; spr->pixels = pixels; SDL_SetColorKey( ( SDL_Surface * ) p, SDL_SRCCOLORKEY | SDL_RLEACCEL, 0 ); SDL_SetAlpha( ( SDL_Surface * ) p, SDL_SRCALPHA | SDL_RLEACCEL, 128 ); ! spr->Width = width; ! spr->Height = height; return spr; } --- 1335,1346 ---- Sprite2D* spr = new Sprite2D(); ! void* p = SDL_CreateRGBSurfaceFrom( pixels, poly->BBox.w, poly->BBox.h, 8, poly->BBox.w, 0, 0, 0, 0 ); ! SDL_SetPalette( ( SDL_Surface * ) p, SDL_LOGPAL, ( SDL_Color * ) palette, 0, 2 ); spr->vptr = p; spr->pixels = pixels; SDL_SetColorKey( ( SDL_Surface * ) p, SDL_SRCCOLORKEY | SDL_RLEACCEL, 0 ); SDL_SetAlpha( ( SDL_Surface * ) p, SDL_SRCALPHA | SDL_RLEACCEL, 128 ); ! spr->Width = poly->BBox.w; ! spr->Height = poly->BBox.h; return spr; } *************** *** 1353,1358 **** if (fill) { if (!poly->fill) { ! poly->fill = PrecalculatePolygon( poly->points, poly->count, ! color ); } Region Screen = Viewport; --- 1353,1357 ---- if (fill) { if (!poly->fill) { ! poly->fill = PrecalculatePolygon( poly, color);//->points, poly->count, color, poly->BBox ); } Region Screen = Viewport; |