Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
shared_object_vk.h
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#ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SHARED_OBJECT_VK_H_
6#define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SHARED_OBJECT_VK_H_
7
8#include <memory>
9
10#include "flutter/fml/macros.h"
12
13namespace impeller {
14
16 public:
17 virtual ~SharedObjectVK() = default;
18};
19
20template <class T>
22 public:
23 using Resource = T;
25 vk::UniqueHandle<Resource, VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>;
26
27 explicit SharedObjectVKT(UniqueResource res) : resource_(std::move(res)) {}
28
29 // NOLINTNEXTLINE(google-explicit-constructor)
30 operator Resource() const { return Get(); }
31
32 const Resource& Get() const { return *resource_; }
33
34 private:
35 UniqueResource resource_;
36
37 SharedObjectVKT(const SharedObjectVKT&) = delete;
38
39 SharedObjectVKT& operator=(const SharedObjectVKT&) = delete;
40};
41
42template <class T>
44 vk::UniqueHandle<T, VULKAN_HPP_DEFAULT_DISPATCHER_TYPE> handle) {
45 if (!handle) {
46 return std::shared_ptr<SharedObjectVKT<T>>{nullptr};
47 }
48 return std::make_shared<SharedObjectVKT<T>>(std::move(handle));
49}
50
51template <class T>
52using SharedHandleVK = std::shared_ptr<SharedObjectVKT<T>>;
53
54} // namespace impeller
55
56#endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SHARED_OBJECT_VK_H_
vk::UniqueHandle< Resource, VULKAN_HPP_DEFAULT_DISPATCHER_TYPE > UniqueResource
const Resource & Get() const
SharedObjectVKT(UniqueResource res)
virtual ~SharedObjectVK()=default
std::shared_ptr< SharedObjectVKT< T > > SharedHandleVK
auto MakeSharedVK(vk::UniqueHandle< T, VULKAN_HPP_DEFAULT_DISPATCHER_TYPE > handle)
Definition ref_ptr.h:256
#define T