~alan-griffiths/mir/fix-1654023

« back to all changes in this revision

Viewing changes to src/platforms/android/server/gl_context.cpp

  • Committer: Daniel van Vugt
  • Date: 2015-04-28 07:54:10 UTC
  • mfrom: (2517 development-branch)
  • mto: This revision was merged to the branch mainline in revision 2673.
  • Revision ID: daniel.van.vugt@canonical.com-20150428075410-rwskshfuar7voesp
Merge latest trunk and fix conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include "android_format_conversion-inl.h"
22
22
#include "mir/graphics/display_report.h"
23
23
#include "mir/graphics/gl_config.h"
 
24
#include "mir/graphics/egl_error.h"
24
25
 
25
26
#include <algorithm>
26
27
#include <boost/throw_exception.hpp>
52
53
 
53
54
    auto egl_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
54
55
    if (egl_display == EGL_NO_DISPLAY)
55
 
        BOOST_THROW_EXCEPTION(std::runtime_error("eglGetDisplay failed\n"));
 
56
        BOOST_THROW_EXCEPTION(mg::egl_error("eglGetDisplay failed"));
56
57
 
57
58
    if (eglInitialize(egl_display, &major, &minor) == EGL_FALSE)
58
 
        BOOST_THROW_EXCEPTION(std::runtime_error("eglInitialize failure\n"));
 
59
        BOOST_THROW_EXCEPTION(mg::egl_error("eglInitialize failure"));
59
60
 
60
61
    if ((major != 1) || (minor != 4))
61
 
        BOOST_THROW_EXCEPTION(std::runtime_error("must have EGL 1.4\n"));
 
62
        BOOST_THROW_EXCEPTION(std::runtime_error("must have EGL 1.4"));
62
63
    return egl_display;
63
64
}
64
65
 
108
109
    if (eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context) == EGL_FALSE)
109
110
    {
110
111
        BOOST_THROW_EXCEPTION(
111
 
            std::runtime_error("could not activate surface with eglMakeCurrent\n"));
 
112
            mg::egl_error("could not activate surface with eglMakeCurrent"));
112
113
    }
113
114
}
114
115
 
186
187
 
187
188
void mga::FramebufferGLContext::swap_buffers() const
188
189
{
189
 
    eglGetError();
190
190
    if (eglSwapBuffers(egl_display, egl_surface) == EGL_FALSE)
191
 
    {
192
 
        std::stringstream sstream;
193
 
        sstream << "eglSwapBuffers failure: EGL error code " << std::hex << eglGetError();
194
 
        BOOST_THROW_EXCEPTION(std::runtime_error(sstream.str()));
195
 
    }
 
191
        BOOST_THROW_EXCEPTION(mg::egl_error("eglSwapBuffers failure"));
196
192
}
197
193
 
198
194
std::shared_ptr<mg::Buffer> mga::FramebufferGLContext::last_rendered_buffer() const