GrVkTypesPriv.h 1.5 KB

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