21 lines
1.1 KiB
C++
21 lines
1.1 KiB
C++
#include "Plot_Render_Context.h"
|
|
#include "Timeline_Stream.h"
|
|
#include <algorithm>
|
|
namespace renderive {
|
|
std::shared_ptr<const Timeline_Stream_Snapshot> Plot_Render_Snapshot::timeline_snapshot(const std::shared_ptr<Timeline_Stream>& stream, int time_point_size, int label_tick_interval, bool start_coord_to_end_coord) const {
|
|
if (!stream)
|
|
return {};
|
|
time_point_size = std::max(1, time_point_size);
|
|
label_tick_interval = std::max(1, label_tick_interval);
|
|
if (!timeline_cache)
|
|
timeline_cache = std::make_shared<Timeline_Stream_Frame_Cache>();
|
|
for (auto& item : timeline_cache->items) {
|
|
if (item.stream.lock() == stream && item.time_point_size == time_point_size && item.tick_space == label_tick_interval && item.start_coord_to_end_coord == start_coord_to_end_coord)
|
|
return item.snapshot;
|
|
}
|
|
auto snapshot = std::make_shared<Timeline_Stream_Snapshot>(stream->capture(time_point_size, label_tick_interval, start_coord_to_end_coord));
|
|
timeline_cache->items.push_back({stream, time_point_size, label_tick_interval, start_coord_to_end_coord, snapshot});
|
|
return snapshot;
|
|
}
|
|
}
|