GrVkTypesPriv.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. #include "include/private/GrVkTypesPriv.h"
  8. #include "src/gpu/vk/GrVkImageLayout.h"
  9. void GrVkBackendSurfaceInfo::cleanup() {
  10. SkSafeUnref(fLayout);
  11. fLayout = nullptr;
  12. };
  13. void GrVkBackendSurfaceInfo::assign(const GrVkBackendSurfaceInfo& that, bool isThisValid) {
  14. fImageInfo = that.fImageInfo;
  15. GrVkImageLayout* oldLayout = fLayout;
  16. fLayout = SkSafeRef(that.fLayout);
  17. if (isThisValid) {
  18. SkSafeUnref(oldLayout);
  19. }
  20. }
  21. void GrVkBackendSurfaceInfo::setImageLayout(VkImageLayout layout) {
  22. SkASSERT(fLayout);
  23. fLayout->setImageLayout(layout);
  24. }
  25. sk_sp<GrVkImageLayout> GrVkBackendSurfaceInfo::getGrVkImageLayout() const {
  26. SkASSERT(fLayout);
  27. return sk_ref_sp(fLayout);
  28. }
  29. GrVkImageInfo GrVkBackendSurfaceInfo::snapImageInfo() const {
  30. return GrVkImageInfo(fImageInfo, fLayout->getImageLayout());
  31. }
  32. #if GR_TEST_UTILS
  33. bool GrVkBackendSurfaceInfo::operator==(const GrVkBackendSurfaceInfo& that) const {
  34. GrVkImageInfo cpyInfoThis = fImageInfo;
  35. GrVkImageInfo cpyInfoThat = that.fImageInfo;
  36. // We don't care about the fImageLayout here since we require they use the same
  37. // GrVkImageLayout.
  38. cpyInfoThis.fImageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
  39. cpyInfoThat.fImageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
  40. return cpyInfoThis == cpyInfoThat && fLayout == that.fLayout;
  41. }
  42. #endif