~ubuntu-branches/ubuntu/utopic/mir/utopic-proposed

« back to all changes in this revision

Viewing changes to src/server/compositor/screencast_display_buffer.h

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2014-03-10 19:28:46 UTC
  • mto: This revision was merged to the branch mainline in revision 63.
  • Revision ID: package-import@ubuntu.com-20140310192846-rq9qm3ec26yrelo2
Tags: upstream-0.1.6+14.04.20140310
Import upstream version 0.1.6+14.04.20140310

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2014 Canonical Ltd.
 
3
 *
 
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.
 
7
 *
 
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.
 
12
 *
 
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/>.
 
15
 *
 
16
 * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
 
17
 */
 
18
 
 
19
#ifndef MIR_COMPOSITOR_SCREENCAST_DISPLAY_BUFFER_H_
 
20
#define MIR_COMPOSITOR_SCREENCAST_DISPLAY_BUFFER_H_
 
21
 
 
22
#include "mir/graphics/display_buffer.h"
 
23
 
 
24
#include <GLES2/gl2.h>
 
25
 
 
26
namespace mir
 
27
{
 
28
namespace compositor
 
29
{
 
30
namespace detail
 
31
{
 
32
 
 
33
template <void (*Generate)(GLsizei,GLuint*), void (*Delete)(GLsizei,GLuint const*)>
 
34
class GLResource
 
35
{
 
36
public:
 
37
    GLResource() { Generate(1, &resource); }
 
38
    ~GLResource() { Delete(1, &resource); }
 
39
    operator GLuint() const { return resource; }
 
40
 
 
41
private:
 
42
    GLResource(GLResource const&) = delete;
 
43
    GLResource& operator=(GLResource const&) = delete;
 
44
    GLuint resource = 0;
 
45
};
 
46
}
 
47
 
 
48
class ScreencastDisplayBuffer : public graphics::DisplayBuffer
 
49
{
 
50
public:
 
51
    ScreencastDisplayBuffer(
 
52
        geometry::Rectangle const& rect,
 
53
        graphics::Buffer& buffer);
 
54
    ~ScreencastDisplayBuffer();
 
55
 
 
56
    geometry::Rectangle view_area() const;
 
57
 
 
58
    void make_current();
 
59
 
 
60
    void release_current();
 
61
 
 
62
    void render_and_post_update(
 
63
        std::list<std::shared_ptr<graphics::Renderable>> const&,
 
64
        std::function<void(graphics::Renderable const&)> const&);
 
65
 
 
66
    void post_update();
 
67
 
 
68
    bool can_bypass() const;
 
69
 
 
70
    MirOrientation orientation() const;
 
71
 
 
72
private:
 
73
    geometry::Rectangle const rect;
 
74
    graphics::Buffer& buffer;
 
75
    GLint old_fbo;
 
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;
 
80
};
 
81
 
 
82
}
 
83
}
 
84
 
 
85
#endif /* MIR_COMPOSITOR_SCREENCAST_DISPLAY_BUFFER_H_ */