| Flutter Impeller |

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/core/device_buffer_descriptor.h"
10 #include "impeller/core/texture.h"
11 #include "impeller/core/texture_descriptor.h"
12 #include "impeller/geometry/size.h"
13
14 namespace impeller {
15
16 class Context;
17 class DeviceBuffer;
18
19 //------------------------------------------------------------------------------
20 /// @brief An object that allocates device memory.
21 ///
22 class Allocator {
23 public:
24 virtual ~Allocator();
25
26 bool IsValid() const;
27
28 std::shared_ptr<DeviceBuffer> CreateBuffer(
29 const DeviceBufferDescriptor& desc);
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 Increment an internal frame used to cycle through a ring buffer of
48 /// allocation pools.
49 virtual void DidAcquireSurfaceFrame();
50
51 protected:
52 Allocator();
53
54 virtual std::shared_ptr<DeviceBuffer> OnCreateBuffer(
55 const DeviceBufferDescriptor& desc) = 0;
56
57 virtual std::shared_ptr<Texture> OnCreateTexture(
58 const TextureDescriptor& desc) = 0;
59
60 private:
61 Allocator(const Allocator&) = delete;
62
63 Allocator& operator=(const Allocator&) = delete;
64 };
65
66 } // namespace impeller
67
68 #endif // FLUTTER_IMPELLER_CORE_ALLOCATOR_H_
impeller::Allocator::IsValid
bool IsValid() const
impeller::Allocator::GetMaxTextureSizeSupported
virtual ISize GetMaxTextureSizeSupported() const =0
impeller::Allocator::OnCreateTexture
virtual std::shared_ptr< Texture > OnCreateTexture(const TextureDescriptor &desc)=0
impeller::DeviceBufferDescriptor
Definition: device_buffer_descriptor.h:14
texture_descriptor.h
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:63
impeller::Allocator::~Allocator
virtual ~Allocator()
impeller::Allocator::CreateTexture
std::shared_ptr< Texture > CreateTexture(const TextureDescriptor &desc)
Definition: allocator.cc:49
impeller::PixelFormat
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition: formats.h:94
impeller::TSize< int64_t >
impeller::Allocator::CreateBuffer
std::shared_ptr< DeviceBuffer > CreateBuffer(const DeviceBufferDescriptor &desc)
Definition: allocator.cc:44
impeller::Allocator
An object that allocates device memory.
Definition: allocator.h:22
impeller::Allocator::CreateBufferWithCopy
std::shared_ptr< DeviceBuffer > CreateBufferWithCopy(const uint8_t *buffer, size_t length)
Definition: allocator.cc:18
impeller::Allocator::Allocator
Allocator()
texture.h
device_buffer_descriptor.h
impeller::TextureDescriptor
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
Definition: texture_descriptor.h:37
impeller::Allocator::DidAcquireSurfaceFrame
virtual void DidAcquireSurfaceFrame()
Increment an internal frame used to cycle through a ring buffer of allocation pools.
Definition: allocator.cc:61
impeller
Definition: aiks_context.cc:10
size.h
impeller::Allocator::OnCreateBuffer
virtual std::shared_ptr< DeviceBuffer > OnCreateBuffer(const DeviceBufferDescriptor &desc)=0