1 /****************************************************************************
2 *
3 * pngshim.c
4 *
5 * PNG Bitmap glyph support.
6 *
7 * Copyright (C) 2013-2019 by
8 * Google, Inc.
9 * Written by Stuart Gill and Behdad Esfahbod.
10 *
11 * This file is part of the FreeType project, and may only be used,
12 * modified, and distributed under the terms of the FreeType project
13 * license, LICENSE.TXT. By continuing to use, modify, or distribute
14 * this file you indicate that you have read the license and
15 * understand and accept it fully.
16 *
17 */
18
19
20 #include <ft2build.h>
21 #include FT_INTERNAL_DEBUG_H
22 #include FT_INTERNAL_STREAM_H
23 #include FT_TRUETYPE_TAGS_H
24 #include FT_CONFIG_STANDARD_LIBRARY_H
25
26
27 #if defined( TT_CONFIG_OPTION_EMBEDDED_BITMAPS ) && \
51
52 /* Premultiplies data and converts RGBA bytes => BGRA. */
53 static void
54 premultiply_data( png_structp png,
55 png_row_infop row_info,
56 png_bytep data )
57 {
58 unsigned int i = 0, limit;
59
60 /* The `vector_size' attribute was introduced in gcc 3.1, which */
61 /* predates clang; the `__BYTE_ORDER__' preprocessor symbol was */
62 /* introduced in gcc 4.6 and clang 3.2, respectively. */
63 /* `__builtin_shuffle' for gcc was introduced in gcc 4.7.0. */
64 #if ( ( defined( __GNUC__ ) && \
65 ( ( __GNUC__ >= 5 ) || \
66 ( ( __GNUC__ == 4 ) && ( __GNUC_MINOR__ >= 7 ) ) ) ) || \
67 ( defined( __clang__ ) && \
68 ( ( __clang_major__ >= 4 ) || \
69 ( ( __clang_major__ == 3 ) && ( __clang_minor__ >= 2 ) ) ) ) ) && \
70 defined( __OPTIMIZE__ ) && \
71 __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
72
73 #ifdef __clang__
74 /* the clang documentation doesn't cover the two-argument case of */
75 /* `__builtin_shufflevector'; however, it is is implemented since */
76 /* version 2.8 */
77 #define vector_shuffle __builtin_shufflevector
78 #else
79 #define vector_shuffle __builtin_shuffle
80 #endif
81
82 typedef unsigned short v82 __attribute__(( vector_size( 16 ) ));
83
84
85 if ( row_info->rowbytes > 15 )
86 {
87 /* process blocks of 16 bytes in one rush, which gives a nice speed-up */
88 limit = row_info->rowbytes - 16 + 1;
89 for ( ; i < limit; i += 16 )
90 {
|
1 /****************************************************************************
2 *
3 * pngshim.c
4 *
5 * PNG Bitmap glyph support.
6 *
7 * Copyright (C) 2013-2020 by
8 * Google, Inc.
9 * Written by Stuart Gill and Behdad Esfahbod.
10 *
11 * This file is part of the FreeType project, and may only be used,
12 * modified, and distributed under the terms of the FreeType project
13 * license, LICENSE.TXT. By continuing to use, modify, or distribute
14 * this file you indicate that you have read the license and
15 * understand and accept it fully.
16 *
17 */
18
19
20 #include <ft2build.h>
21 #include FT_INTERNAL_DEBUG_H
22 #include FT_INTERNAL_STREAM_H
23 #include FT_TRUETYPE_TAGS_H
24 #include FT_CONFIG_STANDARD_LIBRARY_H
25
26
27 #if defined( TT_CONFIG_OPTION_EMBEDDED_BITMAPS ) && \
51
52 /* Premultiplies data and converts RGBA bytes => BGRA. */
53 static void
54 premultiply_data( png_structp png,
55 png_row_infop row_info,
56 png_bytep data )
57 {
58 unsigned int i = 0, limit;
59
60 /* The `vector_size' attribute was introduced in gcc 3.1, which */
61 /* predates clang; the `__BYTE_ORDER__' preprocessor symbol was */
62 /* introduced in gcc 4.6 and clang 3.2, respectively. */
63 /* `__builtin_shuffle' for gcc was introduced in gcc 4.7.0. */
64 #if ( ( defined( __GNUC__ ) && \
65 ( ( __GNUC__ >= 5 ) || \
66 ( ( __GNUC__ == 4 ) && ( __GNUC_MINOR__ >= 7 ) ) ) ) || \
67 ( defined( __clang__ ) && \
68 ( ( __clang_major__ >= 4 ) || \
69 ( ( __clang_major__ == 3 ) && ( __clang_minor__ >= 2 ) ) ) ) ) && \
70 defined( __OPTIMIZE__ ) && \
71 defined( __SSE__ ) && \
72 __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
73
74 #ifdef __clang__
75 /* the clang documentation doesn't cover the two-argument case of */
76 /* `__builtin_shufflevector'; however, it is is implemented since */
77 /* version 2.8 */
78 #define vector_shuffle __builtin_shufflevector
79 #else
80 #define vector_shuffle __builtin_shuffle
81 #endif
82
83 typedef unsigned short v82 __attribute__(( vector_size( 16 ) ));
84
85
86 if ( row_info->rowbytes > 15 )
87 {
88 /* process blocks of 16 bytes in one rush, which gives a nice speed-up */
89 limit = row_info->rowbytes - 16 + 1;
90 for ( ; i < limit; i += 16 )
91 {
|