1130 Commits

Author SHA1 Message Date
Dan Field
ea5131772d Add a Display API to dart:ui that reports the physical size, DPR, and refresh rate of the main display (flutter/engine#41685)
Fixes https://github.com/flutter/flutter/issues/123307 - for Android, iOS, and Web, for the main display only (https://github.com/flutter/flutter/issues/125938 tracks supporting multiple displays, https://github.com/flutter/flutter/issues/125939 for desktop).

Desktop will need to be implemented for this, but given priority for a couple of our customers targetting foldable devices on Android I'm inclined to get this in before desktop can be finished.

The main concern for this right now is that on some Android foldable devices, setting a preferred orientation will cause letterboxing and the `MediaQuery` will _never_ get the full screen size when unfolded. This causes apps to think the screen is smaller than it is, as they've mainly been using `MediaQueryData.size` to figure this out. Android's recommendation is to not set a preferred orientation, and if you must to use the new method introduced in `ViewUtil.java` to calculate the maximal window size.
2023-05-06 18:28:22 +00:00
Tong Mu
05036058d7 Remove single window assumption from SceneBuilder (flutter/engine#41559)
This PR fixes https://github.com/flutter/flutter/issues/112202. `Scene`
is no longer tied to views, but receives method arguments for view
properties, clearing the path to multiview Flutter.

`Scene` no longer creates a `LayerTree` on construction, but only part
of the config. When a output method is called (`toImage`, `toImageSync`,
or `takeLayerTree`), the `LayerTree` is constructed on the spot. In this
way, all `LayerTree`s return to being `unique_ptr`s instead of
`shared_ptr`s, reverting part of
https://github.com/flutter/engine/pull/35608 . And `Scene` no longer
needs to disfunction after one `takeLayerTree`, since the layer tree
config is never really taken away.

A `device_pixel_ratio` is now added to the parameter list of `Engine::Render` and `Animator::Render`.

## 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.
- [ ] 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-05-05 11:25:55 -07:00
Jonah Williams
dfff522046 Remove physical model layer (flutter/engine#41593)
Removes the physical model layer and associated engine code. This was already deprecated and removed in the framework. By removing it in the engine, we can also remove the need for layer tree diff/paint/preroll to have the device pixel ratio. This will simplify some of the multi-view work

Fixes https://github.com/flutter/flutter/issues/125720
2023-05-03 20:28:53 +00:00
Brandon DeRosier
b4271c24de Add missing header guards (flutter/engine#41322)
These keep turning up, so I did a little bash-fu to find them all.
```bash
grep -lL "#pragma once" $(grep -lL "#ifndef .*_H_" $(find . | grep "\.h$")) | cut -c 3-
```
2023-04-19 21:20:21 +00:00
Chinmay Garde
4117cb927e [Impeller] Make //impeller/display_list TU naming consistent. (flutter/engine#41174)
No change in functionality. I've just renamed the TU's to replace `display_list_` to `dl_`. I am sure there are chances to make the naming better. For instance, the op receiver still being named a dispatcher.
2023-04-19 17:32:53 +00:00
Jim Graham
d4a56c721b focus SkiaGPUObject wrappers on only those objects that need the protection (flutter/engine#41237)
With this PR we no longer need to hold DisplayLists in GPUObject wrappers and they can be disposed instantly instead of queueing on the Unref thread.

This will definitely be a win for Impeller as none of the objects used in a frame now require queueing, but the performance impact on apps running on top of skia is less clear if they depend on a lot of images inside their DisplayLists that still need to be queued to be freed. After getting further in the work, it looks like only decoded images need to use the protected DlImage wrappers and most of those should survive many frames before they are disposed. That should hopefully leave very few unrefs happening per frame.

~There are 3 unit tests in `shell_unittests.cc` and `embedder_metal_unittests.mm` that are now GSKIP'd as they now invoke code that needs a fully initialized UIDartState in order to protect their images. I will look into fixing the tests and/or making the code they invoke provide protection without relying on UIDartState.~ (This looks to be fixed in the latest commit by simply not creating DlImageGPUs all over the source base and simply catching only those that end up in UI data structures. There is actually existing code in one of the modules that feeds ui.Image with an answer to wrap the image in a DlImageGPU if it has a skia image anyway, so most of these additional uses of DlImageGPU that were having trouble getting the Skia unref queue just didn't need it anyway.)
2023-04-17 23:47:20 +00:00
fzyzcjy
6b6f725d6d [Impeller] Make DoMakeRasterSnapshot output timeline event. (flutter/engine#41197)
In Skia, there is such a timeline event in `SnapshotControllerSkia::DoMakeRasterSnapshot`. Therefore, since Impeller wants to mimic Skia and this event does take a long time sometimes, it seems reasonable to add this.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-04-17 20:44:19 +00:00
Dan Field
b156f07ddc [Impeller] Allow image rasterization/decoding before/without surface acquisition (flutter/engine#41168)
[Impeller] Allow image rasterization/decoding before/without surface acquisition
2023-04-14 03:02:17 +00:00
LouiseHsu
7f3889d6b0 Revert "Add support for double tap action from Apple Pencil 2" (flutter/engine#41138)
Reverts flutter/engine#39637

Since this feature https://github.com/flutter/flutter/issues/73172 has
been scrapped for now, previous engine work should be reverted. Refer to
[this design
doc](https://docs.google.com/document/d/1r4P5r-jGt2Sjqro3ldCU2axUiHTpu3yhIycnI94OKQw/edit
) for more discussion and details.
2023-04-13 14:59:04 -07:00
Jonah Williams
e14c6ed93d [Impeller] remove unref queue usage on Impeller. (flutter/engine#41050)
[Impeller] remove unref queue usage on Impeller.
2023-04-11 16:49:04 +00:00
Jason Simmons
5fdd31653e Update some more uses of the deprecated Skia SkImage::MakeFromBitmap API (flutter/engine#41041) 2023-04-10 12:27:56 -07:00
Chris Yang
5da580cfb2 [embedder] embedder external view adopt DisplayListEmbedderViewSlice (flutter/engine#40578)
[embedder] embedder external view adopt DisplayListEmbedderViewSlice
2023-04-10 18:54:39 +00:00
Kevin Lubick
a08288c38b Remove (unused) SkImageEncoder.h includes (flutter/engine#40989)
I'm refactoring Skia's image codecs and noticed that although Flutter
includes this header, it doesn't seem to use any of the symbols from it:
`SkEncodeImage` and `SkEncodePixmap`.

This PR removes those includes and also adds some missing includes which
will aid future Skia cleanup CLs.

## 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].
- [ ] 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-04-07 08:27:24 -07:00
Dan Field
967f12d809 [Impeller] Make multi-frame image decodes work even if the GPU switch is disabled (flutter/engine#40963)
Fixes https://github.com/flutter/flutter/issues/124269

Manually verified this is safe on an iPhone 11.

We're not creating/encoding command buffers in this path so it's ok.
AFAICT the test I added would fail if we started doing that because it
doesn't provide any real command buffer interfaces. Most of the code
here is related to tests.
2023-04-06 11:40:27 -07:00
fzyzcjy
047e7d61f5 Fix super tiny typo (flutter/engine#40932)
Fix super tiny typo
2023-04-05 18:31:48 +00:00
Dan Field
668566b8fa [Impeller] Respect enable-impeller command line setting over info.plist setting (flutter/engine#40902)
[Impeller] Respect enable-impeller command line setting over info.plist setting
2023-04-04 00:34:58 +00:00
Zachary Anderson
db6bf07686 Revert "[Impeller] Use Vulkan by default (#40809)" (flutter/engine#40820)
This reverts commit 35efb76a0606844593208ce0c6722aeb9c6b89cf.

Reverting for https://github.com/flutter/flutter/issues/123859
2023-03-31 08:05:36 -07:00
Dan Field
35efb76a06 [Impeller] Use Vulkan by default (flutter/engine#40809)
[Impeller] Use Vulkan by default
2023-03-31 05:05:56 +00:00
Kevin Lubick
f944e918a1 Use new SkImages namespace instead of legacy SkImage static functions (flutter/engine#40761)
Use new SkImages namespace instead of legacy SkImage static functions
2023-03-30 20:22:09 +00:00
Chinmay Garde
8116ea14c7 [Impeller] Enable vulkan validations via a flag on Android. (flutter/engine#40792)
[Impeller] Enable vulkan validations via a flag on Android.
2023-03-30 20:07:51 +00:00
Jim Graham
37317c5984 restructure DL sources into sub-directories and new file naming conventions (flutter/engine#40157)
restructure DL sources into sub-directories and new file naming conventions
2023-03-21 02:34:48 +00:00
Greg Spencer
28a810a5b2 Rename setters for lifecycle state (flutter/engine#40462)
Rename setters for lifecycle state
2023-03-20 21:16:21 +00:00
Jim Graham
f9918c006e Reland "Sequester all Skia<->DL interactions into the skia sub-module" (flutter/engine#40435)
Reland "Sequester all Skia<->DL interactions into the skia sub-module"
2023-03-19 22:59:17 +00:00
Zachary Anderson
6abd95a53b Provisional iOS impeller flag flip (flutter/engine#40405) 2023-03-17 20:35:36 -07:00
Chris Bracken
1404722d05 Add doc comment to Pipeline (flutter/engine#40388)
Add doc comment to Pipeline
2023-03-17 20:38:55 +00:00
Zachary Anderson
d39891c432 Un-bitrot impeller_unittests; disable failing tests; disable non-metal backends (flutter/engine#40339) 2023-03-16 19:34:57 -07:00
Jim Graham
eb3a75ef78 Revert "Reland "Sequester all Skia<->DL interactions into the skia sub-module" (#40319)" (flutter/engine#40357)
Revert "Reland "Sequester all Skia<->DL interactions into the skia sub-module""
2023-03-16 19:55:51 +00:00
Jim Graham
4107e5a226 Reland "Sequester all Skia<->DL interactions into the skia sub-module" (flutter/engine#40319)
Reland "Sequester all Skia<->DL interactions into the skia sub-module"
2023-03-15 22:56:01 +00:00
Jim Graham
b89acc989c Revert "Reland "Sequester all Skia<->DL interactions into the skia sub-module" (#40243)" (flutter/engine#40283)
This reverts commit bbc993164a0d2f7d5a1b7b052ff884500040acc0.
2023-03-14 15:33:08 -07:00
Jim Graham
bbc993164a Reland "Sequester all Skia<->DL interactions into the skia sub-module" (flutter/engine#40243)
Reland "Sequester all Skia<->DL interactions into the skia sub-module"
2023-03-14 18:53:06 +00:00
Dan Field
1de9bf9581 Make the context current before accessing GL in MakeSkiaGpuImage (flutter/engine#40208)
Make the context current before accessing GL in MakeSkiaGpuImage
2023-03-11 00:39:04 +00:00
Jonah Williams
726df65356 Reland: Move asset opening to background thread, fix dart persistent value destruction (flutter/engine#40183)
Reland: Move asset opening to background thread, fix dart persistent value destruction
2023-03-09 22:58:04 +00:00
Jim Graham
bc162fe559 Revert "Reland "Sequester all Skia<->DL interactions into the skia sub-module" (#40114)" (flutter/engine#40161)
Revert "Reland "Sequester all Skia<->DL interactions into the skia sub-module""
2023-03-09 02:41:54 +00:00
Dan Field
3950fa55ca Improve error messaging when render target cannot be created (flutter/engine#40150) 2023-03-08 12:33:29 -08:00
Zachary Anderson
44947b8822 Revert "[engine] move asset mapping copy to background thread (#39918)" (flutter/engine#40147)
Revert "[engine] move asset mapping copy to background thread"
2023-03-08 19:30:27 +00:00
Jonah Williams
9bc89c950c [engine] move asset mapping copy to background thread (flutter/engine#39918)
[engine] move asset mapping copy to background thread
2023-03-08 00:28:34 +00:00
Jim Graham
53a80bdedf Reland "Sequester all Skia<->DL interactions into the skia sub-module" (flutter/engine#40114)
Reland "Sequester all Skia<->DL interactions into the skia sub-module"
2023-03-07 19:03:17 +00:00
Jason Simmons
6927af678e Revert "Sequester all Skia<->DL interactions into the skia sub-module (#40083)" (flutter/engine#40103)
Revert "Sequester all Skia<->DL interactions into the skia sub-module (#40083)"
2023-03-07 02:58:49 +00:00
Jim Graham
acd130b2b2 Sequester all Skia<->DL interactions into the skia sub-module (flutter/engine#40083)
Sequester all Skia<->DL interactions into the skia sub-module
2023-03-06 19:55:32 +00:00
Chris Yang
baee6242e3 [ios] add setting flag to enable embedder api. (flutter/engine#40025)
[ios] add setting flag to enable embedder api.
2023-03-03 23:17:19 +00:00
Jason Simmons
719b8c319d Do not end the frame in the raster cache if ScopedFrame::Raster returns kResubmit (flutter/engine#40007)
Do not end the frame in the raster cache if ScopedFrame::Raster returns kResubmit
2023-03-03 01:12:55 +00:00
Jim Graham
0fa8cbec8a Create DlCanvas interface and implement with DisplayListBuilder and SkCanvasAdapter (flutter/engine#39762)
* Create DlCanvas interface and implement with DisplayListBuilder and SkCanvasAdapter
2023-02-23 22:09:35 -08:00
Tong Mu
dafb738c0a Remove surface check when querying ExternalViewEmbedder (flutter/engine#39803) 2023-02-23 13:51:15 -08:00
Jason Simmons
f2c5edb7fc Fix a race in ShellTest.PushBackdropFilterToVisitedPlatformViews (flutter/engine#39798)
Fixes https://github.com/flutter/flutter/issues/121096
2023-02-22 22:08:21 +00:00
Loïc Sharma
a9e12287f6 [dart:ui] Introduce PlatformDispatcher.implicitView (flutter/engine#39553)
This introduces `PlatformDispatcher.implicitView`, a low-level primitive for the framework's bootstrapping. Most code, including the framework after bootstrapping, will use `View.of(context)` instead of this new API. This new primitive will let us deprecate the `window` global.

Goals:

1. **Enable multi-window**. The `PlatformDispatcher.implicitView` is nullable. If `null`, the app must create a window to get a view it can draw into.
2. **Backwards compatibility**. For "single window" apps, `PlatformDispatcher.instance.implicitView` should behave as similar to `window` as possible.
    1. The `PlatformDispatcher.instance.implicitView.viewId` should be `0`.
    1. The `PlatformDispatcher.instance.implicitView` must be available synchronously at root isolate startup. This allows the framework to determine if it can make single window assumptions at startup.
    2. The `PlatformDispatcher.instance.implicitView` reference must not change after startup: if it is null at startup, it must always be null; if it is non-null at startup, it must always be non-null. If "single window" app enters headless mode, the implicit view must remain non-null.

In the future, the embedder will control whether an implicit view is created: mobile & legacy desktop apps will have an implicit view, multi-window desktop apps won't have an implicit view. This requires updating the engine's embedder API and is out-of-scope for this change. For now, all apps will have an implicit view.

Part of https://github.com/flutter/flutter/issues/120306
2023-02-16 16:32:14 -08:00
Rulong Chen(陈汝龙)
4fb5044193 Uses int64_t instead of int for the |view_id| parameter. (flutter/engine#39618) 2023-02-16 20:20:15 +00:00
LouiseHsu
a63ba37c86 Revert "Revert "Add support for double tap action from Apple Pencil 2 (#39267)" (#39607)" (flutter/engine#39637)
This reverts commit f112c452b80012e456f9ce41deb3009010fe2336.
2023-02-15 20:00:26 +00:00
Jonah Williams
f112c452b8 Revert "Add support for double tap action from Apple Pencil 2 (#39267)" (flutter/engine#39607)
This reverts commit adb83f7d563aaaa44148f7b6a6c76846feb17cb3.
2023-02-14 02:04:06 +00:00
LouiseHsu
adb83f7d56 Add support for double tap action from Apple Pencil 2 (flutter/engine#39267)
* working commit

* some clean up

* white space fixes

* whitespace

* remove unused import

* Addressing PR comment, fix tests, update touch packet on Andriod

* formatting n whitespace again

* add new field to web ui pointer.dart

* update test

* whitespace

* fix test

* PR comments

* fix test

* whitespace

* fix test by factoring out logic into helper function

* whitespace

* fix malformed string

* pr comments

* fix type issue

* sigh whitespace

* revert test changes :)

* pr comments + separate out tests

* extra space

* change test name
2023-02-13 21:52:45 +00:00
Jason Simmons
5f09e0fdf0 Remove Libtxt and Minikin (flutter/engine#39499) 2023-02-13 17:16:04 +00:00