0

[cleanup] Replace base::ranges with std::ranges: gpu/

Done entirely with `git grep` and `sed` + `git cl format`, no
hand-editing.

Bug: 386918226
Change-Id: I5d3721e2160366b10f183ba594346deb355cb041
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6203481
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Owners-Override: Peter Kasting <pkasting@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Victor Miura <vmiura@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1411883}
This commit is contained in:
Peter Kasting
2025-01-27 13:58:47 -08:00
committed by Chromium LUCI CQ
parent cf4648b447
commit 099bfc6275
17 changed files with 43 additions and 44 deletions

@ -4,10 +4,9 @@
#include "gpu/command_buffer/common/sync_token.h"
#include <algorithm>
#include <sstream>
#include "base/ranges/algorithm.h"
namespace gpu {
SyncPointClientId::SyncPointClientId(CommandBufferNamespace in_namespace_id,
@ -49,7 +48,7 @@ std::vector<SyncToken> ReduceSyncTokens(base::span<const SyncToken> tokens) {
std::vector<SyncToken> reduced;
for (const SyncToken& next_token : tokens) {
auto itr =
base::ranges::find_if(reduced, [&next_token](const SyncToken& token) {
std::ranges::find_if(reduced, [&next_token](const SyncToken& token) {
return next_token.namespace_id() == token.namespace_id() &&
next_token.command_buffer_id() == token.command_buffer_id();
});

@ -11,10 +11,10 @@
#include <stddef.h>
#include <algorithm>
#include <unordered_map>
#include "base/containers/heap_array.h"
#include "base/ranges/algorithm.h"
#include "build/build_config.h"
#include "gpu/command_buffer/common/gles2_cmd_copy_texture_chromium_utils.h"
#include "gpu/command_buffer/service/context_state.h"
@ -1004,8 +1004,8 @@ void CopyTextureResourceManagerImpl::Destroy() {
glDeleteFramebuffersEXT(1, &framebuffer_);
framebuffer_ = 0;
base::ranges::for_each(vertex_shaders_, DeleteShader);
base::ranges::for_each(fragment_shaders_, DeleteShader);
std::ranges::for_each(vertex_shaders_, DeleteShader);
std::ranges::for_each(fragment_shaders_, DeleteShader);
for (ProgramMap::const_iterator it = programs_.begin(); it != programs_.end();
++it) {

@ -42,7 +42,6 @@
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/numerics/safe_math.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/trace_event/trace_event.h"
@ -268,8 +267,7 @@ static bool CharacterIsValidForGLES(unsigned char c) {
}
static bool StringIsValidForGLES(const std::string& str) {
return str.length() == 0 ||
base::ranges::all_of(str, CharacterIsValidForGLES);
return str.length() == 0 || std::ranges::all_of(str, CharacterIsValidForGLES);
}
DisallowedFeatures::DisallowedFeatures() = default;

@ -9,6 +9,7 @@
#include "gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h"
#include <algorithm>
#include <memory>
#include <string>
#include <string_view>
@ -17,7 +18,6 @@
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_split.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
@ -2211,7 +2211,7 @@ bool GLES2DecoderPassthroughImpl::IsEmulatedQueryTarget(GLenum target) const {
}
bool GLES2DecoderPassthroughImpl::OnlyHasPendingProgramCompletionQueries() {
return base::ranges::all_of(pending_queries_, [](const auto& query) {
return std::ranges::all_of(pending_queries_, [](const auto& query) {
return query.target == GL_PROGRAM_COMPLETION_QUERY_CHROMIUM;
});
}
@ -2401,8 +2401,8 @@ error::Error GLES2DecoderPassthroughImpl::ProcessQueries(bool did_finish) {
}
void GLES2DecoderPassthroughImpl::RemovePendingQuery(GLuint service_id) {
auto pending_iter = base::ranges::find(pending_queries_, service_id,
&PendingQuery::service_id);
auto pending_iter = std::ranges::find(pending_queries_, service_id,
&PendingQuery::service_id);
if (pending_iter != pending_queries_.end()) {
QuerySync* sync = pending_iter->sync;
sync->result = 0;

@ -1164,7 +1164,7 @@ void D3DImageBacking::BeginAccessCommon(bool write_access) {
void D3DImageBacking::EndAccessCommon(
const D3DSharedFenceSet& signaled_fences) {
DCHECK(base::ranges::all_of(
DCHECK(std::ranges::all_of(
signaled_fences,
[](const scoped_refptr<gfx::D3DSharedFence>& fence) { return !!fence; }));
if (in_write_access_) {

@ -14,6 +14,7 @@
#include <dawn/native/DawnNative.h>
#include <dawn/webgpu_cpp.h>
#include <algorithm>
#include <memory>
#include <utility>
@ -21,7 +22,6 @@
#include "base/functional/callback_helpers.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/unsafe_shared_memory_region.h"
#include "base/ranges/algorithm.h"
#include "base/run_loop.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"

@ -9,11 +9,11 @@
#include "gpu/command_buffer/service/shared_image/external_vk_image_backing_factory.h"
#include <algorithm>
#include <memory>
#include <utility>
#include "base/functional/callback_helpers.h"
#include "base/ranges/algorithm.h"
#include "build/build_config.h"
#include "cc/test/pixel_test_utils.h"
#include "components/viz/common/gpu/vulkan_in_process_context_provider.h"

@ -12,11 +12,11 @@
#include <dawn/native/DawnNative.h>
#include <dawn/webgpu_cpp.h>
#include <algorithm>
#include <memory>
#include <utility>
#include "base/functional/callback_helpers.h"
#include "base/ranges/algorithm.h"
#include "components/viz/common/resources/resource_sizes.h"
#include "components/viz/common/resources/shared_image_format_utils.h"
#include "gpu/command_buffer/common/shared_image_usage.h"

@ -242,7 +242,7 @@ OzoneImageBacking::RetainGLTexturePerContextCache() {
// fail when doing multiple reimport of dmas (and creating multiple textures
// from a single image). See https://crbug.com/1498703.
scoped_refptr<OzoneImageGLTexturesHolder> new_holder;
const auto context_cache_pair = base::ranges::find_if(
const auto context_cache_pair = std::ranges::find_if(
per_context_cached_textures_holders_.begin(),
per_context_cached_textures_holders_.end(),
[current_context](const auto& holder_per_context) {

@ -4,9 +4,10 @@
#include "gpu/command_buffer/service/shared_image/shared_image_backing.h"
#include <algorithm>
#include "base/not_fatal_until.h"
#include "base/notreached.h"
#include "base/ranges/algorithm.h"
#include "base/trace_event/process_memory_dump.h"
#include "build/build_config.h"
#include "components/viz/common/resources/shared_image_format_utils.h"
@ -343,7 +344,7 @@ void SharedImageBacking::ReleaseRef(SharedImageRepresentation* representation) {
AutoLock auto_lock(this);
DCHECK(is_ref_counted_);
auto found = base::ranges::find(refs_, representation);
auto found = std::ranges::find(refs_, representation);
CHECK(found != refs_.end(), base::NotFatalUntil::M130);
// If the found representation is the first (owning) ref, free the attributed

@ -12,10 +12,10 @@
#ifndef GPU_COMMAND_BUFFER_SERVICE_VALUE_VALIDATOR_H_
#define GPU_COMMAND_BUFFER_SERVICE_VALUE_VALIDATOR_H_
#include <algorithm>
#include <vector>
#include "base/containers/contains.h"
#include "base/ranges/algorithm.h"
namespace gpu {
@ -43,7 +43,7 @@ class ValueValidator {
void RemoveValues(const T* invalid_values, int num_values) {
for (int ii = 0; ii < num_values; ++ii) {
auto iter = base::ranges::find(valid_values_, invalid_values[ii]);
auto iter = std::ranges::find(valid_values_, invalid_values[ii]);
if (iter != valid_values_.end()) {
valid_values_.erase(iter);
DCHECK(!IsValid(invalid_values[ii]));

@ -4,6 +4,7 @@
#include "gpu/ipc/client/image_decode_accelerator_proxy.h"
#include <algorithm>
#include <memory>
#include <utility>
#include <vector>
@ -11,7 +12,6 @@
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/notreached.h"
#include "base/ranges/algorithm.h"
#include "cc/paint/paint_image.h"
#include "gpu/command_buffer/common/constants.h"
#include "gpu/config/gpu_info.h"
@ -134,8 +134,8 @@ bool ImageDecodeAcceleratorProxy::IsImageSupported(
const std::vector<ImageDecodeAcceleratorSupportedProfile>& profiles =
host_->gpu_info().image_decode_accelerator_supported_profiles;
auto profile_it =
base::ranges::find(profiles, image_type,
&ImageDecodeAcceleratorSupportedProfile::image_type);
std::ranges::find(profiles, image_type,
&ImageDecodeAcceleratorSupportedProfile::image_type);
if (profile_it == profiles.cend())
return false;

@ -4,7 +4,8 @@
#include "gpu/ipc/common/gpu_feature_info_mojom_traits.h"
#include "base/ranges/algorithm.h"
#include <algorithm>
#include "build/build_config.h"
namespace mojo {

@ -7,6 +7,7 @@
#include <stddef.h>
#include <stdint.h>
#include <algorithm>
#include <memory>
#include <string>
#include <utility>
@ -22,7 +23,6 @@
#include "base/notreached.h"
#include "base/numerics/checked_math.h"
#include "base/numerics/safe_conversions.h"
#include "base/ranges/algorithm.h"
#include "base/run_loop.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
@ -114,8 +114,8 @@ uint64_t GetMemoryDumpByteSize(
const std::string& entry_name) {
DCHECK(dump);
auto entry_it =
base::ranges::find(dump->entries(), entry_name,
&base::trace_event::MemoryAllocatorDump::Entry::name);
std::ranges::find(dump->entries(), entry_name,
&base::trace_event::MemoryAllocatorDump::Entry::name);
if (entry_it != dump->entries().cend()) {
EXPECT_EQ(std::string(base::trace_event::MemoryAllocatorDump::kUnitsBytes),
entry_it->units);

@ -4,6 +4,7 @@
#include "gpu/vulkan/vulkan_device_queue.h"
#include <algorithm>
#include <array>
#include <bit>
#include <cstring>
@ -13,7 +14,6 @@
#include "base/feature_list.h"
#include "base/logging.h"
#include "base/ranges/algorithm.h"
#include "base/strings/stringprintf.h"
#include "base/task/single_thread_task_runner.h"
#include "base/trace_event/memory_dump_manager.h"
@ -226,11 +226,11 @@ bool VulkanDeviceQueue::Initialize(
std::vector<const char*> enabled_extensions;
for (const char* extension : required_extensions) {
if (base::ranges::none_of(physical_device_info.extensions,
[extension](const VkExtensionProperties& p) {
return std::strcmp(extension,
p.extensionName) == 0;
})) {
if (std::ranges::none_of(physical_device_info.extensions,
[extension](const VkExtensionProperties& p) {
return std::strcmp(extension, p.extensionName) ==
0;
})) {
// On Fuchsia, some device extensions are provided by layers.
// TODO(penghuang): checking extensions against layer device extensions
// too.
@ -244,11 +244,11 @@ bool VulkanDeviceQueue::Initialize(
}
for (const char* extension : optional_extensions) {
if (base::ranges::none_of(physical_device_info.extensions,
[extension](const VkExtensionProperties& p) {
return std::strcmp(extension,
p.extensionName) == 0;
})) {
if (std::ranges::none_of(physical_device_info.extensions,
[extension](const VkExtensionProperties& p) {
return std::strcmp(extension, p.extensionName) ==
0;
})) {
DLOG(ERROR) << "Optional Vulkan extension " << extension
<< " is not supported.";
} else {

@ -432,7 +432,7 @@ bool VulkanInstance::CollectDeviceInfo(VkPhysicalDevice physical_device) {
static_assert(kVulkanRequiredApiVersion >= VK_API_VERSION_1_1, "");
if (info.properties.apiVersion >= kVulkanRequiredApiVersion) {
bool has_drm_extension =
base::ranges::any_of(info.extensions, [](const auto& ext) {
std::ranges::any_of(info.extensions, [](const auto& ext) {
return strcmp(ext.extensionName,
VK_EXT_PHYSICAL_DEVICE_DRM_EXTENSION_NAME) == 0;
});

@ -9,11 +9,11 @@
#include "gpu/vulkan/vulkan_util.h"
#include <algorithm>
#include <string_view>
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/ranges/algorithm.h"
#include "base/strings/pattern.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
@ -267,7 +267,7 @@ bool IsVulkanV2EnabledForAdreno(
};
const bool is_slow_gpu_for_v2 =
base::ranges::any_of(slow_gpus_for_v2, [&](const char* pattern) {
std::ranges::any_of(slow_gpus_for_v2, [&](const char* pattern) {
return base::MatchPattern(device_properties.device_name, pattern);
});
@ -294,7 +294,7 @@ bool IsVulkanV3EnabledForAdreno(
};
const bool is_slow_gpu_for_v3 =
base::ranges::any_of(slow_gpus_for_v3, [&](const char* pattern) {
std::ranges::any_of(slow_gpus_for_v3, [&](const char* pattern) {
return base::MatchPattern(device_properties.device_name, pattern);
});