Flutter Impeller
impeller::SamplerGLES Class Referencefinal

#include <sampler_gles.h>

Inheritance diagram for impeller::SamplerGLES:
impeller::Sampler impeller::BackendCast< SamplerGLES, Sampler >

Public Member Functions

 ~SamplerGLES ()
 
bool ConfigureBoundTexture (const TextureGLES &texture, const ProcTableGLES &gl) const
 
- Public Member Functions inherited from impeller::Sampler
virtual ~Sampler ()
 
const SamplerDescriptorGetDescriptor () const
 

Friends

class SamplerLibraryGLES
 

Additional Inherited Members

- Static Public Member Functions inherited from impeller::BackendCast< SamplerGLES, Sampler >
static SamplerGLESCast (Sampler &base)
 
static const SamplerGLESCast (const Sampler &base)
 
static SamplerGLESCast (Sampler *base)
 
static const SamplerGLESCast (const Sampler *base)
 
- Protected Member Functions inherited from impeller::Sampler
 Sampler (const SamplerDescriptor &desc)
 
- Protected Attributes inherited from impeller::Sampler
SamplerDescriptor desc_
 

Detailed Description

Definition at line 17 of file sampler_gles.h.

Constructor & Destructor Documentation

◆ ~SamplerGLES()

impeller::SamplerGLES::~SamplerGLES ( )
default

Member Function Documentation

◆ ConfigureBoundTexture()

bool impeller::SamplerGLES::ConfigureBoundTexture ( const TextureGLES texture,
const ProcTableGLES gl 
) const

Definition at line 71 of file sampler_gles.cc.

72  {
73  if (texture.NeedsMipmapGeneration()) {
75  << "Texture mip count is > 1, but the mipmap has not been generated. "
76  "Texture can not be sampled safely.";
77  return false;
78  }
79 
80  auto target = ToTextureTarget(texture.GetTextureDescriptor().type);
81 
82  if (!target.has_value()) {
83  return false;
84  }
85  const SamplerDescriptor& desc = GetDescriptor();
86 
87  GLint mag_filter = ToParam(desc.mag_filter);
88 
89  // If the texture doesn't have mipmaps, we can't use mip filtering.
90  GLint min_filter;
91  if (texture.GetTextureDescriptor().mip_count > 1) {
92  min_filter = ToParam(desc.min_filter, desc.mip_filter);
93  } else {
94  min_filter = ToParam(desc.min_filter);
95  }
96 
97  gl.TexParameteri(*target, GL_TEXTURE_MIN_FILTER, min_filter);
98  gl.TexParameteri(*target, GL_TEXTURE_MAG_FILTER, mag_filter);
99 
100  const auto supports_decal_mode =
101  gl.GetCapabilities()->SupportsDecalSamplerAddressMode();
102 
103  const auto wrap_s =
104  ToAddressMode(desc.width_address_mode, supports_decal_mode);
105  const auto wrap_t =
106  ToAddressMode(desc.height_address_mode, supports_decal_mode);
107 
108  gl.TexParameteri(*target, GL_TEXTURE_WRAP_S, wrap_s);
109  gl.TexParameteri(*target, GL_TEXTURE_WRAP_T, wrap_t);
110 
111  if (wrap_s == IMPELLER_GL_CLAMP_TO_BORDER ||
112  wrap_t == IMPELLER_GL_CLAMP_TO_BORDER) {
113  // Transparent black.
114  const GLfloat border_color[4] = {0.0f, 0.0f, 0.0f, 0.0f};
115  gl.TexParameterfv(*target, IMPELLER_GL_TEXTURE_BORDER_COLOR, border_color);
116  }
117 
118  return true;
119 }
const SamplerDescriptor & GetDescriptor() const
Definition: sampler.cc:13
static GLint ToAddressMode(SamplerAddressMode mode, bool supports_decal_sampler_address_mode)
Definition: sampler_gles.cc:52
static GLint ToParam(MinMagFilter minmag_filter)
Definition: sampler_gles.cc:20
constexpr std::optional< GLenum > ToTextureTarget(TextureType type)
Definition: formats_gles.h:185
#define IMPELLER_GL_TEXTURE_BORDER_COLOR
Definition: gles.h:13
#define IMPELLER_GL_CLAMP_TO_BORDER
Definition: gles.h:12
#define VALIDATION_LOG
Definition: validation.h:91

References impeller::ProcTableGLES::GetCapabilities(), impeller::Texture::GetTextureDescriptor(), impeller::SamplerDescriptor::height_address_mode, IMPELLER_GL_CLAMP_TO_BORDER, IMPELLER_GL_TEXTURE_BORDER_COLOR, impeller::SamplerDescriptor::mag_filter, impeller::SamplerDescriptor::min_filter, impeller::TextureDescriptor::mip_count, impeller::SamplerDescriptor::mip_filter, impeller::Texture::NeedsMipmapGeneration(), impeller::ToAddressMode(), impeller::ToParam(), impeller::ToTextureTarget(), impeller::TextureDescriptor::type, VALIDATION_LOG, and impeller::SamplerDescriptor::width_address_mode.

Friends And Related Function Documentation

◆ SamplerLibraryGLES

friend class SamplerLibraryGLES
friend

Definition at line 26 of file sampler_gles.h.


The documentation for this class was generated from the following files: