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 {
content::BrowserGpuChannelHostFactory* factory =
content::BrowserGpuChannelHostFactory::instance();
CHECK(factory);
bool lose_context_when_out_of_memory = false;
base::RunLoop run_loop;
factory->EstablishGpuChannel(kInitCause, run_loop.QuitClosure());
run_loop.Run();
scoped_refptr<content::GpuChannelHost>
gpu_channel_host(factory->GetGpuChannel());
DCHECK(gpu_channel_host.get());
context_.reset(
CHECK(gpu_channel_host.get());
bool lose_context_when_out_of_memory = false;
scoped_ptr<WebGraphicsContext3DCommandBufferImpl> web_context(
WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
gpu_channel_host.get(),
blink::WebGraphicsContext3D::Attributes(),
lose_context_when_out_of_memory,
GURL(),
gpu_channel_host.get(), blink::WebGraphicsContext3D::Attributes(),
lose_context_when_out_of_memory, GURL(),
WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(),
NULL));
CHECK(context_.get());
context_->InitializeOnCurrentThread();
context_support_ = context_->GetContextSupport();
nullptr));
provider_ = content::ContextProviderCommandBuffer::Create(
std::move(web_context), content::OFFSCREEN_CONTEXT_FOR_TESTING);
bool bound = provider_->BindToCurrentThread();
CHECK(bound);
gl_ = provider_->ContextGL();
context_support_ = provider_->ContextSupport();
ContentBrowserTest::SetUpOnMainThread();
}
void TearDownOnMainThread() override {
// Must delete the context first.
context_.reset(NULL);
provider_ = nullptr;
ContentBrowserTest::TearDownOnMainThread();
}
protected:
scoped_ptr<content::WebGraphicsContext3DCommandBufferImpl> context_;
gpu::gles2::GLES2Interface* gl_;
gpu::ContextSupport* context_support_;
private:
scoped_refptr<content::ContextProviderCommandBuffer> provider_;
};
} // namespace
......
......@@ -31,7 +31,7 @@ class SignalTest : public ContextTestBase {
}
// 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;
context_support_->SignalQuery(
query,
......@@ -42,22 +42,16 @@ class SignalTest : public ContextTestBase {
};
CONTEXT_TEST_F(SignalTest, BasicSignalSyncTokenTest) {
if (!context_)
return;
const blink::WGC3Duint64 fence_sync = context_->insertFenceSyncCHROMIUM();
context_->GetGLInterface()->ShallowFlushCHROMIUM();
const GLuint64 fence_sync = gl_->InsertFenceSyncCHROMIUM();
gl_->ShallowFlushCHROMIUM();
gpu::SyncToken sync_token;
ASSERT_TRUE(context_->genSyncTokenCHROMIUM(fence_sync, sync_token.GetData()));
gl_->GenSyncTokenCHROMIUM(fence_sync, sync_token.GetData());
TestSignalSyncToken(sync_token);
};
CONTEXT_TEST_F(SignalTest, EmptySignalSyncTokenTest) {
if (!context_)
return;
// Signalling something that doesn't exist should run the callback
// immediately.
gpu::SyncToken sync_token;
......@@ -65,9 +59,6 @@ CONTEXT_TEST_F(SignalTest, EmptySignalSyncTokenTest) {
};
CONTEXT_TEST_F(SignalTest, InvalidSignalSyncTokenTest) {
if (!context_)
return;
// Signalling something that doesn't exist should run the callback
// immediately.
gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0,
......@@ -77,30 +68,23 @@ CONTEXT_TEST_F(SignalTest, InvalidSignalSyncTokenTest) {
};
CONTEXT_TEST_F(SignalTest, BasicSignalQueryTest) {
if (!context_)
return;
unsigned query = context_->createQueryEXT();
context_->beginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, query);
context_->finish();
context_->endQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM);
unsigned query;
gl_->GenQueriesEXT(1, &query);
gl_->BeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, query);
gl_->Finish();
gl_->EndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM);
TestSignalQuery(query);
context_->deleteQueryEXT(query);
gl_->DeleteQueriesEXT(1, &query);
};
CONTEXT_TEST_F(SignalTest, SignalQueryUnboundTest) {
if (!context_)
return;
blink::WebGLId query = context_->createQueryEXT();
GLuint query;
gl_->GenQueriesEXT(1, &query);
TestSignalQuery(query);
context_->deleteQueryEXT(query);
gl_->DeleteQueriesEXT(1, &query);
};
CONTEXT_TEST_F(SignalTest, InvalidSignalQueryUnboundTest) {
if (!context_)
return;
// Signalling something that doesn't exist should run the callback
// immediately.
TestSignalQuery(928729087);
......
......@@ -7,31 +7,51 @@
#include <string>
#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 "ui/gl/gl_surface.h"
namespace {
using gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl;
class ContextTestBase : public testing::Test {
public:
void SetUp() override {
blink::WebGraphicsContext3D::Attributes attributes;
bool lose_context_when_out_of_memory = false;
typedef WebGraphicsContext3DInProcessCommandBufferImpl WGC3DIPCBI;
context_ = WGC3DIPCBI::CreateOffscreenContext(
attributes, lose_context_when_out_of_memory);
context_->InitializeOnCurrentThread();
context_support_ = context_->GetContextSupport();
gpu::gles2::ContextCreationAttribHelper attributes;
attributes.alpha_size = 8;
attributes.depth_size = 24;
attributes.red_size = 8;
attributes.green_size = 8;
attributes.blue_size = 8;
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); }
protected:
scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context_;
gpu::gles2::GLES2Interface* gl_;
gpu::ContextSupport* context_support_;
private:
scoped_ptr<gpu::GLInProcessContext> context_;
};
} // 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