fix: code cleanup
This commit is contained in:
@@ -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;
|
||||
};
|
||||
@@ -69,9 +66,7 @@ struct DrawImageCommand : public Command {
|
||||
};
|
||||
|
||||
|
||||
// --- Visitor Interface ---
|
||||
|
||||
// The visitor interface that the renderer (or replay engine) implements
|
||||
class CommandVisitor {
|
||||
public:
|
||||
virtual ~CommandVisitor() = default;
|
||||
@@ -85,20 +80,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);
|
||||
@@ -115,4 +105,4 @@ private:
|
||||
std::vector<std::unique_ptr<Command>> m_commands;
|
||||
};
|
||||
|
||||
} // namespace pdfengine
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user