1/* 2 * Copyright 2020 Google LLC 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 resetScratchSpace() {} 35 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 45