| Flutter Impeller |

Public Member Functions | Public Attributes | List of all members
impeller::TextureDescriptor Struct Reference

A lightweight object that describes the attributes of a texture that can then used an allocator to create that texture. More...

`#include <texture_descriptor.h>`

## Public Member Functions
constexpr size_t | GetByteSizeOfBaseMipLevel () const
constexpr size_t | GetByteSizeOfAllMipLevels () const
constexpr size_t | GetBytesPerRow () const
constexpr bool | SamplingOptionsAreValid () const
constexpr bool | operator== (const TextureDescriptor &other) const =default
constexpr bool | IsValid () const

## Public Attributes
StorageMode | storage_mode = StorageMode::kDeviceTransient
TextureType | type = TextureType::kTexture2D
PixelFormat | format = PixelFormat::kUnknown
ISize | size
size_t | mip_count = 1u
TextureUsageMask | usage = TextureUsage::kShaderRead
SampleCount | sample_count = SampleCount::kCount1
CompressionType | compression_type = CompressionType::kLossless

## Detailed Description

A lightweight object that describes the attributes of a texture that can then used an allocator to create that texture.

Definition at line 38 of file texture_descriptor.h.

## Member Function Documentation

## ◆ GetByteSizeOfAllMipLevels()

constexpr size_t impeller::TextureDescriptor::GetByteSizeOfAllMipLevels | ( |  | ) | const
| inline constexpr

Definition at line 55 of file texture_descriptor.h.

55 {
56 if (!IsValid()) {
57 return 0u;
58 }
59 size_t result = 0u;
60 int64_t width = size.width;
61 int64_t height = size.height;
62 for (auto i = 0u; i < mip_count; i++) {
63 result +=
64 ISize(width, height).Area() * BytesPerPixelForPixelFormat(format);
65 width /= 2;
66 height /= 2;
67 }
68 return result;
69 }
impeller::BytesPerPixelForPixelFormat
constexpr size_t BytesPerPixelForPixelFormat(PixelFormat format)
Definition: formats.h:466
impeller::ISize
ISize64 ISize
Definition: size.h:162
impeller::TSize::Area
constexpr Type Area() const
Definition: size.h:120
impeller::TSize::height
Type height
Definition: size.h:29
impeller::TSize::width
Type width
Definition: size.h:28
impeller::TextureDescriptor::size
ISize size
Definition: texture_descriptor.h:42
impeller::TextureDescriptor::IsValid
constexpr bool IsValid() const
Definition: texture_descriptor.h:85
impeller::TextureDescriptor::mip_count
size_t mip_count
Definition: texture_descriptor.h:43
impeller::TextureDescriptor::format
PixelFormat format
Definition: texture_descriptor.h:41

References impeller::TSize< T >::Area(), impeller::BytesPerPixelForPixelFormat(), format, impeller::TSize< T >::height, IsValid(), mip_count, size, and impeller::TSize< T >::width.

## ◆ GetByteSizeOfBaseMipLevel()

constexpr size_t impeller::TextureDescriptor::GetByteSizeOfBaseMipLevel | ( |  | ) | const
| inline constexpr

Definition at line 48 of file texture_descriptor.h.

48 {
49 if (!IsValid()) {
50 return 0u;
51 }
52 return size.Area() * BytesPerPixelForPixelFormat(format);
53 }

References impeller::TSize< T >::Area(), impeller::BytesPerPixelForPixelFormat(), format, IsValid(), and size.

Referenced by ImGui_ImplImpeller_Init(), impeller::testing::TEST_P(), and impeller::TextureMTL::~TextureMTL().

## ◆ GetBytesPerRow()

constexpr size_t impeller::TextureDescriptor::GetBytesPerRow | ( |  | ) | const
| inline constexpr

Definition at line 71 of file texture_descriptor.h.

71 {
72 if (!IsValid()) {
73 return 0u;
74 }
75 return size.width * BytesPerPixelForPixelFormat(format);
76 }

References impeller::BytesPerPixelForPixelFormat(), format, IsValid(), size, and impeller::TSize< T >::width.

## ◆ IsValid()

constexpr bool impeller::TextureDescriptor::IsValid | ( |  | ) | const
| inline constexpr

Definition at line 85 of file texture_descriptor.h.

85 {
86 return format != PixelFormat::kUnknown && //
87 !size.IsEmpty() && //
88 mip_count >= 1u && //
89 SamplingOptionsAreValid();
90 }
impeller::PixelFormat::kUnknown
@ kUnknown
impeller::TSize::IsEmpty
constexpr bool IsEmpty() const
Returns true if either of the width or height are 0, negative, or NaN.
Definition: size.h:123
impeller::TextureDescriptor::SamplingOptionsAreValid
constexpr bool SamplingOptionsAreValid() const
Definition: texture_descriptor.h:78

References format, impeller::TSize< T >::IsEmpty(), impeller::kUnknown, mip_count, SamplingOptionsAreValid(), and size.

Referenced by GetByteSizeOfAllMipLevels(), GetByteSizeOfBaseMipLevel(), GetBytesPerRow(), impeller::TextureMTL::TextureMTL(), and impeller::ToMTLTextureDescriptor().

## ◆ operator==()

constexpr bool impeller::TextureDescriptor::operator== | ( | const TextureDescriptor & | other | ) | const
| constexpr default

## ◆ SamplingOptionsAreValid()

constexpr bool impeller::TextureDescriptor::SamplingOptionsAreValid | ( |  | ) | const
| inline constexpr

Definition at line 78 of file texture_descriptor.h.

78 {
79 const auto count = static_cast<uint64_t>(sample_count);
80 return IsMultisampleCapable(type) ? count > 1 : count == 1;
81 }
impeller::IsMultisampleCapable
constexpr bool IsMultisampleCapable(TextureType type)
Definition: formats.h:283
impeller::TextureDescriptor::type
TextureType type
Definition: texture_descriptor.h:40
impeller::TextureDescriptor::sample_count
SampleCount sample_count
Definition: texture_descriptor.h:45

References impeller::IsMultisampleCapable(), sample_count, and type.

Referenced by IsValid().

## Member Data Documentation

## ◆ compression_type

CompressionType impeller::TextureDescriptor::compression_type = CompressionType::kLossless

Definition at line 46 of file texture_descriptor.h.

Referenced by impeller::AllocatedTextureSourceVK::AllocatedTextureSourceVK(), impeller::RenderTargetAllocator::CreateOffscreenMSAA(), impeller::SwapchainTransientsMTL::GetResolveTexture(), impeller::interop::ImpellerTextureCreateWithContentsNew(), impeller::interop::ImpellerTextureCreateWithOpenGLTextureHandleNew(), impeller::testing::TEST(), impeller::TextureDescriptorToString(), and impeller::ToSwapchainTextureDescriptor().

## ◆ format

PixelFormat impeller::TextureDescriptor::format = PixelFormat::kUnknown

Definition at line 41 of file texture_descriptor.h.

Referenced by impeller::AllocatedTextureSourceVK::AllocatedTextureSourceVK(), impeller::ContentContext::ContentContext(), impeller::TypographerContextSkia::CreateGlyphAtlas(), impeller::CreateGradientTexture(), impeller::RenderTargetAllocator::CreateOffscreen(), impeller::RenderTargetAllocator::CreateOffscreenMSAA(), impeller::testing::CreateTestCanvas(), impeller::testing::CreateTestYUVTextures(), impeller::Playground::CreateTextureCubeForFixture(), impeller::CreateTextureForDecompressedImage(), GetByteSizeOfAllMipLevels(), GetByteSizeOfBaseMipLevel(), GetBytesPerRow(), impeller::SwapchainTransientsMTL::GetDepthStencilTexture(), impeller::SwapchainTransientsMTL::GetMSAATexture(), impeller::SwapchainTransientsMTL::GetResolveTexture(), ImGui_ImplImpeller_Init(), impeller::interop::ImpellerTextureCreateWithContentsNew(), impeller::interop::ImpellerTextureCreateWithOpenGLTextureHandleNew(), IsValid(), impeller::KHRSwapchainImageVK::KHRSwapchainImageVK(), impeller::TextureSourceVK::SetLayout(), impeller::RenderTarget::SetupDepthStencilAttachments(), impeller::testing::TEST(), impeller::TEST(), impeller::testing::TEST_P(), impeller::TextureDescriptorToString(), impeller::ToMTLTextureDescriptor(), impeller::ToSwapchainTextureDescriptor(), impeller::SurfaceGLES::WrapFBO(), impeller::SurfaceVK::WrapSwapchainImage(), impeller::WrapTextureMTL(), and impeller::WrapTextureWithRenderTarget().

## ◆ mip_count

size_t impeller::TextureDescriptor::mip_count = 1u

Definition at line 43 of file texture_descriptor.h.

Referenced by impeller::AllocatedTextureSourceVK::AllocatedTextureSourceVK(), impeller::SamplerGLES::ConfigureBoundTexture(), impeller::RenderTargetAllocator::CreateOffscreen(), impeller::RenderTargetAllocator::CreateOffscreenMSAA(), impeller::Allocator::CreateTexture(), impeller::Playground::CreateTextureCubeForFixture(), impeller::CreateTextureForDecompressedImage(), GetByteSizeOfAllMipLevels(), impeller::Texture::GetMipCount(), ImGui_ImplImpeller_Init(), impeller::interop::ImpellerTextureCreateWithContentsNew(), impeller::interop::ImpellerTextureCreateWithOpenGLTextureHandleNew(), IsValid(), impeller::KHRSwapchainImageVK::KHRSwapchainImageVK(), impeller::Texture::NeedsMipmapGeneration(), impeller::TextureSourceVK::SetLayout(), impeller::testing::TEST(), impeller::TEST(), impeller::testing::TEST_P(), impeller::TextureDescriptorToString(), impeller::ToMTLTextureDescriptor(), and impeller::ToSwapchainTextureDescriptor().

## ◆ sample_count

SampleCount impeller::TextureDescriptor::sample_count = SampleCount::kCount1

Definition at line 45 of file texture_descriptor.h.

Referenced by impeller::AllocatedTextureSourceVK::AllocatedTextureSourceVK(), impeller::RenderTargetAllocator::CreateOffscreenMSAA(), impeller::testing::CreateTestCanvas(), impeller::SwapchainTransientsMTL::GetDepthStencilTexture(), impeller::SwapchainTransientsMTL::GetMSAATexture(), impeller::SwapchainTransientsMTL::GetResolveTexture(), SamplingOptionsAreValid(), impeller::RenderTarget::SetupDepthStencilAttachments(), impeller::testing::TEST(), impeller::testing::TEST_P(), impeller::TextureDescriptorToString(), impeller::ToMTLTextureDescriptor(), impeller::ToSwapchainTextureDescriptor(), impeller::SurfaceGLES::WrapFBO(), impeller::SurfaceVK::WrapSwapchainImage(), and impeller::WrapTextureWithRenderTarget().

## ◆ size

ISize impeller::TextureDescriptor::size

Definition at line 42 of file texture_descriptor.h.

Referenced by impeller::AllocatedTextureSourceVK::AllocatedTextureSourceVK(), impeller::glvk::Trampoline::BlitTextureOpenGLToVulkan(), impeller::ContentContext::ContentContext(), impeller::TypographerContextSkia::CreateGlyphAtlas(), impeller::CreateGradientTexture(), impeller::RenderTargetAllocator::CreateOffscreen(), impeller::RenderTargetAllocator::CreateOffscreenMSAA(), impeller::testing::CreateTestCanvas(), impeller::testing::CreateTestYUVTextures(), impeller::Allocator::CreateTexture(), impeller::Playground::CreateTextureCubeForFixture(), impeller::CreateTextureForDecompressedImage(), impeller::EntityPassTarget::Flip(), GetByteSizeOfAllMipLevels(), GetByteSizeOfBaseMipLevel(), GetBytesPerRow(), impeller::SwapchainTransientsMTL::GetDepthStencilTexture(), impeller::SwapchainTransientsMTL::GetMSAATexture(), impeller::SwapchainTransientsMTL::GetResolveTexture(), impeller::TextureVK::GetSize(), ImGui_ImplImpeller_Init(), impeller::interop::ImpellerTextureCreateWithContentsNew(), impeller::interop::ImpellerTextureCreateWithOpenGLTextureHandleNew(), IsValid(), impeller::RenderTarget::SetupDepthStencilAttachments(), impeller::testing::TEST(), impeller::TEST(), impeller::testing::TEST_P(), impeller::TextureDescriptorToString(), impeller::TextureMTL::TextureMTL(), impeller::ToMTLTextureDescriptor(), impeller::ToSwapchainTextureDescriptor(), impeller::SurfaceGLES::WrapFBO(), impeller::SurfaceVK::WrapSwapchainImage(), and impeller::WrapTextureWithRenderTarget().

## ◆ storage_mode

StorageMode impeller::TextureDescriptor::storage_mode = StorageMode::kDeviceTransient

Definition at line 39 of file texture_descriptor.h.

Referenced by impeller::AllocatedTextureSourceVK::AllocatedTextureSourceVK(), impeller::ContentContext::ContentContext(), impeller::TypographerContextSkia::CreateGlyphAtlas(), impeller::CreateGradientTexture(), impeller::RenderTargetAllocator::CreateOffscreen(), impeller::RenderTargetAllocator::CreateOffscreenMSAA(), impeller::testing::CreateTestCanvas(), impeller::testing::CreateTestYUVTextures(), impeller::Playground::CreateTextureCubeForFixture(), impeller::CreateTextureForDecompressedImage(), impeller::SwapchainTransientsMTL::GetDepthStencilTexture(), impeller::SwapchainTransientsMTL::GetMSAATexture(), impeller::SwapchainTransientsMTL::GetResolveTexture(), ImGui_ImplImpeller_Init(), impeller::interop::ImpellerTextureCreateWithContentsNew(), impeller::interop::ImpellerTextureCreateWithOpenGLTextureHandleNew(), impeller::RenderTarget::SetupDepthStencilAttachments(), impeller::testing::TEST(), impeller::testing::TEST_P(), impeller::TextureDescriptorToString(), impeller::ToSwapchainTextureDescriptor(), impeller::SurfaceGLES::WrapFBO(), impeller::SurfaceVK::WrapSwapchainImage(), impeller::WrapTextureWithRenderTarget(), and impeller::TextureMTL::~TextureMTL().

## ◆ type

TextureType impeller::TextureDescriptor::type = TextureType::kTexture2D

Definition at line 40 of file texture_descriptor.h.

Referenced by impeller::AllocatedTextureSourceVK::AllocatedTextureSourceVK(), impeller::SamplerGLES::ConfigureBoundTexture(), impeller::RenderTargetAllocator::CreateOffscreenMSAA(), impeller::testing::CreateTestCanvas(), impeller::Playground::CreateTextureCubeForFixture(), impeller::TextureGLES::GenerateMipmap(), impeller::SwapchainTransientsMTL::GetDepthStencilTexture(), impeller::SwapchainTransientsMTL::GetMSAATexture(), impeller::SwapchainTransientsMTL::GetResolveTexture(), impeller::interop::ImpellerTextureCreateWithContentsNew(), impeller::interop::ImpellerTextureCreateWithOpenGLTextureHandleNew(), impeller::KHRSwapchainImageVK::KHRSwapchainImageVK(), SamplingOptionsAreValid(), impeller::TextureSourceVK::SetLayout(), impeller::RenderTarget::SetupDepthStencilAttachments(), impeller::testing::TEST(), impeller::testing::TEST_P(), impeller::TextureDescriptorToString(), impeller::ToMTLTextureDescriptor(), impeller::ToSwapchainTextureDescriptor(), impeller::SurfaceGLES::WrapFBO(), and impeller::SurfaceVK::WrapSwapchainImage().

## ◆ usage

TextureUsageMask impeller::TextureDescriptor::usage = TextureUsage::kShaderRead

Definition at line 44 of file texture_descriptor.h.

Referenced by impeller::AllocatedTextureSourceVK::AllocatedTextureSourceVK(), impeller::TypographerContextSkia::CreateGlyphAtlas(), impeller::RenderTargetAllocator::CreateOffscreen(), impeller::RenderTargetAllocator::CreateOffscreenMSAA(), impeller::testing::CreateTestCanvas(), impeller::SwapchainTransientsMTL::GetDepthStencilTexture(), impeller::SwapchainTransientsMTL::GetMSAATexture(), impeller::SwapchainTransientsMTL::GetResolveTexture(), impeller::interop::ImpellerTextureCreateWithContentsNew(), impeller::interop::ImpellerTextureCreateWithOpenGLTextureHandleNew(), impeller::RenderTarget::SetupDepthStencilAttachments(), impeller::testing::TEST(), impeller::testing::TEST_P(), impeller::ToMTLTextureDescriptor(), impeller::ToSwapchainTextureDescriptor(), impeller::SurfaceGLES::WrapFBO(), impeller::SurfaceVK::WrapSwapchainImage(), and impeller::WrapTextureWithRenderTarget().

The documentation for this struct was generated from the following file:

- impeller/core/texture_descriptor.h