Flutter Impeller
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"
10
#include "
impeller/renderer/backend/vulkan/surface_context_vk.h
"
11
#include "impeller/renderer/backend/vulkan/test/mock_vulkan.h"
12
#include "
impeller/renderer/surface.h
"
13
14
namespace
impeller
{
15
namespace
testing {
16
17
namespace
{
18
vk::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
31
TEST
(
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
impeller::SurfaceContextVK
Definition:
surface_context_vk.h:33
impeller::SurfaceContextVK::SetWindowSurface
bool SetWindowSurface(vk::UniqueSurfaceKHR surface, const ISize &size)
Definition:
surface_context_vk.cc:70
impeller::SurfaceContextVK::TeardownSwapchain
void TeardownSwapchain()
Can be called when the surface is destroyed to reduce memory usage.
Definition:
surface_context_vk.cc:75
impeller::SurfaceContextVK::AcquireNextSurface
std::unique_ptr< Surface > AcquireNextSurface()
Definition:
surface_context_vk.cc:91
impeller::testing::TEST
TEST(AllocationSizeTest, CanCreateTypedAllocations)
Definition:
allocation_size_unittests.cc:10
impeller
Definition:
allocation.cc:12
surface.h
surface_context_vk.h
impeller
renderer
backend
vulkan
surface_context_vk_unittests.cc
Generated by
1.9.1