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 8 #include "ui/base/ui_export.h" 9 #include "ui/gfx/native_widget_types.h" 10 #include "ui/gfx/rect.h" 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 24 UI_EXPORT static SurfaceFactoryOzone* GetInstance(); 25 26 // Returns a display spec as in |CreateDisplayFromSpec| for the default 27 // native surface. 28 virtual const char* DefaultDisplaySpec(); 29 30 // Sets the implementation delegate. Ownership is retained by the caller. 31 UI_EXPORT static void SetInstance(SurfaceFactoryOzone* impl); 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 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 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; 69 70 // Create a default SufaceFactoryOzone implementation useful for tests. 71 UI_EXPORT static SurfaceFactoryOzone* CreateTestHelper(); 72 73 private: 74 static SurfaceFactoryOzone* impl_; // not owned 75 }; 76 77 } // namespace ui 78 79 80 #endif // UI_BASE_OZONE_SURFACE_LNUX_FACTORY_OZONE_H_ 81