This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
[canvaskit] Enable multiview rendering #48301
Merged
harryterkelsen
merged 48 commits into
flutter:main
from
harryterkelsen:canvaskit-renderer-multiview
Nov 27, 2023
Merged
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
2dacc82
WIP add multiview to renderer
harryterkelsen 913ad52
Merge branch 'main' into canvaskit-renderer-multiview
harryterkelsen d0b625e
WIP
harryterkelsen 241ed34
Merge branch 'main' into canvaskit-renderer-multiview
harryterkelsen 9deb9c7
WIP multiview rendering
harryterkelsen 29dd070
Merge branch 'main' into canvaskit-renderer-multiview
harryterkelsen edb64ec
Respond to comments
harryterkelsen bca01da
Fix tests
harryterkelsen 373b740
Added basic unit test for multiview rendering
harryterkelsen fa27c2b
Merge branch 'main' into canvaskit-renderer-multiview
harryterkelsen 28101a0
Remove unused import in test
harryterkelsen fe52616
Respond to comments
harryterkelsen 225cd17
Add trailing commas so dartfmt doesn't explode
harryterkelsen 0e5ec2c
Undo dartfmt
harryterkelsen 71da65c
trailing whitespace
harryterkelsen ea3791a
trailing whitespace
harryterkelsen f7ddbac
Roll Skia from 3a79d7a618aa to 5606ef899116 (1 revision) (#48331)
skia-flutter-autoroll 27279e7
[web] Hook the new JS API to the FlutterViewManager (#48283)
mdebbar bcfb4fa
Fix not being able to hide iOS status bar via setEnabledSystemUIMode …
LinXunFeng 91b753a
Roll Fuchsia Linux SDK from IK4xyRtZkDwqT6pXA... to 4CZFCL5oL042nQihC…
skia-flutter-autoroll bdc563d
Roll Skia from 5606ef899116 to fc9c5337e568 (1 revision) (#48339)
skia-flutter-autoroll 7bc18bc
Roll Skia from fc9c5337e568 to 094c3d963ba0 (6 revisions) (#48340)
skia-flutter-autoroll 9e9b67c
Roll Skia from 094c3d963ba0 to 2c89bb28860b (1 revision) (#48341)
skia-flutter-autoroll 95a5fb2
Roll Skia from 2c89bb28860b to b3d947126fd2 (1 revision) (#48349)
skia-flutter-autoroll bcc59ad
Roll Skia from b3d947126fd2 to de1673ed1618 (1 revision) (#48350)
skia-flutter-autoroll 4d9bf77
Roll Skia from de1673ed1618 to 201d0c8d83f0 (1 revision) (#48352)
skia-flutter-autoroll a92c484
Roll Skia from 201d0c8d83f0 to b18b594b230d (1 revision) (#48356)
skia-flutter-autoroll e0bdff1
Roll Fuchsia Linux SDK from 4CZFCL5oL042nQihC... to P3HXI8K3eIeoBYhdX…
skia-flutter-autoroll b5da2ff
[Flutter GPU] Raster encoding. First triangle! (#48314)
bdero 53cdf35
Roll Fuchsia Linux SDK from P3HXI8K3eIeoBYhdX... to zHKuNuXtMPLbovc0j…
skia-flutter-autoroll 2f7f23e
Roll Skia from b18b594b230d to 0eea0b277d7d (7 revisions) (#48387)
skia-flutter-autoroll 690ff8a
Roll Fuchsia Linux SDK from zHKuNuXtMPLbovc0j... to qyRH6zYfUEjo9L1x2…
skia-flutter-autoroll c38043a
[Impeller] OES extension does not apply to regular textures for decal…
84feadc
[Impeller] use spec constant for decal support in morph filter. (#48288)
6855b20
[Flutter GPU] Texture binding, index binding, attachments, depth stat…
bdero 71d2ffb
Roll Skia from 0eea0b277d7d to b3e896c2f9bf (2 revisions) (#48391)
skia-flutter-autoroll ad428b2
Roll Skia from b3e896c2f9bf to 2bf9afca2bc1 (1 revision) (#48392)
skia-flutter-autoroll b0c6d87
Roll Skia from 2bf9afca2bc1 to 9fa62ccefe59 (1 revision) (#48393)
skia-flutter-autoroll ac1684c
Reduce number of surfaces required when presenting platform views (#4…
knopp 4e455c2
Roll Skia from 9fa62ccefe59 to 5f0832787d0f (1 revision) (#48400)
skia-flutter-autoroll 91c82d9
Roll Skia from 5f0832787d0f to b0d81aba3f78 (1 revision) (#48401)
skia-flutter-autoroll d73d7b2
Manual roll Dart SDK from f1fd14505782 to c9bdb5884670 (10 revisions)…
skia-flutter-autoroll cc43161
Roll Skia from b0d81aba3f78 to 743fc1cde518 (3 revisions) (#48406)
skia-flutter-autoroll eb13bc2
[Impeller] revert non-zero tessellation optimization. (#48234)
2593d1f
Roll Skia from 743fc1cde518 to 4c964f8c4738 (2 revisions) (#48410)
skia-flutter-autoroll a28b802
Respond to review comments
harryterkelsen 0e59f27
Fix TODOs and changed EngineFlutterView constructor
harryterkelsen bcf62a7
Merge branch 'main' into canvaskit-renderer-multiview
harryterkelsen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,9 +44,16 @@ class CanvasKitRenderer implements Renderer { | |
| DomElement? _sceneHost; | ||
| DomElement? get sceneHost => _sceneHost; | ||
|
|
||
| late Rasterizer rasterizer = Rasterizer(); | ||
| /// This is an SkSurface backed by an OffScreenCanvas. This single Surface is | ||
| /// used to render to many RenderCanvases to produce the rendered scene. | ||
| final Surface offscreenSurface = Surface(); | ||
|
|
||
| set resourceCacheMaxBytes(int bytes) => rasterizer.setSkiaResourceCacheMaxBytes(bytes); | ||
| set resourceCacheMaxBytes(int bytes) => | ||
| offscreenSurface.setSkiaResourceCacheMaxBytes(bytes); | ||
|
|
||
| /// A surface used specifically for `Picture.toImage` when software rendering | ||
| /// is supported. | ||
| final Surface pictureToImageSurface = Surface(); | ||
|
|
||
| @override | ||
| Future<void> initialize() async { | ||
|
|
@@ -64,13 +71,7 @@ class CanvasKitRenderer implements Renderer { | |
|
|
||
| @override | ||
| void reset(FlutterViewEmbedder embedder) { | ||
| // CanvasKit uses a static scene element that never gets replaced, so it's | ||
| // added eagerly during initialization here and never touched, unless the | ||
| // system is reset due to hot restart or in a test. | ||
| _sceneHost = createDomElement('flt-scene'); | ||
| // TODO(harryterkelsen): Do this operation on the appropriate Flutter View. | ||
| final EngineFlutterView implicitView = EnginePlatformDispatcher.instance.implicitView!; | ||
| implicitView.dom.setScene(_sceneHost!); | ||
| // No work required. | ||
| } | ||
|
|
||
| @override | ||
|
|
@@ -373,7 +374,7 @@ class CanvasKitRenderer implements Renderer { | |
| CkParagraphBuilder(style); | ||
|
|
||
| @override | ||
| void renderScene(ui.Scene scene) { | ||
| void renderScene(ui.Scene scene, ui.FlutterView view) { | ||
| // "Build finish" and "raster start" happen back-to-back because we | ||
| // render on the same thread, so there's no overhead from hopping to | ||
| // another thread. | ||
|
|
@@ -384,10 +385,39 @@ class CanvasKitRenderer implements Renderer { | |
| frameTimingsOnBuildFinish(); | ||
| frameTimingsOnRasterStart(); | ||
|
|
||
| // TODO(harryterkelsen): Use `FlutterViewManager.onViewsChanged` to manage | ||
| // the lifecycle of Rasterizers, | ||
| // https://github.com/flutter/flutter/issues/137073. | ||
| final Rasterizer rasterizer = | ||
| _getRasterizerForView(view as EngineFlutterView); | ||
|
|
||
| rasterizer.draw((scene as LayerScene).layerTree); | ||
| frameTimingsOnRasterFinish(); | ||
| } | ||
|
|
||
| final Map<EngineFlutterView, Rasterizer> _rasterizers = | ||
| <EngineFlutterView, Rasterizer>{}; | ||
|
|
||
| Rasterizer _getRasterizerForView(EngineFlutterView view) { | ||
| return _rasterizers.putIfAbsent(view, () { | ||
| return Rasterizer(view.dom.sceneHost); | ||
| }); | ||
| } | ||
|
|
||
| /// Returns the [Rasterizer] that has been created for the given [view]. | ||
| /// Used in tests. | ||
| Rasterizer debugGetRasterizerForView(EngineFlutterView view) { | ||
| return _getRasterizerForView(view); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this look in the map directly? Delegating to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No because the test which uses this needs to get a hold of the |
||
| } | ||
|
|
||
| /// Resets the state of the renderer. Used in tests. | ||
| void debugClear() { | ||
| for (final Rasterizer rasterizer in _rasterizers.values) { | ||
| rasterizer.renderCanvasFactory.debugClear(); | ||
| rasterizer.viewEmbedder.debugClear(); | ||
| } | ||
| } | ||
|
|
||
| @override | ||
| void clearFragmentProgramCache() { | ||
| _programs.clear(); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.