Flutter Engine
The Flutter Engine
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
10
11namespace impeller {
12
13//------------------------------------------------------------------------------
14/// @brief Additional compression to apply to a texture. This value is
15/// ignored on platforms which do not support it.
16///
17/// Lossy compression is only supported on iOS 15+ on A15 chips.
18enum class CompressionType {
20 kLossy,
21};
22
24 switch (type) {
26 return "Lossless";
28 return "Lossy";
29 }
31}
32
33//------------------------------------------------------------------------------
34/// @brief A lightweight object that describes the attributes of a texture
35/// that can then used an allocator to create that texture.
36///
42 size_t mip_count = 1u; // Size::MipCount is usually appropriate.
46
47 constexpr size_t GetByteSizeOfBaseMipLevel() const {
48 if (!IsValid()) {
49 return 0u;
50 }
52 }
53
54 constexpr size_t GetBytesPerRow() const {
55 if (!IsValid()) {
56 return 0u;
57 }
59 }
60
61 constexpr bool SamplingOptionsAreValid() const {
62 const auto count = static_cast<uint64_t>(sample_count);
63 return IsMultisampleCapable(type) ? count > 1 : count == 1;
64 }
65
66 constexpr bool operator==(const TextureDescriptor& other) const {
67 return size == other.size && //
68 storage_mode == other.storage_mode && //
69 format == other.format && //
70 usage == other.usage && //
71 sample_count == other.sample_count && //
72 type == other.type && //
74 mip_count == other.mip_count;
75 }
76
77 constexpr bool operator!=(const TextureDescriptor& other) const {
78 return !(*this == other);
79 }
80
81 constexpr bool IsValid() const {
82 return format != PixelFormat::kUnknown && //
83 !size.IsEmpty() && //
84 mip_count >= 1u && //
86 }
87};
88
89std::string TextureDescriptorToString(const TextureDescriptor& desc);
90
91} // namespace impeller
92
93#endif // FLUTTER_IMPELLER_CORE_TEXTURE_DESCRIPTOR_H_
int count
#define FML_UNREACHABLE()
Definition logging.h:109
constexpr size_t BytesPerPixelForPixelFormat(PixelFormat format)
Definition formats.h:448
std::string TextureDescriptorToString(const TextureDescriptor &desc)
StorageMode
Specified where the allocation resides and how it is used.
Definition formats.h:33
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition formats.h:100
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:284
constexpr const char * CompressionTypeToString(CompressionType type)
constexpr Type Area() const
Definition size.h:102
Type width
Definition size.h:22
constexpr bool IsEmpty() const
Returns true if either of the width or height are 0, negative, or NaN.
Definition size.h:105
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
constexpr size_t GetByteSizeOfBaseMipLevel() const
constexpr size_t GetBytesPerRow() const
constexpr bool SamplingOptionsAreValid() const
constexpr bool operator==(const TextureDescriptor &other) const
constexpr bool IsValid() const
constexpr bool operator!=(const TextureDescriptor &other) const