Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(371)

Unified Diff: webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc

Issue 14318004: Add option to use GLContextVirtual in WGC3DIPCBI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix after r195276 which uses CreateViewContext Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc
diff --git a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc
index ae1242252f6c8d29918a3f9796b53d81ec79e323..df0c5309eeab3d3b0c02a922b8fcc61a63839a7d 100644
--- a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc
+++ b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc
@@ -31,8 +31,9 @@
#include "gpu/command_buffer/common/constants.h"
#include "gpu/command_buffer/service/command_buffer_service.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/transfer_buffer_manager.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_share_group.h"
#include "ui/gl/gl_surface.h"
@@ -99,7 +100,8 @@ class GLInProcessContext {
bool share_resources,
const char* allowed_extensions,
const int32* attrib_list,
- gfx::GpuPreference gpu_preference);
+ gfx::GpuPreference gpu_preference,
+ bool use_virtualized_gl_context_if_possible);
// For an offscreen frame buffer GLInProcessContext, return the texture ID
// with respect to the parent GLInProcessContext. Returns zero if
@@ -150,7 +152,8 @@ class GLInProcessContext {
const gfx::Size& size,
const char* allowed_extensions,
const int32* attrib_list,
- gfx::GpuPreference gpu_preference);
+ gfx::GpuPreference gpu_preference,
+ bool use_virtualized_gl_context_if_possible);
void Destroy();
void OnContextLost();
@@ -214,7 +217,8 @@ GLInProcessContext* GLInProcessContext::CreateContext(
bool share_resources,
const char* allowed_extensions,
const int32* attrib_list,
- gfx::GpuPreference gpu_preference) {
+ gfx::GpuPreference gpu_preference,
+ bool use_virtualized_gl_context_if_possible) {
scoped_ptr<GLInProcessContext> context(
new GLInProcessContext(share_resources));
if (!context->Initialize(
@@ -223,7 +227,8 @@ GLInProcessContext* GLInProcessContext::CreateContext(
size,
allowed_extensions,
attrib_list,
- gpu_preference))
+ gpu_preference,
+ use_virtualized_gl_context_if_possible))
return NULL;
return context.release();
@@ -394,7 +399,8 @@ bool GLInProcessContext::Initialize(
const gfx::Size& size,
const char* allowed_extensions,
const int32* attrib_list,
- gfx::GpuPreference gpu_preference) {
+ gfx::GpuPreference gpu_preference,
+ bool use_virtualized_gl_context_if_possible) {
// Use one share group for all contexts.
CR_DEFINE_STATIC_LOCAL(scoped_refptr<gfx::GLShareGroup>, share_group,
(new gfx::GLShareGroup));
@@ -478,9 +484,31 @@ bool GLInProcessContext::Initialize(
return false;
}
- context_ = gfx::GLContext::CreateGLContext(share_group.get(),
- surface_.get(),
- gpu_preference);
+ if (use_virtualized_gl_context_if_possible) {
+ context_ = share_group->GetSharedContext();
+ 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;
+ }
+ }
+
+ if (!context_) {
+ context_ = gfx::GLContext::CreateGLContext(share_group.get(),
+ surface_.get(),
+ gpu_preference);
+ }
+
if (!context_.get()) {
LOG(ERROR) << "Could not create GLContext.";
Destroy();
@@ -588,9 +616,10 @@ void GLInProcessContext::OnContextLost() {
WebGraphicsContext3DInProcessCommandBufferImpl*
WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext(
const WebKit::WebGraphicsContext3D::Attributes& attributes,
- gfx::AcceleratedWidget window) {
+ gfx::AcceleratedWidget window,
+ bool use_virtualized_gl_context_if_possible) {
return new WebGraphicsContext3DInProcessCommandBufferImpl(
- attributes, false, window);
+ attributes, false, window, use_virtualized_gl_context_if_possible);
}
// static
@@ -598,16 +627,19 @@ WebGraphicsContext3DInProcessCommandBufferImpl*
WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext(
const WebKit::WebGraphicsContext3D::Attributes& attributes) {
return new WebGraphicsContext3DInProcessCommandBufferImpl(
- attributes, true, gfx::kNullAcceleratedWidget);
+ attributes, true, gfx::kNullAcceleratedWidget, false);
piman 2013/04/19 22:51:00 Why false here?
boliu 2013/04/19 22:53:22 Retaining old behavior to not use GLVirtualContext
}
WebGraphicsContext3DInProcessCommandBufferImpl::
WebGraphicsContext3DInProcessCommandBufferImpl(
const WebKit::WebGraphicsContext3D::Attributes& attributes,
bool is_offscreen,
- gfx::AcceleratedWidget window)
+ gfx::AcceleratedWidget window,
+ bool use_virtualized_gl_context_if_possible)
: is_offscreen_(is_offscreen),
window_(window),
+ use_virtualized_gl_context_if_possible_(
+ use_virtualized_gl_context_if_possible),
initialized_(false),
initialize_failed_(false),
context_(NULL),
@@ -663,7 +695,8 @@ bool WebGraphicsContext3DInProcessCommandBufferImpl::MaybeInitializeGL() {
attributes_.shareResources,
preferred_extensions,
attribs,
- gpu_preference);
+ gpu_preference,
+ use_virtualized_gl_context_if_possible_);
if (!context_) {
initialize_failed_ = true;
« no previous file with comments | « webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698