[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 | |
8 | #include "base/memory/scoped_ptr.h" | ||||
tfarina | ebe974f0 | 2015-01-03 04:25:32 | [diff] [blame] | 9 | #include "ui/gfx/geometry/size.h" |
[email protected] | c9e2cbbb | 2012-05-12 21:17:27 | [diff] [blame] | 10 | #include "ui/gl/gl_surface.h" |
[email protected] | ad7bbbd6 | 2011-04-22 23:04:37 | [diff] [blame] | 11 | |
12 | namespace gfx { | ||||
13 | |||||
[email protected] | 4da882a5 | 2014-08-16 08:29:51 | [diff] [blame] | 14 | enum OSMesaSurfaceFormat { OSMesaSurfaceFormatBGRA, OSMesaSurfaceFormatRGBA }; |
15 | |||||
[email protected] | ad7bbbd6 | 2011-04-22 23:04:37 | [diff] [blame] | 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 | ||||
18 | // surfaces can be resized and resizing preserves the contents. | ||||
[email protected] | 3de33af | 2011-09-16 16:39:34 | [diff] [blame] | 19 | class GL_EXPORT GLSurfaceOSMesa : public GLSurface { |
[email protected] | ad7bbbd6 | 2011-04-22 23:04:37 | [diff] [blame] | 20 | public: |
[email protected] | 4da882a5 | 2014-08-16 08:29:51 | [diff] [blame] | 21 | GLSurfaceOSMesa(OSMesaSurfaceFormat format, const gfx::Size& size); |
[email protected] | ad7bbbd6 | 2011-04-22 23:04:37 | [diff] [blame] | 22 | |
[email protected] | ad7bbbd6 | 2011-04-22 23:04:37 | [diff] [blame] | 23 | // Implement GLSurface. |
dcheng | 0803879 | 2014-10-21 10:53:26 | [diff] [blame] | 24 | bool Initialize() override; |
25 | void Destroy() override; | ||||
26 | bool Resize(const gfx::Size& new_size) override; | ||||
27 | bool IsOffscreen() override; | ||||
achaulk | ec8c2db | 2015-05-29 16:35:03 | [diff] [blame^] | 28 | gfx::SwapResult SwapBuffers() override; |
dcheng | 0803879 | 2014-10-21 10:53:26 | [diff] [blame] | 29 | gfx::Size GetSize() override; |
30 | void* GetHandle() override; | ||||
31 | unsigned GetFormat() override; | ||||
[email protected] | f62a5ab | 2011-05-23 20:34:15 | [diff] [blame] | 32 | |
[email protected] | ab9327c | 2012-05-02 02:38:08 | [diff] [blame] | 33 | protected: |
dcheng | 0803879 | 2014-10-21 10:53:26 | [diff] [blame] | 34 | ~GLSurfaceOSMesa() override; |
[email protected] | ab9327c | 2012-05-02 02:38:08 | [diff] [blame] | 35 | |
[email protected] | ad7bbbd6 | 2011-04-22 23:04:37 | [diff] [blame] | 36 | private: |
[email protected] | f62a5ab | 2011-05-23 20:34:15 | [diff] [blame] | 37 | unsigned format_; |
[email protected] | ad7bbbd6 | 2011-04-22 23:04:37 | [diff] [blame] | 38 | gfx::Size size_; |
[email protected] | d925120 | 2013-01-16 22:40:09 | [diff] [blame] | 39 | scoped_ptr<int32[]> buffer_; |
[email protected] | ad7bbbd6 | 2011-04-22 23:04:37 | [diff] [blame] | 40 | |
41 | DISALLOW_COPY_AND_ASSIGN(GLSurfaceOSMesa); | ||||
42 | }; | ||||
43 | |||||
[email protected] | ffcdc963 | 2014-03-27 17:25:23 | [diff] [blame] | 44 | // A thin subclass of |GLSurfaceOSMesa| that can be used in place |
45 | // of a native hardware-provided surface when a native surface | ||||
46 | // provider is not available. | ||||
47 | class GLSurfaceOSMesaHeadless : public GLSurfaceOSMesa { | ||||
48 | public: | ||||
49 | explicit GLSurfaceOSMesaHeadless(); | ||||
50 | |||||
dcheng | 0803879 | 2014-10-21 10:53:26 | [diff] [blame] | 51 | bool IsOffscreen() override; |
achaulk | ec8c2db | 2015-05-29 16:35:03 | [diff] [blame^] | 52 | gfx::SwapResult SwapBuffers() override; |
[email protected] | ffcdc963 | 2014-03-27 17:25:23 | [diff] [blame] | 53 | |
54 | protected: | ||||
dcheng | 0803879 | 2014-10-21 10:53:26 | [diff] [blame] | 55 | ~GLSurfaceOSMesaHeadless() override; |
[email protected] | ffcdc963 | 2014-03-27 17:25:23 | [diff] [blame] | 56 | |
57 | private: | ||||
58 | DISALLOW_COPY_AND_ASSIGN(GLSurfaceOSMesaHeadless); | ||||
59 | }; | ||||
60 | |||||
[email protected] | ad7bbbd6 | 2011-04-22 23:04:37 | [diff] [blame] | 61 | } // namespace gfx |
62 | |||||
[email protected] | c9e2cbbb | 2012-05-12 21:17:27 | [diff] [blame] | 63 | #endif // UI_GL_GL_SURFACE_OSMESA_H_ |