blob: 1aa90bda79229f7cc5933d136e8424f806864280 [file] [log] [blame]
[email protected]1cda0482012-01-25 17:30:071// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]ad7bbbd62011-04-22 23:04:372// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]c9e2cbbb2012-05-12 21:17:275#ifndef UI_GL_GL_SURFACE_OSMESA_H_
6#define UI_GL_GL_SURFACE_OSMESA_H_
[email protected]ad7bbbd62011-04-22 23:04:377
8#include "base/memory/scoped_ptr.h"
tfarinaebe974f02015-01-03 04:25:329#include "ui/gfx/geometry/size.h"
[email protected]c9e2cbbb2012-05-12 21:17:2710#include "ui/gl/gl_surface.h"
[email protected]ad7bbbd62011-04-22 23:04:3711
12namespace gfx {
13
[email protected]4da882a52014-08-16 08:29:5114enum OSMesaSurfaceFormat { OSMesaSurfaceFormatBGRA, OSMesaSurfaceFormatRGBA };
15
[email protected]ad7bbbd62011-04-22 23:04:3716// 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]3de33af2011-09-16 16:39:3419class GL_EXPORT GLSurfaceOSMesa : public GLSurface {
[email protected]ad7bbbd62011-04-22 23:04:3720 public:
[email protected]4da882a52014-08-16 08:29:5121 GLSurfaceOSMesa(OSMesaSurfaceFormat format, const gfx::Size& size);
[email protected]ad7bbbd62011-04-22 23:04:3722
[email protected]ad7bbbd62011-04-22 23:04:3723 // Implement GLSurface.
dcheng08038792014-10-21 10:53:2624 bool Initialize() override;
25 void Destroy() override;
26 bool Resize(const gfx::Size& new_size) override;
27 bool IsOffscreen() override;
achaulkec8c2db2015-05-29 16:35:0328 gfx::SwapResult SwapBuffers() override;
dcheng08038792014-10-21 10:53:2629 gfx::Size GetSize() override;
30 void* GetHandle() override;
31 unsigned GetFormat() override;
[email protected]f62a5ab2011-05-23 20:34:1532
[email protected]ab9327c2012-05-02 02:38:0833 protected:
dcheng08038792014-10-21 10:53:2634 ~GLSurfaceOSMesa() override;
[email protected]ab9327c2012-05-02 02:38:0835
[email protected]ad7bbbd62011-04-22 23:04:3736 private:
[email protected]f62a5ab2011-05-23 20:34:1537 unsigned format_;
[email protected]ad7bbbd62011-04-22 23:04:3738 gfx::Size size_;
[email protected]d9251202013-01-16 22:40:0939 scoped_ptr<int32[]> buffer_;
[email protected]ad7bbbd62011-04-22 23:04:3740
41 DISALLOW_COPY_AND_ASSIGN(GLSurfaceOSMesa);
42};
43
[email protected]ffcdc9632014-03-27 17:25:2344// 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.
47class GLSurfaceOSMesaHeadless : public GLSurfaceOSMesa {
48 public:
49 explicit GLSurfaceOSMesaHeadless();
50
dcheng08038792014-10-21 10:53:2651 bool IsOffscreen() override;
achaulkec8c2db2015-05-29 16:35:0352 gfx::SwapResult SwapBuffers() override;
[email protected]ffcdc9632014-03-27 17:25:2353
54 protected:
dcheng08038792014-10-21 10:53:2655 ~GLSurfaceOSMesaHeadless() override;
[email protected]ffcdc9632014-03-27 17:25:2356
57 private:
58 DISALLOW_COPY_AND_ASSIGN(GLSurfaceOSMesaHeadless);
59};
60
[email protected]ad7bbbd62011-04-22 23:04:3761} // namespace gfx
62
[email protected]c9e2cbbb2012-05-12 21:17:2763#endif // UI_GL_GL_SURFACE_OSMESA_H_