~ubuntu-branches/ubuntu/utopic/mir/utopic-proposed

« back to all changes in this revision

Viewing changes to src/platform/graphics/android/hwc_fb_device.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2014-03-10 19:28:46 UTC
  • mto: This revision was merged to the branch mainline in revision 63.
  • Revision ID: package-import@ubuntu.com-20140310192846-rq9qm3ec26yrelo2
Tags: upstream-0.1.6+14.04.20140310
ImportĀ upstreamĀ versionĀ 0.1.6+14.04.20140310

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 */
19
19
 
20
20
#include "hwc_fb_device.h"
21
 
#include "hwc_layers.h"
22
21
#include "hwc_vsync_coordinator.h"
23
22
#include "framebuffer_bundle.h"
24
23
#include "android_format_conversion-inl.h"
36
35
                              std::shared_ptr<framebuffer_device_t> const& fb_device,
37
36
                              std::shared_ptr<HWCVsyncCoordinator> const& coordinator)
38
37
    : HWCCommonDevice(hwc_device, coordinator),
39
 
      fb_device(fb_device),
40
 
      layer_list({mga::ForceGLLayer{}})
 
38
      fb_device(fb_device)
41
39
{
42
40
}
43
41
 
44
42
void mga::HwcFbDevice::prepare_gl()
45
43
{
46
 
    auto display_list = layer_list.native_list();
47
 
    if (hwc_device->prepare(hwc_device.get(), 1, &display_list) != 0)
 
44
    auto rc = 0;
 
45
    auto display_list = layer_list.native_list().lock();
 
46
    if (display_list)
 
47
    {
 
48
        hwc_display_contents_1_t* displays[num_displays] {display_list.get()};
 
49
        rc = hwc_device->prepare(hwc_device.get(), num_displays, displays);
 
50
    }
 
51
 
 
52
    if ((rc != 0) || (!display_list))
48
53
    {
49
54
        BOOST_THROW_EXCEPTION(std::runtime_error("error during hwc prepare()"));
50
55
    }
57
62
 
58
63
void mga::HwcFbDevice::gpu_render(EGLDisplay dpy, EGLSurface sur)
59
64
{
60
 
    auto display_list = layer_list.native_list();
61
 
    display_list->dpy = dpy;
62
 
    display_list->sur = sur;
63
 
 
64
 
    //set() may affect EGL state by calling eglSwapBuffers.
65
 
    //HWC 1.0 is the only version of HWC that can do this.
66
 
    if (hwc_device->set(hwc_device.get(), 1, &display_list) != 0)
 
65
    auto rc = 0; 
 
66
    auto display_list = layer_list.native_list().lock();
 
67
    if (display_list)
 
68
    {
 
69
        display_list->dpy = dpy;
 
70
        display_list->sur = sur;
 
71
 
 
72
        //set() may affect EGL state by calling eglSwapBuffers.
 
73
        //HWC 1.0 is the only version of HWC that can do this.
 
74
        hwc_display_contents_1_t* displays[num_displays] {display_list.get()};
 
75
        rc = hwc_device->set(hwc_device.get(), num_displays, displays);
 
76
    }
 
77
 
 
78
    if ((rc != 0) || (!display_list))
67
79
    {
68
80
        BOOST_THROW_EXCEPTION(std::runtime_error("error during hwc set()"));
69
81
    }