189 Commits

Author SHA1 Message Date
liyuqian
bc75dc5d85 Call drawPath without clip if possible (flutter/engine#5952)
It turns out that Skia is much slower at drawing paint inside a clipped
path than directly drawing that path. (Average frame time of 22ms vs
18ms in flutter_galary transition test.)
2018-08-07 14:47:32 -07:00
amirh
9d38d63147 Allow freezing a texture. (flutter/engine#5938)
This is needed to avoid jank when resizing an embedded Android view.
See
https://github.com/flutter/flutter/issues/19572#issuecomment-410400724
2018-08-07 14:43:19 -07:00
liyuqian
970df7c987 Call drawPaint instead of drawPath if there's clip (flutter/engine#5937)
If we want to avoid the bleeding edge artifact (flutter/flutter#18057 (comment)) using saveLayer, we have to call drawPaint instead of drawPath as anti-aliased drawPath will always have such artifacts.

This is discovered when I try to add golden tests for such bleeding artifacts using our new Clip enum. Here's the updated golden files: flutter/goldens@cb1fa8a?short_path=57b30ce#diff-57b30cea9b10b7ca689009854e12d70e
2018-08-03 17:00:00 -07:00
Chinmay Garde
3e5e79b737 Fix sundry Fuchsia build issues after the tonic/fxl migration. (flutter/engine#5920) 2018-08-01 13:29:45 -07:00
Chinmay Garde
6ab2c166fd Remove all dependencies on Garnet. (flutter/engine#5869) 2018-07-26 12:49:34 -07:00
Chinmay Garde
62289623fc Remove //flutter/glue and use FML directly. (flutter/engine#5862) 2018-07-25 13:20:48 -07:00
liyuqian
2c526e8068 Rename clip mode to clip behavior (flutter/engine#5853)
* Rename clip mode to clip behavior

So we're consistent across flutter/flutter and flutter/engine

* Clang format
2018-07-25 09:57:10 -07:00
Joshua Seaton
967a473c6d [fml][fxl] Migrate AutoResetWaitableEvent to fml version. (flutter/engine#5808)
Thanks Jason for the speedy review
2018-07-20 10:12:38 -07:00
liyuqian
9f3465f4c3 Add ClipMode to ClipPath/ClipRRect and PhysicalShape layers (flutter/engine#5647)
For flutter/flutter#18057
2018-07-13 12:38:16 -07:00
Jonah Williams
6eab9d08be Remove cullRect calculation on TransformLayers with a perspective transform. (flutter/engine#5693) 2018-07-09 12:52:10 -07:00
Adam Barth
10e5400c52 [fuchsia] Update gn label for fuchsia.ui.scenic (flutter/engine#5673)
The gn label for this target changed.
2018-07-03 21:08:28 -07:00
mikejurka
0eac86cbd8 [fuchsia] Update scenic lib path. (flutter/engine#5649) 2018-06-29 17:24:47 -07:00
mikejurka
c0caf150a3 [fuchsia] Rename scenic_lib => scenic (flutter/engine#5648)
TEST=Compiled and ran flutter app on Fuchsia, verified it rendered and responded to input.
2018-06-29 17:06:55 -07:00
liyuqian
a4a4fc0cd4 Improve perf overlay performance. (flutter/engine#5571)
1. Mark perf overlay path as volatile
2. Set sample_margin_width = 0 to get a bar graph instead of saw-tooth.

Previously, the perf overlay itself could be a significant performance
hit and that makes it difficult to profile flutter app.
2018-06-19 16:42:21 -07:00
liyuqian
fe69e3eea1 Call SkAutoCanvasRestore with doSave = true (flutter/engine#5432)
Although we do have a save before this SkAutoCanvasRestore so we
can theoretically send in doSave = false, it's safer to set doSave
to true to prevent future breakage.

As discussed with mtklein@google.com and reed@google.com, saving
canvas is very cheap in Skia so this should have no performance
impact. Skia is also considering remove doSave argument from
SkAutoCanvasRestore and always save the canvas.
2018-05-31 16:41:58 -07:00
cary-clark
937d250db6 call existing ostream operator for SkMatrix (flutter/engine#5427)
This permits removing the call to SkMatrix::toString(), which is deprecated.
2018-05-31 09:55:57 -04:00
liyuqian
949ece5d45 Remove unnecessary saveLayer (flutter/engine#5420)
saveLayer is slow so we should avoid it as much as possible. If
there are artifacts without saveLayer, then we should report that
to Skia for the fix instead of slowing the performance with
saveLayer.

This PQ makes average rasterizer time drop from 25ms to 18ms in
flutter_gallery transitions perf test on a Nexus 5X.

This partially fixes flutter/flutter#13736 .
We probably still need some work in the opacity layer to squize
all the performance improvements.
2018-05-30 12:50:12 -07:00
liyuqian
4537391c78 Use drawImage for picture layer cache (flutter/engine#5315)
Fixes
1. https://github.com/flutter/flutter/issues/12148
2. most part of https://github.com/flutter/flutter/issues/17731 except some tiny AA diffs.
2018-05-23 16:53:20 -07:00
P.Y. Laligand
a133efee8f [fuchsia] Use the real name for the GFX library... (flutter/engine#5346) 2018-05-23 12:09:23 -07:00
P.Y. Laligand
2d104dae40 [fuchsia] Updated references to the gfx FIDL library. (flutter/engine#5341) 2018-05-23 10:25:33 -07:00
cary-clark
0e82a0b583 remove Skia toString() use (flutter/engine#5326)
Skia toString() is not maintained; the debugger that used it has been replaced. 
Replace usage with equivalent implementation.
2018-05-21 09:04:51 -04:00
Todd Volkert
300f7fa815 Clear the raster cache result when bypassing raster cache. (flutter/engine#5300)
https://github.com/flutter/flutter/issues/17448
2018-05-17 23:50:07 -07:00
cary-clark
fc240c57ab rename obsolete SkColor.h macro (flutter/engine#5175)
change SkColorSetARGBInline to SkColorSetARGB. SkColorSetARGBInline is deprecated and will be deleted from Skia.
2018-05-04 13:44:44 -04:00
Chinmay Garde
602b9b7c33 Add disabled failing test for floating point errors on matrix decomposition. (flutter/engine#5076) 2018-04-24 16:02:38 -07:00
Chinmay Garde
aa8636c3fc Implement Scene::toImage for creating a raster image representation of a scene. (flutter/engine#5021) 2018-04-18 12:42:16 -07:00
Chinmay Garde
82c5c8feda Re-land "Support multiple shells in a single process. (#4932)" (flutter/engine#4998)
* Re-land "Support multiple shells in a single process. (#4932)"

This reverts commit a9dd1abd80f9c5148c74d606302171fa260365ca.
2018-04-13 13:48:15 -07:00
Vyacheslav Egorov
a9dd1abd80 Revert "Re-land "Support multiple shells in a single process. (#4932)" (#4977)" (flutter/engine#4981)
This reverts commit e27940623b550f50fece0740ea3d6e9cb259fdae.
2018-04-12 18:28:55 +02:00
Chinmay Garde
e27940623b Re-land "Support multiple shells in a single process. (#4932)" (flutter/engine#4977)
This reverts commit a1befb4f3090141d738fc2b801e5454d96047121.
2018-04-11 15:41:23 -07:00
Chinmay Garde
a1befb4f30 Revert "Support multiple shells in a single process. (#4932)" (flutter/engine#4964)
This reverts commit 077d29581c35a08a076c5aeb5186855975756b55.
2018-04-10 15:28:43 -07:00
Chinmay Garde
077d29581c Support multiple shells in a single process. (flutter/engine#4932)
* Support multiple shells in a single process.

The Flutter Engine currently works by initializing a singleton shell
instance. This shell has to be created on the platform thread. The shell
is responsible for creating the 3 main threads used by Flutter (UI, IO,
GPU) as well as initializing the Dart VM. The shell, references to task
runners of the main threads as well as all snapshots used for VM
initialization are stored in singleton objects. The Flutter shell only
creates the threads, rasterizers, contexts, etc. to fully support a
single Flutter application. Current support for multiple Flutter
applications is achieved by making multiple applications share the same
resources (via the platform views mechanism).

This scheme has the following limitations:

* The shell is a singleton and there is no way to tear it down. Once you
  run a Flutter application in a process, all resources managed by it
  will remain referenced till process termination.
* The threads on which the shell performs its operations are all
  singletons. These threads are never torn down and multiple Flutter
  applications (if present) have to compete with one another on these
  threads.
* Resources referenced by the Dart VM are leaked because the VM isn't
  shutdown even when there are no more Flutter views.
* The shell as a target does not compile on Fuchsia. The Fuchsia content
  handler uses specific dependencies of the shell to rebuild all the
  shell dependencies on its own. This leads to differences in frame
  scheduling, VM setup, service protocol endpoint setup, tracing, etc..
  Fuchsia is very much a second class citizen in this world.
* Since threads and message loops are managed by the engine, the engine
  has to know about threading and platform message loop interop on each
  supported platform.

Specific updates in this patch:

* The shell is no longer a singleton and the embedder holds the unique
  reference to the shell.
* Shell setup and teardown is deterministic.
* Threads are no longer managed by the shell. Instead, the shell is
  given a task runner configuration by the embedder.
* Since the shell does not own its threads, the embedder can control
  threads and the message loops operating on these threads. The shell is
  only given references to the task runners that execute tasks on these
  threads.
* The shell only needs task runner references. These references can be
  to the same task runner. So, if the embedder thinks that a particular
  Flutter application would not need all the threads, it can pass
  references to the same task runner. This effectively makes Flutter
  application run in single threaded mode. There are some places in the
  shell that make synchronous calls, these sites have been updated to
  ensure that they don’t deadlock.
* The test runner and the headless Dart code runner are now Flutter
  applications that are effectively single threaded (since they don’t
  have rendering concerns of big-boy Flutter application).
* The embedder has to guarantee that the threads and outlive the shell.
  It is easy for the embedder to make that guarantee because shell
  termination is deterministic.
* The embedder can create as many shell as it wants. Typically it
  creates a shell per Flutter application with its own task runner
  configuration. Most embedders obtain these task runners from threads
  dedicated to the shell. But, it is entirely possible that the embedder
  can obtain these task runners from a thread pool.
* There can only be one Dart VM in the process. The numerous shell
  interact with one another to manage the VM lifecycle. Once the last
  shell goes away, the VM does as well and hence all resources
  associated with the VM are collected.
* The shell as a target can now compile and run on Fuchsia. The current
  content handler has been removed from the Flutter engine source tree
  and a new implementation has been written that uses the new shell
  target.
* Isolate management has been significantly overhauled. There are no
  owning references to Dart isolates within the shell. The VM owns the
  only strong reference to the Dart isolate. The isolate that has window
  bindings is now called the root isolate. Child isolates can now be
  created from the root isolate and their bindings and thread
  configurations are now inherited from the root isolate.
* Terminating the shell terminates its root isolates as well as all the
  isolates spawned by this isolate. This is necessary be shell shutdown
  is deterministic and the embedder is free to collect the threads on
  which the isolates execute their tasks (and listen for mircrotasks
  flushes on).
* Launching the root isolate is now significantly overhauled. The shell
  side (non-owning) reference to an isolate is now a little state
  machine and illegal state transitions should be impossible (barring
  construction issues). This is the only way to manage Dart isolates in
  the shell (the shell does not use the C API is dart_api.h anymore).
* Once an isolate is launched, it must be prepared (and hence move to
  the ready phase) by associating a snapshot with the same. This
  snapshot can either be a precompiled snapshot, kernel snapshot, script
  snapshot or source file. Depending on the kind of data specified as a
  snapshot as well as the capabilities of the VM running in the process,
  isolate preparation can fail preparation with the right message.
* Asset management has been significantly overhauled. All asset
  resolution goes through an abstract asset resolver interface. An asset
  manager implements this interface and manages one or more child asset
  resolvers. These asset resolvers typically resolve assets from
  directories, ZIP files (legacy FLX assets if provided), APK bundles,
  FDIO namespaces, etc…
* Each launch of the shell requires a separate and fully configured
  asset resolver. This is necessary because launching isolates for the
  engine may require resolving snapshots as assets from the asset
  resolver. Asset resolvers can be shared by multiple launch instances
  in multiple shells and need to be thread safe.
* References to the command line object have been removed from the
  shell. Instead, the shell only takes a settings object that may be
  configured from the command line. This makes it easy for embedders and
  platforms that don’t have a command line (Fuchsia) to configure the
  shell. Consequently, there is only one spot where the various switches
  are read from the command line (by the embedder and not the shell) to
  form the settings object.
* All platform now respect the log tag (this was done only by Android
  till now) and each shell instance have its own log tag. This makes
  logs from multiple Flutter application in the same process (mainly
  Fuchsia) more easily decipherable.
* The per shell IO task runner now has a new component that is
  unfortunately named the IOManager. This component manages the IO
  GrContext (used for asynchronous texture uploads) that cooperates with
  the GrContext on the GPU task runner associated with the shell. The
  IOManager is also responsible for flushing tasks that collect Skia
  objects that reference GPU resources during deterministic shell
  shutdown.
* The embedder now has to be careful to only enable Blink on a single
  instance of the shell. Launching the legacy text layout and rendering
  engine multiple times is will trip assertions. The entirety of this
  runtime has been separated out into a separate object and can be
  removed in one go when the migration to libtxt is complete.
* There is a new test target for the various C++ objects that the shell
  uses to interact with the Dart VM (the shell no longer use the C API
  in dart_api.h). This allows engine developers to test VM/Isolate
  initialization and teardown without having the setup a full shell
  instance.
* There is a new test target for the testing a single shell instances
  without having to configure and launch an entire VM and associated
  root isolate.
* Mac, Linux & Windows used to have different target that created the
  flutter_tester referenced by the tool. This has now been converted
  into a single target that compiles on all platforms.
* WeakPointers vended by the fml::WeakPtrFactory(notice the difference
  between the same class in the fxl namespace) add threading checks on
  each use. This is enabled by getting rid of the “re-origination”
  feature of the WeakPtrFactory in the fxl namespace. The side effect of
  this is that all non-thread safe components have to be created, used
  and destroyed on the same thread. Numerous thread safety issues were
  caught by this extra assertion and have now been fixed.
  * Glossary of components that are only safe on a specific thread (and
    have the fml variants of the WeakPtrFactory):
    * Platform Thread: Shell
    * UI Thread: Engine, RuntimeDelegate, DartIsolate, Animator
    * GPU Thread: Rasterizer, Surface
    * IO Thread: IOManager

This patch was reviewed in smaller chunks in the following pull
requests. All comments from the pulls requests has been incorporated
into this patch:

* flutter/assets: https://github.com/flutter/engine/pull/4829
* flutter/common: https://github.com/flutter/engine/pull/4830
* flutter/content_handler: https://github.com/flutter/engine/pull/4831
* flutter/flow: https://github.com/flutter/engine/pull/4832
* flutter/fml: https://github.com/flutter/engine/pull/4833
* flutter/lib/snapshot: https://github.com/flutter/engine/pull/4834
* flutter/lib/ui: https://github.com/flutter/engine/pull/4835
* flutter/runtime: https://github.com/flutter/engine/pull/4836
* flutter/shell: https://github.com/flutter/engine/pull/4837
* flutter/synchronization: https://github.com/flutter/engine/pull/4838
* flutter/testing: https://github.com/flutter/engine/pull/4839
2018-04-10 14:57:02 -07:00
Brian Osman
959fc0357a Remove use of SkRect::MakeLargest (flutter/engine#4918)
This API is being hidden for safety reasons. Instead, use a locally
defined rect that's slightly smaller (so operations don't overflow).
2018-04-02 14:36:15 -04:00
Jeff Brown
9e40f3e2d3 Port flutter content handler to FIDL2. (flutter/engine#4903) 2018-03-29 21:49:35 -07:00
Jonah Williams
c407876859 Allow shadows to be colored when physical layer is drawn by engine (flutter/engine#4812)
* pass shadow_color from dart:ui to physical layer

* default shadow color to SK_ColorBLACK

* add doc comments to pushPhysicalShape
2018-03-19 14:16:17 -07:00
mikejurka
16892af75c [fuchsia] Updated scenic fidl prefix (flutter/engine#4798) 2018-03-16 14:13:19 -07:00
mikejurka
a282e52798 [scenic] Rename mozart->scenic. (flutter/engine#4792) 2018-03-14 20:43:04 -07:00
Petr Hosek
84293f06da Migrate all uses of gtest to googletest (flutter/engine#4755)
gtest is an old version that predates the googletest and googlemock
merger, all tests should be using the newer googletest that's being
kept in sync with the upstream version.
2018-03-14 11:32:34 -07:00
Chinmay Garde
457de9145f Make the color filter layer use the paint specified by the framework. (flutter/engine#4782) 2018-03-13 15:44:13 -07:00
Adam Barth
9cacbff47a Switch from fxl::Mutex to std::mutex (flutter/engine#4764)
We're going to remove fxl::Mutex soon.
2018-03-09 11:19:23 -08:00
Alexander Aprelev
5ecac5ba92 Revert "Migrate all uses of gtest to googletest (#4728)" (flutter/engine#4750)
* Merge

* Update license hash
2018-03-06 09:46:24 -08:00
Petr Hosek
93d28a103c Migrate all uses of gtest to googletest (flutter/engine#4728)
gtest is an old version that predates the googletest and googlemock
merger, all tests should be using the newer googletest that's being
kept in sync with the upstream version.
2018-03-06 01:06:32 -08:00
Jim Van Verth
9673d1e3e5 Update to latest SkShadowUtils::DrawShadow() (flutter/engine#4705) 2018-02-27 12:42:23 -05:00
xster
4c986b60e2 Relabel the performance overlay graphs (flutter/engine#4698) 2018-02-22 15:01:18 -08:00
Devon Carew
d9fcfb35c1 add padding around the perf overlay (flutter/engine#4638) 2018-02-06 07:18:45 -08:00
P.Y. Laligand
996feda91d Adjust to thinner Fuchsia sysroot. (flutter/engine#4624) 2018-02-01 13:33:22 -08:00
Brian Osman
24c68f8454 Include SkBitmap and SkPaint (flutter/engine#4582)
Skia is trimming some of these transitive includes
2018-01-23 16:12:43 -05:00
amirh
b86da443de Explicitly check if the shape layer is an oval. (flutter/engine#4577)
isRRect returns false for RRects that are oval.

Fixes flutter/flutter#14186
2018-01-22 12:15:24 -08:00
amirh
ac2c85c69b Update comment on Scenic shapes following feedback from schwa423@ (flutter/engine#4563) 2018-01-17 14:39:40 -08:00
amirh
9ee5ab1d8b Fallback to compose shapes as their bounding rectangles. (flutter/engine#4553)
Scenic doesn't currently support arbitrary shaped frames.
2018-01-16 18:20:18 -08:00
amirh
af26adb128 Revive always using SkPath for physical models (flutter/engine#4537) 2018-01-11 15:11:00 -08:00
amirh
fcfe94380f Revert "Delete the SkPath/SkRRect code duplication in for physical model layers. (#4519)" (flutter/engine#4527)
This reverts commit 0847830c7e3e2abff050596f911f77878b7a3c96.
2018-01-08 19:25:56 -08:00