提交 8d6ded45 编写于 作者: J Jason Simmons 提交者: GitHub

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

See https://github.com/flutter/flutter/issues/7626
上级 2bb12e57
......@@ -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
......
......@@ -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;
......
......@@ -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) {
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册