OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef UI_GFX_GL_GL_SURFACE_EGL_H_ | |
6 #define UI_GFX_GL_GL_SURFACE_EGL_H_ | |
7 #pragma once | |
8 | |
9 #if defined(OS_WIN) | |
10 #include <windows.h> | |
11 #endif | |
12 | |
13 #include "base/compiler_specific.h" | |
14 #include "ui/gfx/gl/gl_surface.h" | |
15 #include "ui/gfx/native_widget_types.h" | |
16 #include "ui/gfx/size.h" | |
17 | |
18 typedef void* EGLConfig; | |
19 typedef void* EGLDisplay; | |
20 typedef void* EGLSurface; | |
21 | |
22 #if defined(OS_ANDROID) | |
23 typedef void* EGLNativeDisplayType; | |
24 #elif defined(OS_WIN) | |
25 typedef HDC EGLNativeDisplayType; | |
26 #else | |
27 typedef struct _XDisplay* EGLNativeDisplayType; | |
28 #endif | |
29 | |
30 namespace gfx { | |
31 | |
32 // Interface for EGL surface. | |
33 class GL_EXPORT GLSurfaceEGL : public GLSurface { | |
34 public: | |
35 GLSurfaceEGL(); | |
36 virtual ~GLSurfaceEGL(); | |
37 | |
38 // Implement GLSurface. | |
39 virtual EGLDisplay GetDisplay() OVERRIDE; | |
40 virtual EGLConfig GetConfig() OVERRIDE; | |
41 | |
42 static bool InitializeOneOff(); | |
43 static EGLDisplay GetHardwareDisplay(); | |
44 static EGLDisplay GetSoftwareDisplay(); | |
45 static EGLNativeDisplayType GetNativeDisplay(); | |
46 | |
47 protected: | |
48 bool software_; | |
49 | |
50 private: | |
51 DISALLOW_COPY_AND_ASSIGN(GLSurfaceEGL); | |
52 }; | |
53 | |
54 // Encapsulates an EGL surface bound to a view. | |
55 class NativeViewGLSurfaceEGL : public GLSurfaceEGL { | |
56 public: | |
57 NativeViewGLSurfaceEGL(bool software, gfx::AcceleratedWidget window); | |
58 virtual ~NativeViewGLSurfaceEGL(); | |
59 | |
60 // Implement GLSurface. | |
61 virtual bool Initialize() OVERRIDE; | |
62 virtual void Destroy() OVERRIDE; | |
63 virtual bool IsOffscreen() OVERRIDE; | |
64 virtual bool SwapBuffers() OVERRIDE; | |
65 virtual gfx::Size GetSize() OVERRIDE; | |
66 virtual EGLSurface GetHandle() OVERRIDE; | |
67 virtual std::string GetExtensions() OVERRIDE; | |
68 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; | |
69 | |
70 protected: | |
71 void SetHandle(EGLSurface surface); | |
72 | |
73 private: | |
74 gfx::AcceleratedWidget window_; | |
75 EGLSurface surface_; | |
76 bool supports_post_sub_buffer_; | |
77 | |
78 DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceEGL); | |
79 }; | |
80 | |
81 // Encapsulates a pbuffer EGL surface. | |
82 class GL_EXPORT PbufferGLSurfaceEGL : public GLSurfaceEGL { | |
83 public: | |
84 PbufferGLSurfaceEGL(bool software, const gfx::Size& size); | |
85 virtual ~PbufferGLSurfaceEGL(); | |
86 | |
87 // Implement GLSurface. | |
88 virtual bool Initialize() OVERRIDE; | |
89 virtual void Destroy() OVERRIDE; | |
90 virtual bool IsOffscreen() OVERRIDE; | |
91 virtual bool SwapBuffers() OVERRIDE; | |
92 virtual gfx::Size GetSize() OVERRIDE; | |
93 virtual bool Resize(const gfx::Size& size) OVERRIDE; | |
94 virtual EGLSurface GetHandle() OVERRIDE; | |
95 virtual void* GetShareHandle() OVERRIDE; | |
96 | |
97 private: | |
98 gfx::Size size_; | |
99 EGLSurface surface_; | |
100 | |
101 DISALLOW_COPY_AND_ASSIGN(PbufferGLSurfaceEGL); | |
102 }; | |
103 | |
104 } // namespace gfx | |
105 | |
106 #endif // UI_GFX_GL_GL_SURFACE_EGL_H_ | |
OLD | NEW |