From ec99c09baf05ce19f64b215482faf03296ed3afe Mon Sep 17 00:00:00 2001 From: Dan Field Date: Thu, 7 Apr 2022 09:22:08 -0700 Subject: [PATCH] Soft revert of 3a0d0b6e36deebc6d477daee9a3cc4dbd09a7900 (flutter/engine#32465) --- engine/src/flutter/shell/common/context_options.cc | 6 ++++++ .../src/flutter/shell/common/context_options_unittests.cc | 4 ++-- engine/src/flutter/shell/gpu/gpu_surface_gl.cc | 2 +- .../flutter/shell/platform/android/android_context_gl.cc | 2 +- engine/src/flutter/shell/platform/embedder/embedder.cc | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/engine/src/flutter/shell/common/context_options.cc b/engine/src/flutter/shell/common/context_options.cc index 073c9fcb7fb..3ae89865de5 100644 --- a/engine/src/flutter/shell/common/context_options.cc +++ b/engine/src/flutter/shell/common/context_options.cc @@ -19,6 +19,12 @@ GrContextOptions MakeDefaultContextOptions(ContextType type, options.fPersistentCache = PersistentCache::GetCacheForProcess(); if (api.has_value() && api.value() == GrBackendApi::kOpenGL) { + // Using stencil buffers has caused memory and performance regressions. + // See b/226484927 for internal customer regressions doc. + // Before enabling, we need to show a motivating case for where it will + // improve performance on OpenGL backend. + options.fAvoidStencilBuffers = true; + // To get video playback on the widest range of devices, we limit Skia to // ES2 shading language when the ES3 external image extension is missing. options.fPreferExternalImagesOverES3 = true; diff --git a/engine/src/flutter/shell/common/context_options_unittests.cc b/engine/src/flutter/shell/common/context_options_unittests.cc index 7e576eeeff4..e49f8e28949 100644 --- a/engine/src/flutter/shell/common/context_options_unittests.cc +++ b/engine/src/flutter/shell/common/context_options_unittests.cc @@ -9,10 +9,10 @@ namespace flutter { namespace testing { -TEST(ContextOptionsTest, OpenGLAllowsStencilBuffers) { +TEST(ContextOptionsTest, OpenGLDisablesStencilBuffers) { auto options = MakeDefaultContextOptions(flutter::ContextType::kRender, GrBackendApi::kOpenGL); - EXPECT_FALSE(options.fAvoidStencilBuffers); + EXPECT_TRUE(options.fAvoidStencilBuffers); } } // namespace testing diff --git a/engine/src/flutter/shell/gpu/gpu_surface_gl.cc b/engine/src/flutter/shell/gpu/gpu_surface_gl.cc index 0ce3fda026c..068ae70519a 100644 --- a/engine/src/flutter/shell/gpu/gpu_surface_gl.cc +++ b/engine/src/flutter/shell/gpu/gpu_surface_gl.cc @@ -139,7 +139,7 @@ static sk_sp WrapOnscreenSurface(GrDirectContext* context, GrBackendRenderTarget render_target(size.width(), // width size.height(), // height 0, // sample count - 8, // stencil bits + 0, // stencil bits framebuffer_info // framebuffer info ); diff --git a/engine/src/flutter/shell/platform/android/android_context_gl.cc b/engine/src/flutter/shell/platform/android/android_context_gl.cc index bf7f0fb4dcf..31bfc748473 100644 --- a/engine/src/flutter/shell/platform/android/android_context_gl.cc +++ b/engine/src/flutter/shell/platform/android/android_context_gl.cc @@ -85,7 +85,7 @@ static EGLResult ChooseEGLConfiguration(EGLDisplay display, EGL_BLUE_SIZE, 8, EGL_ALPHA_SIZE, 8, EGL_DEPTH_SIZE, 0, - EGL_STENCIL_SIZE, 8, + EGL_STENCIL_SIZE, 0, EGL_SAMPLES, static_cast(msaa_samples), EGL_SAMPLE_BUFFERS, sample_buffers, EGL_NONE, // termination sentinel diff --git a/engine/src/flutter/shell/platform/embedder/embedder.cc b/engine/src/flutter/shell/platform/embedder/embedder.cc index 9eda0ffe10a..bfbf8f45b6d 100644 --- a/engine/src/flutter/shell/platform/embedder/embedder.cc +++ b/engine/src/flutter/shell/platform/embedder/embedder.cc @@ -621,7 +621,7 @@ static sk_sp MakeSkSurfaceFromBackingStore( config.size.width, // width config.size.height, // height 1, // sample count - 8, // stencil bits + 0, // stencil bits framebuffer_info // framebuffer info );