Home | History | Annotate | Download | only in in_process
      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.
      4 
      5 #ifndef CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_FACTORY_IMPL_H_
      6 #define CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_FACTORY_IMPL_H_
      7 
      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_synchronous_impl.h"
     12 #include "gpu/command_buffer/service/in_process_command_buffer.h"
     13 #include "webkit/common/gpu/context_provider_web_context.h"
     14 
     15 namespace gpu {
     16 class GLInProcessContext;
     17 }
     18 
     19 namespace webkit {
     20 namespace gpu {
     21 class WebGraphicsContext3DInProcessCommandBufferImpl;
     22 }
     23 }
     24 
     25 namespace content {
     26 
     27 class SynchronousCompositorFactoryImpl : public SynchronousCompositorFactory {
     28  public:
     29   SynchronousCompositorFactoryImpl();
     30   virtual ~SynchronousCompositorFactoryImpl();
     31 
     32   // SynchronousCompositorFactory
     33   virtual scoped_refptr<base::MessageLoopProxy> GetCompositorMessageLoop()
     34       OVERRIDE;
     35   virtual bool RecordFullLayer() OVERRIDE;
     36   virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(int routing_id)
     37       OVERRIDE;
     38   virtual InputHandlerManagerClient* GetInputHandlerManagerClient() OVERRIDE;
     39   virtual scoped_refptr<webkit::gpu::ContextProviderWebContext>
     40       GetSharedOffscreenContextProviderForMainThread() OVERRIDE;
     41   virtual scoped_refptr<StreamTextureFactory> CreateStreamTextureFactory(
     42       int view_id) OVERRIDE;
     43   virtual blink::WebGraphicsContext3D* CreateOffscreenGraphicsContext3D(
     44       const blink::WebGraphicsContext3D::Attributes& attributes) OVERRIDE;
     45 
     46 
     47   SynchronousInputEventFilter* synchronous_input_event_filter() {
     48     return &synchronous_input_event_filter_;
     49   }
     50 
     51   void SetDeferredGpuService(
     52       scoped_refptr<gpu::InProcessCommandBuffer::Service> service);
     53   void SetRecordFullDocument(bool record_full_document);
     54   void CompositorInitializedHardwareDraw();
     55   void CompositorReleasedHardwareDraw();
     56 
     57   scoped_refptr<cc::ContextProvider>
     58       CreateOnscreenContextProviderForCompositorThread();
     59   gpu::GLInProcessContext* GetShareContext();
     60 
     61  private:
     62   bool CanCreateMainThreadContext();
     63   scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider>
     64       TryCreateStreamTextureFactory();
     65   void RestoreContextOnMainThread();
     66 
     67   SynchronousInputEventFilter synchronous_input_event_filter_;
     68 
     69   scoped_refptr<webkit::gpu::ContextProviderWebContext>
     70       offscreen_context_for_main_thread_;
     71 
     72   scoped_refptr<gpu::InProcessCommandBuffer::Service> service_;
     73   scoped_ptr<gpu::GLInProcessContext> share_context_;
     74 
     75   class VideoContextProvider;
     76   scoped_refptr<VideoContextProvider> video_context_provider_;
     77 
     78   bool record_full_layer_;
     79 
     80   // |num_hardware_compositor_lock_| is updated on UI thread only but can be
     81   // read on renderer main thread.
     82   base::Lock num_hardware_compositor_lock_;
     83   unsigned int num_hardware_compositors_;
     84   scoped_refptr<base::MessageLoopProxy> main_thread_proxy_;
     85 };
     86 
     87 }  // namespace content
     88 
     89 #endif  // CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_FACTORY_IMPL_H_
     90