109 Commits

Author SHA1 Message Date
Matej Knopp
9a823f7768 Reduce number of surfaces required when presenting platform views (flutter/engine#43301)
Fixes https://github.com/flutter/flutter/issues/129710
Fixes https://github.com/flutter/flutter/issues/138936

Implements https://flutter.dev/go/optimized-platform-view-layers

## Example

This scene would normally require 5 surfaces, but with the PR it comes
down to 2 (when drawing over platform views) and 1 when all drawing is
outside of platform views).


https://github.com/flutter/flutter/assets/96958/091da832-bfbc-44a2-8da5-d55d84024c96

*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-11-27 14:07:43 +01:00
Matan Lurey
56fc8315cc Re-land "Make flow/embedded_views.h compatible with .clang_tidy." (flutter/engine#48137)
Reverts flutter/engine#48130.

Now that the `runIf` clauses are omitted, CI should be a reliable source
of truth.
2023-11-16 13:05:13 -08:00
auto-submit[bot]
74d08febd7 Reverts "Make flow/embedded_views.h compatible with .clang_tidy." (flutter/engine#48130)
Reverts flutter/engine#47994
Initiated by: jonahwilliams
This change reverts the following previous change:
Original Description:
Work towards https://github.com/flutter/flutter/issues/134969.

All changes were made automatically (i.e. with `--fix`).
2023-11-16 17:18:18 +00:00
Matan Lurey
b741431a73 Make flow/embedded_views.h compatible with .clang_tidy. (flutter/engine#47994)
Work towards https://github.com/flutter/flutter/issues/134969.

All changes were made automatically (i.e. with `--fix`).
2023-11-16 08:47:54 -08:00
Zachary Anderson
aad0b0f680 Revert dl split (flutter/engine#45326)
Reverting for https://github.com/flutter/flutter/issues/133525
fixes: https://github.com/flutter/engine/pull/45326
2023-08-31 17:46:12 +00:00
Dan Field
ffa16ec08f [Impeller] Reland DlAiksCanvas (flutter/engine#45232)
Relands https://github.com/flutter/engine/pull/45131

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

Differences from last time:

- Some minor merge conflict fixes
- Use the RTree to get the bounds instead of recalculating the bounds
- Make the iOS platform view controller implementation use the impeller-aware slices instead of the display list ones. This has been fixed for Android and the desktop embedding, but I missed iOS. The unit tests weren't actually running before I branched for my PR, @zanderso fixed them up separately and this resulted in catching the failures on post submit last time.
2023-08-31 00:29:23 +00:00
Jonah Williams
a04635d9e6 Revert "[Impeller] DlAiksCanvas as a DlCanvas wrapper for impeller::Canvas" (flutter/engine#45149)
Reverts flutter/engine#45131

This is failing the Impeller variants of the unobstructed platform views tests:

https://ci.chromium.org/ui/p/flutter/builders/prod/Mac%20Production%20Engine%20Drone/132249/overview

```
Failing tests:
	-[UnobstructedPlatformViewTests testPlatformViewsMaxOverlays]
	-[UnobstructedPlatformViewTests testOneOverlay]
	-[UnobstructedPlatformViewTests testOneOverlayPartialIntersection]
	-[UnobstructedPlatformViewTests testTwoIntersectingOverlays]
	-[UnobstructedPlatformViewTests testOneOverlayAndTwoIntersectingOverlays]

** TEST FAILED **
```

We've retried it a few times so I suspect this isn't a flake.
2023-08-26 19:31:39 +00:00
Dan Field
e9b2008748 [Impeller] DlAiksCanvas as a DlCanvas wrapper for impeller::Canvas (flutter/engine#45131)
This is a reland of https://github.com/flutter/engine/pull/44248

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

Changes from last time:

- The `drawPoints` benchmark was failing to render anything meaningful because of an error in `AiksLayer` that resulted in an infinitely sized bounding rectangle poisoning the bounds with `NaN` (this happens, for example, with a `drawPaint` call, which that benchmark happens to use). Added a test covering this and filed https://github.com/flutter/flutter/issues/132770 to explore ways to avoid this in the future.
- There was a bug in `DlAiksCanvas::SaveLayer` where a `nullptr` `paint` but non-`nullptr` `backdrop` was failing to actually save the layer. This resulted in incorrect rendering.
- There was a bug in `impeller::Canvas::DrawPicture` that resulted in incorrect stencil depth counting. That was fixed separately by @bdero, but was the cause of incorrect rendering in some Wonderous screens.
- I've added a simple implementation for `AiksLayer::IsReplacing`. It does not currently compare as deeply as the `DisplayListLayer` version potentially does, but it is good enough to avoid the regression noted in https://github.com/flutter/flutter/issues/132071. That regression was on a benchmark that greatly benefits from partial repaint. With the new implementation, it still gains partial repaint where it previously did not. There is more work that can be done here, filed https://github.com/flutter/flutter/issues/133361 to track that work.

I merged but did not fully integrate the `DisplayListBuilder`/`CanvasToReceiver` work that @flar has done. I have a local experiment with that, but would prefer to see this land and run through the device lab so we get some better comparison numbers for which one performs better.
2023-08-26 05:37:28 +00:00
Jim Graham
5a9d0ee712 Reland "Split DisplayListBuilder into DlCanvas optimizer and DlOp recorder classes #44718" (flutter/engine#45085)
Fixes: https://github.com/flutter/flutter/issues/133200
2023-08-25 00:22:14 +00:00
Jim Graham
5fa5cb698e Revert "Split DisplayListBuilder into DlCanvas optimizer and DlOp recorder classes" (flutter/engine#44968)
Reverts flutter/engine#44718

A rendering issue was discovered in internal testing (b/296975714)
2023-08-22 19:14:48 +00:00
Jim Graham
5774ccf84f Split DisplayListBuilder into DlCanvas optimizer and DlOp recorder classes (flutter/engine#44718)
DisplayListBuilder grew over time from a class that implemented a developer-unfriendly stateful API into one that implemented both the developer-friendly DlCanvas API as well as its original stateful API. Over time, the stateful API was buried under a "testing only" facade.

In the meantime, the optimization features that it applies to the DlCanvas calls before it records the operations in a DlOp store are useful without the recording process and so I've been wanting to break those into 2 parts for a while with the goal of removing all stateful APIs from DisplayListBuilder (see https://github.com/flutter/flutter/issues/108303).

This PR takes a major step along that direction by splitting DisplayListBuilder into essentially a convenience class that marries 2 new classes together to achieve its old functionality:
- `DlCanvasToReceiver` - a class that implements DlCanvas, optimizes common situations, and then sends commands to any object that implements `DlOpReceiver`
- `DlOpRecorder` - an implementation of DlOpReceiver that records the operations in a buffer from which to create a `DisplayList` object
- `DisplayListBuilder` now inherits from DlCanvasToReceiver to get the optimizations and provides it with an instance of `DlOpRecorder` as the receiver that it will send its results to
- Similarly, a `DlCanvasToReceiver` instance could be directed to an `impeller:DlDispatcher` to achieve a more straight-through path from the DlCanvas interface to impeller Pictures.
2023-08-21 07:17:19 +00:00
Jason Simmons
0413e2710d Revert "[Impeller] DlCanvas implementation wrapping Aiks canvas" (flutter/engine#44466)
This reverts commit 1785eb5cb8cba53da249614158065d1d53f8f863.

See https://github.com/flutter/flutter/issues/132071
2023-08-07 23:59:47 +00:00
Dan Field
1785eb5cb8 [Impeller] DlCanvas implementation wrapping Aiks canvas (flutter/engine#44248)
Fixes https://github.com/flutter/flutter/issues/130141

The primary goal of this patch is to move dispatching of `dart:ui` `Canvas` commands to the UI thread.

Before this patch, the architecture is something like:

## UI Thread
- `dart:ui` talks to `DisplayListBuilder`, a `DlCanvas` implementation.
- `DisplayListBuilder` does some clip/bounds tracking and creates a `DisplayList` object that is held by `dart:ui`'s `Picture` objects.
- `DisplayList`s are added to `DisplayListLayer`s in `flow`. 

## Raster Thread
- `flow` flattens the various operations into a single `DisplayList` via another `DisplayListBuilder`.
- A `DlOpReceiver`implementation converts that `DisplayList` into an `Aiks` `Canvas`/`Picture`.

After this patch, the architecture instead looks like:

## UI Thread

- No change for Skia.
- If Impeller, use a new `DlCanvasImplementation` that talks to `Aiks`'s `Canvas`.
- If Impeller, `dart:ui` Picture's now hold an `Aiks` `Picture`, which get shared into `AiksLayer`s in `flow`.

## Raster thread

- No change for Skia, but some light refactoring for places that assumed a `DisplayListBuilder` where they really just needed a `DlCanvas`.
- The `Aiks` `Picture`s are combined using new API on `DlCanvas` and still backed by `Aiks`.

These changes show significant improvement on raster times on Android and only very small regressions on UI times in local testing, see https://gist.github.com/dnfield/26528090194c9f5abdbac13cdcbf4f79 for old gallery transition perf numbers.

Many of the other changes in this patch are related to the following:

- Making `DlRTree` usable for Impeller.
  - It would be nice to have a version of DlRTree that speaks `impeller::Rect`.
- Creating the requisite classes to support `EmbeddedViews` so that Desktop works.

This patch does not remove the `impeller::DlDispatcher`, which now would only be used in tests.
2023-08-04 17:35:14 +00:00
Jim Graham
ce4c7d3ffd move rtree and canvas_spy sources to Fuchsia sub-directory (flutter/engine#43615)
These sources have long been obsolete for most of the engine, except for the Fuchsia sources. They do not need to be built for any other platform so this PR moves them into a Fuchsia platform-specific build directory so that they are only present in the Fuchsia binaries.
2023-07-12 22:22:39 +00:00
Dan Field
9062f9858c Delete unused display list/SkPicture code (flutter/engine#43560)
This code no longer does anything.
2023-07-11 17:15:47 +00:00
Jim Graham
b9835fa1b8 remove include of SkPicture files from non-Fuchsia sources (flutter/engine#43542)
Addresses most of https://github.com/flutter/flutter/issues/128060

Most of the uses of SkPicture and Recorder are removed from the engine sources. The few that remain are:

- DisplayList <-> Skia consistency testing code
- Legacy code only used from Fuchsia
- Dart CanvasKit uses which aren't actually using the local Skia sources or libraries

These are all comment and include file changes and so the testing is in the building.
2023-07-11 09:22:19 +00: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
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
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
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
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
Dan Field
96773d7c04 Avoid implicit conversions to floats in dart:ui (flutter/engine#40098)
Avoid implicit conversions to floats in dart:ui
2023-03-24 21:36:41 +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
Kevin Lubick
208eefd981 Fix forward declares and includes of some Skia Ganesh types (flutter/engine#40279)
Fix forward declares and includes of some Skia Ganesh types
2023-03-14 20:47:22 +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
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
Callum Moffat
a367fdc132 Fix position of BackdropFilter above PlatformView (flutter/engine#39244)
* Fix position of BackdropFilter in PlatformView

* Add check of PushFilterToVisitedPlatformViews
2023-02-09 23:58:28 +00:00
Jim Graham
2252b6f362 Reland layer state stack 2 (flutter/engine#37394)
* Revert "Revert "Reland layer state stack" (#37178)"

This reverts commit 21cc000359d8a4da097e8849e83dcbe8ac941e01.

* fix double-transform rendering issues in #114359

* adjust recently added unit test to state_stack APIs

* introduce LSS delegates to simplify some code and reduce overhead

* Fix ShellTest.OnServiceProtocolEstimateRasterCacheMemoryWorks

* add unit test for tracker.setTransform(4x4) and fix bug

* fix culling issue in LayerTree::Flatten
2022-11-17 19:34:19 +00:00
Dan Field
21cc000359 Revert "Reland layer state stack" (flutter/engine#37178) 2022-10-31 18:56:18 +00:00
Jim Graham
df85a4f401 Reland layer state stack (flutter/engine#37135) 2022-10-30 18:30:22 +00:00
Chris Yang
b7b95e9372 Reland "PlatformView partial blur #36015" (flutter/engine#37086) 2022-10-28 16:43:14 +00:00
Jim Graham
8ed073eb54 Revert layer state stack (flutter/engine#37090)
* Revert "Fix a clang-tidy warning in display_list_canvas_unittests.cc (#37062)"

This reverts commit 709c6735fc7ed34df36cee23805bdaa7f6969774.

* Revert "Create a mechanism to manage layer state (#36458)"

This reverts commit 501916deb19a8303ca2a3a9bb37692a873d4679e.
2022-10-27 15:29:58 -07:00
Chris Yang
1806c34015 Revert "PlatformView partial blur" (flutter/engine#37085) 2022-10-27 18:15:14 +00:00
Chris Yang
d30087802c PlatformView partial blur (flutter/engine#36015) 2022-10-27 18:02:09 +00:00
Jim Graham
501916deb1 Create a mechanism to manage layer state (flutter/engine#36458) 2022-10-26 21:43:10 +00:00
gaaclarke
e41c775200 Removed instances of unnecessary values (flutter/engine#36221) 2022-09-26 21:28:04 +00:00
emilyabest
2fd7dde9c8 PlatformView Blur for Backdrop Filter (flutter/engine#34596) 2022-09-06 17:30:57 +00:00
Zachary Anderson
407fb9e192 Revert "Pushing BackdropFilter Mutator (#34355)" (flutter/engine#35543)
This reverts commit ab6376ac20f0ab557b5d4737a8b61f20716b8e85.
2022-08-19 10:01:01 -07:00
Jim Graham
5f9579eae8 Display list multiplexer (flutter/engine#35421) 2022-08-16 05:34:52 +00:00
Javon Thomas
ab6376ac20 Pushing BackdropFilter Mutator (flutter/engine#34355) 2022-08-10 21:36:39 +00:00
Jim Graham
1413379354 Embedders use DisplayListBuilder for compositing (flutter/engine#35170) 2022-08-04 22:23:04 +00:00
Chris Yang
1b6c21d5c1 Make the filter_ in mutator shared_ptr (flutter/engine#34944) 2022-07-27 23:52:03 +00:00
Javon Thomas
43cf716d03 Create blanket backdrop filter mutator (flutter/engine#34408) 2022-07-13 22:08:05 +00:00
ColdPaleLight
5850d41dd0 Make sure that 'BeginFrame' and 'EndFrame' of the 'ExternalViewEmbedder' are paired (flutter/engine#32058) 2022-03-24 14:25:03 -07:00
Jenn Magder
f134ae9ac4 Remove implicit copy assignment operator for 'EmbeddedViewParams' (flutter/engine#30094) 2021-12-06 09:34:01 -08:00
Emmanuel Garcia
03fc3660f6 Destroy overlay surfaces when the rasterizer is torn down (flutter/engine#28894) 2021-09-28 14:38:02 -07:00
ColdPaleLight
4a74166097 Started providing the GPU sync switch to Rasterizer.DrawToSurface() (flutter/engine#28383)
Co-authored-by: Aaron Clarke <gaaclarke>
2021-09-01 11:37:22 -07:00
Dan Field
22da76000a Refactor GPU access switch (flutter/engine#24356) 2021-04-06 22:16:06 -07:00
Chris Bracken
9b4a0264d5 Correct typos throughout the engine/embedder (flutter/engine#25346)
Used the the `misspell` tool available at
https://github.com/client9/misspell, then applied hand-corrections. It's
possible we could adopt this as a presubmit, but there are still enough
false positives that it may not be worth the effort.
2021-04-01 11:08:19 -07:00