| 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_GFX_OZONE_SURFACE_LNUX_FACTORY_OZONE_H_ | 5 #ifndef UI_GFX_OZONE_SURFACE_LNUX_FACTORY_OZONE_H_ |
| 6 #define UI_GFX_OZONE_SURFACE_LNUX_FACTORY_OZONE_H_ | 6 #define UI_GFX_OZONE_SURFACE_LNUX_FACTORY_OZONE_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/native_library.h" | 10 #include "base/native_library.h" |
| 11 #include "ui/gfx/geometry/point.h" | 11 #include "ui/gfx/geometry/point.h" |
| 12 #include "ui/gfx/geometry/rect.h" | 12 #include "ui/gfx/geometry/rect.h" |
| 13 #include "ui/gfx/gfx_export.h" | 13 #include "ui/gfx/gfx_export.h" |
| 14 #include "ui/gfx/native_widget_types.h" | 14 #include "ui/gfx/native_widget_types.h" |
| 15 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
| 16 | 16 |
| 17 class SkBitmap; | 17 class SkBitmap; |
| 18 class SkCanvas; | 18 class SkCanvas; |
| 19 | 19 |
| 20 namespace gfx { | 20 namespace gfx { |
| 21 class VSyncProvider; | 21 class VSyncProvider; |
| 22 class OverlayCandidatesOzone; | 22 class OverlayCandidatesOzone; |
| 23 class SurfaceOzone; |
| 23 typedef intptr_t NativeBufferOzone; | 24 typedef intptr_t NativeBufferOzone; |
| 24 | 25 |
| 25 // The Ozone interface allows external implementations to hook into Chromium to | 26 // The Ozone interface allows external implementations to hook into Chromium to |
| 26 // provide a system specific implementation. The Ozone interface supports two | 27 // provide a system specific implementation. The Ozone interface supports two |
| 27 // drawing modes: 1) accelerated drawing through EGL and 2) software drawing | 28 // drawing modes: 1) accelerated drawing through EGL and 2) software drawing |
| 28 // through Skia. | 29 // through Skia. |
| 29 // | 30 // |
| 30 // The following functionality is specific to the drawing mode and may not have | 31 // The following functionality is specific to the drawing mode and may not have |
| 31 // any meaningful implementation in the other mode. An implementation must | 32 // any meaningful implementation in the other mode. An implementation must |
| 32 // provide functionality for at least one mode. | 33 // provide functionality for at least one mode. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 103 |
| 103 // Returns native platform display handle. This is used to obtain the EGL | 104 // Returns native platform display handle. This is used to obtain the EGL |
| 104 // display connection for the native display. | 105 // display connection for the native display. |
| 105 virtual intptr_t GetNativeDisplay(); | 106 virtual intptr_t GetNativeDisplay(); |
| 106 | 107 |
| 107 // Obtains an AcceleratedWidget backed by a native Linux framebuffer. | 108 // Obtains an AcceleratedWidget backed by a native Linux framebuffer. |
| 108 // The returned AcceleratedWidget is an opaque token that must realized | 109 // The returned AcceleratedWidget is an opaque token that must realized |
| 109 // before it can be used to create a GL surface. | 110 // before it can be used to create a GL surface. |
| 110 virtual gfx::AcceleratedWidget GetAcceleratedWidget() = 0; | 111 virtual gfx::AcceleratedWidget GetAcceleratedWidget() = 0; |
| 111 | 112 |
| 112 // Realizes an AcceleratedWidget so that the returned AcceleratedWidget | 113 // Create a surface for the specified gfx::AcceleratedWidget. |
| 113 // can be used to to create a GLSurface. This method may only be called in | 114 // |
| 114 // a process that has a valid GL context. | 115 // Note: When used from content, this is called in the GPU process. The |
| 115 virtual gfx::AcceleratedWidget RealizeAcceleratedWidget( | 116 // platform must support creation of SurfaceOzone from the GPU process |
| 116 gfx::AcceleratedWidget w) = 0; | 117 // using only the handle contained in gfx::AcceleratedWidget. |
| 118 virtual scoped_ptr<SurfaceOzone> CreateSurfaceForWidget( |
| 119 gfx::AcceleratedWidget widget); |
| 117 | 120 |
| 118 // Sets up GL bindings for the native surface. Takes two callback parameters | 121 // Sets up GL bindings for the native surface. Takes two callback parameters |
| 119 // that allow Ozone to register the GL bindings. | 122 // that allow Ozone to register the GL bindings. |
| 120 virtual bool LoadEGLGLES2Bindings( | 123 virtual bool LoadEGLGLES2Bindings( |
| 121 AddGLLibraryCallback add_gl_library, | 124 AddGLLibraryCallback add_gl_library, |
| 122 SetGLGetProcAddressProcCallback set_gl_get_proc_address) = 0; | 125 SetGLGetProcAddressProcCallback set_gl_get_proc_address) = 0; |
| 123 | 126 |
| 124 // If possible attempts to resize the given AcceleratedWidget instance and if | |
| 125 // a resize action was performed returns true, otherwise false (native | |
| 126 // hardware may only support a single fixed size). | |
| 127 virtual bool AttemptToResizeAcceleratedWidget( | |
| 128 gfx::AcceleratedWidget w, | |
| 129 const gfx::Rect& bounds) = 0; | |
| 130 | |
| 131 // Called after the appropriate GL swap buffers command. Used if extra work | |
| 132 // is needed to perform the actual buffer swap. | |
| 133 virtual bool SchedulePageFlip(gfx::AcceleratedWidget w); | |
| 134 | |
| 135 // Returns a SkCanvas for the backing buffers. Drawing to the canvas will draw | |
| 136 // to the native surface. The canvas is intended for use when no EGL | |
| 137 // acceleration is possible. Its implementation is optional when an EGL | |
| 138 // backend is provided for rendering. | |
| 139 virtual SkCanvas* GetCanvasForWidget(gfx::AcceleratedWidget w); | |
| 140 | |
| 141 // Returns a gfx::VsyncProvider for the provided AcceleratedWidget. Note | |
| 142 // that this may be called after we have entered the sandbox so if there are | |
| 143 // operations (e.g. opening a file descriptor providing vsync events) that | |
| 144 // must be done outside of the sandbox, they must have been completed | |
| 145 // in InitializeHardware. Returns an empty scoped_ptr on error. | |
| 146 virtual scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider( | |
| 147 gfx::AcceleratedWidget w) = 0; | |
| 148 | |
| 149 // Returns an array of EGL properties, which can be used in any EGL function | 127 // Returns an array of EGL properties, which can be used in any EGL function |
| 150 // used to select a display configuration. Note that all properties should be | 128 // used to select a display configuration. Note that all properties should be |
| 151 // immediately followed by the corresponding desired value and array should be | 129 // immediately followed by the corresponding desired value and array should be |
| 152 // terminated with EGL_NONE. Ownership of the array is not transferred to | 130 // terminated with EGL_NONE. Ownership of the array is not transferred to |
| 153 // caller. desired_list contains list of desired EGL properties and values. | 131 // caller. desired_list contains list of desired EGL properties and values. |
| 154 virtual const int32* GetEGLSurfaceProperties(const int32* desired_list); | 132 virtual const int32* GetEGLSurfaceProperties(const int32* desired_list); |
| 155 | 133 |
| 156 // Get the hal struct to check for overlay support. | 134 // Get the hal struct to check for overlay support. |
| 157 virtual gfx::OverlayCandidatesOzone* GetOverlayCandidates( | 135 virtual gfx::OverlayCandidatesOzone* GetOverlayCandidates( |
| 158 gfx::AcceleratedWidget w); | 136 gfx::AcceleratedWidget w); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 177 virtual gfx::NativeBufferOzone CreateNativeBuffer(gfx::Size size, | 155 virtual gfx::NativeBufferOzone CreateNativeBuffer(gfx::Size size, |
| 178 BufferFormat format); | 156 BufferFormat format); |
| 179 | 157 |
| 180 private: | 158 private: |
| 181 static SurfaceFactoryOzone* impl_; // not owned | 159 static SurfaceFactoryOzone* impl_; // not owned |
| 182 }; | 160 }; |
| 183 | 161 |
| 184 } // namespace gfx | 162 } // namespace gfx |
| 185 | 163 |
| 186 #endif // UI_GFX_OZONE_SURFACE_LNUX_FACTORY_OZONE_H_ | 164 #endif // UI_GFX_OZONE_SURFACE_LNUX_FACTORY_OZONE_H_ |
| OLD | NEW |