blob: 50a9b4bdf59bf49be668dfa47d662cb8ccc5778e [file] [log] [blame]
Torne (Richard Coles)90dce4d2013-05-29 14:40:03 +01001// 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)868fa2f2013-06-11 10:57:03 +01008#include "ui/base/ui_export.h"
9#include "ui/gfx/native_widget_types.h"
Ben Murdochca12bfa2013-07-23 11:17:05 +010010#include "ui/gfx/rect.h"
Torne (Richard Coles)90dce4d2013-05-29 14:40:03 +010011
12namespace gfx {
13class VSyncProvider;
14} // namespace gfx
15
16namespace ui {
17
18class SurfaceFactoryOzone {
19 public:
20 SurfaceFactoryOzone();
21 virtual ~SurfaceFactoryOzone();
22
23 // Returns the instance
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010024 UI_EXPORT static SurfaceFactoryOzone* GetInstance();
Torne (Richard Coles)90dce4d2013-05-29 14:40:03 +010025
26 // Returns a display spec as in |CreateDisplayFromSpec| for the default
27 // native surface.
28 virtual const char* DefaultDisplaySpec();
29
Ben Murdocheb525c52013-07-10 11:40:50 +010030 // Sets the implementation delegate. Ownership is retained by the caller.
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010031 UI_EXPORT static void SetInstance(SurfaceFactoryOzone* impl);
Torne (Richard Coles)90dce4d2013-05-29 14:40:03 +010032
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 Murdochca12bfa2013-07-23 11:17:05 +010056 // 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)90dce4d2013-05-29 14:40:03 +010063 // 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 Murdocheb525c52013-07-10 11:40:50 +010069
Ben Murdochca12bfa2013-07-23 11:17:05 +010070 // Create a default SufaceFactoryOzone implementation useful for tests.
71 UI_EXPORT static SurfaceFactoryOzone* CreateTestHelper();
72
Ben Murdocheb525c52013-07-10 11:40:50 +010073 private:
74 static SurfaceFactoryOzone* impl_; // not owned
Torne (Richard Coles)90dce4d2013-05-29 14:40:03 +010075};
76
77} // namespace ui
78
79
80#endif // UI_BASE_OZONE_SURFACE_LNUX_FACTORY_OZONE_H_