OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_BASE_OZONE_SURFACE_LNUX_FACTORY_OZONE_H_ | 5 #ifndef UI_BASE_OZONE_SURFACE_LNUX_FACTORY_OZONE_H_ |
6 #define UI_BASE_OZONE_SURFACE_LNUX_FACTORY_OZONE_H_ | 6 #define UI_BASE_OZONE_SURFACE_LNUX_FACTORY_OZONE_H_ |
7 | 7 |
8 #include "ui/base/ui_export.h" | 8 #include "ui/base/ui_export.h" |
9 #include "ui/gfx/native_widget_types.h" | 9 #include "ui/gfx/native_widget_types.h" |
10 #include "ui/gfx/rect.h" | 10 #include "ui/gfx/rect.h" |
11 | 11 |
12 namespace gfx { | 12 namespace gfx { |
13 class Screen; | 13 class Screen; |
14 class VSyncProvider; | 14 class VSyncProvider; |
15 } // namespace gfx | 15 } // namespace gfx |
16 | 16 |
17 namespace ui { | 17 namespace ui { |
18 | 18 |
19 class UI_EXPORT SurfaceFactoryOzone { | 19 class UI_EXPORT SurfaceFactoryOzone { |
20 public: | 20 public: |
21 // Describes the state of the hardware after initialization. | |
22 enum HardwareState { | |
23 INITIALIZED, | |
24 FAILED, | |
25 }; | |
26 | |
21 SurfaceFactoryOzone(); | 27 SurfaceFactoryOzone(); |
22 virtual ~SurfaceFactoryOzone(); | 28 virtual ~SurfaceFactoryOzone(); |
23 | 29 |
24 // Returns the instance | 30 // Returns the instance |
25 static SurfaceFactoryOzone* GetInstance(); | 31 static SurfaceFactoryOzone* GetInstance(); |
26 | 32 |
27 // Returns a display spec as in |CreateDisplayFromSpec| for the default | 33 // Returns a display spec as in |CreateDisplayFromSpec| for the default |
28 // native surface. | 34 // native surface. |
29 virtual const char* DefaultDisplaySpec(); | 35 virtual const char* DefaultDisplaySpec(); |
30 | 36 |
31 // Sets the implementation delegate. Ownership is retained by the caller. | 37 // Sets the implementation delegate. Ownership is retained by the caller. |
32 static void SetInstance(SurfaceFactoryOzone* impl); | 38 static void SetInstance(SurfaceFactoryOzone* impl); |
33 | 39 |
34 // TODO(rjkroege): decide how to separate screen/display stuff from SFOz | 40 // TODO(rjkroege): decide how to separate screen/display stuff from SFOz |
35 // This method implements gfx::Screen, particularly useful in Desktop Aura. | 41 // This method implements gfx::Screen, particularly useful in Desktop Aura. |
36 virtual gfx::Screen* CreateDesktopScreen(); | 42 virtual gfx::Screen* CreateDesktopScreen(); |
37 | 43 |
38 // TODO(rjkroege): Add a status code if necessary. | |
39 // Configures the display hardware. Must be called from within the GPU | 44 // Configures the display hardware. Must be called from within the GPU |
40 // process before the sandbox has been activated. | 45 // process before the sandbox has been activated. |
41 virtual void InitializeHardware() = 0; | 46 virtual HardwareState InitializeHardware() = 0; |
42 | 47 |
43 // Cleans up display hardware state. Call this from within the GPU process. | 48 // Cleans up display hardware state. Call this from within the GPU process. |
44 // This method must be safe to run inside of the sandbox. | 49 // This method must be safe to run inside of the sandbox. |
45 virtual void ShutdownHardware() = 0; | 50 virtual void ShutdownHardware() = 0; |
46 | 51 |
52 // Returns the native EGL display. This is generally needed in creating | |
53 // EGL windows. | |
54 virtual intptr_t GetNativeDisplay(); | |
55 | |
47 // Obtains an AcceleratedWidget backed by a native Linux framebuffer. | 56 // Obtains an AcceleratedWidget backed by a native Linux framebuffer. |
48 // The returned AcceleratedWidget is an opaque token that must realized | 57 // The returned AcceleratedWidget is an opaque token that must realized |
49 // before it can be used to create a GL surface. | 58 // before it can be used to create a GL surface. |
50 virtual gfx::AcceleratedWidget GetAcceleratedWidget() = 0; | 59 virtual gfx::AcceleratedWidget GetAcceleratedWidget() = 0; |
51 | 60 |
52 // Realizes an AcceleratedWidget so that the returned AcceleratedWidget | 61 // Realizes an AcceleratedWidget so that the returned AcceleratedWidget |
53 // can be used to to create a GLSurface. This method may only be called in | 62 // can be used to to create a GLSurface. This method may only be called in |
54 // a process that has a valid GL context. | 63 // a process that has a valid GL context. |
55 virtual gfx::AcceleratedWidget RealizeAcceleratedWidget( | 64 virtual gfx::AcceleratedWidget RealizeAcceleratedWidget( |
56 gfx::AcceleratedWidget w) = 0; | 65 gfx::AcceleratedWidget w) = 0; |
57 | 66 |
58 // Sets up GL bindings for the native surface. | 67 // Sets up GL bindings for the native surface. |
59 virtual bool LoadEGLGLES2Bindings() = 0; | 68 virtual bool LoadEGLGLES2Bindings() = 0; |
60 | 69 |
61 // If possible attempts to resize the given AcceleratedWidget instance and if | 70 // If possible attempts to resize the given AcceleratedWidget instance and if |
62 // a resize action was performed returns true, otherwise false (native | 71 // a resize action was performed returns true, otherwise false (native |
63 // hardware may only support a single fixed size). | 72 // hardware may only support a single fixed size). |
64 virtual bool AttemptToResizeAcceleratedWidget( | 73 virtual bool AttemptToResizeAcceleratedWidget( |
65 gfx::AcceleratedWidget w, | 74 gfx::AcceleratedWidget w, |
66 const gfx::Rect& bounds) = 0; | 75 const gfx::Rect& bounds) = 0; |
67 | 76 |
77 // Called after the appropriate GL swap buffers command. Used if extra work | |
rjkroege
2013/08/30 15:26:04
I realize it's been a bit of contentious discussio
| |
78 // is needed to perform the actual buffer swap. | |
79 virtual bool SchedulePageFlip(gfx::AcceleratedWidget w); | |
80 | |
68 // Returns a gfx::VsyncProvider for the provided AcceleratedWidget. Note | 81 // Returns a gfx::VsyncProvider for the provided AcceleratedWidget. Note |
69 // that this may be called after we have entered the sandbox so if there are | 82 // that this may be called after we have entered the sandbox so if there are |
70 // operations (e.g. opening a file descriptor providing vsync events) that | 83 // operations (e.g. opening a file descriptor providing vsync events) that |
71 // must be done outside of the sandbox, they must have been completed | 84 // must be done outside of the sandbox, they must have been completed |
72 // in InitializeHardware. Returns NULL on error. | 85 // in InitializeHardware. Returns NULL on error. |
73 virtual gfx::VSyncProvider* GetVSyncProvider(gfx::AcceleratedWidget w) = 0; | 86 virtual gfx::VSyncProvider* GetVSyncProvider(gfx::AcceleratedWidget w) = 0; |
74 | 87 |
75 // Create a default SufaceFactoryOzone implementation useful for tests. | 88 // Create a default SufaceFactoryOzone implementation useful for tests. |
76 static SurfaceFactoryOzone* CreateTestHelper(); | 89 static SurfaceFactoryOzone* CreateTestHelper(); |
77 | 90 |
78 private: | 91 private: |
79 static SurfaceFactoryOzone* impl_; // not owned | 92 static SurfaceFactoryOzone* impl_; // not owned |
80 }; | 93 }; |
81 | 94 |
82 } // namespace ui | 95 } // namespace ui |
83 | 96 |
84 | |
85 #endif // UI_BASE_OZONE_SURFACE_LNUX_FACTORY_OZONE_H_ | 97 #endif // UI_BASE_OZONE_SURFACE_LNUX_FACTORY_OZONE_H_ |
OLD | NEW |