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_OSMESA_H_ | 5 #ifndef UI_GL_GL_SURFACE_OSMESA_H_ |
6 #define UI_GL_GL_SURFACE_OSMESA_H_ | 6 #define UI_GL_GL_SURFACE_OSMESA_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "ui/gfx/geometry/size.h" | 9 #include "ui/gfx/geometry/size.h" |
10 #include "ui/gl/gl_surface.h" | 10 #include "ui/gl/gl_surface.h" |
11 | 11 |
12 namespace gfx { | 12 namespace gfx { |
13 | 13 |
14 enum OSMesaSurfaceFormat { OSMesaSurfaceFormatBGRA, OSMesaSurfaceFormatRGBA }; | 14 enum OSMesaSurfaceFormat { OSMesaSurfaceFormatBGRA, OSMesaSurfaceFormatRGBA }; |
15 | 15 |
16 // A surface that the Mesa software renderer draws to. This is actually just a | 16 // A surface that the Mesa software renderer draws to. This is actually just a |
17 // buffer in system memory. GetHandle returns a pointer to the buffer. These | 17 // buffer in system memory. GetHandle returns a pointer to the buffer. These |
18 // surfaces can be resized and resizing preserves the contents. | 18 // surfaces can be resized and resizing preserves the contents. |
19 class GL_EXPORT GLSurfaceOSMesa : public GLSurface { | 19 class GL_EXPORT GLSurfaceOSMesa : public GLSurface { |
20 public: | 20 public: |
21 GLSurfaceOSMesa(OSMesaSurfaceFormat format, | 21 GLSurfaceOSMesa(OSMesaSurfaceFormat format, |
22 const gfx::Size& size, | 22 const gfx::Size& size, |
23 const gfx::SurfaceConfiguration requested_configuration); | 23 const gfx::SurfaceConfiguration requested_configuration); |
24 | 24 |
25 // Implement GLSurface. | 25 // Implement GLSurface. |
26 bool Initialize() override; | 26 bool Initialize() override; |
27 void Destroy() override; | 27 void Destroy() override; |
28 bool Resize(const gfx::Size& new_size) override; | 28 bool Resize(const gfx::Size& new_size) override; |
29 bool IsOffscreen() override; | 29 bool IsOffscreen() override; |
30 bool SwapBuffers() override; | 30 gfx::SwapResult SwapBuffers() override; |
31 gfx::Size GetSize() override; | 31 gfx::Size GetSize() override; |
32 void* GetHandle() override; | 32 void* GetHandle() override; |
33 unsigned GetFormat() override; | 33 unsigned GetFormat() override; |
34 void* GetConfig() override; | 34 void* GetConfig() override; |
35 | 35 |
36 protected: | 36 protected: |
37 ~GLSurfaceOSMesa() override; | 37 ~GLSurfaceOSMesa() override; |
38 | 38 |
39 private: | 39 private: |
40 unsigned format_; | 40 unsigned format_; |
41 gfx::Size size_; | 41 gfx::Size size_; |
42 scoped_ptr<int32[]> buffer_; | 42 scoped_ptr<int32[]> buffer_; |
43 | 43 |
44 DISALLOW_COPY_AND_ASSIGN(GLSurfaceOSMesa); | 44 DISALLOW_COPY_AND_ASSIGN(GLSurfaceOSMesa); |
45 }; | 45 }; |
46 | 46 |
47 // A thin subclass of |GLSurfaceOSMesa| that can be used in place | 47 // A thin subclass of |GLSurfaceOSMesa| that can be used in place |
48 // of a native hardware-provided surface when a native surface | 48 // of a native hardware-provided surface when a native surface |
49 // provider is not available. | 49 // provider is not available. |
50 class GLSurfaceOSMesaHeadless : public GLSurfaceOSMesa { | 50 class GLSurfaceOSMesaHeadless : public GLSurfaceOSMesa { |
51 public: | 51 public: |
52 explicit GLSurfaceOSMesaHeadless( | 52 explicit GLSurfaceOSMesaHeadless( |
53 const gfx::SurfaceConfiguration requested_configuration); | 53 const gfx::SurfaceConfiguration requested_configuration); |
54 | 54 |
55 bool IsOffscreen() override; | 55 bool IsOffscreen() override; |
56 bool SwapBuffers() override; | 56 SwapResult SwapBuffers() override; |
57 void* GetConfig() override; | 57 void* GetConfig() override; |
58 | 58 |
59 protected: | 59 protected: |
60 ~GLSurfaceOSMesaHeadless() override; | 60 ~GLSurfaceOSMesaHeadless() override; |
61 | 61 |
62 private: | 62 private: |
63 DISALLOW_COPY_AND_ASSIGN(GLSurfaceOSMesaHeadless); | 63 DISALLOW_COPY_AND_ASSIGN(GLSurfaceOSMesaHeadless); |
64 }; | 64 }; |
65 | 65 |
66 } // namespace gfx | 66 } // namespace gfx |
67 | 67 |
68 #endif // UI_GL_GL_SURFACE_OSMESA_H_ | 68 #endif // UI_GL_GL_SURFACE_OSMESA_H_ |
OLD | NEW |