xref: /aosp_15_r20/external/skia/src/gpu/MutableTextureState.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 #include "include/gpu/MutableTextureState.h"
8 
9 #include "include/gpu/GpuTypes.h"
10 #include "src/gpu/MutableTextureStatePriv.h"
11 
12 namespace skgpu {
13 
MutableTextureState()14 MutableTextureState::MutableTextureState():
15     fBackend(BackendApi::kUnsupported),
16     fIsValid(false) {}
17 MutableTextureState::~MutableTextureState() = default;
18 
MutableTextureState(const MutableTextureState & that)19 MutableTextureState::MutableTextureState(const MutableTextureState& that): fIsValid(false) {
20     this->set(that);
21 }
22 
operator =(const MutableTextureState & that)23 MutableTextureState& MutableTextureState::operator=(const MutableTextureState& that) {
24     if (this != &that) {
25         this->set(that);
26     }
27     return *this;
28 }
29 
set(const MutableTextureState & that)30 void MutableTextureState::set(const MutableTextureState& that) {
31     SkASSERT(!fIsValid || this->fBackend == that.fBackend);
32     fIsValid = that.fIsValid;
33     fBackend = that.fBackend;
34     if (!fIsValid) {
35         return;
36     }
37     fStateData.reset();
38     switch (fBackend) {
39         case BackendApi::kVulkan:
40             that.fStateData->copyTo(fStateData);
41             break;
42         default:
43             SK_ABORT("Unknown BackendApi");
44     }
45 }
46 
47 MutableTextureStateData::~MutableTextureStateData() = default;
48 
49 }  // namespace skgpu
50