public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/firefox] f44: Backported HDR fix for GL framebuffer (D318191)
@ 2026-08-21  8:55 Martin Stransky
  0 siblings, 0 replies; only message in thread
From: Martin Stransky @ 2026-08-21  8:55 UTC (permalink / raw)
  To: git-commits

A new commit has been pushed.

Repo   : rpms/firefox
Branch : f44
Commit : daba34bfa2b4146e6b03bc4fdc51f7f87430a306
Author : Martin Stransky <stransky@redhat.com>
Date   : 2026-08-21T10:54:47+02:00
Stats  : +272/-0 in 2 file(s)
URL    : https://src.fedoraproject.org/rpms/firefox/c/daba34bfa2b4146e6b03bc4fdc51f7f87430a306?branch=f44

Log:
Backported HDR fix for GL framebuffer (D318191)

---
diff --git a/D318191.1787388141.diff b/D318191.1787388141.diff
new file mode 100644
index 0000000..465d936
--- /dev/null
+++ b/D318191.1787388141.diff
@@ -0,0 +1,269 @@
+diff -up firefox-154.0/gfx/gl/gtest/moz.build.D318191 firefox-154.0/gfx/gl/gtest/moz.build
+--- firefox-154.0/gfx/gl/gtest/moz.build.D318191	2026-08-12 23:13:26.000000000 +0200
++++ firefox-154.0/gfx/gl/gtest/moz.build	2026-08-21 10:46:40.907696298 +0200
+@@ -6,8 +6,15 @@ LOCAL_INCLUDES += [
+     "/gfx/gl",
+ ]
+ 
++include("/ipc/chromium/chromium-config.mozbuild")
++
+ UNIFIED_SOURCES += [
+     "TestColorspaces.cpp",
+ ]
+ 
++if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk":
++    UNIFIED_SOURCES += [
++        "TestMozFramebuffer.cpp",
++    ]
++
+ FINAL_LIBRARY = "xul-gtest"
+diff -up firefox-154.0/gfx/gl/gtest/TestMozFramebuffer.cpp.D318191 firefox-154.0/gfx/gl/gtest/TestMozFramebuffer.cpp
+--- firefox-154.0/gfx/gl/gtest/TestMozFramebuffer.cpp.D318191	2026-08-21 10:46:40.907621345 +0200
++++ firefox-154.0/gfx/gl/gtest/TestMozFramebuffer.cpp	2026-08-21 10:46:40.907612718 +0200
+@@ -0,0 +1,82 @@
++/* This Source Code Form is subject to the terms of the Mozilla Public
++ * License, v. 2.0. If a copy of the MPL was not distributed with this
++ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
++
++#include "GLContext.h"
++#include "GLContextProvider.h"
++#include "MozFramebuffer.h"
++#include "ScopedGLHelpers.h"
++#include "gfxPlatform.h"
++#include "gtest/gtest.h"
++
++namespace mozilla::gl {
++
++static already_AddRefed<GLContext> CreateTestContext(
++    nsACString* const aFailureId) {
++  return GLContextProvider::CreateHeadless({}, aFailureId);
++}
++
++TEST(MozFramebuffer, OwnedColorBackingIsDeletedWithFramebuffer)
++{
++  gfxPlatform::GetPlatform();
++
++  nsCString failureId;
++  RefPtr<GLContext> gl = CreateTestContext(&failureId);
++  ASSERT_TRUE(gl)
++  << failureId.get();
++  ASSERT_TRUE(gl->MakeCurrent());
++
++  const gfx::IntSize size(16, 16);
++  GLuint texture = gl->CreateTexture();
++  {
++    const ScopedBindTexture bindTexture(gl, texture);
++    gl->TexParams_SetClampNoMips(LOCAL_GL_TEXTURE_2D);
++    gl->fTexImage2D(LOCAL_GL_TEXTURE_2D, 0, LOCAL_GL_RGBA, size.width,
++                    size.height, 0, LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_BYTE,
++                    nullptr);
++  }
++  ASSERT_TRUE(gl->fIsTexture(texture));
++
++  {
++    auto framebuffer = MozFramebuffer::CreateForBacking(
++        gl, size, 0, false, false, LOCAL_GL_TEXTURE_2D, texture);
++    ASSERT_TRUE(framebuffer);
++  }
++
++  EXPECT_FALSE(gl->fIsTexture(texture));
++}
++
++TEST(MozFramebuffer, BorrowedColorBackingSurvivesFramebufferDestruction)
++{
++  gfxPlatform::GetPlatform();
++
++  nsCString failureId;
++  RefPtr<GLContext> gl = CreateTestContext(&failureId);
++  ASSERT_TRUE(gl)
++  << failureId.get();
++  ASSERT_TRUE(gl->MakeCurrent());
++
++  const gfx::IntSize size(16, 16);
++  GLuint texture = gl->CreateTexture();
++  {
++    const ScopedBindTexture bindTexture(gl, texture);
++    gl->TexParams_SetClampNoMips(LOCAL_GL_TEXTURE_2D);
++    gl->fTexImage2D(LOCAL_GL_TEXTURE_2D, 0, LOCAL_GL_RGBA, size.width,
++                    size.height, 0, LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_BYTE,
++                    nullptr);
++  }
++  ASSERT_TRUE(gl->fIsTexture(texture));
++
++  {
++    auto framebuffer = MozFramebuffer::CreateForBacking(
++        gl, size, 0, false, false, LOCAL_GL_TEXTURE_2D, texture,
++        MozFramebuffer::ColorBackingOwnership::Borrowed);
++    ASSERT_TRUE(framebuffer);
++    EXPECT_EQ(framebuffer->ColorTex(), texture);
++  }
++
++  EXPECT_TRUE(gl->fIsTexture(texture));
++  gl->DeleteTexture(texture);
++}
++
++}  // namespace mozilla::gl
+diff -up firefox-154.0/gfx/gl/MozFramebuffer.cpp.D318191 firefox-154.0/gfx/gl/MozFramebuffer.cpp
+--- firefox-154.0/gfx/gl/MozFramebuffer.cpp.D318191	2026-08-12 23:13:27.000000000 +0200
++++ firefox-154.0/gfx/gl/MozFramebuffer.cpp	2026-08-21 10:50:28.692698450 +0200
+@@ -67,35 +67,38 @@ UniquePtr<MozFramebuffer> MozFramebuffer
+   return CreateImpl(
+       gl, size, samples,
+       depthStencil ? DepthAndStencilBuffer::Create(gl, size, samples) : nullptr,
+-      colorTarget, colorName);
++      colorTarget, colorName, ColorBackingOwnership::Owned);
+ }
+ 
+ UniquePtr<MozFramebuffer> MozFramebuffer::CreateForBacking(
+     GLContext* const gl, const gfx::IntSize& size, const uint32_t samples,
+-    bool depthStencil, const GLenum colorTarget, const GLuint colorName) {
++    bool depthStencil, const GLenum colorTarget, const GLuint colorName,
++    ColorBackingOwnership colorBackingOwnership) {
+   return CreateImpl(
+       gl, size, samples,
+       depthStencil ? DepthAndStencilBuffer::Create(gl, size, samples) : nullptr,
+-      colorTarget, colorName);
++      colorTarget, colorName, colorBackingOwnership);
+ }
+ 
+ /* static */ UniquePtr<MozFramebuffer>
+ MozFramebuffer::CreateForBackingWithSharedDepthAndStencil(
+     const gfx::IntSize& size, const uint32_t samples, GLenum colorTarget,
+     GLuint colorName,
+-    const RefPtr<DepthAndStencilBuffer>& depthAndStencilBuffer) {
++    const RefPtr<DepthAndStencilBuffer>& depthAndStencilBuffer,
++    ColorBackingOwnership colorBackingOwnership) {
+   auto gl = depthAndStencilBuffer->gl();
+   if (!gl || !gl->MakeCurrent()) {
+     return nullptr;
+   }
+   return CreateImpl(gl, size, samples, depthAndStencilBuffer, colorTarget,
+-                    colorName);
++                    colorName, colorBackingOwnership);
+ }
+ 
+ /* static */ UniquePtr<MozFramebuffer> MozFramebuffer::CreateImpl(
+     GLContext* const gl, const gfx::IntSize& size, const uint32_t samples,
+     const RefPtr<DepthAndStencilBuffer>& depthAndStencilBuffer,
+-    const GLenum colorTarget, const GLuint colorName) {
++    const GLenum colorTarget, const GLuint colorName,
++    ColorBackingOwnership colorBackingOwnership) {
+   GLuint fb = gl->CreateFramebuffer();
+   const ScopedBindFramebuffer bindFB(gl, fb);
+ 
+@@ -129,7 +132,8 @@ MozFramebuffer::CreateForBackingWithShar
+   }
+ 
+   return UniquePtr<MozFramebuffer>(new MozFramebuffer(
+-      gl, size, fb, samples, depthAndStencilBuffer, colorTarget, colorName));
++      gl, size, fb, samples, depthAndStencilBuffer, colorTarget, colorName,
++      colorBackingOwnership));
+ }
+ 
+ /* static */ RefPtr<DepthAndStencilBuffer> DepthAndStencilBuffer::Create(
+@@ -174,14 +178,16 @@ MozFramebuffer::CreateForBackingWithShar
+ MozFramebuffer::MozFramebuffer(
+     GLContext* const gl, const gfx::IntSize& size, GLuint fb,
+     const uint32_t samples, RefPtr<DepthAndStencilBuffer> depthAndStencilBuffer,
+-    const GLenum colorTarget, const GLuint colorName)
++    const GLenum colorTarget, const GLuint colorName,
++    ColorBackingOwnership colorBackingOwnership)
+     : mWeakGL(gl),
+       mSize(size),
+       mSamples(samples),
+       mFB(fb),
+       mColorTarget(colorTarget),
+       mDepthAndStencilBuffer(std::move(depthAndStencilBuffer)),
+-      mColorName(colorName) {
++      mColorName(colorName),
++      mColorBackingOwnership(colorBackingOwnership) {
+   MOZ_ASSERT(mColorTarget);
+   MOZ_ASSERT(mColorName);
+ }
+@@ -194,7 +200,9 @@ MozFramebuffer::~MozFramebuffer() {
+ 
+   gl->DeleteFramebuffer(mFB);
+ 
+-  DeleteByTarget(gl, mColorTarget, mColorName);
++  if (mColorBackingOwnership == ColorBackingOwnership::Owned) {
++    DeleteByTarget(gl, mColorTarget, mColorName);
++  }
+ }
+ 
+ bool MozFramebuffer::HasDepth() const {
+diff -up firefox-154.0/gfx/gl/MozFramebuffer.h.D318191 firefox-154.0/gfx/gl/MozFramebuffer.h
+--- firefox-154.0/gfx/gl/MozFramebuffer.h.D318191	2026-08-12 23:13:27.000000000 +0200
++++ firefox-154.0/gfx/gl/MozFramebuffer.h	2026-08-21 10:51:52.430220791 +0200
+@@ -42,6 +42,11 @@ class DepthAndStencilBuffer final : publ
+ };
+ 
+ class MozFramebuffer final {
++ public:
++  // A borrowed color backing must outlive the MozFramebuffer that wraps it.
++  enum class ColorBackingOwnership { Owned, Borrowed };
++
++ private:
+   const WeakPtr<GLContext> mWeakGL;
+ 
+  public:
+@@ -64,7 +69,9 @@ class MozFramebuffer final {
+   // Assumes that gl is the current context.
+   static UniquePtr<MozFramebuffer> CreateForBacking(
+       GLContext* gl, const gfx::IntSize& size, uint32_t samples,
+-      bool depthStencil, GLenum colorTarget, GLuint colorName);
++      bool depthStencil, GLenum colorTarget, GLuint colorName,
++      ColorBackingOwnership colorBackingOwnership =
++      ColorBackingOwnership::Owned);
+ 
+   // Create a new framebuffer backed by an existing texture or buffer.
+   // Use the same GLContext, size, and samples as framebufferToShareWith.
+@@ -74,19 +81,23 @@ class MozFramebuffer final {
+   static UniquePtr<MozFramebuffer> CreateForBackingWithSharedDepthAndStencil(
+       const gfx::IntSize& size, const uint32_t samples, GLenum colorTarget,
+       GLuint colorName,
+-      const RefPtr<DepthAndStencilBuffer>& depthAndStencilBuffer);
++      const RefPtr<DepthAndStencilBuffer>& depthAndStencilBuffer,
++      ColorBackingOwnership colorBackingOwnership =
++          ColorBackingOwnership::Owned);
+ 
+  private:
+   MozFramebuffer(GLContext* gl, const gfx::IntSize& size, GLuint fb,
+                  uint32_t samples,
+                  RefPtr<DepthAndStencilBuffer> depthAndStencilBuffer,
+-                 GLenum colorTarget, GLuint colorName);
++                 GLenum colorTarget, GLuint colorName,
++                 ColorBackingOwnership colorBackingOwnership);
+ 
+   // gl must be the current context when this is called.
+   static UniquePtr<MozFramebuffer> CreateImpl(
+       GLContext* const gl, const gfx::IntSize& size, const uint32_t samples,
+       const RefPtr<DepthAndStencilBuffer>& depthAndStencilBuffer,
+-      const GLenum colorTarget, const GLuint colorName);
++      const GLenum colorTarget, const GLuint colorName,
++      ColorBackingOwnership colorBackingOwnership);
+ 
+  public:
+   ~MozFramebuffer();
+diff -up firefox-154.0/gfx/layers/SurfacePoolWayland.cpp.D318191 firefox-154.0/gfx/layers/SurfacePoolWayland.cpp
+--- firefox-154.0/gfx/layers/SurfacePoolWayland.cpp.D318191	2026-08-12 23:13:28.000000000 +0200
++++ firefox-154.0/gfx/layers/SurfacePoolWayland.cpp	2026-08-21 10:47:56.479614816 +0200
+@@ -296,7 +296,8 @@ UniquePtr<MozFramebuffer> SurfacePoolWay
+     // framebuffer that shares it.
+     if (auto buffer = GetDepthBufferForSharing(aProofOfLock, aGL, aSize)) {
+       return MozFramebuffer::CreateForBackingWithSharedDepthAndStencil(
+-          aSize, 0, LOCAL_GL_TEXTURE_2D, aTexture, buffer);
++          aSize, 0, LOCAL_GL_TEXTURE_2D, aTexture, buffer,
++          MozFramebuffer::ColorBackingOwnership::Borrowed);
+     }
+   }
+ 
+@@ -304,7 +305,8 @@ UniquePtr<MozFramebuffer> SurfacePoolWay
+   // new depth buffer and store a weak pointer to the new depth buffer in
+   // mDepthBuffers.
+   UniquePtr<MozFramebuffer> fb = MozFramebuffer::CreateForBacking(
+-      aGL, aSize, 0, aNeedsDepthBuffer, LOCAL_GL_TEXTURE_2D, aTexture);
++      aGL, aSize, 0, aNeedsDepthBuffer, LOCAL_GL_TEXTURE_2D, aTexture,
++      MozFramebuffer::ColorBackingOwnership::Borrowed);
+   if (fb && fb->GetDepthAndStencilBuffer()) {
+     mDepthBuffers.AppendElement(
+         DepthBufferEntry{aGL, aSize, fb->GetDepthAndStencilBuffer().get()});

diff --git a/firefox.spec b/firefox.spec
index 8fefc03..019815a 100644
--- a/firefox.spec
+++ b/firefox.spec
@@ -256,6 +256,7 @@ Patch242:        0026-Add-KDE-integration-to-Firefox.patch
 Patch400:        mozilla-1196777.patch
 Patch401:        mozilla-1667096.patch
 Patch402:        D317117.1787384850.diff
+Patch403:        D318191.1787388141.diff
 
 # https://phabricator.services.mozilla.com/D312871
 # Drop with Firefox 156
@@ -544,6 +545,7 @@ cat %{SOURCE49} | sed -e "s|LIBCLANG_RT_PLACEHOLDER|`pwd`/wasi-sdk-30/build/sysr
 %patch -P400 -p1 -b .1196777
 %patch -P401 -p1 -b .1667096
 %patch -P402 -p1 -b .D317117
+%patch -P403 -p1 -b .D318191
 
 %patch -P410 -p1 -b .libwebrtc-video-capture-implement-buffer-stride-support-for-pipewire
 
@@ -1216,6 +1218,7 @@ fi
 * Fri Aug 21 2026 Martin Stransky <stransky@redhat.com> - 154.0-4
 - Backported fix for HDR crash when HLG transform is missing
   (and it's always missing!).
+- Backported HDR fix for GL framebuffer (D318191).
 
 * Tue Aug 18 2026 Jan Grulich <jgrulich@redhat.com> - 154.0-3
 - WebRTC backport: video_capture - implement buffer stride support for PipeWire

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-08-21  8:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-21  8:55 [rpms/firefox] f44: Backported HDR fix for GL framebuffer (D318191) Martin Stransky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox