blob: c80c12f63b09f9e39219a2495d75e369ae0c21e1 [file] [log] [blame]
caryclark45fa4472015-01-16 07:04:10 -08001/*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7#ifndef SkOpTAllocator_DEFINED
8#define SkOpTAllocator_DEFINED
9
10#include "SkChunkAlloc.h"
11
12// T is SkOpAngle2, SkOpSpan2, or SkOpSegment2
13template<typename T>
14class SkOpTAllocator {
15public:
16 static T* Allocate(SkChunkAlloc* allocator) {
17 void* ptr = allocator->allocThrow(sizeof(T));
18 T* record = (T*) ptr;
19 return record;
20 }
21
22 static T* New(SkChunkAlloc* allocator) {
23 return new (Allocate(allocator)) T();
24 }
25};
26
27#endif