• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2018 Google Inc.
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 #include "include/private/GrVkTypesPriv.h"
9 
10 #include "src/gpu/GrBackendSurfaceMutableStateImpl.h"
11 #include "src/gpu/vk/GrVkImageLayout.h"
12 
cleanup()13 void GrVkBackendSurfaceInfo::cleanup() {};
14 
assign(const GrVkBackendSurfaceInfo & that,bool isThisValid)15 void GrVkBackendSurfaceInfo::assign(const GrVkBackendSurfaceInfo& that, bool isThisValid) {
16     fImageInfo = that.fImageInfo;
17 }
18 
snapImageInfo(const GrBackendSurfaceMutableStateImpl * mutableState) const19 GrVkImageInfo GrVkBackendSurfaceInfo::snapImageInfo(
20         const GrBackendSurfaceMutableStateImpl* mutableState) const {
21     SkASSERT(mutableState);
22     GrVkImageInfo newInfo = fImageInfo;
23     newInfo.fImageLayout = mutableState->getImageLayout();
24     newInfo.fCurrentQueueFamily = mutableState->getQueueFamilyIndex();
25     return newInfo;
26 }
27 
GrVkImageSpecToSurfaceInfo(const GrVkImageSpec & vkSpec,uint32_t sampleCount,uint32_t levelCount,GrProtected isProtected)28 GrVkSurfaceInfo GrVkImageSpecToSurfaceInfo(const GrVkImageSpec& vkSpec,
29                                            uint32_t sampleCount,
30                                            uint32_t levelCount,
31                                            GrProtected isProtected) {
32     GrVkSurfaceInfo info;
33     // Shared info
34     info.fSampleCount = sampleCount;
35     info.fLevelCount = levelCount;
36     info.fProtected = isProtected;
37 
38     // Vulkan info
39     info.fImageTiling = vkSpec.fImageTiling;
40     info.fFormat = vkSpec.fFormat;
41     info.fImageUsageFlags = vkSpec.fImageUsageFlags;
42     info.fYcbcrConversionInfo = vkSpec.fYcbcrConversionInfo;
43     info.fSharingMode = vkSpec.fSharingMode;
44 
45     return info;
46 }
47 
48 #if GR_TEST_UTILS
operator ==(const GrVkBackendSurfaceInfo & that) const49 bool GrVkBackendSurfaceInfo::operator==(const GrVkBackendSurfaceInfo& that) const {
50     GrVkImageInfo cpyInfoThis = fImageInfo;
51     GrVkImageInfo cpyInfoThat = that.fImageInfo;
52     // We don't care about the fImageLayout or fCurrentQueueFamily here since we require they use
53     // the same mutableState.
54     cpyInfoThis.fImageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
55     cpyInfoThat.fImageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
56     cpyInfoThis.fCurrentQueueFamily = VK_QUEUE_FAMILY_IGNORED;
57     cpyInfoThat.fCurrentQueueFamily = VK_QUEUE_FAMILY_IGNORED;
58     return cpyInfoThis == cpyInfoThat;
59 }
60 #endif
61