1 | /* |
2 | * Copyright 2020 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 GrBackendSurfaceMutableStateImpl_DEFINED |
9 | #define GrBackendSurfaceMutableStateImpl_DEFINED |
10 | |
11 | #include "include/core/SkRefCnt.h" |
12 | #include "include/gpu/GrBackendSurfaceMutableState.h" |
13 | |
14 | class GrBackendSurfaceMutableStateImpl : public SkRefCnt { |
15 | public: |
16 | #ifdef SK_VULKAN |
17 | GrBackendSurfaceMutableStateImpl(VkImageLayout layout, uint32_t queueFamilyIndex) |
18 | : fState(layout, queueFamilyIndex) {} |
19 | |
20 | GrBackendSurfaceMutableStateImpl(GrVkSharedImageInfo sharedInfo) |
21 | : fState(sharedInfo.getImageLayout(), sharedInfo.getQueueFamilyIndex()) {} |
22 | #endif |
23 | |
24 | void set(const GrBackendSurfaceMutableState& state) { fState = state; } |
25 | |
26 | #ifdef SK_VULKAN |
27 | VkImageLayout getImageLayout() const { |
28 | SkASSERT(fState.fBackend == GrBackend::kVulkan); |
29 | return fState.fVkState.getImageLayout(); |
30 | } |
31 | |
32 | void setImageLayout(VkImageLayout layout) { |
33 | SkASSERT(fState.fBackend == GrBackend::kVulkan); |
34 | fState.fVkState.setImageLayout(layout); |
35 | } |
36 | |
37 | uint32_t getQueueFamilyIndex() const { |
38 | SkASSERT(fState.fBackend == GrBackend::kVulkan); |
39 | return fState.fVkState.getQueueFamilyIndex(); |
40 | } |
41 | |
42 | void setQueueFamilyIndex(uint32_t queueFamilyIndex) { |
43 | SkASSERT(fState.fBackend == GrBackend::kVulkan); |
44 | fState.fVkState.setQueueFamilyIndex(queueFamilyIndex); |
45 | } |
46 | |
47 | const GrVkSharedImageInfo& getVkSharedImageInfo() { |
48 | SkASSERT(fState.fBackend == GrBackend::kVulkan); |
49 | return fState.fVkState; |
50 | } |
51 | #endif |
52 | |
53 | |
54 | private: |
55 | GrBackendSurfaceMutableState fState; |
56 | }; |
57 | |
58 | #endif |
59 | |