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

Unified Diff: include/private/SkRefSet.h

Issue 2201323003: add pipecanvas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: drawVertices and drawTextOnPath Created 4 years, 4 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: include/private/SkRefSet.h
diff --git a/include/private/SkRefSet.h b/include/private/SkRefSet.h
new file mode 100644
index 0000000000000000000000000000000000000000..27cc7e8c439ff7ece698e12be196efa849e155ae
--- /dev/null
+++ b/include/private/SkRefSet.h
@@ -0,0 +1,39 @@
+/*
+ * 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 SkRefSet_DEFINED
+#define SkRefSet_DEFINED
+
+#include "SkRefCnt.h"
+#include "SkTDArray.h"
+
+template <typename T> class SkRefSet {
+public:
+ ~SkRefSet() { fArray.unrefAll(); }
+
+ T* get(int index) const {
+ return (unsigned)index < (unsigned)fArray.count() ? fArray[index] : nullptr;
+ }
+
+ bool set(int index, T* value) {
+ if ((unsigned)index < (unsigned)fArray.count()) {
+ SkRefCnt_SafeAssign(fArray[index], value);
+ return true;
+ }
+ if (fArray.count() == index && value) {
+ *fArray.append() = SkRef(value);
+ return true;
+ }
+ SkDebugf("SkRefSet: index [%d] out of range %d\n", index, fArray.count());
+ return false;
+ }
+
+private:
+ SkTDArray<T*> fArray;
+};
+
+#endif
« no previous file with comments | « include/core/SkWriteBuffer.h ('k') | samplecode/SampleApp.h » ('j') | src/core/SkReadBuffer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698