Flutter Engine
The Flutter Engine
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"
13
14namespace impeller {
15
16class Context;
17class DeviceBuffer;
18
19//------------------------------------------------------------------------------
20/// @brief An object that allocates device memory.
21///
22class Allocator {
23 public:
24 virtual ~Allocator();
25
26 bool IsValid() const;
27
28 std::shared_ptr<DeviceBuffer> CreateBuffer(
30
31 std::shared_ptr<Texture> CreateTexture(const TextureDescriptor& desc);
32
33 //------------------------------------------------------------------------------
34 /// @brief Minimum value for `row_bytes` on a Texture. The row
35 /// bytes parameter of that method must be aligned to this value.
36 ///
37 virtual uint16_t MinimumBytesPerRow(PixelFormat format) const;
38
39 std::shared_ptr<DeviceBuffer> CreateBufferWithCopy(const uint8_t* buffer,
40 size_t length);
41
42 std::shared_ptr<DeviceBuffer> CreateBufferWithCopy(
43 const fml::Mapping& mapping);
44
45 virtual ISize GetMaxTextureSizeSupported() const = 0;
46
47 /// @brief Write debug memory usage information to the dart timeline in debug
48 /// and profile modes.
49 ///
50 /// This is only supported on the Vulkan backend.
51 virtual void DebugTraceMemoryStatistics() const {};
52
53 protected:
55
56 virtual std::shared_ptr<DeviceBuffer> OnCreateBuffer(
57 const DeviceBufferDescriptor& desc) = 0;
58
59 virtual std::shared_ptr<Texture> OnCreateTexture(
60 const TextureDescriptor& desc) = 0;
61
62 private:
63 Allocator(const Allocator&) = delete;
64
65 Allocator& operator=(const Allocator&) = delete;
66};
67
68} // namespace impeller
69
70#endif // FLUTTER_IMPELLER_CORE_ALLOCATOR_H_
An object that allocates device memory.
Definition: allocator.h:22
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
virtual ISize GetMaxTextureSizeSupported() const =0
std::shared_ptr< DeviceBuffer > CreateBufferWithCopy(const uint8_t *buffer, size_t length)
Definition: allocator.cc:18
virtual std::shared_ptr< Texture > OnCreateTexture(const TextureDescriptor &desc)=0
std::shared_ptr< DeviceBuffer > CreateBuffer(const DeviceBufferDescriptor &desc)
Definition: allocator.cc:44
virtual void DebugTraceMemoryStatistics() const
Write debug memory usage information to the dart timeline in debug and profile modes.
Definition: allocator.h:51
bool IsValid() const
std::shared_ptr< Texture > CreateTexture(const TextureDescriptor &desc)
Definition: allocator.cc:49
virtual std::shared_ptr< DeviceBuffer > OnCreateBuffer(const DeviceBufferDescriptor &desc)=0
uint32_t uint32_t * format
size_t length
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition: formats.h:99
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...