Flutter Engine
 
Loading...
Searching...
No Matches
surface_context_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 <sys/types.h>
6#include <memory>
7#include <utility>
8
9#include "gtest/gtest.h"
13
14namespace impeller {
15namespace testing {
16
17namespace {
18vk::UniqueSurfaceKHR CreateSurface(const ContextVK& context) {
19#if FML_OS_DARWIN
20 impeller::vk::MetalSurfaceCreateInfoEXT createInfo = {};
21 auto [result, surface] =
22 context.GetInstance().createMetalSurfaceEXTUnique(createInfo);
23 FML_DCHECK(result == vk::Result::eSuccess);
24 return std::move(surface);
25#else
26 return {};
27#endif // FML_OS_DARWIN
28}
29} // namespace
30
31TEST(SurfaceContextVK, TearsDownSwapchain) {
32 SetSwapchainImageSize({100, 100});
33 std::shared_ptr<ContextVK> context = MockVulkanContextBuilder().Build();
34
35 vk::UniqueSurfaceKHR surface = CreateSurface(*context);
36 SurfaceContextVK surface_context(context);
37
38 EXPECT_TRUE(surface_context.SetWindowSurface(std::move(surface), {100, 100}));
39 EXPECT_NE(surface_context.AcquireNextSurface(), nullptr);
40
41 surface_context.TeardownSwapchain();
42
43 EXPECT_EQ(surface_context.AcquireNextSurface(), nullptr);
44}
45
46} // namespace testing
47} // namespace impeller
bool SetWindowSurface(vk::UniqueSurfaceKHR surface, const ISize &size)
void TeardownSwapchain()
Can be called when the surface is destroyed to reduce memory usage.
std::unique_ptr< Surface > AcquireNextSurface()
std::shared_ptr< ContextVK > Build()
Create a Vulkan context with Vulkan functions mocked. The caller is given a chance to tinker on the s...
VkSurfaceKHR surface
Definition main.cc:65
#define FML_DCHECK(condition)
Definition logging.h:122
TEST(FrameTimingsRecorderTest, RecordVsync)
vk::UniqueSurfaceKHR CreateSurface(const ContextVK &context)
void SetSwapchainImageSize(ISize size)
Override the image size returned by all swapchain images.