[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 | |
kylechar | 7a46384 | 2016-05-26 14:46:12 | [diff] [blame] | 17 | namespace gl { |
[email protected] | ad7bbbd6 | 2011-04-22 23:04:37 | [diff] [blame] | 18 | |
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: |
klausw | ec8edae | 2017-01-06 18:48:46 | [diff] [blame] | 24 | GLSurfaceOSMesa(GLSurfaceFormat 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. |
klausw | ec8edae | 2017-01-06 18:48:46 | [diff] [blame] | 27 | bool Initialize(GLSurfaceFormat 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, | ||||
Christopher Cameron | 624c11c | 2017-07-26 05:17:13 | [diff] [blame] | 31 | ColorSpace color_space, |
jbauman | 1620587 | 2015-12-15 21:27:27 | [diff] [blame] | 32 | bool has_alpha) override; |
dcheng | 0803879 | 2014-10-21 10:53:26 | [diff] [blame] | 33 | bool IsOffscreen() override; |
achaulk | ec8c2db | 2015-05-29 16:35:03 | [diff] [blame] | 34 | gfx::SwapResult SwapBuffers() override; |
dcheng | 0803879 | 2014-10-21 10:53:26 | [diff] [blame] | 35 | gfx::Size GetSize() override; |
36 | void* GetHandle() override; | ||||
klausw | ec8edae | 2017-01-06 18:48:46 | [diff] [blame] | 37 | GLSurfaceFormat GetFormat() override; |
[email protected] | f62a5ab | 2011-05-23 20:34:15 | [diff] [blame] | 38 | |
[email protected] | ab9327c | 2012-05-02 02:38:08 | [diff] [blame] | 39 | protected: |
dcheng | 0803879 | 2014-10-21 10:53:26 | [diff] [blame] | 40 | ~GLSurfaceOSMesa() override; |
[email protected] | ab9327c | 2012-05-02 02:38:08 | [diff] [blame] | 41 | |
[email protected] | ad7bbbd6 | 2011-04-22 23:04:37 | [diff] [blame] | 42 | private: |
[email protected] | ad7bbbd6 | 2011-04-22 23:04:37 | [diff] [blame] | 43 | gfx::Size size_; |
klausw | ec8edae | 2017-01-06 18:48:46 | [diff] [blame] | 44 | GLSurfaceFormat format_; |
danakj | 25c52c3 | 2016-04-12 21:51:08 | [diff] [blame] | 45 | std::unique_ptr<int32_t[]> buffer_; |
[email protected] | ad7bbbd6 | 2011-04-22 23:04:37 | [diff] [blame] | 46 | |
47 | DISALLOW_COPY_AND_ASSIGN(GLSurfaceOSMesa); | ||||
48 | }; | ||||
49 | |||||
[email protected] | ffcdc963 | 2014-03-27 17:25:23 | [diff] [blame] | 50 | // A thin subclass of |GLSurfaceOSMesa| that can be used in place |
51 | // of a native hardware-provided surface when a native surface | ||||
52 | // provider is not available. | ||||
kylechar | f1f2cba | 2016-06-10 15:41:06 | [diff] [blame] | 53 | class GL_EXPORT GLSurfaceOSMesaHeadless : public GLSurfaceOSMesa { |
[email protected] | ffcdc963 | 2014-03-27 17:25:23 | [diff] [blame] | 54 | public: |
kylechar | f1f2cba | 2016-06-10 15:41:06 | [diff] [blame] | 55 | GLSurfaceOSMesaHeadless(); |
[email protected] | ffcdc963 | 2014-03-27 17:25:23 | [diff] [blame] | 56 | |
dcheng | 0803879 | 2014-10-21 10:53:26 | [diff] [blame] | 57 | bool IsOffscreen() override; |
achaulk | ec8c2db | 2015-05-29 16:35:03 | [diff] [blame] | 58 | gfx::SwapResult SwapBuffers() override; |
[email protected] | ffcdc963 | 2014-03-27 17:25:23 | [diff] [blame] | 59 | |
60 | protected: | ||||
dcheng | 0803879 | 2014-10-21 10:53:26 | [diff] [blame] | 61 | ~GLSurfaceOSMesaHeadless() override; |
[email protected] | ffcdc963 | 2014-03-27 17:25:23 | [diff] [blame] | 62 | |
63 | private: | ||||
64 | DISALLOW_COPY_AND_ASSIGN(GLSurfaceOSMesaHeadless); | ||||
65 | }; | ||||
66 | |||||
kylechar | 7a46384 | 2016-05-26 14:46:12 | [diff] [blame] | 67 | } // namespace gl |
[email protected] | ad7bbbd6 | 2011-04-22 23:04:37 | [diff] [blame] | 68 | |
[email protected] | c9e2cbbb | 2012-05-12 21:17:27 | [diff] [blame] | 69 | #endif // UI_GL_GL_SURFACE_OSMESA_H_ |