Commit bbfb50f4 authored by Bo Liu's avatar Bo Liu Committed by Commit Bot

gpu: Add needs_gl to SharedContextState::IsCurrent

When vulkan is used for composite and raster, there are still code paths
that needs GL. SharedContextState::IsCurrent always return true if
vulkan (or some other non-gl gr_context_type) is used. For the code
paths that always needs GL, IsCurrent is returning the wrong value,
leading to some no-context-current errors.

Fix this by adding a bool needs_gl parameter that defaults to false
(similar to MakeCurrent), and set it to true for the two cases that I
ran into.

Bug: 1151376
Change-Id: Idec4a231579b067d5aa9b60ae21d6a2a11e794ce
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2553285Reviewed-by: default avatarPeng Huang <penghuang@chromium.org>
Commit-Queue: Bo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830250}
parent 3e84de85
......@@ -67,7 +67,7 @@ AbstractTextureImplOnSharedContext::~AbstractTextureImplOnSharedContext() {
if (!shared_context_state_) {
have_context = false;
} else {
if (!shared_context_state_->IsCurrent(nullptr)) {
if (!shared_context_state_->IsCurrent(nullptr, /*needs_gl=*/true)) {
scoped_make_current.emplace(shared_context_state_->context(),
shared_context_state_->surface());
have_context = scoped_make_current->IsContextCurrent();
......
......@@ -545,8 +545,8 @@ void SharedContextState::MarkContextLost(error::ContextLostReason reason) {
}
}
bool SharedContextState::IsCurrent(gl::GLSurface* surface) {
if (!GrContextIsGL())
bool SharedContextState::IsCurrent(gl::GLSurface* surface, bool needs_gl) {
if (!GrContextIsGL() && !needs_gl)
return true;
if (context_lost())
return false;
......
......@@ -106,7 +106,7 @@ class GPU_GLES2_EXPORT SharedContextState
bool MakeCurrent(gl::GLSurface* surface, bool needs_gl = false);
void ReleaseCurrent(gl::GLSurface* surface);
void MarkContextLost(error::ContextLostReason reason = error::kUnknown);
bool IsCurrent(gl::GLSurface* surface);
bool IsCurrent(gl::GLSurface* surface, bool needs_gl = false);
void PurgeMemory(
base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level);
......
......@@ -38,7 +38,8 @@ namespace {
std::unique_ptr<ui::ScopedMakeCurrent> MakeCurrent(
SharedContextState* context_state) {
std::unique_ptr<ui::ScopedMakeCurrent> scoped_make_current;
bool needs_make_current = !context_state->IsCurrent(nullptr);
bool needs_make_current =
!context_state->IsCurrent(nullptr, /*needs_gl=*/true);
if (needs_make_current) {
scoped_make_current = std::make_unique<ui::ScopedMakeCurrent>(
context_state->context(), context_state->surface());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment