Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef UI_BASE_OZONE_SURFACE_LNUX_FACTORY_OZONE_H_ |
| 6 | #define UI_BASE_OZONE_SURFACE_LNUX_FACTORY_OZONE_H_ |
| 7 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 8 | #include "ui/base/ui_export.h" |
| 9 | #include "ui/gfx/native_widget_types.h" |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 10 | #include "ui/gfx/rect.h" |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 11 | |
| 12 | namespace gfx { |
| 13 | class VSyncProvider; |
| 14 | } // namespace gfx |
| 15 | |
| 16 | namespace ui { |
| 17 | |
| 18 | class SurfaceFactoryOzone { |
| 19 | public: |
| 20 | SurfaceFactoryOzone(); |
| 21 | virtual ~SurfaceFactoryOzone(); |
| 22 | |
| 23 | // Returns the instance |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 24 | UI_EXPORT static SurfaceFactoryOzone* GetInstance(); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 25 | |
| 26 | // Returns a display spec as in |CreateDisplayFromSpec| for the default |
| 27 | // native surface. |
| 28 | virtual const char* DefaultDisplaySpec(); |
| 29 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 30 | // Sets the implementation delegate. Ownership is retained by the caller. |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 31 | UI_EXPORT static void SetInstance(SurfaceFactoryOzone* impl); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 32 | |
| 33 | // TODO(rjkroege): Add a status code if necessary. |
| 34 | // Configures the display hardware. Must be called from within the GPU |
| 35 | // process before the sandbox has been activated. |
| 36 | virtual void InitializeHardware() = 0; |
| 37 | |
| 38 | // Cleans up display hardware state. Call this from within the GPU process. |
| 39 | // This method must be safe to run inside of the sandbox. |
| 40 | virtual void ShutdownHardware() = 0; |
| 41 | |
| 42 | // Obtains an AcceleratedWidget backed by a native Linux framebuffer. |
| 43 | // The returned AcceleratedWidget is an opaque token that must realized |
| 44 | // before it can be used to create a GL surface. |
| 45 | virtual gfx::AcceleratedWidget GetAcceleratedWidget() = 0; |
| 46 | |
| 47 | // Realizes an AcceleratedWidget so that the returned AcceleratedWidget |
| 48 | // can be used to to create a GLSurface. This method may only be called in |
| 49 | // a process that has a valid GL context. |
| 50 | virtual gfx::AcceleratedWidget RealizeAcceleratedWidget( |
| 51 | gfx::AcceleratedWidget w) = 0; |
| 52 | |
| 53 | // Sets up GL bindings for the native surface. |
| 54 | virtual bool LoadEGLGLES2Bindings() = 0; |
| 55 | |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 56 | // If possible attempts to resize the given AcceleratedWidget instance and if |
| 57 | // a resize action was performed returns true, otherwise false (native |
| 58 | // hardware may only support a single fixed size). |
| 59 | virtual bool AttemptToResizeAcceleratedWidget( |
| 60 | gfx::AcceleratedWidget w, |
| 61 | const gfx::Rect& bounds) = 0; |
| 62 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 63 | // Returns a gfx::VsyncProvider for the provided AcceleratedWidget. Note |
| 64 | // that this may be called after we have entered the sandbox so if there are |
| 65 | // operations (e.g. opening a file descriptor providing vsync events) that |
| 66 | // must be done outside of the sandbox, they must have been completed |
| 67 | // in InitializeHardware. Returns NULL on error. |
| 68 | virtual gfx::VSyncProvider* GetVSyncProvider(gfx::AcceleratedWidget w) = 0; |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 69 | |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 70 | // Create a default SufaceFactoryOzone implementation useful for tests. |
| 71 | UI_EXPORT static SurfaceFactoryOzone* CreateTestHelper(); |
| 72 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 73 | private: |
| 74 | static SurfaceFactoryOzone* impl_; // not owned |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | } // namespace ui |
| 78 | |
| 79 | |
| 80 | #endif // UI_BASE_OZONE_SURFACE_LNUX_FACTORY_OZONE_H_ |