330 Commits

Author SHA1 Message Date
Kaushik Iska
f02279849e
Do not Prepare raster cache if view_embedder is present (#11300)
This is a perf win because we do not use the cache in Paint anyways.
RasterCache <-> PlatformViews interaction will be improved by:
https://github.com/flutter/flutter/issues/38903
2019-08-20 14:38:45 -07:00
liyuqian
adb4659149
Trace RasterCacheResult::Draw (#11004)
Fixes https://github.com/flutter/flutter/issues/37988
2019-08-14 16:13:49 -07:00
Chinmay Garde
e8f954409d
Allow embedder controlled composition of Flutter layers. (#10195)
This patch allows embedders to split the Flutter layer tree into multiple
chunks. These chunks are meant to be composed one on top of another. This gives
embedders a chance to interleave their own contents between these chunks.

The Flutter embedder API already provides hooks for the specification of
textures for the Flutter engine to compose within its own hierarchy (for camera
feeds, video, etc..). However, not all embedders can render the contents of such
sources into textures the Flutter engine can accept. Moreover, this composition
model may have overheads that are non-trivial for certain use cases. In such
cases, the embedder may choose to specify multiple render target for Flutter to
render into instead of just one.

The use of this API allows embedders to perform composition very similar to the
iOS embedder. This composition model is used on that platform for the embedding
of UIKit view such and web view and map views within the Flutter hierarchy.
However, do note that iOS also has threading configurations that are currently
not available to custom embedders.

The embedder API updates in this patch are ABI stable and existing embedders
will continue to work are normal. For embedders that want to enable this
composition mode, the API is designed to make it easy to opt into the same in an
incremental manner.

Rendering of contents into the “root” rendering surface remains unchanged.
However, now the application can push “platform views” via a scene builder.
These platform views need to handled by a FlutterCompositor specified in a new
field at the end of the FlutterProjectArgs struct.

When a new platform view in introduced within the layer tree, the compositor
will ask the embedder to create a new render target for that platform view.
Render targets can currently be OpenGL framebuffers, OpenGL textures or software
buffers. The type of the render target returned by the embedder must be
compatible with the root render surface. That is, if the root render surface is
an OpenGL framebuffer, the render target for each platform view must either be a
texture or a framebuffer in the same OpenGL context. New render target types as
well as root renderers for newer APIs like Metal & Vulkan can and will be added
in the future. The addition of these APIs will be done in an ABI & API stable
manner.

As Flutter renders frames, it gives the embedder a callback with information
about the position of the various platform views in the effective hierarchy.
The embedder is then meant to put the contents of the render targets that it
setup and had previously given to the engine onto the screen (of course
interleaving the contents of the platform views).

Unit-tests have been added that test not only the structure and properties of
layer hierarchy given to the compositor, but also the contents of the texels
rendered by a test compositor using both the OpenGL and software rendering
backends.

Fixes b/132812775
Fixes flutter/flutter#35410
2019-08-13 14:53:19 -07:00
Kaushik Iska
971a639151
Allow for dynamic thread merging on IOS for embedded view mutations (#9819)
After pre-roll we know if there have been any mutations made to the IOS embedded UIViews. If there are any mutations and the thread configuration is such chat the mutations will be committed on an illegal thread (GPU thread), we merge the threads and keep them merged until the lease expires. The lease is currently set to expire after 10 frames of no mutations. If there are any mutations in the interim we extend the lease.

TaskRunnerMerger will ultimately be responsible for enforcing the correct thread configurations.

This configuration will be inactive even after this change since still use the same thread when we create the iOS engine. That is slated to change in the coming PRs.
2019-08-12 12:32:38 -07:00
cfontas
58f4f27a4e change add part to add child (#10787) 2019-08-09 12:18:44 -07:00
Kaushik Iska
dc559064f7
Revert "Remove one last final call to AddPart()" (#10440) 2019-08-02 09:18:17 -07:00
cfontas
c67a36cbbe Remove one last final call to AddPart() (#10273)
* Remove one last final call to AddPart()

* fix merge conflict

* fix how i merged

* remove add part again

* remove pointer syntax

* fix formatting
2019-07-31 20:05:00 -07:00
David Worsham
a29ef66013
[fuchsia] Remove extraneous ShapeNodes (#10150)
Test: Ran test programs on Fuchsia and dumped Scenic scene graph using
`fx shell cat /hub/c/scenic.cmx/*/out/debug/dump-scenes`
Inspected scene graph to confirm removal of ShapeNodes.
FL-284 #done
2019-07-31 02:22:01 -07:00
cfontas
f8d122bfca Remove Dead Scenic Clipping Code Path. (#10242)
Scenic has now fully transitioned to clipping by adding lists
of planes to Nodes; the old approach of adding a ShapeNode
"part" is now a no-op, and is safe to remove.
2019-07-30 14:19:32 -07:00
Dan Field
56885f79b8
Let pushColorFilter accept all types of ColorFilters (#9641) 2019-07-10 12:06:58 -07:00
Chris Yang
802bd1518b
iOS platform view opacity (#9667) 2019-07-08 16:07:39 -07:00
liyuqian
eb89d9d42c
Explain why OpacityLayer has an offset field (#9713)
According to the request by Amir and Chris.
2019-07-08 15:02:18 -07:00
Kaushik Iska
7f828dd3e3
Raster now returns an enum rather than boolean (#9661)
This is part of a bigger change that will facilitate us
to act on this `RasterStatus`. The specific case is where
after pre-roll we might decide to want to merge the threads
and re-submit the frame -- `RasterStatus::kResubmit` can then
let us achieve this result.
2019-07-03 19:53:01 -07:00
Chris Yang
cea2c3617f
Mutators Stack refactoring (#9663)
Rename methods in the MutatorsStack to Pascal case to match standard cpp style
Refactor the operator== for Mutator class
2019-07-03 11:18:14 -07:00
Kaushik Iska
791143f172
ExternalViewEmbedder can CancelFrame after pre-roll (#9660)
* ExternalViewEmbedder can CancelFrame after pre-roll

- Resets the state so next pre-roll can be successful.
- Commit any pending `CATransaction` so we don't create
  nested transactions.

* Update flow/embedded_views.h
2019-07-03 08:38:19 -07:00
Kaushik Iska
d637f291a9
External view embedder can tell if embedded views have mutated (#9653)
* refactoring to move the mutator stack handling to preroll

* more review fixes

* Add support for external view embedded to know if it has changed

* remove the need to reset

* address comments

* Rename to HasPendingViewOperations
2019-07-03 07:28:53 -07:00
Chris Yang
8306ee68c7 Move the mutators stack handling to preroll (#9651)
* refactoring to move the mutator stack handling to preroll

* more review fixes
2019-07-02 16:35:47 -07:00
Chris Yang
8deeb77f05
make EmbeddedViewParams a unique ptr (#9640) 2019-07-02 13:27:12 -07:00
Chris Yang
a9ee687ac9
iOS PlatformView clip path (#9478) 2019-07-02 10:56:59 -07:00
Chinmay Garde
609a980608
Fix uninitialized variables and put tests in flutter namespace. (#9613)
Also enabled the tests previously disabled due to flakiness caused by these
uninitialized variables.

Fixes https://github.com/flutter/flutter/issues/35338
2019-06-29 21:05:42 -07:00
Chris Yang
8d054008a8
disable mysterious failing tests (#9608) 2019-06-29 12:38:49 -07:00
Chris Yang
aa9b3a180a
Reland "IOS Platform view transform/clipping (#9075)" and fix the breakage. (#9483)
* Revert "Revert "IOS Platform view transform/clipping (#9075)" (#9480)"

This reverts commit 00d929f7f6088375b006746718a65b84678d01c0.

* fix fuschia buid
2019-06-25 15:29:47 -07:00
Chris Bracken
00d929f7f6
Revert "IOS Platform view transform/clipping (#9075)" (#9480)
This reverts commit ebb5b909fbb10dad2275acd4fc8ec1d9744a0bf6.

Seeing the following breakage on host build:
```
../../flutter/flow/scene_update_context.cc:205:36: error: non-const lvalue reference to type 'flutter::MutatorsStack' cannot bind to a value of unrelated type 'const flutter::Stopwatch'
                                   frame.context().raster_time(),
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../flutter/flow/scene_update_context.cc:207:36: error: no viable conversion from 'flutter::TextureRegistry' to 'const flutter::Stopwatch'
                                   frame.context().texture_registry(),
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../flutter/flow/instrumentation.h:55:32: note: candidate constructor not viable: no known conversion from 'flutter::TextureRegistry' to 'const flutter::Stopwatch &' for 1st argument
  FML_DISALLOW_COPY_AND_ASSIGN(Stopwatch);
                               ^
../../flutter/fml/macros.h:28:3: note: expanded from macro 'FML_DISALLOW_COPY_AND_ASSIGN'
  TypeName(const TypeName&) = delete;          \
  ^
../../flutter/flow/scene_update_context.cc:208:36: error: non-const lvalue reference to type 'flutter::TextureRegistry' cannot bind to a temporary of type 'flutter::RasterCache *'
                                   &frame.context().raster_cache(),
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../flutter/flow/scene_update_context.cc:209:36: error: cannot initialize a member subobject of type 'const flutter::RasterCache *' with an rvalue of type 'bool'
                                   false};
                                   ^~~~~
```
2019-06-25 10:48:37 -07:00
Chris Yang
ebb5b909fb
IOS Platform view transform/clipping (#9075) 2019-06-25 09:33:50 -07:00
Michael Klimushyn
950d4813b5
Clamp when overflowing z bounds (#9402) 2019-06-20 18:20:35 -07:00
Chinmay Garde
96a1a843cb
Replace lock_guard with scoped_lock and use class template argument deduction. (#9338) 2019-06-17 10:08:45 -07:00
David Worsham
0df44e9e07
[scene_host] Expose Opacity and remove ExportNode (#9297)
SCN-947 #comment
SCN-1291 #comment
2019-06-13 10:16:21 -07:00
liyuqian
f1d821d8fd
Set identity instead of crash in opt build (#9262)
According to https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#expectations-around-potential-crashes-in-the-engine

This should address https://github.com/flutter/flutter/issues/31650#issuecomment-494935507

We'll instead use `FML_LOG(ERROR)` to report errors to our CI tests. See https://github.com/flutter/flutter/issues/34194
2019-06-13 09:35:54 -07:00
Zachary Anderson
0a2e28d797
Revert tracing changes (#9296)
* Revert "[fuchsia] Fix alignment of Fuchsia/non-Fuchsia tracing (#9289)"

This reverts commit f80ac5f571479053b134e60bca77603269b2ce2a.

* Revert "Align fuchsia and non-fuchsia tracing (#9199)"

This reverts commit 78265484623037c6544dfd5380367bca29fa27b0.
2019-06-12 10:25:49 -07:00
liyuqian
b622d43c39
Make flow layers' attributes immutable (#9176)
For https://github.com/flutter/flutter/issues/33807

We still need to make layers' children immutable for full immutability.
That will require us to change the SceneBuilder API to build the layer
bottom up instead of top down (post-order traversal instead of pre-order
traversal).
2019-06-10 13:09:37 -07:00
liyuqian
9f088c65ee
Add onReportTimings and FrameRasterizedCallback API (#8983)
Using it, a Flutter app can monitor missing frames in the release mode, and a custom Flutter runner (e.g., Fuchsia) can add a custom FrameRasterizedCallback.

Related issues:
https://github.com/flutter/flutter/issues/26154
https://github.com/flutter/flutter/issues/31444
https://github.com/flutter/flutter/issues/32447

Need review as soon as possible so we can merge this before the end of May to catch the milestone.

Tests added:
* NoNeedToReportTimingsByDefault
* NeedsReportTimingsIsSetWithCallback
* ReportTimingsIsCalled
* FrameRasterizedCallbackIsCalled
* FrameTimingSetsAndGetsProperly
* onReportTimings preserves callback zone
* FrameTiming.toString has the correct format

This will need a manual engine roll as the TestWindow defined in the framework needs to implement onReportTimings.
2019-06-06 10:42:48 -07:00
Dan Field
7826548462
Align fuchsia and non-fuchsia tracing (#9199) 2019-06-05 15:14:27 -07:00
liyuqian
fd4368c851
Skip golden tests on non-Linux OSes (#9198) 2019-06-05 14:10:02 -07:00
Chinmay Garde
7746e2e7f9
Compile the physical_shape_layer_unittests.cc TU. (#9187)
This was incorrectly removed by my as I was reworking the GN rules for Fuchsia https://github.com/flutter/engine/pull/8869/files#diff-b6056f6ec9dff658c81f7711f6865e5eL739
2019-06-04 14:51:57 -07:00
Chris Yang
2fcd4e799b
Do nothing if the params didn't change when compositing iOS platform views. (#8999) 2019-06-03 13:08:29 -07:00
Chinmay Garde
37b367e4d2
Allow specifying both Dart and non-Dart fixtures in engine unit-tests. (#9113)
* Allow specifying both Dart and non-Dart fixtures in engine unittests.

This fixes numerous issues in the way in which fixtures were managed
in the engine unit-tests.

* Instead of only being able to specify Dart fixtures, unit-tests may specify
  non-Dart fixtures as well. These are simply copied over to the fixtures
  directory known to the unit-test at runtime.
* An issue where numerous Dart files could be given to the kernel snapshotter
  has been addressed. It was anticipated that such a (legal) invocation to the
  kernel snapshotter would produce a snapshot with the contents of all the Dart
  files added to the root library. This is incorrect and the behavior in this
  case is undefined.
* Dart files referenced by the main Dart file are correctly tracked via a
  depfile.
* The snapshotter arguments have been cleaned up to get rid of unused
  arguments (`—strong`) and  the use of the VM product mode argument has been
  corrected to no longer depend on the Flutter product mode.
2019-05-28 19:11:47 -07:00
liyuqian
d0dc9b94d4
Rename frame_time and engine_time (#8952)
At a quick glance, one could easily think of the "engine_time" as the
GPU thread time and the "frame_time" as the UI thread time because the
GPU thread time is mainly spent on the engine while the UI thread time
is mainly spent on the Dart framework to generate the frame.

But it's actually the other way. The "engine_time" is UI thread time and
the "frame_time" is the GPU thread time.

To avoid the confusion, rename them to "ui_time" and "raster_time"
respectively. I avoided the "gpu_time" because the rasterization may be
purely on a CPU backed software Skia backend.
2019-05-14 14:29:27 -07:00
bungeman
f4d23ef694 Replace Skia font macros with enums. (#8920)
This mechanically replaces kXXX_SkTextEncoding with SkTextEncoding::kXXX
and kXXX_SkFontHinting with SkFontHinting::kXXX. This will allow Skia to
remove these old macro constants and get everyone on the new enums.
2019-05-13 11:11:49 -07:00
Chinmay Garde
f6e6d39860
Wire up Fuchsia SDK related updated for shell dependencies. #8869
This does not actually import the runners into the engine. It only sets up the targets so they need no modifications are necessary when the migration is done. The engine has been verified to build in both buildroots.
2019-05-06 18:01:59 -07:00
liyuqian
50de4692a5
Check the matrix in pushTransform (#8758)
Fixes flutter/flutter#31650
2019-04-26 14:09:53 -07:00
David Worsham
a56aa95e80
[scenic] Purge references to Mozart (#8712)
We also rename all MZ-* bugs to SCN-*.

SCN-580 #comment
2019-04-24 12:26:25 -07:00
liyuqian
7c8ec376ff
Document that OpacityLayer's children are nonempty (#8707)
See https://github.com/flutter/flutter/issues/31517
2019-04-23 15:02:57 -07:00
Matthew Dempsky
b0cbce4175 Replace ThreadLocal with ThreadLocalUniquePtr<T> (#8659)
Fixes https://github.com/flutter/flutter/issues/31292.
2019-04-19 17:33:46 -07:00
liyuqian
d79eb2857d
Generate layer unique id for raster cache key (#8637)
The raw pointer isn't a reliable id as the allocator can reuse an
address that's just been released for another layer.

This will fix Fuchsia bug FL-216.

This problem was not affecting non-Fuchsia Flutter probably because
non-Fuchsia Flutter purges the raster cache key much more frequently so
we won't see a key collision. In Fuchsia, as the key has to wait for the
Vulkan surface to render asynchronously, this suddenly becomes an issue.
2019-04-18 14:14:06 -07:00
liyuqian
edef8bb8b3
Reland elevation test (#8633)
Reland "Add a unit test for PhysicalShapeLayer (#8616)"

This reverts commit 91b71070f55ffc38c432babc7d9bb68ac2720d8d.

The only change is the namespace.
2019-04-18 10:56:24 -07:00
Chinmay Garde
91b71070f5
Revert "Add a unit test for PhysicalShapeLayer (#8616)" (#8627)
This reverts commit 8b667b0178f135411ad72d7e5b3304cc46ff7dcf.
2019-04-17 17:47:58 -07:00
liyuqian
8b667b0178
Add a unit test for PhysicalShapeLayer (#8616)
An unnecessary PrerollContext copy is also removed. The added unit test will catch the error if we forget to subtract the elevation after the copy removal.

This change has been tested with the framework (`flutter test --local-engine=host_debug_unopt`).
2019-04-17 17:34:11 -07:00
liyuqian
8ff631f3df
Rename flow namespace to flutter (#8615)
This follows our namespace change from shell to flutter: https://github.com/flutter/engine/pull/8520.
2019-04-17 14:38:45 -07:00
bungeman
c5d1ba916c Remove call to SkFont::setLinearMetrics (#8612)
This particular call doesn't do anything since the default is false
anyway. In addition Skia is looking to remove this flag since setting it
to true is now synonymous with setting the hinting to none.
2019-04-17 15:13:19 -04:00
Zachary Anderson
dd9dcaf9a5
[fuchsia] Fix SceneUpdateContext for new PaintContext field (#8608) 2019-04-17 09:58:58 -07:00