+
Skip to content

capi: Redefine object interfaces to use opaque pointer types #3537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hermet
Copy link
Member

@hermet hermet commented Jun 16, 2025

Redefined Tvg_XXX and related types as pointers
e.g., typedef struct _Tvg_Canvas* Tvg_Canvas)
to improve encapsulation and clarity in API usage.

issue: #3116

@hermet hermet self-assigned this Jun 16, 2025
@hermet hermet added the APIs Update / Revise APIs label Jun 16, 2025
@hermet hermet requested a review from Copilot June 16, 2025 12:26
@github-actions github-actions bot added example Sample Code binding CAPI / Wasm and removed APIs Update / Revise APIs labels Jun 16, 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 PR updates the C API to use opaque pointer types for all Tvg_* objects, improving encapsulation and clarity.

  • Changed all typedef struct _Tvg_X declarations to pointer types (typedef struct _Tvg_X* Tvg_X)
  • Updated function signatures in headers and implementations to accept handles (Tvg_X) instead of pointers-to-pointers
  • Adjusted example code to declare handles directly and removed unnecessary indirection

Reviewed Changes

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

File Description
src/bindings/capi/tvgCapi.cpp Updated all C API functions to use opaque pointer types
src/bindings/capi/thorvg_capi.h Changed typedefs and function declarations for handles
examples/Capi.cpp Refactored example code to use new opaque handle usage
Comments suppressed due to low confidence (3)

examples/Capi.cpp:99

  • The variables color_stops2_get and cnt are not declared in this scope. You likely meant to pass color_stops2 and the count 3 (or a named count variable).
tvg_gradient_set_color_stops(grad_stroke, color_stops2_get, cnt);

examples/Capi.cpp:145

  • Typo in comment: "Prapare" should be "Prepare".
        //Prapare a dash for the stroke

src/bindings/capi/thorvg_capi.h:444

  • The doc comment above this signature still refers to canvas as a pointer. Update parameter descriptions (@param canvas) and return-value notes to reflect that canvas is now an opaque handle, not a pointer-to-pointer.
TVG_API Tvg_Result tvg_swcanvas_set_target(Tvg_Canvas canvas, uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h, Tvg_Colorspace cs);

@hermet
Copy link
Member Author

hermet commented Jun 16, 2025

API breaks, but abstracts & simplifies the interface. Let's carefully confirm.

@hermet hermet force-pushed the main branch 8 times, most recently from bed6696 to 5838334 Compare June 24, 2025 17:13
@hermet hermet force-pushed the hermet/capi branch 2 times, most recently from dc2d60a to 8220c78 Compare July 4, 2025 12:38
Redefined Tvg_XXX and related types as pointers
e.g., typedef struct _Tvg_Canvas* Tvg_Canvas)
to improve encapsulation and clarity in API usage.

issue: #3116
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
binding CAPI / Wasm example Sample Code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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