freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][bitmap_convert] * src/base/ftbitmap.c (FT_Bitma


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype][bitmap_convert] * src/base/ftbitmap.c (FT_Bitmap_Copy): Recreate target.
Date: Wed, 21 Sep 2022 14:44:27 +0000

Alexei Podtelezhnikov pushed to branch bitmap_convert at FreeType / FreeType

Commits:

  • 82c5ecfe
    by Alexei Podtelezhnikov at 2022-09-21T14:44:23+00:00
    * src/base/ftbitmap.c (FT_Bitmap_Copy): Recreate target.
        
    There is no need to preserve bits before overwriting them.
    Therefore, free-malloc could be faster than realloc.
    

1 changed file:

Changes:

  • src/base/ftbitmap.c
    ... ... @@ -66,9 +66,7 @@
    66 66
       {
    
    67 67
         FT_Memory  memory;
    
    68 68
         FT_Error   error  = FT_Err_Ok;
    
    69
    -
    
    70
    -    FT_Int    pitch;
    
    71
    -    FT_ULong  size;
    
    69
    +    FT_Int     pitch;
    
    72 70
     
    
    73 71
         FT_Int  source_pitch_sign, target_pitch_sign;
    
    74 72
     
    
    ... ... @@ -85,49 +83,28 @@
    85 83
         source_pitch_sign = source->pitch < 0 ? -1 : 1;
    
    86 84
         target_pitch_sign = target->pitch < 0 ? -1 : 1;
    
    87 85
     
    
    88
    -    if ( !source->buffer )
    
    89
    -    {
    
    90
    -      *target = *source;
    
    91
    -      if ( source_pitch_sign != target_pitch_sign )
    
    92
    -        target->pitch = -target->pitch;
    
    86
    +    memory = library->memory;
    
    87
    +    FT_FREE( target->buffer );
    
    88
    +
    
    89
    +    *target = *source;
    
    93 90
     
    
    91
    +    if ( source_pitch_sign != target_pitch_sign )
    
    92
    +      target->pitch = -target->pitch;
    
    93
    +
    
    94
    +    if ( !source->buffer )
    
    94 95
           return FT_Err_Ok;
    
    95
    -    }
    
    96 96
     
    
    97
    -    memory = library->memory;
    
    98 97
         pitch  = source->pitch;
    
    99
    -
    
    100 98
         if ( pitch < 0 )
    
    101 99
           pitch = -pitch;
    
    102
    -    size = (FT_ULong)pitch * source->rows;
    
    103 100
     
    
    104
    -    if ( target->buffer )
    
    105
    -    {
    
    106
    -      FT_Int    target_pitch = target->pitch;
    
    107
    -      FT_ULong  target_size;
    
    108
    -
    
    109
    -
    
    110
    -      if ( target_pitch < 0 )
    
    111
    -        target_pitch = -target_pitch;
    
    112
    -      target_size = (FT_ULong)target_pitch * target->rows;
    
    113
    -
    
    114
    -      if ( target_size != size )
    
    115
    -        FT_MEM_QREALLOC( target->buffer, target_size, size );
    
    116
    -    }
    
    117
    -    else
    
    118
    -      FT_MEM_QALLOC( target->buffer, size );
    
    101
    +    FT_MEM_QALLOC_MULT( target->buffer, target->rows, pitch );
    
    119 102
     
    
    120 103
         if ( !error )
    
    121 104
         {
    
    122
    -      unsigned char *p;
    
    123
    -
    
    124
    -
    
    125
    -      p = target->buffer;
    
    126
    -      *target = *source;
    
    127
    -      target->buffer = p;
    
    128
    -
    
    129 105
           if ( source_pitch_sign == target_pitch_sign )
    
    130
    -        FT_MEM_COPY( target->buffer, source->buffer, size );
    
    106
    +        FT_MEM_COPY( target->buffer, source->buffer,
    
    107
    +                     (FT_Long)source->rows * pitch );
    
    131 108
           else
    
    132 109
           {
    
    133 110
             /* take care of bitmap flow */
    


  • reply via email to

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