liyuqian 28d99854a6
Reland again "Remove layer integral offset snapping #17112" (#18160)
This reverts commit a7a25d3b57f2066798ef8cd43600588e4697c9cd and relands our reland https://github.com/flutter/engine/pull/17915.

Additionally, we fixed the cull rect logic in `OpacityLayer::Preroll` which is  the root cause of https://github.com/flutter/flutter/issues/56298. We've always had that root problem before but it did not trigger performance issues because we were using the OpacityLayer's `paint_bounds`, instead of its child's `paint_bounds` for preparing the layer raster cache. A correct handling of the cull rect should allow us to cull at any level.

It also turns out that our ios32 (iPhone4s) performacne can regress a lot
without snapping. My theory is that although the picture has a
fractional top left corner, many drawing operations inside the picture
have integral coordinations. In older hardwares, keeping those
coordinates integral seems to be performance critical.

To avoid flutter/flutter#41654, the snapping
will still be disabled if the matrix has non-scale-translation
transformations.
2020-05-07 17:19:30 -07:00
..

Scenario App

This folder contains a dart:ui application and scripts to compile it to JIT or AOT for exercising embedders.

It intentionally has no dependencies on the Flutter framework or tooling, such that it should be buildable as a presubmit or postsubmit to the engine even in the face of changes to Dart or dart:ui that require upstream changes in the Flutter tooling.

Running for iOS

cd ${ENGINE_REPO}/..
gclient sync
./flutter/tools/gn --unoptimized --runtime-mode debug --simulator --ios
ninja -C out/ios_debug_sim_unopt
cd ${ENGINE_REPO}/testing/scenario_app
./run_ios_tests.sh

Adding a New Scenario

Create a new subclass of Scenario and add it to the map in main.dart. For an example, see animated_color_square.dart, which draws a continuously animating colored square that bounces off the sides of the viewport.

iOS Platform View Tests

For PlatformView tests on iOS, you'll also have to edit the dictionaries in AppDelegate.m and PlatformViewGoldenTestManager.m so that the correct golden image can be found. Also, you'll have to add a GoldenPlatformViewTests in PlatformViewUITests.m.

Generating Golden Images on iOS

Screenshots are saved as XCTAttachment's. If you look at the output from running the tests you'll find a path in the form: /Users/$USER/Library/Developer/Xcode/DerivedData/Scenarios-$HASH. Inside that directory you'll find ./Build/Products/Debug-iphonesimulator/ScenariosUITests-Runner.app/PlugIns/ScenariosUITests.xctest/ which is where all the images that were compared against golden reside.

Building for iOS

In this folder, after building the ios_host and ios_profile engine targets, run:

./compile_ios_aot.sh ../../../out/host_profile ../../../out/ios_profile/clang_x64/

This will create an App.framework copy it as well as the correct Flutter.framework to where the Xcode project expects to find them.

You can then use xcodebuild to build the ios/Scenarios/Scenarios.xcodeproj, or open that in Xcode and build it that way.

Compiling to JIT mode is similar, using the compile_ios_jit.sh script.

Building for Android

In this folder, after building the host_profile and android_profile_arm64 engine targets, run:

./compile_android_aot.sh ../../../out/host_profile ../../../out/android_profile_arm64/clang_x64/

This will produce a suitable libapp.so for building with an Android app and copy it (along with flutter.jar) to where Gradle will expect to find it to build the app in the android/ folder. The app can be run by opening it in Android Studio and running it, or by running ./gradlew assemble in the android/ folder and installing the APK from the correct folder in android/app/build/outputs/apk.

Changing dart:ui code

If you change the dart:ui interface, remember to point the sky_engine and sky_services clauses to your local engine's output path before compiling.