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