[email protected] | 1cda048 | 2012-01-25 17:30:07 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | ad7bbbd6 | 2011-04-22 23:04:37 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | c9e2cbbb | 2012-05-12 21:17:27 | [diff] [blame] | 5 | #ifndef UI_GL_GL_SURFACE_OSMESA_H_ |
6 | #define UI_GL_GL_SURFACE_OSMESA_H_ | ||||
[email protected] | ad7bbbd6 | 2011-04-22 23:04:37 | [diff] [blame] | 7 | |
avi | 739878c | 2015-12-24 18:06:17 | [diff] [blame] | 8 | #include <stdint.h> |
9 | |||||
danakj | 25c52c3 | 2016-04-12 21:51:08 | [diff] [blame] | 10 | #include <memory> |
11 | |||||
avi | 739878c | 2015-12-24 18:06:17 | [diff] [blame] | 12 | #include "base/macros.h" |
tfarina | ebe974f0 | 2015-01-03 04:25:32 | [diff] [blame] | 13 | #include "ui/gfx/geometry/size.h" |
kylechar | 5b9dec1 | 2016-05-16 15:40:57 | [diff] [blame^] | 14 | #include "ui/gl/gl_export.h" |
[email protected] | c9e2cbbb | 2012-05-12 21:17:27 | [diff] [blame] | 15 | #include "ui/gl/gl_surface.h" |
[email protected] | ad7bbbd6 | 2011-04-22 23:04:37 | [diff] [blame] | 16 | |
17 | namespace gfx { | ||||
18 | |||||
[email protected] | ad7bbbd6 | 2011-04-22 23:04:37 | [diff] [blame] | 19 | // A surface that the Mesa software renderer draws to. This is actually just a |
20 | // buffer in system memory. GetHandle returns a pointer to the buffer. These | ||||
21 | // surfaces can be resized and resizing preserves the contents. | ||||
[email protected] | 3de33af | 2011-09-16 16:39:34 | [diff] [blame] | 22 | class GL_EXPORT GLSurfaceOSMesa : public GLSurface { |
[email protected] | ad7bbbd6 | 2011-04-22 23:04:37 | [diff] [blame] | 23 | public: |
jinsukkim | 556e80df | 2016-02-24 01:01:32 | [diff] [blame] | 24 | GLSurfaceOSMesa(GLSurface::Format format, const gfx::Size& size); |
[email protected] | ad7bbbd6 | 2011-04-22 23:04:37 | [diff] [blame] | 25 | |
[email protected] | ad7bbbd6 | 2011-04-22 23:04:37 | [diff] [blame] | 26 | // Implement GLSurface. |
jinsukkim | 2521961 | 2016-01-20 23:24:07 | [diff] [blame] | 27 | bool Initialize(GLSurface::Format format) override; |
dcheng | 0803879 | 2014-10-21 10:53:26 | [diff] [blame] | 28 | void Destroy() override; |
jbauman | 1620587 | 2015-12-15 21:27:27 | [diff] [blame] | 29 | bool Resize(const gfx::Size& new_size, |
30 | float scale_factor, | ||||
31 | bool has_alpha) override; | ||||
dcheng | 0803879 | 2014-10-21 10:53:26 | [diff] [blame] | 32 | bool IsOffscreen() override; |
achaulk | ec8c2db | 2015-05-29 16:35:03 | [diff] [blame] | 33 | gfx::SwapResult SwapBuffers() override; |
dcheng | 0803879 | 2014-10-21 10:53:26 | [diff] [blame] | 34 | gfx::Size GetSize() override; |
35 | void* GetHandle() override; | ||||
jinsukkim | 556e80df | 2016-02-24 01:01:32 | [diff] [blame] | 36 | GLSurface::Format GetFormat() override; |
[email protected] | f62a5ab | 2011-05-23 20:34:15 | [diff] [blame] | 37 | |
[email protected] | ab9327c | 2012-05-02 02:38:08 | [diff] [blame] | 38 | protected: |
dcheng | 0803879 | 2014-10-21 10:53:26 | [diff] [blame] | 39 | ~GLSurfaceOSMesa() override; |
[email protected] | ab9327c | 2012-05-02 02:38:08 | [diff] [blame] | 40 | |
[email protected] | ad7bbbd6 | 2011-04-22 23:04:37 | [diff] [blame] | 41 | private: |
[email protected] | ad7bbbd6 | 2011-04-22 23:04:37 | [diff] [blame] | 42 | gfx::Size size_; |
jinsukkim | 556e80df | 2016-02-24 01:01:32 | [diff] [blame] | 43 | GLSurface::Format format_; |
danakj | 25c52c3 | 2016-04-12 21:51:08 | [diff] [blame] | 44 | std::unique_ptr<int32_t[]> buffer_; |
[email protected] | ad7bbbd6 | 2011-04-22 23:04:37 | [diff] [blame] | 45 | |
46 | DISALLOW_COPY_AND_ASSIGN(GLSurfaceOSMesa); | ||||
47 | }; | ||||
48 | |||||
[email protected] | ffcdc963 | 2014-03-27 17:25:23 | [diff] [blame] | 49 | // A thin subclass of |GLSurfaceOSMesa| that can be used in place |
50 | // of a native hardware-provided surface when a native surface | ||||
51 | // provider is not available. | ||||
52 | class GLSurfaceOSMesaHeadless : public GLSurfaceOSMesa { | ||||
53 | public: | ||||
54 | explicit GLSurfaceOSMesaHeadless(); | ||||
55 | |||||
dcheng | 0803879 | 2014-10-21 10:53:26 | [diff] [blame] | 56 | bool IsOffscreen() override; |
achaulk | ec8c2db | 2015-05-29 16:35:03 | [diff] [blame] | 57 | gfx::SwapResult SwapBuffers() override; |
[email protected] | ffcdc963 | 2014-03-27 17:25:23 | [diff] [blame] | 58 | |
59 | protected: | ||||
dcheng | 0803879 | 2014-10-21 10:53:26 | [diff] [blame] | 60 | ~GLSurfaceOSMesaHeadless() override; |
[email protected] | ffcdc963 | 2014-03-27 17:25:23 | [diff] [blame] | 61 | |
62 | private: | ||||
63 | DISALLOW_COPY_AND_ASSIGN(GLSurfaceOSMesaHeadless); | ||||
64 | }; | ||||
65 | |||||
[email protected] | ad7bbbd6 | 2011-04-22 23:04:37 | [diff] [blame] | 66 | } // namespace gfx |
67 | |||||
[email protected] | c9e2cbbb | 2012-05-12 21:17:27 | [diff] [blame] | 68 | #endif // UI_GL_GL_SURFACE_OSMESA_H_ |