blob: dee15ebfdff57344a18d9749eae74c2bc2768f23 [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
17namespace gfx {
18
[email protected]ad7bbbd62011-04-22 23:04:3719// 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:
jinsukkim556e80df2016-02-24 01:01:3224 GLSurfaceOSMesa(GLSurface::Format format, const gfx::Size& size);
[email protected]ad7bbbd62011-04-22 23:04:3725
[email protected]ad7bbbd62011-04-22 23:04:3726 // Implement GLSurface.
jinsukkim25219612016-01-20 23:24:0727 bool Initialize(GLSurface::Format 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,
31 bool has_alpha) override;
dcheng08038792014-10-21 10:53:2632 bool IsOffscreen() override;
achaulkec8c2db2015-05-29 16:35:0333 gfx::SwapResult SwapBuffers() override;
dcheng08038792014-10-21 10:53:2634 gfx::Size GetSize() override;
35 void* GetHandle() override;
jinsukkim556e80df2016-02-24 01:01:3236 GLSurface::Format GetFormat() override;
[email protected]f62a5ab2011-05-23 20:34:1537
[email protected]ab9327c2012-05-02 02:38:0838 protected:
dcheng08038792014-10-21 10:53:2639 ~GLSurfaceOSMesa() override;
[email protected]ab9327c2012-05-02 02:38:0840
[email protected]ad7bbbd62011-04-22 23:04:3741 private:
[email protected]ad7bbbd62011-04-22 23:04:3742 gfx::Size size_;
jinsukkim556e80df2016-02-24 01:01:3243 GLSurface::Format format_;
danakj25c52c32016-04-12 21:51:0844 std::unique_ptr<int32_t[]> buffer_;
[email protected]ad7bbbd62011-04-22 23:04:3745
46 DISALLOW_COPY_AND_ASSIGN(GLSurfaceOSMesa);
47};
48
[email protected]ffcdc9632014-03-27 17:25:2349// A thin subclass of |GLSurfaceOSMesa| that can be used in place
50// of a native hardware-provided surface when a native surface
51// provider is not available.
52class GLSurfaceOSMesaHeadless : public GLSurfaceOSMesa {
53 public:
54 explicit GLSurfaceOSMesaHeadless();
55
dcheng08038792014-10-21 10:53:2656 bool IsOffscreen() override;
achaulkec8c2db2015-05-29 16:35:0357 gfx::SwapResult SwapBuffers() override;
[email protected]ffcdc9632014-03-27 17:25:2358
59 protected:
dcheng08038792014-10-21 10:53:2660 ~GLSurfaceOSMesaHeadless() override;
[email protected]ffcdc9632014-03-27 17:25:2361
62 private:
63 DISALLOW_COPY_AND_ASSIGN(GLSurfaceOSMesaHeadless);
64};
65
[email protected]ad7bbbd62011-04-22 23:04:3766} // namespace gfx
67
[email protected]c9e2cbbb2012-05-12 21:17:2768#endif // UI_GL_GL_SURFACE_OSMESA_H_