Flutter Engine
The Flutter Engine
GrMtlSemaphore.h
Go to the documentation of this file.
1/*
2 * Copyright 2019 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef GrMtlSemaphore_DEFINED
9#define GrMtlSemaphore_DEFINED
10
16
17#include <Metal/Metal.h>
18
19class GrMtlGpu;
20
22public:
23 static sk_sp<GrMtlEvent> Make(GrMtlGpu* gpu);
24
26
27 ~GrMtlEvent() override {}
28
29 id<MTLEvent> mtlEvent() const SK_API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0)) {
30 return fMtlEvent;
31 }
32
33#ifdef SK_TRACE_MANAGED_RESOURCES
34 /** output a human-readable dump of this resource's information
35 */
36 void dumpInfo() const override {
37 if (@available(macOS 10.14, iOS 12.0, tvOS 12.0, *)) {
38 SkDebugf("GrMtlEvent: %p (%ld refs)\n", fMtlEvent,
39 CFGetRetainCount((CFTypeRef)fMtlEvent));
40 }
41 }
42#endif
43
44 void freeGPUData() const override {
45 if (@available(macOS 10.14, iOS 12.0, tvOS 12.0, *)) {
46 fMtlEvent = nil;
47 }
48 }
49
50private:
51 GrMtlEvent(id<MTLEvent> mtlEvent) SK_API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0))
52 : fMtlEvent(mtlEvent) {}
53
54 mutable id<MTLEvent> fMtlEvent SK_API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0));
55};
56
58public:
59 static std::unique_ptr<GrMtlSemaphore> Make(GrMtlGpu* gpu) {
61 if (!event) {
62 return nullptr;
63 }
64 return std::unique_ptr<GrMtlSemaphore>(new GrMtlSemaphore(std::move(event), 1));
65 }
66
67 static std::unique_ptr<GrMtlSemaphore> MakeWrapped(GrMTLHandle mtlEvent, uint64_t value) {
69 if (!event) {
70 return nullptr;
71 }
72 return std::unique_ptr<GrMtlSemaphore>(new GrMtlSemaphore(std::move(event), value));
73 }
74
75 ~GrMtlSemaphore() override {}
76
77 sk_sp<GrMtlEvent> event() { return fEvent; }
78 uint64_t value() const { return fValue; }
79
80 GrBackendSemaphore backendSemaphore() const override;
81
82private:
84 : fEvent(std::move(event))
85 , fValue(value) {}
86
87 void setIsOwned() override {}
88
89 sk_sp<GrMtlEvent> fEvent;
90 uint64_t fValue;
91
92 using INHERITED = GrSemaphore;
93};
94
95#endif
const void * GrMTLHandle
Definition: GrMtlTypes.h:20
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
void freeGPUData() const override
~GrMtlEvent() override
id< MTLEvent > mtlEvent() const SK_API_AVAILABLE(macos(10.14)
static sk_sp< GrMtlEvent > Make(GrMtlGpu *gpu)
id< MTLEvent > tvos(12.0))
id< MTLEvent > ios(12.0)
static sk_sp< GrMtlEvent > MakeWrapped(GrMTLHandle event)
static std::unique_ptr< GrMtlSemaphore > Make(GrMtlGpu *gpu)
sk_sp< GrMtlEvent > event()
uint64_t value() const
~GrMtlSemaphore() override
static std::unique_ptr< GrMtlSemaphore > MakeWrapped(GrMTLHandle mtlEvent, uint64_t value)
GrBackendSemaphore backendSemaphore() const override
FlKeyEvent * event
Definition: ref_ptr.h:256