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,33 +523,44 @@ class ScalerImpl : public GLHelper::ScalerInterface { ...@@ -523,33 +523,44 @@ 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
ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, src_texture); // restore the original value when done. (crbug.com/1103385)
gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); GLint oldActiveTexture = 0;
gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); gl_->GetIntegerv(GL_ACTIVE_TEXTURE, &oldActiveTexture);
gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); gl_->ActiveTexture(GL_TEXTURE0);
gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); {
// Bind to the source texture and set the filitering and clamp to the
// Prepare the shader program for drawing. // edge, as required by all shader programs.
ScopedBufferBinder<GL_ARRAY_BUFFER> buffer_binder( ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, src_texture);
gl_, scaler_helper_->vertex_attributes_buffer_); gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
shader_program_->UseProgram(src_texture_size, src_rect, result_size, gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
spec_.scale_x, spec_.flip_output, gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
color_weights_); gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// Execute the draw. // Prepare the shader program for drawing.
gl_->Viewport(0, 0, result_size.width(), result_size.height()); ScopedBufferBinder<GL_ARRAY_BUFFER> buffer_binder(
const GLenum buffers[] = {GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT0 + 1}; gl_, scaler_helper_->vertex_attributes_buffer_);
if (dest_texture_1 > 0) { shader_program_->UseProgram(src_texture_size, src_rect, result_size,
DCHECK_LE(2, scaler_helper_->helper_->MaxDrawBuffers()); spec_.scale_x, spec_.flip_output,
gl_->DrawBuffersEXT(2, buffers); color_weights_);
}
gl_->DrawArrays(GL_TRIANGLE_STRIP, 0, 4); // Execute the draw.
if (dest_texture_1 > 0) { gl_->Viewport(0, 0, result_size.width(), result_size.height());
// Set the draw buffers back to not disrupt external operations. const GLenum buffers[] = {GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT0 + 1};
gl_->DrawBuffersEXT(1, buffers); if (dest_texture_1 > 0) {
DCHECK_LE(2, scaler_helper_->helper_->MaxDrawBuffers());
gl_->DrawBuffersEXT(2, buffers);
}
gl_->DrawArrays(GL_TRIANGLE_STRIP, 0, 4);
if (dest_texture_1 > 0) {
// Set the draw buffers back to not disrupt external operations.
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