Flutter Engine
Loading...
Searching...
No Matches
allocator.h
Go to the documentation of this file.
1
// Copyright 2013 The Flutter Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#ifndef FLUTTER_IMPELLER_CORE_ALLOCATOR_H_
6
#define FLUTTER_IMPELLER_CORE_ALLOCATOR_H_
7
8
#include "
flutter/fml/mapping.h
"
9
#include "
impeller/base/allocation_size.h
"
10
#include "
impeller/core/device_buffer_descriptor.h
"
11
#include "
impeller/core/idle_waiter.h
"
12
#include "
impeller/core/texture.h
"
13
#include "
impeller/core/texture_descriptor.h
"
14
#include "
impeller/geometry/size.h
"
15
16
namespace
impeller
{
17
18
class
Context;
19
class
DeviceBuffer;
20
21
//------------------------------------------------------------------------------
22
/// @brief An object that allocates device memory.
23
///
24
class
Allocator
{
25
public
:
26
virtual
~Allocator
();
27
28
bool
IsValid
()
const
;
29
30
std::shared_ptr<DeviceBuffer>
CreateBuffer
(
31
const
DeviceBufferDescriptor
& desc);
32
33
//------------------------------------------------------------------------------
34
/// @brief Creates a new texture.
35
///
36
/// @param[in] desc The descriptor of the texture to create.
37
/// @param[in] threadsafe Whether mutations to this texture should be
38
/// protected with a threadsafe barrier.
39
///
40
/// This parameter only affects the OpenGLES rendering
41
/// backend.
42
///
43
/// If any interaction with this texture (including
44
/// creation) will be done on a thread other than
45
/// where the OpenGLES context resides, then
46
/// `threadsafe`, must be set to `true`.
47
///
48
std::shared_ptr<Texture>
CreateTexture
(
const
TextureDescriptor
& desc,
49
bool
threadsafe =
false
);
50
51
//------------------------------------------------------------------------------
52
/// @brief Minimum value for `row_bytes` on a Texture. The row
53
/// bytes parameter of that method must be aligned to this value.
54
///
55
virtual
uint16_t
MinimumBytesPerRow
(
PixelFormat
format)
const
;
56
57
std::shared_ptr<DeviceBuffer>
CreateBufferWithCopy
(
const
uint8_t* buffer,
58
size_t
length
);
59
60
std::shared_ptr<DeviceBuffer>
CreateBufferWithCopy
(
61
const
fml::Mapping
& mapping);
62
63
virtual
ISize
GetMaxTextureSizeSupported
()
const
= 0;
64
65
/// @brief Write debug memory usage information to the dart timeline in debug
66
/// and profile modes.
67
///
68
/// This is supported on both the Metal and Vulkan backends.
69
virtual
void
DebugTraceMemoryStatistics
()
const
{};
70
71
// Visible for testing.
72
virtual
Bytes
DebugGetHeapUsage
()
const
{
return
Bytes
{0}; }
73
74
protected
:
75
Allocator
();
76
77
virtual
std::shared_ptr<DeviceBuffer>
OnCreateBuffer
(
78
const
DeviceBufferDescriptor
& desc) = 0;
79
80
virtual
std::shared_ptr<Texture>
OnCreateTexture
(
81
const
TextureDescriptor
& desc,
82
bool
threadsafe =
false
) = 0;
83
84
private
:
85
Allocator
(
const
Allocator
&) =
delete
;
86
87
Allocator
& operator=(
const
Allocator
&) =
delete
;
88
};
89
90
}
// namespace impeller
91
92
#endif
// FLUTTER_IMPELLER_CORE_ALLOCATOR_H_
allocation_size.h
fml::Mapping
Definition
mapping.h:21
impeller::AllocationSize< 1u >
impeller::Allocator
An object that allocates device memory.
Definition
allocator.h:24
impeller::Allocator::MinimumBytesPerRow
virtual uint16_t MinimumBytesPerRow(PixelFormat format) const
Minimum value for row_bytes on a Texture. The row bytes parameter of that method must be aligned to t...
Definition
allocator.cc:69
impeller::Allocator::OnCreateTexture
virtual std::shared_ptr< Texture > OnCreateTexture(const TextureDescriptor &desc, bool threadsafe=false)=0
impeller::Allocator::Allocator
Allocator()
impeller::Allocator::GetMaxTextureSizeSupported
virtual ISize GetMaxTextureSizeSupported() const =0
impeller::Allocator::CreateBufferWithCopy
std::shared_ptr< DeviceBuffer > CreateBufferWithCopy(const uint8_t *buffer, size_t length)
Definition
allocator.cc:18
impeller::Allocator::CreateBuffer
std::shared_ptr< DeviceBuffer > CreateBuffer(const DeviceBufferDescriptor &desc)
Definition
allocator.cc:44
impeller::Allocator::DebugTraceMemoryStatistics
virtual void DebugTraceMemoryStatistics() const
Write debug memory usage information to the dart timeline in debug and profile modes.
Definition
allocator.h:69
impeller::Allocator::DebugGetHeapUsage
virtual Bytes DebugGetHeapUsage() const
Definition
allocator.h:72
impeller::Allocator::~Allocator
virtual ~Allocator()
impeller::Allocator::IsValid
bool IsValid() const
impeller::Allocator::OnCreateBuffer
virtual std::shared_ptr< DeviceBuffer > OnCreateBuffer(const DeviceBufferDescriptor &desc)=0
impeller::Allocator::CreateTexture
std::shared_ptr< Texture > CreateTexture(const TextureDescriptor &desc, bool threadsafe=false)
Creates a new texture.
Definition
allocator.cc:49
device_buffer_descriptor.h
idle_waiter.h
texture.h
size.h
length
size_t length
Definition
key_event_handler.cc:41
mapping.h
impeller
Definition
texture.h:16
impeller::PixelFormat
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition
formats.h:99
impeller::DeviceBufferDescriptor
Definition
device_buffer_descriptor.h:14
impeller::TSize
Definition
size.h:25
impeller::TextureDescriptor
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
Definition
texture_descriptor.h:38
texture_descriptor.h
impeller
core
allocator.h
Generated on Thu Nov 6 2025 16:11:22 for Flutter Engine by
1.9.8