Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
src
sksl
SkSLMemoryPool.h
Go to the documentation of this file.
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
#include "
src/base/SkArenaAlloc.h
"
15
16
namespace
SkSL
{
17
18
class
MemoryPool
{
19
public
:
20
static
std::unique_ptr<MemoryPool>
Make
() {
21
return
std::make_unique<MemoryPool>();
22
}
23
void
*
allocate
(
size_t
size) {
24
return
fArena.
makeBytesAlignedTo
(size, kAlignment);
25
}
26
void
release
(
void
*) {
27
// SkArenaAlloc does not ever attempt to reclaim space.
28
}
29
30
private
:
31
#ifdef SK_FORCE_8_BYTE_ALIGNMENT
32
// https://github.com/emscripten-core/emscripten/issues/10072
33
// Since Skia does not use "long double" (16 bytes), we should be ok to force it back to 8 bytes
34
// until emscripten is fixed.
35
static
constexpr
size_t
kAlignment = 8;
36
#else
37
// Guaranteed alignment of pointer returned by allocate().
38
static
constexpr
size_t
kAlignment =
alignof
(std::max_align_t);
39
#endif
40
41
SkSTArenaAlloc<65536>
fArena{
/*firstHeapAllocation=*/
32768};
42
};
43
44
}
// namespace SkSL
45
46
#endif
// SKSL_MEMORYPOOL
SkArenaAlloc.h
SkTypes.h
SkArenaAlloc::makeBytesAlignedTo
void * makeBytesAlignedTo(size_t size, size_t align)
Definition
SkArenaAlloc.h:200
SkSL::MemoryPool
Definition
SkSLMemoryPool.h:18
SkSL::MemoryPool::Make
static std::unique_ptr< MemoryPool > Make()
Definition
SkSLMemoryPool.h:20
SkSL::MemoryPool::release
void release(void *)
Definition
SkSLMemoryPool.h:26
SkSL::MemoryPool::allocate
void * allocate(size_t size)
Definition
SkSLMemoryPool.h:23
SkSTArenaAlloc
Definition
SkArenaAlloc.h:332
SkSL
Definition
SkCapabilities.h:15
Generated on Fri Apr 26 2024 06:17:34 for Flutter Engine by
1.9.8