This commit is contained in:
saqib mir
2026-06-22 15:24:05 +05:30
141 changed files with 554 additions and 1734 deletions
+1 -11
View File
@@ -10,13 +10,11 @@ namespace pdfengine {
class CommandVisitor;
// Base class for all drawing commands
struct Command {
virtual ~Command() = default;
virtual void accept(CommandVisitor& visitor) const = 0;
};
// --- Specific Command Types ---
struct SaveStateCommand : public Command {
void accept(CommandVisitor& visitor) const override;
@@ -41,7 +39,6 @@ struct FillRectCommand : public Command {
struct DrawTextCommand : public Command {
std::string text;
float x, y;
// We would eventually have a font reference here too
DrawTextCommand(std::string text, float x, float y) : text(std::move(text)), x(x), y(y) {}
void accept(CommandVisitor& visitor) const override;
};
@@ -77,9 +74,7 @@ struct DrawImageCommand : public Command {
};
// --- Visitor Interface ---
// The visitor interface that the renderer (or replay engine) implements
class CommandVisitor {
public:
virtual ~CommandVisitor() = default;
@@ -94,20 +89,15 @@ public:
virtual void visit(const DrawImageCommand& cmd) = 0;
};
// --- Display List Container ---
// A container that stores a sequence of drawing commands.
class DisplayList {
public:
DisplayList() = default;
// Add commands directly
void addCommand(std::unique_ptr<Command> cmd);
// Replay the commands to a visitor (renderer)
void replay(CommandVisitor& visitor) const;
// Helper methods to easily append common commands
void saveState();
void restoreState();
void setTransform(const Matrix& m);
@@ -125,4 +115,4 @@ private:
std::vector<std::unique_ptr<Command>> m_commands;
};
} // namespace pdfengine
}