From 4ea908ee092555fbe5f3d55dbdb881d8d6926c9a Mon Sep 17 00:00:00 2001 From: John McCutchan Date: Wed, 14 Sep 2016 11:32:57 -0700 Subject: [PATCH] Add 'ext.ui.window.scheduleFrame' service protocol extension (flutter/engine#3030) --- engine/src/flutter/lib/ui/natives.dart | 18 ++++++++++++++++++ engine/src/flutter/lib/ui/ui.dart | 3 +++ 2 files changed, 21 insertions(+) diff --git a/engine/src/flutter/lib/ui/natives.dart b/engine/src/flutter/lib/ui/natives.dart index 7b9b19dc16..f5e9c32680 100644 --- a/engine/src/flutter/lib/ui/natives.dart +++ b/engine/src/flutter/lib/ui/natives.dart @@ -13,10 +13,28 @@ class _Logger { static void _printString(String s) native "Logger_PrintString"; } +// A service protocol extension to schedule a frame to be rendered into the +// window. +Future _scheduleFrame( + String method, + Map parameters + ) async { + // Schedule the frame. + window.scheduleFrame(); + // Always succeed. + return new developer.ServiceExtensionResponse.result(JSON.encode({ + 'type': 'Success', + })); +} + void _setupHooks() { // Wire up timer implementation that is driven by MojoHandleWatcher. VMLibraryHooks.eventHandlerSendData = MojoHandleWatcher.timer; VMLibraryHooks.timerMillisecondClock = MojoCoreNatives.timerMillisecondClock; + assert(() { + // In debug mode, register the schedule frame extension. + developer.registerExtension('ext.ui.window.scheduleFrame', _scheduleFrame); + }); } void _scheduleMicrotask(void callback()) native "ScheduleMicrotask"; diff --git a/engine/src/flutter/lib/ui/ui.dart b/engine/src/flutter/lib/ui/ui.dart index cedf951dbe..d06ddab67b 100644 --- a/engine/src/flutter/lib/ui/ui.dart +++ b/engine/src/flutter/lib/ui/ui.dart @@ -14,6 +14,9 @@ library dart_ui; import 'dart:_internal'; +import 'dart:async'; +import 'dart:convert'; +import 'dart:developer' as developer; import 'dart:math' as math; import 'dart:mojo.internal'; import 'dart:nativewrappers';