Home | History | Annotate | Download | only in android
      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 
     11 namespace base {
     12 class MessageLoopProxy;
     13 }
     14 
     15 namespace cc {
     16 class ContextProvider;
     17 class OutputSurface;
     18 }
     19 
     20 namespace content {
     21 
     22 class InputHandlerManagerClient;
     23 class StreamTextureFactory;
     24 
     25 // Decouples creation from usage of the parts needed for the synchonous
     26 // compositor rendering path. In practice this is only used in single
     27 // process mode (namely, for Android WebView) hence the implementation of
     28 // this will be injected from the logical 'browser' side code.
     29 class SynchronousCompositorFactory {
     30  public:
     31   // Must only be called once, e.g. on startup. Ownership of |instance| remains
     32   // with the caller.
     33   static void SetInstance(SynchronousCompositorFactory* instance);
     34   static SynchronousCompositorFactory* GetInstance();
     35 
     36   virtual scoped_refptr<base::MessageLoopProxy>
     37       GetCompositorMessageLoop() = 0;
     38   virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(
     39       int routing_id) = 0;
     40 
     41   // The factory maintains ownership of the returned interface.
     42   virtual InputHandlerManagerClient* GetInputHandlerManagerClient() = 0;
     43 
     44   virtual scoped_refptr<cc::ContextProvider>
     45       GetOffscreenContextProviderForMainThread() = 0;
     46   virtual scoped_refptr<cc::ContextProvider>
     47       GetOffscreenContextProviderForCompositorThread() = 0;
     48   virtual scoped_ptr<StreamTextureFactory> CreateStreamTextureFactory(
     49       int view_id) = 0;
     50 
     51  protected:
     52   SynchronousCompositorFactory() {}
     53   ~SynchronousCompositorFactory() {}
     54 };
     55 
     56 }
     57 
     58 #endif  // CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_FACTORY_H_
     59