From 5e6195c58afe8083c65fd7f58b6e94199c0f58dd Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Thu, 10 Jun 2021 15:50:56 +0900 Subject: [PATCH] common canvas: ++ case cover exception scenarios. Do not update the paint if it's not pushed in the canvas. Change-Id: I5cfd0e107389eac0e2b0947593bef1f6bc7215f5 --- src/lib/tvgCanvasImpl.h | 12 ++++++++++-- src/lib/tvgPaint.h | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/lib/tvgCanvasImpl.h b/src/lib/tvgCanvasImpl.h index 11fe8b9..e4f0376 100644 --- a/src/lib/tvgCanvasImpl.h +++ b/src/lib/tvgCanvasImpl.h @@ -62,7 +62,7 @@ struct Canvas::Impl //Clear render target before drawing if (!renderer || !renderer->clear()) return Result::InsufficientCondition; - //free paints + //Free paints for (auto paint = paints.data; paint < (paints.data + paints.count); ++paint) { (*paint)->pImpl->dispose(*renderer); if (free) delete(*paint); @@ -90,7 +90,14 @@ struct Canvas::Impl //Update single paint node if (paint) { - paint->pImpl->update(*renderer, nullptr, 255, clips, flag); + //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); + return Result::Success; + } + } + return Result::InsufficientCondition; //Update all retained paint nodes } else { for (auto paint = paints.data; paint < (paints.data + paints.count); ++paint) { @@ -121,6 +128,7 @@ struct Canvas::Impl Result sync() { if (!drawing) return Result::InsufficientCondition; + if (renderer->sync()) { drawing = false; return Result::Success; diff --git a/src/lib/tvgPaint.h b/src/lib/tvgPaint.h index f40345f..b0dadd2 100644 --- a/src/lib/tvgPaint.h +++ b/src/lib/tvgPaint.h @@ -48,8 +48,8 @@ namespace tvg uint32_t flag = RenderUpdateFlag::None; Paint* cmpTarget = nullptr; CompositeMethod cmpMethod = CompositeMethod::None; - uint8_t opacity = 255; PaintType type; + uint8_t opacity = 255; ~Impl() { if (cmpTarget) delete(cmpTarget); -- 2.7.4