Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
texture_descriptor.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_TEXTURE_DESCRIPTOR_H_
6#define FLUTTER_IMPELLER_CORE_TEXTURE_DESCRIPTOR_H_
7
8#include <cstdint>
11
12namespace impeller {
13
14//------------------------------------------------------------------------------
15/// @brief Additional compression to apply to a texture. This value is
16/// ignored on platforms which do not support it.
17///
18/// Lossy compression is only supported on iOS 15+ on A15 chips.
19enum class CompressionType {
21 kLossy,
22};
23
25 switch (type) {
27 return "Lossless";
29 return "Lossy";
30 }
32}
33
34//------------------------------------------------------------------------------
35/// @brief A lightweight object that describes the attributes of a texture
36/// that can then used an allocator to create that texture.
37///
43 size_t mip_count = 1u; // Size::MipCount is usually appropriate.
47
48 /// @brief The number of bytes required to store an image of the given texel
49 /// dimensions in this format. Block-compressed formats round the
50 /// dimensions up to whole blocks.
51 constexpr size_t GetByteSizeForDimensions(int64_t width,
52 int64_t height) const {
54 }
55
56 constexpr size_t GetByteSizeOfBaseMipLevel() const {
57 if (!IsValid()) {
58 return 0u;
59 }
61 }
62
63 constexpr size_t GetByteSizeOfAllMipLevels() const {
64 if (!IsValid()) {
65 return 0u;
66 }
67 size_t result = 0u;
68 int64_t width = size.width;
69 int64_t height = size.height;
70 for (auto i = 0u; i < mip_count; i++) {
72 width /= 2;
73 height /= 2;
74 }
75 return result;
76 }
77
78 constexpr size_t GetBytesPerRow() const {
79 if (!IsValid()) {
80 return 0u;
81 }
83 }
84
85 constexpr bool SamplingOptionsAreValid() const {
86 const auto count = static_cast<uint64_t>(sample_count);
87 return IsMultisampleCapable(type) ? count > 1 : count == 1;
88 }
89
90 constexpr bool operator==(const TextureDescriptor& other) const = default;
91
92 constexpr bool IsValid() const {
93 return format != PixelFormat::kUnknown && //
94 !size.IsEmpty() && //
95 mip_count >= 1u && //
97 }
98};
99
100std::string TextureDescriptorToString(const TextureDescriptor& desc);
101
102} // namespace impeller
103
104#endif // FLUTTER_IMPELLER_CORE_TEXTURE_DESCRIPTOR_H_
#define FML_UNREACHABLE()
Definition logging.h:128
std::string TextureDescriptorToString(const TextureDescriptor &desc)
StorageMode
Specified where the allocation resides and how it is used.
Definition formats.h:32
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition formats.h:99
constexpr size_t BytesForTextureRegion(PixelFormat format, int64_t width, int64_t height)
The number of bytes required to store a width x height texel region in format. Block-compressed forma...
Definition formats.h:727
constexpr size_t BytesPerRowForTextureWidth(PixelFormat format, int64_t width)
The number of bytes in a single row of texel blocks for a texture of the given width in format.
Definition formats.h:741
CompressionType
Additional compression to apply to a texture. This value is ignored on platforms which do not support...
constexpr bool IsMultisampleCapable(TextureType type)
Definition formats.h:471
constexpr const char * CompressionTypeToString(CompressionType type)
impeller::ShaderType type
int32_t height
int32_t width
Type height
Definition size.h:29
Type width
Definition size.h:28
constexpr bool IsEmpty() const
Returns true if either of the width or height are 0, negative, or NaN.
Definition size.h:123
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
constexpr size_t GetByteSizeForDimensions(int64_t width, int64_t height) const
The number of bytes required to store an image of the given texel dimensions in this format....
constexpr size_t GetByteSizeOfBaseMipLevel() const
constexpr size_t GetBytesPerRow() const
constexpr size_t GetByteSizeOfAllMipLevels() const
constexpr bool SamplingOptionsAreValid() const
constexpr bool IsValid() const
constexpr bool operator==(const TextureDescriptor &other) const =default