| Flutter Impeller |

Public Member Functions | Friends | List of all members
impeller::SamplerGLES Class Referencefinal

`#include <sampler_gles.h>`

Inheritance diagram for impeller::SamplerGLES:

## Public Member Functions
| ~SamplerGLES ()
bool | ConfigureBoundTexture (const TextureGLES &texture, const ProcTableGLES &gl) const
Public Member Functions inherited from impeller::Sampler
virtual | ~Sampler ()
const SamplerDescriptor & | GetDescriptor () const

## Friends
class | SamplerLibraryGLES

## Additional Inherited Members
Static Public Member Functions inherited from impeller::BackendCast< SamplerGLES, Sampler >
static SamplerGLES & | Cast (Sampler &base)
static const SamplerGLES & | Cast (const Sampler &base)
static SamplerGLES * | Cast (Sampler *base)
static const SamplerGLES * | Cast (const Sampler *base)
Protected Member Functions inherited from impeller::Sampler
| Sampler (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 if (texture.NeedsMipmapGeneration()) {
73 VALIDATION_LOG
74 << "Texture mip count is > 1, but the mipmap has not been generated. "
75 "Texture can not be sampled safely.";
76 return false;
77 }
78
79 auto target = ToTextureTarget(texture.GetTextureDescriptor().type);
80
81 if (!target.has_value()) {
82 return false;
83 }
84 const auto& desc = GetDescriptor();
85
86 GLint mag_filter = ToParam(desc.mag_filter);
87
88 // If the texture doesn't have mipmaps, we can't use mip filtering.
89 GLint min_filter;
90 if (texture.GetTextureDescriptor().mip_count > 1) {
91 min_filter = ToParam(desc.min_filter, desc.mip_filter);
92 } else {
93 min_filter = ToParam(desc.min_filter);
94 }
95
96 gl.TexParameteri(*target, GL_TEXTURE_MIN_FILTER, min_filter);
97 gl.TexParameteri(*target, GL_TEXTURE_MAG_FILTER, mag_filter);
98
99 const auto supports_decal_mode =
100 gl.GetCapabilities()->SupportsDecalSamplerAddressMode();
101
102 const auto wrap_s =
103 ToAddressMode(desc.width_address_mode, supports_decal_mode);
104 const auto wrap_t =
105 ToAddressMode(desc.height_address_mode, supports_decal_mode);
106
107 gl.TexParameteri(*target, GL_TEXTURE_WRAP_S, wrap_s);
108 gl.TexParameteri(*target, GL_TEXTURE_WRAP_T, wrap_t);
109
110 if (wrap_s == IMPELLER_GL_CLAMP_TO_BORDER ||
111 wrap_t == IMPELLER_GL_CLAMP_TO_BORDER) {
112 // Transparent black.
113 const GLfloat border_color[4] = {0.0f, 0.0f, 0.0f, 0.0f};
114 gl.TexParameterfv(*target, IMPELLER_GL_TEXTURE_BORDER_COLOR, border_color);
115 }
116
117 return true;
118 }

References impeller::ProcTableGLES::GetCapabilities(), impeller::Sampler::GetDescriptor(), impeller::Texture::GetTextureDescriptor(), IMPELLER_GL_CLAMP_TO_BORDER, IMPELLER_GL_TEXTURE_BORDER_COLOR, impeller::TextureDescriptor::mip_count, impeller::Texture::NeedsMipmapGeneration(), impeller::ToAddressMode(), impeller::ToParam(), impeller::ToTextureTarget(), impeller::TextureDescriptor::type, and VALIDATION_LOG.

## 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:

- impeller/renderer/backend/gles/sampler_gles.h
- impeller/renderer/backend/gles/sampler_gles.cc

impeller::ToParam
static GLint ToParam(MinMagFilter minmag_filter)
Definition: sampler_gles.cc:19
impeller::ToAddressMode
static GLint ToAddressMode(SamplerAddressMode mode, bool supports_decal_sampler_address_mode)
Definition: sampler_gles.cc:51
IMPELLER_GL_TEXTURE_BORDER_COLOR
#define IMPELLER_GL_TEXTURE_BORDER_COLOR
Definition: gles.h:13
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:91
impeller::Sampler::GetDescriptor
const SamplerDescriptor & GetDescriptor() const
Definition: sampler.cc:13
impeller::ToTextureTarget
constexpr std::optional< GLenum > ToTextureTarget(TextureType type)
Definition: formats_gles.h:185
IMPELLER_GL_CLAMP_TO_BORDER
#define IMPELLER_GL_CLAMP_TO_BORDER
Definition: gles.h:12