Commit 172d3740 authored by Jonathan Backer's avatar Jonathan Backer Committed by Commit Bot

SkiaRenderer: respect --disable-gl-drawing-for-tests

This is similar to the bypass in RealGLApi::glDrawArraysFn. It is
necessary to avoid timeouts in content_browsertests running under TSAN.

Bug: 967716
Change-Id: Ifd35f188b878fb15b8eb909574e31de370e12045
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1942772Reviewed-by: default avatarweiliangc <weiliangc@chromium.org>
Reviewed-by: default avatarVasiliy Telezhnikov <vasilyt@chromium.org>
Commit-Queue: Jonathan Backer <backer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#720077}
parent ee5071c2
......@@ -204,6 +204,7 @@ class ImageTransferCacheEntryTest
scoped_refptr<gl::GLShareGroup> share_group_;
scoped_refptr<gl::GLContext> gl_context_;
sk_sp<GrContext> gr_context_;
gl::DisableNullDrawGLBindings enable_pixel_output_;
};
TEST_P(ImageTransferCacheEntryTest, Deserialize) {
......
......@@ -253,6 +253,7 @@ void PixelTest::SetUpGLRenderer(bool flipped_output_surface) {
void PixelTest::SetUpSkiaRenderer(bool flipped_output_surface,
bool enable_vulkan) {
enable_pixel_output_ = std::make_unique<gl::DisableNullDrawGLBindings>();
if (enable_vulkan) {
auto* command_line = base::CommandLine::ForCurrentProcess();
bool use_gpu = command_line->HasSwitch(::switches::kUseGpuInTests);
......
......@@ -29,6 +29,7 @@
#include "gpu/vulkan/buildflags.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gl/gl_implementation.h"
#if BUILDFLAG(ENABLE_VULKAN)
#include "gpu/vulkan/tests/native_window.h"
......@@ -77,6 +78,7 @@ class SkiaOutputSurfaceImplTest : public testing::TestWithParam<bool> {
std::unique_ptr<base::test::ScopedFeatureList> scoped_feature_list_;
base::WaitableEvent wait_;
const bool on_screen_;
gl::DisableNullDrawGLBindings enable_pixel_output_;
};
void SkiaOutputSurfaceImplTest::BlockMainThread() {
......
......@@ -5,6 +5,7 @@
#include "ui/gl/init/create_gr_gl_interface.h"
#include "build/build_config.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_version_info.h"
#include "ui/gl/progress_reporter.h"
......@@ -106,45 +107,67 @@ GrGLFunction<R GR_GL_FUNCTION_TYPE(Args...)> bind_slow(
};
}
template <typename R, typename... Args>
template <bool droppable_call, typename R, typename... Args>
GrGLFunction<R GR_GL_FUNCTION_TYPE(Args...)> maybe_drop_call(
R(GL_BINDING_CALL* func)(Args...)) {
// One branch is optimized away because droppable_call is set at compile time.
if (droppable_call) {
return [func](Args... args) {
if (!HasInitializedNullDrawGLBindings())
func(args...);
};
} else {
return func;
}
}
template <bool droppable_call = false, typename R, typename... Args>
GrGLFunction<R GR_GL_FUNCTION_TYPE(Args...)> bind_slow_on_mac(
R(GL_BINDING_CALL* func)(Args...),
gl::ProgressReporter* progress_reporter) {
#if defined(OS_MACOSX)
if (!progress_reporter)
return func;
if (!progress_reporter) {
return maybe_drop_call<droppable_call>(func);
}
return [func, progress_reporter](Args... args) {
gl::ScopedProgressReporter scoped_reporter(progress_reporter);
return func(args...);
// Conditional may be optimized out because droppable_call is set at compile
// time.
if (!droppable_call || !HasInitializedNullDrawGLBindings())
return func(args...);
};
#endif
return func;
return maybe_drop_call<droppable_call>(func);
}
template <typename R, typename... Args>
template <bool droppable_call = false, typename R, typename... Args>
GrGLFunction<R GR_GL_FUNCTION_TYPE(Args...)> bind_with_flush_on_mac(
R(GL_BINDING_CALL* func)(Args...)) {
#if defined(OS_MACOSX)
return [func](Args... args) {
glFlush();
func(args...);
glFlush();
// Conditional may be optimized out because droppable_call is set at compile
// time.
if (!droppable_call || !HasInitializedNullDrawGLBindings()) {
glFlush();
func(args...);
glFlush();
}
};
#else
return func;
return maybe_drop_call<droppable_call>(func);
#endif
}
template <typename R, typename... Args>
template <bool droppable_call = false, typename R, typename... Args>
GrGLFunction<R GR_GL_FUNCTION_TYPE(Args...)> bind_slow_with_flush_on_mac(
R(GL_BINDING_CALL* func)(Args...),
gl::ProgressReporter* progress_reporter) {
if (!progress_reporter) {
return bind_with_flush_on_mac(func);
return bind_with_flush_on_mac<droppable_call>(func);
}
return [func, progress_reporter](Args... args) {
gl::ScopedProgressReporter scoped_reporter(progress_reporter);
return bind_with_flush_on_mac(func)(args...);
return bind_with_flush_on_mac<droppable_call>(func)(args...);
};
}
......@@ -256,7 +279,7 @@ sk_sp<GrGLInterface> CreateGrGLInterface(
functions->fBufferData = gl->glBufferDataFn;
functions->fBufferSubData = gl->glBufferSubDataFn;
functions->fClear =
bind_slow_with_flush_on_mac(gl->glClearFn, progress_reporter);
bind_slow_with_flush_on_mac<true>(gl->glClearFn, progress_reporter);
functions->fClearColor = gl->glClearColorFn;
functions->fClearStencil = gl->glClearStencilFn;
functions->fClearTexImage = gl->glClearTexImageFn;
......@@ -287,23 +310,25 @@ sk_sp<GrGLInterface> CreateGrGLInterface(
functions->fDisableVertexAttribArray = gl->glDisableVertexAttribArrayFn;
functions->fDiscardFramebuffer = gl->glDiscardFramebufferEXTFn;
functions->fDrawArrays =
bind_slow_on_mac(gl->glDrawArraysFn, progress_reporter);
bind_slow_on_mac<true>(gl->glDrawArraysFn, progress_reporter);
functions->fDrawBuffer = gl->glDrawBufferFn;
functions->fDrawBuffers = gl->glDrawBuffersARBFn;
functions->fDrawElements =
bind_slow_on_mac(gl->glDrawElementsFn, progress_reporter);
bind_slow_on_mac<true>(gl->glDrawElementsFn, progress_reporter);
functions->fDrawArraysInstanced =
bind_slow_on_mac(gl->glDrawArraysInstancedANGLEFn, progress_reporter);
functions->fDrawElementsInstanced =
bind_slow_on_mac(gl->glDrawElementsInstancedANGLEFn, progress_reporter);
functions->fDrawArraysInstanced = bind_slow_on_mac<true>(
gl->glDrawArraysInstancedANGLEFn, progress_reporter);
functions->fDrawElementsInstanced = bind_slow_on_mac<true>(
gl->glDrawElementsInstancedANGLEFn, progress_reporter);
// GL 4.0 or GL_ARB_draw_indirect or ES 3.1
functions->fDrawArraysIndirect = gl->glDrawArraysIndirectFn;
functions->fDrawElementsIndirect = gl->glDrawElementsIndirectFn;
functions->fDrawArraysIndirect =
bind_slow_on_mac<true>(gl->glDrawArraysIndirectFn, progress_reporter);
functions->fDrawElementsIndirect =
bind_slow_on_mac<true>(gl->glDrawElementsIndirectFn, progress_reporter);
functions->fDrawRangeElements =
bind_slow_on_mac(gl->glDrawRangeElementsFn, progress_reporter);
bind_slow_on_mac<true>(gl->glDrawRangeElementsFn, progress_reporter);
functions->fEnable = gl->glEnableFn;
functions->fEnableVertexAttribArray = gl->glEnableVertexAttribArrayFn;
functions->fEndQuery = gl->glEndQueryFn;
......
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