| Flutter Impeller |

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 #pragma once
6
7 #include <memory>
8
9 #include "flutter/fml/macros.h"
10 #include "impeller/renderer/backend/vulkan/vk.h"
11
12 namespace impeller {
13
14 class SharedObjectVK {
15 public:
16 virtual ~SharedObjectVK() = default;
17 };
18
19 template <class T>
20 class SharedObjectVKT : public SharedObjectVK {
21 public:
22 using Resource = T;
23 using UniqueResource =
24 vk::UniqueHandle<Resource, VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>;
25
26 explicit SharedObjectVKT(UniqueResource res) : resource_(std::move(res)) {}
27
28 operator Resource() const { return Get(); }
29
30 const Resource& Get() const { return *resource_; }
31
32 private:
33 UniqueResource resource_;
34
35 FML_DISALLOW_COPY_AND_ASSIGN(SharedObjectVKT);
36 };
37
38 template <class T>
39 auto MakeSharedVK(
40 vk::UniqueHandle<T, VULKAN_HPP_DEFAULT_DISPATCHER_TYPE> handle) {
41 if (!handle) {
42 return std::shared_ptr<SharedObjectVKT<T>>{nullptr};
43 }
44 return std::make_shared<SharedObjectVKT<T>>(std::move(handle));
45 }
46
47 template <class T>
48 using SharedHandleVK = std::shared_ptr<SharedObjectVKT<T>>;
49
50 } // namespace impeller
impeller::SharedObjectVKT::Resource
T Resource
Definition: shared_object_vk.h:22
impeller::SharedObjectVKT::SharedObjectVKT
SharedObjectVKT(UniqueResource res)
Definition: shared_object_vk.h:26
vk.h
impeller::SharedObjectVK
Definition: shared_object_vk.h:14
impeller::SharedObjectVK::~SharedObjectVK
virtual ~SharedObjectVK()=default
impeller::SharedObjectVKT::UniqueResource
vk::UniqueHandle< Resource, VULKAN_HPP_DEFAULT_DISPATCHER_TYPE > UniqueResource
Definition: shared_object_vk.h:24
impeller::SharedObjectVKT::Get
const Resource & Get() const
Definition: shared_object_vk.h:30
impeller::MakeSharedVK
auto MakeSharedVK(vk::UniqueHandle< T, VULKAN_HPP_DEFAULT_DISPATCHER_TYPE > handle)
Definition: shared_object_vk.h:39
std
Definition: comparable.h:98
impeller::SharedHandleVK
std::shared_ptr< SharedObjectVKT< T > > SharedHandleVK
Definition: shared_object_vk.h:48
impeller::SharedObjectVKT
Definition: shared_object_vk.h:20
impeller
Definition: aiks_context.cc:10