forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathembedder_test_context_vulkan.cc
More file actions
72 lines (58 loc) · 2.44 KB
/
embedder_test_context_vulkan.cc
File metadata and controls
72 lines (58 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/shell/platform/embedder/tests/embedder_test_context_vulkan.h"
#include <memory>
#include <utility>
#include "flutter/fml/logging.h"
#include "flutter/shell/platform/embedder/tests/embedder_test_compositor_vulkan.h"
#include "flutter/testing/test_vulkan_context.h"
#include "flutter/testing/test_vulkan_surface.h"
#include "flutter/vulkan/procs/vulkan_proc_table.h"
#include "flutter/vulkan/vulkan_device.h"
#include "third_party/skia/include/core/SkSurface.h"
namespace flutter {
namespace testing {
EmbedderTestContextVulkan::EmbedderTestContextVulkan(std::string assets_path)
: EmbedderTestContext(std::move(assets_path)), surface_() {
vulkan_context_ = fml::MakeRefCounted<TestVulkanContext>();
}
EmbedderTestContextVulkan::~EmbedderTestContextVulkan() {}
void EmbedderTestContextVulkan::SetupSurface(SkISize surface_size) {
FML_CHECK(surface_size_.isEmpty());
surface_size_ = surface_size;
surface_ = TestVulkanSurface::Create(*vulkan_context_, surface_size_);
}
size_t EmbedderTestContextVulkan::GetSurfacePresentCount() const {
return present_count_;
}
VkImage EmbedderTestContextVulkan::GetNextImage(const SkISize& size) {
return surface_->GetImage();
}
bool EmbedderTestContextVulkan::PresentImage(VkImage image) {
FireRootSurfacePresentCallbackIfPresent(
[&]() { return surface_->GetSurfaceSnapshot(); });
present_count_++;
return true;
}
EmbedderTestContextType EmbedderTestContextVulkan::GetContextType() const {
return EmbedderTestContextType::kVulkanContext;
}
void EmbedderTestContextVulkan::SetupCompositor() {
FML_CHECK(!compositor_) << "Already set up a compositor in this context.";
FML_CHECK(surface_)
<< "Set up the Vulkan surface before setting up a compositor.";
compositor_ = std::make_unique<EmbedderTestCompositorVulkan>(
surface_size_, vulkan_context_->GetGrDirectContext());
}
void* EmbedderTestContextVulkan::InstanceProcAddr(
void* user_data,
FlutterVulkanInstanceHandle instance,
const char* name) {
auto proc_addr = reinterpret_cast<EmbedderTestContextVulkan*>(user_data)
->vulkan_context_->vk_->GetInstanceProcAddr(
reinterpret_cast<VkInstance>(instance), name);
return reinterpret_cast<void*>(proc_addr);
}
} // namespace testing
} // namespace flutter