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

Side by Side Diff: android_webview/browser/deferred_gpu_command_service.cc

Issue 920443003: Android: SetCreateContextCallback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reduce the diff Created 5 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "android_webview/browser/deferred_gpu_command_service.h" 5 #include "android_webview/browser/deferred_gpu_command_service.h"
6 6
7 #include "android_webview/browser/gl_view_renderer_manager.h" 7 #include "android_webview/browser/gl_view_renderer_manager.h"
8 #include "android_webview/browser/shared_renderer_state.h" 8 #include "android_webview/browser/shared_renderer_state.h"
9 #include "base/bind.h"
9 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
10 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
11 #include "base/trace_event/trace_event.h" 12 #include "base/trace_event/trace_event.h"
12 #include "content/public/browser/android/synchronous_compositor.h" 13 #include "content/public/browser/android/synchronous_compositor.h"
14 #include "gpu/blink/webgraphicscontext3d_impl.h"
15 #include "gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h"
16 #include "gpu/command_buffer/client/gl_in_process_context.h"
17 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
13 #include "gpu/command_buffer/service/shader_translator_cache.h" 18 #include "gpu/command_buffer/service/shader_translator_cache.h"
19 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
20 #include "webkit/common/gpu/context_provider_in_process.h"
14 21
15 namespace android_webview { 22 namespace android_webview {
16 23
17 namespace { 24 namespace {
25
18 base::LazyInstance<scoped_refptr<DeferredGpuCommandService> > 26 base::LazyInstance<scoped_refptr<DeferredGpuCommandService> >
19 g_service = LAZY_INSTANCE_INITIALIZER; 27 g_service = LAZY_INSTANCE_INITIALIZER;
28
29 content::SynchronousCompositor::ContextHolder GetContextHolder(
30 bool need_share_group_with_parent,
31 const blink::WebGraphicsContext3D::Attributes& attributes,
32 bool is_offscreen,
33 const gpu::GLInProcessContextSharedMemoryLimits& mem_limits) {
34 gpu::gles2::ContextCreationAttribHelper in_process_attribs;
35 gpu_blink::WebGraphicsContext3DImpl::ConvertAttributes(attributes,
36 &in_process_attribs);
37 in_process_attribs.lose_context_when_out_of_memory = true;
38
39 scoped_ptr<gpu::GLInProcessContext> context(gpu::GLInProcessContext::Create(
40 need_share_group_with_parent ? g_service.Get().get() : nullptr,
41 nullptr/* surface */,
42 is_offscreen,
43 gfx::kNullAcceleratedWidget,
44 gfx::Size(1, 1),
45 nullptr/* share_context */,
46 attributes.shareResources,
47 in_process_attribs,
48 gfx::PreferDiscreteGpu,
49 mem_limits,
50 nullptr,
51 nullptr));
52
53 content::SynchronousCompositor::ContextHolder holder;
54 holder.context = context.get();
55 holder.context_provider = webkit::gpu::ContextProviderInProcess::Create(
56 gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext(
57 context.Pass(), attributes), std::string());
58 return holder;
59 }
60
20 } // namespace 61 } // namespace
21 62
22 base::LazyInstance<base::ThreadLocalBoolean> ScopedAllowGL::allow_gl; 63 base::LazyInstance<base::ThreadLocalBoolean> ScopedAllowGL::allow_gl;
23 64
24 // static 65 // static
25 bool ScopedAllowGL::IsAllowed() { 66 bool ScopedAllowGL::IsAllowed() {
26 return allow_gl.Get().Get(); 67 return allow_gl.Get().Get();
27 } 68 }
28 69
29 ScopedAllowGL::ScopedAllowGL() { 70 ScopedAllowGL::ScopedAllowGL() {
(...skipping 13 matching lines...) Expand all
43 if (service->IdleQueueSize()) { 84 if (service->IdleQueueSize()) {
44 service->RequestProcessGL(); 85 service->RequestProcessGL();
45 } 86 }
46 } 87 }
47 } 88 }
48 89
49 // static 90 // static
50 void DeferredGpuCommandService::SetInstance() { 91 void DeferredGpuCommandService::SetInstance() {
51 if (!g_service.Get().get()) { 92 if (!g_service.Get().get()) {
52 g_service.Get() = new DeferredGpuCommandService; 93 g_service.Get() = new DeferredGpuCommandService;
53 content::SynchronousCompositor::SetGpuService(g_service.Get()); 94 content::SynchronousCompositor::SetCreateContextCallback(
95 base::Bind(&GetContextHolder));
54 } 96 }
55 } 97 }
56 98
57 // static 99 // static
58 DeferredGpuCommandService* DeferredGpuCommandService::GetInstance() { 100 DeferredGpuCommandService* DeferredGpuCommandService::GetInstance() {
59 DCHECK(g_service.Get().get()); 101 DCHECK(g_service.Get().get());
60 return g_service.Get().get(); 102 return g_service.Get().get();
61 } 103 }
62 104
63 DeferredGpuCommandService::DeferredGpuCommandService() {} 105 DeferredGpuCommandService::DeferredGpuCommandService() {}
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 218
177 void DeferredGpuCommandService::AddRef() const { 219 void DeferredGpuCommandService::AddRef() const {
178 base::RefCountedThreadSafe<DeferredGpuCommandService>::AddRef(); 220 base::RefCountedThreadSafe<DeferredGpuCommandService>::AddRef();
179 } 221 }
180 222
181 void DeferredGpuCommandService::Release() const { 223 void DeferredGpuCommandService::Release() const {
182 base::RefCountedThreadSafe<DeferredGpuCommandService>::Release(); 224 base::RefCountedThreadSafe<DeferredGpuCommandService>::Release();
183 } 225 }
184 226
185 } // namespace android_webview 227 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/browser/DEPS ('k') | content/browser/android/in_process/synchronous_compositor_factory_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698