tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 5f46d005fa5d4fdc49a2872a74d780e1e5ae8df5
parent 195873d7f314e2e03c04be36fda58483cb5919b3
Author: Nika Layzell <nika@thelayzells.com>
Date:   Tue, 16 Dec 2025 04:53:47 +0000

Bug 1927599 - Part 6: Get OpenGL-based rendering working on-device, r=gfx-reviewers,ahale

This requires adding a call to texImageIOSurface, which is only available
on-device, so cannot be used for simulator builds. We will need to come up with
another soltuion for simulator, which may reqire a non-IOSurface-based backend.

In addition, the compositor code needs to be changed to use GL_TEXTURE_2D
instead of GL_TEXTURE_RECTANGLE, as that type doesn't exist for OpenGL ES on
iOS.

Differential Revision: https://phabricator.services.mozilla.com/D229403

Diffstat:
Mbuild/moz.configure/toolchain.configure | 2++
Mgfx/layers/SurfacePoolCA.mm | 31++++++++++++++++++++++++-------
Mmobile/ios/app/mobile.js | 8+++++++-
Mmobile/ios/app/moz.build | 4++++
4 files changed, 37 insertions(+), 8 deletions(-)

diff --git a/build/moz.configure/toolchain.configure b/build/moz.configure/toolchain.configure @@ -334,6 +334,8 @@ with only_when(target_is_ios): # aarch64-apple-ios-sim is simulator return target.cpu == "x86_64" or target.raw_os == "ios-sim" + set_config("IPHONEOS_IS_SIMULATOR", target_is_ios_simulator) + def ios_sdk_min_version(): return "18.4" diff --git a/gfx/layers/SurfacePoolCA.mm b/gfx/layers/SurfacePoolCA.mm @@ -21,6 +21,7 @@ # include "GLContextCGL.h" #else # include "GLContextEAGL.h" +# include <OpenGLES/EAGLIOSurface.h> #endif #include "MozFramebuffer.h" @@ -40,6 +41,14 @@ using gl::GLContextCGL; using gl::GLContextEAGL; #endif +// GL_TEXTURE_RECTANGLE_ARB does not exist in OpenGL ES (which is used on iOS). +// Instead GL_TEXTURE_2D supports arbitrary dimensions. +#ifdef XP_MACOSX +static constexpr GLenum kTextureRectTarget = LOCAL_GL_TEXTURE_RECTANGLE_ARB; +#else +static constexpr GLenum kTextureRectTarget = LOCAL_GL_TEXTURE_2D; +#endif + /* static */ RefPtr<SurfacePool> SurfacePool::Create(size_t aPoolSizeLimit) { return new SurfacePoolCA(aPoolSizeLimit); } @@ -331,15 +340,24 @@ Maybe<GLuint> SurfacePoolCA::LockedPool::GetFramebufferForSurface( GLuint tex = aGL->CreateTexture(); { - const gl::ScopedBindTexture bindTex(aGL, tex, - LOCAL_GL_TEXTURE_RECTANGLE_ARB); + const gl::ScopedBindTexture bindTex(aGL, tex, kTextureRectTarget); #ifdef XP_MACOSX - CGLTexImageIOSurface2D(cgl->GetCGLContext(), LOCAL_GL_TEXTURE_RECTANGLE_ARB, + CGLTexImageIOSurface2D(cgl->GetCGLContext(), kTextureRectTarget, LOCAL_GL_RGBA, entry.mSize.width, entry.mSize.height, LOCAL_GL_BGRA, LOCAL_GL_UNSIGNED_INT_8_8_8_8_REV, entry.mIOSurface.get(), 0); -#else +#elif TARGET_OS_SIMULATOR + // texImageIOSurface is unavailable in simulator. MOZ_CRASH("unimplemented"); +#else + [eagl->GetEAGLContext() texImageIOSurface:entry.mIOSurface.get() + target:kTextureRectTarget + internalFormat:LOCAL_GL_RGBA + width:entry.mSize.width + height:entry.mSize.height + format:LOCAL_GL_BGRA + type:LOCAL_GL_UNSIGNED_INT_8_8_8_8_REV + plane:0]; #endif } @@ -380,7 +398,7 @@ SurfacePoolCA::LockedPool::CreateFramebufferForTexture(GLContext* aGL, // framebuffer that shares it. if (auto buffer = GetDepthBufferForSharing(aGL, aSize)) { return gl::MozFramebuffer::CreateForBackingWithSharedDepthAndStencil( - aSize, 0, LOCAL_GL_TEXTURE_RECTANGLE_ARB, aTexture, buffer); + aSize, 0, kTextureRectTarget, aTexture, buffer); } } @@ -388,8 +406,7 @@ SurfacePoolCA::LockedPool::CreateFramebufferForTexture(GLContext* aGL, // new depth buffer and store a weak pointer to the new depth buffer in // mDepthBuffers. UniquePtr<gl::MozFramebuffer> fb = gl::MozFramebuffer::CreateForBacking( - aGL, aSize, 0, aNeedsDepthBuffer, LOCAL_GL_TEXTURE_RECTANGLE_ARB, - aTexture); + aGL, aSize, 0, aNeedsDepthBuffer, kTextureRectTarget, aTexture); if (fb && fb->GetDepthAndStencilBuffer()) { mDepthBuffers.AppendElement( DepthBufferEntry{aGL, aSize, fb->GetDepthAndStencilBuffer().get()}); diff --git a/mobile/ios/app/mobile.js b/mobile/ios/app/mobile.js @@ -5,7 +5,13 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. pref("toolkit.defaultChromeURI", "chrome://geckoview/content/geckoview.xhtml"); -pref("gfx.webrender.software", true); + +// Use software webrender on simulator due to missing APIs. +#if TARGET_OS_SIMULATOR + pref("gfx.webrender.software", true); +#endif + +// Enable the restricted sandbox for content processes. pref("security.sandbox.content.level", 1); // Complete the page load progress bar at different places according to this pref. diff --git a/mobile/ios/app/moz.build b/mobile/ios/app/moz.build @@ -7,6 +7,10 @@ with Files("**"): BUG_COMPONENT = ("GeckoView", "General") +# We can't include TargetConditionals.h in geckoview-prefs.js, so fake the +# TARGET_OS_SIMULATOR define based on config. +DEFINES["TARGET_OS_SIMULATOR"] = 1 if CONFIG["IPHONEOS_IS_SIMULATOR"] else 0 + JS_PREFERENCE_PP_FILES += [ "mobile.js", ]