Commit bbb936c4 authored by boliu@chromium.org's avatar boliu@chromium.org

Add option to use GLContextVirtual in WGC3DIPCBI

BUG=230195
win_x64_rel busted. All other bots passed
NOTRY=true

Review URL: https://chromiumcodereview.appspot.com/14318004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195398 0039d316-1c4b-4281-b951-d872f2087c98
parent fdc86497
...@@ -31,8 +31,9 @@ ...@@ -31,8 +31,9 @@
#include "gpu/command_buffer/common/constants.h" #include "gpu/command_buffer/common/constants.h"
#include "gpu/command_buffer/service/command_buffer_service.h" #include "gpu/command_buffer/service/command_buffer_service.h"
#include "gpu/command_buffer/service/context_group.h" #include "gpu/command_buffer/service/context_group.h"
#include "gpu/command_buffer/service/transfer_buffer_manager.h" #include "gpu/command_buffer/service/gl_context_virtual.h"
#include "gpu/command_buffer/service/gpu_scheduler.h" #include "gpu/command_buffer/service/gpu_scheduler.h"
#include "gpu/command_buffer/service/transfer_buffer_manager.h"
#include "ui/gl/gl_context.h" #include "ui/gl/gl_context.h"
#include "ui/gl/gl_share_group.h" #include "ui/gl/gl_share_group.h"
#include "ui/gl/gl_surface.h" #include "ui/gl/gl_surface.h"
...@@ -241,6 +242,8 @@ static base::LazyInstance< ...@@ -241,6 +242,8 @@ static base::LazyInstance<
std::set<GLInProcessContext*> > std::set<GLInProcessContext*> >
g_all_shared_contexts = LAZY_INSTANCE_INITIALIZER; g_all_shared_contexts = LAZY_INSTANCE_INITIALIZER;
static bool g_use_virtualized_gl_context = false;
namespace { namespace {
// Also calls DetachFromThread on all GLES2Decoders before the lock is released // Also calls DetachFromThread on all GLES2Decoders before the lock is released
...@@ -478,9 +481,29 @@ bool GLInProcessContext::Initialize( ...@@ -478,9 +481,29 @@ bool GLInProcessContext::Initialize(
return false; return false;
} }
context_ = gfx::GLContext::CreateGLContext(share_group.get(), if (g_use_virtualized_gl_context) {
surface_.get(), context_ = share_group->GetSharedContext();
gpu_preference); if (!context_) {
context_ = gfx::GLContext::CreateGLContext(share_group.get(),
surface_.get(),
gpu_preference);
share_group->SetSharedContext(context_);
}
context_ = new ::gpu::GLContextVirtual(share_group.get(),
context_,
decoder_->AsWeakPtr());
if (context_->Initialize(surface_, gpu_preference)) {
VLOG(1) << "Created virtual GL context.";
} else {
context_ = NULL;
}
} else {
context_ = gfx::GLContext::CreateGLContext(share_group.get(),
surface_.get(),
gpu_preference);
}
if (!context_.get()) { if (!context_.get()) {
LOG(ERROR) << "Could not create GLContext."; LOG(ERROR) << "Could not create GLContext.";
Destroy(); Destroy();
...@@ -583,6 +606,18 @@ void GLInProcessContext::OnContextLost() { ...@@ -583,6 +606,18 @@ void GLInProcessContext::OnContextLost() {
context_lost_callback_.Run(); context_lost_callback_.Run();
} }
// static
void
WebGraphicsContext3DInProcessCommandBufferImpl::EnableVirtualizedContext() {
#if !defined(NDEBUG)
{
AutoLockAndDecoderDetachThread lock(g_decoder_lock.Get(),
g_all_shared_contexts.Get());
DCHECK(g_all_shared_contexts.Get().empty());
}
#endif // !defined(NDEBUG)
g_use_virtualized_gl_context = true;
}
// static // static
WebGraphicsContext3DInProcessCommandBufferImpl* WebGraphicsContext3DInProcessCommandBufferImpl*
......
...@@ -45,6 +45,10 @@ class GLInProcessContext; ...@@ -45,6 +45,10 @@ class GLInProcessContext;
class WEBKIT_GPU_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl class WEBKIT_GPU_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl
: public NON_EXPORTED_BASE(WebKit::WebGraphicsContext3D) { : public NON_EXPORTED_BASE(WebKit::WebGraphicsContext3D) {
public: public:
// Must be called before any WebGraphicsContext3DInProcessCommandBufferImpl
// instances are created. Default value is false.
static void EnableVirtualizedContext();
static WebGraphicsContext3DInProcessCommandBufferImpl* static WebGraphicsContext3DInProcessCommandBufferImpl*
CreateViewContext( CreateViewContext(
const WebKit::WebGraphicsContext3D::Attributes& attributes, const WebKit::WebGraphicsContext3D::Attributes& attributes,
......
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