IndexedDBFactory now ForceCloses databases.
[chromium-blink-merge.git] / content / browser / android / in_process / synchronous_compositor_factory_impl.h
blob40bcbac57fd02a4c23c9e66eeb3e0f4961787a22
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_FACTORY_IMPL_H_
6 #define CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_FACTORY_IMPL_H_
8 #include "base/synchronization/lock.h"
9 #include "content/browser/android/in_process/synchronous_input_event_filter.h"
10 #include "content/renderer/android/synchronous_compositor_factory.h"
11 #include "content/renderer/media/android/stream_texture_factory_android_synchronous_impl.h"
13 namespace gpu {
14 class GLInProcessContext;
17 namespace webkit {
18 namespace gpu {
19 class WebGraphicsContext3DInProcessCommandBufferImpl;
23 namespace content {
25 class SynchronousCompositorFactoryImpl : public SynchronousCompositorFactory {
26 public:
27 SynchronousCompositorFactoryImpl();
28 virtual ~SynchronousCompositorFactoryImpl();
30 // SynchronousCompositorFactory
31 virtual scoped_refptr<base::MessageLoopProxy> GetCompositorMessageLoop()
32 OVERRIDE;
33 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(int routing_id)
34 OVERRIDE;
35 virtual InputHandlerManagerClient* GetInputHandlerManagerClient() OVERRIDE;
36 virtual scoped_refptr<cc::ContextProvider>
37 GetOffscreenContextProviderForMainThread() OVERRIDE;
38 // This is called on both renderer main thread (offscreen context creation
39 // path shared between cross-process and in-process platforms) and renderer
40 // compositor impl thread (InitializeHwDraw) in order to support Android
41 // WebView synchronously enable and disable hardware mode multiple times in
42 // the same task. This is ok because in-process WGC3D creation may happen on
43 // any thread and is lightweight.
44 virtual scoped_refptr<cc::ContextProvider>
45 GetOffscreenContextProviderForCompositorThread() OVERRIDE;
46 virtual scoped_ptr<StreamTextureFactory> CreateStreamTextureFactory(
47 int view_id) OVERRIDE;
49 SynchronousInputEventFilter* synchronous_input_event_filter() {
50 return &synchronous_input_event_filter_;
53 void CompositorInitializedHardwareDraw();
54 void CompositorReleasedHardwareDraw();
56 private:
57 void ReleaseGlobalHardwareResources();
58 bool CanCreateMainThreadContext();
59 scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider>
60 TryCreateStreamTextureFactory();
61 scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl>
62 CreateOffscreenContext();
64 SynchronousInputEventFilter synchronous_input_event_filter_;
66 // Only guards construction and destruction of
67 // |offscreen_context_for_compositor_thread_|, not usage.
68 base::Lock offscreen_context_for_compositor_thread_lock_;
69 scoped_refptr<cc::ContextProvider> offscreen_context_for_main_thread_;
70 // This is a pointer to the context owned by
71 // |offscreen_context_for_main_thread_|.
72 gpu::GLInProcessContext* wrapped_gl_context_for_main_thread_;
73 scoped_refptr<cc::ContextProvider> offscreen_context_for_compositor_thread_;
75 // |num_hardware_compositor_lock_| is updated on UI thread only but can be
76 // read on renderer main thread.
77 base::Lock num_hardware_compositor_lock_;
78 unsigned int num_hardware_compositors_;
81 } // namespace content
83 #endif // CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_FACTORY_IMPL_H_