Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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#ifndef FLUTTER_IMPELLER_BASE_ALLOCATION_H_
6#define FLUTTER_IMPELLER_BASE_ALLOCATION_H_
7
8#include <cstdint>
9#include <memory>
10
11#include "flutter/fml/mapping.h"
12
13namespace impeller {
14
16 public:
18
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 Allocation(const Allocation&) = delete;
41
42 Allocation& operator=(const Allocation&) = delete;
43};
44
45std::shared_ptr<fml::Mapping> CreateMappingWithCopy(const uint8_t* contents,
46 size_t length);
47
48std::shared_ptr<fml::Mapping> CreateMappingFromAllocation(
49 const std::shared_ptr<Allocation>& allocation);
50
51std::shared_ptr<fml::Mapping> CreateMappingWithString(
52 std::shared_ptr<const std::string> string);
53
54std::shared_ptr<fml::Mapping> CreateMappingWithString(std::string string);
55
56} // namespace impeller
57
58#endif // FLUTTER_IMPELLER_BASE_ALLOCATION_H_
uint8_t * GetBuffer() const
Definition allocation.cc:20
size_t GetReservedLength() const
Definition allocation.cc:28
size_t GetLength() const
Definition allocation.cc:24
bool Truncate(size_t length, bool npot=true)
Definition allocation.cc:32
static uint32_t NextPowerOfTwoSize(uint32_t x)
Definition allocation.cc:41
size_t length
double x
std::shared_ptr< fml::Mapping > CreateMappingWithCopy(const uint8_t *contents, size_t length)
Definition allocation.cc:83
std::shared_ptr< fml::Mapping > CreateMappingWithString(std::string string)
std::shared_ptr< fml::Mapping > CreateMappingFromAllocation(const std::shared_ptr< Allocation > &allocation)
Definition allocation.cc:99