Skip to content

feat: paint event move texture data to handle, add colorSpace - #47315

Merged
codebytere merged 4 commits into
electron:mainfrom
reitowo:main-paint-event
Aug 8, 2025
Merged

codebytere merged 4 commits into
electron:mainfrom
reitowo:main-paint-event

Conversation

@reitowo

@reitowo reitowo commented May 30, 2025 •

Copy link
Copy Markdown
Member

Description of Change

Breaking change for 'paint' event when shared texture offscreen is enabled, moved shared texture handle data to a unified handle property. Add colorSpace info. Split from #46811

Note that this API was marked experimental, so a breaking change should be expected by developers. Previous API put everything in root object which is not ideal.

Release Notes

Notes:

  • Added colorSpace to offscreen shared texture info of webContents.on('paint') event.
  • Breaking Changed the signature of OffscreenSharedTexture to provide a unified handle that holds the native handle.

@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label May 30, 2025
@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Jun 6, 2025
@reitowo
reitowo force-pushed the main-paint-event branch from 25343d8 to f79fc72 Compare July 6, 2025 14:56
@reitowo
reitowo marked this pull request as ready for review July 6, 2025 14:57
@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Jul 6, 2025
@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Jul 13, 2025
@reitowo
reitowo force-pushed the main-paint-event branch 2 times, most recently from dcfb030 to 67cf1f4 Compare July 14, 2025 14:29
@erickzhao erickzhao added the semver/major incompatible API changes label Jul 24, 2025

@erickzhao erickzhao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@reitowo

reitowo commented Jul 30, 2025

Copy link
Copy Markdown
Member Author

Sure! I added a note at breaking change. @erickzhao

@reitowo
reitowo force-pushed the main-paint-event branch from 67cf1f4 to edfb89d Compare July 30, 2025 15:50
@reitowo
reitowo requested a review from a team as a code owner July 30, 2025 15:50
Comment thread shell/browser/osr/osr_video_consumer.cc Outdated
texture.source_size = info->metadata.source_size;
texture.region_capture_rect = info->metadata.region_capture_rect;
texture.widget_type = view_->GetWidgetType();
texture.is_webgpu_compatible = info->metadata.is_webgpu_compatible;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are is_webgpu_compatible and supports_zero_copy_webgpu_import exposed/used anywhere? I see them being copied, but I don't see any other code that references them.

@samuelmaddock samuelmaddock left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

API LGTM

Breaking changes are fine given this API is already marked as experimental.

* `pixelFormat` string - The pixel format of the texture. Can be `rgba` or `bgra`.
* `codedSize` [Size](size.md) - The full dimensions of the video frame.
* `visibleRect` [Rectangle](rectangle.md) - A subsection of [0, 0, codedSize.width(), codedSize.height()]. In OSR case, it is expected to have the full section area.
* `colorSpace` [ColorSpace](color-space.md) - The color space of the video frame.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We expose colorSpace as a string in the Display object which is a bit unfortunate. I think it's fine to expose with this struct here though. 👍
https://www.electronjs.org/docs/latest/api/structures/display

Later we can figure out whether we want to expose the struct within Display under a potentially different property name.

@reitowo
reitowo force-pushed the main-paint-event branch from 23137e1 to 8ccc93d Compare July 31, 2025 19:29
@reitowo

reitowo commented Aug 2, 2025

Copy link
Copy Markdown
Member Author

Fixed a UTF8 BOM issue.

@reitowo

reitowo commented Aug 5, 2025

Copy link
Copy Markdown
Member Author

@samuelmaddock Hi Sam, could you rerun the flaky check or just merge this? Thanks.

@erickzhao erickzhao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

API LGTM

@codebytere
codebytere merged commit 9dcdec5 into electron:main Aug 8, 2025
@release-clerk

release-clerk Bot commented Aug 8, 2025

Copy link
Copy Markdown

Release Notes Persisted

  • Added colorSpace to offscreen shared texture info of webContents.on('paint') event.
  • Breaking Changed the signature of OffscreenSharedTexture to provide a unified handle that holds the native handle.

kigh-ota pushed a commit to kigh-ota/electron that referenced this pull request Sep 30, 2025
…lectron#47315)

* feat: paint event move shared texture to handle, add color space

* feat: add breaking change

* fix: properties.

* fix: remove utf8 bom
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants