Update rive-cpp to 2.0 version
[platform/core/uifw/rive-tizen.git] / submodule / skia / src / gpu / ganesh / mtl / GrMtlSemaphore.mm
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 #include "src/gpu/ganesh/mtl/GrMtlSemaphore.h"
9
10 #include "src/gpu/ganesh/mtl/GrMtlGpu.h"
11
12 #if !__has_feature(objc_arc)
13 #error This file must be compiled with Arc. Use -fobjc-arc flag
14 #endif
15
16 GR_NORETAIN_BEGIN
17
18 sk_sp<GrMtlEvent> GrMtlEvent::Make(GrMtlGpu* gpu) {
19     if (@available(macOS 10.14, iOS 12.0, *)) {
20         id<MTLEvent> event = [gpu->device() newEvent];
21         return sk_sp<GrMtlEvent>(new GrMtlEvent(event));
22     } else {
23         return nullptr;
24     }
25 }
26
27 sk_sp<GrMtlEvent> GrMtlEvent::MakeWrapped(GrMTLHandle event) {
28     // The GrMtlEvent will have strong ownership at this point.
29     // The GrMTLHandle will subsequently only have weak ownership.
30     if (@available(macOS 10.14, iOS 12.0, *)) {
31         id<MTLEvent> mtlEvent = (__bridge_transfer id<MTLEvent>)event;
32         return sk_sp<GrMtlEvent>(new GrMtlEvent(mtlEvent));
33     } else {
34         return nullptr;
35     }
36 }
37
38 GrBackendSemaphore GrMtlSemaphore::backendSemaphore() const {
39     GrBackendSemaphore backendSemaphore;
40     // The GrMtlSemaphore and the GrBackendSemaphore will have strong ownership at this point.
41     // Whoever uses the GrBackendSemaphore will subsquently steal this ref (see MakeWrapped, above).
42     if (@available(macOS 10.14, iOS 12.0, *)) {
43         GrMTLHandle handle = (__bridge_retained GrMTLHandle)(fEvent->mtlEvent());
44         backendSemaphore.initMetal(handle, fValue);
45     }
46     return backendSemaphore;
47 }
48
49 GR_NORETAIN_END