xref: /aosp_15_r20/external/skia/src/codec/BUILD.bazel (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1load(
2    "//bazel:skia_rules.bzl",
3    "generate_cpp_files_for_headers",
4    "skia_cc_library",
5    "skia_filegroup",
6    "split_srcs_and_hdrs",
7)
8
9package(
10    default_applicable_licenses = ["//:license"],
11)
12
13licenses(["notice"])
14
15PRIVATE_CODEC_HEADERS = [
16    "SkCodecPriv.h",
17    "SkColorPalette.h",
18    "SkFrameHolder.h",
19    "SkMaskSwizzler.h",
20    "SkParseEncodedOrigin.h",
21    "SkSampler.h",
22    "SkScalingCodec.h",
23    "SkSwizzler.h",
24    "SkPixmapUtilsPriv.h",
25    "//include/private:decode_srcs",
26]
27
28# We put any file that is used by more than one codec here to avoid potential issues if clients
29# depend on multiple codecs. This is not a problem for a statically linked binary, but could maybe
30# cause issues with producing a shared library (e.g. duplicate symbols showing up).
31skia_cc_library(
32    name = "any_decoder",
33    srcs = [
34        "SkCodec.cpp",
35        "SkCodecImageGenerator.cpp",
36        "SkCodecImageGenerator.h",
37        "SkColorPalette.cpp",
38        "SkEncodedInfo.cpp",
39        "SkExif.cpp",
40        "SkGainmapInfo.cpp",
41        "SkImageGenerator_FromEncoded.cpp",
42        "SkMaskSwizzler.cpp",
43        "SkParseEncodedOrigin.cpp",
44        "SkPixmapUtils.cpp",
45        "SkSampler.cpp",
46        "SkSwizzler.cpp",
47        "SkTiffUtility.cpp",
48        "SkTiffUtility.h",
49        "//include/codec:any_codec_hdrs",
50    ],
51    hdrs = PRIVATE_CODEC_HEADERS,
52    features = ["layering_check"],
53    local_defines = ["SK_DISABLE_LEGACY_INIT_DECODERS"],
54    visibility = [
55        "//experimental/rust_png:__subpackages__",
56        "//src/encode:__pkg__",
57        "//src/ports:__pkg__",
58    ],
59    deps = [
60        "//modules/skcms",
61        "//src/base",
62        "//src/core",
63        "//src/core:core_priv",
64    ],
65)
66
67skia_cc_library(
68    name = "codec_support",
69    # This is its own rule (with no srcs) to explicitly expose any_codec_hdrs
70    # as public in case a client does not want to use any of our codecs, but
71    # still register their own and/or make use of SkImage::DeferredFromEncodedData
72    hdrs = [
73        "//include/codec:any_codec_hdrs",
74    ],
75    visibility = [
76        "//:__pkg__",
77    ],
78    deps = [
79        ":any_decoder",
80    ],
81)
82
83skia_cc_library(
84    name = "codec_support_priv",
85    hdrs = [
86        "SkCodecImageGenerator.h",
87        "//include/codec:any_codec_hdrs",
88    ] + PRIVATE_CODEC_HEADERS,
89    visibility = [
90        "//modules/skottie:__pkg__",
91        "//modules/skottie/src:__pkg__",
92        "//modules/skresources:__pkg__",
93        "//src/android:__pkg__",
94        "//tools:__pkg__",
95    ],
96    deps = [
97        ":any_decoder",
98    ],
99)
100
101skia_cc_library(
102    name = "android_codec",
103    srcs = [
104        "SkAndroidCodec.cpp",
105        "SkAndroidCodecAdapter.cpp",
106        "SkAndroidCodecAdapter.h",
107        "SkSampledCodec.cpp",
108        "SkSampledCodec.h",
109    ],
110    hdrs = [
111        "//include/codec:android_public_hdrs",
112        "//include/codec:any_codec_hdrs",
113    ],
114    features = ["layering_check"],
115    visibility = ["//:__subpackages__"],
116    deps = [
117        ":any_decoder",
118        "//modules/skcms",
119        "//src/base",
120        "//src/core",
121        "//src/core:core_priv",
122    ],
123)
124
125skia_cc_library(
126    name = "bmp_decode",
127    srcs = [
128        "SkBmpBaseCodec.cpp",
129        "SkBmpBaseCodec.h",
130        "SkBmpCodec.cpp",
131        "SkBmpCodec.h",
132        "SkBmpMaskCodec.cpp",
133        "SkBmpMaskCodec.h",
134        "SkBmpRLECodec.cpp",
135        "SkBmpRLECodec.h",
136        "SkBmpStandardCodec.cpp",
137        "SkBmpStandardCodec.h",
138    ],
139    hdrs = [
140        "//include/codec:any_codec_hdrs",
141        "//include/codec:bmp_public_hdrs",
142    ],
143    defines = ["SK_CODEC_DECODES_BMP"],
144    features = ["layering_check"],
145    visibility = ["//:__subpackages__"],
146    deps = [
147        ":any_decoder",
148        "//modules/skcms",
149        "//src/base",
150        "//src/core",
151        "//src/core:core_priv",
152    ],
153)
154
155skia_cc_library(
156    name = "gif_decode",
157    srcs = [
158        "SkWuffsCodec.cpp",
159    ],
160    hdrs = [
161        "//include/codec:any_codec_hdrs",
162        "//include/codec:gif_public_hdrs",
163    ],
164    defines = ["SK_CODEC_DECODES_GIF"],
165    features = ["layering_check"],
166    visibility = ["//:__subpackages__"],
167    deps = [
168        ":any_decoder",
169        "//modules/skcms",
170        "//src/base",
171        "//src/core",
172        "//src/core:core_priv",
173        "@wuffs",
174    ],
175)
176
177skia_cc_library(
178    name = "ico_decode",
179    srcs = [
180        "SkBmpCodec.h",
181        "SkIcoCodec.cpp",
182        "SkIcoCodec.h",
183    ],
184    hdrs = [
185        "//include/codec:any_codec_hdrs",
186        "//include/codec:ico_public_hdrs",
187    ],
188    defines = ["SK_CODEC_DECODES_ICO"],
189    features = ["layering_check"],
190    visibility = ["//:__subpackages__"],
191    deps = [
192        "//src/base",
193        "//src/core",
194        "//src/core:core_priv",
195        "//modules/skcms",
196        ":any_decoder",
197        # icos can be either PNG or BMP
198        ":bmp_decode",
199        ":png_decode",
200    ],
201)
202
203skia_filegroup(
204    name = "common_jpeg_srcs",
205    srcs = [
206        "SkJpegConstants.h",
207        "SkJpegPriv.h",
208    ],
209    visibility = ["//src/encode:__pkg__"],
210)
211
212skia_cc_library(
213    name = "jpeg_decode",
214    srcs = [
215        "SkJpegCodec.cpp",
216        "SkJpegCodec.h",
217        "SkJpegDecoderMgr.cpp",
218        "SkJpegDecoderMgr.h",
219        "SkJpegMetadataDecoderImpl.cpp",
220        "SkJpegMetadataDecoderImpl.h",
221        "SkJpegSourceMgr.cpp",
222        "SkJpegSourceMgr.h",
223        "SkJpegUtility.cpp",
224        "SkJpegUtility.h",
225        ":common_jpeg_srcs",
226        "//include/private:jpeg_decode_srcs",
227    ],
228    hdrs = [
229        "//include/codec:any_codec_hdrs",
230        "//include/codec:jpeg_public_hdrs",
231    ],
232    defines = ["SK_CODEC_DECODES_JPEG"],
233    features = ["layering_check"],
234    visibility = ["//:__subpackages__"],
235    deps = [
236        ":any_decoder",
237        "//modules/skcms",
238        "//src/base",
239        "//src/core",
240        "//src/core:core_priv",
241        "@libjpeg_turbo",
242    ],
243)
244
245skia_cc_library(
246    name = "jpegxl_decode",
247    srcs = [
248        "SkJpegxlCodec.cpp",
249        "SkJpegxlCodec.h",
250        ":common_jpeg_srcs",
251    ],
252    hdrs = [
253        "//include/codec:any_codec_hdrs",
254        "//include/codec:jpegxl_public_hdrs",
255    ],
256    defines = ["SK_CODEC_DECODES_JPEGXL"],
257    features = ["layering_check"],
258    visibility = ["//:__subpackages__"],
259    deps = [
260        ":any_decoder",
261        "//modules/skcms",
262        "//src/base",
263        "//src/core",
264        "//src/core:core_priv",
265        "@libjxl",
266    ],
267)
268
269skia_filegroup(
270    name = "png_codec_base_srcs",
271    srcs = ["SkPngCodecBase.cpp"],
272)
273
274skia_filegroup(
275    name = "png_codec_base_hdrs",
276    srcs = ["SkPngCodecBase.h"],
277)
278
279skia_cc_library(
280    name = "png_codec_base",
281    srcs = [":png_codec_base_srcs"],
282    hdrs = [
283        ":png_codec_base_hdrs",
284        "//include/codec:any_codec_hdrs",
285    ],
286    features = ["layering_check"],
287    visibility = ["//experimental/rust_png/decoder:__pkg__"],
288    deps = [
289        ":any_decoder",
290        "//modules/skcms",
291        "//src/base",
292        "//src/core",
293        "//src/core:core_priv",
294    ],
295)
296
297skia_filegroup(
298    name = "buffet_png_srcs",
299    srcs = [
300        "SkPngCodec.cpp",
301        "SkPngCodec.h",
302        "SkPngCompositeChunkReader.cpp",
303        "SkPngCompositeChunkReader.h",
304    ],
305)
306
307skia_filegroup(
308    name = "common_png_srcs",
309    srcs = [
310        "SkPngPriv.h",
311    ],
312    visibility = ["//src/encode:__pkg__"],
313)
314
315skia_cc_library(
316    name = "png_decode",
317    srcs = [
318        ":buffet_png_srcs",
319        ":common_png_srcs",
320    ],
321    hdrs = [
322        "//include/codec:any_codec_hdrs",
323        "//include/codec:png_public_hdrs",
324    ],
325    defines = ["SK_CODEC_DECODES_PNG"],
326    features = ["layering_check"],
327    visibility = ["//:__subpackages__"],
328    deps = [
329        ":any_decoder",
330        ":png_codec_base",
331        "//modules/skcms",
332        "//src/base",
333        "//src/core",
334        "//src/core:core_priv",
335        "@libpng",
336    ],
337)
338
339skia_cc_library(
340    name = "wbmp_decode",
341    srcs = [
342        "SkBmpBaseCodec.h",
343        "SkBmpCodec.h",
344        "SkBmpMaskCodec.h",
345        "SkBmpRLECodec.h",
346        "SkBmpStandardCodec.h",
347        "SkWbmpCodec.cpp",
348        "SkWbmpCodec.h",
349        "//include/codec:bmp_public_hdrs",
350    ],
351    hdrs = [
352        "//include/codec:any_codec_hdrs",
353        "//include/codec:wbmp_public_hdrs",
354    ],
355    defines = ["SK_CODEC_DECODES_WBMP"],
356    features = ["layering_check"],
357    visibility = ["//:__subpackages__"],
358    deps = [
359        ":any_decoder",
360        ":bmp_decode",  # Avoid ODR violations by not duplicating .cpp files
361        "//modules/skcms",
362        "//src/base",
363        "//src/core",
364        "//src/core:core_priv",
365    ],
366)
367
368skia_cc_library(
369    name = "webp_decode",
370    srcs = [
371        "SkWebpCodec.cpp",
372        "SkWebpCodec.h",
373    ],
374    hdrs = [
375        "//include/codec:any_codec_hdrs",
376        "//include/codec:webp_public_hdrs",
377    ],
378    defines = ["SK_CODEC_DECODES_WEBP"],
379    features = ["layering_check"],
380    visibility = ["//:__subpackages__"],
381    deps = [
382        ":any_decoder",
383        "//modules/skcms",
384        "//src/base",
385        "//src/core",
386        "//src/core:core_priv",
387        "@libwebp",
388    ],
389)
390
391generate_cpp_files_for_headers(
392    name = "headers_to_compile",
393    headers = [
394        "SkPixmapUtilsPriv.h",
395        "SkScalingCodec.h",
396    ],
397)
398
399# The following are not yet incorporated into the Bazel build
400skia_filegroup(
401    name = "xmp_srcs",
402    srcs = [
403        "SkXmp.cpp",
404    ],
405)
406
407split_srcs_and_hdrs(
408    name = "jpeg_xmp",
409    files = [
410        "SkJpegXmp.cpp",
411        "SkJpegXmp.h",
412    ],
413)
414