~ubuntu-branches/ubuntu/vivid/mir/vivid

« back to all changes in this revision

Viewing changes to src/server/graphics/gbm/gbm_cursor.h

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2014-01-08 02:04:38 UTC
  • mto: This revision was merged to the branch mainline in revision 58.
  • Revision ID: package-import@ubuntu.com-20140108020438-e1npu0pm7qdv5wc4
Tags: upstream-0.1.3+14.04.20140108
Import upstream version 0.1.3+14.04.20140108

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright © 2013 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: Alan Griffiths <alan@octopull.co.uk>
17
 
 */
18
 
 
19
 
 
20
 
#ifndef MIR_GRAPHICS_GBM_GBM_CURSOR_H_
21
 
#define MIR_GRAPHICS_GBM_GBM_CURSOR_H_
22
 
 
23
 
#include "mir/graphics/cursor.h"
24
 
 
25
 
#include <gbm.h>
26
 
#include <memory>
27
 
 
28
 
namespace mir
29
 
{
30
 
namespace geometry
31
 
{
32
 
struct Rectangle;
33
 
}
34
 
namespace graphics
35
 
{
36
 
namespace gbm
37
 
{
38
 
class KMSOutputContainer;
39
 
class KMSOutput;
40
 
class KMSDisplayConfiguration;
41
 
class GBMPlatform;
42
 
 
43
 
class CurrentConfiguration
44
 
{
45
 
public:
46
 
    virtual ~CurrentConfiguration() = default;
47
 
 
48
 
    virtual void with_current_configuration_do(
49
 
        std::function<void(KMSDisplayConfiguration const&)> const& exec) = 0;
50
 
 
51
 
protected:
52
 
    CurrentConfiguration() = default;
53
 
    CurrentConfiguration(CurrentConfiguration const&) = delete;
54
 
    CurrentConfiguration& operator=(CurrentConfiguration const&) = delete;
55
 
};
56
 
 
57
 
class GBMCursor : public Cursor
58
 
{
59
 
public:
60
 
    GBMCursor(
61
 
        gbm_device* device,
62
 
        KMSOutputContainer& output_container,
63
 
        std::shared_ptr<CurrentConfiguration> const& current_configuration);
64
 
 
65
 
    ~GBMCursor() noexcept;
66
 
 
67
 
    void set_image(const void* raw_argb, geometry::Size size);
68
 
 
69
 
    void move_to(geometry::Point position);
70
 
 
71
 
    void show_at_last_known_position();
72
 
    void hide();
73
 
 
74
 
private:
75
 
    enum ForceCursorState { UpdateState, ForceState };
76
 
    void for_each_used_output(std::function<void(KMSOutput&, geometry::Rectangle const&)> const& f);
77
 
    void place_cursor_at(geometry::Point position, ForceCursorState force_state);
78
 
 
79
 
    KMSOutputContainer& output_container;
80
 
    geometry::Point current_position;
81
 
 
82
 
    struct GBMBOWrapper
83
 
    {
84
 
        GBMBOWrapper(gbm_device* gbm);
85
 
        operator gbm_bo*();
86
 
        ~GBMBOWrapper();
87
 
    private:
88
 
        gbm_bo* buffer;
89
 
        GBMBOWrapper(GBMBOWrapper const&) = delete;
90
 
        GBMBOWrapper& operator=(GBMBOWrapper const&) = delete;
91
 
    } buffer;
92
 
 
93
 
    std::shared_ptr<CurrentConfiguration> const current_configuration;
94
 
};
95
 
}
96
 
}
97
 
}
98
 
 
99
 
 
100
 
#endif /* MIR_GRAPHICS_GBM_GBM_CURSOR_H_ */