blob: a6f74814f065ac45050dcb21dc72ceba2c22cbce [file]
// Copyright 2026 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GPU_COMMAND_BUFFER_COMMON_IOSURFACE_VALIDATION_H_
#define GPU_COMMAND_BUFFER_COMMON_IOSURFACE_VALIDATION_H_
#include <string>
#include "components/viz/common/resources/shared_image_format.h"
#include "gpu/command_buffer/common/gpu_command_buffer_common_export.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/mac/io_surface.h"
namespace gpu {
// Ensure that the IOSurface has the same size and pixel format as those
// specified by `size` and `format`. If `cpu_access` is specified, then also
// ensure that the IOSurface supports CPU access. A malicious client could lie
// about this, which, if subsequently used to determine parameters for bounds
// checking, could result in an out-of-bounds memory access.
bool GPU_COMMAND_BUFFER_COMMON_EXPORT
ValidateIOSurface(const gfx::ScopedIOSurface& io_surface,
viz::SharedImageFormat format,
gfx::Size size,
bool cpu_access,
std::string* out_error_str);
} // namespace gpu
#endif // GPU_COMMAND_BUFFER_COMMON_IOSURFACE_VALIDATION_H_