3763 Commits

Author SHA1 Message Date
Jonah Williams
0b9763cec5 [Impeller] prevent no-op backend from throwing exceptions during image decoding (flutter/engine#56522)
This preveents errors reported in some g3 test cases.
2024-11-12 21:44:51 +00:00
Jason Simmons
ef5c2fc014 Do not stop flutter_tester if microtasks are still pending (flutter/engine#56432)
Flutter_tester has a task observer that checks whether the test's Dart code has finished execution.  If Dart no longer has live ports but does have pending microtasks, then flutter_tester should continue running and force a drain of the microtask queue.

Fixes https://github.com/flutter/flutter/issues/158129
2024-11-11 19:22:07 +00:00
Mouad Debbar
a13bd21ce9 [web] Bump Firefox version to 132.0 (flutter/engine#56435)
A firefox upgrade is long overdue. This upgrade fixes some failing tests in https://github.com/flutter/engine/pull/54786
2024-11-11 15:14:06 +00:00
Mouad Debbar
efe78cfd00 [web] Split all 1MB+ fallback fonts (including CJK) (flutter/engine#56388)
By splitting all large fallback fonts (1MB+) into smaller parts, we get faster downloads and fast decoding.

Some fonts are split into 100+ parts, and that's causing `main.dart.js`'s size to grow by ~47KB (Brotli-compressed). The increase in size is due to the extra data we have to store about all the parts of these fonts.

The PR also makes  changes to ensure we don't download the same license file 100 times (once for each part of the split font).

Fixes https://github.com/flutter/flutter/issues/138288
Part of https://github.com/flutter/flutter/issues/153974
2024-11-08 20:44:08 +00:00
Jonah Williams
bc59375978 [Impeller] Add support for ImageFilter.shader (flutter/engine#53490)
Copy-pasta docs:

```
  /// Creates an image filter from a [FragmentShader].
  ///
  /// The fragment shader provided here has additional requirements to be used
  /// by the engine for filtering. The first uniform value must be a vec2, this
  /// will be set by the engine to the size of the bound texture. There must
  /// also be at least one sampler2D uniform, the first of which will be set by
  /// the engine to contain the filter input.
  ///
  /// For example, the following is a valid fragment shader that can be used
  /// with this API. Note that the uniform names are not required to have any
  /// particular value.
  ///
  /// ```glsl
  /// #include <flutter/runtime_effect.glsl>
  ///
  /// uniform vec2 u_size;
  /// uniform float u_time;
  ///
  /// uniform sampler2D u_texture_input;
  ///
  /// out vec4 frag_color;
  ///
  /// void main() {
  ///   frag_color = texture(u_texture_input, FlutterFragCoord().xy / u_size) * u_time;
  ///
  /// }
  ///
  /// ```
  ///
  /// This API is only supported when using the Impeller rendering engine. On
  /// other backends a [UnsupportedError] will be thrown. This error can be
  /// caught and used for feature detection.
  ```

Fixes https://github.com/jonahwilliams/flutter_shaders/issues/34
Fixes https://github.com/jonahwilliams/flutter_shaders/issues/26
Fixes https://github.com/flutter/flutter/issues/132099
2024-11-08 01:15:22 +00:00
Jackson Gardner
d387d0fe3b [skwasm] Make sure to include the transfer list when using postMessage. (flutter/engine#56431)
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.
2024-11-07 18:34:08 +00:00
Yegor
c799bc6196 [web:a11y] make header a <header> when non-empty and heading when empty (flutter/engine#55996)
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
2024-11-07 00:51:19 +00:00
Jackson Gardner
fef97957af [skwasm] Fix empty backdrop drawing. (flutter/engine#56385)
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.
2024-11-06 21:19:07 +00:00
Matan Lurey
b60b012f51 Add and document and explicit toARGB32. (flutter/engine#56329)
Closes https://github.com/flutter/flutter/issues/157128.
2024-11-06 01:07:20 +00:00
Mouad Debbar
d6ce17ba66 [web] Switch all fonts to WOFF2 (non-split) (flutter/engine#56035)
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).
2024-11-05 20:50:50 +00:00
David Iglesias
b772962ba4 [web] injectPlatformView into correct flutterView (flutter/engine#56334)
Makes SceneView inject platform views in the current `flutterView`, instead of the `implicitView`.

This enables platform views in multi-view mode for the Skwasm renderer.

Fixes https://github.com/flutter/flutter/issues/157958

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-11-05 01:25:51 +00:00
Tong Mu
f10ac1e27e Multiple touches of a stylus should be considered from the same device (flutter/engine#56075)
This PR fixes https://github.com/flutter/flutter/issues/156223.

**Problem:** The issue above only occurred when using stylus on Web. Multiple touches were treated as different devices: new devices were added and former devices that had the pointer lifted were never removed. This was further caused by the design that Flutter uses JS's `PointerEvent.pointerId` as the device ID, which increases for each touch.

Flutter had to use `PointerEvent.pointerId` because JS doesn't provide a way to distinguish between multiple styluses. This PR fixes this issue by simply supporting only one stylus, since support for multi-stylus can be really hard. How multi-stylus should be supported can be discussed upon such demands in the future, but at least for now, iPad doesn't support multi-stylus and it's not something I can test.

This PR also rewrote some comments that I got confused by while reading the code.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-11-02 05:38:23 +00:00
Juanjo Tugores
b78aaca24c [web] Transfer focus to view rootElement on blur/remove. (flutter/engine#55045)
The `safeBlur`/`safeRemove`/`safeRemoveSync` methods in the view manager should become the standard way to "blur" and "remove" elements within the web engine.

Calling these method ensures the blur operation doesn't disrupt the framework's view focus management because these methods transfer the focus from the current element to its containing EngineFlutterView's `rootElement`, so focus never abandons the Flutter view unless the user wants to.

This is a generalization of the former `DefaultTextEditingStrategy.scheduleFocusFlutterView`, which turns out is needed in anything that touches elements that may receive focus in the engine, not just text editing.

## Issue

(Maybe) Part of https://github.com/flutter/flutter/issues/157387
(Opportunistically) Fixes https://github.com/flutter/flutter/issues/46638

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-11-02 00:51:13 +00:00
Jackson Gardner
53f8d48270 Remove superfluous dart2wasm test suites/bundles. (flutter/engine#56315)
When dart2wasm was still in early stages and unstable, we wanted to run dart2wasm on as many unit tests and code paths as possible. However, dart2wasm is much more stable now, and there are some configurations that users simply cannot not use and are not worth testing. Specifically, users cannot use renderers other than skwasm with dart2wasm, so we should avoid running test suites specific to those renderers.

* `dart2wasm-html-html` and `dart2wasm-canvaskit-canvaskit` bundles and their associated suites are removed. These are tests specifically for the `html` and `canvaskit` renderers, which are run with those renderers. Users can't use these renderers in dart2wasm mode, so it's not useful to run these tests.
* `dart2wasm-html-ui` and `dart2wasm-canvaskit-ui` and their associated suites are also removed. These are tests that can run on any renderer, and they are being run with the `html` and `canvaskit` renderers. We don't need to run against these renderers on `dart2wasm` since users can't actually use these renderers in dart2wasm mode.
* Notably, `dart2wasm-html-engine` and associated suites are staying. These run against the `html` renderer, but only incidentally. These tests are supposed to be exercising logic that doesn't actually pertain to rendering, and it's logic that will be running for the end user in dart2wasm mode. So it makes sense to continue running these tests against dart2wasm.
2024-11-01 21:38:52 +00:00
Jackson Gardner
8cced6a0ac Reland single threaded Skwasm (flutter/engine#56282)
This attempts to reland the single-threaded Skwasm PR: https://github.com/flutter/engine/pull/56206

The main changes here are in the second commit:
* We need to actually bundle the `skwasm_st` artifacts in `flutter_web_sdk.zip`
* The `locateFile` hack no longer works since emscripten doesn't actually create a worker.js file anymore. So instead, that has been modified to use the `mainScriptUrlOrBlob` module API to do a very similar hack.

Note: I did presubmit testing with the framework CI and it appears the pertinent tests pass. See https://github.com/flutter/flutter/pull/157967
2024-11-01 19:00:08 +00:00
gaaclarke
f81ed55e63 reland: Allow BufferViews to have non-owning references to DeviceBuffers (flutter/engine#56286)
relands https://github.com/flutter/engine/pull/56224

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-10-31 23:46:55 +00:00
auto-submit[bot]
528967bfae Reverts "Allow BufferViews to have non-owning references to DeviceBuffers (#56224)" (flutter/engine#56285)
Reverts: flutter/engine#56224
Initiated by: jonahwilliams
Reason for reverting: merge issue.
Original PR Author: gaaclarke

Reviewed By: {jonahwilliams}

This change reverts the following previous change:
issue: https://github.com/flutter/flutter/issues/157538

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-10-31 22:48:46 +00:00
gaaclarke
1d90823917 Allow BufferViews to have non-owning references to DeviceBuffers (flutter/engine#56224)
issue: https://github.com/flutter/flutter/issues/157538

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I added new tests to check the change I am making or feature I am
adding, or the PR is [test-exempt]. See [testing the engine] for
instructions on writing and running engine tests.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I signed the [CLA].
- [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2024-10-31 15:28:10 -07:00
auto-submit[bot]
38f7a81e37 Reverts "Skwasm single threaded (#56206)" (flutter/engine#56264)
Reverts: flutter/engine#56206
Initiated by: jonahwilliams
Reason for reverting: failing to roll into framework: https://github.com/flutter/flutter/pull/157919 
Original PR Author: eyebrowsoffire

Reviewed By: {harryterkelsen}

This change reverts the following previous change:
This PR creates a single-threaded version of the skwasm renderer, appropriate for non-crossOriginIsolated browsing contexts.
* The single threaded renderer is essentially the same as the multi-threaded renderer, except instead of spawning a web worker and posting messages to it, it simply schedules microtasks on the main thread in their place.
* The new renderer is vended as `skwasm_st.js` and `skwasm_st.wasm` in the same location as multithreaded skwasm. In order to properly build and function, we needed some fixes I put into emscripten that landed in version 3.1.70. That version also changed some behavior that required a few fixes to the CanvasKit build files.
* The skwasm loader in flutter.js has been modified to use the skwasm_st variants when encountering a non-crossOriginIsolated context but a browser and configuration that otherwise would allow the use of skwasm. I also added a new `forceSingleThreadedSkwasm` option to the flutter configuration so that we can override this behavior, especially so that we can accurately benchmark the single threaded renderer in a crossOriginIsolated environment.
* I also consolidated a bunch of our shards that run tests to just have one per browser/platform combination, so four total. This will address https://github.com/flutter/flutter/issues/124682
2024-10-31 14:12:47 +00:00
Jackson Gardner
1a4f588e1f Skwasm single threaded (flutter/engine#56206)
This PR creates a single-threaded version of the skwasm renderer, appropriate for non-crossOriginIsolated browsing contexts.
* The single threaded renderer is essentially the same as the multi-threaded renderer, except instead of spawning a web worker and posting messages to it, it simply schedules microtasks on the main thread in their place.
* The new renderer is vended as `skwasm_st.js` and `skwasm_st.wasm` in the same location as multithreaded skwasm. In order to properly build and function, we needed some fixes I put into emscripten that landed in version 3.1.70. That version also changed some behavior that required a few fixes to the CanvasKit build files.
* The skwasm loader in flutter.js has been modified to use the skwasm_st variants when encountering a non-crossOriginIsolated context but a browser and configuration that otherwise would allow the use of skwasm. I also added a new `forceSingleThreadedSkwasm` option to the flutter configuration so that we can override this behavior, especially so that we can accurately benchmark the single threaded renderer in a crossOriginIsolated environment.
* I also consolidated a bunch of our shards that run tests to just have one per browser/platform combination, so four total. This will address https://github.com/flutter/flutter/issues/124682
2024-10-31 00:42:07 +00:00
David Iglesias
ba7deba7c5 [web] Prioritize split font fallbacks over monolythic ones. (flutter/engine#56187)
Moves "split" font fallbacks (woff2) over "monolythic" ones (ttf) when resolving fonts.

Fixes https://github.com/flutter/flutter/issues/157763

It makes flutter web prefer "Noto Color Emoji" over "Noto Sans Symbols" when rendering emoji, for example.

This also changes the methods that process the font lists so they *return* the fonts they processed, instead of causing a side effect on an incoming array.

---

CIPD Upload log

```
398 sets covering 22287 ranges
Uploading fallback fonts to CIPD with hash 0570a0ea824083da79de07b131fc5df7f55dad4d6cba2ee704912ce7e4ce812a
Enumerating files to zip...
Instance: flutter/flutter_font_fallbacks:6jWhR90elvOjT1bwCe57CrNWbsGrvOzMONf9_bS8w5IC
Setting new fallback fonts deps version to 0570a0ea824083da79de07b131fc5df7f55dad4d6cba2ee704912ce7e4ce812a
```

Link to uploaded bundle:

* https://chrome-infra-packages.appspot.com/p/flutter/flutter_font_fallbacks/+/6jWhR90elvOjT1bwCe57CrNWbsGrvOzMONf9_bS8w5IC

---

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-10-29 23:01:22 +00:00
Brandon DeRosier
3fed10bf0d [Flutter GPU] Fix MSAA sample size and HostBuffer alignment. (flutter/engine#56218)
- Align HostBuffer emplacements properly (fix Metal validation failures).
- Correctly set the pipeline sample size.
- Throw an error when attempting to bind `deviceTransient` textures.
2024-10-29 22:52:21 +00:00
Jim Graham
80d757ef56 Change default TileMode for blur ImageFilter objects to null (flutter/engine#55552)
Fixes https://github.com/flutter/flutter/issues/154935

Historically ImageFilter.blur supported setting a TileMode and had a default mode of `clamp`, but few developers actually set the value and the default was not appropriate for some common uses like as a backdrop filter where the clamp mode produces flashing when scrolling high frequency pixel content underneath a blurred title bar.

This PR removes the default tile mode instead allowing a null value as the default which will allow the engine to use an appropriate context-dependent default tile mode depending on the action being performed. Typically:

- decal for rendering operations and saveLayers and ImageFilterLayer
- clamp for image operations
- mirror for backdrop filters
2024-10-29 22:47:32 +00:00
Alexander Aprelev
d0141e3ee3 Remove --time run of gen_snapshot. (flutter/engine#56204)
'--time'-runs were done to investigate https://github.com/flutter/flutter/issues/154437, which was fixed.
2024-10-29 17:20:15 +00:00
Harry Terkelsen
18214377a3 [canvaskit] Deduplicate golden test file names (flutter/engine#56143)
Two different golden tests produced output named `canvaskit_picture.png`. This PR deduplicates those.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-10-28 23:31:19 +00:00
Brandon DeRosier
40062dbfe5 [Flutter GPU] Replace HostBuffer with Dart version. (flutter/engine#56054)
Resolves https://github.com/flutter/flutter/issues/157431.
2024-10-28 21:16:17 +00:00
Jackson Gardner
45d8f6a4ed Reland (x2) Skwasm overlay optimizations (flutter/engine#56067)
This is an attempt to reland https://github.com/flutter/engine/pull/55468

We now defer actually drawing the pictures until the build of the layer slices, so that we can calculate an accurate `cullRect` for the picture recorder

This also contains a further optimization for the "simple" rendering case (no platform views) where we don't actually do any unnecessary occlusion calculations.
2024-10-25 22:03:56 +00:00
Jason Simmons
641814ad61 [web] Do not copy invalid images in the Skia test image collection (flutter/engine#56102)
A recent Skia commit added a test image that is used to check handling of invalid input.  This is causing some web tests to fail because Firefox rejects the image.

(see https://skia.googlesource.com/skia.git/+/ff59ce65022d71f883b7e3be146bbd32facadaf8)
2024-10-24 22:39:20 +00:00
Alexander Aprelev
f51e0982e9 Reland copy gen snapshot (flutter/engine#56061)
Copy gen_snapshots using python's shutil.copy, avoid links
    
Default implementation of copy does it via hardlink, which seems to be
causing issues with Gatekeeper on mac.

This is reland of 63d8f5cb72d711871736b742a30a45106df21b9a with the fix
for the case when target is a link to the source, that was the cause for
revert c5ad234e11dd716cd8b136cdef8d1233c594c527
    
BUG=https://github.com/flutter/flutter/issues/154437
2024-10-23 10:26:31 -07:00
Brandon DeRosier
026062f08b [Flutter GPU] Fix assert failure in createDeviceBufferWithCopy. (flutter/engine#56039)
Resolves https://github.com/flutter/flutter/issues/157336

`DartByteData` gets raw pointers into the Dart heap via `Dart_TypedDataAcquireData`. So it must be destructed before `AssociateWithDartWrapper` is called, which mutates the heap.

Re-enables failing test for Linux unopt.
2024-10-23 05:08:03 +00:00
David Iglesias
95ae8d46b5 [web] Remove old futureToPromise. (flutter/engine#55847)
This PR removes the old `futureToPromise` implementation (which was barely used), and replaces it by a more standard js_interop approach.

Fixes https://github.com/flutter/flutter/issues/155732

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-10-22 23:09:17 +00:00
Loïc Sharma
c0beb6bb71 [dart:ui] Improve Clip's docs (flutter/engine#55978) 2024-10-22 22:35:12 +00:00
K. P. Krasiński-Sroka
10f2a2ccd1 [canvaskit] Makes access to CkSurface null-safer (flutter/engine#54895)
Handles exceptions coming from `MakeSWCanvasSurface` and `MakeOffscreenSWCanvasSurface`.

Also makes surface size a member of `CkSurface` to make sure that it's always in sync with `surface`.

Fixes https://github.com/flutter/flutter/issues/154402

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-10-22 22:27:00 +00:00
auto-submit[bot]
c5ad234e11 Reverts "Copy gen_snapshots using python's shutil.copy, avoid links (#55830)" (flutter/engine#56034)
Reverts: flutter/engine#55830
Initiated by: chinmaygarde
Reason for reverting: Incremental builds are broken. https://github.com/flutter/flutter/issues/157367
Original PR Author: aam

Reviewed By: {mraleph, cbracken}

This change reverts the following previous change:
Default implementation of copy does it via hardlink, which seems to be causing issues with Gatekeeper on mac.

BUG=https://github.com/flutter/flutter/issues/154437
2024-10-22 19:45:47 +00:00
Brandon DeRosier
3b568c8d68 [Flutter GPU] Fix conditional when checking DeviceBuffer bounds. (flutter/engine#56017)
Resolves https://github.com/flutter/flutter/issues/157324

Fix a silly off-by-one that I didn't catch because none of the tests are using `DeviceBuffer` directly. 🤦
2024-10-22 10:58:38 +00:00
Alexander Aprelev
63d8f5cb72 Copy gen_snapshots using python's shutil.copy, avoid links (flutter/engine#55830)
Default implementation of copy does it via hardlink, which seems to be
causing issues with Gatekeeper on mac.

BUG=https://github.com/flutter/flutter/issues/154437
2024-10-22 04:48:02 +03:00
Brandon DeRosier
493177b5ed [Flutter GPU] Add missing MSAA stuff. (flutter/engine#55424)
Resolves https://github.com/flutter/flutter/issues/144264.
2024-10-22 01:16:25 +00:00
Yegor
1e4d3fae97 Revert "[web:a11y] make header a proper <header> (#55747)" (flutter/engine#55993)
This reverts commit e478ea9bad00114661ee59d79d843cc66d395a24.

This broke a customer: https://github.com/flutter/engine/pull/55747#issuecomment-2426879072
2024-10-21 20:48:57 +00:00
Yegor
5d341acdc5 [web] implement selectable semantics (flutter/engine#55970)
Implement `SemanticsFlag.hasSelectedState` and `SemanticsFlag.isSelected` for web in terms of `aria-selected`.

Fixes https://github.com/flutter/flutter/issues/66673
2024-10-21 20:24:10 +00:00
Mouad Debbar
2af8c83f84 [web] Support woff2 fonts (flutter/engine#55908)
- Enable support for WOFF2 fonts.
- Add Brotli depndency (increases CK size by ~53KB compressed, including the Brotli dictionary).
- Use split WOFF2 fonts for Emoji.
- Remove the `useColorEmoji` runtime config flag.

Partially based off of https://github.com/flutter/engine/pull/41282
Fixes https://github.com/flutter/flutter/issues/119536
Contributes to https://github.com/flutter/flutter/issues/153974 and opens the door for moving more fonts to WOFF2.
2024-10-21 13:38:22 +00:00
Jonah Williams
73ec326b80 [UI] fix scene builder parameter naming. (flutter/engine#55969)
This is reponsible for the bdf golden breaking shader mask.
2024-10-18 17:45:23 -07:00
Jonah Williams
f0f29ce37f [Impeller] add mechanism for sharing bdf inputs. (flutter/engine#55701)
Introduces a mechanism to allow backdrop filters to 1) share backdrop inputs and 2) fuse filter applications for faster blurs.

This is a proposed solution to https://github.com/flutter/flutter/issues/131568

Implemented:
* Developer can specify a "backdrop id" which indicates that a backdrop layer should share the input texture and potentially cached filter for a layer.
* Removes second save layer for each backdrop filter
* Removes save layer trace event for backdrop filter
* Can fuse backdrop filters if there is more than one identical filter

TBD:
* Adjust heruristic to avoid applying bdf filter to entire screen

Suggestions: applying a bdf should be a distinct operation from a save layer in the DL builder/dispatcher. The saveLayer implmenentation in the impeller dispatcher is super convoluted because it needs to handle both.

### Video

Video starts with normal bdf then I hot reload to specify that the bdfs share inputs/filters. This is running on a pixel 8 pro

Change to the macrobenchmark app is just:
```dart
  Widget build(BuildContext context) {
    Widget addBlur(Widget child, bool shouldBlur) {
      if (shouldBlur) {
        return ClipRect(
          child: BackdropFilter(
            filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5),
            backdropId: 1, // Added ID
            child: child,
          ),
        );
      } else {
        return child;
      }
    }
```

https://github.com/user-attachments/assets/22707f97-5825-43f1-91b4-1a02a43437f5

Requires framework changes in https://github.com/jonahwilliams/flutter/pull/new/backdrop_id
2024-10-18 15:38:34 +00:00
Jonah Williams
7a2227ddc8 [Impeller] simpler labels for render target textures and cmd buffers. (flutter/engine#55936)
Avoid Sprintf'ing labels for textures/cmd buffers/render passes. For the render target textures, defer combined label construction until we know the label will be used.
2024-10-18 04:01:50 +00:00
Brandon DeRosier
518ada1675 [Flutter GPU] Remove Command/VertexBuffer usage from Flutter GPU. (flutter/engine#55893)
Resolves https://github.com/flutter/flutter/issues/156764.
Resolves https://github.com/flutter/flutter/issues/155335.

- Remove Command/VertexBuffer from Flutter GPU.
- Separate vertex/index count into `impeller::RenderPass::SetElementCount(size_t count)` & accurately document its behavior.
- Make Flutter GPU uniform/texture bindings re-assignable.
- Remove unnecessary templates.
2024-10-17 22:39:19 +00:00
Yegor
4a93a6a08b Introduce SemanticsFlag.hasSelectedState to the engine API (flutter/engine#55780)
Introduce `SemanticsFlag.hasSelectedState` to the engine API. At this point the flag is not backed by any engine functionality. See also: https://github.com/flutter/flutter/issues/66673#issuecomment-2402903402

| ⚠️ WARNING           |
|:----------------------------|
| Submit _AFTER_ https://github.com/flutter/flutter/pull/157017 and https://github.com/flutter/flutter/pull/157061 land in the framework     |

A step towards https://github.com/flutter/flutter/issues/66673
2024-10-17 22:01:34 +00:00
Jonah Williams
243ea95602 [Impeller] make labeling APIs exclusively use std::string_view. (flutter/engine#55918)
Many of our labeling APIs accepted a std::string. When provided with a string literal (const char*), this would force the allocation of a new std::string object and a copy of the original char*. std::string_view is a view of either a std::string, or a const char* (or other), which allows an API that doesn not need to store the string to accept both without a copy. Of course, we can't store a std::string_view, as that doesn't provide memory ownership - so many of the GLES implementations will still copy the string_view into a string locally.

Also updates several of the debug labelling functions to no-op in release mode and removes some expensive interpolations that aren't super necessary.
2024-10-17 16:54:03 +00:00
Jonah Williams
5c6ab792a2 [Impeller] fix memory leak during gif upload. (flutter/engine#55920)
Fixes https://github.com/flutter/flutter/issues/156728

Need to periodically flush the TLS command buffer pools in multiframe codec just like single frame codec.
2024-10-17 01:17:59 +00:00
Harlen Batagelo
8737cce879 Handle out-of-order add/remove pointer events (flutter/engine#55740)
Fixes [#146251](https://github.com/flutter/flutter/issues/146251).

On Windows, a "pointer add" event to a new view is sometimes sent before the "pointer remove" event from the old view. When `PointerDataPacketConverter` handles the add event, it asserts that the device's pointer state has been cleared. Since the pointer state is cleared only when the remove event is processed, the assertion fails if the events arrive out of order.

The solution proposed here is to synthesize a remove event if an add event is received while the pointer state hasn't been cleared (i.e., if the pointer is added without being removed from the previous view).

To avoid duplicate remove events, the view ID is now tracked in `PointerState`. If the original "remove" arrives after the synthesized one, the state's view ID will differ from the pointer data's view ID, allowing it to be safely ignored.

When synthesizing the remove event, it's possible that the old view has already been destroyed, meaning no remove event will be received later. For example, this occurs when a window is destroyed while the pointer is inside it. However, the framework expects an "add" event to always follow a "remove" event, and "remove" events with invalid views are ignored. To meet the framework's expectations, the view ID of the "add" event will be used for the "remove" event if the old view has been destroyed.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-10-16 20:19:49 +00:00
Brandon DeRosier
50b5307332 [Impeller] Allow binding multiple vertex buffer views. (flutter/engine#55856)
Resolves https://github.com/flutter/flutter/issues/116168.
(Continuation of https://github.com/flutter/engine/pull/49670)

Makes it possible for us to use arbitrary vertex layouts, including SoA layouts with attributes stored in different DeviceBuffers. CanRenderPerspectiveCube was converted to an SoA attribute layout with two separate buffers as an example.

Works on all the backends!

OpenGLES:
<img width="1136" alt="image" src="https://github.com/user-attachments/assets/e2398fde-532f-402d-899a-39aaa556f24f">

Vulkan:
<img width="1136" alt="image" src="https://github.com/user-attachments/assets/1c1bf664-bec1-43cb-ab2e-eb2a74718bfd">

Metal:
<img width="1136" alt="image" src="https://github.com/user-attachments/assets/bf59da17-cf52-4913-88e4-ab6f0bd6fc96">
2024-10-15 01:13:52 +00:00
Brandon DeRosier
778e32ec0d [Flutter GPU] Remove unused fixture. (flutter/engine#55869)
I used this fixture data early on to bootstrap testing for Flutter GPU before shader bundles were finished. But today we have the build system compile shader bundles for us, so this is no longer used.
2024-10-15 00:10:21 +00:00