Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Unified Diff: src/gpu/GrResourceHandle.h

Issue 1955893002: Allow gpu ResourceHandle class to be shared for multiple purposes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: review nit Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/gpu/GrResourceHandle.h
diff --git a/src/gpu/GrResourceHandle.h b/src/gpu/GrResourceHandle.h
new file mode 100644
index 0000000000000000000000000000000000000000..79e58b09444b65ef235ff0d86599424b91c86a60
--- /dev/null
+++ b/src/gpu/GrResourceHandle.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+*/
+
+#ifndef GrResourceHandle_DEFINED
+#define GrResourcehandle_DEFINED
+
+#include "SkTypes.h"
+
robertphillips 2016/05/09 13:13:11 indexed version ?
bsalomon 2016/05/09 13:25:23 I agree that these comments are not totally clear.
egdaniel 2016/05/09 17:19:54 Done.
bsalomon 2016/05/09 17:26:51 version->instantiation?
+// Opaque handle to a resource. Users should always use the macro below to create a specific indexed
+// version of the class.
+template <typename kind> class GrResourceHandle {
+public:
+ GrResourceHandle(int value) : fValue(value) {
+ SkASSERT(this->isValid());
+ }
+
+ GrResourceHandle() : fValue(kInvalid_ResourceHandle) {}
+
+ bool operator==(const GrResourceHandle& other) const { return other.fValue == fValue; }
+ bool isValid() const { return kInvalid_ResourceHandle != fValue; }
+ int toIndex() const { SkASSERT(this->isValid()); return fValue; }
+
+private:
+ static const int kInvalid_ResourceHandle = -1;
+ int fValue;
+};
+
robertphillips 2016/05/09 13:13:11 type index ?
egdaniel 2016/05/09 17:19:54 Done.
+// Creates a type "name" that is a specfic type index of GrResourceHandle.
+#define GR_DEFINE_RESOURCE_HANDLE_CLASS(name) \
+ struct name##Kind {}; \
+ using name = GrResourceHandle<name##Kind>;
+#endif

Powered by Google App Engine
This is Rietveld 408576698