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#ifndef GrVkTypesPriv_DEFINED
9#define GrVkTypesPriv_DEFINED
10
11#include "include/core/SkRefCnt.h"
12#include "include/gpu/vk/GrVkTypes.h"
13
14class GrVkImageLayout;
15
16// This struct is to used to store the the actual information about the vulkan backend image on the
17// GrBackendTexture and GrBackendRenderTarget. When a client calls getVkImageInfo on a
18// GrBackendTexture/RenderTarget, we use the GrVkBackendSurfaceInfo to create a snapshot
19// GrVkImgeInfo object. Internally, this uses a ref count GrVkImageLayout object to track the
20// current VkImageLayout which can be shared with an internal GrVkImage so that layout updates can
21// be seen by all users of the image.
22struct GrVkBackendSurfaceInfo {
23 GrVkBackendSurfaceInfo(GrVkImageInfo info, GrVkImageLayout* layout)
24 : fImageInfo(info), fLayout(layout) {}
25
26 void cleanup();
27
28 GrVkBackendSurfaceInfo& operator=(const GrVkBackendSurfaceInfo&) = delete;
29
30 // Assigns the passed in GrVkBackendSurfaceInfo to this object. if isValid is true we will also
31 // attempt to unref the old fLayout on this object.
32 void assign(const GrVkBackendSurfaceInfo&, bool isValid);
33
34 void setImageLayout(VkImageLayout layout);
35
36 sk_sp<GrVkImageLayout> getGrVkImageLayout() const;
37
38 GrVkImageInfo snapImageInfo() const;
39
40 bool isProtected() const { return fImageInfo.fProtected == GrProtected::kYes; }
41#if GR_TEST_UTILS
42 bool operator==(const GrVkBackendSurfaceInfo& that) const;
43#endif
44
45private:
46 GrVkImageInfo fImageInfo;
47 GrVkImageLayout* fLayout;
48};
49
50#endif
51