Commit b73152db authored by danakj's avatar danakj Committed by Commit bot

Remove WebGraphicsContext3D dependency in gpu_context_tests.h

We make the ContextProviderCommandBuffer and its WebGraphicsContext3D
private in the command buffer version of the tests, and use a
GLInProcessContext in the in-process version. The shared code only is
exposed to GLES2Interface and ContextSupport.

R=kbr@chromium.org
BUG=584497

Review URL: https://codereview.chromium.org/1807813002

Cr-Commit-Position: refs/heads/master@{#381598}
parent 706a9dd9
...@@ -39,36 +39,43 @@ class ContextTestBase : public content::ContentBrowserTest { ...@@ -39,36 +39,43 @@ class ContextTestBase : public content::ContentBrowserTest {
content::BrowserGpuChannelHostFactory* factory = content::BrowserGpuChannelHostFactory* factory =
content::BrowserGpuChannelHostFactory::instance(); content::BrowserGpuChannelHostFactory::instance();
CHECK(factory); CHECK(factory);
bool lose_context_when_out_of_memory = false;
base::RunLoop run_loop; base::RunLoop run_loop;
factory->EstablishGpuChannel(kInitCause, run_loop.QuitClosure()); factory->EstablishGpuChannel(kInitCause, run_loop.QuitClosure());
run_loop.Run(); run_loop.Run();
scoped_refptr<content::GpuChannelHost> scoped_refptr<content::GpuChannelHost>
gpu_channel_host(factory->GetGpuChannel()); gpu_channel_host(factory->GetGpuChannel());
DCHECK(gpu_channel_host.get()); CHECK(gpu_channel_host.get());
context_.reset(
bool lose_context_when_out_of_memory = false;
scoped_ptr<WebGraphicsContext3DCommandBufferImpl> web_context(
WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
gpu_channel_host.get(), gpu_channel_host.get(), blink::WebGraphicsContext3D::Attributes(),
blink::WebGraphicsContext3D::Attributes(), lose_context_when_out_of_memory, GURL(),
lose_context_when_out_of_memory,
GURL(),
WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(),
NULL)); nullptr));
CHECK(context_.get());
context_->InitializeOnCurrentThread(); provider_ = content::ContextProviderCommandBuffer::Create(
context_support_ = context_->GetContextSupport(); std::move(web_context), content::OFFSCREEN_CONTEXT_FOR_TESTING);
bool bound = provider_->BindToCurrentThread();
CHECK(bound);
gl_ = provider_->ContextGL();
context_support_ = provider_->ContextSupport();
ContentBrowserTest::SetUpOnMainThread(); ContentBrowserTest::SetUpOnMainThread();
} }
void TearDownOnMainThread() override { void TearDownOnMainThread() override {
// Must delete the context first. // Must delete the context first.
context_.reset(NULL); provider_ = nullptr;
ContentBrowserTest::TearDownOnMainThread(); ContentBrowserTest::TearDownOnMainThread();
} }
protected: protected:
scoped_ptr<content::WebGraphicsContext3DCommandBufferImpl> context_; gpu::gles2::GLES2Interface* gl_;
gpu::ContextSupport* context_support_; gpu::ContextSupport* context_support_;
private:
scoped_refptr<content::ContextProviderCommandBuffer> provider_;
}; };
} // namespace } // namespace
......
...@@ -31,7 +31,7 @@ class SignalTest : public ContextTestBase { ...@@ -31,7 +31,7 @@ class SignalTest : public ContextTestBase {
} }
// These tests should time out if the callback doesn't get called. // These tests should time out if the callback doesn't get called.
void TestSignalQuery(blink::WebGLId query) { void TestSignalQuery(GLuint query) {
base::RunLoop run_loop; base::RunLoop run_loop;
context_support_->SignalQuery( context_support_->SignalQuery(
query, query,
...@@ -42,22 +42,16 @@ class SignalTest : public ContextTestBase { ...@@ -42,22 +42,16 @@ class SignalTest : public ContextTestBase {
}; };
CONTEXT_TEST_F(SignalTest, BasicSignalSyncTokenTest) { CONTEXT_TEST_F(SignalTest, BasicSignalSyncTokenTest) {
if (!context_) const GLuint64 fence_sync = gl_->InsertFenceSyncCHROMIUM();
return; gl_->ShallowFlushCHROMIUM();
const blink::WGC3Duint64 fence_sync = context_->insertFenceSyncCHROMIUM();
context_->GetGLInterface()->ShallowFlushCHROMIUM();
gpu::SyncToken sync_token; gpu::SyncToken sync_token;
ASSERT_TRUE(context_->genSyncTokenCHROMIUM(fence_sync, sync_token.GetData())); gl_->GenSyncTokenCHROMIUM(fence_sync, sync_token.GetData());
TestSignalSyncToken(sync_token); TestSignalSyncToken(sync_token);
}; };
CONTEXT_TEST_F(SignalTest, EmptySignalSyncTokenTest) { CONTEXT_TEST_F(SignalTest, EmptySignalSyncTokenTest) {
if (!context_)
return;
// Signalling something that doesn't exist should run the callback // Signalling something that doesn't exist should run the callback
// immediately. // immediately.
gpu::SyncToken sync_token; gpu::SyncToken sync_token;
...@@ -65,9 +59,6 @@ CONTEXT_TEST_F(SignalTest, EmptySignalSyncTokenTest) { ...@@ -65,9 +59,6 @@ CONTEXT_TEST_F(SignalTest, EmptySignalSyncTokenTest) {
}; };
CONTEXT_TEST_F(SignalTest, InvalidSignalSyncTokenTest) { CONTEXT_TEST_F(SignalTest, InvalidSignalSyncTokenTest) {
if (!context_)
return;
// Signalling something that doesn't exist should run the callback // Signalling something that doesn't exist should run the callback
// immediately. // immediately.
gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0,
...@@ -77,30 +68,23 @@ CONTEXT_TEST_F(SignalTest, InvalidSignalSyncTokenTest) { ...@@ -77,30 +68,23 @@ CONTEXT_TEST_F(SignalTest, InvalidSignalSyncTokenTest) {
}; };
CONTEXT_TEST_F(SignalTest, BasicSignalQueryTest) { CONTEXT_TEST_F(SignalTest, BasicSignalQueryTest) {
if (!context_) unsigned query;
return; gl_->GenQueriesEXT(1, &query);
gl_->BeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, query);
unsigned query = context_->createQueryEXT(); gl_->Finish();
context_->beginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, query); gl_->EndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM);
context_->finish();
context_->endQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM);
TestSignalQuery(query); TestSignalQuery(query);
context_->deleteQueryEXT(query); gl_->DeleteQueriesEXT(1, &query);
}; };
CONTEXT_TEST_F(SignalTest, SignalQueryUnboundTest) { CONTEXT_TEST_F(SignalTest, SignalQueryUnboundTest) {
if (!context_) GLuint query;
return; gl_->GenQueriesEXT(1, &query);
blink::WebGLId query = context_->createQueryEXT();
TestSignalQuery(query); TestSignalQuery(query);
context_->deleteQueryEXT(query); gl_->DeleteQueriesEXT(1, &query);
}; };
CONTEXT_TEST_F(SignalTest, InvalidSignalQueryUnboundTest) { CONTEXT_TEST_F(SignalTest, InvalidSignalQueryUnboundTest) {
if (!context_)
return;
// Signalling something that doesn't exist should run the callback // Signalling something that doesn't exist should run the callback
// immediately. // immediately.
TestSignalQuery(928729087); TestSignalQuery(928729087);
......
...@@ -7,31 +7,51 @@ ...@@ -7,31 +7,51 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h" #include "gpu/command_buffer/client/gl_in_process_context.h"
#include "gpu/command_buffer/client/gles2_implementation.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/gl/gl_surface.h" #include "ui/gl/gl_surface.h"
namespace { namespace {
using gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl;
class ContextTestBase : public testing::Test { class ContextTestBase : public testing::Test {
public: public:
void SetUp() override { void SetUp() override {
blink::WebGraphicsContext3D::Attributes attributes; gpu::gles2::ContextCreationAttribHelper attributes;
bool lose_context_when_out_of_memory = false; attributes.alpha_size = 8;
typedef WebGraphicsContext3DInProcessCommandBufferImpl WGC3DIPCBI; attributes.depth_size = 24;
context_ = WGC3DIPCBI::CreateOffscreenContext( attributes.red_size = 8;
attributes, lose_context_when_out_of_memory); attributes.green_size = 8;
context_->InitializeOnCurrentThread(); attributes.blue_size = 8;
context_support_ = context_->GetContextSupport(); attributes.stencil_size = 8;
attributes.samples = 4;
attributes.sample_buffers = 1;
attributes.bind_generates_resource = false;
context_.reset(gpu::GLInProcessContext::Create(
nullptr, /* service */
nullptr, /* surface */
true, /* offscreen */
gfx::kNullAcceleratedWidget, /* window */
gfx::Size(1, 1), /* size */
nullptr, /* share_context */
true, /* use_global_share_group */
attributes, gfx::PreferDiscreteGpu,
::gpu::GLInProcessContextSharedMemoryLimits(),
nullptr, /* gpu_memory_buffer_manager */
nullptr /* image_factory */));
gl_ = context_->GetImplementation();
context_support_ = context_->GetImplementation();
} }
void TearDown() override { context_.reset(NULL); } void TearDown() override { context_.reset(NULL); }
protected: protected:
scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context_; gpu::gles2::GLES2Interface* gl_;
gpu::ContextSupport* context_support_; gpu::ContextSupport* context_support_;
private:
scoped_ptr<gpu::GLInProcessContext> context_;
}; };
} // namespace } // namespace
......
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