blob: 246bc2922e38e241fe3f6b409d0b2d5dda8d3b7d [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
avi739878c2015-12-24 18:06:178#include <stdint.h>
9
danakj25c52c32016-04-12 21:51:0810#include <memory>
11
avi739878c2015-12-24 18:06:1712#include "base/macros.h"
tfarinaebe974f02015-01-03 04:25:3213#include "ui/gfx/geometry/size.h"
kylechar5b9dec12016-05-16 15:40:5714#include "ui/gl/gl_export.h"
[email protected]c9e2cbbb2012-05-12 21:17:2715#include "ui/gl/gl_surface.h"
[email protected]ad7bbbd62011-04-22 23:04:3716
kylechar7a463842016-05-26 14:46:1217namespace gl {
[email protected]ad7bbbd62011-04-22 23:04:3718
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]3de33af2011-09-16 16:39:3422class GL_EXPORT GLSurfaceOSMesa : public GLSurface {
[email protected]ad7bbbd62011-04-22 23:04:3723 public:
klauswec8edae2017-01-06 18:48:4624 GLSurfaceOSMesa(GLSurfaceFormat format, const gfx::Size& size);
[email protected]ad7bbbd62011-04-22 23:04:3725
[email protected]ad7bbbd62011-04-22 23:04:3726 // Implement GLSurface.
klauswec8edae2017-01-06 18:48:4627 bool Initialize(GLSurfaceFormat format) override;
dcheng08038792014-10-21 10:53:2628 void Destroy() override;
jbauman16205872015-12-15 21:27:2729 bool Resize(const gfx::Size& new_size,
30 float scale_factor,
Christopher Cameron624c11c2017-07-26 05:17:1331 ColorSpace color_space,
jbauman16205872015-12-15 21:27:2732 bool has_alpha) override;
dcheng08038792014-10-21 10:53:2633 bool IsOffscreen() override;
achaulkec8c2db2015-05-29 16:35:0334 gfx::SwapResult SwapBuffers() override;
dcheng08038792014-10-21 10:53:2635 gfx::Size GetSize() override;
36 void* GetHandle() override;
klauswec8edae2017-01-06 18:48:4637 GLSurfaceFormat GetFormat() override;
[email protected]f62a5ab2011-05-23 20:34:1538
[email protected]ab9327c2012-05-02 02:38:0839 protected:
dcheng08038792014-10-21 10:53:2640 ~GLSurfaceOSMesa() override;
[email protected]ab9327c2012-05-02 02:38:0841
[email protected]ad7bbbd62011-04-22 23:04:3742 private:
[email protected]ad7bbbd62011-04-22 23:04:3743 gfx::Size size_;
klauswec8edae2017-01-06 18:48:4644 GLSurfaceFormat format_;
danakj25c52c32016-04-12 21:51:0845 std::unique_ptr<int32_t[]> buffer_;
[email protected]ad7bbbd62011-04-22 23:04:3746
47 DISALLOW_COPY_AND_ASSIGN(GLSurfaceOSMesa);
48};
49
[email protected]ffcdc9632014-03-27 17:25:2350// 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.
kylecharf1f2cba2016-06-10 15:41:0653class GL_EXPORT GLSurfaceOSMesaHeadless : public GLSurfaceOSMesa {
[email protected]ffcdc9632014-03-27 17:25:2354 public:
kylecharf1f2cba2016-06-10 15:41:0655 GLSurfaceOSMesaHeadless();
[email protected]ffcdc9632014-03-27 17:25:2356
dcheng08038792014-10-21 10:53:2657 bool IsOffscreen() override;
achaulkec8c2db2015-05-29 16:35:0358 gfx::SwapResult SwapBuffers() override;
[email protected]ffcdc9632014-03-27 17:25:2359
60 protected:
dcheng08038792014-10-21 10:53:2661 ~GLSurfaceOSMesaHeadless() override;
[email protected]ffcdc9632014-03-27 17:25:2362
63 private:
64 DISALLOW_COPY_AND_ASSIGN(GLSurfaceOSMesaHeadless);
65};
66
kylechar7a463842016-05-26 14:46:1267} // namespace gl
[email protected]ad7bbbd62011-04-22 23:04:3768
[email protected]c9e2cbbb2012-05-12 21:17:2769#endif // UI_GL_GL_SURFACE_OSMESA_H_