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( 37 int routing_id, 38 scoped_refptr<content::FrameSwapMessageQueue> frame_swap_message_queue) 39 OVERRIDE; 40 virtual InputHandlerManagerClient* GetInputHandlerManagerClient() OVERRIDE; 41 virtual scoped_refptr<webkit::gpu::ContextProviderWebContext> 42 CreateOffscreenContextProvider( 43 const blink::WebGraphicsContext3D::Attributes& attributes, 44 const std::string& debug_name) OVERRIDE; 45 virtual scoped_refptr<StreamTextureFactory> CreateStreamTextureFactory( 46 int view_id) OVERRIDE; 47 virtual webkit::gpu::WebGraphicsContext3DImpl* 48 CreateOffscreenGraphicsContext3D( 49 const blink::WebGraphicsContext3D::Attributes& attributes) OVERRIDE; 50 synchronous_input_event_filter()51 SynchronousInputEventFilter* synchronous_input_event_filter() { 52 return &synchronous_input_event_filter_; 53 } 54 55 void SetDeferredGpuService( 56 scoped_refptr<gpu::InProcessCommandBuffer::Service> service); 57 void SetRecordFullDocument(bool record_full_document); 58 void CompositorInitializedHardwareDraw(); 59 void CompositorReleasedHardwareDraw(); 60 61 scoped_refptr<cc::ContextProvider> 62 CreateOnscreenContextProviderForCompositorThread(); 63 64 private: 65 bool CanCreateMainThreadContext(); 66 scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider> 67 TryCreateStreamTextureFactory(); 68 void RestoreContextOnMainThread(); 69 70 SynchronousInputEventFilter synchronous_input_event_filter_; 71 72 scoped_refptr<gpu::InProcessCommandBuffer::Service> service_; 73 74 class VideoContextProvider; 75 scoped_refptr<VideoContextProvider> video_context_provider_; 76 77 bool record_full_layer_; 78 79 // |num_hardware_compositor_lock_| is updated on UI thread only but can be 80 // read on renderer main thread. 81 base::Lock num_hardware_compositor_lock_; 82 unsigned int num_hardware_compositors_; 83 scoped_refptr<base::MessageLoopProxy> main_thread_proxy_; 84 }; 85 86 } // namespace content 87 88 #endif // CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_FACTORY_IMPL_H_ 89