61 lines
1.8 KiB
C++
61 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include <pdfengine/layout_types.hpp>
|
|
#include <pdfengine/layout_tree.hpp>
|
|
#include <pdfengine/layout_arena.hpp>
|
|
#include <pdfengine/multi_level_cache.hpp>
|
|
#include <pdfengine/spatial_index.hpp>
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <memory>
|
|
#include <atomic>
|
|
#include <chrono>
|
|
|
|
namespace pdfengine {
|
|
|
|
struct PipelineContext {
|
|
std::string documentId;
|
|
int pageIndex = 0;
|
|
float pageWidth = 0.0f;
|
|
float pageHeight = 0.0f;
|
|
|
|
std::shared_ptr<PhysicalLayoutTree> physicalTree;
|
|
std::shared_ptr<LogicalLayoutTree> logicalTree;
|
|
std::shared_ptr<MultiIndexSpatialIndex> spatialIndex;
|
|
|
|
std::vector<LayoutDiagnostic> diagnostics;
|
|
LayoutStatistics stats;
|
|
};
|
|
|
|
class LayoutSession {
|
|
public:
|
|
LayoutSession(std::string documentId, int pageIndex, float width, float height);
|
|
~LayoutSession() = default;
|
|
|
|
// Disable copy
|
|
LayoutSession(const LayoutSession&) = delete;
|
|
LayoutSession& operator=(const LayoutSession&) = delete;
|
|
|
|
[[nodiscard]] PipelineContext& context() noexcept { return m_context; }
|
|
[[nodiscard]] const PipelineContext& context() const noexcept { return m_context; }
|
|
|
|
[[nodiscard]] LayoutArena& arena() noexcept { return m_arena; }
|
|
[[nodiscard]] const LayoutArena& arena() const noexcept { return m_arena; }
|
|
|
|
void cancel() noexcept { m_cancelled.store(true); }
|
|
[[nodiscard]] bool isCancelled() const noexcept { return m_cancelled.load(); }
|
|
|
|
void logDiagnostic(LayoutDiagnostic::Severity severity, const std::string& passName, const std::string& message, const std::string& blockId = "");
|
|
|
|
void finish();
|
|
|
|
private:
|
|
PipelineContext m_context;
|
|
LayoutArena m_arena;
|
|
std::atomic<bool> m_cancelled{false};
|
|
std::chrono::high_resolution_clock::time_point m_startTime;
|
|
};
|
|
|
|
} // namespace pdfengine
|