~albaguirre/mir/backport-fixes-to-0.11

« back to all changes in this revision

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

  • Committer: Tarmac
  • Author(s): Kevin DuBois
  • Date: 2015-01-29 16:35:31 UTC
  • mfrom: (2215.3.26 pull-list-from-device)
  • Revision ID: tarmac-20150129163531-oklyqevk921mxuq3
android: pull the mga::LayerList instance from the mga::HwcDevice to the mga::DisplayBuffer.

Approved by Alan Griffiths, Alexandros Frantzis, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
    };
42
42
    return (renderable.alpha() < 1.0f - tolerance);
43
43
}
 
44
}
44
45
 
45
 
bool renderable_list_is_hwc_incompatible(mg::RenderableList const& list)
 
46
bool mga::HwcDevice::compatible_renderlist(RenderableList const& list)
46
47
{
47
48
    if (list.empty())
48
 
        return true;
 
49
        return false;
49
50
 
50
51
    for (auto const& renderable : list)
51
52
    {
54
55
        if (plane_alpha_is_translucent(*renderable) ||
55
56
           (renderable->transformation() != identity))
56
57
        {
57
 
            return true;
 
58
            return false;
58
59
        }
59
60
    }
60
 
    return false;
61
 
}
 
61
    return true;
62
62
}
63
63
 
64
 
mga::HwcDevice::HwcDevice(
65
 
    std::shared_ptr<HwcWrapper> const& hwc_wrapper,
66
 
    std::shared_ptr<LayerAdapter> const& layer_adapter) :
67
 
    hwc_list{layer_adapter, {}},
 
64
mga::HwcDevice::HwcDevice(std::shared_ptr<HwcWrapper> const& hwc_wrapper) :
68
65
    hwc_wrapper(hwc_wrapper)
69
66
{
70
67
}
82
79
    return it != onscreen_overlay_buffers.end();
83
80
}
84
81
 
85
 
void mga::HwcDevice::post_gl(SwappingGLContext const& context)
86
 
{
87
 
    hwc_list.update_list({});
88
 
 
89
 
    //TODO: SwappingRenderer is temporary until we move the list up to DisplayBuffer
90
 
    struct SwappingRenderer : RenderableListCompositor
91
 
    {
92
 
        void render(RenderableList const&, SwappingGLContext const& context) const
93
 
        {
94
 
            context.swap_buffers();
95
 
        }
96
 
    } null_renderer;
97
 
 
98
 
    commit(context, null_renderer);
99
 
}
100
 
 
101
 
bool mga::HwcDevice::post_overlays(
102
 
    SwappingGLContext const& context,
103
 
    RenderableList const& renderables,
104
 
    RenderableListCompositor const& list_compositor)
105
 
{
106
 
    if (renderable_list_is_hwc_incompatible(renderables))
107
 
        return false;
108
 
 
109
 
    hwc_list.update_list(renderables);
110
 
 
111
 
    bool needs_commit{false};
112
 
    for (auto& layer : hwc_list)
113
 
        needs_commit |= layer.needs_commit;
114
 
    if (!needs_commit)
115
 
        return false;
116
 
 
117
 
    commit(context, list_compositor);
118
 
    return true;
119
 
}
120
 
 
121
82
void mga::HwcDevice::commit(
 
83
    mga::DisplayName,
 
84
    mga::LayerList& hwc_list,
122
85
    SwappingGLContext const& context,
123
86
    RenderableListCompositor const& list_compositor)
124
87
{
128
91
 
129
92
    if (hwc_list.needs_swapbuffers())
130
93
    {
131
 
        list_compositor.render(hwc_list.rejected_renderables(), context);
 
94
        auto rejected_renderables = hwc_list.rejected_renderables();
 
95
        if (rejected_renderables.empty())
 
96
            context.swap_buffers();
 
97
        else
 
98
            list_compositor.render(std::move(rejected_renderables), context);
132
99
        hwc_list.setup_fb(context.last_rendered_buffer());
133
100
        hwc_list.swap_occurred();
134
101
    }