diff options
author | Michel Dänzer <mdaenzer@redhat.com> | 2021-05-05 15:02:25 +0200 |
---|---|---|
committer | Michel Dänzer <michel@daenzer.net> | 2021-07-09 16:15:39 +0200 |
commit | 61cc5d96ed281a082d8dd414506dea0084e446fd (patch) | |
tree | f9e5ce4a786c2e3db5451e477681671d93cc06dd | |
parent | 35f173ddb606f9fbac7957e427fe28a377204cfe (diff) |
present: Refactor present_vblank_init helper ouf of _vblank_create
Allows embedding into another struct.
Acked-by: Olivier Fourdan <ofourdan@redhat.com>
-rw-r--r-- | present/present_priv.h | 19 | ||||
-rw-r--r-- | present/present_vblank.c | 79 |
2 files changed, 75 insertions, 23 deletions
diff --git a/present/present_priv.h b/present/present_priv.h index 99fe37f0f..e75ef6f9d 100644 --- a/present/present_priv.h +++ b/present/present_priv.h @@ -448,6 +448,25 @@ present_screen_priv_init(ScreenPtr screen); void present_vblank_notify(present_vblank_ptr vblank, CARD8 kind, CARD8 mode, uint64_t ust, uint64_t crtc_msc); +Bool +present_vblank_init(present_vblank_ptr vblank, + WindowPtr window, + PixmapPtr pixmap, + CARD32 serial, + RegionPtr valid, + RegionPtr update, + int16_t x_off, + int16_t y_off, + RRCrtcPtr target_crtc, + SyncFence *wait_fence, + SyncFence *idle_fence, + uint32_t options, + const uint32_t capabilities, + present_notify_ptr notifies, + int num_notifies, + uint64_t target_msc, + uint64_t crtc_msc); + present_vblank_ptr present_vblank_create(WindowPtr window, PixmapPtr pixmap, diff --git a/present/present_vblank.c b/present/present_vblank.c index 4401395d7..beca01982 100644 --- a/present/present_vblank.c +++ b/present/present_vblank.c @@ -38,38 +38,39 @@ present_vblank_notify(present_vblank_ptr vblank, CARD8 kind, CARD8 mode, uint64_ } } -present_vblank_ptr -present_vblank_create(WindowPtr window, - PixmapPtr pixmap, - CARD32 serial, - RegionPtr valid, - RegionPtr update, - int16_t x_off, - int16_t y_off, - RRCrtcPtr target_crtc, - SyncFence *wait_fence, - SyncFence *idle_fence, - uint32_t options, - const uint32_t capabilities, - present_notify_ptr notifies, - int num_notifies, - uint64_t target_msc, - uint64_t crtc_msc) +/* The memory vblank points to must be 0-initialized before calling this function. + * + * If this function returns FALSE, present_vblank_destroy must be called to clean + * up. + */ +Bool +present_vblank_init(present_vblank_ptr vblank, + WindowPtr window, + PixmapPtr pixmap, + CARD32 serial, + RegionPtr valid, + RegionPtr update, + int16_t x_off, + int16_t y_off, + RRCrtcPtr target_crtc, + SyncFence *wait_fence, + SyncFence *idle_fence, + uint32_t options, + const uint32_t capabilities, + present_notify_ptr notifies, + int num_notifies, + uint64_t target_msc, + uint64_t crtc_msc) { ScreenPtr screen = window->drawable.pScreen; present_window_priv_ptr window_priv = present_get_window_priv(window, TRUE); present_screen_priv_ptr screen_priv = present_screen_priv(screen); - present_vblank_ptr vblank; PresentFlipReason reason = PRESENT_FLIP_REASON_UNKNOWN; if (target_crtc) { screen_priv = present_screen_priv(target_crtc->pScreen); } - vblank = calloc (1, sizeof (present_vblank_rec)); - if (!vblank) - return NULL; - xorg_list_append(&vblank->window_list, &window_priv->vblank); xorg_list_init(&vblank->event_queue); @@ -140,10 +141,42 @@ present_vblank_create(WindowPtr window, vblank->event_id, vblank, target_msc, vblank->pixmap->drawable.id, vblank->window->drawable.id, target_crtc, vblank->flip, vblank->sync_flip, vblank->serial)); - return vblank; + return TRUE; no_mem: vblank->notifies = NULL; + return FALSE; +} + +present_vblank_ptr +present_vblank_create(WindowPtr window, + PixmapPtr pixmap, + CARD32 serial, + RegionPtr valid, + RegionPtr update, + int16_t x_off, + int16_t y_off, + RRCrtcPtr target_crtc, + SyncFence *wait_fence, + SyncFence *idle_fence, + uint32_t options, + const uint32_t capabilities, + present_notify_ptr notifies, + int num_notifies, + uint64_t target_msc, + uint64_t crtc_msc) +{ + present_vblank_ptr vblank = calloc(1, sizeof(present_vblank_rec)); + + if (!vblank) + return NULL; + + if (present_vblank_init(vblank, window, pixmap, serial, valid, update, + x_off, y_off, target_crtc, wait_fence, idle_fence, + options, capabilities, notifies, num_notifies, + target_msc, crtc_msc)) + return vblank; + present_vblank_destroy(vblank); return NULL; } |