• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 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_MutableTextureStateRef_DEFINED
9 #define skgpu_MutableTextureStateRef_DEFINED
10 
11 #include "include/core/SkRefCnt.h"
12 #include "include/gpu/MutableTextureState.h"
13 
14 namespace skgpu {
15 
16 class MutableTextureStateRef : public SkRefCnt {
17 public:
18 #ifdef SK_VULKAN
MutableTextureStateRef(VkImageLayout layout,uint32_t queueFamilyIndex)19     MutableTextureStateRef(VkImageLayout layout, uint32_t queueFamilyIndex)
20             : fState(layout, queueFamilyIndex) {}
21 #endif
22 
set(const MutableTextureState & state)23     void set(const MutableTextureState& state) { fState = state; }
24 
25 #ifdef SK_VULKAN
getImageLayout()26     VkImageLayout getImageLayout() const {
27         SkASSERT(fState.fBackend == BackendApi::kVulkan);
28         return fState.fVkState.getImageLayout();
29     }
30 
setImageLayout(VkImageLayout layout)31     void setImageLayout(VkImageLayout layout) {
32         SkASSERT(fState.fBackend == BackendApi::kVulkan);
33         fState.fVkState.setImageLayout(layout);
34     }
35 
getQueueFamilyIndex()36     uint32_t getQueueFamilyIndex() const {
37         SkASSERT(fState.fBackend == BackendApi::kVulkan);
38         return fState.fVkState.getQueueFamilyIndex();
39     }
40 
setQueueFamilyIndex(uint32_t queueFamilyIndex)41     void setQueueFamilyIndex(uint32_t queueFamilyIndex) {
42         SkASSERT(fState.fBackend == BackendApi::kVulkan);
43         fState.fVkState.setQueueFamilyIndex(queueFamilyIndex);
44     }
45 
getVkMutableTextureState()46     const VulkanMutableTextureState& getVkMutableTextureState() {
47         SkASSERT(fState.fBackend == BackendApi::kVulkan);
48         return fState.fVkState;
49     }
50 #endif
51 
52 
53 private:
54     MutableTextureState fState;
55 };
56 
57 } // namespace skgpu
58 
59 #endif // skgpu_MutableTextureStateRef_DEFINED
60 
61