blob: e1650a6bd31af3d6a5bd188c28b0ee7979889785 [file] [log] [blame]
joshualittd5a7db42015-01-27 15:39:06 -08001#include "GrBatch.h"
2
3#include "GrMemoryPool.h"
4#include "SkTLS.h"
5
6// TODO I noticed a small benefit to using a larger exclusive pool for batches. Its very small,
7// but seems to be mostly consistent. There is a lot in flux right now, but we should really
8// revisit this when batch is everywhere
9
10class GrBatch_Globals {
11public:
12 static GrMemoryPool* GetTLS() {
13 return (GrMemoryPool*)SkTLS::Get(CreateTLS, DeleteTLS);
14 }
15
16private:
17 static void* CreateTLS() {
18 return SkNEW_ARGS(GrMemoryPool, (16384, 16384));
19 }
20
21 static void DeleteTLS(void* pool) {
22 SkDELETE(reinterpret_cast<GrMemoryPool*>(pool));
23 }
24};
25
26int32_t GrBatch::gCurrBatchClassID =
27 GrBatch::kIllegalBatchClassID;
28
29void* GrBatch::operator new(size_t size) {
30 return GrBatch_Globals::GetTLS()->allocate(size);
31}
32
33void GrBatch::operator delete(void* target) {
34 GrBatch_Globals::GetTLS()->release(target);
35}