diff --git a/DEPS b/DEPS index 19093ed17692e..023921c87b1d3 100644 --- a/DEPS +++ b/DEPS @@ -18,7 +18,7 @@ vars = { 'llvm_git': 'https://llvm.googlesource.com', # OCMock is for testing only so there is no google clone 'ocmock_git': 'https://github.com/erikdoe/ocmock.git', - 'skia_revision': 'ebc149cff431e22c6452d7f4ce5e5749d37d899c', + 'skia_revision': '56b68ce6196c395f24f4ac17ccd18ee03111cbf8', # WARNING: DO NOT EDIT canvaskit_cipd_instance MANUALLY # See `lib/web_ui/README.md` for how to roll CanvasKit to a new version. @@ -53,7 +53,7 @@ vars = { # Dart is: https://github.com/dart-lang/sdk/blob/main/DEPS # You can use //tools/dart/create_updated_flutter_deps.py to produce # updated revision list of existing dependencies. - 'dart_revision': 'b95f6531c726b454ed57eaa69319cf704649cdef', + 'dart_revision': 'ade4dae923f3e5ce8846072c4bf4c98b910cd905', # WARNING: DO NOT EDIT MANUALLY # The lines between blank lines above and below are generated by a script. See create_updated_flutter_deps.py @@ -332,7 +332,7 @@ deps = { Var('chromium_git') + '/external/github.com/WebAssembly/binaryen.git@b9b5f162ca8bf5b899ff0f0351491d7d403d7ed9', 'src/third_party/dart/third_party/devtools': - {'packages': [{'version': 'git_revision:99dca813aaa7fa23ccd6fe3901ac7665e96db3cb', 'package': 'dart/third_party/flutter/devtools'}], 'dep_type': 'cipd'}, + {'dep_type': 'cipd', 'packages': [{'package': 'dart/third_party/flutter/devtools', 'version': 'git_revision:99dca813aaa7fa23ccd6fe3901ac7665e96db3cb'}]}, 'src/third_party/dart/third_party/pkg/args': Var('dart_git') + '/args.git@da56b18ebcb600e050bf57b9c1103b1d2a9fb2ff', @@ -407,7 +407,7 @@ deps = { Var('dart_git') + '/leak_tracker.git@85bd7fb23bfdfdcc66390e8d6ae81aafd65fe51e', 'src/third_party/dart/third_party/pkg/linter': - Var('dart_git') + '/linter.git@e8c878360595c1d268d93f54c09bc843815a42d7', + Var('dart_git') + '/linter.git@655de5d0dc30cdd1df9ce4cd16bd7489106d987f', 'src/third_party/dart/third_party/pkg/logging': Var('dart_git') + '/logging.git@521498757ed3eeae151c2d4796404e8947baa04c', @@ -506,7 +506,7 @@ deps = { Var('dart_git') + '/yaml_edit.git' + '@' + Var('dart_yaml_edit_rev'), 'src/third_party/dart/tools/sdks/dart-sdk': - {'packages': [{'version': 'version:3.1.0-155.0.dev', 'package': 'dart/dart-sdk/${{platform}}'}], 'dep_type': 'cipd'}, + {'dep_type': 'cipd', 'packages': [{'package': 'dart/dart-sdk/${{platform}}', 'version': 'version:3.1.0-155.0.dev'}]}, # WARNING: end of dart dependencies list that is cleaned up automatically - see create_updated_flutter_deps.py. @@ -889,7 +889,7 @@ deps = { 'packages': [ { 'package': 'fuchsia/sdk/core/mac-amd64', - 'version': '0fvk838jTDNQ_l43kj5Vz-3ZA1JntonkaLZ8UJxQSaUC' + 'version': '3C7P0w8ySmtqpyi3SZWDcHJ9zdLC09Fo45XjXGjJ1xQC' } ], 'condition': 'host_os == "mac" and not download_fuchsia_sdk', @@ -899,7 +899,7 @@ deps = { 'packages': [ { 'package': 'fuchsia/sdk/core/linux-amd64', - 'version': '1STsUj0X5YgpiSNEbqRCus0XRGJ-uLoTCxmjIVMy_EoC' + 'version': 'xBJq6PsO5ebblODMegtfmB5Q-Kaghtn_K0m3pR3dU60C' } ], 'condition': 'host_os == "linux" and not download_fuchsia_sdk', diff --git a/ci/licenses_golden/excluded_files b/ci/licenses_golden/excluded_files index aba18f16964f1..844ae7972e8b1 100644 --- a/ci/licenses_golden/excluded_files +++ b/ci/licenses_golden/excluded_files @@ -74,7 +74,6 @@ ../../../flutter/flow/layers/transform_layer_unittests.cc ../../../flutter/flow/mutators_stack_unittests.cc ../../../flutter/flow/raster_cache_unittests.cc -../../../flutter/flow/rtree_unittests.cc ../../../flutter/flow/skia_gpu_object_unittests.cc ../../../flutter/flow/surface_frame_unittests.cc ../../../flutter/flow/testing @@ -212,7 +211,6 @@ ../../../flutter/runtime/no_dart_plugin_registrant_unittests.cc ../../../flutter/runtime/type_conversions_unittests.cc ../../../flutter/shell/common/animator_unittests.cc -../../../flutter/shell/common/canvas_spy_unittests.cc ../../../flutter/shell/common/context_options_unittests.cc ../../../flutter/shell/common/dl_op_spy_unittests.cc ../../../flutter/shell/common/engine_unittests.cc @@ -292,6 +290,7 @@ ../../../flutter/shell/platform/fuchsia/flutter/accessibility_bridge_unittest.cc ../../../flutter/shell/platform/fuchsia/flutter/build/asset_package.py ../../../flutter/shell/platform/fuchsia/flutter/build/gen_debug_wrapper_main.py +../../../flutter/shell/platform/fuchsia/flutter/canvas_spy_unittests.cc ../../../flutter/shell/platform/fuchsia/flutter/component_v2_unittest.cc ../../../flutter/shell/platform/fuchsia/flutter/focus_delegate_unittests.cc ../../../flutter/shell/platform/fuchsia/flutter/fuchsia_intl_unittest.cc @@ -303,6 +302,7 @@ ../../../flutter/shell/platform/fuchsia/flutter/platform_view_unittest.cc ../../../flutter/shell/platform/fuchsia/flutter/pointer_delegate_unittests.cc ../../../flutter/shell/platform/fuchsia/flutter/pointer_injector_delegate_unittest.cc +../../../flutter/shell/platform/fuchsia/flutter/rtree_unittests.cc ../../../flutter/shell/platform/fuchsia/flutter/runner_tzdata_missing_unittest.cc ../../../flutter/shell/platform/fuchsia/flutter/runner_tzdata_unittest.cc ../../../flutter/shell/platform/fuchsia/flutter/tests @@ -449,10 +449,7 @@ ../../../fuchsia/sdk/linux/arch/arm64/sysroot/dist/lib/ld.so.1 ../../../fuchsia/sdk/linux/arch/x64/sysroot/dist/lib/asan/ld.so.1 ../../../fuchsia/sdk/linux/arch/x64/sysroot/dist/lib/ld.so.1 -../../../fuchsia/sdk/linux/dart/fidl/meta.json -../../../fuchsia/sdk/linux/dart/fuchsia/meta.json ../../../fuchsia/sdk/linux/dart/sl4f/meta.json -../../../fuchsia/sdk/linux/dart/zircon/meta.json ../../../fuchsia/sdk/linux/data/config/symbol_index/meta.json ../../../fuchsia/sdk/linux/docs ../../../fuchsia/sdk/linux/fidl/fuchsia.accessibility.gesture/meta.json diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 49f5af8529f2a..8d1d6795f8fd5 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -841,8 +841,6 @@ ORIGIN: ../../../flutter/flow/raster_cache_key.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/flow/raster_cache_key.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/flow/raster_cache_util.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/flow/raster_cache_util.h + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/flow/rtree.cc + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/flow/rtree.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/flow/skia_gpu_object.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/flow/surface.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/flow/surface.h + ../../../flutter/LICENSE @@ -1564,6 +1562,8 @@ ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/texture_vk.h + ../../. ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/vertex_descriptor_vk.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/vertex_descriptor_vk.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/vk.h + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/vma.cc + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/vma.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/renderer/blit_command.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/renderer/blit_command.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/renderer/blit_pass.cc + ../../../flutter/LICENSE @@ -2188,8 +2188,6 @@ ORIGIN: ../../../flutter/runtime/test_font_data.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/runtime/test_font_data.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/common/animator.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/common/animator.h + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/common/canvas_spy.cc + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/common/canvas_spy.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/common/context_options.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/common/context_options.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/common/dart_native_benchmarks.cc + ../../../flutter/LICENSE @@ -2826,6 +2824,8 @@ ORIGIN: ../../../flutter/shell/platform/embedder/embedder_surface.cc + ../../../ ORIGIN: ../../../flutter/shell/platform/embedder/embedder_surface.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/embedder/embedder_surface_gl.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/embedder/embedder_surface_gl.h + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/shell/platform/embedder/embedder_surface_gl_impeller.cc + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/shell/platform/embedder/embedder_surface_gl_impeller.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/embedder/embedder_surface_metal.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/embedder/embedder_surface_metal.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/embedder/embedder_surface_metal_impeller.h + ../../../flutter/LICENSE @@ -2903,6 +2903,8 @@ ORIGIN: ../../../flutter/shell/platform/fuchsia/dart_runner/service_isolate.h + ORIGIN: ../../../flutter/shell/platform/fuchsia/dart_runner/vmservice/empty.dart + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/fuchsia/flutter/accessibility_bridge.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/fuchsia/flutter/accessibility_bridge.h + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/shell/platform/fuchsia/flutter/canvas_spy.cc + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/shell/platform/fuchsia/flutter/canvas_spy.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/fuchsia/flutter/component_v2.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/fuchsia/flutter/component_v2.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/fuchsia/flutter/engine.cc + ../../../flutter/LICENSE @@ -2947,6 +2949,8 @@ ORIGIN: ../../../flutter/shell/platform/fuchsia/flutter/pointer_delegate.h + ../ ORIGIN: ../../../flutter/shell/platform/fuchsia/flutter/pointer_injector_delegate.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/fuchsia/flutter/pointer_injector_delegate.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/fuchsia/flutter/program_metadata.h + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/shell/platform/fuchsia/flutter/rtree.cc + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/shell/platform/fuchsia/flutter/rtree.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/fuchsia/flutter/runner.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/fuchsia/flutter/runner.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/fuchsia/flutter/software_surface.cc + ../../../flutter/LICENSE @@ -3528,8 +3532,6 @@ FILE: ../../../flutter/flow/raster_cache_key.cc FILE: ../../../flutter/flow/raster_cache_key.h FILE: ../../../flutter/flow/raster_cache_util.cc FILE: ../../../flutter/flow/raster_cache_util.h -FILE: ../../../flutter/flow/rtree.cc -FILE: ../../../flutter/flow/rtree.h FILE: ../../../flutter/flow/skia_gpu_object.h FILE: ../../../flutter/flow/surface.cc FILE: ../../../flutter/flow/surface.h @@ -4252,6 +4254,8 @@ FILE: ../../../flutter/impeller/renderer/backend/vulkan/texture_vk.h FILE: ../../../flutter/impeller/renderer/backend/vulkan/vertex_descriptor_vk.cc FILE: ../../../flutter/impeller/renderer/backend/vulkan/vertex_descriptor_vk.h FILE: ../../../flutter/impeller/renderer/backend/vulkan/vk.h +FILE: ../../../flutter/impeller/renderer/backend/vulkan/vma.cc +FILE: ../../../flutter/impeller/renderer/backend/vulkan/vma.h FILE: ../../../flutter/impeller/renderer/blit_command.cc FILE: ../../../flutter/impeller/renderer/blit_command.h FILE: ../../../flutter/impeller/renderer/blit_pass.cc @@ -4878,8 +4882,6 @@ FILE: ../../../flutter/runtime/test_font_data.cc FILE: ../../../flutter/runtime/test_font_data.h FILE: ../../../flutter/shell/common/animator.cc FILE: ../../../flutter/shell/common/animator.h -FILE: ../../../flutter/shell/common/canvas_spy.cc -FILE: ../../../flutter/shell/common/canvas_spy.h FILE: ../../../flutter/shell/common/context_options.cc FILE: ../../../flutter/shell/common/context_options.h FILE: ../../../flutter/shell/common/dart_native_benchmarks.cc @@ -5530,6 +5532,8 @@ FILE: ../../../flutter/shell/platform/embedder/embedder_surface.cc FILE: ../../../flutter/shell/platform/embedder/embedder_surface.h FILE: ../../../flutter/shell/platform/embedder/embedder_surface_gl.cc FILE: ../../../flutter/shell/platform/embedder/embedder_surface_gl.h +FILE: ../../../flutter/shell/platform/embedder/embedder_surface_gl_impeller.cc +FILE: ../../../flutter/shell/platform/embedder/embedder_surface_gl_impeller.h FILE: ../../../flutter/shell/platform/embedder/embedder_surface_metal.h FILE: ../../../flutter/shell/platform/embedder/embedder_surface_metal.mm FILE: ../../../flutter/shell/platform/embedder/embedder_surface_metal_impeller.h @@ -5610,6 +5614,8 @@ FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/service_isolate.h FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/vmservice/empty.dart FILE: ../../../flutter/shell/platform/fuchsia/flutter/accessibility_bridge.cc FILE: ../../../flutter/shell/platform/fuchsia/flutter/accessibility_bridge.h +FILE: ../../../flutter/shell/platform/fuchsia/flutter/canvas_spy.cc +FILE: ../../../flutter/shell/platform/fuchsia/flutter/canvas_spy.h FILE: ../../../flutter/shell/platform/fuchsia/flutter/component_v2.cc FILE: ../../../flutter/shell/platform/fuchsia/flutter/component_v2.h FILE: ../../../flutter/shell/platform/fuchsia/flutter/engine.cc @@ -5654,6 +5660,8 @@ FILE: ../../../flutter/shell/platform/fuchsia/flutter/pointer_delegate.h FILE: ../../../flutter/shell/platform/fuchsia/flutter/pointer_injector_delegate.cc FILE: ../../../flutter/shell/platform/fuchsia/flutter/pointer_injector_delegate.h FILE: ../../../flutter/shell/platform/fuchsia/flutter/program_metadata.h +FILE: ../../../flutter/shell/platform/fuchsia/flutter/rtree.cc +FILE: ../../../flutter/shell/platform/fuchsia/flutter/rtree.h FILE: ../../../flutter/shell/platform/fuchsia/flutter/runner.cc FILE: ../../../flutter/shell/platform/fuchsia/flutter/runner.h FILE: ../../../flutter/shell/platform/fuchsia/flutter/software_surface.cc diff --git a/ci/licenses_golden/licenses_fuchsia b/ci/licenses_golden/licenses_fuchsia index 9b5013d4cf592..44a296c90be71 100644 --- a/ci/licenses_golden/licenses_fuchsia +++ b/ci/licenses_golden/licenses_fuchsia @@ -1,4 +1,4 @@ -Signature: 68b7ea840cc0ec7d126a53cdf00bd955 +Signature: ad98b304d04164e717245b5c284794fb ==================================================================================================== LIBRARY: fuchsia_sdk @@ -354,7 +354,6 @@ FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/lib/libm.so FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/lib/libpthread.so FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/lib/librt.so FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/lib/libzircon.so -FILE: ../../../fuchsia/sdk/linux/dart/zircon/lib/src/fakes/handle_disposition.dart FILE: ../../../fuchsia/sdk/linux/data/config/symbol_index/config.json FILE: ../../../fuchsia/sdk/linux/pkg/async-default/async-default.ifs FILE: ../../../fuchsia/sdk/linux/pkg/fdio/fdio.ifs @@ -646,7 +645,6 @@ ORIGIN: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/prof ORIGIN: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/resource.h + ../../../fuchsia/sdk/linux/LICENSE ORIGIN: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/types.h + ../../../fuchsia/sdk/linux/LICENSE ORIGIN: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/types.h + ../../../fuchsia/sdk/linux/LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/interface.dart + ../../../fuchsia/sdk/linux/LICENSE ORIGIN: ../../../fuchsia/sdk/linux/fidl/fuchsia.component.runner/component_runner.fidl + ../../../fuchsia/sdk/linux/LICENSE ORIGIN: ../../../fuchsia/sdk/linux/fidl/fuchsia.fonts/font_provider.fidl + ../../../fuchsia/sdk/linux/LICENSE ORIGIN: ../../../fuchsia/sdk/linux/fidl/fuchsia.math/math.fidl + ../../../fuchsia/sdk/linux/LICENSE @@ -736,7 +734,6 @@ FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/profil FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/resource.h FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/types.h FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/types.h -FILE: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/interface.dart FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.component.runner/component_runner.fidl FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.fonts/font_provider.fidl FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.math/math.fidl @@ -1082,47 +1079,6 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ==================================================================================================== -==================================================================================================== -LIBRARY: fuchsia_sdk -ORIGIN: ../../../fuchsia/sdk/linux/dart/fidl/lib/fidl.dart + ../../../LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/fuchsia/lib/fuchsia.dart + ../../../LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/zircon/lib/src/fakes/zircon_fakes.dart + ../../../LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/zircon/lib/zircon.dart + ../../../LICENSE -TYPE: LicenseType.bsd -FILE: ../../../fuchsia/sdk/linux/dart/fidl/lib/fidl.dart -FILE: ../../../fuchsia/sdk/linux/dart/fuchsia/lib/fuchsia.dart -FILE: ../../../fuchsia/sdk/linux/dart/zircon/lib/src/fakes/zircon_fakes.dart -FILE: ../../../fuchsia/sdk/linux/dart/zircon/lib/zircon.dart ----------------------------------------------------------------------------------------------------- -Copyright 2018 The Chromium Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -==================================================================================================== - ==================================================================================================== LIBRARY: fuchsia_sdk ORIGIN: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/dlfcn.h + ../../../fuchsia/sdk/linux/LICENSE @@ -1139,29 +1095,6 @@ ORIGIN: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/limits.h + .. ORIGIN: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/smc.h + ../../../fuchsia/sdk/linux/LICENSE ORIGIN: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/threads.h + ../../../fuchsia/sdk/linux/LICENSE ORIGIN: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/time.h + ../../../fuchsia/sdk/linux/LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/codec.dart + ../../../fuchsia/sdk/linux/LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/enum.dart + ../../../fuchsia/sdk/linux/LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/error.dart + ../../../fuchsia/sdk/linux/LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/hash_codes.dart + ../../../fuchsia/sdk/linux/LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/interface_async.dart + ../../../fuchsia/sdk/linux/LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/message.dart + ../../../fuchsia/sdk/linux/LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/struct.dart + ../../../fuchsia/sdk/linux/LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/table.dart + ../../../fuchsia/sdk/linux/LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/types.dart + ../../../fuchsia/sdk/linux/LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/unknown_data.dart + ../../../fuchsia/sdk/linux/LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/fuchsia/lib/src/fakes/fuchsia_fakes.dart + ../../../fuchsia/sdk/linux/LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/zircon/lib/src/channel.dart + ../../../fuchsia/sdk/linux/LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/zircon/lib/src/channel_reader.dart + ../../../fuchsia/sdk/linux/LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/zircon/lib/src/constants.dart + ../../../fuchsia/sdk/linux/LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/zircon/lib/src/errors.dart + ../../../fuchsia/sdk/linux/LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/zircon/lib/src/eventpair.dart + ../../../fuchsia/sdk/linux/LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/zircon/lib/src/fakes/handle.dart + ../../../fuchsia/sdk/linux/LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/zircon/lib/src/fakes/handle_waiter.dart + ../../../fuchsia/sdk/linux/LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/zircon/lib/src/fakes/system.dart + ../../../fuchsia/sdk/linux/LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/zircon/lib/src/handle_wrapper.dart + ../../../fuchsia/sdk/linux/LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/zircon/lib/src/socket.dart + ../../../fuchsia/sdk/linux/LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/zircon/lib/src/socket_reader.dart + ../../../fuchsia/sdk/linux/LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/zircon/lib/src/vmo.dart + ../../../fuchsia/sdk/linux/LICENSE ORIGIN: ../../../fuchsia/sdk/linux/fidl/fuchsia.auth/attestation_signer.fidl + ../../../fuchsia/sdk/linux/LICENSE ORIGIN: ../../../fuchsia/sdk/linux/fidl/fuchsia.auth/common.fidl + ../../../fuchsia/sdk/linux/LICENSE ORIGIN: ../../../fuchsia/sdk/linux/fidl/fuchsia.bluetooth.gatt/types.fidl + ../../../fuchsia/sdk/linux/LICENSE @@ -1374,29 +1307,6 @@ FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/limits.h FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/smc.h FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/threads.h FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/time.h -FILE: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/codec.dart -FILE: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/enum.dart -FILE: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/error.dart -FILE: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/hash_codes.dart -FILE: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/interface_async.dart -FILE: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/message.dart -FILE: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/struct.dart -FILE: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/table.dart -FILE: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/types.dart -FILE: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/unknown_data.dart -FILE: ../../../fuchsia/sdk/linux/dart/fuchsia/lib/src/fakes/fuchsia_fakes.dart -FILE: ../../../fuchsia/sdk/linux/dart/zircon/lib/src/channel.dart -FILE: ../../../fuchsia/sdk/linux/dart/zircon/lib/src/channel_reader.dart -FILE: ../../../fuchsia/sdk/linux/dart/zircon/lib/src/constants.dart -FILE: ../../../fuchsia/sdk/linux/dart/zircon/lib/src/errors.dart -FILE: ../../../fuchsia/sdk/linux/dart/zircon/lib/src/eventpair.dart -FILE: ../../../fuchsia/sdk/linux/dart/zircon/lib/src/fakes/handle.dart -FILE: ../../../fuchsia/sdk/linux/dart/zircon/lib/src/fakes/handle_waiter.dart -FILE: ../../../fuchsia/sdk/linux/dart/zircon/lib/src/fakes/system.dart -FILE: ../../../fuchsia/sdk/linux/dart/zircon/lib/src/handle_wrapper.dart -FILE: ../../../fuchsia/sdk/linux/dart/zircon/lib/src/socket.dart -FILE: ../../../fuchsia/sdk/linux/dart/zircon/lib/src/socket_reader.dart -FILE: ../../../fuchsia/sdk/linux/dart/zircon/lib/src/vmo.dart FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.auth/attestation_signer.fidl FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.auth/common.fidl FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.bluetooth.gatt/types.fidl @@ -2010,7 +1920,6 @@ FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/lib/libm.so FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/lib/libpthread.so FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/lib/librt.so FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/lib/libzircon.so -FILE: ../../../fuchsia/sdk/linux/dart/zircon/lib/src/fakes/handle_disposition.dart FILE: ../../../fuchsia/sdk/linux/data/config/symbol_index/config.json FILE: ../../../fuchsia/sdk/linux/pkg/async-default/async-default.ifs FILE: ../../../fuchsia/sdk/linux/pkg/fdio/fdio.ifs @@ -2071,8 +1980,6 @@ ORIGIN: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/lookup.h + .. ORIGIN: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/clock.h + ../../../fuchsia/sdk/linux/LICENSE ORIGIN: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/scheduler.h + ../../../fuchsia/sdk/linux/LICENSE ORIGIN: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/utc.h + ../../../fuchsia/sdk/linux/LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/bits.dart + ../../../fuchsia/sdk/linux/LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/union.dart + ../../../fuchsia/sdk/linux/LICENSE ORIGIN: ../../../fuchsia/sdk/linux/dart/sl4f/lib/sl4f.dart + ../../../fuchsia/sdk/linux/LICENSE ORIGIN: ../../../fuchsia/sdk/linux/dart/sl4f/lib/src/audio.dart + ../../../fuchsia/sdk/linux/LICENSE ORIGIN: ../../../fuchsia/sdk/linux/dart/sl4f/lib/src/device_log.dart + ../../../fuchsia/sdk/linux/LICENSE @@ -2367,8 +2274,6 @@ FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/lookup.h FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/clock.h FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/scheduler.h FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/utc.h -FILE: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/bits.dart -FILE: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/union.dart FILE: ../../../fuchsia/sdk/linux/dart/sl4f/lib/sl4f.dart FILE: ../../../fuchsia/sdk/linux/dart/sl4f/lib/src/audio.dart FILE: ../../../fuchsia/sdk/linux/dart/sl4f/lib/src/device_log.dart @@ -3031,8 +2936,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. LIBRARY: fuchsia_sdk ORIGIN: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/availability.h + ../../../fuchsia/sdk/linux/LICENSE ORIGIN: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/availability.h + ../../../fuchsia/sdk/linux/LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/codegen_common.dart + ../../../fuchsia/sdk/linux/LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/wire_format.dart + ../../../fuchsia/sdk/linux/LICENSE ORIGIN: ../../../fuchsia/sdk/linux/dart/sl4f/lib/src/trace_processing/metrics/camera_metrics.dart + ../../../fuchsia/sdk/linux/LICENSE ORIGIN: ../../../fuchsia/sdk/linux/dart/sl4f/lib/src/trace_processing/metrics/flatland_latency.dart + ../../../fuchsia/sdk/linux/LICENSE ORIGIN: ../../../fuchsia/sdk/linux/dart/sl4f/lib/src/virtual_camera.dart + ../../../fuchsia/sdk/linux/LICENSE @@ -3160,8 +3063,6 @@ ORIGIN: ../../../fuchsia/sdk/linux/pkg/zx/status_string.cc + ../../../fuchsia/sd TYPE: LicenseType.bsd FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/availability.h FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/availability.h -FILE: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/codegen_common.dart -FILE: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/wire_format.dart FILE: ../../../fuchsia/sdk/linux/dart/sl4f/lib/src/trace_processing/metrics/camera_metrics.dart FILE: ../../../fuchsia/sdk/linux/dart/sl4f/lib/src/trace_processing/metrics/flatland_latency.dart FILE: ../../../fuchsia/sdk/linux/dart/sl4f/lib/src/virtual_camera.dart @@ -3319,7 +3220,6 @@ ORIGIN: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/errors.h + ORIGIN: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/syscalls/internal/cdecls.inc + ../../../fuchsia/sdk/linux/LICENSE ORIGIN: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/errors.h + ../../../fuchsia/sdk/linux/LICENSE ORIGIN: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/internal/cdecls.inc + ../../../fuchsia/sdk/linux/LICENSE -ORIGIN: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/optional_nullable.dart + ../../../fuchsia/sdk/linux/LICENSE ORIGIN: ../../../fuchsia/sdk/linux/dart/sl4f/lib/src/performance_publish.dart + ../../../fuchsia/sdk/linux/LICENSE ORIGIN: ../../../fuchsia/sdk/linux/dart/sl4f/lib/src/trace_processing/metrics/power_metrics.dart + ../../../fuchsia/sdk/linux/LICENSE ORIGIN: ../../../fuchsia/sdk/linux/fidl/fuchsia.accessibility.semantics/overview.fidl + ../../../fuchsia/sdk/linux/LICENSE @@ -3543,7 +3443,6 @@ FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/errors.h FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/syscalls/internal/cdecls.inc FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/errors.h FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/internal/cdecls.inc -FILE: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/optional_nullable.dart FILE: ../../../fuchsia/sdk/linux/dart/sl4f/lib/src/performance_publish.dart FILE: ../../../fuchsia/sdk/linux/dart/sl4f/lib/src/trace_processing/metrics/power_metrics.dart FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.accessibility.semantics/overview.fidl @@ -4241,7 +4140,6 @@ FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/lib/libm.so FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/lib/libpthread.so FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/lib/librt.so FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/lib/libzircon.so -FILE: ../../../fuchsia/sdk/linux/dart/zircon/lib/src/fakes/handle_disposition.dart FILE: ../../../fuchsia/sdk/linux/data/config/symbol_index/config.json FILE: ../../../fuchsia/sdk/linux/pkg/async-default/async-default.ifs FILE: ../../../fuchsia/sdk/linux/pkg/fdio/fdio.ifs @@ -4391,4 +4289,4 @@ permissive licensing, and of not having licensing issues being an obstacle to adoption, that text has been removed. ==================================================================================================== -Total license count: 14 +Total license count: 13 diff --git a/ci/licenses_golden/licenses_skia b/ci/licenses_golden/licenses_skia index bc56434615d09..0134b4a895dfb 100644 --- a/ci/licenses_golden/licenses_skia +++ b/ci/licenses_golden/licenses_skia @@ -1,4 +1,4 @@ -Signature: 3047a4ed811e45763b53b21f0b2da85e +Signature: 63efa44b47bf0eddd988a322acd5d813 ==================================================================================================== LIBRARY: etc1 @@ -2371,7 +2371,6 @@ ORIGIN: ../../../third_party/skia/src/core/SkValidationUtils.h + ../../../third_ ORIGIN: ../../../third_party/skia/src/effects/imagefilters/SkComposeImageFilter.cpp + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/src/effects/imagefilters/SkDisplacementMapImageFilter.cpp + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/src/effects/imagefilters/SkDropShadowImageFilter.cpp + ../../../third_party/skia/LICENSE -ORIGIN: ../../../third_party/skia/src/effects/imagefilters/SkTileImageFilter.cpp + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/src/gpu/Blend.h + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/src/gpu/RectanizerSkyline.cpp + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/src/gpu/ganesh/GrCaps.h + ../../../third_party/skia/LICENSE @@ -2511,7 +2510,6 @@ FILE: ../../../third_party/skia/src/core/SkValidationUtils.h FILE: ../../../third_party/skia/src/effects/imagefilters/SkComposeImageFilter.cpp FILE: ../../../third_party/skia/src/effects/imagefilters/SkDisplacementMapImageFilter.cpp FILE: ../../../third_party/skia/src/effects/imagefilters/SkDropShadowImageFilter.cpp -FILE: ../../../third_party/skia/src/effects/imagefilters/SkTileImageFilter.cpp FILE: ../../../third_party/skia/src/gpu/Blend.h FILE: ../../../third_party/skia/src/gpu/RectanizerSkyline.cpp FILE: ../../../third_party/skia/src/gpu/ganesh/GrCaps.h diff --git a/ci/licenses_golden/licenses_third_party b/ci/licenses_golden/licenses_third_party index bdfa1df6c10af..8c36a1b4004e3 100644 --- a/ci/licenses_golden/licenses_third_party +++ b/ci/licenses_golden/licenses_third_party @@ -1,4 +1,4 @@ -Signature: 2da4bd9577ddf4b32a27495b12806add +Signature: 7b9215d39a578c8eec3c1473fcc3452a ==================================================================================================== LIBRARY: angle diff --git a/flow/BUILD.gn b/flow/BUILD.gn index 560b067e7e22b..0c3e8a3466a12 100644 --- a/flow/BUILD.gn +++ b/flow/BUILD.gn @@ -76,8 +76,6 @@ source_set("flow") { "raster_cache_key.h", "raster_cache_util.cc", "raster_cache_util.h", - "rtree.cc", - "rtree.h", "skia_gpu_object.h", "surface.cc", "surface.h", @@ -171,7 +169,6 @@ if (enable_unittests) { "layers/transform_layer_unittests.cc", "mutators_stack_unittests.cc", "raster_cache_unittests.cc", - "rtree_unittests.cc", "skia_gpu_object_unittests.cc", "surface_frame_unittests.cc", "testing/mock_layer_unittests.cc", diff --git a/flow/embedded_views.h b/flow/embedded_views.h index 99e33b1d6808e..6985c37e5b8c0 100644 --- a/flow/embedded_views.h +++ b/flow/embedded_views.h @@ -10,7 +10,6 @@ #include "flutter/display_list/dl_builder.h" #include "flutter/display_list/skia/dl_sk_canvas.h" -#include "flutter/flow/rtree.h" #include "flutter/flow/surface_frame.h" #include "flutter/fml/memory/ref_counted.h" #include "flutter/fml/raster_thread_merger.h" diff --git a/flow/layers/transform_layer.cc b/flow/layers/transform_layer.cc index 18504d5a45388..ec371a06099ec 100644 --- a/flow/layers/transform_layer.cc +++ b/flow/layers/transform_layer.cc @@ -46,6 +46,21 @@ void TransformLayer::Preroll(PrerollContext* context) { SkRect child_paint_bounds = SkRect::MakeEmpty(); PrerollChildren(context, &child_paint_bounds); + // We convert to a 3x3 matrix here primarily because the SkM44 object + // does not support a mapRect operation. + // https://bugs.chromium.org/p/skia/issues/detail?id=11720&q=mapRect&can=2 + // + // All geometry is X,Y only which means the 3rd row of the 4x4 matrix + // is ignored and the output of the 3rd column is also ignored. + // So we can transform the rectangle using just the 3x3 SkMatrix + // equivalent without any loss of information. + // + // Performance consideration: + // Skia has an internal mapRect for their SkM44 object that is faster + // than what SkMatrix does when it has perspective elements. But SkMatrix + // is otherwise optimal for non-perspective matrices. If SkM44 ever exposes + // a mapRect operation, or if SkMatrix ever optimizes its handling of + // the perspective elements, this issue will become moot. transform_.asM33().mapRect(&child_paint_bounds); set_paint_bounds(child_paint_bounds); } diff --git a/impeller/core/allocator.cc b/impeller/core/allocator.cc index be380b671ec27..075a738fe5b4f 100644 --- a/impeller/core/allocator.cc +++ b/impeller/core/allocator.cc @@ -61,4 +61,6 @@ uint16_t Allocator::MinimumBytesPerRow(PixelFormat format) const { return BytesPerPixelForPixelFormat(format); } +void Allocator::DidAcquireSurfaceFrame() {} + } // namespace impeller diff --git a/impeller/core/allocator.h b/impeller/core/allocator.h index 25b3dae07a22c..62b86b72b047f 100644 --- a/impeller/core/allocator.h +++ b/impeller/core/allocator.h @@ -45,6 +45,10 @@ class Allocator { virtual ISize GetMaxTextureSizeSupported() const = 0; + /// @brief Increment an internal frame used to cycle through a ring buffer of + /// allocation pools. + virtual void DidAcquireSurfaceFrame(); + protected: Allocator(); diff --git a/impeller/core/formats.h b/impeller/core/formats.h index ff031d96008b1..b8cb738aa293d 100644 --- a/impeller/core/formats.h +++ b/impeller/core/formats.h @@ -546,6 +546,7 @@ struct StencilAttachmentDescriptor { /// Indicates what to do when both the stencil and depth tests pass. /// StencilOperation depth_stencil_pass = StencilOperation::kKeep; + //---------------------------------------------------------------------------- /// The mask applied to the reference and stencil buffer values before /// performing the stencil_compare operation. @@ -567,7 +568,7 @@ struct StencilAttachmentDescriptor { constexpr size_t GetHash() const { return fml::HashCombine(stencil_compare, stencil_failure, depth_failure, - depth_stencil_pass, read_mask); + depth_stencil_pass, read_mask, write_mask); } }; diff --git a/impeller/display_list/BUILD.gn b/impeller/display_list/BUILD.gn index a69f63806c685..1b7f13e5d3d05 100644 --- a/impeller/display_list/BUILD.gn +++ b/impeller/display_list/BUILD.gn @@ -15,6 +15,7 @@ impeller_component("skia_conversions") { "../geometry", "//flutter/fml", "//third_party/skia", + "//third_party/skia/modules/skparagraph", ] } diff --git a/impeller/display_list/dl_dispatcher.cc b/impeller/display_list/dl_dispatcher.cc index d1a5ae4f27061..9964e9e71eaf9 100644 --- a/impeller/display_list/dl_dispatcher.cc +++ b/impeller/display_list/dl_dispatcher.cc @@ -1104,9 +1104,23 @@ void DlDispatcher::drawDisplayList( void DlDispatcher::drawTextBlob(const sk_sp blob, SkScalar x, SkScalar y) { - canvas_.DrawTextFrame(TextFrameFromTextBlob(blob), // - impeller::Point{x, y}, // - paint_ // + const auto text_frame = TextFrameFromTextBlob(blob); + if (paint_.style == Paint::Style::kStroke) { + auto path = skia_conversions::PathDataFromTextBlob(blob); + auto bounds = text_frame.GetBounds(); + if (!bounds.has_value()) { + return; + } + canvas_.Save(); + canvas_.Translate({x + bounds->origin.x, y + bounds->origin.y, 0.0}); + canvas_.DrawPath(path, paint_); + canvas_.Restore(); + return; + } + + canvas_.DrawTextFrame(text_frame, // + impeller::Point{x, y}, // + paint_ // ); } diff --git a/impeller/display_list/dl_unittests.cc b/impeller/display_list/dl_unittests.cc index b5ce5c4c9a420..05a0b5d9b072b 100644 --- a/impeller/display_list/dl_unittests.cc +++ b/impeller/display_list/dl_unittests.cc @@ -447,6 +447,19 @@ TEST_P(DisplayListTest, CanDrawWithMaskBlur) { ASSERT_TRUE(OpenPlaygroundHere(builder.Build())); } +TEST_P(DisplayListTest, CanDrawStrokedText) { + flutter::DisplayListBuilder builder; + flutter::DlPaint paint; + + paint.setDrawStyle(flutter::DlDrawStyle::kStroke); + paint.setColor(flutter::DlColor::kRed()); + builder.DrawTextBlob( + SkTextBlob::MakeFromString("stoked about stroked text", CreateTestFont()), + 250, 250, paint); + + ASSERT_TRUE(OpenPlaygroundHere(builder.Build())); +} + TEST_P(DisplayListTest, IgnoreMaskFilterWhenSavingLayer) { auto texture = CreateTextureForFixture("embarcadero.jpg"); flutter::DisplayListBuilder builder; diff --git a/impeller/display_list/skia_conversions.cc b/impeller/display_list/skia_conversions.cc index d7af98f61484f..29f9ad4eed8ae 100644 --- a/impeller/display_list/skia_conversions.cc +++ b/impeller/display_list/skia_conversions.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "impeller/display_list/skia_conversions.h" +#include "third_party/skia/modules/skparagraph/include/Paragraph.h" namespace impeller { namespace skia_conversions { @@ -159,6 +160,14 @@ std::vector ToRSXForms(const SkRSXform xform[], int count) { return result; } +Path PathDataFromTextBlob(const sk_sp& blob) { + if (!blob) { + return {}; + } + + return ToPath(skia::textlayout::Paragraph::GetPath(blob.get())); +} + std::optional ToPixelFormat(SkColorType type) { switch (type) { case kRGBA_8888_SkColorType: diff --git a/impeller/display_list/skia_conversions.h b/impeller/display_list/skia_conversions.h index 5f1524674240d..9406c6d272f62 100644 --- a/impeller/display_list/skia_conversions.h +++ b/impeller/display_list/skia_conversions.h @@ -16,6 +16,7 @@ #include "third_party/skia/include/core/SkPoint.h" #include "third_party/skia/include/core/SkRRect.h" #include "third_party/skia/include/core/SkRSXform.h" +#include "third_party/skia/include/core/SkTextBlob.h" namespace impeller { namespace skia_conversions { @@ -40,6 +41,8 @@ Path ToPath(const SkPath& path); Path ToPath(const SkRRect& rrect); +Path PathDataFromTextBlob(const sk_sp& blob); + std::optional ToPixelFormat(SkColorType type); } // namespace skia_conversions diff --git a/impeller/renderer/backend/gles/render_pass_gles.cc b/impeller/renderer/backend/gles/render_pass_gles.cc index 422ab1fc5932c..2cdadb4fc3cd7 100644 --- a/impeller/renderer/backend/gles/render_pass_gles.cc +++ b/impeller/renderer/backend/gles/render_pass_gles.cc @@ -100,14 +100,16 @@ void ConfigureStencil(const ProcTableGLES& gl, gl.Enable(GL_STENCIL_TEST); const auto& front = pipeline.GetFrontStencilAttachmentDescriptor(); const auto& back = pipeline.GetBackStencilAttachmentDescriptor(); - if (front.has_value() && front == back) { + + if (front.has_value() && back.has_value() && front == back) { ConfigureStencil(GL_FRONT_AND_BACK, gl, *front, stencil_reference); - } else if (front.has_value()) { + return; + } + if (front.has_value()) { ConfigureStencil(GL_FRONT, gl, *front, stencil_reference); - } else if (back.has_value()) { + } + if (back.has_value()) { ConfigureStencil(GL_BACK, gl, *back, stencil_reference); - } else { - FML_UNREACHABLE(); } } @@ -452,6 +454,7 @@ struct RenderPassData { if (gl.DiscardFramebufferEXT.IsAvailable()) { std::vector attachments; + if (pass_data.discard_color_attachment) { attachments.push_back(is_default_fbo ? GL_COLOR_EXT : GL_COLOR_ATTACHMENT0); @@ -460,7 +463,15 @@ struct RenderPassData { attachments.push_back(is_default_fbo ? GL_DEPTH_EXT : GL_DEPTH_ATTACHMENT); } + +// TODO(jonahwilliams): discarding the stencil on the default fbo when running +// on Windows causes Angle to discard the entire render target. Until we know +// the reason, default to storing. +#ifdef FML_OS_WIN + if (pass_data.discard_stencil_attachment && !is_default_fbo) { +#else if (pass_data.discard_stencil_attachment) { +#endif attachments.push_back(is_default_fbo ? GL_STENCIL_EXT : GL_STENCIL_ATTACHMENT); } diff --git a/impeller/renderer/backend/vulkan/BUILD.gn b/impeller/renderer/backend/vulkan/BUILD.gn index bb75156ab63db..4515720b412e9 100644 --- a/impeller/renderer/backend/vulkan/BUILD.gn +++ b/impeller/renderer/backend/vulkan/BUILD.gn @@ -94,6 +94,8 @@ impeller_component("vulkan") { "vertex_descriptor_vk.cc", "vertex_descriptor_vk.h", "vk.h", + "vma.cc", + "vma.h", ] public_deps = [ diff --git a/impeller/renderer/backend/vulkan/allocator_vk.cc b/impeller/renderer/backend/vulkan/allocator_vk.cc index d0af9e4afff2d..345a37bddd9a9 100644 --- a/impeller/renderer/backend/vulkan/allocator_vk.cc +++ b/impeller/renderer/backend/vulkan/allocator_vk.cc @@ -16,6 +16,75 @@ namespace impeller { +static constexpr vk::Flags +ToVKBufferMemoryPropertyFlags(StorageMode mode) { + switch (mode) { + case StorageMode::kHostVisible: + return vk::MemoryPropertyFlagBits::eHostVisible; + case StorageMode::kDevicePrivate: + return vk::MemoryPropertyFlagBits::eDeviceLocal; + case StorageMode::kDeviceTransient: + return vk::MemoryPropertyFlagBits::eLazilyAllocated; + } + FML_UNREACHABLE(); +} + +static VmaAllocationCreateFlags ToVmaAllocationBufferCreateFlags( + StorageMode mode) { + VmaAllocationCreateFlags flags = 0; + switch (mode) { + case StorageMode::kHostVisible: + flags |= VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT; + flags |= VMA_ALLOCATION_CREATE_MAPPED_BIT; + return flags; + case StorageMode::kDevicePrivate: + return flags; + case StorageMode::kDeviceTransient: + return flags; + } + FML_UNREACHABLE(); +} + +static PoolVMA CreateBufferPool(VmaAllocator allocator) { + vk::BufferCreateInfo buffer_info; + buffer_info.usage = vk::BufferUsageFlagBits::eVertexBuffer | + vk::BufferUsageFlagBits::eIndexBuffer | + vk::BufferUsageFlagBits::eUniformBuffer | + vk::BufferUsageFlagBits::eStorageBuffer | + vk::BufferUsageFlagBits::eTransferSrc | + vk::BufferUsageFlagBits::eTransferDst; + buffer_info.size = 1u; // doesn't matter + buffer_info.sharingMode = vk::SharingMode::eExclusive; + auto buffer_info_native = + static_cast(buffer_info); + + VmaAllocationCreateInfo allocation_info = {}; + allocation_info.usage = VMA_MEMORY_USAGE_AUTO; + allocation_info.preferredFlags = static_cast( + ToVKBufferMemoryPropertyFlags(StorageMode::kHostVisible)); + allocation_info.flags = + ToVmaAllocationBufferCreateFlags(StorageMode::kHostVisible); + + uint32_t memTypeIndex; + auto result = vk::Result{vmaFindMemoryTypeIndexForBufferInfo( + allocator, &buffer_info_native, &allocation_info, &memTypeIndex)}; + if (result != vk::Result::eSuccess) { + return {}; + } + + VmaPoolCreateInfo pool_create_info = {}; + pool_create_info.memoryTypeIndex = memTypeIndex; + pool_create_info.flags = VMA_POOL_CREATE_IGNORE_BUFFER_IMAGE_GRANULARITY_BIT | + VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT; + + VmaPool pool = {}; + result = vk::Result{::vmaCreatePool(allocator, &pool_create_info, &pool)}; + if (result != vk::Result::eSuccess) { + return {}; + } + return {allocator, pool}; +} + AllocatorVK::AllocatorVK(std::weak_ptr context, uint32_t vulkan_api_version, const vk::PhysicalDevice& physical_device, @@ -93,17 +162,16 @@ AllocatorVK::AllocatorVK(std::weak_ptr context, VALIDATION_LOG << "Could not create memory allocator"; return; } - allocator_ = allocator; + for (size_t i = 0u; i < staging_buffer_pools_.size(); i++) { + staging_buffer_pools_[i].reset(CreateBufferPool(allocator)); + created_buffer_pools_ &= staging_buffer_pools_[i].is_valid(); + } + allocator_.reset(allocator); supports_memoryless_textures_ = capabilities.SupportsMemorylessTextures(); is_valid_ = true; } -AllocatorVK::~AllocatorVK() { - TRACE_EVENT0("impeller", "DestroyAllocatorVK"); - if (allocator_) { - ::vmaDestroyAllocator(allocator_); - } -} +AllocatorVK::~AllocatorVK() = default; // |Allocator| bool AllocatorVK::IsValid() const { @@ -177,35 +245,22 @@ static constexpr VmaMemoryUsage ToVMAMemoryUsage() { return VMA_MEMORY_USAGE_AUTO; } -static constexpr VkMemoryPropertyFlags ToVKTextureMemoryPropertyFlags( - StorageMode mode, - bool supports_memoryless_textures) { +static constexpr vk::Flags +ToVKTextureMemoryPropertyFlags(StorageMode mode, + bool supports_memoryless_textures) { switch (mode) { case StorageMode::kHostVisible: - return VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; + return vk::MemoryPropertyFlagBits::eHostVisible | + vk::MemoryPropertyFlagBits::eDeviceLocal | + vk::MemoryPropertyFlagBits::eHostCoherent; case StorageMode::kDevicePrivate: - return VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; + return vk::MemoryPropertyFlagBits::eDeviceLocal; case StorageMode::kDeviceTransient: if (supports_memoryless_textures) { - return VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT | - VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; + return vk::MemoryPropertyFlagBits::eLazilyAllocated | + vk::MemoryPropertyFlagBits::eDeviceLocal; } - return VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; - } - FML_UNREACHABLE(); -} - -static constexpr VkMemoryPropertyFlags ToVKBufferMemoryPropertyFlags( - StorageMode mode) { - switch (mode) { - case StorageMode::kHostVisible: - return VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | - VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | - VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; - case StorageMode::kDevicePrivate: - return VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; - case StorageMode::kDeviceTransient: - return VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT; + return vk::MemoryPropertyFlagBits::eDeviceLocal; } FML_UNREACHABLE(); } @@ -270,8 +325,9 @@ class AllocatedTextureSourceVK final : public TextureSourceVK { VmaAllocationCreateInfo alloc_nfo = {}; alloc_nfo.usage = ToVMAMemoryUsage(); - alloc_nfo.preferredFlags = ToVKTextureMemoryPropertyFlags( - desc.storage_mode, supports_memoryless_textures); + alloc_nfo.preferredFlags = + static_cast(ToVKTextureMemoryPropertyFlags( + desc.storage_mode, supports_memoryless_textures)); alloc_nfo.flags = ToVmaAllocationCreateFlags(desc.storage_mode, /*is_texture=*/true, desc.GetByteSizeOfBaseMipLevel()); @@ -331,8 +387,8 @@ class AllocatedTextureSourceVK final : public TextureSourceVK { << vk::to_string(result); return; } - resource_.Reset( - ImageResource(image, allocator, allocation, std::move(image_view))); + resource_.Reset(ImageResource(ImageVMA{allocator, allocation, image}, + std::move(image_view))); is_valid_ = true; } @@ -340,7 +396,7 @@ class AllocatedTextureSourceVK final : public TextureSourceVK { bool IsValid() const { return is_valid_; } - vk::Image GetImage() const override { return resource_->image; } + vk::Image GetImage() const override { return resource_->image.get().image; } vk::ImageView GetImageView() const override { return resource_->image_view.get(); @@ -348,44 +404,19 @@ class AllocatedTextureSourceVK final : public TextureSourceVK { private: struct ImageResource { - vk::Image image = {}; - VmaAllocator allocator = {}; - VmaAllocation allocation = {}; + UniqueImageVMA image; vk::UniqueImageView image_view; ImageResource() = default; - ImageResource(vk::Image p_image, - VmaAllocator p_allocator, - VmaAllocation p_allocation, - vk::UniqueImageView p_image_view) - : image(p_image), - allocator(p_allocator), - allocation(p_allocation), - image_view(std::move(p_image_view)) {} + ImageResource(ImageVMA p_image, vk::UniqueImageView p_image_view) + : image(p_image), image_view(std::move(p_image_view)) {} ImageResource(ImageResource&& o) { std::swap(image, o.image); - std::swap(allocator, o.allocator); - std::swap(allocation, o.allocation); std::swap(image_view, o.image_view); } - ~ImageResource() { - if (!image) { - return; - } - TRACE_EVENT0("impeller", "DestroyDeviceTexture"); - image_view.reset(); - if (image) { - ::vmaDestroyImage( - allocator, // - static_cast(image), // - allocation // - ); - } - } - FML_DISALLOW_COPY_AND_ASSIGN(ImageResource); }; @@ -413,7 +444,7 @@ std::shared_ptr AllocatorVK::OnCreateTexture( auto source = std::make_shared( ContextVK::Cast(*context).GetResourceManager(), // desc, // - allocator_, // + allocator_.get(), // device_holder->GetDevice(), // supports_memoryless_textures_ // ); @@ -423,6 +454,11 @@ std::shared_ptr AllocatorVK::OnCreateTexture( return std::make_shared(context_, std::move(source)); } +void AllocatorVK::DidAcquireSurfaceFrame() { + frame_count_++; + raster_thread_id_ = std::this_thread::get_id(); +} + // |Allocator| std::shared_ptr AllocatorVK::OnCreateBuffer( const DeviceBufferDescriptor& desc) { @@ -441,15 +477,21 @@ std::shared_ptr AllocatorVK::OnCreateBuffer( VmaAllocationCreateInfo allocation_info = {}; allocation_info.usage = ToVMAMemoryUsage(); - allocation_info.preferredFlags = - ToVKBufferMemoryPropertyFlags(desc.storage_mode); - allocation_info.flags = ToVmaAllocationCreateFlags( - desc.storage_mode, /*is_texture=*/false, desc.size); + allocation_info.preferredFlags = static_cast( + ToVKBufferMemoryPropertyFlags(desc.storage_mode)); + allocation_info.flags = ToVmaAllocationBufferCreateFlags(desc.storage_mode); + if (created_buffer_pools_ && desc.storage_mode == StorageMode::kHostVisible && + raster_thread_id_ == std::this_thread::get_id()) { + allocation_info.pool = + staging_buffer_pools_[frame_count_ % staging_buffer_pools_.size()] + .get() + .pool; + } VkBuffer buffer = {}; VmaAllocation buffer_allocation = {}; VmaAllocationInfo buffer_allocation_info = {}; - auto result = vk::Result{::vmaCreateBuffer(allocator_, // + auto result = vk::Result{::vmaCreateBuffer(allocator_.get(), // &buffer_info_native, // &allocation_info, // &buffer, // @@ -463,12 +505,13 @@ std::shared_ptr AllocatorVK::OnCreateBuffer( return {}; } - return std::make_shared(desc, // - context_, // - allocator_, // - buffer_allocation, // - buffer_allocation_info, // - vk::Buffer{buffer} // + return std::make_shared( + desc, // + context_, // + UniqueBufferVMA{BufferVMA{allocator_.get(), // + buffer_allocation, // + vk::Buffer{buffer}}}, // + buffer_allocation_info // ); } diff --git a/impeller/renderer/backend/vulkan/allocator_vk.h b/impeller/renderer/backend/vulkan/allocator_vk.h index fba13f2b7cf12..68b08aa708721 100644 --- a/impeller/renderer/backend/vulkan/allocator_vk.h +++ b/impeller/renderer/backend/vulkan/allocator_vk.h @@ -13,6 +13,7 @@ #include "impeller/renderer/backend/vulkan/device_holder.h" #include "impeller/renderer/backend/vulkan/vk.h" +#include #include namespace impeller { @@ -25,13 +26,20 @@ class AllocatorVK final : public Allocator { private: friend class ContextVK; + static constexpr size_t kPoolCount = 3; + fml::RefPtr vk_; - VmaAllocator allocator_ = {}; + UniqueAllocatorVMA allocator_; + std::array staging_buffer_pools_; std::weak_ptr context_; std::weak_ptr device_holder_; ISize max_texture_size_; bool is_valid_ = false; bool supports_memoryless_textures_ = false; + // TODO(jonahwilliams): figure out why CI can't create these buffer pools. + bool created_buffer_pools_ = true; + uint32_t frame_count_ = 0; + std::thread::id raster_thread_id_; AllocatorVK(std::weak_ptr context, uint32_t vulkan_api_version, @@ -45,6 +53,9 @@ class AllocatorVK final : public Allocator { // |Allocator| bool IsValid() const; + // |Allocator| + void DidAcquireSurfaceFrame() override; + // |Allocator| std::shared_ptr OnCreateBuffer( const DeviceBufferDescriptor& desc) override; diff --git a/impeller/renderer/backend/vulkan/context_vk.cc b/impeller/renderer/backend/vulkan/context_vk.cc index 116aab140aa5e..54332291e670d 100644 --- a/impeller/renderer/backend/vulkan/context_vk.cc +++ b/impeller/renderer/backend/vulkan/context_vk.cc @@ -185,28 +185,21 @@ void ContextVK::Setup(Settings settings) { application_info.setPEngineName("Impeller"); application_info.setPApplicationName("Impeller"); + vk::StructureChain + instance_chain; + + if (!caps->AreValidationsEnabled()) { + instance_chain.unlink(); + } + std::vector enabled_validations = { vk::ValidationFeatureEnableEXT::eSynchronizationValidation, }; - vk::ValidationFeaturesEXT validation; + auto validation = instance_chain.get(); validation.setEnabledValidationFeatures(enabled_validations); - vk::InstanceCreateInfo instance_info; - if (caps->AreValidationsEnabled()) { - std::stringstream ss; - ss << "Enabling validation layers, features: ["; - for (const auto& validation : enabled_validations) { - ss << vk::to_string(validation) << " "; - } - ss << "]"; - FML_LOG(ERROR) << ss.str(); -#if !defined(IMPELLER_ENABLE_VULKAN_VALIDATION_LAYERS) && FML_OS_ANDROID - FML_LOG(ERROR) << "Vulkan validation layers turned on but the gn argument " - "`--enable-vulkan-validation-layers` is missing."; -#endif - instance_info.pNext = &validation; - } + auto instance_info = instance_chain.get(); instance_info.setPEnabledLayerNames(enabled_layers_c); instance_info.setPEnabledExtensionNames(enabled_extensions_c); instance_info.setPApplicationInfo(&application_info); @@ -492,6 +485,9 @@ std::unique_ptr ContextVK::AcquireNextSurface() { if (surface && pipeline_library_) { pipeline_library_->DidAcquireSurfaceFrame(); } + if (allocator_) { + allocator_->DidAcquireSurfaceFrame(); + } return surface; } diff --git a/impeller/renderer/backend/vulkan/device_buffer_vk.cc b/impeller/renderer/backend/vulkan/device_buffer_vk.cc index d113e853bb194..5386ae3c037e8 100644 --- a/impeller/renderer/backend/vulkan/device_buffer_vk.cc +++ b/impeller/renderer/backend/vulkan/device_buffer_vk.cc @@ -6,27 +6,22 @@ #include "flutter/fml/logging.h" #include "flutter/fml/trace_event.h" -#include "vulkan/vulkan_handles.hpp" namespace impeller { DeviceBufferVK::DeviceBufferVK(DeviceBufferDescriptor desc, std::weak_ptr context, - VmaAllocator allocator, - VmaAllocation allocation, - VmaAllocationInfo info, - vk::Buffer buffer) + UniqueBufferVMA buffer, + VmaAllocationInfo info) : DeviceBuffer(desc), context_(std::move(context)), resource_(ContextVK::Cast(*context_.lock().get()).GetResourceManager(), BufferResource{ - allocator, // - allocation, // - info, // - buffer // + std::move(buffer), // + info // }) {} -DeviceBufferVK::~DeviceBufferVK() {} +DeviceBufferVK::~DeviceBufferVK() = default; uint8_t* DeviceBufferVK::OnGetContents() const { return static_cast(resource_->info.pMappedData); @@ -51,17 +46,18 @@ bool DeviceBufferVK::OnCopyHostBuffer(const uint8_t* source, bool DeviceBufferVK::SetLabel(const std::string& label) { auto context = context_.lock(); - if (!context || !resource_->buffer) { + if (!context || !resource_->buffer.is_valid()) { // The context could have died at this point. return false; } - ::vmaSetAllocationName(resource_->allocator, // - resource_->allocation, // - label.c_str() // + ::vmaSetAllocationName(resource_->buffer.get().allocator, // + resource_->buffer.get().allocation, // + label.c_str() // ); - return ContextVK::Cast(*context).SetDebugName(resource_->buffer, label); + return ContextVK::Cast(*context).SetDebugName(resource_->buffer.get().buffer, + label); } bool DeviceBufferVK::SetLabel(const std::string& label, Range range) { @@ -70,7 +66,7 @@ bool DeviceBufferVK::SetLabel(const std::string& label, Range range) { } vk::Buffer DeviceBufferVK::GetBuffer() const { - return resource_->buffer; + return resource_->buffer.get().buffer; } } // namespace impeller diff --git a/impeller/renderer/backend/vulkan/device_buffer_vk.h b/impeller/renderer/backend/vulkan/device_buffer_vk.h index bf5c033b482d8..7cc934f72f135 100644 --- a/impeller/renderer/backend/vulkan/device_buffer_vk.h +++ b/impeller/renderer/backend/vulkan/device_buffer_vk.h @@ -12,6 +12,7 @@ #include "impeller/core/device_buffer.h" #include "impeller/renderer/backend/vulkan/context_vk.h" #include "impeller/renderer/backend/vulkan/resource_manager_vk.h" +#include "impeller/renderer/backend/vulkan/vma.h" namespace impeller { @@ -20,10 +21,8 @@ class DeviceBufferVK final : public DeviceBuffer, public: DeviceBufferVK(DeviceBufferDescriptor desc, std::weak_ptr context, - VmaAllocator allocator, - VmaAllocation allocation, - VmaAllocationInfo info, - vk::Buffer buffer); + UniqueBufferVMA buffer, + VmaAllocationInfo info); // |DeviceBuffer| ~DeviceBufferVK() override; @@ -34,37 +33,17 @@ class DeviceBufferVK final : public DeviceBuffer, friend class AllocatorVK; struct BufferResource { - VmaAllocator allocator = {}; - VmaAllocation allocation = {}; + UniqueBufferVMA buffer; VmaAllocationInfo info = {}; - vk::Buffer buffer = {}; BufferResource() = default; - BufferResource(VmaAllocator p_allocator, - VmaAllocation p_allocation, - VmaAllocationInfo p_info, - vk::Buffer p_buffer) - : allocator(p_allocator), - allocation(p_allocation), - info(p_info), - buffer(p_buffer) {} + BufferResource(UniqueBufferVMA p_buffer, VmaAllocationInfo p_info) + : buffer(std::move(p_buffer)), info(p_info) {} BufferResource(BufferResource&& o) { - std::swap(o.allocator, allocator); - std::swap(o.allocation, allocation); - std::swap(o.info, info); std::swap(o.buffer, buffer); - } - - ~BufferResource() { - if (!buffer) { - return; - } - TRACE_EVENT0("impeller", "DestroyDeviceBuffer"); - ::vmaDestroyBuffer(allocator, - static_cast(buffer), - allocation); + std::swap(o.info, info); } FML_DISALLOW_COPY_AND_ASSIGN(BufferResource); diff --git a/impeller/renderer/backend/vulkan/formats_vk.h b/impeller/renderer/backend/vulkan/formats_vk.h index 2bf4aaedffb1e..634f647f0f533 100644 --- a/impeller/renderer/backend/vulkan/formats_vk.h +++ b/impeller/renderer/backend/vulkan/formats_vk.h @@ -8,7 +8,6 @@ #include "impeller/core/formats.h" #include "impeller/core/shader_types.h" #include "impeller/renderer/backend/vulkan/vk.h" -#include "vulkan/vulkan_enums.hpp" namespace impeller { diff --git a/impeller/renderer/backend/vulkan/pipeline_library_vk.h b/impeller/renderer/backend/vulkan/pipeline_library_vk.h index 538a2b9834c62..4db81e06bb2ab 100644 --- a/impeller/renderer/backend/vulkan/pipeline_library_vk.h +++ b/impeller/renderer/backend/vulkan/pipeline_library_vk.h @@ -17,7 +17,6 @@ #include "impeller/renderer/backend/vulkan/pipeline_vk.h" #include "impeller/renderer/backend/vulkan/vk.h" #include "impeller/renderer/pipeline_library.h" -#include "vulkan/vulkan_handles.hpp" namespace impeller { diff --git a/impeller/renderer/backend/vulkan/render_pass_vk.cc b/impeller/renderer/backend/vulkan/render_pass_vk.cc index 4c2820b7906ee..82d2214a5f5b2 100644 --- a/impeller/renderer/backend/vulkan/render_pass_vk.cc +++ b/impeller/renderer/backend/vulkan/render_pass_vk.cc @@ -23,8 +23,6 @@ #include "impeller/renderer/backend/vulkan/sampler_vk.h" #include "impeller/renderer/backend/vulkan/shared_object_vk.h" #include "impeller/renderer/backend/vulkan/texture_vk.h" -#include "vulkan/vulkan_enums.hpp" -#include "vulkan/vulkan_structs.hpp" namespace impeller { diff --git a/impeller/renderer/backend/vulkan/sampler_vk.h b/impeller/renderer/backend/vulkan/sampler_vk.h index f67a64f9e83d6..5286cef2fbab6 100644 --- a/impeller/renderer/backend/vulkan/sampler_vk.h +++ b/impeller/renderer/backend/vulkan/sampler_vk.h @@ -9,7 +9,6 @@ #include "impeller/core/sampler.h" #include "impeller/renderer/backend/vulkan/shared_object_vk.h" #include "impeller/renderer/backend/vulkan/vk.h" -#include "vulkan/vulkan_handles.hpp" namespace impeller { diff --git a/impeller/renderer/backend/vulkan/vk.h b/impeller/renderer/backend/vulkan/vk.h index 3eef9a3cf6fd6..efbf94b840536 100644 --- a/impeller/renderer/backend/vulkan/vk.h +++ b/impeller/renderer/backend/vulkan/vk.h @@ -67,5 +67,3 @@ #include "vulkan/vulkan.hpp" static_assert(VK_HEADER_VERSION >= 215, "Vulkan headers must not be too old."); - -#include "flutter/flutter_vma/flutter_vma.h" diff --git a/impeller/renderer/backend/vulkan/vma.cc b/impeller/renderer/backend/vulkan/vma.cc new file mode 100644 index 0000000000000..5c28daa885f42 --- /dev/null +++ b/impeller/renderer/backend/vulkan/vma.cc @@ -0,0 +1,11 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "impeller/renderer/backend/vulkan/vma.h" + +namespace impeller { + +// + +} // namespace impeller diff --git a/impeller/renderer/backend/vulkan/vma.h b/impeller/renderer/backend/vulkan/vma.h new file mode 100644 index 0000000000000..f33a396997f01 --- /dev/null +++ b/impeller/renderer/backend/vulkan/vma.h @@ -0,0 +1,134 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#pragma once + +#include "flutter/flutter_vma/flutter_vma.h" +#include "flutter/fml/trace_event.h" +#include "flutter/fml/unique_object.h" +#include "impeller/renderer/backend/vulkan/vk.h" + +namespace impeller { + +// ----------------------------------------------------------------------------- +// Unique handles to VMA allocators. +// ----------------------------------------------------------------------------- +struct AllocatorVMATraits { + static VmaAllocator InvalidValue() { return {}; } + + static bool IsValid(const VmaAllocator& value) { + return value != InvalidValue(); + } + + static void Free(VmaAllocator allocator) { + TRACE_EVENT0("impeller", "DestroyAllocator"); + ::vmaDestroyAllocator(allocator); + } +}; + +using UniqueAllocatorVMA = fml::UniqueObject; + +// ----------------------------------------------------------------------------- +// Unique handles to VMA pools. +// ----------------------------------------------------------------------------- + +struct PoolVMA { + VmaAllocator allocator = {}; + VmaPool pool = {}; + + constexpr bool operator==(const PoolVMA& other) const { + return allocator == other.allocator && pool == other.pool; + } + + constexpr bool operator!=(const PoolVMA& other) const { + return !(*this == other); + } +}; + +struct PoolVMATraits { + static PoolVMA InvalidValue() { return {}; } + + static bool IsValid(const PoolVMA& value) { + return value.allocator != VmaAllocator{}; + } + + static void Free(const PoolVMA& pool) { + TRACE_EVENT0("impeller", "DestroyPool"); + ::vmaDestroyPool(pool.allocator, pool.pool); + } +}; + +using UniquePoolVMA = fml::UniqueObject; + +// ----------------------------------------------------------------------------- +// Unique handles to VMA buffers. +// ----------------------------------------------------------------------------- + +struct BufferVMA { + VmaAllocator allocator = {}; + VmaAllocation allocation = {}; + vk::Buffer buffer = {}; + + constexpr bool operator==(const BufferVMA& other) const { + return allocator == other.allocator && allocation == other.allocation && + buffer == other.buffer; + } + + constexpr bool operator!=(const BufferVMA& other) const { + return !(*this == other); + } +}; + +struct BufferVMATraits { + static BufferVMA InvalidValue() { return {}; } + + static bool IsValid(const BufferVMA& value) { + return value.allocator != VmaAllocator{}; + } + + static void Free(const BufferVMA& buffer) { + TRACE_EVENT0("impeller", "DestroyBuffer"); + ::vmaDestroyBuffer(buffer.allocator, static_cast(buffer.buffer), + buffer.allocation); + } +}; + +using UniqueBufferVMA = fml::UniqueObject; + +// ----------------------------------------------------------------------------- +// Unique handles to VMA images. +// ----------------------------------------------------------------------------- + +struct ImageVMA { + VmaAllocator allocator = {}; + VmaAllocation allocation = {}; + vk::Image image = {}; + + constexpr bool operator==(const ImageVMA& other) const { + return allocator == other.allocator && allocation == other.allocation && + image == other.image; + } + + constexpr bool operator!=(const ImageVMA& other) const { + return !(*this == other); + } +}; + +struct ImageVMATraits { + static ImageVMA InvalidValue() { return {}; } + + static bool IsValid(const ImageVMA& value) { + return value.allocator != VmaAllocator{}; + } + + static void Free(const ImageVMA& image) { + TRACE_EVENT0("impeller", "DestroyImage"); + ::vmaDestroyImage(image.allocator, static_cast(image.image), + image.allocation); + } +}; + +using UniqueImageVMA = fml::UniqueObject; + +} // namespace impeller diff --git a/impeller/renderer/renderer_unittests.cc b/impeller/renderer/renderer_unittests.cc index d18a4eaab4fb7..358612a49c8a2 100644 --- a/impeller/renderer/renderer_unittests.cc +++ b/impeller/renderer/renderer_unittests.cc @@ -1046,6 +1046,142 @@ TEST_P(RendererTest, VertexBufferBuilder) { ASSERT_EQ(vertex_builder.GetVertexCount(), 4u); } +TEST_P(RendererTest, StencilMask) { + using VS = BoxFadeVertexShader; + using FS = BoxFadeFragmentShader; + auto context = GetContext(); + ASSERT_TRUE(context); + using BoxFadePipelineBuilder = PipelineBuilder; + auto desc = BoxFadePipelineBuilder::MakeDefaultPipelineDescriptor(*context); + ASSERT_TRUE(desc.has_value()); + + // Vertex buffer. + VertexBufferBuilder vertex_builder; + vertex_builder.SetLabel("Box"); + vertex_builder.AddVertices({ + {{100, 100, 0.0}, {0.0, 0.0}}, // 1 + {{800, 100, 0.0}, {1.0, 0.0}}, // 2 + {{800, 800, 0.0}, {1.0, 1.0}}, // 3 + {{100, 100, 0.0}, {0.0, 0.0}}, // 1 + {{800, 800, 0.0}, {1.0, 1.0}}, // 3 + {{100, 800, 0.0}, {0.0, 1.0}}, // 4 + }); + auto vertex_buffer = + vertex_builder.CreateVertexBuffer(*context->GetResourceAllocator()); + ASSERT_TRUE(vertex_buffer); + + desc->SetSampleCount(SampleCount::kCount4); + + auto bridge = CreateTextureForFixture("bay_bridge.jpg"); + auto boston = CreateTextureForFixture("boston.jpg"); + ASSERT_TRUE(bridge && boston); + auto sampler = context->GetSamplerLibrary()->GetSampler({}); + ASSERT_TRUE(sampler); + + static bool mirror = false; + static int stencil_reference_write = 0xFF; + static int stencil_reference_read = 0x1; + std::vector stencil_contents; + static int last_stencil_contents_reference_value = 0; + Renderer::RenderCallback callback = [&](RenderTarget& render_target) { + auto buffer = context->CreateCommandBuffer(); + if (!buffer) { + return false; + } + buffer->SetLabel("Playground Command Buffer"); + + { + // Configure the stencil attachment for the test. + RenderTarget::AttachmentConfig stencil_config; + stencil_config.load_action = LoadAction::kLoad; + stencil_config.store_action = StoreAction::kDontCare; + stencil_config.storage_mode = StorageMode::kHostVisible; + render_target.SetupStencilAttachment(*context, + render_target.GetRenderTargetSize(), + true, "stencil", stencil_config); + // Fill the stencil buffer with an checkerboard pattern. + const auto target_width = render_target.GetRenderTargetSize().width; + const auto target_height = render_target.GetRenderTargetSize().height; + const size_t target_size = target_width * target_height; + if (stencil_contents.size() != target_size || + last_stencil_contents_reference_value != stencil_reference_write) { + stencil_contents.resize(target_size); + last_stencil_contents_reference_value = stencil_reference_write; + for (int y = 0; y < target_height; y++) { + for (int x = 0; x < target_width; x++) { + const auto index = y * target_width + x; + const auto kCheckSize = 64; + const auto value = + (((y / kCheckSize) + (x / kCheckSize)) % 2 == 0) * + stencil_reference_write; + stencil_contents[index] = value; + } + } + } + if (!render_target.GetStencilAttachment()->texture->SetContents( + stencil_contents.data(), stencil_contents.size(), 0, false)) { + VALIDATION_LOG << "Could not upload stencil contents to device memory"; + return false; + } + auto pass = buffer->CreateRenderPass(render_target); + if (!pass) { + return false; + } + pass->SetLabel("Stencil Buffer"); + ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_AlwaysAutoResize); + ImGui::SliderInt("Stencil Write Value", &stencil_reference_write, 0, + 0xFF); + ImGui::SliderInt("Stencil Compare Value", &stencil_reference_read, 0, + 0xFF); + ImGui::Checkbox("Mirror", &mirror); + ImGui::End(); + StencilAttachmentDescriptor front_and_back; + front_and_back.stencil_compare = CompareFunction::kLessEqual; + desc->SetStencilAttachmentDescriptors(front_and_back); + auto pipeline = context->GetPipelineLibrary()->GetPipeline(desc).Get(); + + assert(pipeline && pipeline->IsValid()); + + Command cmd; + cmd.label = "Box"; + cmd.pipeline = pipeline; + cmd.stencil_reference = stencil_reference_read; + + cmd.BindVertices(vertex_buffer); + + VS::UniformBuffer uniforms; + uniforms.mvp = Matrix::MakeOrthographic(pass->GetRenderTargetSize()) * + Matrix::MakeScale(GetContentScale()); + if (mirror) { + uniforms.mvp = Matrix::MakeScale(Vector2(-1, -1)) * uniforms.mvp; + } + VS::BindUniformBuffer( + cmd, pass->GetTransientsBuffer().EmplaceUniform(uniforms)); + + FS::FrameInfo frame_info; + frame_info.current_time = GetSecondsElapsed(); + frame_info.cursor_position = GetCursorPosition(); + frame_info.window_size.x = GetWindowSize().width; + frame_info.window_size.y = GetWindowSize().height; + + FS::BindFrameInfo(cmd, + pass->GetTransientsBuffer().EmplaceUniform(frame_info)); + FS::BindContents1(cmd, boston, sampler); + FS::BindContents2(cmd, bridge, sampler); + if (!pass->AddCommand(std::move(cmd))) { + return false; + } + pass->EncodeCommands(); + } + + if (!buffer->SubmitCommands()) { + return false; + } + return true; + }; + OpenPlaygroundHere(callback); +} + } // namespace testing } // namespace impeller diff --git a/lib/ui/channel_buffers.dart b/lib/ui/channel_buffers.dart index a8616698553a4..a93208b3b8bb7 100644 --- a/lib/ui/channel_buffers.dart +++ b/lib/ui/channel_buffers.dart @@ -243,6 +243,14 @@ class _Channel { /// Typically these buffers are drained once a callback is set up on /// the [BinaryMessenger] in the Flutter framework. (See [setListener].) /// +/// ## Channel names +/// +/// By convention, channels are normally named with a reverse-DNS prefix, a +/// slash, and then a domain-specific name. For example, `com.example/demo`. +/// +/// Channel names cannot contain the U+0000 NULL character, because they +/// are passed through APIs that use null-terminated strings. +/// /// ## Buffer capacity and overflow /// /// Each channel has a finite buffer capacity and messages will @@ -326,7 +334,11 @@ class ChannelBuffers { /// If a message overflows the channel, and the channel has not been /// configured to expect overflow, then, in debug mode, a message /// will be printed to the console warning about the overflow. + /// + /// Channel names cannot contain the U+0000 NULL character, because they + /// are passed through APIs that use null-terminated strings. void push(String name, ByteData? data, PlatformMessageResponseCallback callback) { + assert(!name.contains('\u0000'), 'Channel names must not contain U+0000 NULL characters.'); final _Channel channel = _channels.putIfAbsent(name, () => _Channel()); if (channel.push(_StoredMessage(data, callback))) { _printDebug( @@ -365,6 +377,7 @@ class ChannelBuffers { /// /// The draining stops if the listener is removed. void setListener(String name, ChannelCallback callback) { + assert(!name.contains('\u0000'), 'Channel names must not contain U+0000 NULL characters.'); final _Channel channel = _channels.putIfAbsent(name, () => _Channel()); channel.setListener(callback); } @@ -416,8 +429,9 @@ class ChannelBuffers { /// ## `resize` /// /// The `resize` method takes as its argument a list with two values, first - /// the channel name (a UTF-8 string less than 254 bytes long), and second the - /// allowed size of the channel buffer (an integer between 0 and 2147483647). + /// the channel name (a UTF-8 string less than 254 bytes long and not + /// containing any null bytes), and second the allowed size of the channel + /// buffer (an integer between 0 and 2147483647). /// /// Upon receiving the message, the channel's buffer is resized. If necessary, /// messages are silently discarded to ensure the buffer is no bigger than @@ -433,8 +447,9 @@ class ChannelBuffers { /// ## `overflow` /// /// The `overflow` method takes as its argument a list with two values, first - /// the channel name (a UTF-8 string less than 254 bytes long), and second a - /// boolean which is true if overflow is expected and false if it is not. + /// the channel name (a UTF-8 string less than 254 bytes long and not + /// containing any null bytes), and second a boolean which is true if overflow + /// is expected and false if it is not. /// /// This sets a flag on the channel in debug mode. In release mode the message /// is silently ignored. The flag indicates whether overflow is expected on this @@ -473,6 +488,9 @@ class ChannelBuffers { } index += 1; final String channelName = utf8.decode(bytes.sublist(index, index + channelNameLength)); + if (channelName.contains('\u0000')) { + throw Exception("Invalid arguments for 'resize' method sent to $kControlChannelName (channel name must not contain any null bytes)"); + } index += channelNameLength; if (bytes[index] != 0x03) { // 3 = value code for uint32 throw Exception("Invalid arguments for 'resize' method sent to $kControlChannelName (second argument must be an integer in the range 0 to 2147483647)"); @@ -533,6 +551,7 @@ class ChannelBuffers { void resize(String name, int newSize) { _Channel? channel = _channels[name]; if (channel == null) { + assert(!name.contains('\u0000'), 'Channel names must not contain U+0000 NULL characters.'); channel = _Channel(newSize); _channels[name] = channel; } else { @@ -556,6 +575,7 @@ class ChannelBuffers { assert(() { _Channel? channel = _channels[name]; if (channel == null && allowed) { + assert(!name.contains('\u0000'), 'Channel names must not contain U+0000 NULL characters.'); channel = _Channel(); _channels[name] = channel; } diff --git a/lib/ui/dart_ui.cc b/lib/ui/dart_ui.cc index 77b126d797346..efb5af0a30a69 100644 --- a/lib/ui/dart_ui.cc +++ b/lib/ui/dart_ui.cc @@ -78,7 +78,7 @@ typedef CanvasPath Path; V(Gradient::Create, 1) \ V(ImageFilter::Create, 1) \ V(ImageShader::Create, 1) \ - V(ParagraphBuilder::Create, 9) \ + V(ParagraphBuilder::Create, 10) \ V(PathMeasure::Create, 3) \ V(Path::Create, 1) \ V(PictureRecorder::Create, 1) \ diff --git a/lib/ui/text.dart b/lib/ui/text.dart index 313630e98017b..2d40e63722668 100644 --- a/lib/ui/text.dart +++ b/lib/ui/text.dart @@ -2798,7 +2798,7 @@ abstract class Paragraph { /// This only returns a valid value if asserts are enabled, and must not be /// used otherwise. bool get debugDisposed; - } +} @pragma('vm:entry-point') base class _NativeParagraph extends NativeFieldWrapperClass1 implements Paragraph { @@ -3015,6 +3015,28 @@ abstract class ParagraphBuilder { /// [Paragraph]. factory ParagraphBuilder(ParagraphStyle style) = _NativeParagraphBuilder; + /// Whether the rounding hack enabled by default in SkParagraph and TextPainter + /// is disabled. + /// + /// Do not rely on this getter as it exists for migration purposes only and + /// will soon be removed. + static bool get shouldDisableRoundingHack { + return const bool.hasEnvironment('SKPARAGRAPH_REMOVE_ROUNDING_HACK') + || _roundingHackDisabledInDebugMode; + } + static bool _roundingHackDisabledInDebugMode = true; + + /// Only works in debug mode. Do not call this method as it is for migration + /// purposes only and will soon be removed. + static void setDisableRoundingHack(bool disableRoundingHack) { + // bool.hasEnvironment does not work in internal tests so an additional flag + // is needed for tests. + assert(() { + _roundingHackDisabledInDebugMode = disableRoundingHack; + return true; + }()); + } + /// The number of placeholders currently in the paragraph. int get placeholderCount; @@ -3132,11 +3154,12 @@ base class _NativeParagraphBuilder extends NativeFieldWrapperClass1 implements P style._fontSize ?? 0, style._height ?? 0, style._ellipsis ?? '', - _encodeLocale(style._locale) + _encodeLocale(style._locale), + !ParagraphBuilder.shouldDisableRoundingHack, ); } - @Native(symbol: 'ParagraphBuilder::Create') + @Native(symbol: 'ParagraphBuilder::Create') external void _constructor( Int32List encoded, ByteData? strutData, @@ -3145,7 +3168,8 @@ base class _NativeParagraphBuilder extends NativeFieldWrapperClass1 implements P double fontSize, double height, String ellipsis, - String locale); + String locale, + bool applyRoundingHack); @override int get placeholderCount => _placeholderCount; diff --git a/lib/ui/text/paragraph_builder.cc b/lib/ui/text/paragraph_builder.cc index 3857a10572d62..eb01511772d49 100644 --- a/lib/ui/text/paragraph_builder.cc +++ b/lib/ui/text/paragraph_builder.cc @@ -151,11 +151,12 @@ void ParagraphBuilder::Create(Dart_Handle wrapper, double fontSize, double height, const std::u16string& ellipsis, - const std::string& locale) { + const std::string& locale, + bool applyRoundingHack) { UIDartState::ThrowIfUIOperationsProhibited(); auto res = fml::MakeRefCounted( encoded_handle, strutData, fontFamily, strutFontFamilies, fontSize, - height, ellipsis, locale); + height, ellipsis, locale, applyRoundingHack); res->AssociateWithDartWrapper(wrapper); } @@ -230,7 +231,8 @@ ParagraphBuilder::ParagraphBuilder( double fontSize, double height, const std::u16string& ellipsis, - const std::string& locale) { + const std::string& locale, + bool applyRoundingHack) { int32_t mask = 0; txt::ParagraphStyle style; { @@ -291,6 +293,7 @@ ParagraphBuilder::ParagraphBuilder( if (mask & kPSLocaleMask) { style.locale = locale; } + style.apply_rounding_hack = applyRoundingHack; FontCollection& font_collection = UIDartState::Current() ->platform_configuration() diff --git a/lib/ui/text/paragraph_builder.h b/lib/ui/text/paragraph_builder.h index 0018f969da68f..6fc7c58ad97aa 100644 --- a/lib/ui/text/paragraph_builder.h +++ b/lib/ui/text/paragraph_builder.h @@ -30,7 +30,8 @@ class ParagraphBuilder : public RefCountedDartWrappable { double fontSize, double height, const std::u16string& ellipsis, - const std::string& locale); + const std::string& locale, + bool applyRoundingHack); ~ParagraphBuilder() override; @@ -76,7 +77,8 @@ class ParagraphBuilder : public RefCountedDartWrappable { double fontSize, double height, const std::u16string& ellipsis, - const std::string& locale); + const std::string& locale, + bool applyRoundingHack); std::unique_ptr m_paragraphBuilder; }; diff --git a/lib/web_ui/lib/src/engine/canvaskit/canvaskit_api.dart b/lib/web_ui/lib/src/engine/canvaskit/canvaskit_api.dart index 826c4cc8e735b..c6c0d2ebe5c1a 100644 --- a/lib/web_ui/lib/src/engine/canvaskit/canvaskit_api.dart +++ b/lib/web_ui/lib/src/engine/canvaskit/canvaskit_api.dart @@ -130,19 +130,19 @@ extension CanvasKitExtension on CanvasKit { // Text decoration enum is embedded in the CanvasKit object itself. @JS('NoDecoration') external JSNumber get _NoDecoration; - double get NoDecoration => _NoDecoration.toDart; + double get NoDecoration => _NoDecoration.toDartDouble; @JS('UnderlineDecoration') external JSNumber get _UnderlineDecoration; - double get UnderlineDecoration => _UnderlineDecoration.toDart; + double get UnderlineDecoration => _UnderlineDecoration.toDartDouble; @JS('OverlineDecoration') external JSNumber get _OverlineDecoration; - double get OverlineDecoration => _OverlineDecoration.toDart; + double get OverlineDecoration => _OverlineDecoration.toDartDouble; @JS('LineThroughDecoration') external JSNumber get _LineThroughDecoration; - double get LineThroughDecoration => _LineThroughDecoration.toDart; + double get LineThroughDecoration => _LineThroughDecoration.toDartDouble; // End of text decoration enum. external SkTextDecorationStyleEnum get DecorationStyle; @@ -159,7 +159,7 @@ extension CanvasKitExtension on CanvasKit { DomCanvasElement canvas, SkWebGLContextOptions options); double GetWebGLContext( DomCanvasElement canvas, SkWebGLContextOptions options) => - _GetWebGLContext(canvas, options).toDart; + _GetWebGLContext(canvas, options).toDartDouble; @JS('MakeGrContext') external SkGrContext _MakeGrContext(JSNumber glContext); @@ -286,11 +286,11 @@ extension SkSurfaceExtension on SkSurface { @JS('width') external JSNumber _width(); - double width() => _width().toDart; + double width() => _width().toDartDouble; @JS('height') external JSNumber _height(); - double height() => _height().toDart; + double height() => _height().toDartDouble; external JSVoid dispose(); external SkImage makeImageSnapshot(); @@ -327,7 +327,7 @@ class SkFontSlant {} extension SkFontSlantExtension on SkFontSlant { @JS('value') external JSNumber get _value; - double get value => _value.toDart; + double get value => _value.toDartDouble; } final List _skFontSlants = [ @@ -363,7 +363,7 @@ class SkFontWeight {} extension SkFontWeightExtension on SkFontWeight { @JS('value') external JSNumber get _value; - double get value => _value.toDart; + double get value => _value.toDartDouble; } final List _skFontWeights = [ @@ -398,7 +398,7 @@ class SkAffinity {} extension SkAffinityExtension on SkAffinity { @JS('value') external JSNumber get _value; - double get value => _value.toDart; + double get value => _value.toDartDouble; } final List _skAffinitys = [ @@ -426,7 +426,7 @@ class SkTextDirection {} extension SkTextDirectionExtension on SkTextDirection { @JS('value') external JSNumber get _value; - double get value => _value.toDart; + double get value => _value.toDartDouble; } // Flutter enumerates text directions as RTL, LTR, while CanvasKit @@ -460,7 +460,7 @@ class SkTextAlign {} extension SkTextAlignExtension on SkTextAlign { @JS('value') external JSNumber get _value; - double get value => _value.toDart; + double get value => _value.toDartDouble; } final List _skTextAligns = [ @@ -494,7 +494,7 @@ class SkTextHeightBehavior {} extension SkTextHeightBehaviorExtension on SkTextHeightBehavior { @JS('value') external JSNumber get _value; - double get value => _value.toDart; + double get value => _value.toDartDouble; } final List _skTextHeightBehaviors = @@ -531,7 +531,7 @@ class SkRectHeightStyle {} extension SkRectHeightStyleExtension on SkRectHeightStyle { @JS('value') external JSNumber get _value; - double get value => _value.toDart; + double get value => _value.toDartDouble; } final List _skRectHeightStyles = [ @@ -563,7 +563,7 @@ class SkRectWidthStyle {} extension SkRectWidthStyleExtension on SkRectWidthStyle { @JS('value') external JSNumber get _value; - double get value => _value.toDart; + double get value => _value.toDartDouble; } final List _skRectWidthStyles = [ @@ -593,7 +593,7 @@ class SkVertexMode {} extension SkVertexModeExtension on SkVertexMode { @JS('value') external JSNumber get _value; - double get value => _value.toDart; + double get value => _value.toDartDouble; } final List _skVertexModes = [ @@ -623,7 +623,7 @@ class SkPointMode {} extension SkPointModeExtension on SkPointMode { @JS('value') external JSNumber get _value; - double get value => _value.toDart; + double get value => _value.toDartDouble; } final List _skPointModes = [ @@ -652,7 +652,7 @@ class SkClipOp {} extension SkClipOpExtension on SkClipOp { @JS('value') external JSNumber get _value; - double get value => _value.toDart; + double get value => _value.toDartDouble; } final List _skClipOps = [ @@ -680,7 +680,7 @@ class SkFillType {} extension SkFillTypeExtension on SkFillType { @JS('value') external JSNumber get _value; - double get value => _value.toDart; + double get value => _value.toDartDouble; } final List _skFillTypes = [ @@ -711,7 +711,7 @@ class SkPathOp {} extension SkPathOpExtension on SkPathOp { @JS('value') external JSNumber get _value; - double get value => _value.toDart; + double get value => _value.toDartDouble; } final List _skPathOps = [ @@ -744,7 +744,7 @@ class SkBlurStyle {} extension SkBlurStyleExtension on SkBlurStyle { @JS('value') external JSNumber get _value; - double get value => _value.toDart; + double get value => _value.toDartDouble; } final List _skBlurStyles = [ @@ -775,7 +775,7 @@ class SkStrokeCap {} extension SkStrokeCapExtension on SkStrokeCap { @JS('value') external JSNumber get _value; - double get value => _value.toDart; + double get value => _value.toDartDouble; } final List _skStrokeCaps = [ @@ -804,7 +804,7 @@ class SkPaintStyle {} extension SkPaintStyleExtension on SkPaintStyle { @JS('value') external JSNumber get _value; - double get value => _value.toDart; + double get value => _value.toDartDouble; } final List _skPaintStyles = [ @@ -859,7 +859,7 @@ class SkBlendMode {} extension SkBlendModeExtension on SkBlendMode { @JS('value') external JSNumber get _value; - double get value => _value.toDart; + double get value => _value.toDartDouble; } final List _skBlendModes = [ @@ -915,7 +915,7 @@ class SkStrokeJoin {} extension SkStrokeJoinExtension on SkStrokeJoin { @JS('value') external JSNumber get _value; - double get value => _value.toDart; + double get value => _value.toDartDouble; } final List _skStrokeJoins = [ @@ -946,7 +946,7 @@ class SkTileMode {} extension SkTileModeExtension on SkTileMode { @JS('value') external JSNumber get _value; - double get value => _value.toDart; + double get value => _value.toDartDouble; } final List _skTileModes = [ @@ -976,7 +976,7 @@ class SkFilterMode {} extension SkFilterModeExtension on SkFilterMode { @JS('value') external JSNumber get _value; - double get value => _value.toDart; + double get value => _value.toDartDouble; } SkFilterMode toSkFilterMode(ui.FilterQuality filterQuality) { @@ -1002,7 +1002,7 @@ class SkMipmapMode {} extension SkMipmapModeExtension on SkMipmapMode { @JS('value') external JSNumber get _value; - double get value => _value.toDart; + double get value => _value.toDartDouble; } SkMipmapMode toSkMipmapMode(ui.FilterQuality filterQuality) { @@ -1028,7 +1028,7 @@ class SkAlphaType {} extension SkAlphaTypeExtension on SkAlphaType { @JS('value') external JSNumber get _value; - double get value => _value.toDart; + double get value => _value.toDartDouble; } @JS() @@ -1056,7 +1056,7 @@ class SkColorType {} extension SkColorTypeExtension on SkColorType { @JS('value') external JSNumber get _value; - double get value => _value.toDart; + double get value => _value.toDartDouble; } @JS() @@ -1067,31 +1067,31 @@ class SkAnimatedImage {} extension SkAnimatedImageExtension on SkAnimatedImage { @JS('getFrameCount') external JSNumber _getFrameCount(); - double getFrameCount() => _getFrameCount().toDart; + double getFrameCount() => _getFrameCount().toDartDouble; @JS('getRepetitionCount') external JSNumber _getRepetitionCount(); - double getRepetitionCount() => _getRepetitionCount().toDart; + double getRepetitionCount() => _getRepetitionCount().toDartDouble; /// Returns duration in milliseconds. @JS('currentFrameDuration') external JSNumber _currentFrameDuration(); - double currentFrameDuration() => _currentFrameDuration().toDart; + double currentFrameDuration() => _currentFrameDuration().toDartDouble; /// Advances to the next frame and returns its duration in milliseconds. @JS('decodeNextFrame') external JSNumber _decodeNextFrame(); - double decodeNextFrame() => _decodeNextFrame().toDart; + double decodeNextFrame() => _decodeNextFrame().toDartDouble; external SkImage makeImageAtCurrentFrame(); @JS('width') external JSNumber _width(); - double width() => _width().toDart; + double width() => _width().toDartDouble; @JS('height') external JSNumber _height(); - double height() => _height().toDart; + double height() => _height().toDartDouble; /// Deletes the C++ object. /// @@ -1113,11 +1113,11 @@ extension SkImageExtension on SkImage { @JS('width') external JSNumber _width(); - double width() => _width().toDart; + double width() => _width().toDartDouble; @JS('height') external JSNumber _height(); - double height() => _height().toDart; + double height() => _height().toDartDouble; @JS('makeShaderCubic') external SkShader _makeShaderCubic( @@ -1624,7 +1624,7 @@ extension SkFloat32ListExtension on SkFloat32List { /// The number of objects this pointer refers to. @JS('length') external JSNumber get _length; - double get length => _length.toDart; + double get length => _length.toDartDouble; @JS('length') external set _length(JSNumber length); @@ -1655,7 +1655,7 @@ extension SkUint32ListExtension on SkUint32List { /// The number of objects this pointer refers to. @JS('length') external JSNumber get _length; - double get length => _length.toDart; + double get length => _length.toDartDouble; @JS('length') external set _length(JSNumber length); @@ -2084,7 +2084,7 @@ extension SkContourMeasureExtension on SkContourMeasure { @JS('length') external JSNumber _length(); - double length() => _length().toDart; + double length() => _length().toDartDouble; external JSVoid delete(); } @@ -2513,11 +2513,11 @@ extension SkCanvasExtension on SkCanvas { @JS('save') external JSNumber _save(); - double save() => _save().toDart; + double save() => _save().toDartDouble; @JS('getSaveCount') external JSNumber _getSaveCount(); - double getSaveCount() => _getSaveCount().toDart; + double getSaveCount() => _getSaveCount().toDartDouble; @JS('saveLayer') external JSVoid _saveLayer( @@ -2722,6 +2722,8 @@ extension SkParagraphStylePropertiesExtension on SkParagraphStyleProperties { @JS('replaceTabCharacters') external set _replaceTabCharacters(JSBoolean? bool); set replaceTabCharacters(bool? bool) => _replaceTabCharacters = bool?.toJS; + + external set applyRoundingHack(bool applyRoundingHack); } @JS() @@ -2747,7 +2749,7 @@ class SkTextDecorationStyle {} extension SkTextDecorationStyleExtension on SkTextDecorationStyle { @JS('value') external JSNumber get _value; - double get value => _value.toDart; + double get value => _value.toDartDouble; } final List _skTextDecorationStyles = @@ -2779,7 +2781,7 @@ class SkTextBaseline {} extension SkTextBaselineExtension on SkTextBaseline { @JS('value') external JSNumber get _value; - double get value => _value.toDart; + double get value => _value.toDartDouble; } final List _skTextBaselines = [ @@ -2811,7 +2813,7 @@ class SkPlaceholderAlignment {} extension SkPlaceholderAlignmentExtension on SkPlaceholderAlignment { @JS('value') external JSNumber get _value; - double get value => _value.toDart; + double get value => _value.toDartDouble; } final List _skPlaceholderAlignments = @@ -3101,19 +3103,19 @@ class SkLineMetrics {} extension SkLineMetricsExtension on SkLineMetrics { @JS('startIndex') external JSNumber get _startIndex; - double get startIndex => _startIndex.toDart; + double get startIndex => _startIndex.toDartDouble; @JS('endIndex') external JSNumber get _endIndex; - double get endIndex => _endIndex.toDart; + double get endIndex => _endIndex.toDartDouble; @JS('endExcludingWhitespaces') external JSNumber get _endExcludingWhitespaces; - double get endExcludingWhitespaces => _endExcludingWhitespaces.toDart; + double get endExcludingWhitespaces => _endExcludingWhitespaces.toDartDouble; @JS('endIncludingNewline') external JSNumber get _endIncludingNewline; - double get endIncludingNewline => _endIncludingNewline.toDart; + double get endIncludingNewline => _endIncludingNewline.toDartDouble; @JS('isHardBreak') external JSBoolean get _isHardBreak; @@ -3121,31 +3123,31 @@ extension SkLineMetricsExtension on SkLineMetrics { @JS('ascent') external JSNumber get _ascent; - double get ascent => _ascent.toDart; + double get ascent => _ascent.toDartDouble; @JS('descent') external JSNumber get _descent; - double get descent => _descent.toDart; + double get descent => _descent.toDartDouble; @JS('height') external JSNumber get _height; - double get height => _height.toDart; + double get height => _height.toDartDouble; @JS('width') external JSNumber get _width; - double get width => _width.toDart; + double get width => _width.toDartDouble; @JS('left') external JSNumber get _left; - double get left => _left.toDart; + double get left => _left.toDartDouble; @JS('baseline') external JSNumber get _baseline; - double get baseline => _baseline.toDart; + double get baseline => _baseline.toDartDouble; @JS('lineNumber') external JSNumber get _lineNumber; - double get lineNumber => _lineNumber.toDart; + double get lineNumber => _lineNumber.toDartDouble; } @JS() @@ -3173,7 +3175,7 @@ class SkParagraph {} extension SkParagraphExtension on SkParagraph { @JS('getAlphabeticBaseline') external JSNumber _getAlphabeticBaseline(); - double getAlphabeticBaseline() => _getAlphabeticBaseline().toDart; + double getAlphabeticBaseline() => _getAlphabeticBaseline().toDartDouble; @JS('didExceedMaxLines') external JSBoolean _didExceedMaxLines(); @@ -3181,11 +3183,11 @@ extension SkParagraphExtension on SkParagraph { @JS('getHeight') external JSNumber _getHeight(); - double getHeight() => _getHeight().toDart; + double getHeight() => _getHeight().toDartDouble; @JS('getIdeographicBaseline') external JSNumber _getIdeographicBaseline(); - double getIdeographicBaseline() => _getIdeographicBaseline().toDart; + double getIdeographicBaseline() => _getIdeographicBaseline().toDartDouble; @JS('getLineMetrics') external JSArray _getLineMetrics(); @@ -3194,19 +3196,19 @@ extension SkParagraphExtension on SkParagraph { @JS('getLongestLine') external JSNumber _getLongestLine(); - double getLongestLine() => _getLongestLine().toDart; + double getLongestLine() => _getLongestLine().toDartDouble; @JS('getMaxIntrinsicWidth') external JSNumber _getMaxIntrinsicWidth(); - double getMaxIntrinsicWidth() => _getMaxIntrinsicWidth().toDart; + double getMaxIntrinsicWidth() => _getMaxIntrinsicWidth().toDartDouble; @JS('getMinIntrinsicWidth') external JSNumber _getMinIntrinsicWidth(); - double getMinIntrinsicWidth() => _getMinIntrinsicWidth().toDart; + double getMinIntrinsicWidth() => _getMinIntrinsicWidth().toDartDouble; @JS('getMaxWidth') external JSNumber _getMaxWidth(); - double getMaxWidth() => _getMaxWidth().toDart; + double getMaxWidth() => _getMaxWidth().toDartDouble; @JS('getRectsForRange') external JSArray _getRectsForRange( @@ -3259,7 +3261,7 @@ extension SkTextPositionExtnsion on SkTextPosition { @JS('pos') external JSNumber get _pos; - double get pos => _pos.toDart; + double get pos => _pos.toDartDouble; } @JS() @@ -3269,11 +3271,11 @@ class SkTextRange {} extension SkTextRangeExtension on SkTextRange { @JS('start') external JSNumber get _start; - double get start => _start.toDart; + double get start => _start.toDartDouble; @JS('end') external JSNumber get _end; - double get end => _end.toDart; + double get end => _end.toDartDouble; } @JS() @@ -3391,7 +3393,7 @@ class SkData {} extension SkDataExtension on SkData { @JS('size') external JSNumber _size(); - double size() => _size().toDart; + double size() => _size().toDartDouble; @JS('isEmpty') external JSBoolean _isEmpty(); @@ -3435,7 +3437,7 @@ extension SkImageInfoExtension on SkImageInfo { @JS('height') external JSNumber get _height; - double get height => _height.toDart; + double get height => _height.toDartDouble; @JS('isEmpty') external JSBoolean get _isEmpty; @@ -3451,7 +3453,7 @@ extension SkImageInfoExtension on SkImageInfo { @JS('width') external JSNumber get _width; - double get width => _width.toDart; + double get width => _width.toDartDouble; external SkImageInfo makeAlphaType(SkAlphaType alphaType); external SkImageInfo makeColorSpace(ColorSpace colorSpace); @@ -3494,11 +3496,11 @@ extension SkPartialImageInfoExtension on SkPartialImageInfo { @JS('height') external JSNumber get _height; - double get height => _height.toDart; + double get height => _height.toDartDouble; @JS('width') external JSNumber get _width; - double get width => _width.toDart; + double get width => _width.toDartDouble; } @JS('window.flutterCanvasKit.RuntimeEffect') diff --git a/lib/web_ui/lib/src/engine/canvaskit/image.dart b/lib/web_ui/lib/src/engine/canvaskit/image.dart index 77fe97e73a3fe..2fcfa6b6f3791 100644 --- a/lib/web_ui/lib/src/engine/canvaskit/image.dart +++ b/lib/web_ui/lib/src/engine/canvaskit/image.dart @@ -205,10 +205,10 @@ Future readChunked(HttpFetchPayload payload, int contentLength, WebOn int position = 0; int cumulativeBytesLoaded = 0; await payload.read((JSUint8Array1 chunk) { - cumulativeBytesLoaded += chunk.length.toDart.toInt(); + cumulativeBytesLoaded += chunk.length.toDartInt; chunkCallback(cumulativeBytesLoaded, contentLength); result.set(chunk, position.toJS); - position += chunk.length.toDart.toInt(); + position += chunk.length.toDartInt; }); return result.toDart; } diff --git a/lib/web_ui/lib/src/engine/canvaskit/renderer.dart b/lib/web_ui/lib/src/engine/canvaskit/renderer.dart index 834446ef26d82..96da491f69af4 100644 --- a/lib/web_ui/lib/src/engine/canvaskit/renderer.dart +++ b/lib/web_ui/lib/src/engine/canvaskit/renderer.dart @@ -328,6 +328,7 @@ class CanvasKitRenderer implements Renderer { strutStyle: strutStyle, ellipsis: ellipsis, locale: locale, + applyRoundingHack: !ui.ParagraphBuilder.shouldDisableRoundingHack, ); @override diff --git a/lib/web_ui/lib/src/engine/canvaskit/text.dart b/lib/web_ui/lib/src/engine/canvaskit/text.dart index 6fe5a29a48db3..0948916b5d799 100644 --- a/lib/web_ui/lib/src/engine/canvaskit/text.dart +++ b/lib/web_ui/lib/src/engine/canvaskit/text.dart @@ -33,6 +33,7 @@ class CkParagraphStyle implements ui.ParagraphStyle { ui.StrutStyle? strutStyle, String? ellipsis, ui.Locale? locale, + bool applyRoundingHack = true, }) : skParagraphStyle = toSkParagraphStyle( textAlign, textDirection, @@ -46,6 +47,7 @@ class CkParagraphStyle implements ui.ParagraphStyle { strutStyle, ellipsis, locale, + applyRoundingHack, ), _fontFamily = _effectiveFontFamily(fontFamily), _fontSize = fontSize, @@ -145,6 +147,7 @@ class CkParagraphStyle implements ui.ParagraphStyle { ui.StrutStyle? strutStyle, String? ellipsis, ui.Locale? locale, + bool applyRoundingHack, ) { final SkParagraphStyleProperties properties = SkParagraphStyleProperties(); @@ -181,6 +184,7 @@ class CkParagraphStyle implements ui.ParagraphStyle { properties.replaceTabCharacters = true; properties.textStyle = toSkTextStyleProperties( fontFamily, fontSize, height, fontWeight, fontStyle); + properties.applyRoundingHack = applyRoundingHack; return canvasKit.ParagraphStyle(properties); } diff --git a/lib/web_ui/lib/src/engine/configuration.dart b/lib/web_ui/lib/src/engine/configuration.dart index 022dee08b97fb..a2038c8492000 100644 --- a/lib/web_ui/lib/src/engine/configuration.dart +++ b/lib/web_ui/lib/src/engine/configuration.dart @@ -317,7 +317,7 @@ extension JsFlutterConfigurationExtension on JsFlutterConfiguration { @JS('canvasKitMaximumSurfaces') external JSNumber? get _canvasKitMaximumSurfaces; - double? get canvasKitMaximumSurfaces => _canvasKitMaximumSurfaces?.toDart; + double? get canvasKitMaximumSurfaces => _canvasKitMaximumSurfaces?.toDartDouble; @JS('debugShowSemanticsNodes') external JSBoolean? get _debugShowSemanticsNodes; diff --git a/lib/web_ui/lib/src/engine/dom.dart b/lib/web_ui/lib/src/engine/dom.dart index 0b24dc5a8d45a..dfb1b7b9b1d25 100644 --- a/lib/web_ui/lib/src/engine/dom.dart +++ b/lib/web_ui/lib/src/engine/dom.dart @@ -41,9 +41,6 @@ extension ObjectToJSAnyExtension on Object { if (isWasm) { return toJSAnyDeep; } else { - // TODO(joshualitt): remove this cast when we reify JS types on JS - // backends. - // ignore: unnecessary_cast return this as JSAny; } } @@ -76,18 +73,18 @@ extension DomWindowExtension on DomWindow { @JS('devicePixelRatio') external JSNumber get _devicePixelRatio; - double get devicePixelRatio => _devicePixelRatio.toDart; + double get devicePixelRatio => _devicePixelRatio.toDartDouble; external DomDocument get document; external DomHistory get history; @JS('innerHeight') external JSNumber? get _innerHeight; - double? get innerHeight => _innerHeight?.toDart; + double? get innerHeight => _innerHeight?.toDartDouble; @JS('innerWidth') external JSNumber? get _innerWidth; - double? get innerWidth => _innerWidth?.toDart; + double? get innerWidth => _innerWidth?.toDartDouble; external DomLocation get location; external DomNavigator get navigator; @@ -139,7 +136,7 @@ extension DomWindowExtension on DomWindow { @JS('requestAnimationFrame') external JSNumber _requestAnimationFrame(JSFunction callback); double requestAnimationFrame(DomRequestAnimationFrameCallback callback) => - _requestAnimationFrame(callback.toJS).toDart; + _requestAnimationFrame(callback.toJS).toDartDouble; @JS('postMessage') external JSVoid _postMessage1(JSAny message, JSString targetOrigin); @@ -203,7 +200,7 @@ extension DomNavigatorExtension on DomNavigator { @JS('maxTouchPoints') external JSNumber? get _maxTouchPoints; - double? get maxTouchPoints => _maxTouchPoints?.toDart; + double? get maxTouchPoints => _maxTouchPoints?.toDartDouble; @JS('vendor') external JSString get _vendor; @@ -385,7 +382,7 @@ extension DomEventExtension on DomEvent { @JS('timeStamp') external JSNumber? get _timeStamp; - double? get timeStamp => _timeStamp?.toDart; + double? get timeStamp => _timeStamp?.toDartDouble; @JS('type') external JSString get _type; @@ -432,11 +429,11 @@ class DomProgressEvent extends DomEvent { extension DomProgressEventExtension on DomProgressEvent { @JS('loaded') external JSNumber? get _loaded; - double? get loaded => _loaded?.toDart; + double? get loaded => _loaded?.toDartDouble; @JS('total') external JSNumber? get _total; - double? get total => _total?.toDart; + double? get total => _total?.toDartDouble; } @JS() @@ -528,11 +525,11 @@ extension DomElementExtension on DomElement { @JS('clientHeight') external JSNumber get _clientHeight; - double get clientHeight => _clientHeight.toDart; + double get clientHeight => _clientHeight.toDartDouble; @JS('clientWidth') external JSNumber get _clientWidth; - double get clientWidth => _clientWidth.toDart; + double get clientWidth => _clientWidth.toDartDouble; @JS('id') external JSString get _id; @@ -597,13 +594,13 @@ extension DomElementExtension on DomElement { @JS('tabIndex') external JSNumber? get _tabIndex; - double? get tabIndex => _tabIndex?.toDart; + double? get tabIndex => _tabIndex?.toDartDouble; external JSVoid focus(); @JS('scrollTop') external JSNumber get _scrollTop; - double get scrollTop => _scrollTop.toDart; + double get scrollTop => _scrollTop.toDartDouble; @JS('scrollTop') external set _scrollTop(JSNumber value); @@ -611,7 +608,7 @@ extension DomElementExtension on DomElement { @JS('scrollLeft') external JSNumber get _scrollLeft; - double get scrollLeft => _scrollLeft.toDart; + double get scrollLeft => _scrollLeft.toDartDouble; @JS('scrollLeft') external set _scrollLeft(JSNumber value); @@ -828,15 +825,15 @@ class DomHTMLElement extends DomElement {} extension DomHTMLElementExtension on DomHTMLElement { @JS('offsetWidth') external JSNumber get _offsetWidth; - double get offsetWidth => _offsetWidth.toDart; + double get offsetWidth => _offsetWidth.toDartDouble; @JS('offsetLeft') external JSNumber get _offsetLeft; - double get offsetLeft => _offsetLeft.toDart; + double get offsetLeft => _offsetLeft.toDartDouble; @JS('offsetTop') external JSNumber get _offsetTop; - double get offsetTop => _offsetTop.toDart; + double get offsetTop => _offsetTop.toDartDouble; external DomHTMLElement? get offsetParent; } @@ -901,11 +898,11 @@ extension DomHTMLImageElementExtension on DomHTMLImageElement { @JS('naturalWidth') external JSNumber get _naturalWidth; - double get naturalWidth => _naturalWidth.toDart; + double get naturalWidth => _naturalWidth.toDartDouble; @JS('naturalHeight') external JSNumber get _naturalHeight; - double get naturalHeight => _naturalHeight.toDart; + double get naturalHeight => _naturalHeight.toDartDouble; @JS('width') external set _width(JSNumber? value); @@ -1019,7 +1016,7 @@ extension DomPerformanceExtension on DomPerformance { @JS('now') external JSNumber _now(); - double now() => _now().toDart; + double now() => _now().toDartDouble; } @JS() @@ -1058,7 +1055,7 @@ DomCanvasElement createDomCanvasElement({int? width, int? height}) { extension DomCanvasElementExtension on DomCanvasElement { @JS('width') external JSNumber? get _width; - double? get width => _width?.toDart; + double? get width => _width?.toDartDouble; @JS('width') external set _width(JSNumber? value); @@ -1066,7 +1063,7 @@ extension DomCanvasElementExtension on DomCanvasElement { @JS('height') external JSNumber? get _height; - double? get height => _height?.toDart; + double? get height => _height?.toDartDouble; @JS('height') external set _height(JSNumber? value); @@ -1110,15 +1107,15 @@ class WebGLContext {} extension WebGLContextExtension on WebGLContext { @JS('getParameter') external JSNumber _getParameter(JSNumber value); - int getParameter(int value) => _getParameter(value.toJS).toDart.toInt(); + int getParameter(int value) => _getParameter(value.toJS).toDartDouble.toInt(); @JS('SAMPLES') external JSNumber get _samples; - int get samples => _samples.toDart.toInt(); + int get samples => _samples.toDartDouble.toInt(); @JS('STENCIL_BITS') external JSNumber get _stencilBits; - int get stencilBits => _stencilBits.toDart.toInt(); + int get stencilBits => _stencilBits.toDartDouble.toInt(); } @JS() @@ -1778,7 +1775,7 @@ class DomResponse {} extension DomResponseExtension on DomResponse { @JS('status') external JSNumber get _status; - int get status => _status.toDart.toInt(); + int get status => _status.toDartInt; external DomHeaders get headers; @@ -1856,7 +1853,7 @@ class DomTextMetrics {} extension DomTextMetricsExtension on DomTextMetrics { @JS('width') external JSNumber? get _width; - double? get width => _width?.toDart; + double? get width => _width?.toDartDouble; } @JS() @@ -1878,35 +1875,35 @@ class DomRectReadOnly {} extension DomRectReadOnlyExtension on DomRectReadOnly { @JS('x') external JSNumber get _x; - double get x => _x.toDart; + double get x => _x.toDartDouble; @JS('y') external JSNumber get _y; - double get y => _y.toDart; + double get y => _y.toDartDouble; @JS('width') external JSNumber get _width; - double get width => _width.toDart; + double get width => _width.toDartDouble; @JS('height') external JSNumber get _height; - double get height => _height.toDart; + double get height => _height.toDartDouble; @JS('top') external JSNumber get _top; - double get top => _top.toDart; + double get top => _top.toDartDouble; @JS('right') external JSNumber get _right; - double get right => _right.toDart; + double get right => _right.toDartDouble; @JS('bottom') external JSNumber get _bottom; - double get bottom => _bottom.toDart; + double get bottom => _bottom.toDartDouble; @JS('left') external JSNumber get _left; - double get left => _left.toDart; + double get left => _left.toDartDouble; } DomRect createDomRectFromPoints(DomPoint a, DomPoint b) { @@ -1984,11 +1981,11 @@ class DomVisualViewport extends DomEventTarget {} extension DomVisualViewportExtension on DomVisualViewport { @JS('height') external JSNumber? get _height; - double? get height => _height?.toDart; + double? get height => _height?.toDartDouble; @JS('width') external JSNumber? get _width; - double? get width => _width?.toDart; + double? get width => _width?.toDartDouble; } @JS() @@ -2015,11 +2012,11 @@ extension DomHTMLTextAreaElementExtension on DomHTMLTextAreaElement { @JS('selectionStart') external JSNumber? get _selectionStart; - double? get selectionStart => _selectionStart?.toDart; + double? get selectionStart => _selectionStart?.toDartDouble; @JS('selectionEnd') external JSNumber? get _selectionEnd; - double? get selectionEnd => _selectionEnd?.toDart; + double? get selectionEnd => _selectionEnd?.toDartDouble; @JS('selectionStart') external set _selectionStart(JSNumber? value); @@ -2100,11 +2097,11 @@ extension DomKeyboardEventExtension on DomKeyboardEvent { @JS('keyCode') external JSNumber get _keyCode; - double get keyCode => _keyCode.toDart; + double get keyCode => _keyCode.toDartDouble; @JS('location') external JSNumber get _location; - double get location => _location.toDart; + double get location => _location.toDartDouble; @JS('metaKey') external JSBoolean get _metaKey; @@ -2354,38 +2351,38 @@ class DomMouseEvent extends DomUIEvent { extension DomMouseEventExtension on DomMouseEvent { @JS('clientX') external JSNumber get _clientX; - double get clientX => _clientX.toDart; + double get clientX => _clientX.toDartDouble; @JS('clientY') external JSNumber get _clientY; - double get clientY => _clientY.toDart; + double get clientY => _clientY.toDartDouble; @JS('offsetX') external JSNumber get _offsetX; - double get offsetX => _offsetX.toDart; + double get offsetX => _offsetX.toDartDouble; @JS('offsetY') external JSNumber get _offsetY; - double get offsetY => _offsetY.toDart; + double get offsetY => _offsetY.toDartDouble; @JS('pageX') external JSNumber get _pageX; - double get pageX => _pageX.toDart; + double get pageX => _pageX.toDartDouble; @JS('pageY') external JSNumber get _pageY; - double get pageY => _pageY.toDart; + double get pageY => _pageY.toDartDouble; DomPoint get client => DomPoint(clientX, clientY); DomPoint get offset => DomPoint(offsetX, offsetY); @JS('button') external JSNumber get _button; - double get button => _button.toDart; + double get button => _button.toDartDouble; @JS('buttons') external JSNumber? get _buttons; - double? get buttons => _buttons?.toDart; + double? get buttons => _buttons?.toDartDouble; @JS('ctrlKey') external JSBoolean get _ctrlKey; @@ -2414,7 +2411,7 @@ class DomPointerEvent extends DomMouseEvent { extension DomPointerEventExtension on DomPointerEvent { @JS('pointerId') external JSNumber? get _pointerId; - double? get pointerId => _pointerId?.toDart; + double? get pointerId => _pointerId?.toDartDouble; @JS('pointerType') external JSString? get _pointerType; @@ -2422,15 +2419,15 @@ extension DomPointerEventExtension on DomPointerEvent { @JS('pressure') external JSNumber? get _pressure; - double? get pressure => _pressure?.toDart; + double? get pressure => _pressure?.toDartDouble; @JS('tiltX') external JSNumber? get _tiltX; - double? get tiltX => _tiltX?.toDart; + double? get tiltX => _tiltX?.toDartDouble; @JS('tiltY') external JSNumber? get _tiltY; - double? get tiltY => _tiltY?.toDart; + double? get tiltY => _tiltY?.toDartDouble; @JS('getCoalescedEvents') external JSArray _getCoalescedEvents(); @@ -2457,23 +2454,23 @@ class DomWheelEvent extends DomMouseEvent { extension DomWheelEventExtension on DomWheelEvent { @JS('deltaX') external JSNumber get _deltaX; - double get deltaX => _deltaX.toDart; + double get deltaX => _deltaX.toDartDouble; @JS('deltaY') external JSNumber get _deltaY; - double get deltaY => _deltaY.toDart; + double get deltaY => _deltaY.toDartDouble; @JS('wheelDeltaX') external JSNumber? get _wheelDeltaX; - double? get wheelDeltaX => _wheelDeltaX?.toDart; + double? get wheelDeltaX => _wheelDeltaX?.toDartDouble; @JS('wheelDeltaY') external JSNumber? get _wheelDeltaY; - double? get wheelDeltaY => _wheelDeltaY?.toDart; + double? get wheelDeltaY => _wheelDeltaY?.toDartDouble; @JS('deltaMode') external JSNumber get _deltaMode; - double get deltaMode => _deltaMode.toDart; + double get deltaMode => _deltaMode.toDartDouble; } DomWheelEvent createDomWheelEvent(String type, [Map? init]) { @@ -2524,15 +2521,15 @@ class DomTouch { extension DomTouchExtension on DomTouch { @JS('identifier') external JSNumber? get _identifier; - double? get identifier => _identifier?.toDart; + double? get identifier => _identifier?.toDartDouble; @JS('clientX') external JSNumber get _clientX; - double get clientX => _clientX.toDart; + double get clientX => _clientX.toDartDouble; @JS('clientY') external JSNumber get _clientY; - double get clientY => _clientY.toDart; + double get clientY => _clientY.toDartDouble; DomPoint get client => DomPoint(clientX, clientY); } @@ -2622,11 +2619,11 @@ extension DomHTMLInputElementExtension on DomHTMLInputElement { @JS('selectionStart') external JSNumber? get _selectionStart; - double? get selectionStart => _selectionStart?.toDart; + double? get selectionStart => _selectionStart?.toDartDouble; @JS('selectionEnd') external JSNumber? get _selectionEnd; - double? get selectionEnd => _selectionEnd?.toDart; + double? get selectionEnd => _selectionEnd?.toDartDouble; @JS('selectionStart') external set _selectionStart(JSNumber? value); @@ -2724,11 +2721,11 @@ class DomOffscreenCanvas extends DomEventTarget { extension DomOffscreenCanvasExtension on DomOffscreenCanvas { @JS('height') external JSNumber? get _height; - double? get height => _height?.toDart; + double? get height => _height?.toDartDouble; @JS('width') external JSNumber? get _width; - double? get width => _width?.toDart; + double? get width => _width?.toDartDouble; @JS('height') external set _height(JSNumber? value); @@ -2837,9 +2834,9 @@ extension DomCSSStyleSheetExtension on DomCSSStyleSheet { external JSNumber _insertRule2(JSString rule, JSNumber index); double insertRule(String rule, [int? index]) { if (index == null) { - return _insertRule1(rule.toJS).toDart; + return _insertRule1(rule.toJS).toDartDouble; } else { - return _insertRule2(rule.toJS, index.toJS).toDart; + return _insertRule2(rule.toJS, index.toJS).toDartDouble; } } } @@ -3191,7 +3188,7 @@ class _DomList {} extension DomListExtension on _DomList { @JS('length') external JSNumber get _length; - double get length => _length.toDart; + double get length => _length.toDartDouble; @JS('item') external DomNode _item(JSNumber index); @@ -3243,7 +3240,7 @@ class _DomTouchList {} extension DomTouchListExtension on _DomTouchList { @JS('length') external JSNumber get _length; - double get length => _length.toDart; + double get length => _length.toDartDouble; @JS('item') external DomNode _item(JSNumber index); @@ -3386,7 +3383,7 @@ class DomSegment {} extension DomSegmentExtension on DomSegment { @JS('index') external JSNumber get _index; - int get index => _index.toDart.toInt(); + int get index => _index.toDartDouble.toInt(); @JS('isWordLike') external JSBoolean get _isWordLike; @@ -3424,15 +3421,15 @@ extension DomV8BreakIteratorExtension on DomV8BreakIterator { @JS('first') external JSNumber _first(); - double first() => _first().toDart; + double first() => _first().toDartDouble; @JS('next') external JSNumber _next(); - double next() => _next().toDart; + double next() => _next().toDartDouble; @JS('current') external JSNumber _current(); - double current() => _current().toDart; + double current() => _current().toDartDouble; @JS('breakType') external JSString _breakType(); diff --git a/lib/web_ui/lib/src/engine/initialization.dart b/lib/web_ui/lib/src/engine/initialization.dart index 94340b6d22c7f..5e94e5a78b77b 100644 --- a/lib/web_ui/lib/src/engine/initialization.dart +++ b/lib/web_ui/lib/src/engine/initialization.dart @@ -169,7 +169,8 @@ Future initializeEngineServices({ // milliseconds as a double value, with sub-millisecond information // hidden in the fraction. So we first multiply it by 1000 to uncover // microsecond precision, and only then convert to `int`. - final int highResTimeMicroseconds = (1000 * highResTime.toDart).toInt(); + final int highResTimeMicroseconds = + (1000 * highResTime.toDartDouble).toInt(); // In Flutter terminology "building a frame" consists of "beginning // frame" and "drawing frame". diff --git a/lib/web_ui/lib/src/engine/profiler.dart b/lib/web_ui/lib/src/engine/profiler.dart index ec2d97abc96a4..fa5c3c47debe0 100644 --- a/lib/web_ui/lib/src/engine/profiler.dart +++ b/lib/web_ui/lib/src/engine/profiler.dart @@ -12,8 +12,7 @@ import 'platform_dispatcher.dart'; import 'safe_browser_api.dart'; @JS('window._flutter_internal_on_benchmark') -external JSAny? get _onBenchmark; -Object? get onBenchmark => _onBenchmark?.toObjectShallow; +external JSExportedDartFunction? get onBenchmark; /// A function that computes a value of type [R]. /// @@ -106,7 +105,7 @@ class Profiler { void benchmark(String name, double value) { _checkBenchmarkMode(); - final OnBenchmark? callback = onBenchmark as OnBenchmark?; + final OnBenchmark? callback = onBenchmark?.toDart as OnBenchmark?; if (callback != null) { callback(name, value); } diff --git a/lib/web_ui/lib/src/engine/safe_browser_api.dart b/lib/web_ui/lib/src/engine/safe_browser_api.dart index bc7b6bd3a4e7b..59fc2bf5a00e2 100644 --- a/lib/web_ui/lib/src/engine/safe_browser_api.dart +++ b/lib/web_ui/lib/src/engine/safe_browser_api.dart @@ -302,7 +302,7 @@ class VideoFrame implements DomCanvasImageSource {} extension VideoFrameExtension on VideoFrame { @JS('allocationSize') external JSNumber _allocationSize(); - double allocationSize() => _allocationSize().toDart; + double allocationSize() => _allocationSize().toDartDouble; @JS('copyTo') external JsPromise _copyTo(JSAny destination); @@ -314,23 +314,23 @@ extension VideoFrameExtension on VideoFrame { @JS('codedWidth') external JSNumber get _codedWidth; - double get codedWidth => _codedWidth.toDart; + double get codedWidth => _codedWidth.toDartDouble; @JS('codedHeight') external JSNumber get _codedHeight; - double get codedHeight => _codedHeight.toDart; + double get codedHeight => _codedHeight.toDartDouble; @JS('displayWidth') external JSNumber get _displayWidth; - double get displayWidth => _displayWidth.toDart; + double get displayWidth => _displayWidth.toDartDouble; @JS('displayHeight') external JSNumber get _displayHeight; - double get displayHeight => _displayHeight.toDart; + double get displayHeight => _displayHeight.toDartDouble; @JS('duration') external JSNumber? get _duration; - double? get duration => _duration?.toDart; + double? get duration => _duration?.toDartDouble; external VideoFrame clone(); external JSVoid close(); @@ -364,11 +364,11 @@ class ImageTrack {} extension ImageTrackExtension on ImageTrack { @JS('repetitionCount') external JSNumber get _repetitionCount; - double get repetitionCount => _repetitionCount.toDart; + double get repetitionCount => _repetitionCount.toDartDouble; @JS('frameCount') external JSNumber get _frameCount; - double get frameCount => _frameCount.toDart; + double get frameCount => _frameCount.toDartDouble; } void scaleCanvas2D(Object context2d, num x, num y) { diff --git a/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/font_collection.dart b/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/font_collection.dart index f5c544bbd827f..ed7a9dd85ce2b 100644 --- a/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/font_collection.dart +++ b/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/font_collection.dart @@ -110,7 +110,7 @@ class SkwasmFontCollection implements FlutterFontCollection { int length = 0; final List chunks = []; await response.read((JSUint8Array chunk) { - length += chunk.length.toDart.toInt(); + length += chunk.length.toDartInt; chunks.add(chunk); }); final SkDataHandle fontData = skDataCreate(length); @@ -118,7 +118,7 @@ class SkwasmFontCollection implements FlutterFontCollection { final JSUint8Array wasmMemory = createUint8ArrayFromBuffer(skwasmInstance.wasmMemory.buffer); for (final JSUint8Array chunk in chunks) { wasmMemory.set(chunk, dataAddress.toJS); - dataAddress += chunk.length.toDart.toInt(); + dataAddress += chunk.length.toDartInt; } final SkwasmTypeface typeface = SkwasmTypeface(fontData); skDataDispose(fontData); @@ -138,7 +138,7 @@ class SkwasmFontCollection implements FlutterFontCollection { int length = 0; final List chunks = []; await response.read((JSUint8Array chunk) { - length += chunk.length.toDart.toInt(); + length += chunk.length.toDartInt; chunks.add(chunk); }); final SkDataHandle fontData = skDataCreate(length); @@ -146,7 +146,7 @@ class SkwasmFontCollection implements FlutterFontCollection { final JSUint8Array wasmMemory = createUint8ArrayFromBuffer(skwasmInstance.wasmMemory.buffer); for (final JSUint8Array chunk in chunks) { wasmMemory.set(chunk, dataAddress.toJS); - dataAddress += chunk.length.toDart.toInt(); + dataAddress += chunk.length.toDartInt; } final SkwasmTypeface typeface = SkwasmTypeface(fontData); diff --git a/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/memory.dart b/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/memory.dart index 2497f83490ff0..030122c83f5e3 100644 --- a/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/memory.dart +++ b/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/memory.dart @@ -29,7 +29,7 @@ typedef DisposeFunction = void Function(Pointer); class SkwasmFinalizationRegistry { SkwasmFinalizationRegistry(this.dispose) : registry = createDomFinalizationRegistry(((JSNumber address) => - dispose(Pointer.fromAddress(address.toDart.toInt())) + dispose(Pointer.fromAddress(address.toDartDouble.toInt())) ).toJS); final DomFinalizationRegistry registry; diff --git a/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/surface.dart b/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/surface.dart index 049e770203b9f..d4bd716de2b3c 100644 --- a/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/surface.dart +++ b/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/surface.dart @@ -37,7 +37,7 @@ class SkwasmSurface { skwasmInstance.addFunction( _callbackHandler.toJS, 'vii'.toJS - ).toDart.toInt() + ).toDartDouble.toInt() ); surfaceSetCallbackHandler(handle, _callbackHandle); } @@ -75,9 +75,9 @@ class SkwasmSurface { } void _callbackHandler(JSNumber jsCallbackId, JSNumber jsPointer) { - final int callbackId = jsCallbackId.toDart.toInt(); + final int callbackId = jsCallbackId.toDartDouble.toInt(); final Completer completer = _pendingCallbacks.remove(callbackId)!; - completer.complete(jsPointer.toDart.toInt()); + completer.complete(jsPointer.toDartDouble.toInt()); } void dispose() { diff --git a/lib/web_ui/lib/text.dart b/lib/web_ui/lib/text.dart index 491966a0f88c2..dea0c720db9ec 100644 --- a/lib/web_ui/lib/text.dart +++ b/lib/web_ui/lib/text.dart @@ -685,6 +685,19 @@ abstract class Paragraph { abstract class ParagraphBuilder { factory ParagraphBuilder(ParagraphStyle style) => engine.renderer.createParagraphBuilder(style); + + static bool get shouldDisableRoundingHack { + return const bool.hasEnvironment('SKPARAGRAPH_REMOVE_ROUNDING_HACK') + || _roundingHackDisabledInDebugMode; + } + static bool _roundingHackDisabledInDebugMode = true; + static void setDisableRoundingHack(bool disableRoundingHack) { + assert(() { + _roundingHackDisabledInDebugMode = disableRoundingHack; + return true; + }()); + } + void pushStyle(TextStyle style); void pop(); void addText(String text); diff --git a/lib/web_ui/test/canvaskit/text_test.dart b/lib/web_ui/test/canvaskit/text_test.dart index 8d4af676480fe..d906cabc33167 100644 --- a/lib/web_ui/test/canvaskit/text_test.dart +++ b/lib/web_ui/test/canvaskit/text_test.dart @@ -123,7 +123,29 @@ void testMain() { } }); }); + + test('applyRoundingHack works', () { + const double fontSize = 1.25; + const String text = '12345'; + assert((fontSize * text.length).truncate() != fontSize * text.length); + final bool roundingHackWasDisabled = ui.ParagraphBuilder.shouldDisableRoundingHack; + ui.ParagraphBuilder.setDisableRoundingHack(true); + final ui.ParagraphBuilder builder = ui.ParagraphBuilder( + ui.ParagraphStyle(fontSize: fontSize, fontFamily: 'FlutterTest'), + ); + builder.addText(text); + final ui.Paragraph paragraph = builder.build() + ..layout(const ui.ParagraphConstraints(width: text.length * fontSize)); + + expect(paragraph.maxIntrinsicWidth, text.length * fontSize); + switch (paragraph.computeLineMetrics()) { + case [ui.LineMetrics(width: final double width)]: + expect(width, text.length * fontSize); + case final List metrics: + expect(metrics, hasLength(1)); + } + ui.ParagraphBuilder.setDisableRoundingHack(roundingHackWasDisabled); + }); // TODO(hterkelsen): https://github.com/flutter/flutter/issues/71520 }, skip: isSafari || isFirefox); - } diff --git a/lib/web_ui/test/engine/profiler_test.dart b/lib/web_ui/test/engine/profiler_test.dart index 551af1225e3ec..8aa36c8e2e101 100644 --- a/lib/web_ui/test/engine/profiler_test.dart +++ b/lib/web_ui/test/engine/profiler_test.dart @@ -4,7 +4,6 @@ import 'dart:js_interop'; -import 'package:js/js_util.dart' as js_util; import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; @@ -12,8 +11,7 @@ import 'package:ui/src/engine.dart'; import '../common/spy.dart'; @JS('window._flutter_internal_on_benchmark') -external set _onBenchmark (JSAny? object); -set onBenchmark (Object? object) => _onBenchmark = object?.toJSAnyShallow; +external set onBenchmark(JSAny? object); void main() { internalBootstrapBrowserTest(() => testMain); @@ -46,9 +44,9 @@ void _profilerTests() { test('can listen to benchmarks', () { final List data = []; - onBenchmark = js_util.allowInterop((String name, num value) { + onBenchmark = (String name, num value) { data.add(BenchmarkDatapoint(name, value)); - }); + }.toJS; Profiler.instance.benchmark('foo', 123); expect(data, [BenchmarkDatapoint('foo', 123)]); @@ -69,9 +67,9 @@ void _profilerTests() { final List data = []; // Wrong callback signature. - onBenchmark = js_util.allowInterop((num value) { + onBenchmark = (num value) { data.add(BenchmarkDatapoint('bad', value)); - }); + }.toJS; expect( () => Profiler.instance.benchmark('foo', 123), @@ -82,10 +80,12 @@ void _profilerTests() { expect(data, isEmpty); // Not even a callback. - onBenchmark = 'string'; + onBenchmark = 'string'.toJS; expect( () => Profiler.instance.benchmark('foo', 123), - throwsA(isA()), + // dart2js throws a TypeError, while dart2wasm throws an explicit + // exception. + throwsA(anything), ); }); } diff --git a/shell/common/BUILD.gn b/shell/common/BUILD.gn index 19009938162fc..c5a4db91e4333 100644 --- a/shell/common/BUILD.gn +++ b/shell/common/BUILD.gn @@ -81,8 +81,6 @@ source_set("common") { sources = [ "animator.cc", "animator.h", - "canvas_spy.cc", - "canvas_spy.h", "context_options.cc", "context_options.h", "display_manager.cc", @@ -295,7 +293,6 @@ if (enable_unittests) { sources = [ "animator_unittests.cc", - "canvas_spy_unittests.cc", "context_options_unittests.cc", "dl_op_spy_unittests.cc", "engine_unittests.cc", diff --git a/shell/common/rasterizer.cc b/shell/common/rasterizer.cc index 3fb35fcc30803..e3daa2d7cabda 100644 --- a/shell/common/rasterizer.cc +++ b/shell/common/rasterizer.cc @@ -552,7 +552,6 @@ RasterStatus Rasterizer::DrawToSurfaceUnsafe( auto root_surface_canvas = embedder_root_canvas ? embedder_root_canvas : frame->Canvas(); - auto compositor_frame = compositor_context_->AcquireFrame( surface_->GetContext(), // skia GrContext root_surface_canvas, // root surface canvas diff --git a/shell/gpu/gpu_surface_gl_delegate.h b/shell/gpu/gpu_surface_gl_delegate.h index f097cba2d0266..dee0c682969a0 100644 --- a/shell/gpu/gpu_surface_gl_delegate.h +++ b/shell/gpu/gpu_surface_gl_delegate.h @@ -58,7 +58,7 @@ class GPUSurfaceGLDelegate { virtual std::unique_ptr GLContextMakeCurrent() = 0; // Called to clear the current GL context on the thread. This may be called on - // either the GPU or IO threads. + // either the Raster or IO threads. virtual bool GLContextClearCurrent() = 0; // Inform the GL Context that there's going to be no writing beyond diff --git a/shell/gpu/gpu_surface_gl_impeller.cc b/shell/gpu/gpu_surface_gl_impeller.cc index 20fd96142d917..3b6777042eaa7 100644 --- a/shell/gpu/gpu_surface_gl_impeller.cc +++ b/shell/gpu/gpu_surface_gl_impeller.cc @@ -61,7 +61,7 @@ std::unique_ptr GPUSurfaceGLImpeller::AcquireFrame( delegate = delegate_]() -> bool { if (weak) { GLPresentInfo present_info = { - .fbo_id = 0, + .fbo_id = 0u, .frame_damage = std::nullopt, // TODO (https://github.com/flutter/flutter/issues/105597): wire-up // presentation time to impeller backend. @@ -80,10 +80,14 @@ std::unique_ptr GPUSurfaceGLImpeller::AcquireFrame( return nullptr; } + GLFrameInfo frame_info = {static_cast(size.width()), + static_cast(size.height())}; + const GLFBOInfo fbo_info = delegate_->GLContextFBO(frame_info); + auto surface = impeller::SurfaceGLES::WrapFBO( impeller_context_, // context swap_callback, // swap_callback - 0u, // fbo + fbo_info.fbo_id, // fbo impeller::PixelFormat::kR8G8B8A8UNormInt, // color_format impeller::ISize{size.width(), size.height()} // fbo_size ); @@ -122,12 +126,12 @@ std::unique_ptr GPUSurfaceGLImpeller::AcquireFrame( }); return std::make_unique( - nullptr, // surface - SurfaceFrame::FramebufferInfo{}, // framebuffer info - submit_callback, // submit callback - size, // frame size - std::move(context_switch), // context result - true // display list fallback + nullptr, // surface + delegate_->GLContextFramebufferInfo(), // framebuffer info + submit_callback, // submit callback + size, // frame size + std::move(context_switch), // context result + true // display list fallback ); } diff --git a/shell/platform/android/external_view_embedder/external_view_embedder.h b/shell/platform/android/external_view_embedder/external_view_embedder.h index db2c77e4b3922..400b43fb91a89 100644 --- a/shell/platform/android/external_view_embedder/external_view_embedder.h +++ b/shell/platform/android/external_view_embedder/external_view_embedder.h @@ -9,7 +9,6 @@ #include "flutter/common/task_runners.h" #include "flutter/flow/embedded_views.h" -#include "flutter/flow/rtree.h" #include "flutter/shell/platform/android/context/android_context.h" #include "flutter/shell/platform/android/external_view_embedder/surface_pool.h" #include "flutter/shell/platform/android/jni/platform_view_android_jni.h" diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm index 15aaeea0deff0..bf7e607878d1b 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm @@ -10,7 +10,6 @@ #include #include "flutter/common/graphics/persistent_cache.h" -#include "flutter/flow/rtree.h" #include "flutter/fml/platform/darwin/scoped_nsobject.h" #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterChannels.h" #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.h" diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h index 8a4fe6d5340bd..43cb43cf4e33b 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h @@ -6,7 +6,6 @@ #define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_FLUTTERPLATFORMVIEWS_INTERNAL_H_ #include "flutter/flow/embedded_views.h" -#include "flutter/flow/rtree.h" #include "flutter/fml/platform/darwin/scoped_nsobject.h" #include "flutter/shell/common/shell.h" #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterBinaryMessenger.h" diff --git a/shell/platform/embedder/BUILD.gn b/shell/platform/embedder/BUILD.gn index aa43f3f48b755..5bfe8cad0215f 100644 --- a/shell/platform/embedder/BUILD.gn +++ b/shell/platform/embedder/BUILD.gn @@ -95,16 +95,6 @@ template("embedder_source_set") { ] public_deps = [ ":embedder_headers" ] - - if (embedder_enable_gl) { - sources += [ - "embedder_external_texture_gl.cc", - "embedder_external_texture_gl.h", - "embedder_surface_gl.cc", - "embedder_surface_gl.h", - ] - } - deps = [ ":embedder_gpu_configuration", "//flutter/assets", @@ -121,13 +111,33 @@ template("embedder_source_set") { "//third_party/skia", ] + if (embedder_enable_gl) { + sources += [ + "embedder_external_texture_gl.cc", + "embedder_external_texture_gl.h", + "embedder_surface_gl.cc", + "embedder_surface_gl.h", + ] + + if (impeller_supports_rendering) { + sources += [ + "embedder_surface_gl_impeller.cc", + "embedder_surface_gl_impeller.h", + ] + deps += [ "//flutter/impeller/renderer/backend/gles" ] + } + } + if (impeller_supports_rendering) { sources += [ "embedder_render_target_impeller.cc", "embedder_render_target_impeller.h", ] - deps += [ "//flutter/impeller" ] + deps += [ + "//flutter/impeller", + "//flutter/impeller/renderer", + ] } if (embedder_enable_metal) { @@ -143,6 +153,7 @@ template("embedder_source_set") { "embedder_surface_metal_impeller.h", "embedder_surface_metal_impeller.mm", ] + deps += [ "//flutter/impeller/renderer/backend/metal" ] } cflags_objc = flutter_cflags_objc diff --git a/shell/platform/embedder/embedder.cc b/shell/platform/embedder/embedder.cc index 008ea576482d5..34b874b609a85 100644 --- a/shell/platform/embedder/embedder.cc +++ b/shell/platform/embedder/embedder.cc @@ -64,9 +64,20 @@ extern const intptr_t kPlatformStrongDillSize; #include "rapidjson/rapidjson.h" #include "rapidjson/writer.h" +// Note: the IMPELLER_SUPPORTS_RENDERING may be defined even when the +// embedder/BUILD.gn variable impeller_supports_rendering is disabled. #ifdef SHELL_ENABLE_GL #include "flutter/shell/platform/embedder/embedder_external_texture_gl.h" -#endif +#ifdef IMPELLER_SUPPORTS_RENDERING +#include "flutter/shell/platform/embedder/embedder_render_target_impeller.h" // nogncheck +#include "flutter/shell/platform/embedder/embedder_surface_gl_impeller.h" // nogncheck +#include "impeller/core/texture.h" // nogncheck +#include "impeller/renderer/backend/gles/context_gles.h" // nogncheck +#include "impeller/renderer/backend/gles/texture_gles.h" // nogncheck +#include "impeller/renderer/context.h" // nogncheck +#include "impeller/renderer/render_target.h" // nogncheck +#endif // IMPELLER_SUPPORTS_RENDERING +#endif // SHELL_ENABLE_GL #ifdef SHELL_ENABLE_METAL #include "flutter/shell/platform/embedder/embedder_surface_metal.h" @@ -265,7 +276,8 @@ InferOpenGLPlatformViewCreationCallback( const flutter::PlatformViewEmbedder::PlatformDispatchTable& platform_dispatch_table, std::unique_ptr - external_view_embedder) { + external_view_embedder, + bool enable_impeller) { #ifdef SHELL_ENABLE_GL if (config->type != kOpenGL) { return nullptr; @@ -441,15 +453,30 @@ InferOpenGLPlatformViewCreationCallback( return fml::MakeCopyable( [gl_dispatch_table, fbo_reset_after_present, platform_dispatch_table, + enable_impeller, external_view_embedder = std::move(external_view_embedder)](flutter::Shell& shell) mutable { + std::shared_ptr view_embedder = + std::move(external_view_embedder); + if (enable_impeller) { + return std::make_unique( + shell, // delegate + shell.GetTaskRunners(), // task runners + std::make_unique( + gl_dispatch_table, fbo_reset_after_present, + view_embedder), // embedder_surface + platform_dispatch_table, // embedder platform dispatch table + view_embedder // external view embedder + ); + } return std::make_unique( - shell, // delegate - shell.GetTaskRunners(), // task runners - gl_dispatch_table, // embedder GL dispatch table - fbo_reset_after_present, // fbo reset after present + shell, // delegate + shell.GetTaskRunners(), // task runners + std::make_unique( + gl_dispatch_table, fbo_reset_after_present, + view_embedder), // embedder_surface platform_dispatch_table, // embedder platform dispatch table - std::move(external_view_embedder) // external view embedder + view_embedder // external view embedder ); }); #else @@ -686,7 +713,7 @@ InferPlatformViewCreationCallback( case kOpenGL: return InferOpenGLPlatformViewCreationCallback( config, user_data, platform_dispatch_table, - std::move(external_view_embedder)); + std::move(external_view_embedder), enable_impeller); case kSoftware: return InferSoftwarePlatformViewCreationCallback( config, user_data, platform_dispatch_table, @@ -924,6 +951,66 @@ static sk_sp MakeSkSurfaceFromBackingStore( #endif } +static std::unique_ptr +MakeRenderTargetFromBackingStoreImpeller( + FlutterBackingStore backing_store, + const fml::closure& on_release, + const std::shared_ptr& aiks_context, + const FlutterBackingStoreConfig& config, + const FlutterOpenGLFramebuffer* framebuffer) { +#if defined(SHELL_ENABLE_GL) && defined(IMPELLER_SUPPORTS_RENDERING) + + const auto& gl_context = + impeller::ContextGLES::Cast(*aiks_context->GetContext()); + const auto size = impeller::ISize(config.size.width, config.size.height); + + impeller::TextureDescriptor color0_tex; + color0_tex.type = impeller::TextureType::kTexture2D; + color0_tex.format = impeller::PixelFormat::kR8G8B8A8UNormInt; + color0_tex.size = size; + color0_tex.usage = static_cast( + impeller::TextureUsage::kRenderTarget); + color0_tex.sample_count = impeller::SampleCount::kCount1; + color0_tex.storage_mode = impeller::StorageMode::kDevicePrivate; + + impeller::ColorAttachment color0; + color0.texture = std::make_shared( + gl_context.GetReactor(), color0_tex, + impeller::TextureGLES::IsWrapped::kWrapped); + color0.clear_color = impeller::Color::DarkSlateGray(); + color0.load_action = impeller::LoadAction::kClear; + color0.store_action = impeller::StoreAction::kStore; + + impeller::TextureDescriptor stencil0_tex; + stencil0_tex.type = impeller::TextureType::kTexture2D; + stencil0_tex.format = impeller::PixelFormat::kR8G8B8A8UNormInt; + stencil0_tex.size = size; + stencil0_tex.usage = static_cast( + impeller::TextureUsage::kRenderTarget); + stencil0_tex.sample_count = impeller::SampleCount::kCount1; + + impeller::StencilAttachment stencil0; + stencil0.clear_stencil = 0; + stencil0.texture = std::make_shared( + gl_context.GetReactor(), stencil0_tex, + impeller::TextureGLES::IsWrapped::kWrapped); + stencil0.load_action = impeller::LoadAction::kClear; + stencil0.store_action = impeller::StoreAction::kDontCare; + + impeller::RenderTarget render_target_desc; + + render_target_desc.SetColorAttachment(color0, framebuffer->target); + render_target_desc.SetStencilAttachment(stencil0); + + return std::make_unique( + backing_store, aiks_context, + std::make_unique(std::move(render_target_desc)), + on_release); +#else + return nullptr; +#endif +} + static std::unique_ptr MakeRenderTargetFromBackingStoreImpeller( FlutterBackingStore backing_store, @@ -1113,12 +1200,19 @@ CreateEmbedderRenderTarget( break; } case kFlutterOpenGLTargetTypeFramebuffer: { - auto skia_surface = MakeSkSurfaceFromBackingStore( - context, config, &backing_store.open_gl.framebuffer); - render_target = MakeRenderTargetFromSkSurface( - backing_store, std::move(skia_surface), - collect_callback.Release()); - break; + if (enable_impeller) { + render_target = MakeRenderTargetFromBackingStoreImpeller( + backing_store, collect_callback.Release(), aiks_context, config, + &backing_store.open_gl.framebuffer); + break; + } else { + auto skia_surface = MakeSkSurfaceFromBackingStore( + context, config, &backing_store.open_gl.framebuffer); + render_target = MakeRenderTargetFromSkSurface( + backing_store, std::move(skia_surface), + collect_callback.Release()); + break; + } } } break; diff --git a/shell/platform/embedder/embedder_surface_gl_impeller.cc b/shell/platform/embedder/embedder_surface_gl_impeller.cc new file mode 100644 index 0000000000000..7a4c3ddf1524b --- /dev/null +++ b/shell/platform/embedder/embedder_surface_gl_impeller.cc @@ -0,0 +1,188 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "flutter/shell/platform/embedder/embedder_surface_gl_impeller.h" + +#include + +#include "impeller/entity/gles/entity_shaders_gles.h" +#include "impeller/renderer/backend/gles/context_gles.h" +#include "impeller/renderer/backend/gles/proc_table_gles.h" +#include "impeller/scene/shaders/gles/scene_shaders_gles.h" + +namespace flutter { + +class ReactorWorker final : public impeller::ReactorGLES::Worker { + public: + ReactorWorker() = default; + + // |ReactorGLES::Worker| + bool CanReactorReactOnCurrentThreadNow( + const impeller::ReactorGLES& reactor) const override { + impeller::ReaderLock lock(mutex_); + auto found = reactions_allowed_.find(std::this_thread::get_id()); + if (found == reactions_allowed_.end()) { + return false; + } + return found->second; + } + + void SetReactionsAllowedOnCurrentThread(bool allowed) { + impeller::WriterLock lock(mutex_); + reactions_allowed_[std::this_thread::get_id()] = allowed; + } + + private: + mutable impeller::RWMutex mutex_; + std::map reactions_allowed_ IPLR_GUARDED_BY(mutex_); + + FML_DISALLOW_COPY_AND_ASSIGN(ReactorWorker); +}; + +EmbedderSurfaceGLImpeller::EmbedderSurfaceGLImpeller( + EmbedderSurfaceGL::GLDispatchTable gl_dispatch_table, + bool fbo_reset_after_present, + std::shared_ptr external_view_embedder) + : gl_dispatch_table_(std::move(gl_dispatch_table)), + fbo_reset_after_present_(fbo_reset_after_present), + external_view_embedder_(std::move(external_view_embedder)), + worker_(std::make_shared()) { + // Make sure all required members of the dispatch table are checked. + if (!gl_dispatch_table_.gl_make_current_callback || + !gl_dispatch_table_.gl_clear_current_callback || + !gl_dispatch_table_.gl_present_callback || + !gl_dispatch_table_.gl_fbo_callback || + !gl_dispatch_table_.gl_populate_existing_damage || + !gl_dispatch_table_.gl_proc_resolver) { + return; + } + std::vector> shader_mappings = { + std::make_shared( + impeller_entity_shaders_gles_data, + impeller_entity_shaders_gles_length), + std::make_shared( + impeller_scene_shaders_gles_data, impeller_scene_shaders_gles_length), + }; + auto gl = std::make_unique( + gl_dispatch_table_.gl_proc_resolver); + if (!gl->IsValid()) { + return; + } + + impeller_context_ = + impeller::ContextGLES::Create(std::move(gl), shader_mappings); + + if (!impeller_context_) { + FML_LOG(ERROR) << "Could not create Impeller context."; + return; + } + + worker_->SetReactionsAllowedOnCurrentThread(true); + auto worker_id = impeller_context_->AddReactorWorker(worker_); + if (!worker_id.has_value()) { + FML_LOG(ERROR) << "Could not add reactor worker."; + return; + } + + FML_LOG(ERROR) << "Using the Impeller rendering backend (OpenGL)."; + valid_ = true; +} + +EmbedderSurfaceGLImpeller::~EmbedderSurfaceGLImpeller() = default; + +// |EmbedderSurface| +bool EmbedderSurfaceGLImpeller::IsValid() const { + return valid_; +} + +// |GPUSurfaceGLDelegate| +std::unique_ptr +EmbedderSurfaceGLImpeller::GLContextMakeCurrent() { + worker_->SetReactionsAllowedOnCurrentThread(true); + return std::make_unique( + gl_dispatch_table_.gl_make_current_callback()); +} + +// |GPUSurfaceGLDelegate| +bool EmbedderSurfaceGLImpeller::GLContextClearCurrent() { + worker_->SetReactionsAllowedOnCurrentThread(false); + return gl_dispatch_table_.gl_clear_current_callback(); +} + +// |GPUSurfaceGLDelegate| +bool EmbedderSurfaceGLImpeller::GLContextPresent( + const GLPresentInfo& present_info) { + // Pass the present information to the embedder present callback. + return gl_dispatch_table_.gl_present_callback(present_info); +} + +// |GPUSurfaceGLDelegate| +GLFBOInfo EmbedderSurfaceGLImpeller::GLContextFBO( + GLFrameInfo frame_info) const { + // Get the FBO ID using the gl_fbo_callback and then get exiting damage by + // passing that ID to the gl_populate_existing_damage. + return gl_dispatch_table_.gl_populate_existing_damage( + gl_dispatch_table_.gl_fbo_callback(frame_info)); +} + +// |GPUSurfaceGLDelegate| +bool EmbedderSurfaceGLImpeller::GLContextFBOResetAfterPresent() const { + return fbo_reset_after_present_; +} + +// |GPUSurfaceGLDelegate| +SkMatrix EmbedderSurfaceGLImpeller::GLContextSurfaceTransformation() const { + auto callback = gl_dispatch_table_.gl_surface_transformation_callback; + if (!callback) { + SkMatrix matrix; + matrix.setIdentity(); + return matrix; + } + return callback(); +} + +// |GPUSurfaceGLDelegate| +EmbedderSurfaceGL::GLProcResolver EmbedderSurfaceGLImpeller::GetGLProcResolver() + const { + return gl_dispatch_table_.gl_proc_resolver; +} + +// |GPUSurfaceGLDelegate| +SurfaceFrame::FramebufferInfo +EmbedderSurfaceGLImpeller::GLContextFramebufferInfo() const { + // Enable partial repaint by default on the embedders. + auto info = SurfaceFrame::FramebufferInfo{}; + info.supports_readback = true; + info.supports_partial_repaint = + gl_dispatch_table_.gl_populate_existing_damage != nullptr; + return info; +} + +// |EmbedderSurface| +std::unique_ptr EmbedderSurfaceGLImpeller::CreateGPUSurface() { + return std::make_unique( + this, // GPU surface GL delegate + impeller_context_ // render to surface + ); +} + +// |EmbedderSurface| +std::shared_ptr +EmbedderSurfaceGLImpeller::CreateImpellerContext() const { + return impeller_context_; +} + +// |EmbedderSurface| +sk_sp EmbedderSurfaceGLImpeller::CreateResourceContext() + const { + if (gl_dispatch_table_.gl_make_resource_current_callback()) { + worker_->SetReactionsAllowedOnCurrentThread(true); + } else { + FML_DLOG(ERROR) << "Could not make the resource context current."; + worker_->SetReactionsAllowedOnCurrentThread(false); + } + return nullptr; +} + +} // namespace flutter diff --git a/shell/platform/embedder/embedder_surface_gl_impeller.h b/shell/platform/embedder/embedder_surface_gl_impeller.h new file mode 100644 index 0000000000000..6d19272102bf3 --- /dev/null +++ b/shell/platform/embedder/embedder_surface_gl_impeller.h @@ -0,0 +1,81 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_SURFACE_GL_IMPELLER_H_ +#define FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_SURFACE_GL_IMPELLER_H_ + +#include "flutter/fml/macros.h" +#include "flutter/shell/gpu/gpu_surface_gl_impeller.h" +#include "flutter/shell/platform/embedder/embedder_external_view_embedder.h" +#include "flutter/shell/platform/embedder/embedder_surface.h" +#include "flutter/shell/platform/embedder/embedder_surface_gl.h" + +namespace impeller { +class ContextGLES; +} // namespace impeller + +namespace flutter { + +class ReactorWorker; + +class EmbedderSurfaceGLImpeller final : public EmbedderSurface, + public GPUSurfaceGLDelegate { + public: + EmbedderSurfaceGLImpeller( + EmbedderSurfaceGL::GLDispatchTable gl_dispatch_table, + bool fbo_reset_after_present, + std::shared_ptr external_view_embedder); + + ~EmbedderSurfaceGLImpeller() override; + + private: + bool valid_ = false; + EmbedderSurfaceGL::GLDispatchTable gl_dispatch_table_; + bool fbo_reset_after_present_; + std::shared_ptr impeller_context_; + std::shared_ptr external_view_embedder_; + std::shared_ptr worker_; + + // |EmbedderSurface| + bool IsValid() const override; + + // |EmbedderSurface| + std::unique_ptr CreateGPUSurface() override; + + // |EmbedderSurface| + std::shared_ptr CreateImpellerContext() const override; + + // |GPUSurfaceGLDelegate| + std::unique_ptr GLContextMakeCurrent() override; + + // |GPUSurfaceGLDelegate| + bool GLContextClearCurrent() override; + + // |GPUSurfaceGLDelegate| + bool GLContextPresent(const GLPresentInfo& present_info) override; + + // |GPUSurfaceGLDelegate| + GLFBOInfo GLContextFBO(GLFrameInfo frame_info) const override; + + // |GPUSurfaceGLDelegate| + bool GLContextFBOResetAfterPresent() const override; + + // |GPUSurfaceGLDelegate| + SkMatrix GLContextSurfaceTransformation() const override; + + // |GPUSurfaceGLDelegate| + GLProcResolver GetGLProcResolver() const override; + + // |GPUSurfaceGLDelegate| + SurfaceFrame::FramebufferInfo GLContextFramebufferInfo() const override; + + // |EmbedderSurface| + sk_sp CreateResourceContext() const override; + + FML_DISALLOW_COPY_AND_ASSIGN(EmbedderSurfaceGLImpeller); +}; + +} // namespace flutter + +#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_SURFACE_GL_IMPELLER_H_ diff --git a/shell/platform/embedder/platform_view_embedder.cc b/shell/platform/embedder/platform_view_embedder.cc index ccbe0fc01a524..7e7ed026079f3 100644 --- a/shell/platform/embedder/platform_view_embedder.cc +++ b/shell/platform/embedder/platform_view_embedder.cc @@ -66,16 +66,12 @@ PlatformViewEmbedder::PlatformViewEmbedder( PlatformViewEmbedder::PlatformViewEmbedder( PlatformView::Delegate& delegate, const flutter::TaskRunners& task_runners, - const EmbedderSurfaceGL::GLDispatchTable& gl_dispatch_table, - bool fbo_reset_after_present, + std::unique_ptr embedder_surface, PlatformDispatchTable platform_dispatch_table, std::shared_ptr external_view_embedder) : PlatformView(delegate, task_runners), external_view_embedder_(std::move(external_view_embedder)), - embedder_surface_( - std::make_unique(gl_dispatch_table, - fbo_reset_after_present, - external_view_embedder_)), + embedder_surface_(std::move(embedder_surface)), platform_message_handler_(new EmbedderPlatformMessageHandler( GetWeakPtr(), task_runners.GetPlatformTaskRunner())), diff --git a/shell/platform/embedder/platform_view_embedder.h b/shell/platform/embedder/platform_view_embedder.h index 87378b5074672..896e11a7101c6 100644 --- a/shell/platform/embedder/platform_view_embedder.h +++ b/shell/platform/embedder/platform_view_embedder.h @@ -17,6 +17,7 @@ #ifdef SHELL_ENABLE_GL #include "flutter/shell/platform/embedder/embedder_surface_gl.h" +#include "flutter/shell/platform/embedder/embedder_surface_gl_impeller.h" #endif #ifdef SHELL_ENABLE_METAL @@ -65,8 +66,7 @@ class PlatformViewEmbedder final : public PlatformView { PlatformViewEmbedder( PlatformView::Delegate& delegate, const flutter::TaskRunners& task_runners, - const EmbedderSurfaceGL::GLDispatchTable& gl_dispatch_table, - bool fbo_reset_after_present, + std::unique_ptr embedder_surface, PlatformDispatchTable platform_dispatch_table, std::shared_ptr external_view_embedder); #endif diff --git a/shell/platform/fuchsia/flutter/BUILD.gn b/shell/platform/fuchsia/flutter/BUILD.gn index b9b4202306471..2b529a85e49f9 100644 --- a/shell/platform/fuchsia/flutter/BUILD.gn +++ b/shell/platform/fuchsia/flutter/BUILD.gn @@ -58,6 +58,8 @@ template("runner_sources") { sources = [ "accessibility_bridge.cc", "accessibility_bridge.h", + "canvas_spy.cc", + "canvas_spy.h", "component_v2.cc", "component_v2.h", "engine.cc", @@ -94,6 +96,8 @@ template("runner_sources") { "pointer_injector_delegate.cc", "pointer_injector_delegate.h", "program_metadata.h", + "rtree.cc", + "rtree.h", "runner.cc", "runner.h", "software_surface.cc", @@ -499,6 +503,7 @@ if (enable_unittests) { sources = [ "accessibility_bridge_unittest.cc", + "canvas_spy_unittests.cc", "component_v2_unittest.cc", "flutter_runner_fakes.h", "focus_delegate_unittests.cc", @@ -507,6 +512,7 @@ if (enable_unittests) { "platform_view_unittest.cc", "pointer_delegate_unittests.cc", "pointer_injector_delegate_unittest.cc", + "rtree_unittests.cc", "tests/engine_unittests.cc", "tests/fake_flatland_unittests.cc", "tests/fake_session_unittests.cc", diff --git a/shell/common/canvas_spy.cc b/shell/platform/fuchsia/flutter/canvas_spy.cc similarity index 99% rename from shell/common/canvas_spy.cc rename to shell/platform/fuchsia/flutter/canvas_spy.cc index 0f9dee034fa53..fe45a8fdebb50 100644 --- a/shell/common/canvas_spy.cc +++ b/shell/platform/fuchsia/flutter/canvas_spy.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/shell/common/canvas_spy.h" +#include "flutter/shell/platform/fuchsia/flutter/canvas_spy.h" namespace flutter { diff --git a/shell/common/canvas_spy.h b/shell/platform/fuchsia/flutter/canvas_spy.h similarity index 98% rename from shell/common/canvas_spy.h rename to shell/platform/fuchsia/flutter/canvas_spy.h index 4bfaef4c7400c..629538dd83df2 100644 --- a/shell/common/canvas_spy.h +++ b/shell/platform/fuchsia/flutter/canvas_spy.h @@ -10,8 +10,8 @@ #include "third_party/skia/include/utils/SkNWayCanvas.h" #include "third_party/skia/include/utils/SkNoDrawCanvas.h" -#ifndef FLUTTER_SHELL_COMMON_CANVAS_SPY_H_ -#define FLUTTER_SHELL_COMMON_CANVAS_SPY_H_ +#ifndef FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_CANVAS_SPY_H_ +#define FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_CANVAS_SPY_H_ namespace flutter { @@ -258,4 +258,4 @@ class DidDrawCanvas final : public SkCanvasVirtualEnforcer { } // namespace flutter -#endif // FLUTTER_SHELL_COMMON_SKIA_EVENT_TRACER_IMPL_H_ +#endif // FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_CANVAS_SPY_H_ diff --git a/shell/common/canvas_spy_unittests.cc b/shell/platform/fuchsia/flutter/canvas_spy_unittests.cc similarity index 96% rename from shell/common/canvas_spy_unittests.cc rename to shell/platform/fuchsia/flutter/canvas_spy_unittests.cc index 4f135392c41e9..80726fa047e28 100644 --- a/shell/common/canvas_spy_unittests.cc +++ b/shell/platform/fuchsia/flutter/canvas_spy_unittests.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "canvas_spy.h" +#include "flutter/shell/platform/fuchsia/flutter/canvas_spy.h" #include "gtest/gtest.h" #include "third_party/skia/include/core/SkPictureRecorder.h" diff --git a/shell/platform/fuchsia/flutter/flatland_external_view_embedder.h b/shell/platform/fuchsia/flutter/flatland_external_view_embedder.h index 5a3142eb5d2f6..8c794c2c7f6e2 100644 --- a/shell/platform/fuchsia/flutter/flatland_external_view_embedder.h +++ b/shell/platform/fuchsia/flutter/flatland_external_view_embedder.h @@ -17,10 +17,10 @@ #include #include "flutter/flow/embedded_views.h" -#include "flutter/flow/rtree.h" #include "flutter/fml/logging.h" #include "flutter/fml/macros.h" -#include "flutter/shell/common/canvas_spy.h" +#include "flutter/shell/platform/fuchsia/flutter/canvas_spy.h" +#include "flutter/shell/platform/fuchsia/flutter/rtree.h" #include "third_party/skia/include/core/SkPictureRecorder.h" #include "third_party/skia/include/core/SkPoint.h" #include "third_party/skia/include/core/SkRect.h" diff --git a/shell/platform/fuchsia/flutter/gfx_external_view_embedder.h b/shell/platform/fuchsia/flutter/gfx_external_view_embedder.h index 6d0bc30061047..378fdf26d1dfb 100644 --- a/shell/platform/fuchsia/flutter/gfx_external_view_embedder.h +++ b/shell/platform/fuchsia/flutter/gfx_external_view_embedder.h @@ -17,10 +17,10 @@ #include #include "flutter/flow/embedded_views.h" -#include "flutter/flow/rtree.h" #include "flutter/fml/logging.h" #include "flutter/fml/macros.h" -#include "flutter/shell/common/canvas_spy.h" +#include "flutter/shell/platform/fuchsia/flutter/canvas_spy.h" +#include "flutter/shell/platform/fuchsia/flutter/rtree.h" #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkPictureRecorder.h" #include "third_party/skia/include/core/SkPoint.h" diff --git a/flow/rtree.cc b/shell/platform/fuchsia/flutter/rtree.cc similarity index 97% rename from flow/rtree.cc rename to shell/platform/fuchsia/flutter/rtree.cc index ff66d52c1762c..c0b1aa3ab08bf 100644 --- a/flow/rtree.cc +++ b/shell/platform/fuchsia/flutter/rtree.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "rtree.h" +#include "flutter/shell/platform/fuchsia/flutter/rtree.h" #include diff --git a/flow/rtree.h b/shell/platform/fuchsia/flutter/rtree.h similarity index 91% rename from flow/rtree.h rename to shell/platform/fuchsia/flutter/rtree.h index 35c74137243c8..ac5334cbdc8f1 100644 --- a/flow/rtree.h +++ b/shell/platform/fuchsia/flutter/rtree.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef FLUTTER_FLOW_RTREE_H_ -#define FLUTTER_FLOW_RTREE_H_ +#ifndef FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_RTREE_H_ +#define FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_RTREE_H_ #include #include @@ -62,4 +62,4 @@ class RTreeFactory : public SkBBHFactory { } // namespace flutter -#endif // FLUTTER_FLOW_RTREE_H_ +#endif // FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_RTREE_H_ diff --git a/flow/rtree_unittests.cc b/shell/platform/fuchsia/flutter/rtree_unittests.cc similarity index 99% rename from flow/rtree_unittests.cc rename to shell/platform/fuchsia/flutter/rtree_unittests.cc index d1af5bb235d4c..80bcb35bbb5d6 100644 --- a/flow/rtree_unittests.cc +++ b/shell/platform/fuchsia/flutter/rtree_unittests.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "rtree.h" +#include "flutter/shell/platform/fuchsia/flutter/rtree.h" #include "flutter/testing/testing.h" #include "third_party/skia/include/core/SkCanvas.h" diff --git a/shell/platform/windows/angle_surface_manager.cc b/shell/platform/windows/angle_surface_manager.cc index 18d21f6b425b9..7deafc2d0bf8c 100644 --- a/shell/platform/windows/angle_surface_manager.cc +++ b/shell/platform/windows/angle_surface_manager.cc @@ -20,20 +20,21 @@ namespace flutter { int AngleSurfaceManager::instance_count_ = 0; -std::unique_ptr AngleSurfaceManager::Create() { +std::unique_ptr AngleSurfaceManager::Create( + bool enable_impeller) { std::unique_ptr manager; - manager.reset(new AngleSurfaceManager()); + manager.reset(new AngleSurfaceManager(enable_impeller)); if (!manager->initialize_succeeded_) { return nullptr; } return std::move(manager); } -AngleSurfaceManager::AngleSurfaceManager() +AngleSurfaceManager::AngleSurfaceManager(bool enable_impeller) : egl_config_(nullptr), egl_display_(EGL_NO_DISPLAY), egl_context_(EGL_NO_CONTEXT) { - initialize_succeeded_ = Initialize(); + initialize_succeeded_ = Initialize(enable_impeller); ++instance_count_; } @@ -66,15 +67,21 @@ bool AngleSurfaceManager::InitializeEGL( return true; } -bool AngleSurfaceManager::Initialize() { - // TODO(dnfield): Enable MSAA here, see similar code in android_context_gl.cc - // Will need to plumb in argument from project bundle for sampling rate. - // https://github.com/flutter/flutter/issues/100392 +bool AngleSurfaceManager::Initialize(bool enable_impeller) { const EGLint config_attributes[] = {EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_ALPHA_SIZE, 8, EGL_DEPTH_SIZE, 8, EGL_STENCIL_SIZE, 8, EGL_NONE}; + const EGLint impeller_config_attributes[] = { + EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, + EGL_ALPHA_SIZE, 8, EGL_DEPTH_SIZE, 0, EGL_STENCIL_SIZE, 8, + EGL_SAMPLE_BUFFERS, 1, EGL_SAMPLES, 4, EGL_NONE}; + const EGLint impeller_config_attributes_no_msaa[] = { + EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, + EGL_ALPHA_SIZE, 8, EGL_DEPTH_SIZE, 0, EGL_STENCIL_SIZE, 8, + EGL_NONE}; + const EGLint display_context_attributes[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE}; @@ -147,11 +154,26 @@ bool AngleSurfaceManager::Initialize() { } EGLint numConfigs = 0; - if ((eglChooseConfig(egl_display_, config_attributes, &egl_config_, 1, - &numConfigs) == EGL_FALSE) || - (numConfigs == 0)) { - LogEglError("Failed to choose first context"); - return false; + if (enable_impeller) { + // First try the MSAA configuration. + if ((eglChooseConfig(egl_display_, impeller_config_attributes, &egl_config_, + 1, &numConfigs) == EGL_FALSE) || + (numConfigs == 0)) { + // Next fall back to disabled MSAA. + if ((eglChooseConfig(egl_display_, impeller_config_attributes_no_msaa, + &egl_config_, 1, &numConfigs) == EGL_FALSE) || + (numConfigs == 0)) { + LogEglError("Failed to choose first context"); + return false; + } + } + } else { + if ((eglChooseConfig(egl_display_, config_attributes, &egl_config_, 1, + &numConfigs) == EGL_FALSE) || + (numConfigs == 0)) { + LogEglError("Failed to choose first context"); + return false; + } } egl_context_ = eglCreateContext(egl_display_, egl_config_, EGL_NO_CONTEXT, diff --git a/shell/platform/windows/angle_surface_manager.h b/shell/platform/windows/angle_surface_manager.h index edfe7a8cbcd95..576704f630054 100644 --- a/shell/platform/windows/angle_surface_manager.h +++ b/shell/platform/windows/angle_surface_manager.h @@ -27,7 +27,8 @@ namespace flutter { // destroy surfaces class AngleSurfaceManager { public: - static std::unique_ptr Create(); + static std::unique_ptr Create(bool enable_impeller); + virtual ~AngleSurfaceManager(); // Creates an EGLSurface wrapper and backing DirectX 11 SwapChain @@ -88,10 +89,10 @@ class AngleSurfaceManager { protected: // Creates a new surface manager retaining reference to the passed-in target // for the lifetime of the manager. - AngleSurfaceManager(); + explicit AngleSurfaceManager(bool enable_impeller); private: - bool Initialize(); + bool Initialize(bool enable_impeller); void CleanUp(); // Attempts to initialize EGL using ANGLE. diff --git a/shell/platform/windows/flutter_project_bundle.cc b/shell/platform/windows/flutter_project_bundle.cc index df289b526a0f4..aab3239ce8291 100644 --- a/shell/platform/windows/flutter_project_bundle.cc +++ b/shell/platform/windows/flutter_project_bundle.cc @@ -88,7 +88,17 @@ void FlutterProjectBundle::SetSwitches( } const std::vector FlutterProjectBundle::GetSwitches() { - return GetSwitchesFromEnvironment(); + if (engine_switches_.size() == 0) { + return GetSwitchesFromEnvironment(); + } + std::vector switches; + switches.insert(switches.end(), engine_switches_.begin(), + engine_switches_.end()); + + auto env_switches = GetSwitchesFromEnvironment(); + switches.insert(switches.end(), env_switches.begin(), env_switches.end()); + + return switches; } } // namespace flutter diff --git a/shell/platform/windows/flutter_windows_engine.cc b/shell/platform/windows/flutter_windows_engine.cc index 3dd00d422ae0f..844790db56c17 100644 --- a/shell/platform/windows/flutter_windows_engine.cc +++ b/shell/platform/windows/flutter_windows_engine.cc @@ -199,7 +199,13 @@ FlutterWindowsEngine::FlutterWindowsEngine(const FlutterProjectBundle& project) FlutterWindowsTextureRegistrar::ResolveGlFunctions(gl_procs_); texture_registrar_ = std::make_unique(this, gl_procs_); - surface_manager_ = AngleSurfaceManager::Create(); + + // Check for impeller support. + auto& switches = project_->GetSwitches(); + enable_impeller_ = std::find(switches.begin(), switches.end(), + "--enable-impeller=true") != switches.end(); + + surface_manager_ = AngleSurfaceManager::Create(enable_impeller_); window_proc_delegate_manager_ = std::make_unique(); window_proc_delegate_manager_->RegisterTopLevelWindowProcDelegate( [](HWND hwnd, UINT msg, WPARAM wpar, LPARAM lpar, void* user_data, @@ -369,9 +375,21 @@ bool FlutterWindowsEngine::Run(std::string_view entrypoint) { args.aot_data = aot_data_.get(); } - FlutterRendererConfig renderer_config = surface_manager_ - ? GetOpenGLRendererConfig() - : GetSoftwareRendererConfig(); + FlutterRendererConfig renderer_config; + + if (enable_impeller_) { + // Impeller does not support a Software backend. Avoid falling back and + // confusing the engine on which renderer is selected. + if (!surface_manager_) { + FML_LOG(ERROR) << "Could not create surface manager. Impeller backend " + "does not support software rendering."; + return false; + } + renderer_config = GetOpenGLRendererConfig(); + } else { + renderer_config = surface_manager_ ? GetOpenGLRendererConfig() + : GetSoftwareRendererConfig(); + } auto result = embedder_api_.Run(FLUTTER_ENGINE_VERSION, &renderer_config, &args, this, &engine_); diff --git a/shell/platform/windows/flutter_windows_engine.h b/shell/platform/windows/flutter_windows_engine.h index 01f371d0a4fee..29a904d3506b4 100644 --- a/shell/platform/windows/flutter_windows_engine.h +++ b/shell/platform/windows/flutter_windows_engine.h @@ -391,6 +391,8 @@ class FlutterWindowsEngine { bool high_contrast_enabled_ = false; + bool enable_impeller_ = false; + // The manager for WindowProc delegate registration and callbacks. std::unique_ptr window_proc_delegate_manager_; diff --git a/shell/platform/windows/flutter_windows_engine_unittests.cc b/shell/platform/windows/flutter_windows_engine_unittests.cc index d518e7f9c1f66..80fb26f6cd3b3 100644 --- a/shell/platform/windows/flutter_windows_engine_unittests.cc +++ b/shell/platform/windows/flutter_windows_engine_unittests.cc @@ -223,6 +223,41 @@ TEST_F(FlutterWindowsEngineTest, RunWithoutANGLEUsesSoftware) { modifier.embedder_api().Shutdown = [](auto engine) { return kSuccess; }; } +TEST_F(FlutterWindowsEngineTest, RunWithoutANGLEOnImpellerFailsToStart) { + FlutterWindowsEngineBuilder builder{GetContext()}; + builder.SetSwitches({"--enable-impeller=true"}); + std::unique_ptr engine = builder.Build(); + EngineModifier modifier(engine.get()); + + modifier.embedder_api().NotifyDisplayUpdate = + MOCK_ENGINE_PROC(NotifyDisplayUpdate, + ([engine_instance = engine.get()]( + FLUTTER_API_SYMBOL(FlutterEngine) raw_engine, + const FlutterEngineDisplaysUpdateType update_type, + const FlutterEngineDisplay* embedder_displays, + size_t display_count) { return kSuccess; })); + + // Accessibility updates must do nothing when the embedder engine is mocked + modifier.embedder_api().UpdateAccessibilityFeatures = MOCK_ENGINE_PROC( + UpdateAccessibilityFeatures, + [](FLUTTER_API_SYMBOL(FlutterEngine) engine, + FlutterAccessibilityFeature flags) { return kSuccess; }); + + // Stub out UpdateLocales and SendPlatformMessage as we don't have a fully + // initialized engine instance. + modifier.embedder_api().UpdateLocales = MOCK_ENGINE_PROC( + UpdateLocales, ([](auto engine, const FlutterLocale** locales, + size_t locales_count) { return kSuccess; })); + modifier.embedder_api().SendPlatformMessage = + MOCK_ENGINE_PROC(SendPlatformMessage, + ([](auto engine, auto message) { return kSuccess; })); + + // Set the AngleSurfaceManager to nullptr to test software fallback path. + modifier.SetSurfaceManager(nullptr); + + EXPECT_FALSE(engine->Run()); +} + TEST_F(FlutterWindowsEngineTest, SendPlatformMessageWithoutResponse) { FlutterWindowsEngineBuilder builder{GetContext()}; std::unique_ptr engine = builder.Build(); diff --git a/shell/platform/windows/flutter_windows_view_unittests.cc b/shell/platform/windows/flutter_windows_view_unittests.cc index 89082dd46cba1..2d5dfd71409d1 100644 --- a/shell/platform/windows/flutter_windows_view_unittests.cc +++ b/shell/platform/windows/flutter_windows_view_unittests.cc @@ -118,7 +118,7 @@ class MockFlutterWindowsEngine : public FlutterWindowsEngine { class MockAngleSurfaceManager : public AngleSurfaceManager { public: - MockAngleSurfaceManager() {} + MockAngleSurfaceManager() : AngleSurfaceManager(false) {} MOCK_METHOD4(CreateSurface, bool(WindowsRenderTarget*, EGLint, EGLint, bool)); MOCK_METHOD4(ResizeSurface, void(WindowsRenderTarget*, EGLint, EGLint, bool)); diff --git a/shell/platform/windows/testing/flutter_windows_engine_builder.cc b/shell/platform/windows/testing/flutter_windows_engine_builder.cc index d4f8086c89609..9b8f6e4053dbc 100644 --- a/shell/platform/windows/testing/flutter_windows_engine_builder.cc +++ b/shell/platform/windows/testing/flutter_windows_engine_builder.cc @@ -62,6 +62,11 @@ void FlutterWindowsEngineBuilder::AddDartEntrypointArgument(std::string arg) { dart_entrypoint_arguments_.emplace_back(std::move(arg)); } +void FlutterWindowsEngineBuilder::SetSwitches( + std::vector switches) { + switches_ = std::move(switches); +} + void FlutterWindowsEngineBuilder::SetCreateKeyboardHandlerCallbacks( KeyboardKeyEmbedderHandler::GetKeyStateHandler get_key_state, KeyboardKeyEmbedderHandler::MapVirtualKeyToScanCode map_vk_to_scan) { @@ -86,6 +91,7 @@ std::unique_ptr FlutterWindowsEngineBuilder::Build() { } FlutterProjectBundle project(properties_); + project.SetSwitches(switches_); return std::make_unique(project, get_key_state_, map_vk_to_scan_); diff --git a/shell/platform/windows/testing/flutter_windows_engine_builder.h b/shell/platform/windows/testing/flutter_windows_engine_builder.h index ce3648a82a005..e17d3c794227e 100644 --- a/shell/platform/windows/testing/flutter_windows_engine_builder.h +++ b/shell/platform/windows/testing/flutter_windows_engine_builder.h @@ -29,6 +29,8 @@ class FlutterWindowsEngineBuilder { KeyboardKeyEmbedderHandler::GetKeyStateHandler get_key_state, KeyboardKeyEmbedderHandler::MapVirtualKeyToScanCode map_vk_to_scan); + void SetSwitches(std::vector switches); + std::unique_ptr Build(); private: @@ -36,6 +38,7 @@ class FlutterWindowsEngineBuilder { FlutterDesktopEngineProperties properties_ = {}; std::string dart_entrypoint_; std::vector dart_entrypoint_arguments_; + std::vector switches_; KeyboardKeyEmbedderHandler::GetKeyStateHandler get_key_state_; KeyboardKeyEmbedderHandler::MapVirtualKeyToScanCode map_vk_to_scan_; diff --git a/sky/packages/sky_engine/LICENSE b/sky/packages/sky_engine/LICENSE index 899035f691ddb..5c9f132c7b49b 100644 --- a/sky/packages/sky_engine/LICENSE +++ b/sky/packages/sky_engine/LICENSE @@ -26790,7 +26790,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- accessibility angle -fuchsia_sdk skia Copyright 2018 The Chromium Authors. All rights reserved. diff --git a/testing/dart/channel_buffers_test.dart b/testing/dart/channel_buffers_test.dart index a35f84207e49f..906c3c57b1127 100644 --- a/testing/dart/channel_buffers_test.dart +++ b/testing/dart/channel_buffers_test.dart @@ -22,6 +22,12 @@ void _resize(ui.ChannelBuffers buffers, String name, int newSize) { } void main() { + bool assertsEnabled = false; + assert(() { + assertsEnabled = true; + return true; + }()); + test('push drain', () async { const String channel = 'foo'; final ByteData data = _makeByteData('bar'); @@ -36,9 +42,9 @@ void main() { // ignore: deprecated_member_use await buffers.drain(channel, (ByteData? drainedData, ui.PlatformMessageResponseCallback drainedCallback) async { expect(drainedData, equals(data)); - assert(!called); + expect(called, isFalse); drainedCallback(drainedData); - assert(called); + expect(called, isTrue); }); }); @@ -227,21 +233,21 @@ void main() { buffers.push('a', three, (ByteData? data) { }); log.add('top'); buffers.setListener('a', (ByteData? data, ui.PlatformMessageResponseCallback callback) { - assert(data != null); + expect(data, isNotNull); log.add('a1: ${utf8.decode(data!.buffer.asUint8List())}'); }); log.add('-1'); await null; log.add('-2'); buffers.setListener('a', (ByteData? data, ui.PlatformMessageResponseCallback callback) { - assert(data != null); + expect(data, isNotNull); log.add('a2: ${utf8.decode(data!.buffer.asUint8List())}'); }); log.add('-3'); await null; log.add('-4'); buffers.setListener('b', (ByteData? data, ui.PlatformMessageResponseCallback callback) { - assert(data != null); + expect(data, isNotNull); log.add('b: ${utf8.decode(data!.buffer.asUint8List())}'); }); log.add('-5'); @@ -290,7 +296,7 @@ void main() { buffers.push('a', three, (ByteData? data) { }); log.add('-1'); buffers.setListener('a', (ByteData? data, ui.PlatformMessageResponseCallback callback) { - assert(data != null); + expect(data, isNotNull); log.add('a1: ${utf8.decode(data!.buffer.asUint8List())}'); }); await null; // handles one @@ -299,7 +305,7 @@ void main() { await null; log.add('-3'); buffers.setListener('a', (ByteData? data, ui.PlatformMessageResponseCallback callback) { - assert(data != null); + expect(data, isNotNull); log.add('a2: ${utf8.decode(data!.buffer.asUint8List())}'); }); log.add('-4'); @@ -372,6 +378,24 @@ void main() { 'callback2: true', ]); }); + + test('ChannelBufferspush rejects names with nulls', () async { + const String channel = 'foo\u0000bar'; + final ByteData blabla = _makeByteData('blabla'); + final ui.ChannelBuffers buffers = ui.ChannelBuffers(); + try { + buffers.push(channel, blabla, (ByteData? data) { }); + fail('did not throw as expected'); + } on AssertionError catch (e) { + expect(e.toString(), contains('U+0000 NULL')); + } + try { + buffers.setListener(channel, (ByteData? data, ui.PlatformMessageResponseCallback callback) { }); + fail('did not throw as expected'); + } on AssertionError catch (e) { + expect(e.toString(), contains('U+0000 NULL')); + } + }, skip: !assertsEnabled); } class _TestChannelBuffers extends ui.ChannelBuffers { diff --git a/testing/dart/paragraph_test.dart b/testing/dart/paragraph_test.dart index 8c8e865770c59..075bfa2993c4f 100644 --- a/testing/dart/paragraph_test.dart +++ b/testing/dart/paragraph_test.dart @@ -233,4 +233,25 @@ void main() { expect(callback, throwsStateError); } }); + + test('disableRoundingHack works', () { + const double fontSize = 1.25; + const String text = '12345'; + assert((fontSize * text.length).truncate() != fontSize * text.length); + final bool roundingHackWasDisabled = ParagraphBuilder.shouldDisableRoundingHack; + ParagraphBuilder.setDisableRoundingHack(true); + final ParagraphBuilder builder = ParagraphBuilder(ParagraphStyle(fontSize: fontSize)); + builder.addText(text); + final Paragraph paragraph = builder.build() + ..layout(const ParagraphConstraints(width: text.length * fontSize)); + + expect(paragraph.maxIntrinsicWidth, text.length * fontSize); + switch (paragraph.computeLineMetrics()) { + case [LineMetrics(width: final double width)]: + expect(width, text.length * fontSize); + case final List metrics: + expect(metrics, hasLength(1)); + } + ParagraphBuilder.setDisableRoundingHack(roundingHackWasDisabled); + }); } diff --git a/third_party/txt/src/skia/paragraph_builder_skia.cc b/third_party/txt/src/skia/paragraph_builder_skia.cc index 96d98f3f4c29f..641725ec6ccfb 100644 --- a/third_party/txt/src/skia/paragraph_builder_skia.cc +++ b/third_party/txt/src/skia/paragraph_builder_skia.cc @@ -138,6 +138,7 @@ skt::ParagraphStyle ParagraphBuilderSkia::TxtToSkia(const ParagraphStyle& txt) { skia.turnHintingOff(); skia.setReplaceTabCharacters(true); + skia.setApplyRoundingHack(txt.apply_rounding_hack); return skia; } diff --git a/third_party/txt/src/txt/paragraph_style.h b/third_party/txt/src/txt/paragraph_style.h index 7c3043b8ad899..e1915323a0bd3 100644 --- a/third_party/txt/src/txt/paragraph_style.h +++ b/third_party/txt/src/txt/paragraph_style.h @@ -95,6 +95,14 @@ class ParagraphStyle { std::u16string ellipsis; std::string locale; + // Temporary flag that indicates whether the Paragraph should report its + // metrics with rounding hacks applied. + // + // This flag currently defaults to true and will be flipped to false once the + // migration is complete. + // TODO(LongCatIsLooong): https://github.com/flutter/flutter/issues/31707 + bool apply_rounding_hack = true; + TextStyle GetTextStyle() const; bool unlimited_lines() const; diff --git a/tools/gn b/tools/gn index 320243ba62818..33908609e5c16 100755 --- a/tools/gn +++ b/tools/gn @@ -214,6 +214,13 @@ def buildtools_dir(): def setup_goma(args): goma_gn_args = {} + # args.goma has three states, True (--goma), False (--no-goma), and + # None (default). In True mode, we force GOMA to be used (and fail + # if we cannot enable it) unless the selected target definitely does + # not support it (in which case we print a warning). In False mode, + # we disable GOMA regardless. In None mode, we enable it if we can + # autodetect a configuration, and otherwise disable it. + # When running in CI, the recipes use their own goma install, and take # care of starting and stopping the compiler proxy. running_on_luci = os.environ.get('LUCI_CONTEXT') is not None @@ -235,14 +242,16 @@ def setup_goma(args): if args.target_os == 'wasm' or args.web: goma_gn_args['use_goma'] = False goma_gn_args['goma_dir'] = None - print('Disabling GOMA for wasm builds, it is not supported yet.') - elif args.goma and not running_on_luci and os.path.exists(cipd_goma_dir): + if args.goma: + print('Disabling GOMA for wasm builds, it is not supported yet.') + elif args.goma is not False and not running_on_luci and os.path.exists( + cipd_goma_dir): goma_gn_args['use_goma'] = True goma_gn_args['goma_dir'] = cipd_goma_dir - elif args.goma and goma_dir and os.path.exists(goma_dir): + elif args.goma is not False and goma_dir and os.path.exists(goma_dir): goma_gn_args['use_goma'] = True goma_gn_args['goma_dir'] = goma_dir - elif args.goma and os.path.exists(goma_home_dir): + elif args.goma is not False and os.path.exists(goma_home_dir): goma_gn_args['use_goma'] = True goma_gn_args['goma_dir'] = goma_home_dir elif args.goma: @@ -870,7 +879,7 @@ def parse_args(args): help='Do not build the host-side development artifacts.' ) - parser.add_argument('--goma', default=True, action='store_true') + parser.add_argument('--goma', default=None, action='store_true') parser.add_argument('--no-goma', dest='goma', action='store_false') parser.add_argument( '--xcode-symlinks',