Update overlays_gr_context_ correctly (flutter/engine#8175)
There can be cases where SubmitFrame gets called before overlays are a part of the frame, in these cases, we should not update the GRContext ahead of time. This commit makes it so we will update it only when the frame really shows the overlay. This addresses: https://github.com/flutter/flutter/issues/28920
This commit is contained in:
@@ -21,7 +21,7 @@ class EmbeddedViewParams {
|
||||
};
|
||||
|
||||
// This is only used on iOS when running in a non headless mode,
|
||||
// in this case ViewEmbedded is a reference to the
|
||||
// in this case ExternalViewEmbedder is a reference to the
|
||||
// FlutterPlatformViewsController which is owned by FlutterViewController.
|
||||
class ExternalViewEmbedder {
|
||||
public:
|
||||
|
||||
@@ -210,8 +210,7 @@ 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,
|
||||
gr_context != overlays_gr_context_);
|
||||
EnsureGLOverlayInitialized(view_id, gl_context, gr_context);
|
||||
} else {
|
||||
EnsureOverlayInitialized(view_id);
|
||||
}
|
||||
@@ -221,7 +220,6 @@ 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();
|
||||
@@ -267,10 +265,10 @@ void FlutterPlatformViewsController::EnsureOverlayInitialized(int64_t overlay_id
|
||||
void FlutterPlatformViewsController::EnsureGLOverlayInitialized(
|
||||
int64_t overlay_id,
|
||||
std::shared_ptr<IOSGLContext> gl_context,
|
||||
GrContext* gr_context,
|
||||
bool update_gr_context) {
|
||||
GrContext* gr_context) {
|
||||
if (overlays_.count(overlay_id) != 0) {
|
||||
if (update_gr_context) {
|
||||
if (gr_context != overlays_gr_context_) {
|
||||
overlays_gr_context_ = 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();
|
||||
|
||||
@@ -101,8 +101,7 @@ class FlutterPlatformViewsController {
|
||||
void EnsureOverlayInitialized(int64_t overlay_id);
|
||||
void EnsureGLOverlayInitialized(int64_t overlay_id,
|
||||
std::shared_ptr<IOSGLContext> gl_context,
|
||||
GrContext* gr_context,
|
||||
bool update_gr_context);
|
||||
GrContext* gr_context);
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(FlutterPlatformViewsController);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user