~morphis/mir/fix-screencast-orientation

« back to all changes in this revision

Viewing changes to examples/animated_cursor_demo_client.c

  • Committer: Simon Fels
  • Date: 2016-04-20 06:56:22 UTC
  • mfrom: (1266.1.6 mir)
  • Revision ID: simon.fels@canonical.com-20160420065622-fa4i1zkav6tqhs54
Merge lp:mir/ubuntu

[ Alberto Aguirre ]
* New upstream release 0.21.0 (https://launchpad.net/mir/+milestone/0.21.0)
  - ABI summary:
    . mirclient ABI unchanged at 9
    . mirserver ABI unchanged at 38
    . mircommon ABI unchanged at 5
    . mirplatform ABI unchanged at 11
    . mirprotobuf ABI unchanged at 3
    . mirplatformgraphics ABI unchaged at 8
    . mirclientplatform ABI bumped to 5
    . mirinputplatform ABI unchanged at 5
  - Enhancements:
    . New display enumeration API
    . Added Android diagnostic tests to assist during porting to
      new devices
    . Added mir_demo_client_camera: a Video4Linux2 client
  - Bugs fixed:
    . Sometimes devices don't suspend - display turns back on
      immediately (LP: #1549701)
    . Mir crashed with exception 'failed to add sync point to command
      buffer' (LP: #1554635)
    . Mouse cursor is unusably slow in Unity 8 with a 1000Hz mouse
      (LP: #1539009)
    . Packaged mir_unit_tests binary is not suitable for general use
      (LP: #1547015)
    . [regression] Mir stops receiving input after a pause/resume
      cycle (LP: #1548989)
    . NBS (--nbuffers=0) causes software clients to crash with
      std::exception::what: Failed to mmap buffer 13, "Permission denied")
      (LP: #1550432)
    . Fullscreen clients freeze when using NBS with multiple monitors
      (LP: #1551536)
    . [ FAILED ] DisplayConfigurationTest.output_position_is_independent_of_
      orientation (LP: #1552065)
    . The server-side use of MIR_SOCKET is confusing (LP: #1290345)
    . [regression] FTBFS with -DMIR_LINK_TIME_OPTIMIZATION=on
      -Duse_debflags=on (LP: #1350343)
    . Mir On X (mesa-x11) keeps receiving mouse movement events even
      when not focused (LP: #1528110)
    . x11 platform: mouse cursor moves strange (LP: #1546324)
    . Cross compiling to wily/vivid doesn't work (LP: #1549152)
    . Rendering stutters when a new client establishes a connection
      (LP: #1549359)
    . 'mir_demo_server --test-client' crashes (SIGSEGV) when client
      dies (LP: #1555620)
    . [testfail] CI failure: TestClientInput.client_input_config_request_
      receives_all_attached_devices (LP: #1555708)
    . [regression] Mir FTBFS when MIR_ENABLE_TESTS=no (LP: #1556080)
    . Mir-on-X11 doesn't exit (until it gets an event) (LP: #1556210)
    . InputPlatformProbe.x11_platform_found_and_used_when_display_connection_
      works breaks with old input drivers present (LP: #1543049)
    . [regression] MIR_CLIENT_PERF_REPORT is missing window/surface
      names (LP: #1546933)
    . Installed binaries fail to run with mir_demo_server --test-client XXXX
      (LP: #1556160)
    . mir_demo_server --test-client [mir_demo_client_scroll|
      mir_demo_client_flicker] fails (LP: #1556205)
    . The contents of debian/mir-demos.examples are out of date and useless
      (LP: #1557446)
[ CI Train Bot ]
* No-change rebuild.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 * Author: Robert Carr <robert.carr@canonical.com>
17
17
 */
18
18
 
19
 
#define _GNU_SOURCE // for nanosleep
20
 
 
21
19
#include "eglapp.h"
22
20
 
23
21
#include "mir_toolkit/mir_client_library.h"
24
22
 
 
23
#include <math.h>
25
24
#include <stdio.h>
26
25
#include <stdlib.h>
27
26
#include <string.h>
33
32
 
34
33
void animate_cursor(MirBufferStream *stream)
35
34
{
36
 
    static double alpha = 0.0;
37
 
    char fill_color = 0xff * alpha;
38
 
    
 
35
    // mir_pixel_format_argb_8888 as set below
 
36
    int const bpp = 4;
 
37
    uint32_t const background = 0x00000000;
 
38
    uint32_t const foreground = 0xffffffff;
 
39
 
39
40
    MirGraphicsRegion region;
40
41
    mir_buffer_stream_get_graphics_region(stream, &region);
41
42
    
42
 
    memset(region.vaddr, fill_color, region.stride*region.height);
 
43
    for (int y = 0; y < region.height; ++y)
 
44
    {
 
45
        for (int x = 0; x < region.width; ++x)
 
46
        {
 
47
            uint32_t* pixel = (uint32_t*)
 
48
                              (region.vaddr + y * region.stride + x * bpp);
 
49
            *pixel = background;
 
50
        }
 
51
    }
 
52
 
 
53
    static float theta = 0.0f;
 
54
    theta += 0.000234567f;
 
55
 
 
56
    char* origin = region.vaddr + (region.height/2)*region.stride;
 
57
 
 
58
    for (int x = 0; x < region.width; ++x)
 
59
    {
 
60
        int const magnitude = region.height / 3;
 
61
        int y = magnitude * sinf(theta + x * 2 * M_PI / region.width);
 
62
        uint32_t* pixel = (uint32_t*)(origin + x*bpp + y*region.stride);
 
63
        *pixel = foreground;
 
64
    }
43
65
    
44
66
    mir_buffer_stream_swap_buffers_sync(stream);
45
 
    alpha += 0.01;
46
 
    if (alpha >= 1.0)
47
 
        alpha = 0.0;
48
 
    
49
67
}
50
68
 
51
69
MirBufferStream* make_cursor_stream(MirConnection *connection, MirSurface *surface)
76
94
    MirBufferStream* stream = make_cursor_stream(mir_eglapp_native_connection(),
77
95
        mir_eglapp_native_surface());
78
96
 
79
 
    struct timespec onehundred_millis = {
80
 
        0, 100*1000000
81
 
    };
82
 
 
83
97
    while (mir_eglapp_running())
84
98
    {
85
 
        nanosleep(&onehundred_millis, &onehundred_millis);
86
99
        animate_cursor(stream);
87
100
    }
88
101