This change doesn't have unit tests, because it doesn't actually change the functional behavior of the renderer, it only changes its performance characteristics. If the transfer list is not included, the browser copies the image bitmaps instead of transfers them, which is slow, but does actually work. I am going to be adding some additional benchmarking in the framework to ensure that we detect if we regress something like this again.
Overdraw prevention prevents overlapping triangles in the stroke tessellator from being visible with partially opaque draws. For fully opaque draws (or usage of src blend mode) I do not believe this will be an issue - so we can disable this to speed things up a tiny bit.
This code runs after we covert opaque draws to src blend mode, so checking for src blend mode should be sufficient.
Previously, if `layout_data` was not nil, we failed to `CFRelease` `source`. However, if `layout_data` was nil, we dif free source, then immediately set it to a new CoreFoundation object, which we then failed to free.
We now use `fml::CFRef` which just does the right thing.
Finally, we were returning `(__brdige_transfer)CFRetain(layout_data)` but `__bridge_transfer` releases the transferred object at the end of the enclosing expression, so this is equivalent to `(__bridge)layout_data`, which is what we now do.
No tests since this is a refactor with no semantic changes, other than fixing an internal leak.
[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Previously, in `mouseAndGestureEventsAreHandledSeparately:` we were using `CGEventRef cgEventStart` after it had been `CFRelease`d. Twice. This migrates to use fml::CFRef and avoids the issue altogether.
[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This relands the [reverted](https://github.com/flutter/engine/pull/55993) [original PR](https://github.com/flutter/engine/pull/55747) with one important adjustment: if the header is empty and has a label, it is rendered as a heading (`<h1>`, `<h2>`, etc) instead of a `<header>`. This is to be consistent with mobile, where headers are frequently used as headings, and screen readers do indeed read it as "heading". Changing all headers to the `<header>` tag turned to out to be too disruptive to existing usages of `SemanticsProperties.header`.
Long-term, when https://github.com/flutter/flutter/issues/155928 is implemented, we could migrate the framework to use `SemanticsProperties.headingLevel` to communicate that something is a heading, and encourage our users to move from `header` to `headingLevel` as well. After that migration is done, we could make all headers proper `<header>` tags, and not special-case empty headers.
Fixes https://github.com/flutter/flutter/issues/152268
Fixes https://github.com/flutter/flutter/issues/158275
We are now counting on the content context to keep the host buffer alive. the imgui overlay does not use a content context, so it has to manage the lifetime of the host buffer correctly, keeping it alive for as many frames as needed and destroying it in the correct order (before context destruction).
If our operation affects the backdrop, the layer slice builder needs to take that into account when deciding whether to actually build a slice. In addition, we should take the content in the backdrop into account when calculating the cull rect for our picture recorders.
For this to actually work, we need a fix for https://g-issues.skia.org/issues/362552959 which I am currently working on.
Heap allocation is extremely expensive on Android.
We can speed up the stroke tessellation by allocation a large arena and using that to write vertices. If the vertices would overflow, we switch to a dynamically allocated vector.
Ensure that all Objective-C code in the codebase is being built with the standard set of Flutter Objective-C compiler flags with ARC enabled.
Also bumps the cflags config up to the top of the first block within each target in which Objective-C sources appear, so that the location is consistent.
Migrates The following targets to ARC, which had been missed in previous passes since they didn't declare the standard Flutter Obj-C[++] cflags:
* `//flutter/fml:fml_unittests`
* `//flutter/impeller/golden_tests:metal_screenshot`
* `//flutter/impeller/playground:playground`
* `//flutter/impeller/backend/metal:metal`
* `//flutter/impeller/backend/metal:metal_unittests`
* `//shell/gpu:gpu_surface_metal_unittests`
* `//flutter/shell/platform/embedder:embedder_unittests`
This patch includes no semantic changes.
Issue: https://github.com/flutter/flutter/issues/137801
[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Previously, we had not enabled standard iOS cflags for `ios_test_flutter`, though ARC had been manually added to the cflags. This meant that the following flags were not enabled:
* -Werror=overriding-method-mismatch
* -Werror=undeclared-selector
Both of these existed in the code within this target:
* undeclared-selector: `insertionPointColor` was a non-public selector on UITextInput prior to iOS 17.
* overriding-method-mismatch: `FakeFlutterUndoManagerDelegate`, which implements the `FlutterUndoManagerDelegate` protocol, declared `initWithUndoManager:activeInputView:` with a different type for `activeInputView`. This was a hack to jam in a test mock object that didn't match the required type for the property. Conveniently we have a class (`FlutterTextInputView`) that implements the required type and protocol (`UIView<UITextInput>`).
Issue: https://github.com/flutter/flutter/issues/137801
[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This method simply wrapped a common method, which is simpler to use
directly. The test only tested this common method, which already has
tests in common/.
fml::scoped_nsobject and fml::scoped_nsprotocol classes are no longer
necessary now that the entire codebase has been migrated to ARC.
This also eliminates the fml_arc_unittests target which tests that code.
All references to that target in documentation, run_tests.py have been
removed. This target was used in various `et` build/query unit tests and
has been replaced with the fml_unittests target in those cases.
Issue: https://github.com/flutter/flutter/issues/137801
At shutdown time the ReactorGLES may still be holding handles of GL objects. These objects should be cleaned up when the reactor is deleted.
This leak can be seen by running DlGoldenTest.ShimmerTest, which takes a series of screenshots. Each screenshot creates an AiksContext. Without this change, the textures in the AiksContext's ReactorGLES will be leaked after the AiksContext is destroyed.
Google Fonts serves TTF fonts gzipped. By switching to WOFF2 fonts, we get Brotli compression by design.
Google Font's WOFF2 fonts are 30%+ smaller than their gzipped TTF counterparts (including Roboto).
The content context options hash function is pefect - meaning a distinct hash guarantees a distinct value and vice versa. We can replace the hashing entirely with an equality check of the hash function.
Additionally, we can remove the hashmap. As most of these maps have fewer than a dozen entries (often just 2 or 3) and the linear search is much faster.
The unspecified default is 256 MiB which is ... big. 4Mb value is the default that Skia used to use, and results in less memory usage at least in local testing.
benchmarks will determine if this has a positive or negative impact on performance.
https://github.com/flutter/flutter/issues/157497
Migrates DarwinContextMetal to a plain C struct, eliminating the need for constructor, getters, etc. since it's only used in this translation unit. The fields themselves cannot be inlined as fields on ShellTestPlatformViewMetal because the header in which that class is defined is included in plain C++ (non-Obj-C++) translation units and therefore cannot contain Obj-C types.
This simplifies the code and simultaneously fixes complicated ARC behaviour in which the const "DarwinContextMetal::context()" getter caused retainCount to be incremented on the underlying context_ pointer, but not decremented even if never unassigned. In particular the line
```objc
FML_CHECK([metal_context->context() mainContext]));
```
appeared to cause refcount to be incremented but never decremented.
Regardless of the ARC issue, this significantly simplifies the code.
This also eliminates the last remaining use of fml::scoped_nsobject in Flutter's codebase. That class will be removed in a followup PR.
No test changes since there is no change to semantics.
Issue: https://github.com/flutter/flutter/issues/137801
[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This test is flakey despite using the mocked vulkan backend. This likely
indicates that VMA is still performing some real initialization work in
a way that is not consistently passing or failing.
It may not be safe to use VMA with mock vulkan.
Remove unused repo deps; these are now brought in as part of dart-lang/tools. This is for dart-lang repos `browser_launcher`, `clock`, `bazel_worker`, `cli_util`, `csslib`, `html`, and `json_rpc_2`.
No pubspecs (pubspec.yaml, web_sdk/pubspec.yaml) needed to be updated as part of this change.
Issues:
- https://github.com/dart-lang/sdk/issues/56591
[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Closes https://github.com/flutter/flutter/issues/157945.
```sh
% et cleanup --dry-run
Checking /Users/matanl/Developer/engine/src/out...
The following directories were accessed later than 2024-10-02:
android_debug
android_debug_arm64
android_debug_unopt
android_debug_unopt_arm64_ide
host_debug_unopt_arm64_ide
ios_debug
ios_debug_sim_unopt_arm64
ios_debug_unopt
ios_debug_unopt_arm64
license_script_output
wasm_release
web_tests
Run without --dry-run to reclaim 2.79gb.
```
```sh
flutter % et cleanup
Checking /Users/matanl/Developer/engine/src/out...
Deleted 12 output directories and reclaimed 2.79gb.
```
Fixes https://github.com/flutter/flutter/issues/137454
Host coherent memory does not need to be flushed. Almost all mobile devices will have host coherent memory for us to write to, but we still need check because of swiftshader and/or desktop at some point.