• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 defined(SK_GANESH)
16 
17 #include "src/gpu/ganesh/GrMemoryPool.h"
18 
19 namespace SkSL {
20 using 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.
27 namespace SkSL {
28 
29 class MemoryPool {
30 public:
Make(size_t,size_t)31     static std::unique_ptr<MemoryPool> Make(size_t, size_t) {
32         return std::make_unique<MemoryPool>();
33     }
resetScratchSpace()34     void resetScratchSpace() {}
reportLeaks()35     void reportLeaks() const {}
isEmpty()36     bool isEmpty() const { return true; }
allocate(size_t size)37     void* allocate(size_t size) { return ::operator new(size); }
release(void * p)38     void release(void* p) { ::operator delete(p); }
39 };
40 
41 }  // namespace SkSL
42 
43 #endif // defined(SK_GANESH)
44 #endif // SKSL_MEMORYPOOL
45