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

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

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

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

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

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