mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
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:
parent
2bb12e578e
commit
8d6ded45f0
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user