提交 82c13d7e 编写于 作者: M Matt Perry

Merge remote-tracking branch 'upstream/master' into performance

...@@ -15,9 +15,24 @@ PLUTIL = [ ...@@ -15,9 +15,24 @@ PLUTIL = [
'plutil' 'plutil'
] ]
def MakeDirectories(path):
try:
os.makedirs(path)
except OSError as exc:
if exc.errno == errno.EEXIST and os.path.isdir(path):
return 0
else:
return -1
return 0
def ProcessInfoPlist(args): def ProcessInfoPlist(args):
output_plist_file = os.path.abspath(os.path.join(args.output, 'Info.plist')) output_plist_file = os.path.abspath(os.path.join(args.output, 'Info.plist'))
if MakeDirectories(os.path.dirname(output_plist_file)) == -1:
return -1
return subprocess.check_call( PLUTIL + [ return subprocess.check_call( PLUTIL + [
'-convert', '-convert',
'binary1', 'binary1',
...@@ -42,18 +57,6 @@ def PerformCodeSigning(args): ...@@ -42,18 +57,6 @@ def PerformCodeSigning(args):
]) ])
def MakeDirectories(path):
try:
os.makedirs(path)
except OSError as exc:
if exc.errno == errno.EEXIST and os.path.isdir(path):
return 0
else:
return -1
return 0
def GenerateProjectStructure(args): def GenerateProjectStructure(args):
application_path = os.path.join( args.dir, args.name + ".app" ) application_path = os.path.join( args.dir, args.name + ".app" )
return MakeDirectories( application_path ) return MakeDirectories( application_path )
......
...@@ -56,6 +56,10 @@ template("resource_copy_ios") { ...@@ -56,6 +56,10 @@ template("resource_copy_ios") {
set_sources_assignment_filter([]) set_sources_assignment_filter([])
sources = _resources sources = _resources
outputs = [ "$root_build_dir/$_app_name.app/$_bundle_directory/{{source_file_part}}" ] outputs = [ "$root_build_dir/$_app_name.app/$_bundle_directory/{{source_file_part}}" ]
if (defined(invoker.deps)) {
deps = invoker.deps
}
} }
} }
...@@ -115,14 +119,14 @@ template("ios_app") { ...@@ -115,14 +119,14 @@ template("ios_app") {
script = ios_app_script script = ios_app_script
sources = [ invoker.info_plist ] sources = [ invoker.info_plist ]
outputs = [ "$root_build_dir/Info.plist" ] outputs = [ "$root_build_dir/plist/$app_name/Info.plist" ]
args = [ args = [
"plist", "plist",
"-i", "-i",
rebase_path(invoker.info_plist, root_build_dir), rebase_path(invoker.info_plist, root_build_dir),
"-o", "-o",
rebase_path(root_build_dir), rebase_path("$root_build_dir/plist/$app_name"),
] ]
} }
...@@ -131,7 +135,7 @@ template("ios_app") { ...@@ -131,7 +135,7 @@ template("ios_app") {
copy_gen_target_name = target_name + "_copy" copy_gen_target_name = target_name + "_copy"
copy(copy_gen_target_name) { copy(copy_gen_target_name) {
sources = [ sources = [
"$root_build_dir/Info.plist", "$root_build_dir/plist/$app_name/Info.plist",
"$root_build_dir/$app_name", "$root_build_dir/$app_name",
] ]
......
...@@ -7,7 +7,7 @@ import("//sky/build/skyx.gni") ...@@ -7,7 +7,7 @@ import("//sky/build/skyx.gni")
template("sky_app") { template("sky_app") {
skyx_target_name = target_name skyx_target_name = target_name
if (is_android) { if (is_android || is_ios) {
skyx_target_name = "app" skyx_target_name = "app"
} }
...@@ -89,5 +89,45 @@ template("sky_app") { ...@@ -89,5 +89,45 @@ template("sky_app") {
deps += invoker.deps deps += invoker.deps
} }
} }
} else if (is_ios && defined(invoker.info_plist)) {
import("//build/config/ios/rules.gni")
import("//build/config/ios/ios_sdk.gni")
ios_app(target_name) {
app_name = target_name + "_app"
code_signing_identity = ios_code_signing_identity
info_plist = invoker.info_plist
if (defined(invoker.entitlements_path)) {
entitlements_path = invoker.entitlements_path
} else {
entitlements_path = "//sky/shell/ios/Entitlements.xcent"
}
resources_gen_target_name = target_name + "_res"
resource_copy_ios(resources_gen_target_name) {
resources = [
"//third_party/icu/android/icudtl.dat",
"$target_gen_dir/app.skyx",
]
bundle_directory = "."
deps = [ ":app" ]
}
deps = [
"//sky/shell:ios_scaffolding",
":$resources_gen_target_name",
":$skyx_target_name",
]
if (defined(invoker.deps)) {
deps += invoker.deps
}
}
} else {
group(target_name) {
}
} }
} }
...@@ -14,5 +14,7 @@ sky_app("game") { ...@@ -14,5 +14,7 @@ sky_app("game") {
deps = [ deps = [
"//sky/packages/sky/example/game/apk:resources", "//sky/packages/sky/example/game/apk:resources",
] ]
} else if (is_ios) {
info_plist = "ios/Info.plist"
} }
} }
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<!--
This executable name must match the name of the app provided to the
ios_app GN template
-->
<key>CFBundleExecutable</key>
<string>game_app</string>
<key>CFBundleIdentifier</key>
<string>org.domokit.sky.game</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>game_app</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>DTPlatformName</key>
<string>iphonesimulator</string>
<key>DTSDKName</key>
<string>iphonesimulator8.3</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>MinimumOSVersion</key>
<string>8.3</string>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>iPhoneSimulator</string>
</array>
</dict>
</plist>
...@@ -47,7 +47,7 @@ class SkyBinding { ...@@ -47,7 +47,7 @@ class SkyBinding {
_renderView = renderViewOverride; _renderView = renderViewOverride;
} }
assert(_renderView != null); assert(_renderView != null);
scheduler.addPersistentFrameCallback(_beginFrame); scheduler.addPersistentFrameCallback(beginFrame);
assert(_instance == this); assert(_instance == this);
} }
...@@ -69,7 +69,7 @@ class SkyBinding { ...@@ -69,7 +69,7 @@ class SkyBinding {
void set root(RenderBox value) { void set root(RenderBox value) {
_renderView.child = value; _renderView.child = value;
} }
void _beginFrame(double timeStamp) { void beginFrame(double timeStamp) {
RenderObject.flushLayout(); RenderObject.flushLayout();
RenderObject.flushPaint(); RenderObject.flushPaint();
_renderView.paintFrame(); _renderView.paintFrame();
......
...@@ -7,6 +7,7 @@ import 'dart:collection'; ...@@ -7,6 +7,7 @@ import 'dart:collection';
import 'dart:sky' as sky; import 'dart:sky' as sky;
import 'package:sky/base/hit_test.dart'; import 'package:sky/base/hit_test.dart';
import 'package:sky/base/scheduler.dart' as scheduler;
import 'package:sky/mojo/activity.dart' as activity; import 'package:sky/mojo/activity.dart' as activity;
import 'package:sky/rendering/box.dart'; import 'package:sky/rendering/box.dart';
import 'package:sky/rendering/object.dart'; import 'package:sky/rendering/object.dart';
...@@ -651,6 +652,11 @@ abstract class Component extends Widget { ...@@ -651,6 +652,11 @@ abstract class Component extends Widget {
_scheduleComponentForRender(this); _scheduleComponentForRender(this);
} }
static void flushBuild() {
if (!_dirtyComponents.isEmpty)
_buildDirtyComponents();
}
Widget build(); Widget build();
} }
...@@ -759,13 +765,15 @@ void _absorbDirtyComponents(List<Component> list) { ...@@ -759,13 +765,15 @@ void _absorbDirtyComponents(List<Component> list) {
} }
void _buildDirtyComponents() { void _buildDirtyComponents() {
assert(!_dirtyComponents.isEmpty);
Stopwatch sw; Stopwatch sw;
if (_shouldLogRenderDuration) if (_shouldLogRenderDuration)
sw = new Stopwatch()..start(); sw = new Stopwatch()..start();
_inRenderDirtyComponents = true; _inRenderDirtyComponents = true;
try { try {
sky.tracing.begin('Widgets._buildDirtyComponents'); sky.tracing.begin('Component.flushBuild');
List<Component> sortedDirtyComponents = new List<Component>(); List<Component> sortedDirtyComponents = new List<Component>();
_absorbDirtyComponents(sortedDirtyComponents); _absorbDirtyComponents(sortedDirtyComponents);
int index = 0; int index = 0;
...@@ -784,7 +792,7 @@ void _buildDirtyComponents() { ...@@ -784,7 +792,7 @@ void _buildDirtyComponents() {
} finally { } finally {
_buildScheduled = false; _buildScheduled = false;
_inRenderDirtyComponents = false; _inRenderDirtyComponents = false;
sky.tracing.end('Widgets._buildDirtyComponents'); sky.tracing.end('Component.flushBuild');
} }
Widget._notifyMountStatusChanged(); Widget._notifyMountStatusChanged();
...@@ -795,21 +803,20 @@ void _buildDirtyComponents() { ...@@ -795,21 +803,20 @@ void _buildDirtyComponents() {
if (_debugFrameTimes.length >= 1000) { if (_debugFrameTimes.length >= 1000) {
_debugFrameTimes.sort(); _debugFrameTimes.sort();
const int i = 99; const int i = 99;
print('_buildDirtyComponents: ${i+1}th fastest frame out of the last ${_debugFrameTimes.length}: ${_debugFrameTimes[i]} microseconds'); print('Component.flushBuild: ${i+1}th fastest frame out of the last ${_debugFrameTimes.length}: ${_debugFrameTimes[i]} microseconds');
_debugFrameTimes.clear(); _debugFrameTimes.clear();
} }
} }
} }
void _scheduleComponentForRender(Component c) { void _scheduleComponentForRender(Component component) {
_dirtyComponents.add(c); _dirtyComponents.add(component);
if (!_buildScheduled) { if (!_buildScheduled) {
_buildScheduled = true; _buildScheduled = true;
new Future.microtask(_buildDirtyComponents); scheduler.ensureVisualUpdate();
} }
} }
// RenderObjectWrappers correspond to a desired state of a RenderObject. // RenderObjectWrappers correspond to a desired state of a RenderObject.
// They are fully immutable, with one exception: A Widget which is a // They are fully immutable, with one exception: A Widget which is a
// Component which lives within an MultiChildRenderObjectWrapper's // Component which lives within an MultiChildRenderObjectWrapper's
...@@ -1178,6 +1185,11 @@ class WidgetSkyBinding extends SkyBinding { ...@@ -1178,6 +1185,11 @@ class WidgetSkyBinding extends SkyBinding {
} }
} }
void beginFrame(double timeStamp) {
Component.flushBuild();
super.beginFrame(timeStamp);
}
} }
abstract class App extends StatefulComponent { abstract class App extends StatefulComponent {
......
...@@ -169,10 +169,36 @@ if (is_android) { ...@@ -169,10 +169,36 @@ if (is_android) {
import("//build/config/ios/rules.gni") import("//build/config/ios/rules.gni")
import("//build/config/ios/ios_sdk.gni") import("//build/config/ios/ios_sdk.gni")
source_set("ios_scaffolding") {
sources = [
"ios/main_ios.mm",
"ios/sky_app_delegate.h",
"ios/sky_app_delegate.mm",
"ios/sky_surface.h",
"ios/sky_surface.mm",
"ios/sky_view_controller.h",
"ios/sky_view_controller.mm",
]
set_sources_assignment_filter([])
sources += [
"mac/platform_mac.h",
"mac/platform_mac.mm",
"mac/platform_service_provider_mac.cc",
"mac/platform_view_mac.h",
"mac/platform_view_mac.mm",
]
set_sources_assignment_filter(sources_assignment_filter)
deps = common_deps + [
":common",
"//sky/services/ns_net",
]
}
ios_app("shell") { ios_app("shell") {
app_name = "SkyShell" app_name = "SkyShell"
info_plist = "ios/Info.plist" info_plist = "ios/Info.plist"
scaffolding_target = "ios_scaffolding"
entitlements_path = "ios/Entitlements.xcent" entitlements_path = "ios/Entitlements.xcent"
code_signing_identity = ios_code_signing_identity code_signing_identity = ios_code_signing_identity
...@@ -181,35 +207,8 @@ if (is_android) { ...@@ -181,35 +207,8 @@ if (is_android) {
bundle_directory = "." bundle_directory = "."
} }
source_set(scaffolding_target) {
sources = [
"ios/main_ios.mm",
"ios/sky_app_delegate.h",
"ios/sky_app_delegate.mm",
"ios/sky_surface.h",
"ios/sky_surface.mm",
"ios/sky_view_controller.h",
"ios/sky_view_controller.mm",
]
set_sources_assignment_filter([])
sources += [
"mac/platform_mac.h",
"mac/platform_mac.mm",
"mac/platform_service_provider_mac.cc",
"mac/platform_view_mac.h",
"mac/platform_view_mac.mm",
]
set_sources_assignment_filter(sources_assignment_filter)
deps = common_deps + [
":common",
"//sky/services/ns_net",
]
}
deps = [ deps = [
":$scaffolding_target", ":ios_scaffolding",
":sky_resources", ":sky_resources",
] ]
} }
......
...@@ -131,16 +131,32 @@ static sky::InputEventPtr BasicInputEventFromRecognizer( ...@@ -131,16 +131,32 @@ static sky::InputEventPtr BasicInputEventFromRecognizer(
if (server && target) { if (server && target) {
return [NSString stringWithFormat:@"http://%@/%@", server, target]; return [NSString stringWithFormat:@"http://%@/%@", server, target];
} }
return [NSBundle mainBundle].infoDictionary[@"org.domokit.sky.load_url"]; return [NSBundle mainBundle].infoDictionary[@"org.domokit.sky.load_url"];
} }
- (NSString*)skyInitialBundleURL {
return [[NSBundle mainBundle] pathForResource:@"app" ofType:@"skyx"];
}
- (void)connectToEngineAndLoad { - (void)connectToEngineAndLoad {
auto interface_request = mojo::GetProxy(&_sky_engine); auto interface_request = mojo::GetProxy(&_sky_engine);
self.platformView->ConnectToEngine(interface_request.Pass()); self.platformView->ConnectToEngine(interface_request.Pass());
mojo::String string(self.skyInitialLoadURL.UTF8String); NSString *endpoint = self.skyInitialBundleURL;
_sky_engine->RunFromNetwork(string); if (endpoint.length > 0) {
// Load from bundle
mojo::String string(endpoint.UTF8String);
_sky_engine->RunFromBundle(string);
return;
}
endpoint = self.skyInitialLoadURL;
if (endpoint.length > 0) {
// Load from URL
mojo::String string(endpoint.UTF8String);
_sky_engine->RunFromNetwork(string);
return;
}
} }
- (void)notifySurfaceDestruction { - (void)notifySurfaceDestruction {
......
...@@ -149,6 +149,7 @@ class TestRenderView extends RenderView { ...@@ -149,6 +149,7 @@ class TestRenderView extends RenderView {
// TEST API: // TEST API:
void syncCheckFrame() { void syncCheckFrame() {
Component.flushBuild();
RenderObject.flushLayout(); RenderObject.flushLayout();
paintFrame(); paintFrame();
print(lastPaint); // TODO(ianh): figure out how to make this fit the unit testing framework better print(lastPaint); // TODO(ianh): figure out how to make this fit the unit testing framework better
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册