未验证 提交 f0dd6436 编写于 作者: A Amir Hardon 提交者: GitHub

Recreate the overlay rendering surfaces if the GrContext was changed. (#7317)

When the app is sent to the background and then brought to the forward it is possible that the GrContext was changed.
This resulted in overlay surfaces not being updated after being backgrounded and foregrounded.

This change makes sure to re-create the overlay rendering surfaces if the GrContext for the main surface was changed.

fixes flutter/flutter#24900
上级 245317a6
......@@ -210,7 +210,8 @@ bool FlutterPlatformViewsController::SubmitFrame(bool gl_rendering,
for (size_t i = 0; i < composition_order_.size(); i++) {
int64_t view_id = composition_order_[i];
if (gl_rendering) {
EnsureGLOverlayInitialized(view_id, gl_context, gr_context);
EnsureGLOverlayInitialized(view_id, gl_context, gr_context,
gr_context != overlays_gr_context_);
} else {
EnsureOverlayInitialized(view_id);
}
......@@ -220,6 +221,7 @@ bool FlutterPlatformViewsController::SubmitFrame(bool gl_rendering,
canvas->flush();
did_submit &= frame->Submit();
}
overlays_gr_context_ = gr_context;
picture_recorders_.clear();
if (composition_order_ == active_composition_order_) {
composition_order_.clear();
......@@ -265,8 +267,16 @@ void FlutterPlatformViewsController::EnsureOverlayInitialized(int64_t overlay_id
void FlutterPlatformViewsController::EnsureGLOverlayInitialized(
int64_t overlay_id,
std::shared_ptr<IOSGLContext> gl_context,
GrContext* gr_context) {
GrContext* gr_context,
bool update_gr_context) {
if (overlays_.count(overlay_id) != 0) {
if (update_gr_context) {
// The overlay already exists, but the GrContext was changed so we need to recreate
// the rendering surface with the new GrContext.
IOSSurfaceGL* ios_surface_gl = (IOSSurfaceGL*)overlays_[overlay_id]->ios_surface.get();
std::unique_ptr<Surface> surface = ios_surface_gl->CreateSecondaryGPUSurface(gr_context);
overlays_[overlay_id]->surface = std::move(surface);
}
return;
}
FlutterOverlayView* overlay_view = [[FlutterOverlayView alloc] init];
......
......@@ -78,6 +78,10 @@ class FlutterPlatformViewsController {
std::map<int64_t, fml::scoped_nsobject<NSObject<FlutterPlatformView>>> views_;
std::map<int64_t, fml::scoped_nsobject<FlutterTouchInterceptingView>> touch_interceptors_;
std::map<int64_t, std::unique_ptr<FlutterPlatformViewLayer>> overlays_;
// The GrContext that is currently used by all of the overlay surfaces.
// We track this to know when the GrContext for the Flutter app has changed
// so we can update the overlays with the new context.
GrContext* overlays_gr_context_;
SkISize frame_size_;
// A vector of embedded view IDs according to their composition order.
......@@ -97,7 +101,8 @@ class FlutterPlatformViewsController {
void EnsureOverlayInitialized(int64_t overlay_id);
void EnsureGLOverlayInitialized(int64_t overlay_id,
std::shared_ptr<IOSGLContext> gl_context,
GrContext* gr_context);
GrContext* gr_context,
bool update_gr_context);
FML_DISALLOW_COPY_AND_ASSIGN(FlutterPlatformViewsController);
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册