aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkTArray.h
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-09-20 17:33:24 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-09-20 17:33:24 +0000
commit98874cdda0323aa1ffc730e271a2dd98b6dbbe38 (patch)
tree538a9af65566d7f526fae3db70ac209a80968f33 /include/core/SkTArray.h
parentdd5bd670e6784857824afb9a7c3b51eb8e1baf6b (diff)
[GPU] Use new Var type for inputs/outputs of FS and VS
Review URL: http://codereview.appspot.com/5056048/ git-svn-id: http://skia.googlecode.com/svn/trunk@2289 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core/SkTArray.h')
-rw-r--r--include/core/SkTArray.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/include/core/SkTArray.h b/include/core/SkTArray.h
index 975aeed639..3e2a00687b 100644
--- a/include/core/SkTArray.h
+++ b/include/core/SkTArray.h
@@ -246,6 +246,16 @@ public:
}
/**
+ * Version of above that uses a copy constructor to initialize the new item
+ */
+ T& push_back(const T& t) {
+ checkRealloc(1);
+ new ((char*)fMemArray+sizeof(T)*fCount) T(t);
+ ++fCount;
+ return fItemArray[fCount-1];
+ }
+
+ /**
* Allocates n more default T values, and returns the address of the start
* of that new range. Note: this address is only valid until the next API
* call made on the array that might add or remove elements.
@@ -261,6 +271,34 @@ public:
}
/**
+ * Version of above that uses a copy constructor to initialize all n items
+ * to the same T.
+ */
+ T* push_back_n(int n, const T& t) {
+ SkASSERT(n >= 0);
+ checkRealloc(n);
+ for (int i = 0; i < n; ++i) {
+ new (fItemArray + fCount + i) T(t);
+ }
+ fCount += n;
+ return fItemArray + fCount - n;
+ }
+
+ /**
+ * Version of above that uses a copy constructor to initialize the n items
+ * to separate T values.
+ */
+ T* push_back_n(int n, const T t[]) {
+ SkASSERT(n >= 0);
+ checkRealloc(n);
+ for (int i = 0; i < n; ++i) {
+ new (fItemArray + fCount + i) T(t[i]);
+ }
+ fCount += n;
+ return fItemArray + fCount - n;
+ }
+
+ /**
* Removes the last element. Not safe to call when count() == 0.
*/
void pop_back() {