• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"""
2This file contains defines used by all builds of Skia.
3"""
4
5load("//bazel:extra_defines.bzl", "EXTRA_DEFINES")
6load("//bazel:skia_rules.bzl", "select_multi")
7
8GENERAL_DEFINES = [
9    "SK_GAMMA_APPLY_TO_A8",
10] + select({
11    "//bazel/common_config_settings:debug_build": [
12        "SK_DEBUG",
13    ],
14    "//bazel/common_config_settings:release_build": [
15        "SK_RELEASE",
16        "NDEBUG",
17    ],
18    "//bazel/common_config_settings:fast_build": [
19        "SK_DEBUG",
20    ],
21}) + select({
22    "//bazel/common_config_settings:enable_tracing_false": ["SK_DISABLE_TRACING"],
23    "//conditions:default": [],
24}) + select({
25    "//bazel/common_config_settings:enable_effect_serialization_false": ["SK_DISABLE_EFFECT_DESERIALIZATION"],
26    "//conditions:default": [],
27}) + select({
28    "//src/gpu:enable_gpu_test_utils_true": [
29        "GR_TEST_UTILS=1",
30        "SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=1",
31    ],
32    "//conditions:default": [],
33}) + select({
34    "//src/sksl:enable_skslc_true": [
35        "SKSL_STANDALONE",
36        "SK_DISABLE_TRACING",
37        "SK_ENABLE_SPIRV_CROSS",
38        "SK_ENABLE_SPIRV_VALIDATION",
39        "SK_ENABLE_WGSL_VALIDATION",
40    ],
41    "//conditions:default": [],
42}) + select({
43    "//src/sksl:enable_sksl_tracing_true": ["SKSL_ENABLE_TRACING"],
44    "//conditions:default": [],
45}) + select({
46    "//src/sksl:needs_sksl": ["SK_ENABLE_SKSL"],
47    "//conditions:default": [],
48}) + select({
49    "//src/pdf:enable_pdf_backend_true": ["SK_SUPPORT_PDF"],
50    "//conditions:default": [],
51}) + select({
52    "//src/shaders:legacy_shader_context_true": [],  # This is the default in SkTypes.h
53    "//src/shaders:legacy_shader_context_false": ["SK_DISABLE_LEGACY_SHADERCONTEXT"],
54}) + select({
55    "//src/lazy:enable_discardable_memory_true": ["SK_USE_DISCARDABLE_SCALEDIMAGECACHE"],
56    "//src/lazy:enable_discardable_memory_false": [],
57})
58
59GPU_DEFINES = select_multi({
60    "//src/gpu:gl_backend": [
61        "SK_GL",
62        "SK_GANESH",
63    ],
64    "//src/gpu:vulkan_backend": [
65        "SK_VULKAN",
66        "SK_GANESH",
67    ],
68    "//src/gpu:dawn_backend": [
69        "SK_DAWN",
70        "SK_GANESH",
71        "VK_USE_PLATFORM_XCB_KHR",  # TODO(kjlubick) support dawn's dawn_enable_vulkan etc
72    ],
73}) + select({
74    "//src/gpu:gl_standard": [
75        "SK_ASSUME_GL=1",
76    ],
77    "//src/gpu:gles_standard": [
78        "SK_ASSUME_GL_ES=1",
79    ],
80    "//src/gpu:webgl_standard": [
81        "SK_ASSUME_WEBGL=1",
82        "SK_USE_WEBGL",
83    ],
84    "//conditions:default": [],
85}) + select({
86    "//src/gpu:vulkan_with_vma": [
87        "SK_USE_VMA",
88    ],
89    "//conditions:default": [],
90})
91
92CODEC_DEFINES = [
93    "SK_HAS_ANDROID_CODEC",
94] + select_multi(
95    {
96        "//src/codec:avif_decode_codec": ["SK_CODEC_DECODES_AVIF"],
97        "//src/codec:gif_decode_codec": ["SK_HAS_WUFFS_LIBRARY"],
98        "//src/codec:jpeg_decode_codec": ["SK_CODEC_DECODES_JPEG"],
99        "//src/encode:jpeg_encode_codec": ["SK_ENCODE_JPEG"],
100        "//src/codec:png_decode_codec": ["SK_CODEC_DECODES_PNG"],
101        "//src/encode:png_encode_codec": ["SK_ENCODE_PNG"],
102        "//src/codec:raw_decode_codec": [
103            "SK_CODEC_DECODES_RAW",
104            "SK_CODEC_DECODES_JPEG",
105        ],
106        "//src/codec:webp_decode_codec": ["SK_CODEC_DECODES_WEBP"],
107        "//src/encode:webp_encode_codec": ["SK_ENCODE_WEBP"],
108    },
109)
110
111TYPEFACE_DEFINES = select_multi(
112    {
113        "//src/ports:uses_freetype": ["SK_TYPEFACE_FACTORY_FREETYPE"],
114        #TODO: others when they become available
115    },
116)
117
118PLATFORM_DEFINES = select({
119    "//bazel/common_config_settings:cpu_wasm": [
120        # working around https://github.com/emscripten-core/emscripten/issues/10072
121        "SK_FORCE_8_BYTE_ALIGNMENT",
122        "SK_DISABLE_AAA",  # This saves about 57KB of code size, uncompressed
123    ],
124    "//conditions:default": [],
125})
126
127# Skia's public headers can work with any version of a Vulkan header. When compiling Skia internals,
128# we want to use the Vulkan headers in //include/third_party/vulkan, so we set this define only when
129# building the library but not exporting it for clients, so they can use whatever vulkan they want.
130GENERAL_LOCAL_DEFINES = ["SKIA_IMPLEMENTATION=1"]
131
132DEFAULT_DEFINES = GENERAL_DEFINES + GPU_DEFINES + CODEC_DEFINES + TYPEFACE_DEFINES + PLATFORM_DEFINES + EXTRA_DEFINES
133
134DEFAULT_LOCAL_DEFINES = GENERAL_LOCAL_DEFINES
135