mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-11 07:02:31 +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);
|
buffer.count += (TVG_HEADER_SIGNATURE_LENGTH + TVG_HEADER_VERSION_LENGTH);
|
||||||
|
|
||||||
//3. View Size
|
//3. View Size
|
||||||
float var[2];
|
writeData(vsize, SIZE(vsize));
|
||||||
paint->bounds(nullptr, nullptr, &var[0], &var[1]);
|
|
||||||
if (var[0] <= FLT_EPSILON || var[1] <= FLT_EPSILON) return false;
|
|
||||||
writeData(var, SIZE(var));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -449,6 +446,12 @@ bool TvgSaver::save(Paint* paint, const string& path)
|
||||||
this->path = strdup(path.c_str());
|
this->path = strdup(path.c_str());
|
||||||
if (!this->path) return false;
|
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;
|
this->paint = paint;
|
||||||
|
|
||||||
TaskScheduler::request(this);
|
TaskScheduler::request(this);
|
||||||
|
|
|
@ -35,6 +35,7 @@ private:
|
||||||
Array<TvgBinByte> buffer;
|
Array<TvgBinByte> buffer;
|
||||||
Paint* paint = nullptr;
|
Paint* paint = nullptr;
|
||||||
char *path = nullptr;
|
char *path = nullptr;
|
||||||
|
float vsize[2] = {0.0f, 0.0f};
|
||||||
|
|
||||||
bool flushTo(const std::string& path);
|
bool flushTo(const std::string& path);
|
||||||
void reserveCount();
|
void reserveCount();
|
||||||
|
|
Loading…
Add table
Reference in a new issue