749 Commits

Author SHA1 Message Date
Jim Graham
7fea2b0933 switch from MockCanvas to DisplayListBuilder in layer unit tests (flutter/engine#41889)
Part of an ongoing set of efforts to address https://github.com/flutter/flutter/issues/106448

The layer unittests have been using a MockCanvas class to record the painting of trees of layers and then testing for the expected output.

A while back a similar mechanism was created to compare DisplayList output and to print out a human-friendly version of the differences found, but it was only used in a few tests written at the time it was created and a few since then.

This is the first in a series of PRs that will move all the rest of the unit tests onto the new DL comparison mechanism, starting with the layer types that just do basic drawing. Some of the remaining layers will require creating new hooks in, for instance, the Texture registry, the performance overlay TextBlob generation, etc.
2023-05-10 19:00:18 +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
Jim Graham
6ad6014776 [Impeller] take advantage of DisplayList culling (flutter/engine#41606)
Switching the calls to dispatch into an Impeller Dispatcher to use a cull rect to enable pre-culling of the out-of-bounds ops.

This change showed an improvement of around 2x on the rendering performance of the non-intersecting platform view benchmark, but that was measured without the recent changes to the destructive blend modes in Impeller renderer.
2023-05-01 23:27:52 +00:00
Jonah Williams
8167e14475 [Impeller] partial repaint for Impeller/iOS. (flutter/engine#40959)
Implements partial repaint for Impeller.

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

The new code that manages the damage regions is more or less a copy paste from the existing Skia implementation. Compared to Skia, there are a few differences:

Normally Impeller wants to use the drawable as the resolve texture for the root MSAA pass. Unfortunately this will unconditonally clear that texture. Thus to do a partial repaint, we have to allocate a separate texture to resolve to and then blit into the drawable.

The blit seems to take about 500ns for a full screen on an iPhone 13. That implies that partial repaint is likely not worth doing if the screen is significantly changed. Thus I've added code in compositor_context.cc that computes the percentage of width or height that is part of the dirty rect. Above a threshold of (abitrarily chosen) 70%, we just render as normal. This should mean there is only a very minor hit from performing the diff on screens that are highly changed.

The other special case, is that sometimes we get damage rects that are empty - that is the drawable is already completely up to date with what we want to render. IN that case I shortcircuit all of the impeller code and just present immediately. I previously tried returning without a present but this resulted in Xcode reporting dropped frames. One caveat here is that if you use the XCode frame debugger and attempt to capture a frame where we early present, then it will claim it couldn't capture any command buffers (because we didn't create any).

To facilitate all of this, I added some additonal plumbing so that the impeller surface can get the clip rect from the submit info. Additionally, rather than using a clip rect impeller will translate and then shrink the root surface texture. This reduces memory usage compared to just clippling.
2023-04-26 21:13:03 +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
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
Kevin Lubick
108eb0fa89 Migrate uses of deprecated SkImage->encodeToData (flutter/engine#41204)
In https://skia-review.googlesource.com/c/skia/+/667296, Skia deprecated
`SkImage->encodeToData`.

This PR fixes all uses in Flutter of that API by using SkPngEncoder
directly.

## 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-17 10:03:40 -07: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
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
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
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
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
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
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
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
Dan Field
f08b06a495 Preserve order when regenerating GPU images (flutter/engine#40268)
Preserve order when regenerating GPU images
2023-03-14 19:59:16 +00: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
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
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
Jason Simmons
ccb2f5758f Always use integers to hold the size of the performance overlay cache bitmap (flutter/engine#40071)
Previously this was comparing a float overlay rectangle size with an
integer cache bitmap size.  This could result in mismatches if the
overlay width is not an integer.
2023-03-04 08:54:13 -08:00
Kevin Lubick
709e160b5c Fix includes of SkBitmap/SkImage (flutter/engine#40026) 2023-03-02 12:25:42 -08:00
Nayuta403
51f3dfb971 fix typo (flutter/engine#39971)
fix typo
2023-03-02 09:25:26 +00:00
Jim Graham
cf7d6b6440 remove obsolete DlAttribute::From(SkObject) methods (flutter/engine#40005)
remove obsolete DlAttribute::From(SkObject) methods
2023-03-02 03:49:18 +00:00
Jim Graham
90da25ef48 uncomment a DL raster cache unittest enhancement now that it is feasible (flutter/engine#39845)
uncomment a DL raster cache unittest enhancement now that it is feasible
2023-02-24 19:00:14 +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
Jim Graham
39c93ced57 Cached DisplayList opacity inheritance fix (flutter/engine#39690)
* only indicate opacity inheritance when DL is actually cached

* unit test

* use CacheInfo struct to simplify return values
2023-02-17 05:18:23 +00: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
gaaclarke
f51ea3b01f [Impeller] Adds wide gamut support for iOS. (flutter/engine#39111)
* Implemented wide gamut images for iOS

Moved the surface to an extended range color format.

* wrong gamma but default pixel format set to bgra10_xr

* BGR10_XR add

* format

* updated todos

* updated todo with information about pixel formats

* switched logic for determining if we have a wide gamut image

* cleaned up gamut math to match style and linked source

* made the color attachment pixel format match the surface

* updated vulkan format switch

* removed comment

* added enable disable switch

* moved default to bgr10 for now since there is a bug where someone is still reading this, msaa?

* fixed the decoder settings to make sure we don't lose wide gamut colors

* fixed stored srgb gamut variable

* fixed false lint

* updated test

* added ability to grab the surface data for tests

* made the screenshot utility return the format

* added width and height to the platform channel payload

* fixed a couple of broken targets

* moved back the default pixel buffer format

* cleanup and add docstrings

* made the surfacedata feature only available in debug builds

* added decoding unit test

* fixed objc tests

* turned off by default

* bdero feedback1

* bdero2

* bdero3

* fixed merge issue

* removed using std::shared_ptr
2023-02-11 00:08:20 +00:00
Matej Knopp
066c6c6d8f Use DisplayListMatrixClipTracker in DiffContext (flutter/engine#38010) 2023-02-10 20:50:28 +00:00
Jim Graham
99de2ca94b add support to run dl_canvas_unittests on GPU surfaces (off by default) (flutter/engine#38993)
* add support to run dl_canvas_unittests on GPU surfaces (off by default)

* empty commit to trigger build

* conditionally include platform-specific surface provider headers

* ignore DL test files during license checks

* typo

* add dependencies to rendertests to hopefully build on Windows

* remove benchmarking deps from dl_rendertests

* more changes to get Windows rendertests to link

* add --enable-gl synonym and prevent non-SW surface provider dest on Windows

* fix gn formatting

* review feedback
2023-02-10 20:43:13 +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
Brandon DeRosier
841758cc6c Add SkSurface include to every file where it's used (flutter/engine#39304) 2023-02-01 00:50:58 +00:00
Callum Moffat
be0feedee7 Fix position of ImageFilter layer when raster-cached (flutter/engine#38567)
* Fix position of ImageFilter layer when raster-cached

* Move integral transform and add tests

* Don't round in Preroll
2023-01-25 21:12:02 +00:00
Kevin Lubick
ecd5ad9c7c SkBudgeted -> skgpu::Budgeted (flutter/engine#38660)
* SkBudgeted -> skgpu::Budgeted

* colon

* format

* fix GN rules

* undo includes
2023-01-05 21:42:34 +00:00
Jim Graham
c48bdca6da Display list R-Tree culling (flutter/engine#38429)
* collect DL indices in RTree for clip culling

* fix bounds in unit test and minor opt in Dispatch

* normalize inline matrix objects and minor fixes to unit test

* remove over-eager DCHECK and improve R-Tree comments

* formatting

* include vector for Windows

* method rename and distribute child nodes more evenly

* add R-Tree specific unit tests and debug checks

* add comments about geometry to R-Tree unit tests and adjust spacing

* licenses

* licenses attempt 2

* fix potential overflow with uint32_t

* aggressively const DisplayList fields and methods

* add implementation comments per review feedback
2022-12-22 10:16:25 +00:00
ColdPaleLight
2779c20e03 Collapse bounds calculations into DisplayListBuilder (flutter/engine#34365)
* Collapse bounds calculations into DisplayListBuilder

* Tweak code

* Remove bounds cull

* Remove obsolete comment
2022-12-15 11:52:52 +00:00
Jim Graham
f2fd4d7f0e Fix premature LayerStateStack layer culling (flutter/engine#38159)
* remove premature opacity culling

* remove premature clip culling
2022-12-09 21:31:05 +00:00
Ian Hickson
7ab8cddeb7 Documentation and other cleanup in dart:ui, plus a small performance improvement. (flutter/engine#38047)
* Remove nonsensical (and I think unnecessary?) comment.
* Document willChangeHint, isComplexHint
* Fix grammer in Rect docs
* Remove runtimeType.toString twice
* Add detail to ImageShader constructor docs.
* Document Vertices and drawVertices!
* Update checks in Vertices constructors (and add tests).
* Fix some typos.
* Minor other doc improvements.
* Fold in @jonahwilliams' performance improvement from https://github.com/flutter/engine/pull/38041
2022-12-03 01:13:06 +00:00
Jim Graham
07fc5a59f9 Add optional offset parameter to ImageFilterLayer (flutter/engine#36863)
* add optional offset parameter to ImageFilterLayer

* update unit test for LayerStateStack and fix HTML implementation
2022-11-21 17:59:55 +00:00
Jenn Magder
3085f214f9 Turn on clang tidy error for underscores in Google tests (flutter/engine#37700) 2022-11-17 21:13:11 +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
Michael Ludwig
8191916a47 Use SkImageFilters::Shader instead of ::Paint (flutter/engine#37682)
* Use SkImageFilters::Shader instead of ::Paint

SkImageFilters::Paint() is deprecated and will be removed in https://skia-review.googlesource.com/c/skia/+/604917

* Fix formatting
2022-11-16 12:56:57 -08:00