mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
tvg_saver: verify view size earlier before the job is started.
This commit is contained in:
parent
78f6f9d896
commit
41b5d8eb4e
2 changed files with 8 additions and 4 deletions
|
@ -69,10 +69,7 @@ bool TvgSaver::writeHeader()
|
|||
buffer.count += (TVG_HEADER_SIGNATURE_LENGTH + TVG_HEADER_VERSION_LENGTH);
|
||||
|
||||
//3. View Size
|
||||
float var[2];
|
||||
paint->bounds(nullptr, nullptr, &var[0], &var[1]);
|
||||
if (var[0] <= FLT_EPSILON || var[1] <= FLT_EPSILON) return false;
|
||||
writeData(var, SIZE(var));
|
||||
writeData(vsize, SIZE(vsize));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -449,6 +446,12 @@ bool TvgSaver::save(Paint* paint, const string& path)
|
|||
this->path = strdup(path.c_str());
|
||||
if (!this->path) return false;
|
||||
|
||||
paint->bounds(nullptr, nullptr, &vsize[0], &vsize[1]);
|
||||
if (vsize[0] <= FLT_EPSILON || vsize[1] <= FLT_EPSILON) {
|
||||
TVGLOG("TVG_SAVER", "Saving paint(%p) has zero view size.", paint);
|
||||
return false;
|
||||
}
|
||||
|
||||
this->paint = paint;
|
||||
|
||||
TaskScheduler::request(this);
|
||||
|
|
|
@ -35,6 +35,7 @@ private:
|
|||
Array<TvgBinByte> buffer;
|
||||
Paint* paint = nullptr;
|
||||
char *path = nullptr;
|
||||
float vsize[2] = {0.0f, 0.0f};
|
||||
|
||||
bool flushTo(const std::string& path);
|
||||
void reserveCount();
|
||||
|
|
Loading…
Add table
Reference in a new issue