freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Git][freetype/freetype][master] [cff] Optimize the blend vector computa


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype][master] [cff] Optimize the blend vector computations.
Date: Mon, 20 May 2024 23:18:06 +0000

Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType

Commits:

  • 4ccdc9f9
    by Alexei Podtelezhnikov (Алексей Подтележников) at 2024-05-20T18:53:57-04:00
    [cff] Optimize the blend vector computations.
    
    * src/cff/cffload.c (cff_blend_build_vector): Use FT_MulDiv and skip
    multiplying by 1.
    

1 changed file:

Changes:

  • src/cff/cffload.c
    ... ... @@ -1495,44 +1495,41 @@
    1495 1495
           for ( j = 0; j < lenNDV; j++ )
    
    1496 1496
           {
    
    1497 1497
             CFF_AxisCoords*  axis = &varRegion->axisList[j];
    
    1498
    -        FT_Fixed         axisScalar;
    
    1499 1498
     
    
    1500 1499
     
    
    1501 1500
             /* compute the scalar contribution of this axis; */
    
    1502 1501
             /* ignore invalid ranges                         */
    
    1503 1502
             if ( axis->startCoord > axis->peakCoord ||
    
    1504 1503
                  axis->peakCoord > axis->endCoord   )
    
    1505
    -          axisScalar = FT_FIXED_ONE;
    
    1504
    +          continue;
    
    1506 1505
     
    
    1507 1506
             else if ( axis->startCoord < 0 &&
    
    1508 1507
                       axis->endCoord > 0   &&
    
    1509 1508
                       axis->peakCoord != 0 )
    
    1510
    -          axisScalar = FT_FIXED_ONE;
    
    1509
    +          continue;
    
    1511 1510
     
    
    1512 1511
             /* peak of 0 means ignore this axis */
    
    1513 1512
             else if ( axis->peakCoord == 0 )
    
    1514
    -          axisScalar = FT_FIXED_ONE;
    
    1513
    +          continue;
    
    1515 1514
     
    
    1516 1515
             /* ignore this region if coords are out of range */
    
    1517 1516
             else if ( NDV[j] < axis->startCoord ||
    
    1518 1517
                       NDV[j] > axis->endCoord   )
    
    1519
    -          axisScalar = 0;
    
    1520
    -
    
    1521
    -        /* calculate a proportional factor */
    
    1522
    -        else
    
    1523 1518
             {
    
    1524
    -          if ( NDV[j] == axis->peakCoord )
    
    1525
    -            axisScalar = FT_FIXED_ONE;
    
    1526
    -          else if ( NDV[j] < axis->peakCoord )
    
    1527
    -            axisScalar = FT_DivFix( NDV[j] - axis->startCoord,
    
    1528
    -                                    axis->peakCoord - axis->startCoord );
    
    1529
    -          else
    
    1530
    -            axisScalar = FT_DivFix( axis->endCoord - NDV[j],
    
    1531
    -                                    axis->endCoord - axis->peakCoord );
    
    1519
    +          blend->BV[master] = 0;
    
    1520
    +          break;
    
    1532 1521
             }
    
    1533 1522
     
    
    1534
    -        /* take product of all the axis scalars */
    
    1535
    -        blend->BV[master] = FT_MulFix( blend->BV[master], axisScalar );
    
    1523
    +        /* adjust proportionally */
    
    1524
    +        else if ( NDV[j] < axis->peakCoord )
    
    1525
    +          blend->BV[master] = FT_MulDiv( blend->BV[master],
    
    1526
    +                                         NDV[j] - axis->startCoord,
    
    1527
    +                                         axis->peakCoord - axis->startCoord );
    
    1528
    +
    
    1529
    +        else if ( NDV[j] > axis->peakCoord )
    
    1530
    +          blend->BV[master] = FT_MulDiv( blend->BV[master],
    
    1531
    +                                         axis->endCoord - NDV[j],
    
    1532
    +                                         axis->endCoord - axis->peakCoord );
    
    1536 1533
           }
    
    1537 1534
     
    
    1538 1535
           FT_TRACE4(( ", %f ",
    


  • reply via email to

    [Prev in Thread] Current Thread [Next in Thread]