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#ifndef FLUTTER_TESTING_TEST_VULKAN_CONTEXT_H_
6#define FLUTTER_TESTING_TEST_VULKAN_CONTEXT_H_
7
8#include "flutter/fml/macros.h"
9#include "flutter/fml/memory/ref_ptr.h"
10#include "flutter/testing/test_vulkan_image.h"
11#include "flutter/vulkan/procs/vulkan_proc_table.h"
12#include "flutter/vulkan/vulkan_application.h"
13#include "flutter/vulkan/vulkan_device.h"
14
15#include "third_party/skia/include/core/SkSize.h"
16#include "third_party/skia/include/gpu/GrDirectContext.h"
17
18namespace flutter {
19namespace testing {
20
21class TestVulkanContext : public fml::RefCountedThreadSafe<TestVulkanContext> {
22 public:
23 TestVulkanContext();
24 ~TestVulkanContext();
25
26 std::optional<TestVulkanImage> CreateImage(const SkISize& size) const;
27
28 sk_sp<GrDirectContext> GetGrDirectContext() const;
29
30 private:
31 fml::RefPtr<vulkan::VulkanProcTable> vk_;
32 std::unique_ptr<vulkan::VulkanApplication> application_;
33 std::unique_ptr<vulkan::VulkanDevice> device_;
34
35 sk_sp<GrDirectContext> context_;
36
37 friend class EmbedderTestContextVulkan;
38 friend class EmbedderConfigBuilder;
39
40 FML_FRIEND_MAKE_REF_COUNTED(TestVulkanContext);
41 FML_FRIEND_REF_COUNTED_THREAD_SAFE(TestVulkanContext);
42 FML_DISALLOW_COPY_AND_ASSIGN(TestVulkanContext);
43};
44
45} // namespace testing
46} // namespace flutter
47
48#endif // FLUTTER_TESTING_TEST_VULKAN_CONTEXT_H_
49

source code of flutter_engine/flutter/testing/test_vulkan_context.h