| Flutter Impeller |

allocation.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 <limits>
8 #include <memory>
9
10 #include "flutter/fml/macros.h"
11 #include "flutter/fml/mapping.h"
12
13 namespace impeller {
14
15 class Allocation {
16 public:
17 Allocation();
18
19 ~Allocation();
20
21 uint8_t* GetBuffer() const;
22
23 size_t GetLength() const;
24
25 size_t GetReservedLength() const;
26
27 [[nodiscard]] bool Truncate(size_t length, bool npot = true);
28
29 static uint32_t NextPowerOfTwoSize(uint32_t x);
30
31 private:
32 uint8_t* buffer_ = nullptr;
33 size_t length_ = 0;
34 size_t reserved_ = 0;
35
36 [[nodiscard]] bool Reserve(size_t reserved);
37
38 [[nodiscard]] bool ReserveNPOT(size_t reserved);
39
40 FML_DISALLOW_COPY_AND_ASSIGN(Allocation);
41 };
42
43 std::shared_ptr<fml::Mapping> CreateMappingWithCopy(const uint8_t* contents,
44 size_t length);
45
46 std::shared_ptr<fml::Mapping> CreateMappingFromAllocation(
47 const std::shared_ptr<Allocation>& allocation);
48
49 std::shared_ptr<fml::Mapping> CreateMappingWithString(
50 std::shared_ptr<const std::string> string);
51
52 std::shared_ptr<fml::Mapping> CreateMappingWithString(std::string string);
53
54 } // namespace impeller
impeller::Allocation::~Allocation
~Allocation()
Definition: allocation.cc:17
impeller::Allocation::NextPowerOfTwoSize
static uint32_t NextPowerOfTwoSize(uint32_t x)
Definition: allocation.cc:42
impeller::CreateMappingFromAllocation
std::shared_ptr< fml::Mapping > CreateMappingFromAllocation(const std::shared_ptr< Allocation > &allocation)
Definition: allocation.cc:100
impeller::Allocation::Allocation
Allocation()
impeller::Allocation::GetReservedLength
size_t GetReservedLength() const
Definition: allocation.cc:29
impeller::Allocation::GetLength
size_t GetLength() const
Definition: allocation.cc:25
impeller::Allocation::GetBuffer
uint8_t * GetBuffer() const
Definition: allocation.cc:21
impeller::Allocation
Definition: allocation.h:15
impeller::CreateMappingWithString
std::shared_ptr< fml::Mapping > CreateMappingWithString(std::string string)
Definition: allocation.cc:112
impeller::CreateMappingWithCopy
std::shared_ptr< fml::Mapping > CreateMappingWithCopy(const uint8_t *contents, size_t length)
Definition: allocation.cc:84
impeller
Definition: aiks_context.cc:10
impeller::Allocation::Truncate
bool Truncate(size_t length, bool npot=true)
Definition: allocation.cc:33