Changeset 23808


Ignore:
Timestamp:
09/20/13 22:28:03 (10 years ago)
Author:
nit
Message:

[titan] optimize gradient

File:
1 edited

Legend:

Unmodified
Added
Removed
  • titan/titan/skin.h

    r23807 r23808  
    26752675void drawgradient(int posx, int posy, int width, int height, long col1, long col2, int transparent, int flag)
    26762676{
    2677         int p = 0, i = 0, x = 0, y = 0, steps = 0, xstep = 0, ystep = 0;
     2677        int p, i, x, y, steps, xstep, ystep, tmp = 0;
    26782678        int xcount = 0, ycount = 0, owidth = width, oheight = height;
    26792679        unsigned char r3, g3, b3;
     
    26852685        {
    26862686                if(flag == LEFTMIDDLE) width = width / 2;
     2687                if(width < 10)
     2688                        steps = width;
    26872689                if(width < 100)
    2688                         steps = width;
     2690                        steps = width / 2;
    26892691                else
    26902692                        steps = width / 5;
     
    26952697        {
    26962698                if(flag == TOPMIDDLE) height = height / 2;
    2697                 if(height < 100)
     2699                if(height < 10)
    26982700                        steps = height;
     2701                else if(height < 100)
     2702                        steps = height / 2;
    26992703                else
    27002704                        steps = height / 5;
     
    27102714        unsigned char g2 = (col2 >> 8) & 0xff;
    27112715        unsigned char b2 = col2 & 0xff;
     2716
     2717        int yend = (posy + ystep) * skinfb->width;
     2718        int xend = posx + xstep;
     2719        posy *= skinfb->width;
    27122720
    27132721        for(i = 0; i < steps; i++)
     
    27182726                b3 = (b1 * p + b2 * i) / steps;
    27192727                col = (transparent << 24) | (r3 << 16) | (g3 << 8) | b3;
    2720        
    2721                 for(y = 0; y < ystep; y++)
    2722                         for(x = 0; x < xstep; x++)
    2723                                 drawpixel(posx + x, posy + y, col);
     2728               
     2729                for(y = posy; y < yend; y += skinfb->width)
     2730                        for(x = posx; x < xend; x++)
     2731                                drawpixelfast(x, y, col);
    27242732
    27252733                if(flag == LEFTRIGHT || flag == LEFTMIDDLE)
     
    27272735                        posx += xstep;
    27282736                        xcount += xstep;
     2737                        xend = posx + xstep;
    27292738                }
    27302739                else
    27312740                {
    2732                         posy += ystep;
     2741                        tmp = ystep * skinfb->width;
     2742                        posy += tmp;
    27332743                        ycount += ystep;
     2744                        yend = posy + tmp;
    27342745                }
    27352746        }
     
    27452756                        col = (transparent << 24) | (r3 << 16) | (g3 << 8) | b3;
    27462757               
    2747                         for(y = 0; y < ystep; y++)
    2748                                 for(x = 0; x < xstep; x++)
    2749                                         drawpixel(posx + x, posy + y, col);
     2758                        for(y = posy; y < yend; y += skinfb->width)
     2759                                for(x = posx; x < xend; x++)
     2760                                        drawpixelfast(x, y, col);
    27502761                       
    27512762                        if(flag == LEFTMIDDLE)
     
    27532764                                posx += xstep;
    27542765                                xcount += xstep;
     2766                                xend = posx + xstep;
    27552767                        }
    27562768                        else
    27572769                        {
    2758                                 posy += ystep;
     2770                                tmp = ystep * skinfb->width;
     2771                                posy += tmp;
    27592772                                ycount += ystep;
     2773                                yend = posy + tmp;
    27602774                        }
    27612775                }
     
    27662780                if(owidth > xcount)
    27672781                {
    2768                         int tmp = owidth - xcount;
    2769                         for(y = 0; y < ystep; y++)
    2770                                 for(x = 0; x < tmp; x++)
    2771                                         drawpixel(posx + x, posy + y, col);
     2782                        int tmp = posx + (owidth - xcount);
     2783                        for(y = posy; y < yend; y += skinfb->width)
     2784                                for(x = posx; x < tmp; x++)
     2785                                        drawpixelfast(x, y, col);
    27722786                }
    27732787        }
     
    27762790                if(oheight > ycount)
    27772791                {
    2778                         int tmp = oheight - ycount;
    2779                         for(y = 0; y < tmp; y++)
    2780                                 for(x = 0; x < xstep; x++)
    2781                                         drawpixel(posx + x, posy + y, col);
     2792                        int tmp = posy + ((oheight - ycount) * skinfb->width);
     2793                        for(y = posy; y < tmp; y += skinfb->width)
     2794                                for(x = posx; x < xend; x++)
     2795                                        drawpixelfast(x, y, col);
    27822796                }
    27832797        }
Note: See TracChangeset for help on using the changeset viewer.