Index: android_webview/browser/deferred_gpu_command_service.cc |
diff --git a/android_webview/browser/deferred_gpu_command_service.cc b/android_webview/browser/deferred_gpu_command_service.cc |
index 0bcb3afdcc3147d7d43f263160a4c435947b854d..a0ed04ac214484db1324fc31ed7571c1375d4fa4 100644 |
--- a/android_webview/browser/deferred_gpu_command_service.cc |
+++ b/android_webview/browser/deferred_gpu_command_service.cc |
@@ -6,17 +6,60 @@ |
#include "android_webview/browser/gl_view_renderer_manager.h" |
#include "android_webview/browser/shared_renderer_state.h" |
+#include "base/bind.h" |
#include "base/lazy_instance.h" |
#include "base/synchronization/lock.h" |
#include "base/trace_event/trace_event.h" |
#include "content/public/browser/android/synchronous_compositor.h" |
+#include "gpu/blink/webgraphicscontext3d_impl.h" |
+#include "gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h" |
+#include "gpu/command_buffer/client/gl_in_process_context.h" |
+#include "gpu/command_buffer/common/gles2_cmd_utils.h" |
#include "gpu/command_buffer/service/shader_translator_cache.h" |
+#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
+#include "webkit/common/gpu/context_provider_in_process.h" |
namespace android_webview { |
namespace { |
+ |
base::LazyInstance<scoped_refptr<DeferredGpuCommandService> > |
g_service = LAZY_INSTANCE_INITIALIZER; |
+ |
+content::SynchronousCompositor::ContextHolder GetContextHolder( |
+ bool need_share_group_with_parent, |
tfarina
2015/02/24 17:02:34
What I do with this?
boliu
2015/02/24 21:52:57
If true, pass g_service as the first parameter to
tfarina
2015/02/24 22:10:12
Done.
|
+ const blink::WebGraphicsContext3D::Attributes& attributes, |
+ bool is_offscreen, |
+ const gpu::GLInProcessContextSharedMemoryLimits& mem_limits) { |
+ content::SynchronousCompositor::ContextHolder holder; |
+ |
+ gpu::gles2::ContextCreationAttribHelper in_process_attribs; |
+ gpu_blink::WebGraphicsContext3DImpl::ConvertAttributes(attributes, |
+ &in_process_attribs); |
+ in_process_attribs.lose_context_when_out_of_memory = true; |
+ |
+ scoped_ptr<gpu::GLInProcessContext> context(gpu::GLInProcessContext::Create( |
+ NULL /* service */, |
+ NULL /* surface */, |
+ is_offscreen, |
+ gfx::kNullAcceleratedWidget, |
+ gfx::Size(1, 1), |
+ NULL /* share_context */, |
+ attributes.shareResources, |
+ in_process_attribs, |
+ gfx::PreferDiscreteGpu, |
+ mem_limits, |
+ nullptr, |
+ nullptr)); |
+ |
+ holder.context_provider = webkit::gpu::ContextProviderInProcess::Create( |
+ gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext( |
+ context.Pass(), attributes), std::string()); |
+ |
+ holder.context = context.get(); |
boliu
2015/02/24 21:52:57
You already called context.Pass() 2 lines above, s
tfarina
2015/02/24 22:10:12
Done.
|
+ return holder; |
+} |
+ |
} // namespace |
base::LazyInstance<base::ThreadLocalBoolean> ScopedAllowGL::allow_gl; |
@@ -50,7 +93,8 @@ ScopedAllowGL::~ScopedAllowGL() { |
void DeferredGpuCommandService::SetInstance() { |
if (!g_service.Get().get()) { |
g_service.Get() = new DeferredGpuCommandService; |
- content::SynchronousCompositor::SetGpuService(g_service.Get()); |
+ content::SynchronousCompositor::SetCreateContextCallback( |
+ base::Bind(&GetContextHolder)); |
} |
} |