Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mir_surface.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2012 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser 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 Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17  */
18 #ifndef MIR_CLIENT_MIR_SURFACE_H_
19 #define MIR_CLIENT_MIR_SURFACE_H_
20 
21 #include "mir_protobuf.pb.h"
22 
25 #include "mir_toolkit/common.h"
28 #include "mir_wait_handle.h"
29 #include "mir_client_surface.h"
30 #include "client_platform.h"
31 
32 #include <memory>
33 #include <functional>
34 #include <mutex>
35 
36 namespace mir
37 {
38 namespace input
39 {
40 namespace receiver
41 {
42 class InputPlatform;
43 class InputReceiverThread;
44 }
45 }
46 namespace client
47 {
48 class ClientBuffer;
49 
50 struct MemoryRegion;
51 }
52 }
53 
55 {
56 public:
57  MirSurface(MirSurface const &) = delete;
58  MirSurface& operator=(MirSurface const &) = delete;
59 
60  MirSurface(
61  MirConnection *allocating_connection,
62  mir::protobuf::DisplayServer::Stub & server,
63  std::shared_ptr<mir::client::ClientBufferFactory> const& buffer_factory,
64  std::shared_ptr<mir::input::receiver::InputPlatform> const& input_platform,
65  MirSurfaceParameters const& params,
66  mir_surface_callback callback, void * context);
67 
68  ~MirSurface();
69 
71  mir_surface_callback callback,
72  void *context);
73 
75  char const * get_error_message();
76  int id() const;
77  bool is_valid() const;
78  MirWaitHandle* next_buffer(mir_surface_callback callback, void * context);
80 
83  std::shared_ptr<mir::client::ClientBuffer> get_current_buffer();
84  uint32_t get_current_buffer_id() const;
85  void get_cpu_region(MirGraphicsRegion& region);
86  EGLNativeWindowType generate_native_window();
87 
89  int attrib(MirSurfaceAttrib a) const;
90 
91  void set_event_handler(MirEventDelegate const* delegate);
92  void handle_event(MirEvent const& e);
93 
94  /* mir::client::ClientSurface */
97 
98 private:
99  mutable std::mutex mutex; // Protects all members of *this
100 
101  void on_configured();
102  void process_incoming_buffer();
103  void populate(MirBufferPackage& buffer_package);
104  void created(mir_surface_callback callback, void * context);
105  void new_buffer(mir_surface_callback callback, void * context);
106  MirPixelFormat convert_ipc_pf_to_geometry(google::protobuf::int32 pf);
107  void release_cpu_region();
108 
109  mir::protobuf::DisplayServer::Stub & server;
110  mir::protobuf::Surface surface;
111  std::string error_message;
112 
113  MirConnection* const connection;
114  MirWaitHandle create_wait_handle;
115  MirWaitHandle next_buffer_wait_handle;
116  MirWaitHandle configure_wait_handle;
117 
118  std::shared_ptr<mir::client::MemoryRegion> secured_region;
119  std::shared_ptr<mir::client::ClientBufferDepository> buffer_depository;
120  std::shared_ptr<mir::input::receiver::InputPlatform> const input_platform;
121 
122  std::shared_ptr<EGLNativeWindowType> accelerated_window;
123 
124  mir::protobuf::SurfaceSetting configure_result;
125 
126  // Cache of latest SurfaceSettings returned from the server
127  int attrib_cache[mir_surface_attribs];
128 
129  std::function<void(MirEvent const*)> handle_event_callback;
130  std::shared_ptr<mir::input::receiver::InputReceiverThread> input_thread;
131 };
132 
133 #endif /* MIR_CLIENT_PRIVATE_MIR_WAIT_HANDLE_H_ */
std::shared_ptr< mir::client::ClientBuffer > get_current_buffer()
Definition: mir_surface.cpp:247
MirWaitHandle * release_surface(mir_surface_callback callback, void *context)
Definition: mir_surface.cpp:232
Definition: mir_surface.h:54
Definition: mir_wait_handle.h:31
Definition: common.h:40
uint32_t get_current_buffer_id() const
Definition: mir_surface.cpp:254
bool is_valid() const
Definition: mir_surface.cpp:117
int id() const
Definition: mir_surface.cpp:110
void handle_event(MirEvent const &e)
Definition: mir_surface.cpp:379
Definition: mir_native_buffer.h:30
MirWaitHandle * next_buffer(mir_surface_callback callback, void *context)
Definition: mir_surface.cpp:143
MirWaitHandle * configure(MirSurfaceAttrib a, int value)
Definition: mir_surface.cpp:300
void request_and_wait_for_configure(MirSurfaceAttrib a, int value)
Definition: mir_surface.cpp:411
MirSurfaceParameters get_parameters() const
Definition: mir_surface.cpp:86
char const * get_error_message()
Definition: mir_surface.cpp:99
MirWaitHandle * get_create_wait_handle()
Definition: mir_surface.cpp:160
void(* mir_surface_callback)(MirSurface *surface, void *client_context)
Callback to be passed when calling:
Definition: client_types.h:74
MirEventDelegate may be used to specify (at surface creation time) callbacks for handling of events...
Definition: client_types.h:264
MirNativeBuffer * get_current_buffer_package()
Definition: mir_surface.cpp:239
Definition: mir_client_surface.h:31
MirSurfaceAttrib
Attributes of a surface that the client and server/shell may wish to get or set over the wire...
Definition: common.h:34
MirPixelFormat
The order of components in a format enum matches the order of the components as they would be written...
Definition: common.h:99
MirPlatformType platform_type()
Definition: mir_surface.cpp:398
MirSurface & operator=(MirSurface const &)=delete
~MirSurface()
Definition: mir_surface.cpp:70
Definition: mir_connection.h:69
Retrieved information about a MirSurface.
Definition: client_types.h:164
Definition: event.h:207
void request_and_wait_for_next_buffer()
Definition: mir_surface.cpp:406
int attrib(MirSurfaceAttrib a) const
Definition: mir_surface.cpp:346
void set_event_handler(MirEventDelegate const *delegate)
Definition: mir_surface.cpp:353
EGLNativeWindowType generate_native_window()
Definition: mir_surface.cpp:293
MirPlatformType
The native buffer type for the system the client is connected on.
Definition: client_types.h:144
MirSurface(MirSurface const &)=delete
void get_cpu_region(MirGraphicsRegion &region)
Definition: mir_surface.cpp:124
MirSurfaceParameters is the structure of minimum required information that you must provide to Mir in...
Definition: client_types.h:121

Copyright © 2012,2013 Canonical Ltd.
Generated on Fri Apr 11 21:14:53 UTC 2014