Mir

Merge lp:~alan-griffiths/mir/port-examples-off-obsolete-APIs into lp:mir

Proposed by Alan Griffiths
Status: Merged
Approved by: Chris Halse Rogers
Approved revision: no longer in the source branch.
Merged at revision: 4173
Proposed branch: lp:~alan-griffiths/mir/port-examples-off-obsolete-APIs
Merge into: lp:mir
Prerequisite: lp:~alan-griffiths/mir/deprecation-macros
Diff against target: 1665 lines (+457/-447)
22 files modified
examples/CMakeLists.txt (+2/-0)
examples/animated_cursor_demo_client.c (+0/-9)
examples/basic.c (+10/-11)
examples/camera.c (+3/-10)
examples/chain_jumping_buffers.c (+0/-10)
examples/client_helpers.cpp (+0/-57)
examples/client_helpers.h (+0/-27)
examples/eglapp.c (+37/-77)
examples/fingerpaint.c (+92/-70)
examples/flicker.c (+58/-14)
examples/multi_stream.cpp (+101/-48)
examples/multiwin.c (+66/-56)
examples/prerendered_frames.c (+5/-15)
examples/progressbar.c (+50/-14)
examples/release_at_exit.c (+0/-4)
examples/render_surface.cpp (+0/-3)
examples/tooltip.c (+21/-12)
src/server/compositor/stream.cpp (+2/-0)
src/server/compositor/stream.h (+1/-1)
tests/include/mir/test/doubles/stub_buffer.h (+3/-3)
tests/include/mir/test/doubles/stub_buffer_allocator.h (+4/-4)
tests/mir_test_framework/stub_client_platform_factory.cpp (+2/-2)
To merge this branch: bzr merge lp:~alan-griffiths/mir/port-examples-off-obsolete-APIs
Reviewer Review Type Date Requested Status
Chris Halse Rogers Approve
Mir CI Bot continuous-integration Approve
Brandon Schaefer (community) Approve
Alberto Aguirre (community) Approve
Review via email: mp+324255@code.launchpad.net

Commit message

Port examples off the APIs we propose to delete in release 1.0

Description of the change

Port examples off the APIs we propose to delete in release 1.0

This gives an idea of what is possible with the proposed APIs.

Note that:

1. there's still a bit of '#pragma GCC diagnostic ignored "-Wdeprecated-declarations"' in client_helpers.cpp to be addressed; and,
2. multiwin has lost its transparency - although AFAICS the example code is not at fault

To post a comment you must log in.
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:4191
https://mir-jenkins.ubuntu.com/job/mir-ci/3404/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/4630
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/4759
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/4748
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/4748
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4662
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4662/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/4662
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/4662/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4662
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4662/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=zesty/4662
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=zesty/4662/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/4662
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/4662/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/3404/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

Looks good here, though weird alpha is ignored with render surface...

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> Looks good here, though weird alpha is ignored with render surface...

There seems to be a problem with the RS API implementation.

The server-side bufferstream is being created with the render surface, not when the stream is requested. The latter only creates the client-side object (without updating the server), so the pixel format cannot be respected by the server.

(The difficulty removing the remaining deprecated calls from client_helpers.cpp might be related: unless the pixel format is set for the surface nothing appears onscreen.)

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> > Looks good here, though weird alpha is ignored with render surface...
>
> There seems to be a problem with the RS API implementation.
>
> The server-side bufferstream is being created with the render surface, not
> when the stream is requested. The latter only creates the client-side object
> (without updating the server), so the pixel format cannot be respected by the
> server.

Not that the server even cares what the buffer stream alpha is:

            list.emplace_back(std::make_shared<SurfaceSnapshot>(
                info.stream, id,
                geom::Rectangle{surface_rect.top_left + info.displacement, std::move(size)},
                transformation_matrix, surface_alpha, info.stream.get()));
                                       ^^^^^^^^^^^^^

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> Looks good here, though weird alpha is ignored with render surface...

Fixed!!

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Oops! A few tests seem to rely on the bufferstream pixel format overriding that of the buffer.

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

lgtm

review: Approve
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:4194
https://mir-jenkins.ubuntu.com/job/mir-ci/3406/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/4633
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/4762
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/4751
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/4751
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4665
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4665/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/4665
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/4665/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4665
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4665/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=zesty/4665
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=zesty/4665/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/4665
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/4665/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/3406/rebuild

review: Approve (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:4195
https://mir-jenkins.ubuntu.com/job/mir-ci/3407/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/4634
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/4763
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/4752
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/4752
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4666
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4666/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/4666
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/4666/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4666
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4666/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=zesty/4666
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=zesty/4666/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/4666
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/4666/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/3407/rebuild

review: Approve (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'examples/CMakeLists.txt'
2--- examples/CMakeLists.txt 2017-05-08 03:04:26 +0000
3+++ examples/CMakeLists.txt 2017-05-22 16:48:39 +0000
4@@ -1,3 +1,5 @@
5+add_definitions(-DMIR_DEPRECATE_RENDERSURFACES=0)
6+
7 mir_add_wrapped_executable(mir_demo_standalone_render_surfaces
8 render_surfaces.cpp
9 buffer_render_target.cpp
10
11=== modified file 'examples/animated_cursor_demo_client.c'
12--- examples/animated_cursor_demo_client.c 2017-05-08 03:04:26 +0000
13+++ examples/animated_cursor_demo_client.c 2017-05-22 16:48:39 +0000
14@@ -30,10 +30,7 @@
15 #include <time.h>
16 #include <GLES2/gl2.h>
17
18-#pragma GCC diagnostic push
19-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
20 MirRenderSurface* render_surface;
21-#pragma GCC diagnostic pop
22
23 void animate_cursor(MirBufferStream *stream)
24 {
25@@ -73,8 +70,6 @@
26
27 MirBufferStream* make_cursor_surface(MirConnection *connection, MirWindow *window)
28 {
29-#pragma GCC diagnostic push
30-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
31 render_surface =
32 mir_connection_create_render_surface_sync(connection, 24, 24);
33
34@@ -85,7 +80,6 @@
35
36 MirWindowSpec *spec = mir_create_window_spec(connection);
37 mir_window_spec_set_cursor_render_surface(spec, render_surface, 0 , 0);
38-#pragma GCC diagnostic pop
39
40 mir_window_apply_spec(window, spec);
41 mir_window_spec_release(spec);
42@@ -112,10 +106,7 @@
43 animate_cursor(stream);
44 }
45
46-#pragma GCC diagnostic push
47-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
48 mir_render_surface_release(render_surface);
49-#pragma GCC diagnostic pop
50
51 mir_eglapp_cleanup();
52
53
54=== modified file 'examples/basic.c'
55--- examples/basic.c 2017-05-08 03:04:26 +0000
56+++ examples/basic.c 2017-05-22 16:48:39 +0000
57@@ -61,10 +61,12 @@
58 } MirDemoState;
59 ///\internal [MirDemoState_tag]
60
61-#pragma GCC diagnostic push
62-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
63+
64 int demo_client(const char* server, int buffer_swap_count)
65 {
66+ static int const width = 640;
67+ static int const height = 480;
68+
69 MirDemoState mcd;
70 mcd.connection = 0;
71 mcd.window = 0;
72@@ -107,10 +109,11 @@
73 unsigned int valid_formats;
74 mir_connection_get_available_surface_formats(mcd.connection, &pixel_format, 1, &valid_formats);
75
76- MirWindowSpec *spec = mir_create_normal_window_spec(mcd.connection, 640, 480);
77+ MirRenderSurface* rs = mir_connection_create_render_surface_sync(mcd.connection, width, height);
78+ MirWindowSpec *spec = mir_create_normal_window_spec(mcd.connection, width, height);
79 assert(spec != NULL);
80- mir_window_spec_set_pixel_format(spec, pixel_format);
81 mir_window_spec_set_name(spec, __FILE__);
82+ mir_window_spec_add_render_surface(spec, rs, width, height, 0, 0);
83
84 ///\internal [surface_create_tag]
85 // ...we create a surface using that format.
86@@ -133,19 +136,13 @@
87 else
88 assert(strcmp(mir_window_get_error_message(mcd.window), "") == 0);
89
90- MirBufferStream *bs =
91- mir_window_get_buffer_stream(mcd.window);
92+ MirBufferStream* bs = mir_render_surface_get_buffer_stream(rs, width, height, pixel_format);
93
94 // We can keep exchanging the current buffer for a new one
95 for (int i = 0; i < buffer_swap_count; i++)
96 {
97 // We can query the current graphics buffer attributes
98 {
99- ///\internal [get_current_buffer_tag]
100- MirNativeBuffer* buffer_package = NULL;
101- mir_buffer_stream_get_current_buffer(bs, &buffer_package);
102-#pragma GCC diagnostic pop
103- assert(buffer_package != NULL);
104 MirGraphicsRegion graphics_region;
105 mir_buffer_stream_get_graphics_region(bs, &graphics_region);
106
107@@ -164,6 +161,8 @@
108 puts("Window released");
109 ///\internal [surface_release_tag]
110
111+ mir_render_surface_release(rs);
112+
113 ///\internal [connection_release_tag]
114 // We should release our connection
115 mir_connection_release(mcd.connection);
116
117=== modified file 'examples/camera.c'
118--- examples/camera.c 2017-05-08 03:04:26 +0000
119+++ examples/camera.c 2017-05-22 16:48:39 +0000
120@@ -86,7 +86,6 @@
121 static void on_event(MirWindow *surface, const MirEvent *event, void *context)
122 {
123 State *state = (State*)context;
124- bool handled = true;
125
126 // FIXME: We presently need to know that events come in on a different
127 // thread to main (LP: #1194384). When that's resolved, simple
128@@ -99,15 +98,12 @@
129 state->resized = true;
130 break;
131 default:
132- handled = false;
133 break;
134 }
135
136 pthread_mutex_unlock(&state->mutex);
137
138- if (!handled)
139- mir_eglapp_handle_event(surface, event, NULL);
140-
141+ mir_eglapp_handle_event(surface, event, NULL);
142 }
143
144 static void fourcc_string(__u32 x, char str[5])
145@@ -387,11 +383,8 @@
146 if (ultrafast)
147 {
148 pref = camera_pref_speed;
149-#pragma GCC diagnostic push
150-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
151- MirBufferStream* bs = mir_window_get_buffer_stream(mir_eglapp_native_window());
152-#pragma GCC diagnostic pop
153- mir_buffer_stream_set_swapinterval(bs, 0);
154+// MirBufferStream* bs = mir_window_get_buffer_stream(mir_eglapp_native_window());
155+// mir_buffer_stream_set_swapinterval(bs, 0);
156 }
157 Camera *cam = open_camera(dev_video, pref, 1);
158 if (!cam)
159
160=== modified file 'examples/chain_jumping_buffers.c'
161--- examples/chain_jumping_buffers.c 2017-05-08 03:04:26 +0000
162+++ examples/chain_jumping_buffers.c 2017-05-22 16:48:39 +0000
163@@ -88,8 +88,6 @@
164 rendering = 0;
165 }
166
167-#pragma GCC diagnostic push
168-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
169 int main(int argc, char** argv)
170 {
171 static char const *socket_file = NULL;
172@@ -192,19 +190,12 @@
173 {
174 printf("could not create MirPresentationChain\n");
175
176- // TODO this is a frig to pass smoke tests until we support NBS by default
177-#if (MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 3, 0))
178- printf("This is currently an unreleased API - likely server support is switched off\n");
179- return 0;
180-#else
181 return -1;
182-#endif
183 }
184 }
185
186 //Arrange a 2x2 grid of chains within window
187 MirWindowSpec* spec = mir_create_normal_window_spec(connection, width, height);
188- mir_window_spec_set_pixel_format(spec, format);
189 mir_window_spec_add_render_surface(
190 spec, render_surface[0], chain_width, chain_height, displacement_x, displacement_y);
191 mir_window_spec_add_render_surface(
192@@ -273,4 +264,3 @@
193 mir_connection_release(connection);
194 return 0;
195 }
196-#pragma GCC diagnostic pop
197
198=== modified file 'examples/client_helpers.cpp'
199--- examples/client_helpers.cpp 2017-05-08 03:04:26 +0000
200+++ examples/client_helpers.cpp 2017-05-22 16:48:39 +0000
201@@ -53,63 +53,6 @@
202
203 #pragma GCC diagnostic push
204 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
205-me::BufferStream::BufferStream(
206- Connection& connection,
207- unsigned int width,
208- unsigned int height,
209- bool prefer_alpha,
210- bool hardware)
211- : stream{create_stream(connection, width, height, prefer_alpha, hardware),
212- &mir_buffer_stream_release_sync}
213-{
214- if (!mir_buffer_stream_is_valid(stream.get()))
215- {
216- // TODO: Huh. There's no mir_buffer_stream_get_error?
217- throw std::runtime_error("Could not create buffer stream.");
218- }
219-}
220-
221-me::BufferStream::operator MirBufferStream*() const
222-{
223- return stream.get();
224-}
225-
226-MirBufferStream* me::BufferStream::create_stream(
227- MirConnection *connection,
228- unsigned int width,
229- unsigned int height,
230- bool prefer_alpha,
231- bool hardware)
232-{
233- MirPixelFormat selected_format;
234- unsigned int valid_formats{0};
235- MirPixelFormat pixel_formats[mir_pixel_formats];
236- mir_connection_get_available_surface_formats(connection, pixel_formats, mir_pixel_formats, &valid_formats);
237- if (valid_formats == 0)
238- throw std::runtime_error("no pixel formats for buffer stream");
239- selected_format = pixel_formats[0];
240- //select an 8 bit opaque format if we can
241- if (!prefer_alpha)
242- {
243- for(auto i = 0u; i < valid_formats; i++)
244- {
245- if (pixel_formats[i] == mir_pixel_format_xbgr_8888 ||
246- pixel_formats[i] == mir_pixel_format_xrgb_8888)
247- {
248- selected_format = pixel_formats[i];
249- break;
250- }
251- }
252- }
253-
254- return mir_connection_create_buffer_stream_sync(
255- connection,
256- width,
257- height,
258- selected_format,
259- hardware ? mir_buffer_usage_hardware : mir_buffer_usage_software);
260-}
261-
262 me::NormalWindow::NormalWindow(me::Connection& connection, unsigned int width, unsigned int height, bool prefers_alpha, bool hardware) :
263 window{create_window(connection, width, height, prefers_alpha, hardware), window_deleter}
264 {
265
266=== modified file 'examples/client_helpers.h'
267--- examples/client_helpers.h 2017-05-08 03:04:26 +0000
268+++ examples/client_helpers.h 2017-05-22 16:48:39 +0000
269@@ -41,33 +41,6 @@
270 MirConnection* connection;
271 };
272
273-class BufferStream
274-{
275-public:
276- BufferStream(
277- Connection& connection,
278- unsigned int width,
279- unsigned int height,
280- bool prefer_alpha = false,
281- bool hardware = true);
282-
283- operator MirBufferStream*() const;
284-private:
285- MirBufferStream* create_stream(
286- MirConnection* connection,
287- unsigned int width,
288- unsigned int height,
289- bool prefer_alpha,
290- bool hardware);
291-
292-#pragma GCC diagnostic push
293-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
294- std::unique_ptr<MirBufferStream, decltype(&mir_buffer_stream_release_sync)> const stream;
295-#pragma GCC diagnostic pop
296- BufferStream(BufferStream const&) = delete;
297- BufferStream& operator=(BufferStream const&) = delete;
298-};
299-
300 class NormalWindow
301 {
302 public:
303
304=== modified file 'examples/eglapp.c'
305--- examples/eglapp.c 2017-05-08 05:23:46 +0000
306+++ examples/eglapp.c 2017-05-22 16:48:39 +0000
307@@ -34,6 +34,7 @@
308 static const char* appname = "egldemo";
309
310 static MirConnection *connection;
311+static MirRenderSurface* surface;
312 static MirWindow* window;
313 static EGLDisplay egldisplay;
314 static EGLSurface eglsurface;
315@@ -41,10 +42,6 @@
316 static double refresh_rate = 0.0;
317 static mir_eglapp_bool alt_vsync = 0;
318
319-#pragma GCC diagnostic push
320-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
321-static MirRenderSurface* surface;
322-
323 #define CHECK(_cond, _err) \
324 if (!(_cond)) \
325 { \
326@@ -86,15 +83,6 @@
327 return running;
328 }
329
330-/* Apparently usleep is deprecated so we write own own... */
331-static void micro_sleep(unsigned long usec)
332-{
333- struct timespec ts = {0, usec * 1000};
334- while (nanosleep(&ts, &ts) && errno == EINTR)
335- {
336- }
337-}
338-
339 void mir_eglapp_swap_buffers(void)
340 {
341 EGLint width, height;
342@@ -103,11 +91,6 @@
343 return;
344
345 eglSwapBuffers(egldisplay, eglsurface);
346- if (alt_vsync)
347- {
348- MirBufferStream* bs = mir_window_get_buffer_stream(window);
349- micro_sleep(mir_buffer_stream_get_microseconds_till_vblank(bs));
350- }
351
352 /*
353 * Querying the surface (actually the current buffer) dimensions here is
354@@ -350,7 +333,7 @@
355 char const* dims = NULL;
356 char const* cursor_name = mir_default_cursor_name;
357 unsigned int rgb_bits = 8;
358- mir_eglapp_bool help = 0, no_vsync = 0, quiet = 0, new_egl = 0;
359+ mir_eglapp_bool help = 0, no_vsync = 0, quiet = 0;
360 mir_eglapp_bool fullscreen = !*width || !*height;
361
362 struct mir_eglapp_arg const default_args[] =
363@@ -367,7 +350,6 @@
364 {"-o <id>", "%u", &output_id, "Force placement on output monitor ID"},
365 {"-q", "!", &quiet, "Quiet mode (no messages output)"},
366 {"-s <width>x<height>", "=", &dims, "Force window size"},
367- {"-r", "!", &new_egl, "Use new EGL (must have new EGL backend installed)"},
368 {"--", "$", NULL, "Ignore all arguments that follow"},
369 {NULL, NULL, NULL, NULL}
370 };
371@@ -411,18 +393,8 @@
372 connection = mir_connect_sync(mir_socket, appname);
373 CHECK(mir_connection_is_valid(connection), "Can't get connection");
374
375- if (new_egl)
376- {
377- printf("Using the new EGL driver - program will crash if your EGL"
378- " driver does not support the new EGL backend.\n");
379- egldisplay = eglGetDisplay(connection);
380- }
381- else
382- {
383- printf("Using the legacy EGL driver.\n");
384- egldisplay = eglGetDisplay(
385- mir_connection_get_egl_native_display(connection));
386- }
387+ egldisplay = eglGetDisplay(connection);
388+
389 CHECK(egldisplay != EGL_NO_DISPLAY, "Can't eglGetDisplay");
390
391 ok = eglInitialize(egldisplay, NULL, NULL);
392@@ -444,45 +416,42 @@
393 CHECK(ok, "Could not eglChooseConfig");
394 CHECK(neglconfigs > 0, "No EGL config available");
395
396- MirPixelFormat pixel_format =
397- mir_connection_get_egl_pixel_format(connection, egldisplay, eglconfig);
398-
399- printf("Mir chose pixel format %d.\n", pixel_format);
400- if (alpha_bits == 0)
401- {
402- /*
403- * If we are opaque then it's OK to switch pixel format slightly,
404- * to enable bypass/overlays to work. Otherwise the presence of an
405- * alpha channel would prevent them from being used.
406- * It would be really nice if Mesa just gave us the right answer in
407- * the first place though. (LP: #1480755)
408- */
409- if (pixel_format == mir_pixel_format_abgr_8888)
410- pixel_format = mir_pixel_format_xbgr_8888;
411- else if (pixel_format == mir_pixel_format_argb_8888)
412- pixel_format = mir_pixel_format_xrgb_8888;
413- }
414- printf("Using pixel format %d.\n", pixel_format);
415-
416 MirWindowSpec *spec =
417 mir_create_normal_window_spec(connection, *width, *height);
418
419 CHECK(spec != NULL, "Can't create a window spec");
420
421 if (fullscreen)
422+ {
423 mir_window_spec_set_state(spec, mir_window_state_fullscreen);
424
425- if (new_egl)
426- {
427- surface = mir_connection_create_render_surface_sync(connection, *width, *height);
428- CHECK(mir_render_surface_is_valid(surface), "could not create surface");
429- CHECK(mir_render_surface_get_error_message(surface), "");
430- mir_window_spec_add_render_surface(spec, surface, *width, *height, 0, 0);
431- }
432- else
433- {
434- mir_window_spec_set_pixel_format(spec, pixel_format);
435- }
436+ MirDisplayConfig* display_config =
437+ mir_connection_create_display_configuration(connection);
438+
439+ int const count = mir_display_config_get_num_outputs(display_config);
440+
441+ for (int i = 0; i != count; ++i)
442+ {
443+ MirOutput const* output = mir_display_config_get_output(display_config, i);
444+
445+ if (mir_output_get_connection_state(output) == mir_output_connection_state_connected &&
446+ mir_output_is_enabled(output))
447+ {
448+ MirOutputMode const* mode = mir_output_get_current_mode(output);
449+ *width = mir_output_mode_get_width(mode);
450+ *height = mir_output_mode_get_height(mode);
451+
452+ break;
453+ }
454+ }
455+
456+ mir_display_config_release(display_config);
457+ }
458+
459+ surface = mir_connection_create_render_surface_sync(connection, *width, *height);
460+ CHECK(mir_render_surface_is_valid(surface), "could not create surface");
461+ CHECK(mir_render_surface_get_error_message(surface), "");
462+ mir_window_spec_add_render_surface(spec, surface, *width, *height, 0, 0);
463
464 char const* name = argv[0];
465 for (char const* p = name; *p; p++)
466@@ -507,19 +476,11 @@
467 mir_window_apply_spec(window, spec);
468 mir_window_spec_release(spec);
469
470- if (new_egl)
471- {
472- eglsurface = eglCreateWindowSurface(egldisplay,
473- eglconfig,
474- (EGLNativeWindowType)surface,
475- NULL);
476- }
477- else
478- {
479- eglsurface = eglCreateWindowSurface(egldisplay, eglconfig,
480- (EGLNativeWindowType)mir_buffer_stream_get_egl_native_window(mir_window_get_buffer_stream(window)), NULL);
481- }
482-
483+ eglsurface = eglCreateWindowSurface(egldisplay,
484+ eglconfig,
485+ (EGLNativeWindowType)surface,
486+ NULL);
487+
488 CHECK(eglsurface != EGL_NO_SURFACE, "eglCreateWindowSurface failed");
489
490 eglctx = eglCreateContext(egldisplay, eglconfig, EGL_NO_CONTEXT,
491@@ -558,7 +519,6 @@
492
493 return 1;
494 }
495-#pragma GCC diagnostic pop
496
497 struct MirConnection* mir_eglapp_native_connection()
498 {
499
500=== modified file 'examples/fingerpaint.c'
501--- examples/fingerpaint.c 2017-05-08 03:04:26 +0000
502+++ examples/fingerpaint.c 2017-05-22 16:48:39 +0000
503@@ -182,33 +182,70 @@
504 }
505 }
506
507-static void on_event(MirWindow *surface, const MirEvent *event, void *context)
508+typedef struct Context
509 {
510- (void)surface;
511- MirGraphicsRegion *canvas = (MirGraphicsRegion*)context;
512+ MirConnection *connection;
513+ MirRenderSurface* surface;
514+ MirWindow* window;
515+ MirGraphicsRegion* canvas;
516+} Context;
517
518- static const Color color[] =
519- {
520- {0x80, 0xff, 0x00, 0xff},
521- {0x00, 0xff, 0x80, 0xff},
522- {0xff, 0x00, 0x80, 0xff},
523- {0xff, 0x80, 0x00, 0xff},
524- {0x00, 0x80, 0xff, 0xff},
525- {0x80, 0x00, 0xff, 0xff},
526- {0xff, 0xff, 0x00, 0xff},
527- {0x00, 0xff, 0xff, 0xff},
528- {0xff, 0x00, 0xff, 0xff},
529- {0xff, 0x00, 0x00, 0xff},
530- {0x00, 0xff, 0x00, 0xff},
531- {0x00, 0x00, 0xff, 0xff},
532- };
533-
534- MirEventType event_type = mir_event_get_type(event);
535+static void on_event(MirWindow *window, const MirEvent *event, void *context_)
536+{
537+ Context* context = (Context*)context_;
538
539 pthread_mutex_lock(&mutex);
540
541- if (event_type == mir_event_type_input)
542- {
543+ switch (mir_event_get_type(event))
544+ {
545+ case mir_event_type_resize:
546+ {
547+ MirResizeEvent const* resize = mir_event_get_resize_event(event);
548+ int const new_width = mir_resize_event_get_width(resize);
549+ int const new_height = mir_resize_event_get_height(resize);
550+
551+ mir_render_surface_set_size(context->surface, new_width, new_height);
552+ MirWindowSpec* spec = mir_create_window_spec(context->connection);
553+ mir_window_spec_add_render_surface(spec, context->surface, new_width, new_height, 0, 0);
554+ mir_window_apply_spec(window, spec);
555+ mir_window_spec_release(spec);
556+ break;
557+ }
558+
559+ case mir_event_type_close_window:
560+ {
561+ static int closing = 0;
562+
563+ ++closing;
564+ if (closing == 1)
565+ printf("Sure you don't want to save your work?\n");
566+ else if (closing > 1)
567+ {
568+ printf("Oh I forgot you can't save your work. Quitting now...\n");
569+ running = false;
570+ changed = true;
571+ }
572+ break;
573+ }
574+
575+ case mir_event_type_input:
576+ {
577+ static const Color color[] =
578+ {
579+ {0x80, 0xff, 0x00, 0xff},
580+ {0x00, 0xff, 0x80, 0xff},
581+ {0xff, 0x00, 0x80, 0xff},
582+ {0xff, 0x80, 0x00, 0xff},
583+ {0x00, 0x80, 0xff, 0xff},
584+ {0x80, 0x00, 0xff, 0xff},
585+ {0xff, 0xff, 0x00, 0xff},
586+ {0x00, 0xff, 0xff, 0xff},
587+ {0xff, 0x00, 0xff, 0xff},
588+ {0xff, 0x00, 0x00, 0xff},
589+ {0x00, 0xff, 0x00, 0xff},
590+ {0x00, 0x00, 0xff, 0xff},
591+ };
592+
593 static size_t base_color = 0;
594 static size_t max_fingers = 0;
595 static float max_pressure = 1.0f;
596@@ -232,8 +269,7 @@
597 pev = mir_input_event_get_pointer_event(input_event);
598 ended = mir_pointer_event_action(pev) ==
599 mir_pointer_action_button_up;
600- touch_count = mir_pointer_event_button_state(pev,
601- mir_pointer_button_primary) ? 1 : 0;
602+ touch_count = mir_pointer_event_button_state(pev, mir_pointer_button_primary) ? 1 : 0;
603 default:
604 break;
605 }
606@@ -263,15 +299,15 @@
607 x = mir_touch_event_axis_value(tev, p, mir_touch_axis_x);
608 y = mir_touch_event_axis_value(tev, p, mir_touch_axis_y);
609 float m = mir_touch_event_axis_value(tev, p,
610- mir_touch_axis_touch_major);
611+ mir_touch_axis_touch_major);
612 float n = mir_touch_event_axis_value(tev, p,
613- mir_touch_axis_touch_minor);
614+ mir_touch_axis_touch_minor);
615 radius = (m + n) / 4; /* Half the average */
616 // mir_touch_axis_touch_major can be 0
617 if (radius < 5)
618 radius = 5;
619 pressure = mir_touch_event_axis_value(tev, p,
620- mir_touch_axis_pressure);
621+ mir_touch_axis_pressure);
622 }
623 else if (pev != NULL)
624 {
625@@ -293,29 +329,17 @@
626 pressure /= max_pressure;
627 tone.a *= pressure;
628
629- draw_box(canvas, x - radius, y - radius, 2*radius, &tone);
630+ draw_box(context->canvas, x - radius, y - radius, 2*radius, &tone);
631 }
632-
633- changed = true;
634- }
635- }
636- else if (event_type == mir_event_type_close_window)
637- {
638- static int closing = 0;
639-
640- ++closing;
641- if (closing == 1)
642- printf("Sure you don't want to save your work?\n");
643- else if (closing > 1)
644- {
645- printf("Oh I forgot you can't save your work. Quitting now...\n");
646- running = false;
647- changed = true;
648- }
649- }
650- else if (event_type == mir_event_type_resize)
651- {
652- changed = true;
653+
654+ changed = true;
655+ }
656+
657+ break;
658+ }
659+
660+ default:
661+ break;
662 }
663
664 pthread_cond_signal(&change);
665@@ -340,14 +364,12 @@
666 return NULL;
667 }
668
669-#pragma GCC diagnostic push
670-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
671 int main(int argc, char *argv[])
672 {
673 static const Color background = {180, 180, 150, 255};
674- MirConnection *conn;
675- MirWindow* window;
676 MirGraphicsRegion canvas;
677+ Context context = { NULL, NULL, NULL, &canvas };
678+
679 int swap_interval = 0;
680
681 char *mir_socket = NULL;
682@@ -409,21 +431,21 @@
683 }
684 }
685
686- conn = mir_connect_sync(mir_socket, argv[0]);
687- if (!mir_connection_is_valid(conn))
688+ context.connection = mir_connect_sync(mir_socket, argv[0]);
689+ if (!mir_connection_is_valid(context.connection))
690 {
691- fprintf(stderr, "Could not connect to a display server: %s\n", mir_connection_get_error_message(conn));
692+ fprintf(stderr, "Could not connect to a display server: %s\n", mir_connection_get_error_message(context.connection));
693 return 1;
694 }
695
696 MirDisplayConfig* display_config =
697- mir_connection_create_display_configuration(conn);
698+ mir_connection_create_display_configuration(context.connection);
699
700 MirOutput const* output = find_active_output(display_config);
701 if (output == NULL)
702 {
703 fprintf(stderr, "No active outputs found.\n");
704- mir_connection_release(conn);
705+ mir_connection_release(context.connection);
706 return 1;
707 }
708
709@@ -443,7 +465,7 @@
710 if (pixel_format == mir_pixel_format_invalid)
711 {
712 fprintf(stderr, "Could not find a fast 32-bit pixel format\n");
713- mir_connection_release(conn);
714+ mir_connection_release(context.connection);
715 return 1;
716 }
717
718@@ -453,19 +475,19 @@
719
720 mir_display_config_release(display_config);
721
722- MirWindowSpec *spec = mir_create_normal_window_spec(conn, width, height);
723- mir_window_spec_set_pixel_format(spec, pixel_format);
724+ context.surface = mir_connection_create_render_surface_sync(context.connection, width, height);
725+ MirWindowSpec *spec = mir_create_normal_window_spec(context.connection, width, height);
726 mir_window_spec_set_name(spec, "Mir Fingerpaint");
727- mir_window_spec_set_buffer_usage(spec, mir_buffer_usage_software);
728+ mir_window_spec_add_render_surface(spec, context.surface, width, height, 0, 0);
729
730- window = mir_create_window_sync(spec);
731+ context.window = mir_create_window_sync(spec);
732 mir_window_spec_release(spec);
733
734- if (window != NULL)
735+ if (context.window != NULL)
736 {
737- MirBufferStream* bs = mir_window_get_buffer_stream(window);
738+ mir_window_set_event_handler(context.window, &on_event, &context);
739+ MirBufferStream* bs = mir_render_surface_get_buffer_stream(context.surface, width, height, pixel_format);
740 mir_buffer_stream_set_swapinterval(bs, swap_interval);
741- mir_window_set_event_handler(window, &on_event, &canvas);
742
743 canvas.width = width;
744 canvas.height = height;
745@@ -497,7 +519,7 @@
746 }
747
748 /* Ensure canvas won't be used after it's freed */
749- mir_window_set_event_handler(window, NULL, NULL);
750+ mir_window_set_event_handler(context.window, NULL, NULL);
751 free(canvas.vaddr);
752 }
753 else
754@@ -505,15 +527,15 @@
755 fprintf(stderr, "Failed to malloc canvas\n");
756 }
757
758- mir_window_release_sync(window);
759+ mir_window_release_sync(context.window);
760 }
761 else
762 {
763 fprintf(stderr, "mir_connection_create_surface_sync failed\n");
764 }
765
766- mir_connection_release(conn);
767+ mir_render_surface_release(context.surface);
768+ mir_connection_release(context.connection);
769
770 return 0;
771 }
772-#pragma GCC diagnostic pop
773
774=== modified file 'examples/flicker.c'
775--- examples/flicker.c 2017-05-08 03:04:26 +0000
776+++ examples/flicker.c 2017-05-22 16:48:39 +0000
777@@ -101,11 +101,48 @@
778 }
779 }
780
781-#pragma GCC diagnostic push
782-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
783+typedef struct Context
784+{
785+ MirConnection *connection;
786+ MirRenderSurface* surface;
787+} Context;
788+
789+static void handle_event(MirWindow* window, MirEvent const* ev, void* context_)
790+{
791+ Context* context = (Context*)context_;
792+
793+ switch (mir_event_get_type(ev))
794+ {
795+ case mir_event_type_resize:
796+ {
797+ MirResizeEvent const* resize = mir_event_get_resize_event(ev);
798+ int const new_width = mir_resize_event_get_width(resize);
799+ int const new_height = mir_resize_event_get_height(resize);
800+
801+ mir_render_surface_set_size(context->surface, new_width, new_height);
802+ MirWindowSpec* spec = mir_create_window_spec(context->connection);
803+ mir_window_spec_add_render_surface(spec, context->surface, new_width, new_height, 0, 0);
804+ mir_window_apply_spec(window, spec);
805+ mir_window_spec_release(spec);
806+ break;
807+ }
808+
809+ case mir_event_type_close_window:
810+ running = 0;
811+ printf("Received close event from server.\n");
812+ break;
813+
814+ default:
815+ break;
816+ }
817+}
818+
819+
820 int main(int argc, char* argv[])
821 {
822- MirConnection *connection = 0;
823+ static int const width = 640;
824+ static int const height = 480;
825+
826 MirWindow *window = 0;
827 int swapinterval = 1;
828
829@@ -140,25 +177,30 @@
830 }
831 }
832
833+ Context context = { 0, 0 };
834+
835 puts("Starting");
836
837- connection = mir_connect_sync(socket_file, __FILE__);
838- assert(connection != NULL);
839- assert(mir_connection_is_valid(connection));
840- assert(strcmp(mir_connection_get_error_message(connection), "") == 0);
841+ context.connection = mir_connect_sync(socket_file, __FILE__);
842+ assert(context.connection != NULL);
843+ assert(mir_connection_is_valid(context.connection));
844+ assert(strcmp(mir_connection_get_error_message(context.connection), "") == 0);
845 puts("Connected");
846
847 unsigned int const num_formats = 32;
848 MirPixelFormat pixel_formats[num_formats];
849 unsigned int valid_formats;
850- mir_connection_get_available_surface_formats(connection, pixel_formats, num_formats, &valid_formats);
851+ mir_connection_get_available_surface_formats(context.connection, pixel_formats, num_formats, &valid_formats);
852 MirPixelFormat pixel_format = find_8888_format(pixel_formats, valid_formats);
853
854- MirWindowSpec *spec = mir_create_normal_window_spec(connection, 640, 480);
855+ context.surface = mir_connection_create_render_surface_sync(context.connection, width, height);
856+ puts("Surface created");
857+
858+ MirWindowSpec *spec = mir_create_normal_window_spec(context.connection, width, height);
859 assert(spec != NULL);
860- mir_window_spec_set_pixel_format(spec, pixel_format);
861 mir_window_spec_set_name(spec, __FILE__);
862- mir_window_spec_set_buffer_usage(spec, mir_buffer_usage_software);
863+ mir_window_spec_add_render_surface(spec, context.surface, width, height, 0, 0);
864+ mir_window_spec_set_event_handler(spec, handle_event, &context);
865
866 window = mir_create_window_sync(spec);
867 mir_window_spec_release(spec);
868@@ -168,7 +210,7 @@
869 assert(strcmp(mir_window_get_error_message(window), "") == 0);
870 puts("Window created");
871
872- MirBufferStream* bs = mir_window_get_buffer_stream(window);
873+ MirBufferStream* bs = mir_render_surface_get_buffer_stream(context.surface, width, height, pixel_format);
874 mir_buffer_stream_set_swapinterval(bs, swapinterval);
875
876 uint32_t pattern[2] = {0};
877@@ -192,9 +234,11 @@
878 mir_window_release_sync(window);
879 puts("Window released");
880
881- mir_connection_release(connection);
882+ mir_render_surface_release(context.surface);
883+ puts("Surface released");
884+
885+ mir_connection_release(context.connection);
886 puts("Connection released");
887
888 return 0;
889 }
890-#pragma GCC diagnostic pop
891
892=== modified file 'examples/multi_stream.cpp'
893--- examples/multi_stream.cpp 2017-05-08 03:04:26 +0000
894+++ examples/multi_stream.cpp 2017-05-22 16:48:39 +0000
895@@ -30,9 +30,42 @@
896 #include <memory>
897
898 namespace po = boost::program_options;
899-
900 namespace me = mir::examples;
901
902+namespace
903+{
904+class MyBufferStream
905+{
906+public:
907+ MyBufferStream(
908+ me::Connection& connection,
909+ int width,
910+ int height,
911+ int displacement_x,
912+ int displacement_y);
913+
914+ operator MirBufferStream*() const { return bs; }
915+ operator MirRenderSurface*() const;
916+
917+ int displacement_x{0};
918+ int displacement_y{0};
919+ int width{0};
920+ int height{0};
921+
922+ MyBufferStream& operator=(MyBufferStream &&) = default;
923+ MyBufferStream(MyBufferStream &&) = default;
924+
925+private:
926+
927+ MirBufferStream* get_stream(MirConnection* connection, int width, int height) const;
928+
929+ std::unique_ptr<MirRenderSurface, decltype(&mir_render_surface_release)> stream;
930+ MirBufferStream* bs;
931+
932+ MyBufferStream(MyBufferStream const&) = delete;
933+ MyBufferStream& operator=(MyBufferStream const&) = delete;
934+};
935+
936 class Pixel
937 {
938 public:
939@@ -93,6 +126,8 @@
940 void* const addr;
941 MirPixelFormat const format;
942 };
943+}
944+
945
946 class pixel_iterator : std::iterator<std::random_access_iterator_tag, Pixel>
947 {
948@@ -180,6 +215,7 @@
949 position += delta;
950 }
951
952+
953 int main(int argc, char* argv[])
954 {
955 po::options_description desc("Mir multi-bufferstream example:");
956@@ -206,40 +242,25 @@
957 me::Connection connection{socket, "Multiple MirBufferStream example"};
958
959 me::NormalWindow window{connection, 200, 200, true, false};
960-#pragma GCC diagnostic push
961-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
962- MirBufferStream* surface_stream = mir_window_get_buffer_stream(window);
963-#pragma GCC diagnostic pop
964+
965+ std::vector<MyBufferStream> stream;
966+
967+ stream.emplace_back(connection, 200, 200, 0, 0);
968+ fill_stream_with(stream[0], 255, 0, 0, 128);
969+ mir_buffer_stream_swap_buffers_sync(stream[0]);
970+
971+ stream.emplace_back(connection, 50, 50, 50, 50);
972+ fill_stream_with(stream[1], 0, 0, 255, 128);
973+ mir_buffer_stream_swap_buffers_sync(stream[1]);
974+
975 int topSize = 100, dTopSize = 2;
976- auto top = std::make_unique<me::BufferStream>(connection, topSize, topSize, true, false);
977- me::BufferStream bottom(connection, 50, 50, true, false);
978-
979- fill_stream_with(surface_stream, 255, 0, 0, 128);
980- mir_buffer_stream_swap_buffers_sync(surface_stream);
981- fill_stream_with(*top, 0, 255, 0, 128);
982- mir_buffer_stream_swap_buffers_sync(*top);
983- fill_stream_with(bottom, 0, 0, 255, 128);
984- mir_buffer_stream_swap_buffers_sync(bottom);
985-
986- std::array<MirBufferStreamInfo, 3> arrangement;
987-
988- arrangement[0].displacement_x = 0;
989- arrangement[0].displacement_y = 0;
990- arrangement[0].stream = surface_stream;
991-
992- arrangement[1].displacement_x = 50;
993- arrangement[1].displacement_y = 50;
994- arrangement[1].stream = bottom;
995-
996- arrangement[2].displacement_x = -40;
997- arrangement[2].displacement_y = -10;
998- arrangement[2].stream = *top;
999+ stream.emplace_back(connection, topSize, topSize, -40, -10);
1000+ fill_stream_with(stream[2], 0, 255, 0, 128);
1001+ mir_buffer_stream_swap_buffers_sync(stream[2]);
1002
1003 int top_dx{1}, top_dy{2};
1004 int bottom_dx{2}, bottom_dy{-1};
1005
1006- auto spec = mir_create_window_spec(connection);
1007-
1008 int baseColour = 255, dbase = 1;
1009 int topColour = 255, dtop = 1;
1010 int bottomColour = 255, dbottom = 1;
1011@@ -261,10 +282,10 @@
1012
1013 while (poll(&signal_poll, 1, 0) <= 0)
1014 {
1015- bounce_position(arrangement[1].displacement_x, bottom_dx, -100, 300);
1016- bounce_position(arrangement[1].displacement_y, bottom_dy, -100, 300);
1017- bounce_position(arrangement[2].displacement_x, top_dx, -100, 300);
1018- bounce_position(arrangement[2].displacement_y, top_dy, -100, 300);
1019+ bounce_position(stream[1].displacement_x, bottom_dx, -100, 300);
1020+ bounce_position(stream[1].displacement_y, bottom_dy, -100, 300);
1021+ bounce_position(stream[2].displacement_x, top_dx, -100, 300);
1022+ bounce_position(stream[2].displacement_y, top_dy, -100, 300);
1023
1024 bounce_position(baseColour, dbase, 128, 255);
1025 bounce_position(topColour, dtop, 200, 255);
1026@@ -272,24 +293,56 @@
1027
1028 bounce_position(topSize, dTopSize, 70, 120);
1029
1030- top = std::make_unique<me::BufferStream>(connection, topSize, topSize, true, false);
1031- arrangement[2].stream = *top;
1032-
1033- fill_stream_with(surface_stream, baseColour, 0, 0, 128);
1034- fill_stream_with(bottom, 0, 0, bottomColour, 128);
1035- fill_stream_with(*top, 0, topColour, 0, 128);
1036-#pragma GCC diagnostic push
1037-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1038- mir_window_spec_set_streams(spec, arrangement.data(), arrangement.size());
1039-#pragma GCC diagnostic pop
1040- mir_buffer_stream_swap_buffers_sync(surface_stream);
1041- mir_buffer_stream_swap_buffers_sync(bottom);
1042- mir_buffer_stream_swap_buffers_sync(*top);
1043+ stream[2] = MyBufferStream{connection, topSize, topSize, stream[2].displacement_x, stream[2].displacement_y};
1044+
1045+ fill_stream_with(stream[0], baseColour, 0, 0, 128);
1046+ fill_stream_with(stream[1], 0, 0, bottomColour, 128);
1047+ fill_stream_with(stream[2], 0, topColour, 0, 128);
1048+
1049+ auto spec = mir_create_window_spec(connection);
1050+ for (auto& s : stream)
1051+ {
1052+ mir_buffer_stream_swap_buffers_sync(s);
1053+ mir_window_spec_add_render_surface(spec, s, s.width, s.height, s.displacement_x, s.displacement_y);
1054+ }
1055 mir_window_apply_spec(window, spec);
1056+ mir_window_spec_release(spec);
1057 }
1058- mir_window_spec_release(spec);
1059 close(signal_watch);
1060
1061 std::cout << "Quitting; have a nice day." << std::endl;
1062 return 0;
1063 }
1064+
1065+MyBufferStream::MyBufferStream(
1066+ me::Connection& connection,
1067+ int width,
1068+ int height,
1069+ int displacement_x,
1070+ int displacement_y)
1071+ : displacement_x{displacement_x},
1072+ displacement_y{displacement_y},
1073+ width{width},
1074+ height{height},
1075+ stream{mir_connection_create_render_surface_sync(connection, width, height), &mir_render_surface_release},
1076+ bs{get_stream(connection, width, height)}
1077+{
1078+}
1079+
1080+MyBufferStream::operator MirRenderSurface*() const
1081+{
1082+ return stream.get();
1083+}
1084+
1085+MirBufferStream* MyBufferStream::get_stream(MirConnection* connection, int width, int height) const
1086+{
1087+ MirPixelFormat selected_format;
1088+ unsigned int valid_formats{0};
1089+ MirPixelFormat pixel_formats[mir_pixel_formats];
1090+ mir_connection_get_available_surface_formats(connection, pixel_formats, mir_pixel_formats, &valid_formats);
1091+ if (valid_formats == 0)
1092+ throw std::runtime_error("no pixel formats for buffer stream");
1093+ selected_format = pixel_formats[0];
1094+
1095+ return mir_render_surface_get_buffer_stream(stream.get(), width, height, selected_format);
1096+}
1097
1098=== modified file 'examples/multiwin.c'
1099--- examples/multiwin.c 2017-05-08 03:04:26 +0000
1100+++ examples/multiwin.c 2017-05-22 16:48:39 +0000
1101@@ -30,7 +30,10 @@
1102
1103 typedef struct
1104 {
1105+ MirConnection *conn;
1106+ MirRenderSurface* surface;
1107 MirWindow *window;
1108+ MirBufferStream* bs;
1109 Color fill;
1110 } Window;
1111
1112@@ -164,17 +167,59 @@
1113 static void draw_window(Window *win)
1114 {
1115 MirGraphicsRegion region;
1116-#pragma GCC diagnostic push
1117-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1118- MirBufferStream *bs = mir_window_get_buffer_stream(win->window);
1119-#pragma GCC diagnostic pop
1120- mir_buffer_stream_get_graphics_region(bs, &region);
1121+ mir_buffer_stream_get_graphics_region(win->bs, &region);
1122 clear_region(&region, &win->fill);
1123- mir_buffer_stream_swap_buffers_sync(bs);
1124+ mir_buffer_stream_swap_buffers_sync(win->bs);
1125 }
1126
1127 static char const *socket_file = NULL;
1128
1129+static void handle_event(MirWindow* window, MirEvent const* ev, void* context_)
1130+{
1131+ Window* context = (Window*)context_;
1132+
1133+ switch (mir_event_get_type(ev))
1134+ {
1135+ case mir_event_type_resize:
1136+ {
1137+ MirResizeEvent const* resize = mir_event_get_resize_event(ev);
1138+ int const new_width = mir_resize_event_get_width(resize);
1139+ int const new_height = mir_resize_event_get_height(resize);
1140+
1141+ mir_render_surface_set_size(context->surface, new_width, new_height);
1142+ MirWindowSpec* spec = mir_create_window_spec(context->conn);
1143+ mir_window_spec_add_render_surface(spec, context->surface, new_width, new_height, 0, 0);
1144+ mir_window_apply_spec(window, spec);
1145+ mir_window_spec_release(spec);
1146+ break;
1147+ }
1148+
1149+ case mir_event_type_close_window:
1150+ running = 0;
1151+ printf("Received close event from server.\n");
1152+ break;
1153+
1154+ default:
1155+ break;
1156+ }
1157+}
1158+
1159+static void init_window(MirConnection *conn, Window* win, char const* name, int width, int height, Color color, MirPixelFormat pixel_format)
1160+{
1161+ win->conn = conn;
1162+ win->surface = mir_connection_create_render_surface_sync(conn, width, height);
1163+ win->bs = mir_render_surface_get_buffer_stream(win->surface, width, height, pixel_format);
1164+ win->fill = color;
1165+ premultiply_alpha(&win->fill);
1166+
1167+ MirWindowSpec *spec= mir_create_normal_window_spec(conn, width, height);
1168+ mir_window_spec_set_name(spec, name);
1169+ mir_window_spec_add_render_surface(spec, win->surface, width, height, 0, 0);
1170+ mir_window_spec_set_event_handler(spec, &handle_event, win);
1171+ win->window = mir_create_window_sync(spec);
1172+ mir_window_spec_release(spec);
1173+}
1174+
1175 int main(int argc, char *argv[])
1176 {
1177 MirConnection *conn;
1178@@ -225,8 +270,7 @@
1179 {
1180 MirPixelFormat formats[mir_pixel_formats];
1181 unsigned int valid_formats;
1182- mir_connection_get_available_surface_formats(conn, formats,
1183- mir_pixel_formats, &valid_formats);
1184+ mir_connection_get_available_surface_formats(conn, formats, mir_pixel_formats, &valid_formats);
1185
1186 for (f = 0; f < valid_formats; f++)
1187 {
1188@@ -245,49 +289,13 @@
1189 }
1190 }
1191
1192- MirWindowSpec *spec = mir_create_normal_window_spec(conn, 225, 225);
1193- if (spec == NULL)
1194- {
1195- fprintf(stderr, "Could not create a window spec.\n");
1196- mir_connection_release(conn);
1197- return 1;
1198- }
1199-
1200-#pragma GCC diagnostic push
1201-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1202- mir_window_spec_set_pixel_format(spec, pixel_format);
1203- mir_window_spec_set_buffer_usage(spec, mir_buffer_usage_software);
1204-#pragma GCC diagnostic pop
1205- mir_window_spec_set_name(spec, "red");
1206-
1207- win[0].window = mir_create_window_sync(spec);
1208- win[0].fill.r = 0xff;
1209- win[0].fill.g = 0x00;
1210- win[0].fill.b = 0x00;
1211- win[0].fill.a = alpha;
1212- premultiply_alpha(&win[0].fill);
1213-
1214- mir_window_spec_set_name(spec, "green");
1215- mir_window_spec_set_width(spec, 300);
1216- mir_window_spec_set_height(spec, 150);
1217- win[1].window = mir_create_window_sync(spec);
1218- win[1].fill.r = 0x00;
1219- win[1].fill.g = 0xff;
1220- win[1].fill.b = 0x00;
1221- win[1].fill.a = alpha;
1222- premultiply_alpha(&win[1].fill);
1223-
1224- mir_window_spec_set_name(spec, "blue");
1225- mir_window_spec_set_width(spec, 150);
1226- mir_window_spec_set_height(spec, 300);
1227- win[2].window = mir_create_window_sync(spec);
1228- win[2].fill.r = 0x00;
1229- win[2].fill.g = 0x00;
1230- win[2].fill.b = 0xff;
1231- win[2].fill.a = alpha;
1232- premultiply_alpha(&win[2].fill);
1233-
1234- mir_window_spec_release(spec);
1235+ Color red = {0xff, 0x00, 0x00, alpha};
1236+ Color green = {0x00, 0xff, 0x00, alpha};
1237+ Color blue = {0x00, 0x00, 0xff, alpha};
1238+
1239+ init_window(conn, win+0, "red", 255, 255, red, pixel_format);
1240+ init_window(conn, win+1, "green", 300, 150, green, pixel_format);
1241+ init_window(conn, win+2, "blue", 150, 300, blue, pixel_format);
1242
1243 signal(SIGINT, shutdown);
1244 signal(SIGTERM, shutdown);
1245@@ -295,14 +303,16 @@
1246
1247 while (running)
1248 {
1249- int w;
1250- for (w = 0; w < (int)(sizeof(win)/sizeof(win[0])); w++)
1251+ for (int w = 0; w < (int)(sizeof(win)/sizeof(win[0])); w++)
1252 draw_window(win + w);
1253 }
1254
1255- mir_window_release_sync(win[0].window);
1256- mir_window_release_sync(win[1].window);
1257- mir_window_release_sync(win[2].window);
1258+ for (int w = 0; w < (int)(sizeof(win)/sizeof(win[0])); w++)
1259+ {
1260+ mir_window_release_sync(win[w].window);
1261+ mir_render_surface_release(win[w].surface);
1262+ }
1263+
1264 mir_connection_release(conn);
1265
1266 return 0;
1267
1268=== modified file 'examples/prerendered_frames.c'
1269--- examples/prerendered_frames.c 2017-05-08 03:04:26 +0000
1270+++ examples/prerendered_frames.c 2017-05-22 16:48:39 +0000
1271@@ -92,8 +92,6 @@
1272 rendering = 0;
1273 }
1274
1275-#pragma GCC diagnostic push
1276-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1277 int main(int argc, char** argv)
1278 {
1279 static char const *socket_file = NULL;
1280@@ -149,31 +147,24 @@
1281 return -1;
1282 }
1283
1284- MirRenderSurface* render_surface = mir_connection_create_render_surface_sync(connection, width, height);
1285- if (!mir_render_surface_is_valid(render_surface))
1286+ MirRenderSurface* surface = mir_connection_create_render_surface_sync(connection, width, height);
1287+ if (!mir_render_surface_is_valid(surface))
1288 {
1289 printf("could not create a render surface\n");
1290 return -1;
1291 }
1292
1293- MirPresentationChain* chain = mir_render_surface_get_presentation_chain(render_surface);
1294+ MirPresentationChain* chain = mir_render_surface_get_presentation_chain(surface);
1295 if (!mir_presentation_chain_is_valid(chain))
1296 {
1297 printf("could not create MirPresentationChain\n");
1298
1299-// TODO this is a frig to pass smoke tests until we support NBS by default
1300-#if (MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 3, 0))
1301- printf("This is currently an unreleased API - likely server support is switched off\n");
1302- return 0;
1303-#else
1304 return -1;
1305-#endif
1306 }
1307
1308 MirWindowSpec* spec = mir_create_normal_window_spec(connection, width, height);
1309- mir_window_spec_set_pixel_format(spec, format);
1310 mir_window_spec_add_render_surface(
1311- spec, render_surface, width, height, displacement_x, displacement_y);
1312+ spec, surface, width, height, displacement_x, displacement_y);
1313 MirWindow* window = mir_create_window_sync(spec);
1314 if (!mir_window_is_valid(window))
1315 {
1316@@ -234,9 +225,8 @@
1317
1318 for (i = 0u; i < num_prerendered_frames; i++)
1319 mir_buffer_release(buffer_available[i].buffer);
1320- mir_render_surface_release(render_surface);
1321+ mir_render_surface_release(surface);
1322 mir_window_release_sync(window);
1323 mir_connection_release(connection);
1324 return 0;
1325 }
1326-#pragma GCC diagnostic pop
1327
1328=== modified file 'examples/progressbar.c'
1329--- examples/progressbar.c 2017-05-08 03:04:26 +0000
1330+++ examples/progressbar.c 2017-05-22 16:48:39 +0000
1331@@ -52,6 +52,42 @@
1332 }
1333 }
1334
1335+typedef struct
1336+{
1337+ MirConnection *conn;
1338+ MirRenderSurface* surface;
1339+} Surface;
1340+
1341+static void handle_event(MirWindow* window, MirEvent const* ev, void* context_)
1342+{
1343+ Surface* context = (Surface*)context_;
1344+
1345+ switch (mir_event_get_type(ev))
1346+ {
1347+ case mir_event_type_resize:
1348+ {
1349+ MirResizeEvent const* resize = mir_event_get_resize_event(ev);
1350+ int const new_width = mir_resize_event_get_width(resize);
1351+ int const new_height = mir_resize_event_get_height(resize);
1352+
1353+ mir_render_surface_set_size(context->surface, new_width, new_height);
1354+ MirWindowSpec* spec = mir_create_window_spec(context->conn);
1355+ mir_window_spec_add_render_surface(spec, context->surface, new_width, new_height, 0, 0);
1356+ mir_window_apply_spec(window, spec);
1357+ mir_window_spec_release(spec);
1358+ break;
1359+ }
1360+
1361+ case mir_event_type_close_window:
1362+ running = 0;
1363+ printf("Received close event from server.\n");
1364+ break;
1365+
1366+ default:
1367+ break;
1368+ }
1369+}
1370+
1371 static void blend(uint32_t *dest, uint32_t src, int alpha_shift)
1372 {
1373 uint8_t *d = (uint8_t*)dest;
1374@@ -181,13 +217,9 @@
1375 }
1376 }
1377
1378-static void redraw(MirWindow *window, const MirGraphicsRegion *canvas)
1379+static void redraw(MirBufferStream *bs, const MirGraphicsRegion *canvas)
1380 {
1381 MirGraphicsRegion backbuffer;
1382-#pragma GCC diagnostic push
1383-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1384- MirBufferStream *bs = mir_window_get_buffer_stream(window);
1385-#pragma GCC diagnostic pop
1386
1387 mir_buffer_stream_get_graphics_region(bs, &backbuffer);
1388 clear_region(&backbuffer, background);
1389@@ -253,17 +285,25 @@
1390
1391 int width = 500;
1392 int height = 500;
1393+
1394+ Surface surface;
1395+
1396+ surface.conn = conn;
1397+ surface.surface = mir_connection_create_render_surface_sync(conn, width, height);
1398+ MirBufferStream *bs = mir_render_surface_get_buffer_stream(surface.surface, width, height, pixel_format);
1399+
1400 MirWindowSpec *spec = mir_create_normal_window_spec(conn, width, height);
1401+
1402+ mir_window_spec_add_render_surface(spec, surface.surface, width, height, 0, 0);
1403+ mir_window_spec_set_event_handler(spec, &handle_event, &surface);
1404+
1405 if (spec == NULL)
1406 {
1407 fprintf(stderr, "Could not create a window spec.\n");
1408 mir_connection_release(conn);
1409 return 1;
1410 }
1411-#pragma GCC diagnostic push
1412-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1413- mir_window_spec_set_pixel_format(spec, pixel_format);
1414-#pragma GCC diagnostic pop
1415+
1416 {
1417 char name[128];
1418 snprintf(name, sizeof(name)-1, "Progress Bars (%dHz)", hz);
1419@@ -271,10 +311,6 @@
1420 mir_window_spec_set_name(spec, name);
1421 }
1422
1423-#pragma GCC diagnostic push
1424-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1425- mir_window_spec_set_buffer_usage(spec, mir_buffer_usage_software);
1426-#pragma GCC diagnostic pop
1427 window = mir_create_window_sync(spec);
1428 mir_window_spec_release(spec);
1429
1430@@ -311,7 +347,7 @@
1431
1432 draw_box(&canvas, x, y, box_width, foreground);
1433
1434- redraw(window, &canvas);
1435+ redraw(bs, &canvas);
1436 usleep(1000000 / hz);
1437 }
1438
1439
1440=== modified file 'examples/release_at_exit.c'
1441--- examples/release_at_exit.c 2017-05-08 03:04:26 +0000
1442+++ examples/release_at_exit.c 2017-05-22 16:48:39 +0000
1443@@ -47,10 +47,6 @@
1444 unsigned int valid_formats;
1445 mir_connection_get_available_surface_formats(connection, &pixel_format, 1, &valid_formats);
1446 MirWindowSpec *spec = mir_create_normal_window_spec(connection, 640, 480);
1447-#pragma GCC diagnostic push
1448-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1449- mir_window_spec_set_pixel_format(spec, pixel_format);
1450-#pragma GCC diagnostic pop
1451 window = mir_create_window_sync(spec);
1452 mir_window_spec_release(spec);
1453
1454
1455=== modified file 'examples/render_surface.cpp'
1456--- examples/render_surface.cpp 2017-05-08 03:04:26 +0000
1457+++ examples/render_surface.cpp 2017-05-22 16:48:39 +0000
1458@@ -179,8 +179,6 @@
1459 position += delta;
1460 }
1461
1462-#pragma GCC diagnostic push
1463-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1464 int main(int /*argc*/, char* /*argv*/[])
1465 {
1466 char const* socket = nullptr;
1467@@ -246,4 +244,3 @@
1468
1469 return 0;
1470 }
1471-#pragma GCC diagnostic pop
1472
1473=== modified file 'examples/tooltip.c'
1474--- examples/tooltip.c 2017-05-08 03:04:26 +0000
1475+++ examples/tooltip.c 2017-05-22 16:48:39 +0000
1476@@ -28,7 +28,14 @@
1477 /// A simple orange client surface with a simple grey tooltip
1478
1479 static MirPixelFormat select_pixel_format(MirConnection* connection);
1480-static MirWindow* create_tooltip(MirConnection* const connection, MirWindow* const parent, const MirPixelFormat format);
1481+
1482+typedef struct MyWindow
1483+{
1484+ MirRenderSurface *surface;
1485+ MirWindow *window;
1486+} MyWindow;
1487+
1488+static MyWindow create_tooltip(MirConnection* const connection, MirWindow* const parent, const MirPixelFormat format);
1489
1490 typedef struct Color
1491 {
1492@@ -61,12 +68,13 @@
1493 mir_window_apply_spec(parent, spec);
1494 mir_window_spec_release(spec);
1495
1496- MirWindow* tooltip = create_tooltip(connection, parent, select_pixel_format(connection));
1497+ MyWindow tooltip = create_tooltip(connection, parent, select_pixel_format(connection));
1498 while (mir_eglapp_running())
1499 {
1500 }
1501
1502- mir_window_release_sync(tooltip);
1503+ mir_window_release_sync(tooltip.window);
1504+ mir_render_surface_release(tooltip.surface);
1505 mir_eglapp_cleanup();
1506
1507 return 0;
1508@@ -97,28 +105,29 @@
1509 return pixel_format;
1510 }
1511
1512-#pragma GCC diagnostic push
1513-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1514-static MirWindow* create_tooltip(MirConnection* const connection, MirWindow* const parent, const MirPixelFormat format)
1515+
1516+
1517+static MyWindow create_tooltip(MirConnection* const connection, MirWindow* const parent, const MirPixelFormat format)
1518 {
1519 MirRectangle zone = { 0, 0, 10, 10 };
1520 int const width = 50;
1521 int const height = 20;
1522+
1523+ MirRenderSurface *const surface = mir_connection_create_render_surface_sync(connection, width, height);
1524+
1525 MirWindowSpec* const spec = mir_create_tip_window_spec(
1526 connection, width, height, parent, &zone, mir_edge_attachment_vertical);
1527- mir_window_spec_set_pixel_format(spec, format);
1528-
1529- mir_window_spec_set_buffer_usage(spec, mir_buffer_usage_software);
1530 mir_window_spec_set_name(spec, "tooltip");
1531 mir_window_spec_set_min_width(spec, width);
1532 mir_window_spec_set_max_width(spec, width);
1533 mir_window_spec_set_min_height(spec, height);
1534 mir_window_spec_set_max_height(spec, height);
1535+ mir_window_spec_add_render_surface(spec, surface, width, height, 0, 0);
1536
1537 MirWindow* tooltip = mir_create_window_sync(spec);
1538 mir_window_spec_release(spec);
1539
1540- MirBufferStream* const bs = mir_window_get_buffer_stream(tooltip);
1541+ MirBufferStream* bs = mir_render_surface_get_buffer_stream(surface, width, height, format);
1542 MirGraphicsRegion buffer;
1543 mir_buffer_stream_get_graphics_region(bs, &buffer);
1544
1545@@ -156,6 +165,6 @@
1546
1547 mir_buffer_stream_swap_buffers_sync(bs);
1548
1549- return tooltip;
1550+ MyWindow result = {surface, tooltip};
1551+ return result;
1552 }
1553-#pragma GCC diagnostic pop
1554
1555=== modified file 'src/server/compositor/stream.cpp'
1556--- src/server/compositor/stream.cpp 2017-05-08 03:04:26 +0000
1557+++ src/server/compositor/stream.cpp 2017-05-22 16:48:39 +0000
1558@@ -75,6 +75,7 @@
1559 first_frame_posted = true;
1560 buffers->receive_buffer(buffer->id());
1561 deferred_io = schedule->schedule_nonblocking(buffers->get(buffer->id()));
1562+ pf = buffer->pixel_format();
1563 }
1564 observers.frame_posted(1, buffer->size());
1565
1566@@ -96,6 +97,7 @@
1567
1568 MirPixelFormat mc::Stream::pixel_format() const
1569 {
1570+ std::lock_guard<decltype(mutex)> lk(mutex);
1571 return pf;
1572 }
1573
1574
1575=== modified file 'src/server/compositor/stream.h'
1576--- src/server/compositor/stream.h 2017-05-08 03:04:26 +0000
1577+++ src/server/compositor/stream.h 2017-05-22 16:48:39 +0000
1578@@ -71,7 +71,7 @@
1579 std::shared_ptr<frontend::ClientBuffers> const buffers;
1580 std::shared_ptr<MultiMonitorArbiter> const arbiter;
1581 geometry::Size size;
1582- MirPixelFormat const pf;
1583+ MirPixelFormat pf;
1584 bool first_frame_posted;
1585
1586 scene::SurfaceObservers observers;
1587
1588=== modified file 'tests/include/mir/test/doubles/stub_buffer.h'
1589--- tests/include/mir/test/doubles/stub_buffer.h 2017-05-08 03:04:26 +0000
1590+++ tests/include/mir/test/doubles/stub_buffer.h 2017-05-22 16:48:39 +0000
1591@@ -67,12 +67,12 @@
1592 {
1593 }
1594
1595- StubBuffer(std::shared_ptr<graphics::NativeBuffer> const& native_buffer, geometry::Size const& size)
1596+ StubBuffer(std::shared_ptr<graphics::NativeBuffer> const& native_buffer, geometry::Size const& size, MirPixelFormat const pixel_format)
1597 : StubBuffer{
1598 native_buffer,
1599 graphics::BufferProperties{
1600 size,
1601- mir_pixel_format_argb_8888,
1602+ pixel_format,
1603 graphics::BufferUsage::hardware},
1604 geometry::Stride{}}
1605
1606@@ -80,7 +80,7 @@
1607 }
1608
1609 StubBuffer(std::shared_ptr<graphics::NativeBuffer> const& native_buffer)
1610- : StubBuffer{native_buffer, {}}
1611+ : StubBuffer{native_buffer, {}, mir_pixel_format_abgr_8888}
1612 {
1613 }
1614
1615
1616=== modified file 'tests/include/mir/test/doubles/stub_buffer_allocator.h'
1617--- tests/include/mir/test/doubles/stub_buffer_allocator.h 2017-05-08 03:04:26 +0000
1618+++ tests/include/mir/test/doubles/stub_buffer_allocator.h 2017-05-22 16:48:39 +0000
1619@@ -39,24 +39,24 @@
1620 std::shared_ptr<graphics::Buffer> alloc_buffer(
1621 graphics::BufferProperties const& properties)
1622 {
1623- return std::make_shared<StubBuffer>(std::make_shared<mir_test_framework::NativeBuffer>(properties), properties.size);
1624+ return std::make_shared<StubBuffer>(std::make_shared<mir_test_framework::NativeBuffer>(properties), properties.size, properties.format);
1625 }
1626
1627 std::shared_ptr<graphics::Buffer> alloc_software_buffer(geometry::Size sz, MirPixelFormat pf)
1628 {
1629 graphics::BufferProperties properties{sz, pf, graphics::BufferUsage::software};
1630- return std::make_shared<StubBuffer>(std::make_shared<mir_test_framework::NativeBuffer>(properties), sz);
1631+ return std::make_shared<StubBuffer>(std::make_shared<mir_test_framework::NativeBuffer>(properties), sz, pf);
1632 }
1633
1634 std::shared_ptr<graphics::Buffer> alloc_buffer(geometry::Size sz, uint32_t, uint32_t flags)
1635 {
1636- graphics::BufferProperties properties{sz, mir_pixel_format_abgr_8888, graphics::BufferUsage::hardware};
1637+ graphics::BufferProperties properties{sz, mir_pixel_format_xbgr_8888, graphics::BufferUsage::hardware};
1638 #pragma GCC diagnostic push
1639 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1640 if (mir_buffer_usage_software == static_cast<MirBufferUsage>(flags))
1641 properties.usage = graphics::BufferUsage::software;
1642 #pragma GCC diagnostic pop
1643- return std::make_shared<StubBuffer>(std::make_shared<mir_test_framework::NativeBuffer>(properties), sz);
1644+ return std::make_shared<StubBuffer>(std::make_shared<mir_test_framework::NativeBuffer>(properties), sz, properties.format);
1645 }
1646
1647 std::vector<MirPixelFormat> supported_pixel_formats()
1648
1649=== modified file 'tests/mir_test_framework/stub_client_platform_factory.cpp'
1650--- tests/mir_test_framework/stub_client_platform_factory.cpp 2017-05-17 04:48:46 +0000
1651+++ tests/mir_test_framework/stub_client_platform_factory.cpp 2017-05-22 16:48:39 +0000
1652@@ -140,11 +140,11 @@
1653 }
1654
1655 std::shared_ptr<mcl::ClientBuffer> create_buffer(
1656- std::shared_ptr<MirBufferPackage> const& package, uint32_t, uint32_t) override
1657+ std::shared_ptr<MirBufferPackage> const& package, uint32_t native_pf, uint32_t) override
1658 {
1659 mir::graphics::BufferUsage usage = mir::graphics::BufferUsage::hardware;
1660 geom::Size size {package->width, package->height};
1661- auto pf = mir_pixel_format_abgr_8888;
1662+ auto const pf = static_cast<MirPixelFormat>(native_pf);
1663 mir::graphics::BufferProperties properties { size, pf, usage };
1664 return std::make_shared<mtd::StubClientBuffer>(package, size, pf,
1665 std::make_shared<mtf::NativeBuffer>(properties));

Subscribers

People subscribed via source and target branches