blob: e4f6ba9481233c958edf57dc00ebc7aa6b154a85 [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"
[email protected]c9e2cbbb2012-05-12 21:17:2714#include "ui/gl/gl_surface.h"
[email protected]ad7bbbd62011-04-22 23:04:3715
16namespace gfx {
17
[email protected]ad7bbbd62011-04-22 23:04:3718// A surface that the Mesa software renderer draws to. This is actually just a
19// buffer in system memory. GetHandle returns a pointer to the buffer. These
20// surfaces can be resized and resizing preserves the contents.
[email protected]3de33af2011-09-16 16:39:3421class GL_EXPORT GLSurfaceOSMesa : public GLSurface {
[email protected]ad7bbbd62011-04-22 23:04:3722 public:
jinsukkim556e80df2016-02-24 01:01:3223 GLSurfaceOSMesa(GLSurface::Format format, const gfx::Size& size);
[email protected]ad7bbbd62011-04-22 23:04:3724
[email protected]ad7bbbd62011-04-22 23:04:3725 // Implement GLSurface.
jinsukkim25219612016-01-20 23:24:0726 bool Initialize(GLSurface::Format format) override;
dcheng08038792014-10-21 10:53:2627 void Destroy() override;
jbauman16205872015-12-15 21:27:2728 bool Resize(const gfx::Size& new_size,
29 float scale_factor,
30 bool has_alpha) override;
dcheng08038792014-10-21 10:53:2631 bool IsOffscreen() override;
achaulkec8c2db2015-05-29 16:35:0332 gfx::SwapResult SwapBuffers() override;
dcheng08038792014-10-21 10:53:2633 gfx::Size GetSize() override;
34 void* GetHandle() override;
jinsukkim556e80df2016-02-24 01:01:3235 GLSurface::Format GetFormat() override;
[email protected]f62a5ab2011-05-23 20:34:1536
[email protected]ab9327c2012-05-02 02:38:0837 protected:
dcheng08038792014-10-21 10:53:2638 ~GLSurfaceOSMesa() override;
[email protected]ab9327c2012-05-02 02:38:0839
[email protected]ad7bbbd62011-04-22 23:04:3740 private:
[email protected]ad7bbbd62011-04-22 23:04:3741 gfx::Size size_;
jinsukkim556e80df2016-02-24 01:01:3242 GLSurface::Format format_;
danakj25c52c32016-04-12 21:51:0843 std::unique_ptr<int32_t[]> buffer_;
[email protected]ad7bbbd62011-04-22 23:04:3744
45 DISALLOW_COPY_AND_ASSIGN(GLSurfaceOSMesa);
46};
47
[email protected]ffcdc9632014-03-27 17:25:2348// A thin subclass of |GLSurfaceOSMesa| that can be used in place
49// of a native hardware-provided surface when a native surface
50// provider is not available.
51class GLSurfaceOSMesaHeadless : public GLSurfaceOSMesa {
52 public:
53 explicit GLSurfaceOSMesaHeadless();
54
dcheng08038792014-10-21 10:53:2655 bool IsOffscreen() override;
achaulkec8c2db2015-05-29 16:35:0356 gfx::SwapResult SwapBuffers() override;
[email protected]ffcdc9632014-03-27 17:25:2357
58 protected:
dcheng08038792014-10-21 10:53:2659 ~GLSurfaceOSMesaHeadless() override;
[email protected]ffcdc9632014-03-27 17:25:2360
61 private:
62 DISALLOW_COPY_AND_ASSIGN(GLSurfaceOSMesaHeadless);
63};
64
[email protected]ad7bbbd62011-04-22 23:04:3765} // namespace gfx
66
[email protected]c9e2cbbb2012-05-12 21:17:2767#endif // UI_GL_GL_SURFACE_OSMESA_H_