Commit e06c7f41 authored by Kai Ninomiya's avatar Kai Ninomiya Committed by Commit Bot

ScalerImpl::Execute: Don't assume what texture unit is active

This code assumed texture unit 0 was active. In fact, sometimes the
current texture unit is different; in this case, the active texture unit
was 2, because Skia set it here:

gpu::gles2::GLES2Implementation::ActiveTexture(unsigned int)
skia_bindings::GLES2ImplementationWithGrContextSupport::ActiveTexture(unsigned int)
GrGLFunction<void (unsigned int)>::GrGLFunction<GrGLFunction<void (unsigned int)> (anonymous namespace)::gles_bind<void, unsigned int>(void (gpu::gles2::GLES2Interface::*)(unsigned int), gpu::gles2::GLES2Interface*, gpu::ContextSupport*)::'lambda'(unsigned int)>(void)::'lambda'(void const*, unsigned int)::__invoke(void const*, unsigned int)
GrGLGpu::setTextureUnit(int)
GrGLGpu::bindTexture(int, GrSamplerState, GrSwizzle const&, GrGLTexture*)
_ZNSt4__Cr10__function16__policy_invokerIFvRK15GrTextureEffectEE11__call_implINS0_20__default_alloc_funcIZN11GrGLProgram12bindTexturesERK20GrPrimitiveProcessorPKPK14GrSurfaceProxyRK10GrPipelineE3$_1S5_EEEEvPKNS0_16__policy_storageES4_
GrFragmentProcessor::visitTextureEffects(std::__Cr::function<void (GrTextureEffect const&)> const&) const
GrFragmentProcessor::visitTextureEffects(std::__Cr::function<void (GrTextureEffect const&)> const&) const
GrFragmentProcessor::visitTextureEffects(std::__Cr::function<void (GrTextureEffect const&)> const&) const
GrPipeline::visitTextureEffects(std::__Cr::function<void (GrTextureEffect const&)> const&) const
GrGLProgram::bindTextures(GrPrimitiveProcessor const&, GrSurfaceProxy const* const*, GrPipeline const&)
GrGLOpsRenderPass::onBindTextures(GrPrimitiveProcessor const&, GrSurfaceProxy const* const*, GrPipeline const&)
GrOpsRenderPass::bindTextures(GrPrimitiveProcessor const&, GrSurfaceProxy const* const*, GrPipeline const&)
(anonymous namespace)::FillRectOp::onExecute(GrOpFlushState*, SkRect const&)
GrOp::execute(GrOpFlushState*, SkRect const&)
GrOpsTask::onExecute(GrOpFlushState*)
GrDrawingManager::executeRenderTasks(int, int, GrOpFlushState*, int*)
GrDrawingManager::flush(GrSurfaceProxy**, int, SkSurface::BackendSurfaceAccess, GrFlushInfo const&, GrBackendSurfaceMutableState const*)
GrDirectContext::flush(GrFlushInfo const&)
media::VideoFrameYUVConverter::ConvertFromVideoFrameYUVSkia(media::VideoFrame const*, viz::RasterContextProvider*, unsigned int, unsigned int)
media::VideoFrameYUVConverter::ConvertFromVideoFrameYUVWithGrContext(media::VideoFrame const*, viz::RasterContextProvider*, gpu::MailboxHolder const&)
media::VideoFrameYUVConverter::ConvertYUVVideoFrame(media::VideoFrame const*, viz::RasterContextProvider*, gpu::MailboxHolder const&)
media::PaintCanvasVideoRenderer::CopyVideoFrameYUVDataToGLTexture(viz::RasterContextProvider*, gpu::gles2::GLES2Interface*, media::VideoFrame const&, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, int, bool, bool)
blink::WebMediaPlayerMS::CopyVideoYUVDataToPlatformTexture(gpu::gles2::GLES2Interface*, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, int, bool, bool, int, blink::WebMediaPlayer::VideoFrameUploadMetadata*)
non-virtual thunk to blink::WebMediaPlayerMS::CopyVideoYUVDataToPlatformTexture(gpu::gles2::GLES2Interface*, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, int, bool, bool, int, blink::WebMediaPlayer::VideoFrameUploadMetadata*)
blink::WebGLRenderingContextBase::TexImageHelperHTMLVideoElement(blink::SecurityOrigin const*, blink::WebGLRenderingContextBase::TexImageFunctionID, unsigned int, int, int, unsigned int, unsigned int, int, int, int, blink::HTMLVideoElement*, blink::IntRect const&, int, int, blink::ExceptionState&)
blink::WebGLRenderingContextBase::texImage2D(blink::ExecutionContext*, unsigned int, int, int, unsigned int, unsigned int, blink::HTMLVideoElement*, blink::ExceptionState&)
blink::WebGL2RenderingContextBase::texImage2D(blink::ExecutionContext*, unsigned int, int, int, unsigned int, unsigned int, blink::HTMLVideoElement*, blink::ExceptionState&)

Bug: 1103385
Change-Id: I3a4bdd41613de448effcaa676870b60d7190cb64
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2522119
Commit-Queue: Kenneth Russell <kbr@chromium.org>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825000}
parent 1a2989c6
...@@ -523,8 +523,15 @@ class ScalerImpl : public GLHelper::ScalerInterface { ...@@ -523,8 +523,15 @@ class ScalerImpl : public GLHelper::ScalerInterface {
src_rect.size() == gfx::SizeF(result_size)) src_rect.size() == gfx::SizeF(result_size))
? GL_NEAREST ? GL_NEAREST
: GL_LINEAR; : GL_LINEAR;
// Bind to the source texture and set the filitering and clamp to the edge,
// as required by all shader programs. // Set the active texture unit to 0 for the ScopedTextureBinder below, then
// restore the original value when done. (crbug.com/1103385)
GLint oldActiveTexture = 0;
gl_->GetIntegerv(GL_ACTIVE_TEXTURE, &oldActiveTexture);
gl_->ActiveTexture(GL_TEXTURE0);
{
// Bind to the source texture and set the filitering and clamp to the
// edge, as required by all shader programs.
ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, src_texture); ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, src_texture);
gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
...@@ -550,6 +557,10 @@ class ScalerImpl : public GLHelper::ScalerInterface { ...@@ -550,6 +557,10 @@ class ScalerImpl : public GLHelper::ScalerInterface {
// Set the draw buffers back to not disrupt external operations. // Set the draw buffers back to not disrupt external operations.
gl_->DrawBuffersEXT(1, buffers); gl_->DrawBuffersEXT(1, buffers);
} }
// ScopedTextureBinder ends here, before restoring ActiveTexture state.
}
gl_->ActiveTexture(oldActiveTexture);
} }
GLES2Interface* gl_; GLES2Interface* gl_;
......
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