Skip to content

Commit

Permalink
Support stencil buffers on OpenGL for Windows and Android (flutter#31967
Browse files Browse the repository at this point in the history
)
  • Loading branch information
dnfield authored Mar 15, 2022
1 parent 5a80834 commit cd7a1e2
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,7 @@ FILE: ../../../flutter/shell/common/canvas_spy.h
FILE: ../../../flutter/shell/common/canvas_spy_unittests.cc
FILE: ../../../flutter/shell/common/context_options.cc
FILE: ../../../flutter/shell/common/context_options.h
FILE: ../../../flutter/shell/common/context_options_unittests.cc
FILE: ../../../flutter/shell/common/dart_native_benchmarks.cc
FILE: ../../../flutter/shell/common/display.cc
FILE: ../../../flutter/shell/common/display.h
Expand Down
1 change: 1 addition & 0 deletions shell/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ if (enable_unittests) {
sources = [
"animator_unittests.cc",
"canvas_spy_unittests.cc",
"context_options_unittests.cc",
"engine_unittests.cc",
"input_events_unittests.cc",
"persistent_cache_unittests.cc",
Expand Down
2 changes: 0 additions & 2 deletions shell/common/context_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ GrContextOptions MakeDefaultContextOptions(ContextType type,
options.fPersistentCache = PersistentCache::GetCacheForProcess();

if (api.has_value() && api.value() == GrBackendApi::kOpenGL) {
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;
Expand Down
19 changes: 19 additions & 0 deletions shell/common/context_options_unittests.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "context_options.h"

#include "gtest/gtest.h"

namespace flutter {
namespace testing {

TEST(ContextOptionsTest, OpenGLAllowsStencilBuffers) {
auto options = MakeDefaultContextOptions(flutter::ContextType::kRender,
GrBackendApi::kOpenGL);
EXPECT_FALSE(options.fAvoidStencilBuffers);
}

} // namespace testing
} // namespace flutter
2 changes: 1 addition & 1 deletion shell/gpu/gpu_surface_gl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ static sk_sp<SkSurface> WrapOnscreenSurface(GrDirectContext* context,
GrBackendRenderTarget render_target(size.width(), // width
size.height(), // height
0, // sample count
0, // stencil bits (TODO)
8, // stencil bits
framebuffer_info // framebuffer info
);

Expand Down
2 changes: 1 addition & 1 deletion shell/platform/android/android_context_gl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static EGLResult<EGLConfig> ChooseEGLConfiguration(EGLDisplay display) {
EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 8,
EGL_DEPTH_SIZE, 0,
EGL_STENCIL_SIZE, 0,
EGL_STENCIL_SIZE, 8,
EGL_NONE, // termination sentinel
// clang-format on
};
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/embedder/embedder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ static sk_sp<SkSurface> MakeSkSurfaceFromBackingStore(
config.size.width, // width
config.size.height, // height
1, // sample count
0, // stencil bits
8, // stencil bits
framebuffer_info // framebuffer info
);

Expand Down

0 comments on commit cd7a1e2

Please sign in to comment.