5151 Commits

Author SHA1 Message Date
Dan Field
d33b2d4288 Delete WeakPtrFactory from GPUSurfaceVulkanImpeller (flutter/engine#42710)
Should fix https://github.com/flutter/flutter/issues/128618.

This is unused - if it were used we'd have to be careful about deleting the object on the same thread it's created on.
2023-06-09 22:27:46 +00:00
gaaclarke
bf5c52d8af [Impeller] Reland: Added a switch to turn on vulkan (flutter/engine#42669)
relands https://github.com/flutter/engine/pull/42585

## 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].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] I added new tests to check the change I am making or feature I am
adding, or Hixie said 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
[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
2023-06-09 11:35:29 -07:00
gaaclarke
2097506136 [Impeller] Makes validation layers flag work for android (flutter/engine#42625)
This builds and links in the validation layers for android. They then
can be turned on or off with a manifest field.

fixes https://github.com/flutter/flutter/issues/123788
depends on https://github.com/flutter/buildroot/pull/741

## 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.
- [ ] 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.
- [ ] I added new tests to check the change I am making or feature I am
adding, or Hixie said 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
[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
2023-06-09 10:22:21 -07:00
Justin McCandless
986c173094 Platform channel for predictive back (flutter/engine#39208)
Adds a platform channel method for enabling/disabling Android's predictive back feature.
2023-06-09 10:06:33 -07:00
Bruno Leroux
0445311a23 [Linux] Return keyboard pressed state (flutter/engine#42346)
## Description

This PR updates the Linux engine in order to answer to keyboard pressed state queries from the framework (as implemented in https://github.com/flutter/flutter/pull/122885).

## Related Issue

Linux engine implementation for https://github.com/flutter/flutter/issues/87391

## Tests

Adds 2 tests.
2023-06-09 11:28:15 +00:00
Renzo Olivares
8b7818b946 [Linux] composing delta fixes (flutter/engine#42648)
Fixes a few issues with the Linux text editing delta implementation that was causing some issues when composing CJK text.

`im_preedit_changed_cb` dispatches a delta with the delta range set as the current composing region causing a crash when composing because the new composing region range might not yet exist in the `oldText` that the delta is applied to. We should instead send the composing region before the change to the text as that will be the correct range that is being modified in the `oldText`.

`im_preedit_end_cb` dispatches a delta with an empty `oldText`, a not empty `deltaText`, and a delta range of `(-1,-1)` causing a crash when composing ends because the delta range will never be within the range of the text. We should instead send the current text value as the `oldText` and not send a `deltaRange` or `deltaText` since a `(-1,-1)` range essentially means nothing in the text changed.

`im_commit_cb` does not account for the case when we were previously composing when the text was committed. This causes the dispatched delta to have a delta range that always inserts at the current the selection, when it should instead replace the previous composing range. We should account for the case when we are previously composing before committing the text, and dispatch a delta with the previous composing region.

Fixes https://github.com/flutter/flutter/issues/113909
2023-06-08 21:14:01 +00:00
toneyzeng
c659b9a590 Fix: invalid time-point comparison between each from different clock source (flutter/engine#42409)
Sometimes the time point created late will less than the time point create earlier since the CLOCK SOURCE has changed.

We must make sure the  CLOCK SOURCE (fml::TimePoint) is always keep the same while we are testing. 
Corrects the test case is needed before we fix the problem completely.
2023-06-08 21:12:12 +00:00
Zachary Anderson
8e7fbbb8a7 Revert "[Impeller] Added a switch to turn on vulkan" (flutter/engine#42660)
Reverts flutter/engine#42585

Reverting to investigate
https://github.com/flutter/flutter/issues/128484
2023-06-08 09:04:17 -07:00
Bruno Leroux
a3843d747d [iOS] Fix TextInputAction.continueAction sends wrong action to framework (flutter/engine#42615)
## Description

This PR fixes an issue related to text input plugin, on IOS, sending a wrong action string to the engine for `FlutterTextInputActionContinue`.

## Related Issue

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

## Tests

Adds 1 test.
2023-06-07 20:11:47 +00:00
Jonah Williams
02591dca4d [Impeller] fix missing assignment of embedder render target. (flutter/engine#42630)
Otherwise we can't render 😄
2023-06-07 19:57:57 +00:00
Chris Bracken
e7a44a64a7 [macOS] Add platformview creation parameter support (flutter/engine#42607)
Previously, when creating native platform views on macOS, we ignored any parameters passed via the framework side "params" argument in the "create" method call, and instead always passed a nil value to the FlutterPlatformViewFactory. This made it impossible for users of macOS platform views to pass constructor arguments to the NSView subclass implementing the platform view.

We now decode the arguments data using the codec specified by the `FlutterPlatformViewFactory` and pass them through to the `[FlutterPlatformViewFactory createWithIdentifier:arguments:]` method where the platform view author can make use of them.

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

This is a part of the broader macOS platform view support effort: https://github.com/flutter/flutter/issues/41722

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-06-07 19:16:56 +00:00
gaaclarke
01f6db8882 [Impeller] Added a switch to turn on vulkan (flutter/engine#42585)
fixes https://github.com/flutter/flutter/issues/128286

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-06-07 19:08:04 +00:00
J-P Nurmi
42b7de838e [Linux][a11y] implement AtkText::get_text/string_at_offset() (flutter/engine#38144)
This PR implements `AtkText::get_string_at_offset()` (and the deprecated `AtkText::get_text_at_offset()` still used by e.g. Orca) for `FlAccessibleTextField` to allow Orca to read out loud the current character while moving the text cursor around.

### Before (unmute to hear the screen reader)

[textfield-a11y-before.webm](https://user-images.githubusercontent.com/140617/206556644-fb4f4df8-acca-4d97-86d5-7120f0a4871d.webm)

### After (unmute to hear the screen reader)

[textfield-a11y-after.webm](https://user-images.githubusercontent.com/140617/206556678-4fbf9112-291e-4518-a258-e9ca33469430.webm)

Fixes: flutter/flutter#113049

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-06-07 17:18:04 +00:00
Tong Mu
fdadd4c99e Revert "[Android] Return keyboard pressed state" (flutter/engine#42616)
Reverts flutter/engine#41695 due to internal bug report b/284945818.

cc @bleroux let's investigate some day.
2023-06-07 01:38:45 -07:00
Brandon DeRosier
72a1fea6e2 [Impeller] Reland 2: Add Impeller Metal support in the embedder API (#42411) (flutter/engine#42597)
This reverts commit
8d6f091751
+ fixes bugs.

Reworked the surface wrapping to use a valid descriptor when wrapping
the drawable.
2023-06-06 23:02:02 -07:00
Zachary Anderson
8d6f091751 Revert "[Impeller] Reland: Add Impeller Metal support in the embedder API (#42411)" (flutter/engine#42593)
Reverts flutter/engine#42545

Not sure if this is needed, but getting a revert started for the
regression noted here:
https://github.com/flutter/engine/pull/42545#issuecomment-1579034704.
2023-06-06 10:57:57 -07:00
Matej Knopp
5ef190cc5c [macOS] Force clipping to path when platform view clip rect is rotated (flutter/engine#42539)
Normally when platform view is clipped to a simple rect we rely on
clipping to container layer bounds. However when the clip rect is
rotated the container layer is expanded accordingly and clipping to path
must be used instead.

Fixes https://github.com/flutter/flutter/issues/128175
2023-06-05 18:14:16 -07:00
Brandon DeRosier
fba5e2b514 [Impeller] Reland: Add Impeller Metal support in the embedder API (#42411) (flutter/engine#42545)
This reverts commit
45dd178414.

Original PR: https://github.com/flutter/engine/pull/42411

Part of https://github.com/flutter/flutter/issues/112230.
2023-06-05 14:51:43 -07:00
Kevin Lubick
0f09000dea Add missing #include of SkCFObject.h (flutter/engine#42573)
Another follow-on to http://review.skia.org/704942 which removed some
#includes that Flutter had been transitively depending on.

Note that SkCFObject is mac-only, so I included it the appropriate
#ifdef in embedder.cc, but the other two files are already mac-only so
they do not need that guard.

## 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].
- [ ] 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 Hixie said the PR is test-exempt. See [testing the engine]
for instructions on writing and running engine tests.
- [ ] 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
[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
2023-06-05 14:44:46 -04:00
Zachary Anderson
af94169054 Check more optional accesses (flutter/engine#42528)
Related https://github.com/flutter/flutter/issues/127701
2023-06-05 08:38:32 -07:00
Kevin Lubick
14d8bae027 Add missing includes of GrBackendSurface.h (flutter/engine#42563)
In https://skia-review.googlesource.com/c/skia/+/704942, Skia removed
some unnecessary #includes which parts of Flutter had been depending on
implicitly. This adds those includes in explicitly.

## 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].
- [ ] 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 Hixie said the PR is test-exempt. See [testing the engine]
for instructions on writing and running engine tests.
- [ ] 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
[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
2023-06-05 10:32:41 -04:00
Brandon DeRosier
45dd178414 Revert "[Impeller] Add Impeller Metal support in the embedder API (#42411)" (flutter/engine#42532)
This reverts commit 666563a5544cf2a98a51c6b24e7bc03e265eedb0.

Expected to resolve https://github.com/flutter/flutter/issues/128145
2023-06-02 18:11:00 -07:00
Chris Bracken
49e25a2dee [macOS] Top-left origin for PlatformView container (flutter/engine#42523)
For consistency with Flutter (and all other platforms), Flutter views in the macOS embedder set `isFlipped` to ensure a co-ordinate system with the origin in the top-left, with y co-ordinates increasing towards the bottom edge of the view.

Previously, we were using a stock NSView as the container, which uses a bottom-left origin by default. Instead we extract the PlatformView container view as its own class with `isFlipped` true.

This doesn't correct the issue of the view anchorpoint/position but does correct rotation direction.

This also applies the transform back to origin prior to other transforms when adjusting the platformview position rather than after.

Issue: https://github.com/flutter/flutter/issues/124490

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-06-02 23:35:43 +00:00
Jim Graham
01aeff259a Revert "Reland "add non-rendering operation culling to DisplayListBuilder" (#41463)" (flutter/engine#42525)
Reverts flutter/engine#42330

Some golden failures down the line were discovered in internal testing. See b/285539451
2023-06-02 21:59:50 +00:00
Michael Goderbauer
298dad2e13 MultiView changes for dart:ui (flutter/engine#42493)
Fixes https://github.com/flutter/flutter/issues/124991.

Framework tests are failing because I need to do a pre-migration of `flutter_test` for the Object -> int change of viewId. That's in https://github.com/flutter/flutter/pull/128092.
2023-06-02 21:29:48 +00:00
Camille Simon
3a156b7a42 [Android] Bump unit test robolectric version to 4.10.3 (flutter/engine#42454)
Bumps robolectric version for unit tests to [4.10.3](https://github.com/robolectric/robolectric/releases/tag/robolectric-4.10.3), the latest and greatest. Should support running unit tests with API 33.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-06-02 19:45:21 +00:00
Tong Mu
dc666a37db Revert "[Rasterizer] Make resubmit information temporary" (flutter/engine#42455)
Reverts flutter/engine#42001 due to being the likely culprit to
flakiness https://github.com/flutter/flutter/issues/127936 .
2023-06-01 21:50:47 -07:00
John McCutchan
d72aace3ef Ensure PlatformView engine life cycle callbacks are invoked (flutter/engine#42491)
- Move some code off of the message handler onto the parent class.
- Call the engine life cycle callbacks on PlatformView regardless of
which mode is used.
- Re-enable and fix test that these callbacks are invoked.

Fixes [#120329](https://github.com/flutter/flutter/issues/120329)

*If you had to change anything in the [flutter/tests] repo, include a
link to the migration guide as per the [breaking change policy].*

## 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 Hixie said 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
[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
2023-06-01 14:51:25 -07:00
Bruno Leroux
849e5fb2f6 [Windows - TextInput] Insert new line only when TextInputAction.newline (flutter/engine#42244)
## Description

This PR updates the Windows text input plugin to avoid adding a new line on a multiline text field when action is not set to `TextInputAction.newline`.

## Related Issue

Fixes https://github.com/flutter/flutter/issues/125879 as Linux and macOS implementations are merged.
Linux PR: https://github.com/flutter/engine/pull/41895
macOS PR: https://github.com/flutter/engine/pull/41977

## Tests

Adds 2 tests.
2023-06-01 20:59:13 +00:00
Brandon DeRosier
666563a554 [Impeller] Add Impeller Metal support in the embedder API (flutter/engine#42411)
Part of https://github.com/flutter/flutter/issues/112230.

Now seemed like the right time to sneak this in:
* We have large desktop refactors on the horizon (multi-window).
* We're starting to land optimizations that complicate the surface behavior such as wide gamut and dirty regions.
* We have plans to migrate the iOS embedder to use the embedder API (https://github.com/flutter/flutter/issues/112232).

![Screenshot 2023-05-30 at 6 59 48 PM](https://github.com/flutter/engine/assets/919017/16616be8-f94e-42ba-8a97-4ce4aa29e662)
2023-06-01 20:10:58 +00:00
Callum Moffat
7daf5e001c Fix crash getting spell-check suggestions (flutter/engine#42466)
On some Samsung devices Flutter with spell-check enabled will crash when typing/moving near the ">" character. 

Stack trace is

```
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.textservice.SentenceSuggestionsInfo.getSuggestionsCount()' on a null object reference
       at io.flutter.plugin.editing.SpellCheckPlugin.onGetSentenceSuggestions(SpellCheckPlugin.java:26)
       at android.view.textservice.SpellCheckerSession.lambda$handleOnGetSentenceSuggestionsMultiple$1$android-view-textservice-SpellCheckerSession(SpellCheckerSession.java:224)
       at android.view.textservice.SpellCheckerSession$$ExternalSyntheticLambda0.run(:4)
       at android.os.Handler.handleCallback(Handler.java:942)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:226)
       at android.os.Looper.loop(Looper.java:313)
       at android.app.ActivityThread.main(ActivityThread.java:8747)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
```
2023-06-01 19:37:16 +00:00
Jason Simmons
d473f0d24d Wait for GL command completion in the ExternalTextureGLRefreshedTooOften test (flutter/engine#42438)
This test sometimes caused assertion failures when running on Windows with ANGLE.  The process may be unable to safely clean up global objects if GL commands are pending when the test exits.
2023-06-01 18:46:16 +00:00
Kevin Lubick
1df7a98848 Clean up Skia includes around SkSurfaceCharacterization (flutter/engine#42485)
While contemplating a change to SkSurfaceCharacterization, I was curious
who was using this. Flutter #included it, but never actually seemed to
use it. Thus, I removed includes of it and other unnecessary #includes
in those same files, as well as addressing follow-on compile errors.

## 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].
- [ ] 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 Hixie said the PR is test-exempt. See [testing the engine]
for instructions on writing and running engine tests.
- [ ] 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
[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
2023-06-01 14:08:46 -04:00
Jim Graham
a98c1eb274 Reland "add non-rendering operation culling to DisplayListBuilder" (#41463) (flutter/engine#42330)
The original PR caused some golden test failures down the line, likely due to bad analysis of when the combined BlendMode and color would result in a NOP situation.

This PR adds tests that go through every BlandMode and pair it with a variety of colors and Color/ImageFilters to verify that the operations are only omitted when they actually produce no change in the output. It also checks the validity of the "modifies_transparent_black" property of DisplayLists which can be used in place of the current CanvasSpy/DlOpSpy classes.

The description from the [previous PR](https://github.com/flutter/engine/pull/41463) updated with the new name of the DL property:

---------------------------------
This optimization avoids recording unnecessary render operations that will not affect the output and also eliminates the need for "draw detection" mechanisms like `DlOpSpy` and `CanvasSpy` by remembering if any non-transparent operations were included. The `DlOpSpy` unit tests were updated to check if the results from that object match the new `DisplayList::modifies_transparent_black()` method.

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

In addition, this change will unblock some other Issues:

- https://github.com/flutter/flutter/issues/125318
- https://github.com/flutter/flutter/issues/125403
2023-06-01 17:44:04 +00:00
Kevin Lubick
8666e1af8f Register codecs with Skia explicitly (flutter/engine#42320)
In http://review.skia.org/689016, Skia added an option to explicitly
register codecs to use (instead of relying on #defines set by BUILD.gn
rules.

This uses that mechanism to explicitly register all the codecs that
Flutter was currently using from Skia (at least by my read of
[tools/gn](fee0534882/tools/gn (L292)).

I'm not sure if there is another place I need to put this sort of code,
e.g. for Fuchsia things.

To really test this out, we would want to add a define of
SK_DISABLE_LEGACY_INIT_DECODERS when compiling Skia, but I'm not sure
the best place to do this.

## 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].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] I added new tests to check the change I am making or feature I am
adding, or Hixie said the PR is test-exempt. See [testing the engine]
for instructions on writing and running engine tests.
- [ ] 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
[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
2023-05-31 14:15:18 -04:00
Zachary Anderson
9022cac6f8 Enables bugprone-unchecked-optional-access for some files (flutter/engine#42428) 2023-05-30 16:52:58 -07:00
hangyu
ab43a145cf Handle a11y focus event on Ios and android (flutter/engine#41777)
framework change:https://github.com/flutter/flutter/pull/126171
issue: https://github.com/flutter/flutter/issues/94523

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-05-30 21:50:56 +00:00
Matej Knopp
821bb52e38 Fix unitialized SkRect (flutter/engine#42403)
Empty SkRect needs to be created with `SkRect::MakeEmpty()` otherwise the default value is undefined (and possibly garbage).

*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-05-30 21:37:12 +00:00
Greg Spencer
a1b365111f Reland: "Adding app lifecycle notification for macOS and Linux, add hidden state." (#40542) (flutter/engine#42418)
## Description

This reverts commit 879917b to re-land #40542 to fix the lint warning which caused the original PR to be reverted (the lint warnings were turned on after the original was landed, which is why it wasn't caught earlier).
2023-05-30 20:45:46 +00:00
Zachary Anderson
879917b1e6 Revert "Adding app lifecycle notification for macOS and Linux, add hidden state." (flutter/engine#42384) 2023-05-28 00:02:58 -07:00
Greg Spencer
2af9be9d97 Adding app lifecycle notification for macOS and Linux, add hidden state. (flutter/engine#40542)
## Description

This adds app lifecycle notification for macOS and Linux, and adds a new `hidden` state to the `AppLifecycleState` enum.

To be functional, this needs a corresponding framework change: https://github.com/flutter/flutter/pull/123274

## Related Issues
 - https://github.com/flutter/flutter/issues/30735

## Tests
 - Added tests for state changes.
2023-05-26 23:24:33 +00:00
Chris Bracken
19c02ddcd9 [macOS] Extract more PlatformViewMutator code (flutter/engine#42361)
This extracts an extra method from `[FlutterMutatorView applyFlutterLayer:]` to perform the final PlatformViewContainer and PlatformView re-nesting in the view stack, then apply transforms, and finally apply the outer axis-aligned master clip rect around the whole thing.

This is a refactoring for readability (primarily clearer parameterisation) and applies no semantic changes to the code. This is the last in a series of refactoring applied to this method.

Issue: https://github.com/flutter/flutter/issues/124490

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-05-26 22:14:42 +00:00
Zachary Anderson
5633d0d833 Enable bugprone-unchecked-optional-access, disable in files with warnings (flutter/engine#42359)
First part of https://github.com/flutter/flutter/issues/127701
2023-05-26 21:58:46 +00:00
Renzo Olivares
ea95b85e63 [macOS] Do not bounce editing state back to framework on setEditState (flutter/engine#42091)
Some context for this change https://github.com/flutter/flutter/issues/118642#issuecomment-1550864240 and https://github.com/flutter/flutter/issues/118759#issuecomment-1551906489 . Tldr, the use-case that this bouncing was originally introduced for in #13702 is no longer an issue.

This ack response is also not present on other desktop platforms or iOS.

Fixes [#118759](https://github.com/flutter/flutter/issues/118759) and [#118642](https://github.com/flutter/flutter/issues/118642)
2023-05-26 21:07:02 +00:00
Dan Field
83b6fa4ff7 [Impeller] Avoid encoding metal commands while the GPU is unavailable when decoding images. (flutter/engine#42349)
Fixes https://github.com/flutter/flutter/issues/126878

This disables device private upload on iOS when backgrounded, and disables mipmap generation when backgrounded.

We don't have a good way to test the core problem in this repo because it only reproduces on physical iOS hardware - simulators don't really care if you do this stuff in the background.

I'll write a devicelab test in the framework to capture this. In the mean time it can be reviewed.

We could consider making the IOManager a shared_ptr instead of having an fml::WeakPtr and that'd clean up some of the extra arguments to engine construction - or we could consider vending the sync switch from impeller::Context unconditionally, but it's pretty iOS specific...
2023-05-26 18:46:33 +00:00
Jason Simmons
ff27c6d7a5 [Impeller] Disable the wide gamut settings flag on iOS simulators (flutter/engine#42331)
Wide gamut is not supported on the iOS simulator, and the iOS platform's FlutterView.isWideGamutSupported checked for this.  However, the ImageDecoder decides whether to enable wide gamut based on the engine's settings, so the flag in the settings needs to be modified for the simulator.
2023-05-26 00:31:10 +00:00
Tong Mu
3a4bdfa370 [macOS] Multi-view thread synchronizer (flutter/engine#41915)
This PR adapts `FlutterThreadSynchronizer` to multi-view.

### Problem
The `FlutterThreadSynchronizer` is a macOS engine class to ensure that, if the current window is resized, nothing will not be presented until the layer tree is drawn with the up-to-date size. 

This class is not compatible with multiview. A simple way to realize it is: while the class is owned by `FlutterView`, it blocks the _global_ platform thread and rasterizer thread - there is got to be some problems. Indeed, when I was testing with multiple windows (https://github.com/flutter/engine/pull/40399), the app freezes as soon as I resize a window.

The problem is because Flutter only have one rasterizer thread. When I'm resizing window A, A's synchronizer detects that the size mismatches, so it blocks the rasterizer thread to wait for an updated content with the updated size. However, window B is to be rendered next, and B's size matches and will try to rasterize, and will be blocked due to the blocked rasterizer thread, window A's updated content will never arrive, causing a deadlock.

### Changes
This PR removes the single-view assumption of `FlutterThreadSynchronizer` by making it created by `FlutterEngine` and shared by all `FlutterView`s, and that it prevents rasterization for all views if any view has a mismatched size.

The synchronizer is assigned to the view controller in the `attachToEngine:withId` method (now renamed to `setUpWithEngine:viewId:threadSynchronizer:`.

This PR also adds unit tests for `FlutterThreadSynchronizer`, which didn't have any unit tests at all.
* To achieve this, the `beginResizeForView:` method no longer checks whether  is called on the main thread, but whether it's called on the main queue. These are equivalent for the real main queue, since the documentation promises that the main queue always executes on the main thread. However, this change allows substituting the queue with a custom one for unit tests.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-05-25 22:37:35 +00:00
Tong Mu
3b00b85da8 [Rasterizer] Make resubmit information temporary (flutter/engine#42001)
This PR refactors `Rasterizer` so that the resubmit information is
returned as a temporary struct instead of stored permanently as class
member. This limits the lifetime of these values and reduces class
members.

Additionally, this benefits the multi-view project: if the rasterizer is
going to store multiple surfaces, what variables should be stored in a
map from view IDs? Should all surfaces have a to-be-submitted record?
The answer is "no", because these information is only temporary.

This PR should not need unit tests since it's only a refactor.

## Pre-launch Checklist

- [ ] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [ ] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [ ] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] I added new tests to check the change I am making or feature I am
adding, or Hixie said the PR is test-exempt. See [testing the engine]
for instructions on writing and running engine tests.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [ ] I signed the [CLA].
- [ ] 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
[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
2023-05-25 13:11:23 -07:00
Matej Knopp
634c40bf03 [macOS] Fix FlutterViewController retain cycle (flutter/engine#42317)
Fixes https://github.com/flutter/flutter/issues/127572

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-05-25 16:49:05 +00:00
Jonah Williams
be33a58e18 [Impeller] Encode render passes concurrently on iOS. (flutter/engine#42028)
Allows pushing encoding of command buffers to a worker thread, relying on the fact that these buffers are always scheduled in the order that they are enqueued. This follows the guidelines from https://developer.apple.com/documentation/metal/mtlcommandbuffer?language=objc
2023-05-23 19:40:05 +00:00