MCPcopy Create free account
hub / github.com/OSSystems/EasySplash / animation

Method animation

src/animation.cpp:48–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46
47
48animation::animation(zip_archive &p_zip_archive, display &p_display)
49 : m_fps(0)
50 , m_total_num_frames(0)
51 , m_output_width(0)
52 , m_output_height(0)
53 , m_zip_archive(p_zip_archive)
54 , m_display(p_display)
55 , m_image_handle_cache(10, [&](animation_position const &p_key, display::image_handle & p_value) {
56 m_display.unload_image(p_value);
57 LOG_MSG(trace, "cache cleanup: unloading image at position " << p_key);
58 })
59{
60 zip_archive::entry const *desc_entry = find_entry_by_name(p_zip_archive, "desc.txt");
61 if (desc_entry == NULL)
62 {
63 LOG_MSG(error, "file desc.txt was not found in zip archive");
64 return;
65 }
66
67 datablock desc_data = p_zip_archive.uncompress_data(*desc_entry);
68 datablock_buf desc_readbuf(desc_data);
69 std::istream desc_input(&desc_readbuf);
70
71 std::string line;
72
73 {
74 std::getline(desc_input, line);
75 std::stringstream sstr(line);
76 sstr >> m_output_width >> m_output_height >> m_fps;
77 }
78
79 while (true)
80 {
81 std::getline(desc_input, line);
82 if (!desc_input)
83 break;
84
85 part new_part;
86
87 std::string type, path;
88 int pause; // dummy value, not currently used
89
90 std::stringstream sstr(line);
91 sstr >> type >> new_part.m_num_times_to_play >> pause >> path;
92 if (path.empty() || type.empty())
93 {
94 LOG_MSG(error, "line \"" << line << "\" in desc.txt file is invalid");
95 continue;
96 }
97
98 if (new_part.m_num_times_to_play == 0)
99 new_part.m_num_times_to_play = 1;
100
101 new_part.m_play_until_complete = (type == "p");
102
103 // Find all entries which start with the given path, and execute the specified
104 // function for eatch matching entry (the matching entries are passed to the function)
105 p_zip_archive.find_entries_with_path(path, [&](zip_archive::entry const &p_entry) {

Callers

nothing calls this directly

Calls 4

find_entry_by_nameFunction · 0.85
uncompress_dataMethod · 0.80
unload_imageMethod · 0.45

Tested by

no test coverage detected