Resubmit 2289 with fix for glsl version
git-svn-id: http://skia.googlecode.com/svn/trunk@2291 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/include/GrAllocator.h b/gpu/include/GrAllocator.h
index 7652be3..eca2ab0 100755
--- a/gpu/include/GrAllocator.h
+++ b/gpu/include/GrAllocator.h
@@ -46,7 +46,7 @@
*
* @return pointer to the added item.
*/
- void* push_back() {
+ void* push_back() {
int indexInBlock = fCount % fItemsPerBlock;
// we always have at least one block
if (0 == indexInBlock) {
@@ -153,7 +153,7 @@
* Must be at least size(T)*itemsPerBlock sized.
* Caller is responsible for freeing this memory.
*/
- GrTAllocator(int itemsPerBlock, void* initialBlock)
+ explicit GrTAllocator(int itemsPerBlock, void* initialBlock = NULL)
: fAllocator(sizeof(T), itemsPerBlock, initialBlock) {}
/**
@@ -163,7 +163,7 @@
* and the size of subsequent blocks.
*/
template <int N>
- GrTAllocator(SkAlignedSTStorage<N,T>* initialBlock)
+ explicit GrTAllocator(SkAlignedSTStorage<N,T>* initialBlock)
: fAllocator(sizeof(T), N, initialBlock->get()) {}
/**
@@ -177,7 +177,14 @@
new (item) T;
return *(T*)item;
}
-
+
+ T& push_back(const T& t) {
+ void* item = fAllocator.push_back();
+ GrAssert(NULL != item);
+ new (item) T(t);
+ return *(T*)item;
+ }
+
/**
* removes all added items
*/