Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
ahb_swapchain_vk_unittests.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "gtest/gtest.h"
6
10
12
15
16const std::vector<std::string> kAndroidDeviceExtensions = {
17 "VK_KHR_swapchain",
18 "VK_ANDROID_external_memory_android_hardware_buffer",
19 "VK_KHR_sampler_ycbcr_conversion",
20 "VK_KHR_external_memory",
21 "VK_EXT_queue_family_foreign",
22 "VK_KHR_dedicated_allocation",
23};
24
26 public:
27 bool IsValid() const override { return true; }
28
29 ASurfaceControl* GetHandle() const override { return nullptr; }
30
31 bool RemoveFromParent() const override { return true; }
32};
33
34TEST(AndroidAHBSwapchainTest,
35 AHBSwapchainNoFenceWaitAfterAcquireNextImageFailure) {
36 bool wait_for_fences_called = false;
37 auto const context =
41 [](VkDevice, VkSwapchainKHR, uint64_t, VkSemaphore, VkFence,
42 uint32_t*) -> VkResult { return VK_ERROR_SURFACE_LOST_KHR; })
43 .SetWaitForFencesCallback([&](VkDevice, uint32_t, const VkFence*,
44 VkBool32, uint64_t) -> VkResult {
45 wait_for_fences_called = true;
46 return VK_SUCCESS;
47 })
48 .Build();
49
50 auto ahb_swapchain = std::shared_ptr<AHBSwapchainVK>(new AHBSwapchainVK(
51 context, std::make_shared<FakeSurfaceControl>(), {}, {100, 100}, false));
52
53 auto image = ahb_swapchain->AcquireNextDrawable();
54 EXPECT_FALSE(image);
55
56 ahb_swapchain->AcquireNextDrawable();
57 EXPECT_FALSE(wait_for_fences_called);
58}
59
60TEST(AndroidAHBSwapchainTest, AHBSwapchainDtorCallsWaitIdle) {
63 .Build();
64
65 auto ahb_swapchain = std::shared_ptr<AHBSwapchainVK>(new AHBSwapchainVK(
66 context, std::make_shared<FakeSurfaceControl>(), {}, {100, 100}, false));
67
68 ahb_swapchain.reset();
69
70 auto called_functions = GetMockVulkanFunctions(context->GetDevice());
71 EXPECT_NE(std::find(called_functions->begin(), called_functions->end(),
72 "vkDeviceWaitIdle"),
73 called_functions->end());
74}
75
76} // namespace impeller::android::testing
The implementation of a swapchain that uses hardware buffers presented to a given surface control on ...
A wrapper for ASurfaceControl. https://developer.android.com/ndk/reference/group/native-activity#asur...
bool RemoveFromParent() const override
Remove the surface control from the hierarchy of nodes presented by the system compositor.
MockVulkanContextBuilder & SetDeviceExtensions(const std::vector< std::string > &device_extensions)
Definition mock_vulkan.h:92
std::shared_ptr< ContextVK > Build()
Create a Vulkan context with Vulkan functions mocked. The caller is given a chance to tinker on the s...
MockVulkanContextBuilder SetAcquireNextImageCallback(std::function< std::remove_pointer_t< PFN_vkAcquireNextImageKHR > > acquire_next_image_callback)
FlutterVulkanImage * image
TEST(AndroidAHBSwapchainTest, AHBSwapchainNoFenceWaitAfterAcquireNextImageFailure)
const std::vector< std::string > kAndroidDeviceExtensions
std::shared_ptr< std::vector< std::string > > GetMockVulkanFunctions(VkDevice device)
std::shared_ptr< ContextGLES > context