~mir-team/mir/in-process-egl+input-conglomeration

« back to all changes in this revision

Viewing changes to src/server/graphics/gbm/kms_output.cpp

Merged trunk and fixed issues

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include "page_flipper.h"
21
21
 
22
22
#include <boost/throw_exception.hpp>
 
23
#include <boost/exception/info.hpp>
23
24
 
24
25
#include <stdexcept>
25
26
#include <vector>
168
169
    page_flipper->wait_for_flip(current_crtc->crtc_id);
169
170
}
170
171
 
 
172
void mgg::KMSOutput::set_cursor(gbm_bo* buffer)
 
173
{
 
174
    if (current_crtc)
 
175
    {
 
176
        if (auto result = drmModeSetCursor(
 
177
                drm_fd,
 
178
                current_crtc->crtc_id,
 
179
                gbm_bo_get_handle(buffer).u32,
 
180
                gbm_bo_get_width(buffer),
 
181
                gbm_bo_get_height(buffer)))
 
182
        {
 
183
            BOOST_THROW_EXCEPTION(
 
184
                ::boost::enable_error_info(std::runtime_error("drmModeSetCursor() failed"))
 
185
                    << (boost::error_info<KMSOutput, decltype(result)>(result)));
 
186
        }
 
187
    }
 
188
}
 
189
 
 
190
void mgg::KMSOutput::move_cursor(geometry::Point destination)
 
191
{
 
192
    if (current_crtc)
 
193
    {
 
194
        if (auto result = drmModeMoveCursor(drm_fd, current_crtc->crtc_id,
 
195
                                            destination.x.as_uint32_t(),
 
196
                                            destination.y.as_uint32_t()))
 
197
        {
 
198
            BOOST_THROW_EXCEPTION(
 
199
                ::boost::enable_error_info(std::runtime_error("drmModeMoveCursor() failed"))
 
200
                    << (boost::error_info<KMSOutput, decltype(result)>(result)));
 
201
        }
 
202
    }
 
203
}
 
204
 
 
205
void mgg::KMSOutput::clear_cursor()
 
206
{
 
207
    if (current_crtc)
 
208
    {
 
209
        drmModeSetCursor(drm_fd, current_crtc->crtc_id, 0, 0, 0);
 
210
    }
 
211
}
 
212
 
171
213
bool mgg::KMSOutput::ensure_crtc()
172
214
{
173
215
    /* Nothing to do if we already have a crtc */