2
* Copyright © 2014 Canonical Ltd.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License version 3,
6
* as published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
19
#ifndef MIR_COMPOSITOR_SCREENCAST_DISPLAY_BUFFER_H_
20
#define MIR_COMPOSITOR_SCREENCAST_DISPLAY_BUFFER_H_
22
#include "mir/graphics/display_buffer.h"
24
#include <GLES2/gl2.h>
33
template <void (*Generate)(GLsizei,GLuint*), void (*Delete)(GLsizei,GLuint const*)>
37
GLResource() { Generate(1, &resource); }
38
~GLResource() { Delete(1, &resource); }
39
operator GLuint() const { return resource; }
42
GLResource(GLResource const&) = delete;
43
GLResource& operator=(GLResource const&) = delete;
48
class ScreencastDisplayBuffer : public graphics::DisplayBuffer
51
ScreencastDisplayBuffer(
52
geometry::Rectangle const& rect,
53
graphics::Buffer& buffer);
54
~ScreencastDisplayBuffer();
56
geometry::Rectangle view_area() const;
60
void release_current();
62
void render_and_post_update(
63
std::list<std::shared_ptr<graphics::Renderable>> const&,
64
std::function<void(graphics::Renderable const&)> const&);
68
bool can_bypass() const;
70
MirOrientation orientation() const;
73
geometry::Rectangle const rect;
74
graphics::Buffer& buffer;
76
GLint old_viewport[4];
77
detail::GLResource<glGenTextures,glDeleteTextures> const color_tex;
78
detail::GLResource<glGenRenderbuffers,glDeleteRenderbuffers> const depth_rbo;
79
detail::GLResource<glGenFramebuffers,glDeleteFramebuffers> const fbo;
85
#endif /* MIR_COMPOSITOR_SCREENCAST_DISPLAY_BUFFER_H_ */