0

[tvos] Use kern_return_t for the return type of IOSurface{Lock,Unlock}

This uses `kern_return_t` for the return type of
`IOSurface{Lock,Unlock}`. In the current code base, `IOReturn` is used
for the return type of `IOSurface{Lock, Unlock}` but the return type is
not available for tvOS. According to the function signature,
`IOSurface{Lock, Unlock}` returns `kern_return_t`. So, this change uses
`kern_return_t` and compares the return value with KERN_SUCCESS.

Bug: 391914246
Change-Id: I296c3a8ab77adc9283d3b02911eff5713916b269
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6429008
Reviewed-by: John Rummell <jrummell@chromium.org>
Reviewed-by: Matthew Denton <mpdenton@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Dave Tapuska <dtapuska@chromium.org>
Commit-Queue: Julie Jeongeun Kim <jkim@igalia.com>
Reviewed-by: Kyle Charbonneau <kylechar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1443779}
This commit is contained in:
Julie Jeongeun Kim
2025-04-07 14:48:56 -07:00
committed by Chromium LUCI CQ
parent 9c30fb3795
commit c16fc9a490
6 changed files with 22 additions and 20 deletions
components/viz/service/display_embedder
gpu
command_buffer
service
ipc
media/base
ui/gfx/mac

@@ -78,10 +78,10 @@ void SoftwareOutputDeviceMac::UpdateAndCopyBufferDamage(
{ {
TRACE_EVENT0("browser", "IOSurfaceLock for software copy"); TRACE_EVENT0("browser", "IOSurfaceLock for software copy");
IOReturn io_result = IOSurfaceLock( kern_return_t io_result = IOSurfaceLock(
previous_io_surface, kIOSurfaceLockReadOnly | kIOSurfaceLockAvoidSync, previous_io_surface, kIOSurfaceLockReadOnly | kIOSurfaceLockAvoidSync,
nullptr); nullptr);
if (io_result) { if (io_result != KERN_SUCCESS) {
DLOG(ERROR) << "Failed to lock previous IOSurface " << io_result; DLOG(ERROR) << "Failed to lock previous IOSurface " << io_result;
return; return;
} }
@@ -101,11 +101,12 @@ void SoftwareOutputDeviceMac::UpdateAndCopyBufferDamage(
{ {
TRACE_EVENT0("browser", "IOSurfaceUnlock"); TRACE_EVENT0("browser", "IOSurfaceUnlock");
IOReturn io_result = IOSurfaceUnlock( kern_return_t io_result = IOSurfaceUnlock(
previous_io_surface, kIOSurfaceLockReadOnly | kIOSurfaceLockAvoidSync, previous_io_surface, kIOSurfaceLockReadOnly | kIOSurfaceLockAvoidSync,
nullptr); nullptr);
if (io_result) if (io_result != KERN_SUCCESS) {
DLOG(ERROR) << "Failed to unlock previous IOSurface " << io_result; DLOG(ERROR) << "Failed to unlock previous IOSurface " << io_result;
}
} }
} }
@@ -156,9 +157,10 @@ SkCanvas* SoftwareOutputDeviceMac::BeginPaint(
// |current_paint_canvas_|. // |current_paint_canvas_|.
{ {
TRACE_EVENT0("browser", "IOSurfaceLock for software paint"); TRACE_EVENT0("browser", "IOSurfaceLock for software paint");
IOReturn io_result = IOSurfaceLock(current_paint_buffer_->io_surface.get(), kern_return_t io_result =
kIOSurfaceLockAvoidSync, nullptr); IOSurfaceLock(current_paint_buffer_->io_surface.get(),
if (io_result) { kIOSurfaceLockAvoidSync, nullptr);
if (io_result != KERN_SUCCESS) {
DLOG(ERROR) << "Failed to lock IOSurface " << io_result; DLOG(ERROR) << "Failed to lock IOSurface " << io_result;
current_paint_buffer_ = nullptr; current_paint_buffer_ = nullptr;
return nullptr; return nullptr;
@@ -186,11 +188,12 @@ void SoftwareOutputDeviceMac::EndPaint() {
{ {
TRACE_EVENT0("browser", "IOSurfaceUnlock"); TRACE_EVENT0("browser", "IOSurfaceUnlock");
IOReturn io_result = kern_return_t io_result =
IOSurfaceUnlock(current_paint_buffer_->io_surface.get(), IOSurfaceUnlock(current_paint_buffer_->io_surface.get(),
kIOSurfaceLockAvoidSync, nullptr); kIOSurfaceLockAvoidSync, nullptr);
if (io_result) if (io_result != KERN_SUCCESS) {
DLOG(ERROR) << "Failed to unlock IOSurface " << io_result; DLOG(ERROR) << "Failed to unlock IOSurface " << io_result;
}
} }
current_paint_canvas_.reset(); current_paint_canvas_.reset();

@@ -56,12 +56,12 @@ using GraphiteTextureHolder = SkiaImageRepresentation::GraphiteTextureHolder;
struct ScopedIOSurfaceLock { struct ScopedIOSurfaceLock {
ScopedIOSurfaceLock(IOSurfaceRef iosurface, IOSurfaceLockOptions options) ScopedIOSurfaceLock(IOSurfaceRef iosurface, IOSurfaceLockOptions options)
: io_surface_(iosurface) { : io_surface_(iosurface) {
IOReturn r = IOSurfaceLock(io_surface_, options, nullptr); kern_return_t r = IOSurfaceLock(io_surface_, options, nullptr);
CHECK_EQ(kIOReturnSuccess, r); CHECK_EQ(KERN_SUCCESS, r);
} }
~ScopedIOSurfaceLock() { ~ScopedIOSurfaceLock() {
IOReturn r = IOSurfaceUnlock(io_surface_, 0, nullptr); kern_return_t r = IOSurfaceUnlock(io_surface_, 0, nullptr);
CHECK_EQ(kIOReturnSuccess, r); CHECK_EQ(KERN_SUCCESS, r);
} }
ScopedIOSurfaceLock(const ScopedIOSurfaceLock&) = delete; ScopedIOSurfaceLock(const ScopedIOSurfaceLock&) = delete;

@@ -114,8 +114,8 @@ bool GpuMemoryBufferImplIOSurface::Map() {
if (map_count_++) if (map_count_++)
return true; return true;
IOReturn status = IOSurfaceLock(io_surface_.get(), lock_flags_, nullptr); kern_return_t status = IOSurfaceLock(io_surface_.get(), lock_flags_, nullptr);
DCHECK_NE(status, kIOReturnCannotLock) << " lock_flags_: " << lock_flags_; DCHECK_EQ(status, KERN_SUCCESS) << " lock_flags_: " << lock_flags_;
return true; return true;
} }

@@ -1003,7 +1003,7 @@ scoped_refptr<VideoFrame> VideoFrame::WrapUnacceleratedIOSurface(
// add a destruction callback to unlock the IOSurface. // add a destruction callback to unlock the IOSurface.
kern_return_t lock_result = kern_return_t lock_result =
IOSurfaceLock(io_surface.get(), kIOSurfaceLockReadOnly, nullptr); IOSurfaceLock(io_surface.get(), kIOSurfaceLockReadOnly, nullptr);
if (lock_result != kIOReturnSuccess) { if (lock_result != KERN_SUCCESS) {
DLOG(ERROR) << "Failed to lock IOSurface."; DLOG(ERROR) << "Failed to lock IOSurface.";
return nullptr; return nullptr;
} }

@@ -325,10 +325,10 @@ base::apple::ScopedCFTypeRef<IOSurfaceRef> CreateIOSurface(
if (should_clear) { if (should_clear) {
// Zero-initialize the IOSurface. Calling IOSurfaceLock/IOSurfaceUnlock // Zero-initialize the IOSurface. Calling IOSurfaceLock/IOSurfaceUnlock
// appears to be sufficient. https://crbug.com/584760#c17 // appears to be sufficient. https://crbug.com/584760#c17
IOReturn r = IOSurfaceLock(surface.get(), 0, nullptr); kern_return_t r = IOSurfaceLock(surface.get(), 0, nullptr);
DCHECK_EQ(kIOReturnSuccess, r); DCHECK_EQ(KERN_SUCCESS, r);
r = IOSurfaceUnlock(surface.get(), 0, nullptr); r = IOSurfaceUnlock(surface.get(), 0, nullptr);
DCHECK_EQ(kIOReturnSuccess, r); DCHECK_EQ(KERN_SUCCESS, r);
} }
// Ensure that all IOSurfaces start as sRGB. // Ensure that all IOSurfaces start as sRGB.

@@ -5,7 +5,6 @@
#ifndef UI_GFX_MAC_IO_SURFACE_H_ #ifndef UI_GFX_MAC_IO_SURFACE_H_
#define UI_GFX_MAC_IO_SURFACE_H_ #define UI_GFX_MAC_IO_SURFACE_H_
#include <IOKit/IOReturn.h>
#include <IOSurface/IOSurfaceRef.h> #include <IOSurface/IOSurfaceRef.h>
#include <mach/mach.h> #include <mach/mach.h>