Commit be49447a authored by Jonathan Backer's avatar Jonathan Backer Committed by Commit Bot

Reset GL state

GLES2DecoderImpl hooks into GLStateRestorer for virtual context
switching. These hooks work even without enabling virtual contexts and
are used in DirectContextProvider::SetGLRendererCopierRequiredState.

GLES2DecoderPassthroughImpl does not have any state restoration hooks.
This CL explicitly sets state used by GLRendererCopier, GLScaler, and
GLI420Converter.

Bug: 1016833
Change-Id: I7ebead5148411677765b3d4635871873b7af0018
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1912907Reviewed-by: default avatarkylechar <kylechar@chromium.org>
Commit-Queue: Jonathan Backer <backer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714733}
parent 634e78bf
...@@ -154,11 +154,24 @@ void DirectContextProvider::SetGLRendererCopierRequiredState( ...@@ -154,11 +154,24 @@ void DirectContextProvider::SetGLRendererCopierRequiredState(
// SkiaOutputSurfaceImplOnGpu::ScopedUseContextProvider). // SkiaOutputSurfaceImplOnGpu::ScopedUseContextProvider).
gles2_implementation_->BindFramebuffer(GL_FRAMEBUFFER, 0); gles2_implementation_->BindFramebuffer(GL_FRAMEBUFFER, 0);
decoder_->RestoreActiveTexture(); auto* group = decoder()->GetContextGroup();
decoder_->RestoreProgramBindings(); if (group->use_passthrough_cmd_decoder()) {
decoder_->RestoreAllAttributes(); // Matches state setting in
decoder_->RestoreGlobalState(); // SkiaOutputSurfaceImplOnGpu::ScopedUseContextProvider when passthrough
decoder_->RestoreBufferBindings(); // is enabled so that client side and service side state match.
//
// TODO(backer): Use ANGLE API to force state reset once API is available.
gles2_implementation_->UseProgram(0);
gles2_implementation_->ActiveTexture(GL_TEXTURE0);
gles2_implementation_->BindBuffer(GL_ARRAY_BUFFER, 0);
gles2_implementation_->BindTexture(GL_TEXTURE_2D, 0);
} else {
decoder_->RestoreActiveTexture();
decoder_->RestoreProgramBindings();
decoder_->RestoreAllAttributes();
decoder_->RestoreGlobalState();
decoder_->RestoreBufferBindings();
}
// At this point |decoder_| cached state (if any, passthrough doesn't cache) // At this point |decoder_| cached state (if any, passthrough doesn't cache)
// is synced with GLContext state. But GLES2Implementation caches some state // is synced with GLContext state. But GLES2Implementation caches some state
......
...@@ -220,6 +220,16 @@ class SkiaOutputSurfaceImplOnGpu::ScopedUseContextProvider { ...@@ -220,6 +220,16 @@ class SkiaOutputSurfaceImplOnGpu::ScopedUseContextProvider {
// side consistent with that. // side consistent with that.
auto* api = impl_on_gpu_->api_; auto* api = impl_on_gpu_->api_;
api->glBindFramebufferEXTFn(GL_FRAMEBUFFER, 0); api->glBindFramebufferEXTFn(GL_FRAMEBUFFER, 0);
auto* group = impl_on_gpu->context_provider_->decoder()->GetContextGroup();
if (group->use_passthrough_cmd_decoder()) {
// Passthrough decoding is not hooked into GLStateRestorer and we must
// manually reset the context into a known state after Skia is finished.
api->glUseProgramFn(0);
api->glActiveTextureFn(GL_TEXTURE0);
api->glBindBufferFn(GL_ARRAY_BUFFER, 0);
api->glBindTextureFn(GL_TEXTURE_2D, 0);
}
impl_on_gpu_->context_provider_->SetGLRendererCopierRequiredState( impl_on_gpu_->context_provider_->SetGLRendererCopierRequiredState(
texture_client_id); texture_client_id);
} }
......
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