OLD | NEW |
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 #ifndef CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_FACTORY_IMPL_H
_ | 5 #ifndef CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_FACTORY_IMPL_H
_ |
6 #define CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_FACTORY_IMPL_H
_ | 6 #define CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_FACTORY_IMPL_H
_ |
7 | 7 |
8 #include "base/synchronization/lock.h" | 8 #include "base/synchronization/lock.h" |
9 #include "content/browser/android/in_process/synchronous_input_event_filter.h" | 9 #include "content/browser/android/in_process/synchronous_input_event_filter.h" |
10 #include "content/renderer/android/synchronous_compositor_factory.h" | 10 #include "content/renderer/android/synchronous_compositor_factory.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 virtual ~SynchronousCompositorFactoryImpl(); | 34 virtual ~SynchronousCompositorFactoryImpl(); |
35 | 35 |
36 // SynchronousCompositorFactory | 36 // SynchronousCompositorFactory |
37 virtual scoped_refptr<base::MessageLoopProxy> GetCompositorMessageLoop() | 37 virtual scoped_refptr<base::MessageLoopProxy> GetCompositorMessageLoop() |
38 OVERRIDE; | 38 OVERRIDE; |
39 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(int routing_id) | 39 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(int routing_id) |
40 OVERRIDE; | 40 OVERRIDE; |
41 virtual InputHandlerManagerClient* GetInputHandlerManagerClient() OVERRIDE; | 41 virtual InputHandlerManagerClient* GetInputHandlerManagerClient() OVERRIDE; |
42 virtual scoped_refptr<webkit::gpu::ContextProviderWebContext> | 42 virtual scoped_refptr<webkit::gpu::ContextProviderWebContext> |
43 GetSharedOffscreenContextProviderForMainThread() OVERRIDE; | 43 GetSharedOffscreenContextProviderForMainThread() OVERRIDE; |
44 // This is called on both renderer main thread (offscreen context creation | |
45 // path shared between cross-process and in-process platforms) and renderer | |
46 // compositor impl thread (InitializeHwDraw) in order to support Android | |
47 // WebView synchronously enable and disable hardware mode multiple times in | |
48 // the same task. This is ok because in-process WGC3D creation may happen on | |
49 // any thread and is lightweight. | |
50 virtual scoped_refptr<cc::ContextProvider> | |
51 GetOffscreenContextProviderForCompositorThread() OVERRIDE; | |
52 virtual scoped_refptr<StreamTextureFactory> CreateStreamTextureFactory( | 44 virtual scoped_refptr<StreamTextureFactory> CreateStreamTextureFactory( |
53 int view_id) OVERRIDE; | 45 int view_id) OVERRIDE; |
54 virtual blink::WebGraphicsContext3D* CreateOffscreenGraphicsContext3D( | 46 virtual blink::WebGraphicsContext3D* CreateOffscreenGraphicsContext3D( |
55 const blink::WebGraphicsContext3D::Attributes& attributes) OVERRIDE; | 47 const blink::WebGraphicsContext3D::Attributes& attributes) OVERRIDE; |
56 | 48 |
| 49 // This is called on the renderer compositor impl thread (InitializeHwDraw) in |
| 50 // order to support Android WebView synchronously enable and disable hardware |
| 51 // mode multiple times in the same task. |
| 52 scoped_refptr<cc::ContextProvider> |
| 53 GetOffscreenContextProviderForCompositorThread(); |
| 54 |
57 SynchronousInputEventFilter* synchronous_input_event_filter() { | 55 SynchronousInputEventFilter* synchronous_input_event_filter() { |
58 return &synchronous_input_event_filter_; | 56 return &synchronous_input_event_filter_; |
59 } | 57 } |
60 | 58 |
61 void SetDeferredGpuService( | 59 void SetDeferredGpuService( |
62 scoped_refptr<gpu::InProcessCommandBuffer::Service> service); | 60 scoped_refptr<gpu::InProcessCommandBuffer::Service> service); |
63 void CompositorInitializedHardwareDraw(); | 61 void CompositorInitializedHardwareDraw(); |
64 void CompositorReleasedHardwareDraw(); | 62 void CompositorReleasedHardwareDraw(); |
65 | 63 |
66 scoped_refptr<cc::ContextProvider> | 64 scoped_refptr<cc::ContextProvider> |
67 CreateOnscreenContextProviderForCompositorThread( | 65 CreateOnscreenContextProviderForCompositorThread( |
68 scoped_refptr<gfx::GLSurface> surface); | 66 scoped_refptr<gfx::GLSurface> surface); |
69 | 67 |
70 private: | 68 private: |
71 bool CanCreateMainThreadContext(); | 69 bool CanCreateMainThreadContext(); |
72 scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider> | 70 scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider> |
73 TryCreateStreamTextureFactory(); | 71 TryCreateStreamTextureFactory(); |
74 | 72 |
75 SynchronousInputEventFilter synchronous_input_event_filter_; | 73 SynchronousInputEventFilter synchronous_input_event_filter_; |
76 | 74 |
77 // Only guards construction and destruction of | |
78 // |offscreen_context_for_compositor_thread_|, not usage. | |
79 base::Lock offscreen_context_for_compositor_thread_lock_; | |
80 scoped_refptr<webkit::gpu::ContextProviderWebContext> | 75 scoped_refptr<webkit::gpu::ContextProviderWebContext> |
81 offscreen_context_for_main_thread_; | 76 offscreen_context_for_main_thread_; |
82 // This is a pointer to the context owned by | 77 // This is a pointer to the context owned by |
83 // |offscreen_context_for_main_thread_|. | 78 // |offscreen_context_for_main_thread_|. |
84 gpu::GLInProcessContext* wrapped_gl_context_for_compositor_thread_; | 79 gpu::GLInProcessContext* wrapped_gl_context_for_compositor_thread_; |
85 scoped_refptr<cc::ContextProvider> offscreen_context_for_compositor_thread_; | 80 scoped_refptr<cc::ContextProvider> offscreen_context_for_compositor_thread_; |
86 | 81 |
87 scoped_refptr<gpu::InProcessCommandBuffer::Service> service_; | 82 scoped_refptr<gpu::InProcessCommandBuffer::Service> service_; |
88 scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider> | 83 scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider> |
89 video_context_provider_; | 84 video_context_provider_; |
90 | 85 |
91 // |num_hardware_compositor_lock_| is updated on UI thread only but can be | 86 // |num_hardware_compositor_lock_| is updated on UI thread only but can be |
92 // read on renderer main thread. | 87 // read on renderer main thread. |
93 base::Lock num_hardware_compositor_lock_; | 88 base::Lock num_hardware_compositor_lock_; |
94 unsigned int num_hardware_compositors_; | 89 unsigned int num_hardware_compositors_; |
95 }; | 90 }; |
96 | 91 |
97 } // namespace content | 92 } // namespace content |
98 | 93 |
99 #endif // CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_FACTORY_IMP
L_H_ | 94 #endif // CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_FACTORY_IMP
L_H_ |
OLD | NEW |