1cb93a386Sopenharmony_ci/* 2cb93a386Sopenharmony_ci * Copyright 2020 Google LLC 3cb93a386Sopenharmony_ci * 4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be 5cb93a386Sopenharmony_ci * found in the LICENSE file. 6cb93a386Sopenharmony_ci */ 7cb93a386Sopenharmony_ci 8cb93a386Sopenharmony_ci#ifndef GrBackendSurfaceMutableStateImpl_DEFINED 9cb93a386Sopenharmony_ci#define GrBackendSurfaceMutableStateImpl_DEFINED 10cb93a386Sopenharmony_ci 11cb93a386Sopenharmony_ci#include "include/core/SkRefCnt.h" 12cb93a386Sopenharmony_ci#include "include/gpu/GrBackendSurfaceMutableState.h" 13cb93a386Sopenharmony_ci 14cb93a386Sopenharmony_ciclass GrBackendSurfaceMutableStateImpl : public SkRefCnt { 15cb93a386Sopenharmony_cipublic: 16cb93a386Sopenharmony_ci#ifdef SK_VULKAN 17cb93a386Sopenharmony_ci GrBackendSurfaceMutableStateImpl(VkImageLayout layout, uint32_t queueFamilyIndex) 18cb93a386Sopenharmony_ci : fState(layout, queueFamilyIndex) {} 19cb93a386Sopenharmony_ci 20cb93a386Sopenharmony_ci GrBackendSurfaceMutableStateImpl(GrVkSharedImageInfo sharedInfo) 21cb93a386Sopenharmony_ci : fState(sharedInfo.getImageLayout(), sharedInfo.getQueueFamilyIndex()) {} 22cb93a386Sopenharmony_ci#endif 23cb93a386Sopenharmony_ci 24cb93a386Sopenharmony_ci void set(const GrBackendSurfaceMutableState& state) { fState = state; } 25cb93a386Sopenharmony_ci 26cb93a386Sopenharmony_ci#ifdef SK_VULKAN 27cb93a386Sopenharmony_ci VkImageLayout getImageLayout() const { 28cb93a386Sopenharmony_ci SkASSERT(fState.fBackend == GrBackend::kVulkan); 29cb93a386Sopenharmony_ci return fState.fVkState.getImageLayout(); 30cb93a386Sopenharmony_ci } 31cb93a386Sopenharmony_ci 32cb93a386Sopenharmony_ci void setImageLayout(VkImageLayout layout) { 33cb93a386Sopenharmony_ci SkASSERT(fState.fBackend == GrBackend::kVulkan); 34cb93a386Sopenharmony_ci fState.fVkState.setImageLayout(layout); 35cb93a386Sopenharmony_ci } 36cb93a386Sopenharmony_ci 37cb93a386Sopenharmony_ci uint32_t getQueueFamilyIndex() const { 38cb93a386Sopenharmony_ci SkASSERT(fState.fBackend == GrBackend::kVulkan); 39cb93a386Sopenharmony_ci return fState.fVkState.getQueueFamilyIndex(); 40cb93a386Sopenharmony_ci } 41cb93a386Sopenharmony_ci 42cb93a386Sopenharmony_ci void setQueueFamilyIndex(uint32_t queueFamilyIndex) { 43cb93a386Sopenharmony_ci SkASSERT(fState.fBackend == GrBackend::kVulkan); 44cb93a386Sopenharmony_ci fState.fVkState.setQueueFamilyIndex(queueFamilyIndex); 45cb93a386Sopenharmony_ci } 46cb93a386Sopenharmony_ci 47cb93a386Sopenharmony_ci const GrVkSharedImageInfo& getVkSharedImageInfo() { 48cb93a386Sopenharmony_ci SkASSERT(fState.fBackend == GrBackend::kVulkan); 49cb93a386Sopenharmony_ci return fState.fVkState; 50cb93a386Sopenharmony_ci } 51cb93a386Sopenharmony_ci#endif 52cb93a386Sopenharmony_ci 53cb93a386Sopenharmony_ci 54cb93a386Sopenharmony_ciprivate: 55cb93a386Sopenharmony_ci GrBackendSurfaceMutableState fState; 56cb93a386Sopenharmony_ci}; 57cb93a386Sopenharmony_ci 58cb93a386Sopenharmony_ci#endif 59