Add optional param to setBackendTextureState to return previous state.
Bug: skia:10742
Change-Id: I334e7896d0a1509eb666c46d5731d2573a5c1aba
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/318698
Reviewed-by: Austin Eng <enga@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/GrBackendSurfaceMutableState.cpp b/src/gpu/GrBackendSurfaceMutableState.cpp
new file mode 100644
index 0000000..dec31d7
--- /dev/null
+++ b/src/gpu/GrBackendSurfaceMutableState.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2020 Google LLC
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "include/gpu/GrBackendSurfaceMutableState.h"
+
+#include <new>
+
+GrBackendSurfaceMutableState::GrBackendSurfaceMutableState(const GrBackendSurfaceMutableState& that)
+ : fBackend(that.fBackend), fIsValid(that.fIsValid) {
+ if (!fIsValid) {
+ return;
+ }
+ switch (fBackend) {
+ case GrBackend::kVulkan:
+#ifdef SK_VULKAN
+ SkASSERT(that.fBackend == GrBackend::kVulkan);
+ fVkState = that.fVkState;
+#endif
+ break;
+ default:
+ (void)that;
+ SkUNREACHABLE;
+ }
+}
+
+GrBackendSurfaceMutableState& GrBackendSurfaceMutableState::operator=(
+ const GrBackendSurfaceMutableState& that) {
+ if (this != &that) {
+ this->~GrBackendSurfaceMutableState();
+ new (this) GrBackendSurfaceMutableState(that);
+ }
+ return *this;
+}
+