Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
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 70 of file sampler_gles.cc.

71 {
72 auto target = ToTextureTarget(texture.GetTextureDescriptor().type);
73
74 if (!target.has_value()) {
75 return false;
76 }
77 const SamplerDescriptor& desc = GetDescriptor();
78
79 GLint mag_filter = ToParam(desc.mag_filter);
80
81 // If the texture doesn't have mipmaps, we can't use mip filtering.
82 GLint min_filter;
83 if (texture.GetTextureDescriptor().mip_count > 1) {
84 min_filter = ToParam(desc.min_filter, desc.mip_filter);
85 } else {
86 min_filter = ToParam(desc.min_filter);
87 }
88
89 gl.TexParameteri(*target, GL_TEXTURE_MIN_FILTER, min_filter);
90 gl.TexParameteri(*target, GL_TEXTURE_MAG_FILTER, mag_filter);
91
92 // Bound the sampled mip range to the levels the texture declares. GLES leaves
93 // GL_TEXTURE_MAX_LEVEL at its default of 1000, so a texture sampled with a
94 // mipmap filter reads as black unless every level down to 1x1 is defined.
95 // Metal and Vulkan allocate exactly mip_count levels, and clamping here gives
96 // the same behavior for a partial, manually uploaded mip chain. The parameter
97 // is unavailable on ES 2.0 without GL_APPLE_texture_max_level, and external
98 // textures have no mip levels, so it is skipped in those cases.
99 if (*target != GL_TEXTURE_EXTERNAL_OES &&
100 gl.GetCapabilities()->SupportsTextureMaxLevel()) {
101 const GLint max_level =
102 static_cast<GLint>(texture.GetTextureDescriptor().mip_count) - 1;
103 gl.TexParameteri(*target, GL_TEXTURE_MAX_LEVEL, max_level);
104 }
105
106 const auto supports_decal_mode =
107 gl.GetCapabilities()->SupportsDecalSamplerAddressMode();
108
109 const auto wrap_s =
110 ToAddressMode(desc.width_address_mode, supports_decal_mode);
111 const auto wrap_t =
112 ToAddressMode(desc.height_address_mode, supports_decal_mode);
113
114 gl.TexParameteri(*target, GL_TEXTURE_WRAP_S, wrap_s);
115 gl.TexParameteri(*target, GL_TEXTURE_WRAP_T, wrap_t);
116
117 if (wrap_s == IMPELLER_GL_CLAMP_TO_BORDER ||
118 wrap_t == IMPELLER_GL_CLAMP_TO_BORDER) {
119 // Transparent black.
120 const GLfloat border_color[4] = {0.0f, 0.0f, 0.0f, 0.0f};
121 gl.TexParameterfv(*target, IMPELLER_GL_TEXTURE_BORDER_COLOR, border_color);
122 }
123
124 return true;
125}
const SamplerDescriptor & GetDescriptor() const
Definition sampler.cc:13
uint32_t * target
FlTexture * texture
constexpr std::optional< GLenum > ToTextureTarget(TextureType type)
static GLint ToAddressMode(SamplerAddressMode mode, bool supports_decal_sampler_address_mode)
static GLint ToParam(MinMagFilter minmag_filter)
#define IMPELLER_GL_TEXTURE_BORDER_COLOR
Definition gles.h:13
#define IMPELLER_GL_CLAMP_TO_BORDER
Definition gles.h:12

References impeller::ProcTableGLES::GetCapabilities(), impeller::SamplerDescriptor::height_address_mode, IMPELLER_GL_CLAMP_TO_BORDER, IMPELLER_GL_TEXTURE_BORDER_COLOR, impeller::SamplerDescriptor::mag_filter, impeller::SamplerDescriptor::min_filter, impeller::SamplerDescriptor::mip_filter, target, texture, impeller::ToAddressMode(), impeller::ToParam(), impeller::ToTextureTarget(), and impeller::SamplerDescriptor::width_address_mode.

Friends And Related Symbol 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: