yum-mirror/VkFFT

git clone https://git.yummers.dev/yum-mirror/VkFFT

Tolmachev DmitriiMetal support in VkFFTba7001c

master
3.1 KiB99 linesraw
1//-------------------------------------------------------------------------------------------------------------------------------------------------------------
2//
3// Metal/MTLDrawable.hpp
4//
5// Copyright 2020-2021 Apple Inc.
6//
7// Licensed under the Apache License, Version 2.0 (the "License");
8// you may not use this file except in compliance with the License.
9// You may obtain a copy of the License at
10//
11//     http://www.apache.org/licenses/LICENSE-2.0
12//
13// Unless required by applicable law or agreed to in writing, software
14// distributed under the License is distributed on an "AS IS" BASIS,
15// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16// See the License for the specific language governing permissions and
17// limitations under the License.
18//
19//-------------------------------------------------------------------------------------------------------------------------------------------------------------
20
21#pragma once
22
23#include "MTLDefines.hpp"
24#include "MTLHeaderBridge.hpp"
25#include "MTLPrivate.hpp"
26
27#include <Foundation/Foundation.hpp>
28
29#include <CoreFoundation/CoreFoundation.h>
30#include <functional>
31
32namespace MTL
33{
34using DrawablePresentedHandler = void (^)(class Drawable*);
35
36using DrawablePresentedHandlerFunction = std::function<void(class Drawable*)>;
37
38class Drawable : public NS::Referencing<Drawable>
39{
40public:
41    void           addPresentedHandler(const MTL::DrawablePresentedHandlerFunction& function);
42
43    void           present();
44
45    void           presentAtTime(CFTimeInterval presentationTime);
46
47    void           presentAfterMinimumDuration(CFTimeInterval duration);
48
49    void           addPresentedHandler(const MTL::DrawablePresentedHandler block);
50
51    CFTimeInterval presentedTime() const;
52
53    NS::UInteger   drawableID() const;
54};
55
56}
57
58_MTL_INLINE void MTL::Drawable::addPresentedHandler(const MTL::DrawablePresentedHandlerFunction& function)
59{
60    __block DrawablePresentedHandlerFunction blockFunction = function;
61
62    addPresentedHandler(^(Drawable* pDrawable) { blockFunction(pDrawable); });
63}
64
65// method: present
66_MTL_INLINE void MTL::Drawable::present()
67{
68    Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(present));
69}
70
71// method: presentAtTime:
72_MTL_INLINE void MTL::Drawable::presentAtTime(CFTimeInterval presentationTime)
73{
74    Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(presentAtTime_), presentationTime);
75}
76
77// method: presentAfterMinimumDuration:
78_MTL_INLINE void MTL::Drawable::presentAfterMinimumDuration(CFTimeInterval duration)
79{
80    Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(presentAfterMinimumDuration_), duration);
81}
82
83// method: addPresentedHandler:
84_MTL_INLINE void MTL::Drawable::addPresentedHandler(const MTL::DrawablePresentedHandler block)
85{
86    Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(addPresentedHandler_), block);
87}
88
89// property: presentedTime
90_MTL_INLINE CFTimeInterval MTL::Drawable::presentedTime() const
91{
92    return Object::sendMessage<CFTimeInterval>(this, _MTL_PRIVATE_SEL(presentedTime));
93}
94
95// property: drawableID
96_MTL_INLINE NS::UInteger MTL::Drawable::drawableID() const
97{
98    return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(drawableID));
99}