blob: 75bae16669757ff6f100291cec15e970e646b9c1 [file] [log] [blame]
John Stiles23e68662020-10-29 10:17:15 -04001/*
2 * Copyright 2016 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
8#ifndef SKSL_MEMORYPOOL
9#define SKSL_MEMORYPOOL
10
11#include <memory>
12
13#include "include/core/SkTypes.h"
14
15#if SK_SUPPORT_GPU
16
17#include "src/gpu/GrMemoryPool.h"
18
19namespace SkSL {
20using MemoryPool = ::GrMemoryPool;
21}
22
23#else
24
25// When Ganesh is disabled, GrMemoryPool is not linked in. We include a minimal class which mimics
26// the GrMemoryPool interface but simply redirects to the system allocator.
27namespace SkSL {
28
29class MemoryPool {
30public:
31 static std::unique_ptr<MemoryPool> Make(size_t, size_t) {
32 return std::make_unique<MemoryPool>();
33 }
34 void reportLeaks() const {}
35 bool isEmpty() const { return true; }
36 void* allocate(size_t size) { return ::operator new(size); }
37 void release(void* p) { ::operator delete(p); }
38};
39
40} // namespace SkSL
41
42#endif // SK_SUPPORT_GPU
43#endif // SKSL_MEMORYPOOL