Add a second per-frame callback that is invoked after the microtask queue is drained (#3632)

See https://github.com/flutter/flutter/issues/7626
This commit is contained in:
Jason Simmons 2017-04-27 10:23:46 -07:00 committed by GitHub
parent 2bb12e578e
commit 8d6ded45f0
4 changed files with 17 additions and 0 deletions

View File

@ -83,6 +83,11 @@ void _beginFrame(int microseconds) {
window.onBeginFrame(new Duration(microseconds: microseconds));
}
void _drawFrame() {
if (window.onDrawFrame != null)
window.onDrawFrame();
}
// If this value changes, update the encoding code in the following files:
//
// * pointer_data.cc

View File

@ -149,6 +149,12 @@ class Window {
/// last time this callback was invoked.
FrameCallback onBeginFrame;
/// A callback that is invoked for each frame after onBeginFrame has
/// completed and after the microtask queue has been drained. This can be
/// used to implement a second phase of frame rendering that happens
/// after any deferred work queued by the onBeginFrame phase.
VoidCallback onDrawFrame;
/// A callback that is invoked when pointer data is available.
PointerDataPacketCallback onPointerDataPacket;

View File

@ -10,6 +10,7 @@
#include "lib/tonic/converter/dart_converter.h"
#include "lib/tonic/dart_args.h"
#include "lib/tonic/dart_library_natives.h"
#include "lib/tonic/dart_microtask_queue.h"
#include "lib/tonic/logging/dart_invoke.h"
#include "lib/tonic/typed_data/dart_byte_data.h"
@ -221,6 +222,10 @@ void Window::BeginFrame(ftl::TimePoint frameTime) {
{
Dart_NewInteger(microseconds),
});
tonic::DartMicrotaskQueue::RunMicrotasks();
DartInvokeField(library_.value(), "_drawFrame", {});
}
void Window::CompletePlatformMessageEmptyResponse(int response_id) {

View File

@ -5,6 +5,7 @@ dart:isolate,::,_getIsolateScheduleImmediateClosure
dart:isolate,::,_setupHooks
dart:isolate,::,_startMainIsolate
dart:ui,::,_beginFrame
dart:ui,::,_drawFrame
dart:ui,::,_dispatchPlatformMessage
dart:ui,::,_dispatchPointerDataPacket
dart:ui,::,_dispatchSemanticsAction