mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-20 15:03:25 +00:00
common canvas: ++ case cover exception scenarios.
Do not update the paint if it's not pushed in the canvas.
This commit is contained in:
parent
2401495c47
commit
6b75ce3476
2 changed files with 11 additions and 3 deletions
|
@ -62,7 +62,7 @@ struct Canvas::Impl
|
||||||
//Clear render target before drawing
|
//Clear render target before drawing
|
||||||
if (!renderer || !renderer->clear()) return Result::InsufficientCondition;
|
if (!renderer || !renderer->clear()) return Result::InsufficientCondition;
|
||||||
|
|
||||||
//free paints
|
//Free paints
|
||||||
for (auto paint = paints.data; paint < (paints.data + paints.count); ++paint) {
|
for (auto paint = paints.data; paint < (paints.data + paints.count); ++paint) {
|
||||||
(*paint)->pImpl->dispose(*renderer);
|
(*paint)->pImpl->dispose(*renderer);
|
||||||
if (free) delete(*paint);
|
if (free) delete(*paint);
|
||||||
|
@ -90,7 +90,14 @@ struct Canvas::Impl
|
||||||
|
|
||||||
//Update single paint node
|
//Update single paint node
|
||||||
if (paint) {
|
if (paint) {
|
||||||
|
//Optimize Me: Can we skip the searching?
|
||||||
|
for (auto paint2 = paints.data; paint2 < (paints.data + paints.count); ++paint2) {
|
||||||
|
if ((*paint2) == paint) {
|
||||||
paint->pImpl->update(*renderer, nullptr, 255, clips, flag);
|
paint->pImpl->update(*renderer, nullptr, 255, clips, flag);
|
||||||
|
return Result::Success;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Result::InsufficientCondition;
|
||||||
//Update all retained paint nodes
|
//Update all retained paint nodes
|
||||||
} else {
|
} else {
|
||||||
for (auto paint = paints.data; paint < (paints.data + paints.count); ++paint) {
|
for (auto paint = paints.data; paint < (paints.data + paints.count); ++paint) {
|
||||||
|
@ -121,6 +128,7 @@ struct Canvas::Impl
|
||||||
Result sync()
|
Result sync()
|
||||||
{
|
{
|
||||||
if (!drawing) return Result::InsufficientCondition;
|
if (!drawing) return Result::InsufficientCondition;
|
||||||
|
|
||||||
if (renderer->sync()) {
|
if (renderer->sync()) {
|
||||||
drawing = false;
|
drawing = false;
|
||||||
return Result::Success;
|
return Result::Success;
|
||||||
|
|
|
@ -48,8 +48,8 @@ namespace tvg
|
||||||
uint32_t flag = RenderUpdateFlag::None;
|
uint32_t flag = RenderUpdateFlag::None;
|
||||||
Paint* cmpTarget = nullptr;
|
Paint* cmpTarget = nullptr;
|
||||||
CompositeMethod cmpMethod = CompositeMethod::None;
|
CompositeMethod cmpMethod = CompositeMethod::None;
|
||||||
uint8_t opacity = 255;
|
|
||||||
PaintType type;
|
PaintType type;
|
||||||
|
uint8_t opacity = 255;
|
||||||
|
|
||||||
~Impl() {
|
~Impl() {
|
||||||
if (cmpTarget) delete(cmpTarget);
|
if (cmpTarget) delete(cmpTarget);
|
||||||
|
|
Loading…
Add table
Reference in a new issue