Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(809)

Side by Side Diff: ui/gl/gl_surface_egl.h

Issue 1168993002: Update the native_viewport interface to allow specification of the surface configuration, currently… (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_GL_GL_SURFACE_EGL_H_ 5 #ifndef UI_GL_GL_SURFACE_EGL_H_
6 #define UI_GL_GL_SURFACE_EGL_H_ 6 #define UI_GL_GL_SURFACE_EGL_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "ui/gfx/geometry/size.h" 12 #include "ui/gfx/geometry/size.h"
13 #include "ui/gfx/vsync_provider.h" 13 #include "ui/gfx/vsync_provider.h"
14 #include "ui/gl/gl_bindings.h" 14 #include "ui/gl/gl_bindings.h"
15 #include "ui/gl/gl_surface.h" 15 #include "ui/gl/gl_surface.h"
16 16
17 namespace gfx { 17 namespace gfx {
18 18
19 // Get default EGL display for GLSurfaceEGL (differs by platform). 19 // Get default EGL display for GLSurfaceEGL (differs by platform).
20 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay(); 20 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay();
21 21
22 // Interface for EGL surface. 22 // Interface for EGL surface.
23 class GL_EXPORT GLSurfaceEGL : public GLSurface { 23 class GL_EXPORT GLSurfaceEGL : public GLSurface {
24 public: 24 public:
25 GLSurfaceEGL(); 25 GLSurfaceEGL(SurfaceConfiguration requested_configuration);
26 26
27 // Implement GLSurface. 27 // Implement GLSurface.
28 void DestroyAndTerminateDisplay() override; 28 void DestroyAndTerminateDisplay() override;
29 EGLDisplay GetDisplay() override; 29 EGLDisplay GetDisplay() override;
30 30
31 static bool InitializeOneOff(); 31 static bool InitializeOneOff();
32 static EGLDisplay GetHardwareDisplay(); 32 static EGLDisplay GetHardwareDisplay();
33 static EGLNativeDisplayType GetNativeDisplay(); 33 static EGLNativeDisplayType GetNativeDisplay();
34 34
35 // These aren't particularly tied to surfaces, but since we already 35 // These aren't particularly tied to surfaces, but since we already
36 // have the static InitializeOneOff here, it's easiest to reuse its 36 // have the static InitializeOneOff here, it's easiest to reuse its
37 // initialization guards. 37 // initialization guards.
38 static const char* GetEGLExtensions(); 38 static const char* GetEGLExtensions();
39 static bool HasEGLExtension(const char* name); 39 static bool HasEGLExtension(const char* name);
40 static bool IsCreateContextRobustnessSupported(); 40 static bool IsCreateContextRobustnessSupported();
41 static bool IsEGLSurfacelessContextSupported(); 41 static bool IsEGLSurfacelessContextSupported();
42 42
43 protected: 43 protected:
44 ~GLSurfaceEGL() override; 44 ~GLSurfaceEGL() override;
45 45
46 private: 46 private:
47 DISALLOW_COPY_AND_ASSIGN(GLSurfaceEGL); 47 DISALLOW_COPY_AND_ASSIGN(GLSurfaceEGL);
48 }; 48 };
49 49
50 // Encapsulates an EGL surface bound to a view. 50 // Encapsulates an EGL surface bound to a view.
51 class GL_EXPORT NativeViewGLSurfaceEGL : public GLSurfaceEGL { 51 class GL_EXPORT NativeViewGLSurfaceEGL : public GLSurfaceEGL {
52 public: 52 public:
53 explicit NativeViewGLSurfaceEGL(EGLNativeWindowType window); 53 explicit NativeViewGLSurfaceEGL(EGLNativeWindowType window,
54 SurfaceConfiguration requested_configuration);
54 55
55 // Implement GLSurface. 56 // Implement GLSurface.
56 EGLConfig GetConfig() override; 57 EGLConfig GetConfig() override;
57 bool Initialize() override; 58 bool Initialize() override;
58 void Destroy() override; 59 void Destroy() override;
59 bool Resize(const gfx::Size& size) override; 60 bool Resize(const gfx::Size& size) override;
60 bool Recreate() override; 61 bool Recreate() override;
61 bool IsOffscreen() override; 62 bool IsOffscreen() override;
62 bool SwapBuffers() override; 63 bool SwapBuffers() override;
63 gfx::Size GetSize() override; 64 gfx::Size GetSize() override;
(...skipping 22 matching lines...) Expand all
86 scoped_ptr<VSyncProvider> vsync_provider_; 87 scoped_ptr<VSyncProvider> vsync_provider_;
87 88
88 int swap_interval_; 89 int swap_interval_;
89 90
90 DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceEGL); 91 DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceEGL);
91 }; 92 };
92 93
93 // Encapsulates a pbuffer EGL surface. 94 // Encapsulates a pbuffer EGL surface.
94 class GL_EXPORT PbufferGLSurfaceEGL : public GLSurfaceEGL { 95 class GL_EXPORT PbufferGLSurfaceEGL : public GLSurfaceEGL {
95 public: 96 public:
96 explicit PbufferGLSurfaceEGL(const gfx::Size& size); 97 explicit PbufferGLSurfaceEGL(const gfx::Size& size,
98 SurfaceConfiguration requested_configuration);
97 99
98 // Implement GLSurface. 100 // Implement GLSurface.
99 EGLConfig GetConfig() override; 101 EGLConfig GetConfig() override;
100 bool Initialize() override; 102 bool Initialize() override;
101 void Destroy() override; 103 void Destroy() override;
102 bool IsOffscreen() override; 104 bool IsOffscreen() override;
103 bool SwapBuffers() override; 105 bool SwapBuffers() override;
104 gfx::Size GetSize() override; 106 gfx::Size GetSize() override;
105 bool Resize(const gfx::Size& size) override; 107 bool Resize(const gfx::Size& size) override;
106 EGLSurface GetHandle() override; 108 EGLSurface GetHandle() override;
107 void* GetShareHandle() override; 109 void* GetShareHandle() override;
108 110
109 protected: 111 protected:
110 ~PbufferGLSurfaceEGL() override; 112 ~PbufferGLSurfaceEGL() override;
111 113
112 private: 114 private:
113 gfx::Size size_; 115 gfx::Size size_;
114 EGLSurface surface_; 116 EGLSurface surface_;
117 EGLConfig config_;
115 118
116 DISALLOW_COPY_AND_ASSIGN(PbufferGLSurfaceEGL); 119 DISALLOW_COPY_AND_ASSIGN(PbufferGLSurfaceEGL);
117 }; 120 };
118 121
119 // SurfacelessEGL is used as Offscreen surface when platform supports 122 // SurfacelessEGL is used as Offscreen surface when platform supports
120 // KHR_surfaceless_context and GL_OES_surfaceless_context. This would avoid the 123 // KHR_surfaceless_context and GL_OES_surfaceless_context. This would avoid the
121 // need to create a dummy EGLsurface in case we render to client API targets. 124 // need to create a dummy EGLsurface in case we render to client API targets.
122 class GL_EXPORT SurfacelessEGL : public GLSurfaceEGL { 125 class GL_EXPORT SurfacelessEGL : public GLSurfaceEGL {
123 public: 126 public:
124 explicit SurfacelessEGL(const gfx::Size& size); 127 explicit SurfacelessEGL(const gfx::Size& size,
128 SurfaceConfiguration requested_configuration);
125 129
126 // Implement GLSurface. 130 // Implement GLSurface.
127 EGLConfig GetConfig() override; 131 EGLConfig GetConfig() override;
128 bool Initialize() override; 132 bool Initialize() override;
129 void Destroy() override; 133 void Destroy() override;
130 bool IsOffscreen() override; 134 bool IsOffscreen() override;
131 bool IsSurfaceless() const override; 135 bool IsSurfaceless() const override;
132 bool SwapBuffers() override; 136 bool SwapBuffers() override;
133 gfx::Size GetSize() override; 137 gfx::Size GetSize() override;
134 bool Resize(const gfx::Size& size) override; 138 bool Resize(const gfx::Size& size) override;
135 EGLSurface GetHandle() override; 139 EGLSurface GetHandle() override;
136 void* GetShareHandle() override; 140 void* GetShareHandle() override;
137 141
138 protected: 142 protected:
139 ~SurfacelessEGL() override; 143 ~SurfacelessEGL() override;
140 144
141 private: 145 private:
142 gfx::Size size_; 146 gfx::Size size_;
143 DISALLOW_COPY_AND_ASSIGN(SurfacelessEGL); 147 DISALLOW_COPY_AND_ASSIGN(SurfacelessEGL);
144 }; 148 };
145 149
146 } // namespace gfx 150 } // namespace gfx
147 151
148 #endif // UI_GL_GL_SURFACE_EGL_H_ 152 #endif // UI_GL_GL_SURFACE_EGL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698