|
2 | 2 | # Use of this source code is governed by a BSD-style license that can be
|
3 | 3 | # found in the LICENSE file.
|
4 | 4 |
|
| 5 | +# This file is based on: |
| 6 | +# https://skia.googlesource.com/skia/+/master/third_party/libwebp/BUILD.gn |
5 | 7 | config("libwebp_config") {
|
6 | 8 | include_dirs = [ "src" ]
|
7 | 9 | }
|
8 | 10 |
|
| 11 | +config("libwebp_defines") { |
| 12 | + defines = [ |
| 13 | + # WebP naturally decodes to RGB_565, Skia with BGR_565. |
| 14 | + # This makes WebP decode to BGR_565 when we ask for RGB_565. |
| 15 | + # (It also swaps the color order for 4444, but we don't care today.) |
| 16 | + "WEBP_SWAP_16BIT_CSP", |
| 17 | + ] |
| 18 | +} |
| 19 | + |
| 20 | +source_set("libwebp_sse41") { |
| 21 | + include_dirs = [ "//third_party/libwebp/src" ] |
| 22 | + configs += [ ":libwebp_defines" ] |
| 23 | + sources = [ |
| 24 | + "//third_party/libwebp/src/dsp/alpha_processing_sse41.c", |
| 25 | + "//third_party/libwebp/src/dsp/dec_sse41.c", |
| 26 | + "//third_party/libwebp/src/dsp/enc_sse41.c", |
| 27 | + "//third_party/libwebp/src/dsp/lossless_enc_sse41.c", |
| 28 | + ] |
| 29 | + if ((current_cpu == "x86" || current_cpu == "x64") && |
| 30 | + (!is_win || is_clang)) { |
| 31 | + cflags_c = [ "-msse4.1" ] |
| 32 | + } |
| 33 | +} |
| 34 | + |
| 35 | +source_set("libwebp_avx2") { |
| 36 | + include_dirs = [ "//third_party/libwebp/src" ] |
| 37 | + configs += [ ":libwebp_defines" ] |
| 38 | + sources = [ |
| 39 | + "//third_party/libwebp/src/dsp/enc_avx2.c", |
| 40 | + ] |
| 41 | + if ((current_cpu == "x86" || current_cpu == "x64") && |
| 42 | + (!is_win || is_clang)) { |
| 43 | + cflags_c = [ "-mavx2" ] |
| 44 | + } |
| 45 | +} |
| 46 | + |
9 | 47 | source_set("libwebp") {
|
10 | 48 | public_configs = [":libwebp_config"]
|
| 49 | + deps = [ |
| 50 | + ":libwebp_avx2", |
| 51 | + ":libwebp_sse41", |
| 52 | + ] |
| 53 | + |
11 | 54 | if (is_android) {
|
12 |
| - deps = [ "//third_party/cpu-features" ] |
| 55 | + deps += [ "//third_party/cpu-features" ] |
13 | 56 | }
|
| 57 | + |
14 | 58 | sources = [
|
15 | 59 | "//third_party/libwebp/src/dec/alpha_dec.c",
|
16 | 60 | "//third_party/libwebp/src/dec/buffer_dec.c",
|
|
0 commit comments