策略抽离
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
#include "Render_Frame_Snapshot.h"
|
||||
#include "../architecture/Timeline_Stream.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace renderive {
|
||||
|
||||
std::shared_ptr<const Timeline_Stream_Snapshot> Render_Frame_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;
|
||||
}
|
||||
|
||||
} // namespace renderive
|
||||
Reference in New Issue
Block a user