Flutter Impeller
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
 
constexpr bool operator!= (const TextureDescriptor &other) const
 
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
inlineconstexpr

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  }
constexpr size_t BytesPerPixelForPixelFormat(PixelFormat format)
Definition: formats.h:466
ISize64 ISize
Definition: size.h:162
constexpr Type Area() const
Definition: size.h:120
Type height
Definition: size.h:29
Type width
Definition: size.h:28
constexpr bool IsValid() const

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
inlineconstexpr

◆ GetBytesPerRow()

constexpr size_t impeller::TextureDescriptor::GetBytesPerRow ( ) const
inlineconstexpr

Definition at line 71 of file texture_descriptor.h.

71  {
72  if (!IsValid()) {
73  return 0u;
74  }
76  }

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

◆ IsValid()

constexpr bool impeller::TextureDescriptor::IsValid ( ) const
inlineconstexpr

Definition at line 98 of file texture_descriptor.h.

98  {
99  return format != PixelFormat::kUnknown && //
100  !size.IsEmpty() && //
101  mip_count >= 1u && //
103  }
constexpr bool IsEmpty() const
Returns true if either of the width or height are 0, negative, or NaN.
Definition: size.h:123
constexpr bool SamplingOptionsAreValid() const

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
inlineconstexpr

Definition at line 94 of file texture_descriptor.h.

94  {
95  return !(*this == other);
96  }

◆ operator==()

constexpr bool impeller::TextureDescriptor::operator== ( const TextureDescriptor other) const
inlineconstexpr

Definition at line 83 of file texture_descriptor.h.

83  {
84  return size == other.size && //
85  storage_mode == other.storage_mode && //
86  format == other.format && //
87  usage == other.usage && //
88  sample_count == other.sample_count && //
89  type == other.type && //
90  compression_type == other.compression_type && //
91  mip_count == other.mip_count;
92  }

References compression_type, format, mip_count, sample_count, size, storage_mode, type, and usage.

◆ SamplingOptionsAreValid()

constexpr bool impeller::TextureDescriptor::SamplingOptionsAreValid ( ) const
inlineconstexpr

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  }
constexpr bool IsMultisampleCapable(TextureType type)
Definition: formats.h:283

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

Referenced by IsValid().

Member Data Documentation

◆ compression_type

◆ format

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

◆ mip_count

◆ sample_count

◆ 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(), operator==(), impeller::RenderTarget::SetupDepthStencilAttachments(), impeller::testing::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

◆ type

◆ usage


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