| 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 #pragma once
6
7 #include <string>
8
9 #include "flutter/fml/macros.h"
10 #include "flutter/fml/mapping.h"
11 #include "impeller/core/device_buffer_descriptor.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 class Texture;
21
22 //------------------------------------------------------------------------------
23 /// @brief An object that allocates device memory.
24 ///
25 class Allocator {
26 public:
27 virtual ~Allocator();
28
29 bool IsValid() const;
30
31 std::shared_ptr<DeviceBuffer> CreateBuffer(
32 const DeviceBufferDescriptor& desc);
33
34 std::shared_ptr<Texture> CreateTexture(const TextureDescriptor& desc);
35
36 //------------------------------------------------------------------------------
37 /// @brief Minimum value for `row_bytes` on a Texture. The row
38 /// bytes parameter of that method must be aligned to this value.
39 ///
40 virtual uint16_t MinimumBytesPerRow(PixelFormat format) const;
41
42 std::shared_ptr<DeviceBuffer> CreateBufferWithCopy(const uint8_t* buffer,
43 size_t length);
44
45 std::shared_ptr<DeviceBuffer> CreateBufferWithCopy(
46 const fml::Mapping& mapping);
47
48 virtual ISize GetMaxTextureSizeSupported() const = 0;
49
50 /// @brief Increment an internal frame used to cycle through a ring buffer of
51 /// allocation pools.
52 virtual void DidAcquireSurfaceFrame();
53
54 protected:
55 Allocator();
56
57 virtual std::shared_ptr<DeviceBuffer> OnCreateBuffer(
58 const DeviceBufferDescriptor& desc) = 0;
59
60 virtual std::shared_ptr<Texture> OnCreateTexture(
61 const TextureDescriptor& desc) = 0;
62
63 private:
64 FML_DISALLOW_COPY_AND_ASSIGN(Allocator);
65 };
66
67 } // namespace impeller
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:13
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::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:25
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:39
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::PixelFormat
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition: formats.h:94
impeller
Definition: aiks_context.cc:10
size.h
impeller::Allocator::OnCreateBuffer
virtual std::shared_ptr< DeviceBuffer > OnCreateBuffer(const DeviceBufferDescriptor &desc)=0