Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 66f764a

Browse files
authored
Make testing/... and vulkan/... compatible with .clang-tidy. (#48161)
1 parent 1d2ee54 commit 66f764a

13 files changed

+77
-74
lines changed

flow/layers/platform_view_layer_unittests.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ TEST_F(PlatformViewLayerTest, ClippedPlatformViewPrerollsAndPaintsNothing) {
7777
{MockCanvas::DrawCall{0, MockCanvas::SaveData{1}},
7878
MockCanvas::DrawCall{
7979
1, MockCanvas::ClipRectData{parent_clip, ClipOp::kIntersect,
80-
MockCanvas::kHard_ClipEdgeStyle}},
80+
MockCanvas::kHardClipEdgeStyle}},
8181
MockCanvas::DrawCall{1, MockCanvas::SaveData{2}},
8282
MockCanvas::DrawCall{
8383
2, MockCanvas::ClipRectData{child_clip, ClipOp::kIntersect,
84-
MockCanvas::kHard_ClipEdgeStyle}},
84+
MockCanvas::kHardClipEdgeStyle}},
8585
MockCanvas::DrawCall{2, MockCanvas::RestoreData{1}},
8686
MockCanvas::DrawCall{1, MockCanvas::RestoreData{0}}}));
8787
}

testing/mock_canvas.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,21 +208,21 @@ void MockCanvas::DrawDisplayList(const sk_sp<DisplayList> display_list,
208208
}
209209

210210
void MockCanvas::ClipRect(const SkRect& rect, ClipOp op, bool is_aa) {
211-
ClipEdgeStyle style = is_aa ? kSoft_ClipEdgeStyle : kHard_ClipEdgeStyle;
211+
ClipEdgeStyle style = is_aa ? kSoftClipEdgeStyle : kHardClipEdgeStyle;
212212
draw_calls_.emplace_back(
213213
DrawCall{current_layer_, ClipRectData{rect, op, style}});
214214
tracker_.clipRect(rect, op, is_aa);
215215
}
216216

217217
void MockCanvas::ClipRRect(const SkRRect& rrect, ClipOp op, bool is_aa) {
218-
ClipEdgeStyle style = is_aa ? kSoft_ClipEdgeStyle : kHard_ClipEdgeStyle;
218+
ClipEdgeStyle style = is_aa ? kSoftClipEdgeStyle : kHardClipEdgeStyle;
219219
draw_calls_.emplace_back(
220220
DrawCall{current_layer_, ClipRRectData{rrect, op, style}});
221221
tracker_.clipRRect(rrect, op, is_aa);
222222
}
223223

224224
void MockCanvas::ClipPath(const SkPath& path, ClipOp op, bool is_aa) {
225-
ClipEdgeStyle style = is_aa ? kSoft_ClipEdgeStyle : kHard_ClipEdgeStyle;
225+
ClipEdgeStyle style = is_aa ? kSoftClipEdgeStyle : kHardClipEdgeStyle;
226226
draw_calls_.emplace_back(
227227
DrawCall{current_layer_, ClipPathData{path, op, style}});
228228
tracker_.clipPath(path, op, is_aa);
@@ -501,8 +501,8 @@ bool operator==(const MockCanvas::ClipRectData& a,
501501

502502
static std::ostream& operator<<(std::ostream& os,
503503
const MockCanvas::ClipEdgeStyle& style) {
504-
return os << (style == MockCanvas::kSoft_ClipEdgeStyle ? "kSoftEdges"
505-
: "kHardEdges");
504+
return os << (style == MockCanvas::kSoftClipEdgeStyle ? "kSoftEdges"
505+
: "kHardEdges");
506506
}
507507

508508
std::ostream& operator<<(std::ostream& os,

testing/mock_canvas.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ static constexpr SkRect kEmptyRect = SkRect::MakeEmpty();
3737
class MockCanvas final : public DlCanvas {
3838
public:
3939
enum ClipEdgeStyle {
40-
kHard_ClipEdgeStyle,
41-
kSoft_ClipEdgeStyle,
40+
kHardClipEdgeStyle,
41+
kSoftClipEdgeStyle,
4242
};
4343

4444
struct SaveData {

testing/stream_capture.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace testing {
2121
class StreamCapture {
2222
public:
2323
// Begins capturing output to the specified stream.
24-
StreamCapture(std::ostream* ostream);
24+
explicit StreamCapture(std::ostream* ostream);
2525

2626
// Stops capturing output to the specified stream, and restores the original
2727
// output buffer, if |Stop| has not already been called.

vulkan/procs/vulkan_handle.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class VulkanHandle {
2424
: handle_(handle), disposer_(disposer) {}
2525

2626
VulkanHandle(VulkanHandle&& other)
27-
: handle_(other.handle_), disposer_(other.disposer_) {
27+
: handle_(other.handle_), disposer_(std::move(other.disposer_)) {
2828
other.handle_ = VK_NULL_HANDLE;
2929
other.disposer_ = nullptr;
3030
}

vulkan/vulkan_backbuffer.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace vulkan {
1515
VulkanBackbuffer::VulkanBackbuffer(const VulkanProcTable& p_vk,
1616
const VulkanHandle<VkDevice>& device,
1717
const VulkanHandle<VkCommandPool>& pool)
18-
: vk(p_vk),
18+
: vk_(p_vk),
1919
device_(device),
2020
usage_command_buffer_(p_vk, device, pool),
2121
render_command_buffer_(p_vk, device, pool),
@@ -54,14 +54,14 @@ bool VulkanBackbuffer::CreateSemaphores() {
5454
};
5555

5656
auto semaphore_collect = [this](VkSemaphore semaphore) {
57-
vk.DestroySemaphore(device_, semaphore, nullptr);
57+
vk_.DestroySemaphore(device_, semaphore, nullptr);
5858
};
5959

6060
for (size_t i = 0; i < semaphores_.size(); i++) {
6161
VkSemaphore semaphore = VK_NULL_HANDLE;
6262

63-
if (VK_CALL_LOG_ERROR(vk.CreateSemaphore(device_, &create_info, nullptr,
64-
&semaphore)) != VK_SUCCESS) {
63+
if (VK_CALL_LOG_ERROR(vk_.CreateSemaphore(device_, &create_info, nullptr,
64+
&semaphore)) != VK_SUCCESS) {
6565
return false;
6666
}
6767

@@ -79,14 +79,14 @@ bool VulkanBackbuffer::CreateFences() {
7979
};
8080

8181
auto fence_collect = [this](VkFence fence) {
82-
vk.DestroyFence(device_, fence, nullptr);
82+
vk_.DestroyFence(device_, fence, nullptr);
8383
};
8484

8585
for (size_t i = 0; i < use_fences_.size(); i++) {
8686
VkFence fence = VK_NULL_HANDLE;
8787

88-
if (VK_CALL_LOG_ERROR(vk.CreateFence(device_, &create_info, nullptr,
89-
&fence)) != VK_SUCCESS) {
88+
if (VK_CALL_LOG_ERROR(vk_.CreateFence(device_, &create_info, nullptr,
89+
&fence)) != VK_SUCCESS) {
9090
return false;
9191
}
9292

@@ -103,7 +103,7 @@ bool VulkanBackbuffer::WaitFences() {
103103
fences[i] = use_fences_[i];
104104
}
105105

106-
return VK_CALL_LOG_ERROR(vk.WaitForFences(
106+
return VK_CALL_LOG_ERROR(vk_.WaitForFences(
107107
device_, static_cast<uint32_t>(use_fences_.size()), fences, true,
108108
std::numeric_limits<uint64_t>::max())) == VK_SUCCESS;
109109
}
@@ -115,7 +115,7 @@ bool VulkanBackbuffer::ResetFences() {
115115
fences[i] = use_fences_[i];
116116
}
117117

118-
return VK_CALL_LOG_ERROR(vk.ResetFences(
118+
return VK_CALL_LOG_ERROR(vk_.ResetFences(
119119
device_, static_cast<uint32_t>(use_fences_.size()), fences)) ==
120120
VK_SUCCESS;
121121
}

vulkan/vulkan_backbuffer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class VulkanBackbuffer {
4343
VulkanCommandBuffer& GetRenderCommandBuffer();
4444

4545
private:
46-
const VulkanProcTable& vk;
46+
const VulkanProcTable& vk_;
4747
const VulkanHandle<VkDevice>& device_;
4848
std::array<VulkanHandle<VkSemaphore>, 2> semaphores_;
4949
std::array<VulkanHandle<VkFence>, 2> use_fences_;

vulkan/vulkan_command_buffer.cc

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ VulkanCommandBuffer::VulkanCommandBuffer(
1212
const VulkanProcTable& p_vk,
1313
const VulkanHandle<VkDevice>& device,
1414
const VulkanHandle<VkCommandPool>& pool)
15-
: vk(p_vk), device_(device), pool_(pool), valid_(false) {
15+
: vk_(p_vk), device_(device), pool_(pool), valid_(false) {
1616
const VkCommandBufferAllocateInfo allocate_info = {
1717
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
1818
.pNext = nullptr,
@@ -23,14 +23,14 @@ VulkanCommandBuffer::VulkanCommandBuffer(
2323

2424
VkCommandBuffer buffer = VK_NULL_HANDLE;
2525

26-
if (VK_CALL_LOG_ERROR(vk.AllocateCommandBuffers(device_, &allocate_info,
27-
&buffer)) != VK_SUCCESS) {
26+
if (VK_CALL_LOG_ERROR(vk_.AllocateCommandBuffers(device_, &allocate_info,
27+
&buffer)) != VK_SUCCESS) {
2828
FML_DLOG(INFO) << "Could not allocate command buffers.";
2929
return;
3030
}
3131

3232
auto buffer_collect = [this](VkCommandBuffer buffer) {
33-
vk.FreeCommandBuffers(device_, pool_, 1, &buffer);
33+
vk_.FreeCommandBuffers(device_, pool_, 1, &buffer);
3434
};
3535

3636
handle_ = VulkanHandle<VkCommandBuffer>{buffer, buffer_collect};
@@ -56,11 +56,12 @@ bool VulkanCommandBuffer::Begin() const {
5656
.pInheritanceInfo = nullptr,
5757
};
5858

59-
return VK_CALL_LOG_ERROR(vk.BeginCommandBuffer(handle_, &info)) == VK_SUCCESS;
59+
return VK_CALL_LOG_ERROR(vk_.BeginCommandBuffer(handle_, &info)) ==
60+
VK_SUCCESS;
6061
}
6162

6263
bool VulkanCommandBuffer::End() const {
63-
return VK_CALL_LOG_ERROR(vk.EndCommandBuffer(handle_)) == VK_SUCCESS;
64+
return VK_CALL_LOG_ERROR(vk_.EndCommandBuffer(handle_)) == VK_SUCCESS;
6465
}
6566

6667
bool VulkanCommandBuffer::InsertPipelineBarrier(
@@ -73,10 +74,11 @@ bool VulkanCommandBuffer::InsertPipelineBarrier(
7374
const VkBufferMemoryBarrier* buffer_memory_barriers,
7475
uint32_t image_memory_barrier_count,
7576
const VkImageMemoryBarrier* image_memory_barriers) const {
76-
vk.CmdPipelineBarrier(handle_, src_stage_flags, dest_stage_flags,
77-
dependency_flags, memory_barrier_count, memory_barriers,
78-
buffer_memory_barrier_count, buffer_memory_barriers,
79-
image_memory_barrier_count, image_memory_barriers);
77+
vk_.CmdPipelineBarrier(handle_, src_stage_flags, dest_stage_flags,
78+
dependency_flags, memory_barrier_count,
79+
memory_barriers, buffer_memory_barrier_count,
80+
buffer_memory_barriers, image_memory_barrier_count,
81+
image_memory_barriers);
8082
return true;
8183
}
8284

vulkan/vulkan_command_buffer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class VulkanCommandBuffer {
4141
const VkImageMemoryBarrier* image_memory_barriers) const;
4242

4343
private:
44-
const VulkanProcTable& vk;
44+
const VulkanProcTable& vk_;
4545
const VulkanHandle<VkDevice>& device_;
4646
const VulkanHandle<VkCommandPool>& pool_;
4747
VulkanHandle<VkCommandBuffer> handle_;

vulkan/vulkan_device.cc

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ static uint32_t FindGraphicsQueueIndex(
3232
VulkanDevice::VulkanDevice(VulkanProcTable& p_vk,
3333
VulkanHandle<VkPhysicalDevice> physical_device,
3434
bool enable_validation_layers)
35-
: vk(p_vk),
35+
: vk_(p_vk),
3636
physical_device_(std::move(physical_device)),
3737
graphics_queue_index_(std::numeric_limits<uint32_t>::max()),
3838
valid_(false) {
39-
if (!physical_device_ || !vk.AreInstanceProcsSetup()) {
39+
if (!physical_device_ || !vk_.AreInstanceProcsSetup()) {
4040
return;
4141
}
4242

@@ -60,20 +60,20 @@ VulkanDevice::VulkanDevice(VulkanProcTable& p_vk,
6060

6161
const char* extensions[] = {
6262
#if FML_OS_ANDROID
63-
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
63+
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
6464
#endif
6565
#if OS_FUCHSIA
66-
VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME,
67-
VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME,
68-
VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME,
69-
VK_FUCHSIA_EXTERNAL_MEMORY_EXTENSION_NAME,
70-
VK_FUCHSIA_EXTERNAL_SEMAPHORE_EXTENSION_NAME,
71-
VK_FUCHSIA_BUFFER_COLLECTION_EXTENSION_NAME,
66+
VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME,
67+
VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME,
68+
VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME,
69+
VK_FUCHSIA_EXTERNAL_MEMORY_EXTENSION_NAME,
70+
VK_FUCHSIA_EXTERNAL_SEMAPHORE_EXTENSION_NAME,
71+
VK_FUCHSIA_BUFFER_COLLECTION_EXTENSION_NAME,
7272
#endif
7373
};
7474

7575
auto enabled_layers =
76-
DeviceLayersToEnable(vk, physical_device_, enable_validation_layers);
76+
DeviceLayersToEnable(vk_, physical_device_, enable_validation_layers);
7777

7878
const char* layers[enabled_layers.size()];
7979

@@ -96,23 +96,23 @@ VulkanDevice::VulkanDevice(VulkanProcTable& p_vk,
9696

9797
VkDevice device = VK_NULL_HANDLE;
9898

99-
if (VK_CALL_LOG_ERROR(vk.CreateDevice(physical_device_, &create_info, nullptr,
100-
&device)) != VK_SUCCESS) {
99+
if (VK_CALL_LOG_ERROR(vk_.CreateDevice(physical_device_, &create_info,
100+
nullptr, &device)) != VK_SUCCESS) {
101101
FML_DLOG(INFO) << "Could not create device.";
102102
return;
103103
}
104104

105105
device_ = VulkanHandle<VkDevice>{
106-
device, [this](VkDevice device) { vk.DestroyDevice(device, nullptr); }};
106+
device, [this](VkDevice device) { vk_.DestroyDevice(device, nullptr); }};
107107

108-
if (!vk.SetupDeviceProcAddresses(device_)) {
108+
if (!vk_.SetupDeviceProcAddresses(device_)) {
109109
FML_DLOG(INFO) << "Could not set up device proc addresses.";
110110
return;
111111
}
112112

113113
VkQueue queue = VK_NULL_HANDLE;
114114

115-
vk.GetDeviceQueue(device_, graphics_queue_index_, 0, &queue);
115+
vk_.GetDeviceQueue(device_, graphics_queue_index_, 0, &queue);
116116

117117
if (queue == VK_NULL_HANDLE) {
118118
FML_DLOG(INFO) << "Could not get the device queue handle.";
@@ -133,13 +133,13 @@ VulkanDevice::VulkanDevice(VulkanProcTable& p_vk,
133133
VulkanHandle<VkDevice> device,
134134
uint32_t queue_family_index,
135135
VulkanHandle<VkQueue> queue)
136-
: vk(p_vk),
136+
: vk_(p_vk),
137137
physical_device_(std::move(physical_device)),
138138
device_(std::move(device)),
139139
queue_(std::move(queue)),
140140
graphics_queue_index_(queue_family_index),
141141
valid_(false) {
142-
if (!physical_device_ || !vk.AreInstanceProcsSetup()) {
142+
if (!physical_device_ || !vk_.AreInstanceProcsSetup()) {
143143
return;
144144
}
145145

@@ -159,16 +159,16 @@ bool VulkanDevice::InitializeCommandPool() {
159159
};
160160

161161
VkCommandPool command_pool = VK_NULL_HANDLE;
162-
if (VK_CALL_LOG_ERROR(vk.CreateCommandPool(device_, &command_pool_create_info,
163-
nullptr, &command_pool)) !=
162+
if (VK_CALL_LOG_ERROR(vk_.CreateCommandPool(
163+
device_, &command_pool_create_info, nullptr, &command_pool)) !=
164164
VK_SUCCESS) {
165165
FML_DLOG(INFO) << "Could not create the command pool.";
166166
return false;
167167
}
168168

169169
command_pool_ = VulkanHandle<VkCommandPool>{
170170
command_pool, [this](VkCommandPool pool) {
171-
vk.DestroyCommandPool(device_, pool, nullptr);
171+
vk_.DestroyCommandPool(device_, pool, nullptr);
172172
}};
173173

174174
return true;
@@ -183,7 +183,7 @@ bool VulkanDevice::IsValid() const {
183183
}
184184

185185
bool VulkanDevice::WaitIdle() const {
186-
return VK_CALL_LOG_ERROR(vk.DeviceWaitIdle(device_)) == VK_SUCCESS;
186+
return VK_CALL_LOG_ERROR(vk_.DeviceWaitIdle(device_)) == VK_SUCCESS;
187187
}
188188

189189
const VulkanHandle<VkDevice>& VulkanDevice::GetHandle() const {
@@ -220,7 +220,7 @@ bool VulkanDevice::GetSurfaceCapabilities(
220220
}
221221

222222
bool success =
223-
VK_CALL_LOG_ERROR(vk.GetPhysicalDeviceSurfaceCapabilitiesKHR(
223+
VK_CALL_LOG_ERROR(vk_.GetPhysicalDeviceSurfaceCapabilitiesKHR(
224224
physical_device_, surface.Handle(), capabilities)) == VK_SUCCESS;
225225

226226
if (!success) {
@@ -254,7 +254,7 @@ bool VulkanDevice::GetPhysicalDeviceFeatures(
254254
if (features == nullptr || !physical_device_) {
255255
return false;
256256
}
257-
vk.GetPhysicalDeviceFeatures(physical_device_, features);
257+
vk_.GetPhysicalDeviceFeatures(physical_device_, features);
258258
return true;
259259
}
260260

@@ -289,13 +289,13 @@ std::vector<VkQueueFamilyProperties> VulkanDevice::GetQueueFamilyProperties()
289289
const {
290290
uint32_t count = 0;
291291

292-
vk.GetPhysicalDeviceQueueFamilyProperties(physical_device_, &count, nullptr);
292+
vk_.GetPhysicalDeviceQueueFamilyProperties(physical_device_, &count, nullptr);
293293

294294
std::vector<VkQueueFamilyProperties> properties;
295295
properties.resize(count, {});
296296

297-
vk.GetPhysicalDeviceQueueFamilyProperties(physical_device_, &count,
298-
properties.data());
297+
vk_.GetPhysicalDeviceQueueFamilyProperties(physical_device_, &count,
298+
properties.data());
299299

300300
return properties;
301301
}
@@ -310,7 +310,7 @@ int VulkanDevice::ChooseSurfaceFormat(
310310
}
311311

312312
uint32_t format_count = 0;
313-
if (VK_CALL_LOG_ERROR(vk.GetPhysicalDeviceSurfaceFormatsKHR(
313+
if (VK_CALL_LOG_ERROR(vk_.GetPhysicalDeviceSurfaceFormatsKHR(
314314
physical_device_, surface.Handle(), &format_count, nullptr)) !=
315315
VK_SUCCESS) {
316316
return -1;
@@ -323,7 +323,7 @@ int VulkanDevice::ChooseSurfaceFormat(
323323
std::vector<VkSurfaceFormatKHR> formats;
324324
formats.resize(format_count);
325325

326-
if (VK_CALL_LOG_ERROR(vk.GetPhysicalDeviceSurfaceFormatsKHR(
326+
if (VK_CALL_LOG_ERROR(vk_.GetPhysicalDeviceSurfaceFormatsKHR(
327327
physical_device_, surface.Handle(), &format_count, formats.data())) !=
328328
VK_SUCCESS) {
329329
return -1;
@@ -388,7 +388,7 @@ bool VulkanDevice::QueueSubmit(
388388
.pSignalSemaphores = signal_semaphores.data(),
389389
};
390390

391-
if (VK_CALL_LOG_ERROR(vk.QueueSubmit(queue_, 1, &submit_info, fence)) !=
391+
if (VK_CALL_LOG_ERROR(vk_.QueueSubmit(queue_, 1, &submit_info, fence)) !=
392392
VK_SUCCESS) {
393393
return false;
394394
}

0 commit comments

Comments
 (0)