1// Copyright 2013 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_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_FACTORY_H_ 6#define CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_FACTORY_H_ 7 8#include "base/memory/ref_counted.h" 9#include "base/memory/scoped_ptr.h" 10#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" 11 12namespace base { 13class MessageLoopProxy; 14} 15 16namespace cc { 17class ContextProvider; 18class OutputSurface; 19} 20 21namespace webkit { 22namespace gpu { 23class ContextProviderWebContext; 24class WebGraphicsContext3DImpl; 25} 26} 27 28namespace content { 29 30class InputHandlerManagerClient; 31class StreamTextureFactory; 32class FrameSwapMessageQueue; 33 34// Decouples creation from usage of the parts needed for the synchonous 35// compositor rendering path. In practice this is only used in single 36// process mode (namely, for Android WebView) hence the implementation of 37// this will be injected from the logical 'browser' side code. 38class SynchronousCompositorFactory { 39 public: 40 // Must only be called once, e.g. on startup. Ownership of |instance| remains 41 // with the caller. 42 static void SetInstance(SynchronousCompositorFactory* instance); 43 static SynchronousCompositorFactory* GetInstance(); 44 45 virtual scoped_refptr<base::MessageLoopProxy> 46 GetCompositorMessageLoop() = 0; 47 virtual bool RecordFullLayer() = 0; 48 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface( 49 int routing_id, 50 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue) = 0; 51 52 // The factory maintains ownership of the returned interface. 53 virtual InputHandlerManagerClient* GetInputHandlerManagerClient() = 0; 54 55 virtual scoped_refptr<webkit::gpu::ContextProviderWebContext> 56 CreateOffscreenContextProvider( 57 const blink::WebGraphicsContext3D::Attributes& attributes, 58 const std::string& debug_name) = 0; 59 virtual scoped_refptr<StreamTextureFactory> CreateStreamTextureFactory( 60 int frame_id) = 0; 61 virtual webkit::gpu::WebGraphicsContext3DImpl* 62 CreateOffscreenGraphicsContext3D( 63 const blink::WebGraphicsContext3D::Attributes& attributes) = 0; 64 65 protected: 66 SynchronousCompositorFactory() {} 67 virtual ~SynchronousCompositorFactory() {} 68}; 69 70} 71 72#endif // CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_FACTORY_H_ 73