Fix premultiplied sRGB browser rendering #533

Open
SoprachevAK wants to merge 2 commits from SoprachevAK/fix/browser-premultiplied-srgb-blending into master
SoprachevAK commented 2026-08-16 23:15:55 -05:00 (Migrated from github.com)

Description

Uses the scene item's linear-sRGB state to select the correct rendering path for premultiplied browser textures:

  • Linear blending uses DrawSrgbDecompressPremultiplied.
  • Nonlinear blending draws the texture without conversion.

Also sets OBS_SOURCE_INITIAL_BLEND_METHOD_SRGB_OFF so new browser scene items initially use nonlinear blending.

Depends on obsproject/obs-studio#13797, this fixes #469.

Motivation and Context

This is the obs-browser companion to obs-studio#13797, which contains the core rendering changes, migration logic, and full motivation.

Chromium composites content in nonlinear sRGB, so browser sources should initially use nonlinear blending while still providing a correct linear rendering path when selected by the user.

How Has This Been Tested?

Manually tested on a MacBook Pro with an Apple M5 Pro running macOS 26.5.2, together with the changes from obs-studio#13797.

Verified both linear and nonlinear blending with opaque and semi-transparent content over transparent, black, and white backgrounds. The test page, comparison screenshots, and detailed results are included in the main PR.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have read the contributing document.
  • My code has been run through clang-format.
  • My code follows the project's style guidelines
  • My code is not on the master branch.
  • My code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.
  • I have used AI tooling in the creation of this PR.
    • AI tooling was used for research and autocomplete assistance. I deliberately reviewed, understood, and verified every submitted line of code, and personally evaluated all architectural decisions and trade-offs.
<!--- Please fill out the following template, which will help other contributors review your Pull Request. --> <!--- Make sure you’ve read the contribution guidelines here: https://github.com/obsproject/obs-studio/blob/master/CONTRIBUTING.md --> ### Description <!--- Describe your changes in detail. --> <!--- If this change includes UI elements, please include screenshots. --> Uses the scene item's linear-sRGB state to select the correct rendering path for premultiplied browser textures: - Linear blending uses `DrawSrgbDecompressPremultiplied`. - Nonlinear blending draws the texture without conversion. Also sets `OBS_SOURCE_INITIAL_BLEND_METHOD_SRGB_OFF` so new browser scene items initially use nonlinear blending. Depends on obsproject/obs-studio#13797, this fixes #469. ### Motivation and Context <!--- Why is this change required? What problem does it solve? --> <!--- If it fixes an open GitHub Issue, or implements feature request --> <!--- from the Ideas page, please link to the issue here. --> This is the obs-browser companion to [obs-studio#13797](https://github.com/obsproject/obs-studio/pull/13797), which contains the core rendering changes, migration logic, and full motivation. Chromium composites content in nonlinear sRGB, so browser sources should initially use nonlinear blending while still providing a correct linear rendering path when selected by the user. ### How Has This Been Tested? <!--- Please describe in detail how you tested your changes. --> <!--- Include details of your testing environment (hardware, OS version, etc.),--> <!--- and the tests you ran, including how it may affect other areas of code. --> Manually tested on a MacBook Pro with an Apple M5 Pro running macOS 26.5.2, together with the changes from obs-studio#13797. Verified both linear and nonlinear blending with opaque and semi-transparent content over transparent, black, and white backgrounds. The test page, comparison screenshots, and detailed results are included in the main PR. ### Types of changes <!--- What types of changes does your PR introduce? Uncomment all that apply --> - Bug fix (non-breaking change which fixes an issue) <!--- - New feature (non-breaking change which adds functionality) --> <!--- - Tweak (non-breaking change to improve existing functionality) --> <!--- - Performance enhancement (non-breaking change which improves efficiency) --> <!--- - Code cleanup (non-breaking change which makes code smaller or more readable) --> <!--- - Breaking change (fix or feature that would cause existing functionality to change) --> <!--- - Documentation (a change to documentation pages) --> ### Checklist: <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [x] I have read the [**contributing** document](https://github.com/obsproject/obs-studio/blob/master/CONTRIBUTING.md). - [x] My code has been run through [clang-format](https://github.com/obsproject/obs-studio/blob/master/.clang-format). - [x] My code follows the project's [**style guidelines**](https://github.com/obsproject/obs-studio/blob/master/CODESTYLE.md) - [x] My code is not on the master branch. - [x] My code has been tested. - [x] All commit messages are properly formatted and commits squashed where appropriate. - [x] I have included updates to all appropriate documentation. <!-- Complete the current GitHub AI-disclosure section truthfully. --> - [x] I have used AI tooling in the creation of this PR. - AI tooling was used for research and autocomplete assistance. I deliberately reviewed, understood, and verified every submitted line of code, and personally evaluated all architectural decisions and trade-offs.
This pull request is broken due to missing fork information.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'SoprachevAK/fix/browser-premultiplied-srgb-blending:SoprachevAK/fix/browser-premultiplied-srgb-blending'
git switch 'SoprachevAK/fix/browser-premultiplied-srgb-blending'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'master'
git merge --no-ff 'SoprachevAK/fix/browser-premultiplied-srgb-blending'
git switch 'SoprachevAK/fix/browser-premultiplied-srgb-blending'
git rebase 'master'
git switch 'master'
git merge --ff-only 'SoprachevAK/fix/browser-premultiplied-srgb-blending'
git switch 'SoprachevAK/fix/browser-premultiplied-srgb-blending'
git rebase 'master'
git switch 'master'
git merge --no-ff 'SoprachevAK/fix/browser-premultiplied-srgb-blending'
git switch 'master'
git merge --squash 'SoprachevAK/fix/browser-premultiplied-srgb-blending'
git switch 'master'
git merge --ff-only 'SoprachevAK/fix/browser-premultiplied-srgb-blending'
git switch 'master'
git merge 'SoprachevAK/fix/browser-premultiplied-srgb-blending'
git push origin 'master'
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-obsproject/obs-browser!533
No description provided.