| 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..77cd24c87a246f77d9f127cacd67c7d68126a47c 100644
|
| --- a/android_webview/browser/deferred_gpu_command_service.cc
|
| +++ b/android_webview/browser/deferred_gpu_command_service.cc
|
| @@ -6,17 +6,58 @@
|
|
|
| #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,
|
| + const blink::WebGraphicsContext3D::Attributes& attributes,
|
| + bool is_offscreen,
|
| + const gpu::GLInProcessContextSharedMemoryLimits& mem_limits) {
|
| + 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(
|
| + need_share_group_with_parent ? g_service.Get().get() : nullptr,
|
| + nullptr/* surface */,
|
| + is_offscreen,
|
| + gfx::kNullAcceleratedWidget,
|
| + gfx::Size(1, 1),
|
| + nullptr/* share_context */,
|
| + attributes.shareResources,
|
| + in_process_attribs,
|
| + gfx::PreferDiscreteGpu,
|
| + mem_limits,
|
| + nullptr,
|
| + nullptr));
|
| +
|
| + content::SynchronousCompositor::ContextHolder holder;
|
| + holder.context = context.get();
|
| + holder.context_provider = webkit::gpu::ContextProviderInProcess::Create(
|
| + gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext(
|
| + context.Pass(), attributes), std::string());
|
| + return holder;
|
| +}
|
| +
|
| } // namespace
|
|
|
| base::LazyInstance<base::ThreadLocalBoolean> ScopedAllowGL::allow_gl;
|
| @@ -50,7 +91,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));
|
| }
|
| }
|
|
|
|
|