+
Skip to content

Conversation

hermet
Copy link
Member

@hermet hermet commented Aug 6, 2025

This update adjusts the ThorVG canvas specification to
allow more flexible and efficient usage patterns.

Key changes include:

a. push behavior:
calling canvas push no longer triggers an automatic update
on the paint object. This avoids redundant updates in common
scenarios where the user explicitly calls canvas update afterwards.

b. implicit update on draw:
if canvas draw is called without a prior canvas update,
an implicit update will be performed. This ensures compatibility
with the updated push behavior and prevents missing updates.

c. relaxed success conditions
the functions canvas update, sync, draw are now more tolerant
of empty or idle canvas states. If no paint objects are present,
they will return success instead of failure.

Note: These changes may break backward compatibility in cases
where stricter failure checks were previously relied upon.

issue: #3116

@hermet hermet self-assigned this Aug 6, 2025
@Copilot Copilot AI review requested due to automatic review settings August 6, 2025 15:57
@hermet hermet added refactoring Code refactoring / Exceptional handles APIs Update / Revise APIs labels Aug 6, 2025
@hermet hermet changed the title Hermet/api canvas api revision Aug 6, 2025
@github-actions github-actions bot added example Sample Code test Unit tests renderer Core rendering binding CAPI / Wasm labels Aug 6, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request implements an improved canvas state management system to resolve rendering order and timing issues. The changes redesign how the canvas handles the sequence of push, update, draw, and sync operations by introducing a more robust state machine.

Key changes include:

  • Introduces a new "Painting" status to better track canvas state transitions
  • Removes strict empty scene validation and updates API behavior to be more permissive
  • Updates documentation to clarify proper API usage patterns and expected return values

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/testSwCanvas.cpp Updates test expectations to reflect new API behavior where operations succeed instead of returning InsufficientCondition
src/renderer/tvgCanvas.h Implements core canvas state machine with new Painting status and improved error handling
src/renderer/tvgCanvas.cpp Removes restrictive empty scene validation from public update() method
src/bindings/capi/thorvg_capi.h Updates C API documentation with clearer usage patterns and return value descriptions
inc/thorvg.h Updates C++ API documentation to match new behavior and clarify proper usage
examples/Retaining.cpp Adds explicit update() call to demonstrate proper API usage pattern

hermet added 2 commits August 7, 2025 13:06
This update adjusts the ThorVG canvas specification to
allow more flexible and efficient usage patterns.

Key changes include:

a. push behavior:
 calling canvas push no longer triggers an automatic update
 on the paint object.  This avoids redundant updates in common
 scenarios where the user explicitly calls canvas update afterwards.

b. implicit update on draw:
 if canvas draw is called without a prior canvas update,
 an implicit update will be performed. This ensures compatibility
 with the updated push behavior and prevents missing updates.

c. relaxed success conditions
 the functions canvas update, sync, draw are now more tolerant
 of empty or idle canvas states. If no paint objects are present,
 they will return success instead of failure.

Note: These changes may break backward compatibility in cases
where stricter failure checks were previously relied upon.

issue: #3116
formating++ & removed useless information
@hermet hermet merged commit 3d40227 into main Aug 7, 2025
15 checks passed
@hermet hermet deleted the hermet/api branch August 7, 2025 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

APIs Update / Revise APIs binding CAPI / Wasm example Sample Code refactoring Code refactoring / Exceptional handles renderer Core rendering test Unit tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载