1package {
2    default_applicable_licenses: ["frameworks_base_libs_hwui_license"],
3}
4
5// Added automatically by a large-scale-change that took the approach of
6// 'apply every license found to every target'. While this makes sure we respect
7// every license restriction, it may not be entirely correct.
8//
9// e.g. GPL in an MIT project might only apply to the contrib/ directory.
10//
11// Please consider splitting the single license below into multiple licenses,
12// taking care not to lose any license_kind information, and overriding the
13// default license using the 'licenses: [...]' property on targets as needed.
14//
15// For unused files, consider creating a 'fileGroup' with "//visibility:private"
16// to attach the license to, and including a comment whether the files may be
17// used in the current project.
18// See: http://go/android-license-faq
19license {
20    name: "frameworks_base_libs_hwui_license",
21    visibility: [":__subpackages__"],
22    license_kinds: [
23        "SPDX-license-identifier-Apache-2.0",
24        "SPDX-license-identifier-BSD",
25    ],
26    license_text: [
27        "NOTICE",
28    ],
29}
30
31cc_defaults {
32    name: "hwui_defaults",
33    defaults: [
34        "hwui_static_deps",
35        "skia_deps",
36        //"hwui_bugreport_font_cache_usage",
37        //"hwui_compile_for_perf",
38        "hwui_lto",
39    ],
40
41    cpp_std: "experimental",
42
43    cflags: [
44        "-DEGL_EGLEXT_PROTOTYPES",
45        "-DGL_GLEXT_PROTOTYPES",
46        "-DATRACE_TAG=ATRACE_TAG_VIEW",
47        "-DLOG_TAG=\"OpenGLRenderer\"",
48        "-Wall",
49        "-Wthread-safety",
50        "-Wno-unused-parameter",
51        "-Wunreachable-code",
52        "-Werror",
53        "-fvisibility=hidden",
54
55        // GCC false-positives on this warning, and since we -Werror that's
56        // a problem
57        "-Wno-free-nonheap-object",
58
59        // Do not de-optimise cold code paths in AFDO.
60        // Some code paths might be infrequently executed but critical to latency.
61        "-fno-profile-sample-accurate",
62    ],
63
64    include_dirs: [
65        "external/skia/include/private",
66        "external/skia/src/core",
67    ],
68
69    product_variables: {
70        eng: {
71            lto: {
72                never: true,
73            },
74        },
75    },
76
77    target: {
78        android: {
79            include_dirs: [
80                "external/skia/src/image",
81                "external/skia/src/utils",
82                "external/skia/src/gpu",
83                "external/skia/src/shaders",
84            ],
85        },
86        host: {
87            include_dirs: [
88                "external/vulkan-headers/include",
89            ],
90            cflags: [
91                "-Wno-unused-variable",
92            ],
93        },
94    },
95}
96
97cc_defaults {
98    name: "hwui_static_deps",
99    defaults: [
100        "android.hardware.graphics.common-ndk_shared",
101        "android.hardware.graphics.composer3-ndk_shared",
102    ],
103    shared_libs: [
104        "libbase",
105        "libharfbuzz_ng",
106        "libminikin",
107    ],
108
109    static_libs: [
110        "libui-types",
111    ],
112
113    target: {
114        android: {
115            shared_libs: [
116                "android.hardware.graphics.common@1.2",
117                "liblog",
118                "libcutils",
119                "libutils",
120                "libEGL",
121                "libGLESv1_CM",
122                "libGLESv2",
123                "libGLESv3",
124                "libvulkan",
125                "libnativedisplay",
126                "libnativewindow",
127                "libprotobuf-cpp-lite",
128                "libft2",
129                "libandroidfw",
130                "libcrypto",
131                "libsync",
132                "libui",
133            ],
134            static_libs: [
135                "libEGL_blobCache",
136                "libprotoutil",
137                "libshaders",
138                "libstatslog_hwui",
139                "libstatspull_lazy",
140                "libstatssocket_lazy",
141                "libtonemap",
142            ],
143        },
144        host: {
145            static_libs: [
146                "libandroidfw",
147                "libutils",
148            ],
149        },
150    },
151}
152
153cc_defaults {
154    name: "hwui_bugreport_font_cache_usage",
155    cflags: ["-DBUGREPORT_FONT_CACHE_USAGE"],
156}
157
158cc_defaults {
159    name: "hwui_compile_for_perf",
160    // TODO: Non-arm?
161    cflags: [
162        "-fno-omit-frame-pointer",
163        "-marm",
164        "-mapcs",
165    ],
166}
167
168// Build hwui library with ThinLTO by default.
169cc_defaults {
170    name: "hwui_lto",
171    target: {
172        android: {
173            lto: {
174                thin: true,
175            },
176        },
177    },
178}
179
180// ------------------------
181// framework-graphics jar
182// ------------------------
183
184java_sdk_library {
185    name: "framework-graphics",
186    defaults: ["framework-module-defaults"],
187    visibility: [
188        "//frameworks/base", // Framework
189    ],
190
191    srcs: [
192        ":framework-graphics-srcs",
193    ],
194
195    permitted_packages: [
196        "android.graphics",
197    ],
198
199    // TODO: once framework-graphics is officially part of the
200    // UI-rendering module this line would no longer be
201    // needed.
202    installable: true,
203
204    // Disable api_lint that the defaults enable
205    // TODO: enable this
206    api_lint: {
207        enabled: false,
208    },
209    // TODO: remove this
210    unsafe_ignore_missing_latest_api: true,
211}
212
213filegroup {
214    name: "framework-graphics-srcs",
215    srcs: [
216        "apex/java/**/*.java",
217    ],
218    path: "apex/java",
219}
220
221java_api_contribution {
222    name: "framework-graphics-public-stubs",
223    api_surface: "public",
224    api_file: "api/current.txt",
225    visibility: [
226        "//build/orchestrator/apis",
227    ],
228}
229
230// ------------------------
231// APEX
232// ------------------------
233
234cc_library_headers {
235    name: "android_graphics_apex_headers",
236
237    host_supported: true,
238    export_include_dirs: [
239        "apex/include",
240    ],
241    target: {
242        windows: {
243            enabled: true,
244        },
245    },
246}
247
248cc_defaults {
249    name: "android_graphics_apex",
250    cflags: [
251        "-Wno-unused-parameter",
252        "-Wno-non-virtual-dtor",
253        "-Wno-maybe-uninitialized",
254        "-Wno-parentheses",
255        "-Wall",
256        "-Werror",
257        "-Wno-error=deprecated-declarations",
258        "-Wunused",
259        "-Wunreachable-code",
260    ],
261
262    cppflags: ["-Wno-conversion-null"],
263
264    srcs: [
265        "apex/android_matrix.cpp",
266        "apex/android_paint.cpp",
267        "apex/android_region.cpp",
268        "apex/properties.cpp",
269    ],
270
271    header_libs: ["android_graphics_apex_headers"],
272
273    target: {
274        android: {
275            srcs: [ // sources that depend on android only libraries
276                "apex/android_bitmap.cpp",
277                "apex/android_canvas.cpp",
278                "apex/jni_runtime.cpp",
279            ],
280        },
281        host: {
282            srcs: [
283                "apex/LayoutlibLoader.cpp",
284            ],
285        },
286    },
287}
288
289// ------------------------
290// Android Graphics JNI
291// ------------------------
292
293cc_library_headers {
294    name: "android_graphics_jni_headers",
295
296    host_supported: true,
297    export_include_dirs: [
298        "jni",
299    ],
300    target: {
301        windows: {
302            enabled: true,
303        },
304    },
305}
306
307cc_defaults {
308    name: "android_graphics_jni",
309    cflags: [
310        "-Wno-unused-parameter",
311        "-Wno-non-virtual-dtor",
312        "-Wno-maybe-uninitialized",
313        "-Wno-parentheses",
314
315        "-DGL_GLEXT_PROTOTYPES",
316        "-DEGL_EGLEXT_PROTOTYPES",
317
318        "-DU_USING_ICU_NAMESPACE=0",
319
320        "-Wall",
321        "-Werror",
322        "-Wno-error=deprecated-declarations",
323        "-Wunused",
324        "-Wunreachable-code",
325    ],
326
327    cppflags: ["-Wno-conversion-null"],
328
329    srcs: [
330        "jni/android_graphics_animation_NativeInterpolatorFactory.cpp",
331        "jni/android_graphics_animation_RenderNodeAnimator.cpp",
332        "jni/android_graphics_Canvas.cpp",
333        "jni/android_graphics_ColorSpace.cpp",
334        "jni/android_graphics_drawable_AnimatedVectorDrawable.cpp",
335        "jni/android_graphics_drawable_VectorDrawable.cpp",
336        "jni/android_graphics_HardwareRendererObserver.cpp",
337        "jni/android_graphics_Matrix.cpp",
338        "jni/android_graphics_Picture.cpp",
339        "jni/android_graphics_DisplayListCanvas.cpp",
340        "jni/android_graphics_Mesh.cpp",
341        "jni/android_graphics_RenderNode.cpp",
342        "jni/android_nio_utils.cpp",
343        "jni/android_util_PathParser.cpp",
344
345        "jni/Bitmap.cpp",
346        "jni/BufferUtils.cpp",
347        "jni/HardwareBufferHelpers.cpp",
348        "jni/BitmapFactory.cpp",
349        "jni/ByteBufferStreamAdaptor.cpp",
350        "jni/Camera.cpp",
351        "jni/CanvasProperty.cpp",
352        "jni/ColorFilter.cpp",
353        "jni/CreateJavaOutputStreamAdaptor.cpp",
354        "jni/FontFamily.cpp",
355        "jni/FontUtils.cpp",
356        "jni/Gainmap.cpp",
357        "jni/Graphics.cpp",
358        "jni/ImageDecoder.cpp",
359        "jni/Interpolator.cpp",
360        "jni/MeshSpecification.cpp",
361        "jni/MaskFilter.cpp",
362        "jni/NinePatch.cpp",
363        "jni/NinePatchPeeker.cpp",
364        "jni/Paint.cpp",
365        "jni/PaintFilter.cpp",
366        "jni/Path.cpp",
367        "jni/PathEffect.cpp",
368        "jni/PathIterator.cpp",
369        "jni/PathMeasure.cpp",
370        "jni/Picture.cpp",
371        "jni/Region.cpp",
372        "jni/ScopedParcel.cpp",
373        "jni/Shader.cpp",
374        "jni/RenderEffect.cpp",
375        "jni/Typeface.cpp",
376        "jni/Utils.cpp",
377        "jni/YuvToJpegEncoder.cpp",
378        "jni/fonts/Font.cpp",
379        "jni/fonts/FontFamily.cpp",
380        "jni/text/LineBreaker.cpp",
381        "jni/text/MeasuredText.cpp",
382        "jni/text/TextShaper.cpp",
383        "jni/text/GraphemeBreak.cpp",
384    ],
385
386    header_libs: [
387        "android_graphics_jni_headers",
388        "libnativewindow_headers",
389    ],
390
391    include_dirs: [
392        "external/skia/include/private",
393        "external/skia/src/codec",
394        "external/skia/src/core",
395    ],
396
397    shared_libs: [
398        "libbase",
399        "libcutils",
400        "libharfbuzz_ng",
401        "libimage_io",
402        "libjpeg",
403        "libultrahdr",
404        "liblog",
405        "libminikin",
406        "libz",
407    ],
408
409    static_libs: [
410        "libnativehelper_lazy",
411        "libziparchive_for_incfs",
412    ],
413
414    target: {
415        android: {
416            srcs: [ // sources that depend on android only libraries
417                "jni/AnimatedImageDrawable.cpp",
418                "jni/android_graphics_TextureLayer.cpp",
419                "jni/android_graphics_HardwareRenderer.cpp",
420                "jni/android_graphics_HardwareBufferRenderer.cpp",
421                "jni/BitmapRegionDecoder.cpp",
422                "jni/GIFMovie.cpp",
423                "jni/GraphicsStatsService.cpp",
424                "jni/Movie.cpp",
425                "jni/MovieImpl.cpp",
426                "jni/pdf/PdfDocument.cpp",
427                "jni/pdf/PdfEditor.cpp",
428                "jni/pdf/PdfRenderer.cpp",
429                "jni/pdf/PdfUtils.cpp",
430            ],
431            shared_libs: [
432                "libandroidfw",
433                "libbinder",
434                "libbinder_ndk",
435                "libmediandk",
436                "libnativedisplay",
437                "libnativewindow",
438                "libpdfium",
439            ],
440            static_libs: [
441                "libgif",
442                "libstatslog_hwui",
443                "libstatspull_lazy",
444                "libstatssocket_lazy",
445            ],
446        },
447        host: {
448            cflags: [
449                "-Wno-unused-const-variable",
450                "-Wno-unused-function",
451            ],
452            static_libs: [
453                "libandroidfw",
454            ],
455        },
456    },
457}
458
459cc_library_static {
460    name: "libstatslog_hwui",
461    generated_sources: ["statslog_hwui.cpp"],
462    generated_headers: ["statslog_hwui.h"],
463    export_generated_headers: ["statslog_hwui.h"],
464    static_libs: [
465        "libstatssocket_lazy",
466        "libstatspull_lazy",
467    ],
468}
469
470genrule {
471    name: "statslog_hwui.h",
472    tools: ["stats-log-api-gen"],
473    cmd: "$(location stats-log-api-gen) --header $(genDir)/statslog_hwui.h --module hwui" +
474        " --namespace android,uirenderer,stats",
475    out: [
476        "statslog_hwui.h",
477    ],
478}
479
480genrule {
481    name: "statslog_hwui.cpp",
482    tools: ["stats-log-api-gen"],
483    cmd: "$(location stats-log-api-gen) --cpp $(genDir)/statslog_hwui.cpp --module hwui" +
484        " --namespace android,uirenderer,stats --importHeader statslog_hwui.h",
485    out: [
486        "statslog_hwui.cpp",
487    ],
488}
489
490// ------------------------
491// library
492// ------------------------
493
494cc_library_headers {
495    name: "libhwui_internal_headers",
496
497    host_supported: true,
498    export_include_dirs: [
499        ".",
500    ],
501    header_libs: ["android_graphics_jni_headers"],
502    export_header_lib_headers: ["android_graphics_jni_headers"],
503}
504
505cc_defaults {
506    name: "libhwui_defaults",
507    defaults: ["hwui_defaults"],
508
509    whole_static_libs: ["libskia"],
510
511    srcs: [
512        "canvas/CanvasFrontend.cpp",
513        "canvas/CanvasOpBuffer.cpp",
514        "canvas/CanvasOpRasterizer.cpp",
515        "effects/StretchEffect.cpp",
516        "effects/GainmapRenderer.cpp",
517        "pipeline/skia/HolePunch.cpp",
518        "pipeline/skia/SkiaDisplayList.cpp",
519        "pipeline/skia/SkiaRecordingCanvas.cpp",
520        "pipeline/skia/StretchMask.cpp",
521        "pipeline/skia/RenderNodeDrawable.cpp",
522        "pipeline/skia/ReorderBarrierDrawables.cpp",
523        "pipeline/skia/TransformCanvas.cpp",
524        "renderthread/Frame.cpp",
525        "renderthread/RenderTask.cpp",
526        "renderthread/TimeLord.cpp",
527        "hwui/AnimatedImageDrawable.cpp",
528        "hwui/Bitmap.cpp",
529        "hwui/BlurDrawLooper.cpp",
530        "hwui/Canvas.cpp",
531        "hwui/ImageDecoder.cpp",
532        "hwui/MinikinSkia.cpp",
533        "hwui/MinikinUtils.cpp",
534        "hwui/PaintImpl.cpp",
535        "hwui/Typeface.cpp",
536        "utils/Blur.cpp",
537        "utils/Color.cpp",
538        "utils/LinearAllocator.cpp",
539        "utils/VectorDrawableUtils.cpp",
540        "AnimationContext.cpp",
541        "Animator.cpp",
542        "AnimatorManager.cpp",
543        "CanvasTransform.cpp",
544        "DamageAccumulator.cpp",
545        "Gainmap.cpp",
546        "Interpolator.cpp",
547        "LightingInfo.cpp",
548        "Matrix.cpp",
549        "Mesh.cpp",
550        "MemoryPolicy.cpp",
551        "PathParser.cpp",
552        "Properties.cpp",
553        "PropertyValuesAnimatorSet.cpp",
554        "PropertyValuesHolder.cpp",
555        "RecordingCanvas.cpp",
556        "RenderNode.cpp",
557        "RenderProperties.cpp",
558        "RootRenderNode.cpp",
559        "SkiaCanvas.cpp",
560        "SkiaInterpolator.cpp",
561        "Tonemapper.cpp",
562        "VectorDrawable.cpp",
563    ],
564
565    proto: {
566        export_proto_headers: true,
567    },
568
569    target: {
570        android: {
571            header_libs: [
572                "libandroid_headers_private",
573                "libtonemap_headers",
574            ],
575
576            srcs: [
577                "hwui/AnimatedImageThread.cpp",
578                "pipeline/skia/ATraceMemoryDump.cpp",
579                "pipeline/skia/GLFunctorDrawable.cpp",
580                "pipeline/skia/LayerDrawable.cpp",
581                "pipeline/skia/ShaderCache.cpp",
582                "pipeline/skia/SkiaMemoryTracer.cpp",
583                "pipeline/skia/SkiaOpenGLPipeline.cpp",
584                "pipeline/skia/SkiaPipeline.cpp",
585                "pipeline/skia/SkiaProfileRenderer.cpp",
586                "pipeline/skia/SkiaVulkanPipeline.cpp",
587                "pipeline/skia/VkFunctorDrawable.cpp",
588                "pipeline/skia/VkInteropFunctorDrawable.cpp",
589                "renderstate/RenderState.cpp",
590                "renderthread/CacheManager.cpp",
591                "renderthread/CanvasContext.cpp",
592                "renderthread/DrawFrameTask.cpp",
593                "renderthread/EglManager.cpp",
594                "renderthread/ReliableSurface.cpp",
595                "renderthread/RenderEffectCapabilityQuery.cpp",
596                "renderthread/VulkanManager.cpp",
597                "renderthread/VulkanSurface.cpp",
598                "renderthread/RenderProxy.cpp",
599                "renderthread/RenderThread.cpp",
600                "renderthread/HintSessionWrapper.cpp",
601                "service/GraphicsStatsService.cpp",
602                "thread/CommonPool.cpp",
603                "utils/GLUtils.cpp",
604                "utils/NdkUtils.cpp",
605                "utils/StringUtils.cpp",
606                "AutoBackendTextureRelease.cpp",
607                "DeferredLayerUpdater.cpp",
608                "DeviceInfo.cpp",
609                "FrameInfo.cpp",
610                "FrameInfoVisualizer.cpp",
611                "HardwareBitmapUploader.cpp",
612                "HWUIProperties.sysprop",
613                "JankTracker.cpp",
614                "FrameMetricsReporter.cpp",
615                "Layer.cpp",
616                "LayerUpdateQueue.cpp",
617                "ProfileData.cpp",
618                "ProfileDataContainer.cpp",
619                "Readback.cpp",
620                "TreeInfo.cpp",
621                "WebViewFunctorManager.cpp",
622                "protos/graphicsstats.proto",
623            ],
624
625            // Allow implicit fallthroughs in HardwareBitmapUploader.cpp until they are fixed.
626            cflags: ["-Wno-implicit-fallthrough"],
627        },
628        host: {
629            srcs: [
630                "utils/HostColorSpace.cpp",
631            ],
632            export_static_lib_headers: [
633                "libarect",
634            ],
635        },
636    },
637}
638
639cc_library {
640    name: "libhwui",
641    host_supported: true,
642    defaults: [
643        "libhwui_defaults",
644        "android_graphics_apex",
645        "android_graphics_jni",
646        "linker_hugepage_aligned",
647    ],
648    export_header_lib_headers: ["android_graphics_apex_headers"],
649    target: {
650        android: {
651            version_script: "libhwui.map.txt",
652        },
653    },
654    afdo: true,
655}
656
657cc_library_static {
658    name: "libhwui_static",
659    defaults: [
660        "libhwui_defaults",
661    ],
662}
663
664cc_defaults {
665    name: "hwui_test_defaults",
666    defaults: ["hwui_defaults"],
667    test_suites: ["general-tests"],
668    header_libs: ["libandroid_headers_private"],
669    target: {
670        android: {
671            shared_libs: [
672                "libgui",
673                "libui",
674            ],
675        },
676    },
677    srcs: [
678        "tests/common/scenes/*.cpp",
679        "tests/common/LeakChecker.cpp",
680        "tests/common/TestListViewSceneBase.cpp",
681        "tests/common/TestContext.cpp",
682        "tests/common/TestScene.cpp",
683        "tests/common/TestUtils.cpp",
684    ],
685}
686
687// ------------------------
688// unit tests
689// ------------------------
690
691cc_test {
692    name: "hwui_unit_tests",
693    defaults: [
694        "hwui_test_defaults",
695        "android_graphics_apex",
696        "android_graphics_jni",
697    ],
698
699    static_libs: [
700        "libgmock",
701        "libhwui_static",
702    ],
703    shared_libs: [
704        "libmemunreachable",
705    ],
706    srcs: [
707        "tests/unit/main.cpp",
708        "tests/unit/ABitmapTests.cpp",
709        "tests/unit/AutoBackendTextureReleaseTests.cpp",
710        "tests/unit/CacheManagerTests.cpp",
711        "tests/unit/CanvasContextTests.cpp",
712        "tests/unit/CanvasOpTests.cpp",
713        "tests/unit/CanvasFrontendTests.cpp",
714        "tests/unit/CommonPoolTests.cpp",
715        "tests/unit/DamageAccumulatorTests.cpp",
716        "tests/unit/DeferredLayerUpdaterTests.cpp",
717        "tests/unit/EglManagerTests.cpp",
718        "tests/unit/FatVectorTests.cpp",
719        "tests/unit/GraphicsStatsServiceTests.cpp",
720        "tests/unit/HintSessionWrapperTests.cpp",
721        "tests/unit/JankTrackerTests.cpp",
722        "tests/unit/FrameMetricsReporterTests.cpp",
723        "tests/unit/LayerUpdateQueueTests.cpp",
724        "tests/unit/LinearAllocatorTests.cpp",
725        "tests/unit/MatrixTests.cpp",
726        "tests/unit/OpBufferTests.cpp",
727        "tests/unit/PathInterpolatorTests.cpp",
728        "tests/unit/RenderEffectCapabilityQueryTests.cpp",
729        "tests/unit/RenderNodeDrawableTests.cpp",
730        "tests/unit/RenderNodeTests.cpp",
731        "tests/unit/RenderPropertiesTests.cpp",
732        "tests/unit/RenderThreadTests.cpp",
733        "tests/unit/ShaderCacheTests.cpp",
734        "tests/unit/SkiaBehaviorTests.cpp",
735        "tests/unit/SkiaDisplayListTests.cpp",
736        "tests/unit/SkiaPipelineTests.cpp",
737        "tests/unit/SkiaRenderPropertiesTests.cpp",
738        "tests/unit/SkiaCanvasTests.cpp",
739        "tests/unit/StretchEffectTests.cpp",
740        "tests/unit/StringUtilsTests.cpp",
741        "tests/unit/TestUtilsTests.cpp",
742        "tests/unit/ThreadBaseTests.cpp",
743        "tests/unit/TypefaceTests.cpp",
744        "tests/unit/VectorDrawableTests.cpp",
745        "tests/unit/WebViewFunctorManagerTests.cpp",
746    ],
747    data: [
748        ":hwuimicro",
749    ],
750}
751
752// ------------------------
753// Macro-bench app
754// ------------------------
755
756cc_benchmark {
757    name: "hwuimacro",
758    defaults: ["hwui_test_defaults"],
759
760    static_libs: ["libhwui"],
761    shared_libs: [
762        "libmemunreachable",
763    ],
764
765    srcs: [
766        "tests/macrobench/TestSceneRunner.cpp",
767        "tests/macrobench/main.cpp",
768    ],
769}
770
771// ------------------------
772// Micro-bench app
773// ---------------------
774
775cc_benchmark {
776    name: "hwuimicro",
777    defaults: ["hwui_test_defaults"],
778
779    static_libs: ["libhwui_static"],
780    shared_libs: [
781        "libmemunreachable",
782    ],
783
784    srcs: [
785        "tests/microbench/main.cpp",
786        "tests/microbench/CanvasOpBench.cpp",
787        "tests/microbench/DisplayListCanvasBench.cpp",
788        "tests/microbench/LinearAllocatorBench.cpp",
789        "tests/microbench/PathParserBench.cpp",
790        "tests/microbench/RenderNodeBench.cpp",
791    ],
792}
793