Remove unused parameter.
[chromium-blink-merge.git] / ui / ozone / public / surface_factory_ozone.h
blob4e223bf1fc8b8abc9252978c29a53e7aaf5179ff
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.
5 #ifndef UI_OZONE_PUBLIC_SURFACE_FACTORY_OZONE_H_
6 #define UI_OZONE_PUBLIC_SURFACE_FACTORY_OZONE_H_
8 #include "base/callback.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/native_library.h"
11 #include "ui/gfx/geometry/point.h"
12 #include "ui/gfx/geometry/rect.h"
13 #include "ui/gfx/geometry/rect.h"
14 #include "ui/gfx/native_widget_types.h"
15 #include "ui/gfx/overlay_transform.h"
16 #include "ui/ozone/ozone_base_export.h"
18 class SkBitmap;
19 class SkCanvas;
21 namespace ui {
23 class NativePixmap;
24 class OverlayCandidatesOzone;
25 class SurfaceOzoneCanvas;
26 class SurfaceOzoneEGL;
28 // The Ozone interface allows external implementations to hook into Chromium to
29 // provide a system specific implementation. The Ozone interface supports two
30 // drawing modes: 1) accelerated drawing through EGL and 2) software drawing
31 // through Skia.
33 // If you want to paint on a window with ozone, you need to create a
34 // SurfaceOzoneEGL or SurfaceOzoneCanvas for that window. The platform can
35 // support software, EGL, or both for painting on the window.
36 // The following functionality is specific to the drawing mode and may not have
37 // any meaningful implementation in the other mode. An implementation must
38 // provide functionality for at least one mode.
40 // 1) Accelerated Drawing (EGL path):
42 // The following functions are specific to EGL:
43 // - GetNativeDisplay
44 // - LoadEGLGLES2Bindings
45 // - GetEGLSurfaceProperties (optional if the properties match the default
46 // Chromium ones).
47 // - CreateEGLSurfaceForWidget
49 // 2) Software Drawing (Skia):
51 // The following function is specific to the software path:
52 // - CreateCanvasForWidget
54 // The accelerated path can optionally provide support for the software drawing
55 // path.
57 // The remaining functions are not covered since they are needed in both drawing
58 // modes (See comments bellow for descriptions).
59 class OZONE_BASE_EXPORT SurfaceFactoryOzone {
60 public:
61 // Describes overlay buffer format.
62 // TODO: this is a placeholder for now and will be populated with more
63 // formats once we know what sorts of content, video, etc. we can support.
64 enum BufferFormat {
65 UNKNOWN,
66 RGBA_8888,
67 RGBX_8888,
68 RGB_888,
71 enum BufferUsage {
72 MAP,
73 SCANOUT,
76 typedef void* (*GLGetProcAddressProc)(const char* name);
77 typedef base::Callback<void(base::NativeLibrary)> AddGLLibraryCallback;
78 typedef base::Callback<void(GLGetProcAddressProc)>
79 SetGLGetProcAddressProcCallback;
81 SurfaceFactoryOzone();
82 virtual ~SurfaceFactoryOzone();
84 // Returns the singleton instance.
85 static SurfaceFactoryOzone* GetInstance();
87 // Returns native platform display handle. This is used to obtain the EGL
88 // display connection for the native display.
89 virtual intptr_t GetNativeDisplay();
91 // Returns Drm file descriptor. This is used to obtain access to the
92 // driver interface by other API than GL.
93 virtual int GetDrmFd();
95 // Create SurfaceOzoneEGL for the specified gfx::AcceleratedWidget.
97 // Note: When used from content, this is called in the GPU process. The
98 // platform must support creation of SurfaceOzoneEGL from the GPU process
99 // using only the handle contained in gfx::AcceleratedWidget.
100 virtual scoped_ptr<SurfaceOzoneEGL> CreateEGLSurfaceForWidget(
101 gfx::AcceleratedWidget widget);
103 // Create an EGL surface that isn't backed by any buffers, and is used
104 // for overlay-only displays. This will return NULL if this mode is
105 // not supported.
106 virtual scoped_ptr<SurfaceOzoneEGL> CreateSurfacelessEGLSurfaceForWidget(
107 gfx::AcceleratedWidget widget);
109 // Create SurfaceOzoneCanvas for the specified gfx::AcceleratedWidget.
111 // Note: The platform must support creation of SurfaceOzoneCanvas from the
112 // Browser Process using only the handle contained in gfx::AcceleratedWidget.
113 virtual scoped_ptr<SurfaceOzoneCanvas> CreateCanvasForWidget(
114 gfx::AcceleratedWidget widget);
116 // Sets up GL bindings for the native surface. Takes two callback parameters
117 // that allow Ozone to register the GL bindings.
118 virtual bool LoadEGLGLES2Bindings(
119 AddGLLibraryCallback add_gl_library,
120 SetGLGetProcAddressProcCallback set_gl_get_proc_address) = 0;
122 // Returns an array of EGL properties, which can be used in any EGL function
123 // used to select a display configuration. Note that all properties should be
124 // immediately followed by the corresponding desired value and array should be
125 // terminated with EGL_NONE. Ownership of the array is not transferred to
126 // caller. desired_list contains list of desired EGL properties and values.
127 virtual const int32* GetEGLSurfaceProperties(const int32* desired_list);
129 // Get the hal struct to check for overlay support.
130 virtual OverlayCandidatesOzone* GetOverlayCandidates(
131 gfx::AcceleratedWidget w);
133 // Create a single native buffer to be used for overlay planes or zero copy
134 // for |widget| representing a particular display controller or default
135 // display controller for kNullAcceleratedWidget.
136 virtual scoped_refptr<NativePixmap> CreateNativePixmap(
137 gfx::AcceleratedWidget widget,
138 gfx::Size size,
139 BufferFormat format,
140 BufferUsage usage);
142 // Sets the overlay plane to switch to at the next page flip.
143 // |w| specifies the screen to display this overlay plane on.
144 // |plane_z_order| specifies the stacking order of the plane relative to the
145 // main framebuffer located at index 0.
146 // |plane_transform| specifies how the buffer is to be transformed during.
147 // composition.
148 // |buffer| to be presented by the overlay.
149 // |display_bounds| specify where it is supposed to be on the screen.
150 // |crop_rect| specifies the region within the buffer to be placed
151 // inside |display_bounds|. This is specified in texture coordinates, in the
152 // range of [0,1].
153 virtual bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
154 int plane_z_order,
155 gfx::OverlayTransform plane_transform,
156 scoped_refptr<NativePixmap> buffer,
157 const gfx::Rect& display_bounds,
158 const gfx::RectF& crop_rect);
160 // Returns true if overlays can be shown at z-index 0, replacing the main
161 // surface. Combined with surfaceless extensions, it allows for an
162 // overlay-only mode.
163 virtual bool CanShowPrimaryPlaneAsOverlay();
165 // Returns true if the platform is able to create buffers for a specific usage
166 // such as MAP for zero copy or SCANOUT for display controller.
167 virtual bool CanCreateNativePixmap(BufferUsage usage);
169 private:
170 static SurfaceFactoryOzone* impl_; // not owned
173 } // namespace ui
175 #endif // UI_OZONE_PUBLIC_SURFACE_FACTORY_OZONE_H_