~ubuntu-branches/ubuntu/wily/mir/wily-proposed

« back to all changes in this revision

Viewing changes to examples/eglapp.c

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2014-01-08 02:04:38 UTC
  • mto: This revision was merged to the branch mainline in revision 58.
  • Revision ID: package-import@ubuntu.com-20140108020438-e1npu0pm7qdv5wc4
Tags: upstream-0.1.3+14.04.20140108
ImportĀ upstreamĀ versionĀ 0.1.3+14.04.20140108

Show diffs side-by-side

added added

removed removed

Lines of Context:
93
93
        lastcount = count;
94
94
    }
95
95
 
96
 
    /* This is one way to handle window resizing. But in future it would be
97
 
       better to have resize events coming from the server */
 
96
    /*
 
97
     * Querying the surface (actually the current buffer) dimensions here is
 
98
     * the only truly safe way to be sure that the dimensions we think we
 
99
     * have are those of the buffer being rendered to. But this should be
 
100
     * improved in future; https://bugs.launchpad.net/mir/+bug/1194384
 
101
     */
98
102
    if (eglQuerySurface(egldisplay, eglsurface, EGL_WIDTH, &width) &&
99
103
        eglQuerySurface(egldisplay, eglsurface, EGL_HEIGHT, &height))
100
104
    {
102
106
    }
103
107
}
104
108
 
105
 
static void mir_eglapp_handle_input(MirSurface* surface, MirEvent const* ev, void* context)
 
109
static void mir_eglapp_handle_event(MirSurface* surface, MirEvent const* ev, void* context)
106
110
{
107
111
    (void) surface;
108
112
    (void) context;
112
116
    {
113
117
        running = 0;
114
118
    }
115
 
}
116
 
 
117
 
static unsigned int get_bpp(MirPixelFormat pf)
118
 
{
119
 
    switch (pf)
 
119
    else if (ev->type == mir_event_type_resize)
120
120
    {
121
 
        case mir_pixel_format_abgr_8888:
122
 
        case mir_pixel_format_xbgr_8888:
123
 
        case mir_pixel_format_argb_8888:
124
 
        case mir_pixel_format_xrgb_8888:
125
 
            return 32;
126
 
        case mir_pixel_format_bgr_888:
127
 
            return 24;
128
 
        case mir_pixel_format_invalid:
129
 
        default:
130
 
            return 0;
 
121
        /*
 
122
         * FIXME: https://bugs.launchpad.net/mir/+bug/1194384
 
123
         * It is unsafe to set the width and height here because we're in a
 
124
         * different thread to that doing the rendering. So we either need
 
125
         * support for event queuing (directing them to another thread) or
 
126
         * full single-threaded callbacks. (LP: #1194384).
 
127
         */
 
128
        printf("Resized to %dx%d\n", ev->resize.width, ev->resize.height);
131
129
    }
132
130
}
133
131
 
172
170
    };
173
171
    MirEventDelegate delegate = 
174
172
    {
175
 
        mir_eglapp_handle_input,
 
173
        mir_eglapp_handle_event,
176
174
        NULL
177
175
    };
178
176
    EGLConfig eglconfig;
342
340
 
343
341
    printf("Server supports %d of %d surface pixel formats. Using format: %d\n",
344
342
        nformats, mir_pixel_formats, surfaceparm.pixel_format);
345
 
    unsigned int bpp = get_bpp(surfaceparm.pixel_format);
 
343
    unsigned int bpp = 8 * MIR_BYTES_PER_PIXEL(surfaceparm.pixel_format);
346
344
    EGLint attribs[] =
347
345
    {
348
346
        EGL_SURFACE_TYPE, EGL_WINDOW_BIT,