OLD | NEW |
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_GLX_H_ | 5 #ifndef UI_GL_GL_SURFACE_GLX_H_ |
6 #define UI_GL_GL_SURFACE_GLX_H_ | 6 #define UI_GL_GL_SURFACE_GLX_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
| 10 #include <memory> |
10 #include <string> | 11 #include <string> |
11 | 12 |
12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "ui/events/platform/platform_event_dispatcher.h" | |
15 #include "ui/gfx/geometry/size.h" | 15 #include "ui/gfx/geometry/size.h" |
16 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
17 #include "ui/gfx/vsync_provider.h" | 17 #include "ui/gfx/vsync_provider.h" |
18 #include "ui/gfx/x/x11_types.h" | 18 #include "ui/gfx/x/x11_types.h" |
19 #include "ui/gl/gl_export.h" | 19 #include "ui/gl/gl_export.h" |
20 #include "ui/gl/gl_surface.h" | 20 #include "ui/gl/gl_surface.h" |
21 | 21 |
22 namespace gl { | 22 namespace gl { |
23 | 23 |
24 // Base class for GLX surfaces. | 24 // Base class for GLX surfaces. |
(...skipping 22 matching lines...) Expand all Loading... |
47 void* GetConfig() override = 0; | 47 void* GetConfig() override = 0; |
48 | 48 |
49 protected: | 49 protected: |
50 ~GLSurfaceGLX() override; | 50 ~GLSurfaceGLX() override; |
51 | 51 |
52 private: | 52 private: |
53 DISALLOW_COPY_AND_ASSIGN(GLSurfaceGLX); | 53 DISALLOW_COPY_AND_ASSIGN(GLSurfaceGLX); |
54 }; | 54 }; |
55 | 55 |
56 // A surface used to render to a view. | 56 // A surface used to render to a view. |
57 class GL_EXPORT NativeViewGLSurfaceGLX : public GLSurfaceGLX, | 57 class GL_EXPORT NativeViewGLSurfaceGLX : public GLSurfaceGLX { |
58 public ui::PlatformEventDispatcher { | |
59 public: | 58 public: |
60 explicit NativeViewGLSurfaceGLX(gfx::AcceleratedWidget window); | 59 explicit NativeViewGLSurfaceGLX(gfx::AcceleratedWidget window); |
61 | 60 |
62 // Implement GLSurfaceGLX. | 61 // Implement GLSurfaceGLX. |
63 bool Initialize(GLSurface::Format format) override; | 62 bool Initialize(GLSurface::Format format) override; |
64 void Destroy() override; | 63 void Destroy() override; |
65 bool Resize(const gfx::Size& size, | 64 bool Resize(const gfx::Size& size, |
66 float scale_factor, | 65 float scale_factor, |
67 bool has_alpha) override; | 66 bool has_alpha) override; |
68 bool IsOffscreen() override; | 67 bool IsOffscreen() override; |
69 gfx::SwapResult SwapBuffers() override; | 68 gfx::SwapResult SwapBuffers() override; |
70 gfx::Size GetSize() override; | 69 gfx::Size GetSize() override; |
71 void* GetHandle() override; | 70 void* GetHandle() override; |
72 bool SupportsPostSubBuffer() override; | 71 bool SupportsPostSubBuffer() override; |
73 void* GetConfig() override; | 72 void* GetConfig() override; |
74 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override; | 73 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override; |
75 gfx::VSyncProvider* GetVSyncProvider() override; | 74 gfx::VSyncProvider* GetVSyncProvider() override; |
76 | 75 |
77 protected: | 76 protected: |
78 ~NativeViewGLSurfaceGLX() override; | 77 ~NativeViewGLSurfaceGLX() override; |
79 | 78 |
| 79 // Handle registering and unregistering for Expose events. |
| 80 virtual void RegisterEvents() = 0; |
| 81 virtual void UnregisterEvents() = 0; |
| 82 |
| 83 // Forwards Expose event to child window. |
| 84 void ForwardExposeEvent(XEvent* xevent); |
| 85 |
| 86 // Checks if event is Expose for child window. |
| 87 bool CanHandleEvent(XEvent* xevent); |
| 88 |
| 89 gfx::AcceleratedWidget window() const { return window_; } |
| 90 |
80 private: | 91 private: |
81 // The handle for the drawable to make current or swap. | 92 // The handle for the drawable to make current or swap. |
82 GLXDrawable GetDrawableHandle() const; | 93 GLXDrawable GetDrawableHandle() const; |
83 | 94 |
84 // PlatformEventDispatcher implementation | |
85 bool CanDispatchEvent(const ui::PlatformEvent& event) override; | |
86 uint32_t DispatchEvent(const ui::PlatformEvent& event) override; | |
87 | |
88 // Window passed in at creation. Always valid. | 95 // Window passed in at creation. Always valid. |
89 gfx::AcceleratedWidget parent_window_; | 96 gfx::AcceleratedWidget parent_window_; |
90 | 97 |
91 // Child window, used to control resizes so that they're in-order with GL. | 98 // Child window, used to control resizes so that they're in-order with GL. |
92 gfx::AcceleratedWidget window_; | 99 gfx::AcceleratedWidget window_; |
93 | 100 |
94 // GLXDrawable for the window. | 101 // GLXDrawable for the window. |
95 GLXWindow glx_window_; | 102 GLXWindow glx_window_; |
96 | 103 |
97 GLXFBConfig config_; | 104 GLXFBConfig config_; |
(...skipping 29 matching lines...) Expand all Loading... |
127 | 134 |
128 // GLXDrawable for the window. | 135 // GLXDrawable for the window. |
129 GLXWindow glx_window_; | 136 GLXWindow glx_window_; |
130 | 137 |
131 DISALLOW_COPY_AND_ASSIGN(UnmappedNativeViewGLSurfaceGLX); | 138 DISALLOW_COPY_AND_ASSIGN(UnmappedNativeViewGLSurfaceGLX); |
132 }; | 139 }; |
133 | 140 |
134 } // namespace gl | 141 } // namespace gl |
135 | 142 |
136 #endif // UI_GL_GL_SURFACE_GLX_H_ | 143 #endif // UI_GL_GL_SURFACE_GLX_H_ |
OLD | NEW |