aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/vk/GrVkTypesPriv.cpp
blob: ec75e58e3bb502b3a0ed86f0dc58dfcf2435538b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
 * Copyright 2018 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "GrVkTypesPriv.h"

#include "GrVkImageLayout.h"

void GrVkBackendSurfaceInfo::cleanup() {
    SkSafeUnref(fLayout);
    fLayout = nullptr;
};

void GrVkBackendSurfaceInfo::assign(const GrVkBackendSurfaceInfo& that, bool isThisValid) {
    fImageInfo = that.fImageInfo;
    GrVkImageLayout* oldLayout = fLayout;
    fLayout = SkSafeRef(that.fLayout);
    if (isThisValid) {
        SkSafeUnref(oldLayout);
    }
}

void GrVkBackendSurfaceInfo::setImageLayout(VkImageLayout layout) {
    SkASSERT(fLayout);
    fLayout->setImageLayout(layout);
}

sk_sp<GrVkImageLayout> GrVkBackendSurfaceInfo::getGrVkImageLayout() const {
    SkASSERT(fLayout);
    return sk_ref_sp(fLayout);
}

GrVkImageInfo GrVkBackendSurfaceInfo::snapImageInfo() const {
    return GrVkImageInfo(fImageInfo, fLayout->getImageLayout());
}

#if GR_TEST_UTILS
bool GrVkBackendSurfaceInfo::operator==(const GrVkBackendSurfaceInfo& that) const {
    GrVkImageInfo cpyInfoThis = fImageInfo;
    GrVkImageInfo cpyInfoThat = that.fImageInfo;
    // We don't care about the fImageLayout here since we require they use the same
    // GrVkImageLayout.
    cpyInfoThis.fImageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
    cpyInfoThat.fImageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
    return cpyInfoThis == cpyInfoThat && fLayout == that.fLayout;
}
#endif