root frame gap should be set to the gap of the first received frame

This commit is contained in:
Kovid Goyal
2021-01-29 14:26:32 +05:30
parent ad4665e638
commit 597267d1d0
2 changed files with 9 additions and 9 deletions

View File

@@ -908,7 +908,7 @@ handle_animation_frame_load_command(GraphicsManager *self, GraphicsCommand *g, I
ABRT("ENOSPC", "Failed to cache data for image frame"); ABRT("ENOSPC", "Failed to cache data for image frame");
} }
if (is_new_frame) { if (is_new_frame) {
if (!img->extra_framecnt) img->root_frame.gap = DEFAULT_GAP; if (!img->extra_framecnt) img->root_frame.gap = g->_gap > 0 ? g->_gap : DEFAULT_GAP;
Frame *frames = realloc(img->extra_frames, sizeof(img->extra_frames[0]) * img->extra_framecnt + 1); Frame *frames = realloc(img->extra_frames, sizeof(img->extra_frames[0]) * img->extra_framecnt + 1);
if (!frames) ABRT("ENOMEM", "Out of memory"); if (!frames) ABRT("ENOMEM", "Out of memory");
img->extra_frames = frames; img->extra_frames = frames;

View File

@@ -615,33 +615,33 @@ class TestGraphics(BaseTest):
self.assertIn('ransparen', res.msg) self.assertIn('ransparen', res.msg)
# simple new frame # simple new frame
t(payload='2' * 36) t(payload='2' * 36, z=77)
img = g.image_for_client_id(1) img = g.image_for_client_id(1)
self.assertEqual(img['extra_frames'], ({'gap': 40, 'id': 2, 'data': b'2' * 36},)) self.assertEqual(img['extra_frames'], ({'gap': 77, 'id': 2, 'data': b'2' * 36},))
# test editing a frame # test editing a frame
t(payload='3' * 36, r=2) t(payload='3' * 36, r=2)
img = g.image_for_client_id(1) img = g.image_for_client_id(1)
self.assertEqual(img['extra_frames'], ({'gap': 40, 'id': 2, 'data': b'3' * 36},)) self.assertEqual(img['extra_frames'], ({'gap': 77, 'id': 2, 'data': b'3' * 36},))
# test editing part of a frame # test editing part of a frame
t(payload='4' * 12, r=2, s=2, v=2) t(payload='4' * 12, r=2, s=2, v=2)
img = g.image_for_client_id(1) img = g.image_for_client_id(1)
self.assertEqual(img['extra_frames'], ({'gap': 40, 'id': 2, 'data': b'444444333333444444333333333333333333'},)) self.assertEqual(img['extra_frames'], ({'gap': 77, 'id': 2, 'data': b'444444333333444444333333333333333333'},))
t(payload='5' * 12, r=2, s=2, v=2, x=1, y=1) t(payload='5' * 12, r=2, s=2, v=2, x=1, y=1)
img = g.image_for_client_id(1) img = g.image_for_client_id(1)
self.assertEqual(img['extra_frames'], ({'gap': 40, 'id': 2, 'data': b'444444333555555444555555333333333333'},)) self.assertEqual(img['extra_frames'], ({'gap': 77, 'id': 2, 'data': b'444444333555555444555555333333333333'},))
t(payload='3' * 36, r=2) t(payload='3' * 36, r=2)
img = g.image_for_client_id(1) img = g.image_for_client_id(1)
self.assertEqual(img['extra_frames'], ({'gap': 40, 'id': 2, 'data': b'3' * 36},)) self.assertEqual(img['extra_frames'], ({'gap': 77, 'id': 2, 'data': b'3' * 36},))
# test loading from previous frame # test loading from previous frame
t(payload='4' * 12, c=2, s=2, v=2, z=101, frame_number=3) t(payload='4' * 12, c=2, s=2, v=2, z=101, frame_number=3)
img = g.image_for_client_id(1) img = g.image_for_client_id(1)
self.assertEqual(img['extra_frames'], ( self.assertEqual(img['extra_frames'], (
{'gap': 40, 'id': 2, 'data': b'3' * 36}, {'gap': 77, 'id': 2, 'data': b'3' * 36},
{'gap': 101, 'id': 3, 'data': b'444444333333444444333333333333333333'}, {'gap': 101, 'id': 3, 'data': b'444444333333444444333333333333333333'},
)) ))
# test changing gaps # test changing gaps
img = g.image_for_client_id(1) img = g.image_for_client_id(1)
self.assertEqual(img['root_frame_gap'], 40) self.assertEqual(img['root_frame_gap'], 77)
self.assertIsNone(li(a='a', i=1, r=1, z=13)) self.assertIsNone(li(a='a', i=1, r=1, z=13))
img = g.image_for_client_id(1) img = g.image_for_client_id(1)
self.assertEqual(img['root_frame_gap'], 13) self.assertEqual(img['root_frame_gap'], 13)