blob: f616c3bdbcf13bf14eec25da35cb239c7b9ba4fb [file] [log] [blame]
John Stiles23e68662020-10-29 10:17:15 -04001/*
John Stilese5d729c2020-10-29 10:26:28 -04002 * Copyright 2020 Google LLC
John Stiles23e68662020-10-29 10:17:15 -04003 *
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 }
John Stilese5d729c2020-10-29 10:26:28 -040034 void resetScratchSpace() {}
John Stiles23e68662020-10-29 10:17:15 -040035 void reportLeaks() const {}
36 bool isEmpty() const { return true; }
37 void* allocate(size_t size) { return ::operator new(size); }
38 void release(void* p) { ::operator delete(p); }
39};
40
41} // namespace SkSL
42
43#endif // SK_SUPPORT_GPU
44#endif // SKSL_MEMORYPOOL