MCPcopy Create free account
hub / github.com/Tom94/tev / bytes

Method bytes

include/tev/VectorGraphics.h:78–103  ·  view source on GitHub ↗

Returns the expected (not actual) size of `data` in number of bytes, depending on the type of the command.

Source from the content-addressed store, hash-verified

76
77 // Returns the expected (not actual) size of `data` in number of bytes, depending on the type of the command.
78 size_t bytes() const {
79 switch (type) {
80 case EType::Save: return 0;
81 case EType::Restore: return 0;
82 case EType::FillColor: return sizeof(Color);
83 case EType::Fill: return 0;
84 case EType::StrokeColor: return sizeof(Color);
85 case EType::Stroke: return 0;
86 case EType::BeginPath: return 0;
87 case EType::ClosePath: return 0;
88 case EType::PathWinding: return sizeof(float);
89 case EType::DebugDumpPathCache: return 0;
90 case EType::MoveTo: return sizeof(Pos);
91 case EType::LineTo: return sizeof(Pos);
92 case EType::ArcTo: return sizeof(Pos) * 2 + sizeof(float) /* radius */;
93 case EType::Arc: return sizeof(Pos) + sizeof(float) * 4 /* radius, 2 angles, winding */;
94 case EType::BezierTo: return sizeof(Pos) * 3 /* 2 control points, end point */;
95 case EType::Circle: return sizeof(Pos) + sizeof(float) /* radius */;
96 case EType::Ellipse: return sizeof(Pos) + sizeof(Size);
97 case EType::QuadTo: return sizeof(Pos) * 2 /* control point, end point */;
98 case EType::Rect: return sizeof(Pos) + sizeof(Size);
99 case EType::RoundedRect: return sizeof(Pos) + sizeof(Size) + sizeof(float) /* radius */;
100 case EType::RoundedRectVarying: return sizeof(Pos) + sizeof(Size) + sizeof(float) * 4 /* radius per corner */;
101 default: throw std::runtime_error{"Invalid VgCommand type."};
102 }
103 }
104
105 // Returns the expected size of `data` in number of floats, depending on the type of the command.
106 size_t size() const { return bytes() / sizeof(float); }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected