Home | History | Annotate | Download | only in public
      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 UI_OZONE_PUBLIC_OZONE_PLATFORM_H_
      6 #define UI_OZONE_PUBLIC_OZONE_PLATFORM_H_
      7 
      8 #include "base/memory/scoped_ptr.h"
      9 #include "ui/ozone/ozone_export.h"
     10 
     11 namespace gfx {
     12 class Rect;
     13 }
     14 
     15 namespace ui {
     16 
     17 class CursorFactoryOzone;
     18 class NativeDisplayDelegate;
     19 class SurfaceFactoryOzone;
     20 class GpuPlatformSupport;
     21 class GpuPlatformSupportHost;
     22 class PlatformWindow;
     23 class PlatformWindowDelegate;
     24 
     25 // Base class for Ozone platform implementations.
     26 //
     27 // Ozone platforms must override this class and implement the virtual
     28 // GetFooFactoryOzone() methods to provide implementations of the
     29 // various ozone interfaces.
     30 //
     31 // The OzonePlatform subclass can own any state needed by the
     32 // implementation that is shared between the various ozone interfaces,
     33 // such as a connection to the windowing system.
     34 //
     35 // A platform is free to use different implementations of each
     36 // interface depending on the context. You can, for example, create
     37 // different objects depending on the underlying hardware, command
     38 // line flags, or whatever is appropriate for the platform.
     39 class OZONE_EXPORT OzonePlatform {
     40  public:
     41   OzonePlatform();
     42   virtual ~OzonePlatform();
     43 
     44   // Initializes the subsystems/resources necessary for the UI process (e.g.
     45   // events, surface, etc.)
     46   static void InitializeForUI();
     47 
     48   // Initializes the subsystems/resources necessary for the GPU process.
     49   static void InitializeForGPU();
     50 
     51   static OzonePlatform* GetInstance();
     52 
     53   // Factory getters to override in subclasses. The returned objects will be
     54   // injected into the appropriate layer at startup. Subclasses should not
     55   // inject these objects themselves. Ownership is retained by OzonePlatform.
     56   virtual ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() = 0;
     57   virtual ui::CursorFactoryOzone* GetCursorFactoryOzone() = 0;
     58   virtual ui::GpuPlatformSupport* GetGpuPlatformSupport() = 0;
     59   virtual ui::GpuPlatformSupportHost* GetGpuPlatformSupportHost() = 0;
     60   virtual scoped_ptr<PlatformWindow> CreatePlatformWindow(
     61       PlatformWindowDelegate* delegate,
     62       const gfx::Rect& bounds) = 0;
     63 #if defined(OS_CHROMEOS)
     64   virtual scoped_ptr<ui::NativeDisplayDelegate>
     65       CreateNativeDisplayDelegate() = 0;
     66 #endif
     67 
     68  private:
     69   virtual void InitializeUI() = 0;
     70   virtual void InitializeGPU() = 0;
     71 
     72   static void CreateInstance();
     73 
     74   static OzonePlatform* instance_;
     75 
     76   DISALLOW_COPY_AND_ASSIGN(OzonePlatform);
     77 };
     78 
     79 }  // namespace ui
     80 
     81 #endif  // UI_OZONE_PUBLIC_OZONE_PLATFORM_H_
     82