xref: /aosp_15_r20/external/skia/src/gpu/graphite/BackendSemaphore.cpp (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2023 Google LLC
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 "include/gpu/graphite/BackendSemaphore.h"
9 
10 #include "src/gpu/graphite/BackendSemaphorePriv.h"
11 
12 namespace skgpu::graphite {
13 
14 BackendSemaphore::BackendSemaphore() = default;
15 
16 BackendSemaphore::~BackendSemaphore() = default;
17 
BackendSemaphore(const BackendSemaphore & that)18 BackendSemaphore::BackendSemaphore(const BackendSemaphore& that) {
19     *this = that;
20 }
21 
operator =(const BackendSemaphore & that)22 BackendSemaphore& BackendSemaphore::operator=(const BackendSemaphore& that) {
23     if (!that.isValid()) {
24         fIsValid = false;
25         return *this;
26     }
27     SkASSERT(!this->isValid() || this->backend() == that.backend());
28     fIsValid = true;
29     fBackend = that.fBackend;
30 
31     switch (that.backend()) {
32         case BackendApi::kDawn:
33             SK_ABORT("Unsupported Backend");
34         case BackendApi::kMetal:
35         case BackendApi::kVulkan:
36             fSemaphoreData.reset();
37             that.fSemaphoreData->copyTo(fSemaphoreData);
38             break;
39         default:
40             SK_ABORT("Unsupported Backend");
41     }
42     return *this;
43 }
44 
~BackendSemaphoreData()45 BackendSemaphoreData::~BackendSemaphoreData(){};
46 
47 }  // End of namespace skgpu::graphite
48