mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-19 22:41:52 +00:00
renderer: ensure canvas rendering continues despite invalid scene parts
Previously, the logic was set to halt rendering when any part of the paints, particularly bitmap-based images, failed to render. This update modifies the behavior to continue drawing the scene, allowing for the successful rendering of other elements. issue: https://github.com/thorvg/thorvg/issues/1951
This commit is contained in:
parent
331839d493
commit
bf4654a991
2 changed files with 5 additions and 4 deletions
|
@ -1928,8 +1928,8 @@ bool rasterStroke(SwSurface* surface, SwShape* shape, uint8_t r, uint8_t g, uint
|
||||||
|
|
||||||
bool rasterImage(SwSurface* surface, SwImage* image, const RenderMesh* mesh, const Matrix* transform, const SwBBox& bbox, uint8_t opacity)
|
bool rasterImage(SwSurface* surface, SwImage* image, const RenderMesh* mesh, const Matrix* transform, const SwBBox& bbox, uint8_t opacity)
|
||||||
{
|
{
|
||||||
//Verify Boundary
|
//Outside of the viewport, skip the rendering
|
||||||
if (bbox.max.x < 0 || bbox.max.y < 0 || bbox.min.x >= static_cast<SwCoord>(surface->w) || bbox.min.y >= static_cast<SwCoord>(surface->h)) return false;
|
if (bbox.max.x < 0 || bbox.max.y < 0 || bbox.min.x >= static_cast<SwCoord>(surface->w) || bbox.min.y >= static_cast<SwCoord>(surface->h)) return true;
|
||||||
|
|
||||||
if (mesh && mesh->triangleCnt > 0) return _rasterTexmapPolygonMesh(surface, image, mesh, transform, &bbox, opacity);
|
if (mesh && mesh->triangleCnt > 0) return _rasterTexmapPolygonMesh(surface, image, mesh, transform, &bbox, opacity);
|
||||||
else return _rasterImage(surface, image, transform, bbox, opacity);
|
else return _rasterImage(surface, image, transform, bbox, opacity);
|
||||||
|
|
|
@ -128,6 +128,7 @@ struct Scene::Impl
|
||||||
bool render(RenderMethod* renderer)
|
bool render(RenderMethod* renderer)
|
||||||
{
|
{
|
||||||
Compositor* cmp = nullptr;
|
Compositor* cmp = nullptr;
|
||||||
|
auto ret = true;
|
||||||
|
|
||||||
if (needComp) {
|
if (needComp) {
|
||||||
cmp = renderer->target(bounds(renderer), renderer->colorSpace());
|
cmp = renderer->target(bounds(renderer), renderer->colorSpace());
|
||||||
|
@ -136,12 +137,12 @@ struct Scene::Impl
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto paint : paints) {
|
for (auto paint : paints) {
|
||||||
if (!paint->pImpl->render(renderer)) return false;
|
ret &= paint->pImpl->render(renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmp) renderer->endComposite(cmp);
|
if (cmp) renderer->endComposite(cmp);
|
||||||
|
|
||||||
return true;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderRegion bounds(RenderMethod* renderer) const
|
RenderRegion bounds(RenderMethod* renderer) const
|
||||||
|
|
Loading…
Add table
Reference in a new issue