Commit 880c1aaf authored by Eric Karl's avatar Eric Karl Committed by Commit Bot

Correctly handle context lock in TestInProcessContextProvider

TestInProcessContextProvider was not calling

context is lockable. This change updates TestInProcessContextProvider
to optionally support locking, and set up the ContextCacheController
if locking is requested.

ContextCacheController: :SetLock, which is required in cases where the
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I54d1de3768bf958dea944101565fefb99ff2602e
Reviewed-on: https://chromium-review.googlesource.com/1097945Reviewed-by: default avatarenne <enne@chromium.org>
Commit-Queue: Eric Karl <ericrk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#566653}
parent 110fab42
...@@ -57,7 +57,7 @@ class OopPixelTest : public testing::Test { ...@@ -57,7 +57,7 @@ class OopPixelTest : public testing::Test {
void SetUp() override { void SetUp() override {
raster_context_provider_ = raster_context_provider_ =
base::MakeRefCounted<TestInProcessContextProvider>( base::MakeRefCounted<TestInProcessContextProvider>(
/*enable_oop_rasterization=*/true); /*enable_oop_rasterization=*/true, /*support_locking=*/true);
const int raster_max_texture_size = const int raster_max_texture_size =
raster_context_provider_->ContextCapabilities().max_texture_size; raster_context_provider_->ContextCapabilities().max_texture_size;
oop_image_cache_.reset(new GpuImageDecodeCache( oop_image_cache_.reset(new GpuImageDecodeCache(
...@@ -66,7 +66,7 @@ class OopPixelTest : public testing::Test { ...@@ -66,7 +66,7 @@ class OopPixelTest : public testing::Test {
gles2_context_provider_ = gles2_context_provider_ =
base::MakeRefCounted<TestInProcessContextProvider>( base::MakeRefCounted<TestInProcessContextProvider>(
/*enable_oop_rasterization=*/false); /*enable_oop_rasterization=*/false, /*support_locking=*/true);
const int gles2_max_texture_size = const int gles2_max_texture_size =
raster_context_provider_->ContextCapabilities().max_texture_size; raster_context_provider_->ContextCapabilities().max_texture_size;
gpu_image_cache_.reset(new GpuImageDecodeCache( gpu_image_cache_.reset(new GpuImageDecodeCache(
......
...@@ -46,9 +46,9 @@ LayerTreePixelTest::CreateLayerTreeFrameSink( ...@@ -46,9 +46,9 @@ LayerTreePixelTest::CreateLayerTreeFrameSink(
scoped_refptr<TestInProcessContextProvider> worker_context_provider; scoped_refptr<TestInProcessContextProvider> worker_context_provider;
if (test_type_ == PIXEL_TEST_GL) { if (test_type_ == PIXEL_TEST_GL) {
compositor_context_provider = new TestInProcessContextProvider( compositor_context_provider = new TestInProcessContextProvider(
/*enable_oop_rasterization=*/false); /*enable_oop_rasterization=*/false, /*support_locking=*/false);
worker_context_provider = new TestInProcessContextProvider( worker_context_provider = new TestInProcessContextProvider(
/*enable_oop_rasterization=*/false); /*enable_oop_rasterization=*/false, /*support_locking=*/true);
} }
static constexpr bool disable_display_vsync = false; static constexpr bool disable_display_vsync = false;
bool synchronous_composite = bool synchronous_composite =
...@@ -78,7 +78,7 @@ LayerTreePixelTest::CreateDisplayOutputSurfaceOnThread( ...@@ -78,7 +78,7 @@ LayerTreePixelTest::CreateDisplayOutputSurfaceOnThread(
// compositor. // compositor.
auto display_context_provider = auto display_context_provider =
base::MakeRefCounted<TestInProcessContextProvider>( base::MakeRefCounted<TestInProcessContextProvider>(
/*enable_oop_rasterization=*/false); /*enable_oop_rasterization=*/false, /*support_locking=*/false);
display_context_provider->BindToCurrentThread(); display_context_provider->BindToCurrentThread();
bool flipped_output_surface = false; bool flipped_output_surface = false;
......
...@@ -196,7 +196,7 @@ void PixelTest::SetUpGLWithoutRenderer(bool flipped_output_surface) { ...@@ -196,7 +196,7 @@ void PixelTest::SetUpGLWithoutRenderer(bool flipped_output_surface) {
enable_pixel_output_ = std::make_unique<gl::DisableNullDrawGLBindings>(); enable_pixel_output_ = std::make_unique<gl::DisableNullDrawGLBindings>();
auto context_provider = base::MakeRefCounted<TestInProcessContextProvider>( auto context_provider = base::MakeRefCounted<TestInProcessContextProvider>(
/*enable_oop_rasterization=*/false); /*enable_oop_rasterization=*/false, /*support_locking=*/false);
output_surface_ = std::make_unique<PixelTestOutputSurface>( output_surface_ = std::make_unique<PixelTestOutputSurface>(
std::move(context_provider), flipped_output_surface); std::move(context_provider), flipped_output_surface);
output_surface_->BindToClient(output_surface_client_.get()); output_surface_->BindToClient(output_surface_client_.get());
...@@ -207,7 +207,7 @@ void PixelTest::SetUpGLWithoutRenderer(bool flipped_output_surface) { ...@@ -207,7 +207,7 @@ void PixelTest::SetUpGLWithoutRenderer(bool flipped_output_surface) {
shared_bitmap_manager_.get()); shared_bitmap_manager_.get());
child_context_provider_ = base::MakeRefCounted<TestInProcessContextProvider>( child_context_provider_ = base::MakeRefCounted<TestInProcessContextProvider>(
/*enable_oop_rasterization=*/false); /*enable_oop_rasterization=*/false, /*support_locking=*/false);
child_context_provider_->BindToCurrentThread(); child_context_provider_->BindToCurrentThread();
child_resource_provider_ = child_resource_provider_ =
std::make_unique<viz::ClientResourceProvider>(true); std::make_unique<viz::ClientResourceProvider>(true);
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/lazy_instance.h" #include "base/lazy_instance.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/stl_util.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "components/viz/common/gpu/context_cache_controller.h" #include "components/viz/common/gpu/context_cache_controller.h"
#include "components/viz/common/resources/platform_color.h" #include "components/viz/common/resources/platform_color.h"
...@@ -63,7 +64,11 @@ std::unique_ptr<gpu::GLInProcessContext> CreateTestInProcessContext() { ...@@ -63,7 +64,11 @@ std::unique_ptr<gpu::GLInProcessContext> CreateTestInProcessContext() {
} }
TestInProcessContextProvider::TestInProcessContextProvider( TestInProcessContextProvider::TestInProcessContextProvider(
bool enable_oop_rasterization) { bool enable_oop_rasterization,
bool support_locking) {
if (support_locking)
context_lock_.emplace();
if (enable_oop_rasterization) { if (enable_oop_rasterization) {
gpu::ContextCreationAttribs attribs; gpu::ContextCreationAttribs attribs;
attribs.bind_generates_resource = false; attribs.bind_generates_resource = false;
...@@ -94,6 +99,8 @@ TestInProcessContextProvider::TestInProcessContextProvider( ...@@ -94,6 +99,8 @@ TestInProcessContextProvider::TestInProcessContextProvider(
gles2_context_->GetImplementation()->command_buffer(), gles2_context_->GetImplementation()->command_buffer(),
gles2_context_->GetCapabilities()); gles2_context_->GetCapabilities());
} }
cache_controller_->SetLock(GetLock());
} }
TestInProcessContextProvider::~TestInProcessContextProvider() = default; TestInProcessContextProvider::~TestInProcessContextProvider() = default;
...@@ -154,7 +161,7 @@ viz::ContextCacheController* TestInProcessContextProvider::CacheController() { ...@@ -154,7 +161,7 @@ viz::ContextCacheController* TestInProcessContextProvider::CacheController() {
} }
base::Lock* TestInProcessContextProvider::GetLock() { base::Lock* TestInProcessContextProvider::GetLock() {
return &context_lock_; return base::OptionalOrNullptr(context_lock_);
} }
const gpu::Capabilities& TestInProcessContextProvider::ContextCapabilities() const gpu::Capabilities& TestInProcessContextProvider::ContextCapabilities()
......
...@@ -37,7 +37,8 @@ class TestInProcessContextProvider ...@@ -37,7 +37,8 @@ class TestInProcessContextProvider
public viz::ContextProvider, public viz::ContextProvider,
public viz::RasterContextProvider { public viz::RasterContextProvider {
public: public:
explicit TestInProcessContextProvider(bool enable_oop_rasterization); explicit TestInProcessContextProvider(bool enable_oop_rasterization,
bool support_locking);
// viz::ContextProvider / viz::RasterContextProvider implementation. // viz::ContextProvider / viz::RasterContextProvider implementation.
void AddRef() const override; void AddRef() const override;
...@@ -73,7 +74,7 @@ class TestInProcessContextProvider ...@@ -73,7 +74,7 @@ class TestInProcessContextProvider
std::unique_ptr<gpu::RasterInProcessContext> raster_context_; std::unique_ptr<gpu::RasterInProcessContext> raster_context_;
std::unique_ptr<viz::ContextCacheController> cache_controller_; std::unique_ptr<viz::ContextCacheController> cache_controller_;
base::Lock context_lock_; base::Optional<base::Lock> context_lock_;
gpu::GpuFeatureInfo gpu_feature_info_; gpu::GpuFeatureInfo gpu_feature_info_;
}; };
......
...@@ -156,7 +156,8 @@ TEST_F(LayerTreeHostScrollbarsPixelTest, MAYBE_HugeTransformScale) { ...@@ -156,7 +156,8 @@ TEST_F(LayerTreeHostScrollbarsPixelTest, MAYBE_HugeTransformScale) {
background->AddChild(layer); background->AddChild(layer);
scoped_refptr<TestInProcessContextProvider> context( scoped_refptr<TestInProcessContextProvider> context(
new TestInProcessContextProvider(/*enable_oop_rasterization=*/false)); new TestInProcessContextProvider(/*enable_oop_rasterization=*/false,
/*support_locking=*/false));
context->BindToCurrentThread(); context->BindToCurrentThread();
int max_texture_size = 0; int max_texture_size = 0;
context->ContextGL()->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size); context->ContextGL()->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size);
......
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