Mir
client_buffer_stream.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2015 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: Robert Carr <robert.carr@canonical.com>
17  */
18 
19 #ifndef MIR_CLIENT_CLIENT_BUFFER_STREAM_H_
20 #define MIR_CLIENT_CLIENT_BUFFER_STREAM_H_
21 
23 #include "mir/geometry/size.h"
24 
27 #include "mir_wait_handle.h"
28 
29 #include <memory>
30 #include <functional>
31 #include <EGL/eglplatform.h>
32 
33 /*
34  * ClientBufferStream::egl_native_window() returns EGLNativeWindowType.
35  *
36  * EGLNativeWindowType is an EGL platform-specific type that is typically a
37  * (possibly slightly obfuscated) pointer. This makes our client module ABI
38  * technically EGL-platform dependent, which is awkward because we support
39  * multiple EGL platforms.
40  *
41  * On both the Mesa and the Android EGL platforms EGLNativeWindow is a
42  * pointer or a uintptr_t.
43  *
44  * In practise EGLNativeWindowType is always a typedef to a pointer-ish, but
45  * for paranoia's sake make sure the build will fail if we ever encounter a
46  * strange EGL platform where this isn't the case.
47  */
48 #include <type_traits>
49 static_assert(
50  sizeof(EGLNativeWindowType) == sizeof(void*) &&
51  std::is_pod<EGLNativeWindowType>::value,
52  "The ClientBufferStream requires that EGLNativeWindowType be no-op convertible to void*");
53 
54 #undef EGLNativeWindowType
55 #define EGLNativeWindowType void*
56 
57 namespace mir
58 {
59 namespace protobuf
60 {
61 class Buffer;
62 }
63 namespace client
64 {
65 class ClientBuffer;
66 class MemoryRegion;
67 
69 {
70 public:
71  virtual ~ClientBufferStream() = default;
72 
73  virtual MirSurfaceParameters get_parameters() const = 0;
74  virtual std::shared_ptr<ClientBuffer> get_current_buffer() = 0;
75  virtual uint32_t get_current_buffer_id() = 0;
76  virtual EGLNativeWindowType egl_native_window() = 0;
77  virtual MirWaitHandle* next_buffer(std::function<void()> const& done) = 0;
78 
79  virtual std::shared_ptr<MemoryRegion> secure_for_cpu_write() = 0;
80 
81  virtual int swap_interval() const = 0;
82  virtual MirWaitHandle* set_swap_interval(int interval) = 0;
83 
84  virtual MirNativeBuffer* get_current_buffer_package() = 0;
85  virtual MirPlatformType platform_type() = 0;
86 
87  virtual frontend::BufferStreamId rpc_id() const = 0;
88 
89  virtual bool valid() const = 0;
90  virtual void set_size(geometry::Size) = 0;
91  virtual MirWaitHandle* set_scale(float) = 0;
92  virtual char const* get_error_message() const = 0;
93  virtual MirConnection* connection() const = 0;
94 
95  virtual void buffer_available(mir::protobuf::Buffer const& buffer) = 0;
96  virtual void buffer_unavailable() = 0;
97 protected:
98  ClientBufferStream() = default;
99  ClientBufferStream(const ClientBufferStream&) = delete;
100  ClientBufferStream& operator=(const ClientBufferStream&) = delete;
101 };
102 
103 }
104 }
105 
106 #endif /* MIR_CLIENT_CLIENT_BUFFER_STREAM_H_ */
Definition: size.h:30
All things Mir.
Definition: atomic_callback.h:25
Definition: mir_wait_handle.h:31
Definition: mir_native_buffer.h:30
Definition: client_buffer_stream.h:68
Definition: mir_connection.h:96
#define EGLNativeWindowType
Definition: client_buffer_stream.h:55
MirPlatformType
The native buffer type for the system the client is connected on.
Definition: client_types.h:200
MirSurfaceParameters is the structure of minimum required information that you must provide to Mir in...
Definition: client_types.h:169

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Sep 8 14:50:19 UTC 2016