| 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 |
#ifndef skgpu_MutableTextureStatePriv_DEFINED |
| 9 |
#define skgpu_MutableTextureStatePriv_DEFINED |
| 10 |
|
| 11 |
#include "include/core/SkTypes.h" |
| 12 |
#include "include/gpu/MutableTextureState.h" |
| 13 |
|
| 14 |
namespace skgpu { |
| 15 |
enum class BackendApi : unsigned int; |
| 16 |
|
| 17 |
class MutableTextureStateData { |
| 18 |
public: |
| 19 |
virtual ~MutableTextureStateData(); |
| 20 |
|
| 21 |
#if defined(SK_DEBUG) |
| 22 |
virtual BackendApi type() const = 0; |
| 23 |
#endif |
| 24 |
protected: |
| 25 |
MutableTextureStateData() = default; |
| 26 |
MutableTextureStateData(const MutableTextureStateData&) = default; |
| 27 |
|
| 28 |
using AnyStateData = MutableTextureState::AnyStateData; |
| 29 |
|
| 30 |
private: |
| 31 |
friend class MutableTextureState; |
| 32 |
virtual void copyTo(AnyStateData&) const = 0; |
| 33 |
}; |
| 34 |
|
| 35 |
class MutableTextureStatePriv final { |
| 36 |
public: |
| 37 |
template <typename StateData> |
| 38 |
static MutableTextureState MakeMutableTextureState(BackendApi backend, |
| 39 |
const StateData& data) { |
| 40 |
return MutableTextureState(backend, data); |
| 41 |
} |
| 42 |
|
| 43 |
static const MutableTextureStateData* GetStateData(const MutableTextureState& mts) { |
| 44 |
return mts.fStateData.get(); |
| 45 |
} |
| 46 |
|
| 47 |
static const MutableTextureStateData* GetStateData(const MutableTextureState* mts) { |
| 48 |
SkASSERT(mts); |
| 49 |
return mts->fStateData.get(); |
| 50 |
} |
| 51 |
|
| 52 |
static MutableTextureStateData* GetStateData(MutableTextureState* mts) { |
| 53 |
SkASSERT(mts); |
| 54 |
return mts->fStateData.get(); |
| 55 |
} |
| 56 |
}; |
| 57 |
} // namespace skgpu |
| 58 |
|
| 59 |
#endif |