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

« back to all changes in this revision

Viewing changes to src/server/scene/basic_surface.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
1
/*
2
 
 * Copyright © 2012 Canonical Ltd.
 
2
 * Copyright © 2012-2014 Canonical Ltd.
3
3
 *
4
4
 * This program is free software: you can redistribute it and/or modify it
5
5
 * under the terms of the GNU General Public License version 3,
19
19
#ifndef MIR_SCENE_BASIC_SURFACE_H_
20
20
#define MIR_SCENE_BASIC_SURFACE_H_
21
21
 
 
22
#include "mir/compositor/compositing_criteria.h"
 
23
#include "mir/geometry/rectangle.h"
 
24
#include "mir/input/surface.h"
 
25
 
 
26
#include "mutable_surface_state.h"
22
27
#include "mir_toolkit/common.h"
23
 
#include "mir/geometry/rectangle.h"
24
 
#include "mir/graphics/buffer_properties.h"
25
28
 
26
29
#include <glm/glm.hpp>
27
30
#include <vector>
28
31
#include <memory>
 
32
#include <mutex>
29
33
#include <string>
30
34
 
31
35
namespace mir
32
36
{
33
37
namespace compositor
34
38
{
35
 
class CompositingCriteria;
36
39
struct BufferIPCPackage;
37
40
class BufferStream;
38
41
}
47
50
}
48
51
namespace scene
49
52
{
50
 
class SurfaceData;
51
53
class SceneReport;
52
54
 
53
 
class BasicSurface
 
55
class BasicSurface :
 
56
    public compositor::CompositingCriteria,
 
57
    public input::Surface,
 
58
    public MutableSurfaceState
54
59
{
55
60
public:
56
 
    BasicSurface(std::shared_ptr<SurfaceData> const& surface_data,
 
61
    BasicSurface(
 
62
        std::string const& name,
 
63
        geometry::Rectangle rect,
 
64
        std::function<void()> change_cb,
 
65
        bool nonrectangular,
57
66
        std::shared_ptr<compositor::BufferStream> const& buffer_stream,
58
67
        std::shared_ptr<input::InputChannel> const& input_channel,
59
68
        std::shared_ptr<SceneReport> const& report);
60
69
 
61
 
    virtual ~BasicSurface();
62
 
 
63
 
    virtual std::string const& name() const;
64
 
    virtual void move_to(geometry::Point const& top_left);
65
 
    virtual void set_rotation(float degrees, glm::vec3 const& axis);
66
 
    virtual float alpha() const;
67
 
    virtual void set_alpha(float alpha);
68
 
    virtual void set_hidden(bool is_hidden);
69
 
 
70
 
    virtual geometry::Point top_left() const;
71
 
    virtual geometry::Size size() const;
72
 
 
73
 
    virtual MirPixelFormat pixel_format() const;
74
 
 
75
 
    virtual std::shared_ptr<graphics::Buffer> snapshot_buffer() const;
76
 
    virtual void swap_buffers(graphics::Buffer* old_buffer, std::function<void(graphics::Buffer* new_buffer)> complete);
77
 
    virtual void force_requests_to_complete();
78
 
 
79
 
    virtual bool supports_input() const;
80
 
    virtual int client_input_fd() const;
81
 
    virtual void allow_framedropping(bool);
82
 
    virtual std::shared_ptr<input::InputChannel> input_channel() const;
83
 
 
84
 
    virtual void set_input_region(std::vector<geometry::Rectangle> const& input_rectangles);
85
 
 
86
 
    virtual std::shared_ptr<compositor::CompositingCriteria> compositing_criteria();
87
 
 
88
 
    virtual std::shared_ptr<compositor::BufferStream> buffer_stream() const;
89
 
 
90
 
    virtual std::shared_ptr<input::Surface> input_surface() const;
 
70
    ~BasicSurface() noexcept;
 
71
 
 
72
    std::string const& name() const override;
 
73
    void move_to(geometry::Point const& top_left) override;
 
74
    float alpha() const override;
 
75
    void set_hidden(bool is_hidden) override;
 
76
 
 
77
    geometry::Size size() const override;
 
78
 
 
79
    MirPixelFormat pixel_format() const;
 
80
 
 
81
    std::shared_ptr<graphics::Buffer> snapshot_buffer() const;
 
82
    void swap_buffers(graphics::Buffer* old_buffer, std::function<void(graphics::Buffer* new_buffer)> complete);
 
83
    void force_requests_to_complete();
 
84
 
 
85
    bool supports_input() const;
 
86
    int client_input_fd() const;
 
87
    void allow_framedropping(bool);
 
88
    std::shared_ptr<input::InputChannel> input_channel() const;
 
89
 
 
90
    void set_input_region(std::vector<geometry::Rectangle> const& input_rectangles) override;
 
91
 
 
92
    std::shared_ptr<compositor::BufferStream> buffer_stream() const;
91
93
 
92
94
    /**
93
95
     * Resize the surface.
94
96
     * \returns true if the size changed, false if it was already that size.
95
97
     * \throws std::logic_error For impossible sizes like {0,0}.
96
98
     */
97
 
    virtual bool resize(geometry::Size const& size);
 
99
    bool resize(geometry::Size const& size) override;
 
100
    geometry::Point top_left() const override;
 
101
    bool contains(geometry::Point const& point) const override;
 
102
    void frame_posted() override;
 
103
    void set_alpha(float alpha) override;
 
104
    void set_rotation(float degrees, glm::vec3 const&) override;
 
105
    glm::mat4 const& transformation() const override;
 
106
    bool should_be_rendered_in(geometry::Rectangle const& rect) const  override;
 
107
    bool shaped() const  override;  // meaning the pixel format has alpha
98
108
 
99
109
private:
100
110
    BasicSurface(BasicSurface const&) = delete;
101
111
    BasicSurface& operator=(BasicSurface const&) = delete;
102
112
 
103
 
    std::shared_ptr<SurfaceData> surface_data;
104
 
    std::shared_ptr<compositor::BufferStream> surface_buffer_stream;
 
113
    std::mutex mutable guard;
 
114
    std::function<void()> const notify_change;
 
115
    std::string const surface_name;
 
116
    geometry::Rectangle surface_rect;
 
117
    glm::mat4 rotation_matrix;
 
118
    mutable glm::mat4 transformation_matrix;
 
119
    mutable geometry::Size transformation_size;
 
120
    mutable bool transformation_dirty;
 
121
    float surface_alpha;
 
122
    bool first_frame_posted;
 
123
    bool hidden;
 
124
    const bool nonrectangular;
 
125
    std::vector<geometry::Rectangle> input_rectangles;
 
126
    std::shared_ptr<compositor::BufferStream> const surface_buffer_stream;
105
127
    std::shared_ptr<input::InputChannel> const server_input_channel;
106
128
    std::shared_ptr<SceneReport> const report;
107
129
};