915 Commits

Author SHA1 Message Date
Amir Hardon
387ca2ef86
Add an internal_nodes_canvas to PaintContext. (#6728)
When we visit a PlatformViewLayer during the paint traversal it replaces
the PaintContext's canvas with a new one that is painted ontop of the
embedded view.
We need to make sure that operations applied by parent layers are also
applied to the new canvas.

To achieve this we collect all the canvases in a SkNWayCanvas and use
this canvas by non leaf nodes. Leaf nodes still paint only to the "current"
canvas.

This PR moves the overlay canvas creation from the paint phase to the
preroll phase, collects them into a SkNWayCanvas and set it in
PaintContext.

To keep this PR focused, I only used the internal_nodes_canvas in the
tranform_layer.
Will followup with a PR that changes all internal layers to use the
internal_nodes_canvas.
2018-11-08 09:31:40 -08:00
Dan Field
09ff6dc479
avoid overreleasing FlutterView (#6791) 2018-11-07 21:19:14 -08:00
Mehmet Fidanboylu
94dd7165ef
Skia Cleanup (#6786) 2018-11-07 15:29:52 -08:00
Michael Goderbauer
70a1106b50
Unify copyright lines (#6757) 2018-11-07 12:24:35 -08:00
Todd Volkert
4cdddbac42
Fix String comparison as if Java were Dart. (#6781)
This also removes unused imports and sorts imports correctly
2018-11-07 09:59:51 -08:00
Dan Field
177e043b53
fix setInitialRoute (#6774)
* fix setInitialRoute
2018-11-06 17:15:11 -08:00
Amir Hardon
5006ce5748
fix type in embedded views preview flag name (#6767) 2018-11-06 10:35:01 -08:00
Amir Hardon
fa4c01ee6a
Add an Info.plist flag to enable the embedded iOS views preview. (#6756)
When the flag is true, we currently use a single thread configuration,
and disabled the raster cache for opacity layers.

The flag's name is 'io.flutter_embedded_views_preview'.
2018-11-05 20:08:25 -08:00
Amir Hardon
124f20f404
Clear the on-screen surface every frame. (#6753)
We are currently clearing the offscreen surface before rasterizing, but
as we draw the image snapshot of the offscreen surface into the onscreen
surface transparent pixels are blended with the current contents of the onscreen surface instead of replacing them. This is
particularly noticeable when embedding platform views.
2018-11-05 15:08:07 -08:00
Stanislav Baranov
b5758d0d38
Propagate positions of secondary pointers in UP events on Android (#6716) 2018-11-02 10:51:35 -07:00
Amir Hardon
9e1f546a85
Add an overlay surface on top of embedded UIViews. (#6726)
The overlay surfaces are going to be the same IOSSurface implementation
with the platform views controller set to null (so these are surfaces
that don't support embedding platform views to them).

  * Adds a FlutterOverlayView which is a UIView that's showing an
    overlay surface.
  * Creates an overlay surface for each embedded UIView (done in
    FlutterPlatformViewsController).
  * Changes CompositeEmbeddedView to return a new canvas.
  * Makes the PlatformViewLayer replace the PaintContext's canvas with
    the canvas for the overlay view.
  * Changed canvas in PaintContext to be a pointer so it can be changed.

TBD in following PRs:
  * Copy the current canvas state when replacing a canvas in PaintContext.
  * Make FlutterOverlayView work with a GL backend (currently it only
    works with software rendering)
2018-11-01 17:45:16 -07:00
Amir Hardon
c79faed71c
Decode UIView's creation parameters and pass them to the view factory. (#6715) 2018-10-31 16:15:42 -07:00
Amir Hardon
0ec3b7d437
Apply changes to the embedded UIView tree when presenting a frame (#6712)
Also tracks the order of embedded views from frame to frame, and only
removes and reattaches subviews if there is a structural change to the
UIView hierarchy.
2018-10-31 14:56:59 -07:00
Amir Hardon
92944f72fb
Move FlutterPlatformViewsController into FlutterEngine. (#6709)
This PR breaks PlatformViewsController's construction dependency on FlutterView,
which allows making FlutterEngine its owner instead of
FlutterViewController.

Also renamed the FlutterScreenshotDelegate to FlutterViewEngineDelegate
which is FlutterView's delegate to the engine, and expanded it to
provide a view embedder.
2018-10-31 13:02:44 -07:00
Amir Hardon
059876ea9a
Delay embedded UIViews touch events until the framework says so. (#6665)
This allows the framework to decide whether and when a touch event
sequence arrives to the embedded view. Which gives the framework the
ability to manage hit testing and gesture disambiguation for embedded
UIViews.

We achieve this by wrapping each embedded UIView with another UIView that has
a custom UIGestureRecognizer that delays touch events from being
delivered, and another UIGestureRecognizer that makes sure to let
Flutter know of events that are hit tested to the embedded view.
2018-10-30 20:16:56 -07:00
Dan Field
d8672baaa2
Ensure Simulator publishes mDNS records (#6696)
* Ensure Simulator publishes mDNS records on loopback interface.
2018-10-30 18:04:18 -07:00
Dan Field
91a019cfd3 Fix popSystemNavigator (#6691) 2018-10-29 16:36:28 -07:00
Gary Qian
3b17cfb684
Flutter tester default locales (#6689) 2018-10-29 14:06:04 -07:00
Amir Hardon
cc686d7aeb
Don't populate the external view embedder in PaintContext. (#6686)
The platform views embedding is still WIP, and until we dynamically
merge the gpu and platform threads based on the presence of an embedded
view in the scene fetching the view embedder is not thread safe.

This PR essentially disables iOS platform views embedding, we will
re-enable once dynamic thread merging is supported.
2018-10-29 10:38:04 -07:00
Mehmet Fidanboylu
a1d7cad70c
Fix inconsistent include syntax (#6680) 2018-10-28 11:40:26 -07:00
Chinmay Garde
ba8f6aa71c
Handle Windows headers defining ERROR to 0 in log levels. (#6677) 2018-10-26 16:47:14 -07:00
Dan Field
55e12993a0
Update FlutterPlugin.h docs, suppress warning for older API (#6672)
* Update FlutterPlugin.h docs, suppress warning for older API
2018-10-26 14:54:33 -07:00
Amir Hardon
f7970048dd
Attach and position embedded UIVIews (#6614) 2018-10-26 14:45:17 -07:00
Amir Hardon
df85722fa0
Plumb the iOS PlatformViewsController into flow. (#6603)
For flow to manipulate the embedded UIViews during the paint traversal
it needs some hook in PaintContext.
This PR introduces a ViewEmbeder interface that is implemented by the
iOS PlatformViewsController and plumbs it into PaintContext.

The ViewEmbedder interface is mainly a place holder at this point, as
this PR is focused on just the plumbing.
2018-10-26 14:26:59 -07:00
Dan Field
2bfb893cf3
iOS Embedding Refactor (#6447)
* Create FlutterEngine to manage a Shell to support maintaining execution state across instances of FlutterViewControllers
* Refactor PlatformViewIOS to support adding or removing a FlutterViewController dynamically
* Refactor FlutterDartHeadlessCodeRunner to implement FlutterEngine
* Refactor FlutterViewController to accept a FlutterEngine at initialization or to create one for backwards compatibility; any Shell related responsibilities are now passed through to the Engine instance
* Remove FlutterNavigationController (unused)
* Update all public Objective C doc comments to be consistent and formatable
* Add public documentation to all public headers
2018-10-26 13:00:12 -07:00
Stanislav Baranov
dd791f36ac
Propagate pointer size from Android MotionEvent (#6662) 2018-10-26 09:39:10 -07:00
Jonah Williams
cf75289b68
TextField is only a live region when it has input focus (#6649) 2018-10-25 08:37:49 -07:00
Amir Hardon
9669b70e17
Add an iOS PlatformViewsController for creating/disposing UIViews. (#6569)
Adds a FlutterPlatformViewFactory protocol - a simple factory protocol to be implemented by plugins
  that exposes a UIView for embedding in Flutter apps.
* Adds a FlutterPlatformView protocol, which is used to associate a
  dispose callback with a `UIView` created by a FlutterPlatformViewFactory.
* Exposes a registerViewFactory method in FlutterPluginRegistrar.
* Implements the `flutter/platform_views` system channel on iOS, allowing
  Dart code to ask for creation/destruction of UIViews.
2018-10-24 15:07:05 -07:00
Dan Field
6c2477bd29
fix setter for viewOpaque (#6653) 2018-10-24 12:31:44 -07:00
Chinmay Garde
e1e60933b2
Realize kernel asset mappings on a worker thread if one is available. (#6648) 2018-10-24 11:33:46 -07:00
Chinmay Garde
e78f86e011
Fix mac builds. Only Linux and Windows require default GL proc resolvers. (#6641) 2018-10-23 10:46:14 -07:00
James Clarke
52e48ab84a Fix Windows embedding. Appears that #6523 or #6525 introduced a bug for embedder scenarios causing the window native library to be incorrectly initialized and thus incapable of correctly resolving GL functions. This change fixes that. (#6624) 2018-10-23 09:47:53 -07:00
Dan Field
427915e2fb
Allow FlutterViewController to specify whether its FlutterView is opaque (#6570)
* Allow FlutterViewController to specify whether its FlutterView is opaque
2018-10-22 19:53:04 -07:00
Chinmay Garde
20c805c973
Ensure that Scene::toImage renders texture backed images. (#6636)
TL;DR: Offscreen surface is created on the render thread and device to host
transfer performed there before task completion on the UI thread.

While attempting to snapshot layer trees, the engine was attempting to use the
IO thread context. The reasoning was that this would be safe to do because any
textures uploaded to the GPU as a result of async texture upload would have
originated from this context and hence the handles would be valid in either
context. As it turns out, while the handles are valid, Skia does not support
this use-case because cross-context images transfer ownership of the image from
one context to another. So, when we made the hop from the UI thread to the IO
thread (for snapshotting), if either the UI or GPU threads released the last
reference to the texture backed image, the image would be invalid. This led to
such images being absent from the layer tree snapshot.

Simply referencing the images as they are being used on the IO thread is not
sufficient because accessing images on one context after their ownership has
already been transferred to another is not safe behavior (from Skia's
perspective, the handles are still valid in the sharegroup).

To work around these issues, it was decided that an offscreen render target
would be created on the render thread. The color attachment of this render
target could then be transferred as a cross context image to the IO thread for
the device to host tranfer.

Again, this is currently not quite possible because the only way to create
cross context images is from encoded data. Till Skia exposes the functionality
to create cross-context images from textures in one context, we do a device to
host transfer on the GPU thread. The side effect of this is that this is now
part of the frame workload (image compression, which dominate the wall time,
is still done of the IO thread).

A minor side effect of this patch is that the GPU latch needs to be waited on
before the UI thread tasks can be completed before shell initialization.
2018-10-22 17:40:24 -07:00
Matthew Smith
edfe02481a 13771 - iOS dictation bug (#6607)
According to the iOS docs, implementing
`- (id)insertDictationResultPlaceholder`

```Implementation of this method is optional but can be done when you want to provide a specific rectangle for the placeholder animation while the dictation results are being processed. ```

If you do not implement this method, UIKit will insert a default placeholder of 10 whitespace characters. By overriding this, no placeholder text will be inserted. If you implement the `insertDictationResultPlaceholder`, you must implement
`- (void)removeDictationResultPlaceholder:(id)placeholder willInsertResult:(BOOL)willInsertResult`
2018-10-22 10:28:39 -07:00
Gary Qian
8cb3965a3e
Properly gate android API < 21 and remove extraneous data array. (#6619) 2018-10-19 15:01:43 -07:00
Chinmay Garde
739d66eeb3
Don't attempt to build any platform target on Fuchsia. (#6617) 2018-10-19 14:20:31 -07:00
Gary Qian
09dcc3d5ee
Gate locale.getScript() behind version check for android API < 21 (#6592) 2018-10-18 14:03:48 -07:00
Gary Qian
35340ceaf0
Pass full locale list with script and variant codes to framework (#6557)
* Locale Passing

* Pass full locale list and script and variant codes to framework

* Working Android locale list passing and fallback
2018-10-17 10:53:01 -07:00
Chinmay Garde
10f9cab4c5
Ensure that the platform view is created and destroyed when running the shell unittests. (#6560) 2018-10-16 14:30:19 -07:00
Dan Field
62cd86c5a8
Advertise iOS Observatory port over mDNS/Bonjour (#6533)
* Publish port of observatory over mDNS
2018-10-15 17:21:01 -07:00
Shaoxing Wang
26f437f377 Fix crash when removeViewImmediate invoked from platform view (#6266)
* Fix crash when removeViewImmediate invoked from platform view

* Clear animation before remove view from mFakeWindowRootView
2018-10-15 16:09:10 -07:00
Chinmay Garde
08272ee6aa
Allow specifying custom toolchains and sysroots for host builds. (#6548)
Updates buildroot to https://github.com/flutter/buildroot/pull/180.
2018-10-15 14:18:02 -07:00
Jason Simmons
75e875240e
Fix the Mac embedder build (#6525) 2018-10-12 16:24:54 -07:00
Jonah Williams
436f9707b9
Add version check for dismissable (#6522) 2018-10-12 15:47:11 -07:00
Jason Simmons
7767c785b4
Provide a default GL function resolver in the embedder (#6523)
Also check whether the implementation behind the resolver is OpenGL or
OpenGL ES
2018-10-12 15:07:46 -07:00
谢然
05aac0f270 fix ResourceExtractor npe. (#6461) 2018-10-12 09:56:00 -07:00
James D. Lin
3ffa362952
Add a callback for iOS when the first Flutter frame is rendered (#6135)
Add a `-[FlutterViewController setFlutterViewDidRenderCallback:]`
method on iOS so client applications can be notified when the Flutter
view has rendered.  This can be used for add2app cases to determine
when to take an initial screenshot for comparisons in automated
tests.

The callback is expected to be an Objective-C block (or Swift
closure).  I chose to support only a single callback because it's
much simpler (especially since it does not require a separate method
to unregister the callback), and it's not clear that there are use
cases that would justify additional complexity.  Clients have the
flexibility to make their callback invoke other callbacks anyway.

I alternatively considered adding a `-[FlutterViewController
viewDidRenderFirstFlutterFrame]` method that clients could override
in a subclass, but using an Objective-C block seems more flexible and
less of a burden.

Fixes https://github.com/flutter/flutter/issues/20665
2018-10-11 20:21:13 -07:00
Gary Qian
61cf4c01fd
Pass scriptcode and variantcode to dart:ui Window. (#6493) 2018-10-10 17:22:59 -07:00
Jason Simmons
155ba09619
Use an older version of SurfaceTexture.setOnFrameAvailableListener when running on pre-Lollipop devices (#6489)
Fixes https://github.com/flutter/flutter/issues/21730
2018-10-10 15:01:48 -07:00