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 tick_space, bool start_coord_to_end_coord) const {
|
|
if (!stream)
|
|
return {};
|
|
time_point_size = std::max(1, time_point_size);
|
|
tick_space = std::max(1, tick_space);
|
|
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 == tick_space && 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, tick_space, start_coord_to_end_coord));
|
|
timeline_cache->items.push_back({stream, time_point_size, tick_space, start_coord_to_end_coord, snapshot});
|
|
return snapshot;
|
|
}
|
|
}
|