| 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 18 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 75 of file sampler_gles.cc.

76 {
77 if (!IsValid()) {
78 return false;
79 }
80
81 if (texture.NeedsMipmapGeneration()) {
82 VALIDATION_LOG
83 << "Texture mip count is > 1, but the mipmap has not been generated. "
84 "Texture can not be sampled safely.";
85 return false;
86 }
87
88 auto target = ToTextureTarget(texture.GetTextureDescriptor().type);
89
90 if (!target.has_value()) {
91 return false;
92 }
93 const auto& desc = GetDescriptor();
94
95 std::optional<MipFilter> mip_filter = std::nullopt;
96 if (texture.GetTextureDescriptor().mip_count > 1) {
97 mip_filter = desc.mip_filter;
98 }
99
100 gl.TexParameteri(*target, GL_TEXTURE_MIN_FILTER,
101 ToParam(desc.min_filter, mip_filter));
102 gl.TexParameteri(*target, GL_TEXTURE_MAG_FILTER, ToParam(desc.mag_filter));
103
104 const auto supports_decal_mode =
105 gl.GetCapabilities()->SupportsDecalSamplerAddressMode();
106
107 const auto wrap_s =
108 ToAddressMode(desc.width_address_mode, supports_decal_mode);
109 const auto wrap_t =
110 ToAddressMode(desc.height_address_mode, supports_decal_mode);
111
112 gl.TexParameteri(*target, GL_TEXTURE_WRAP_S, wrap_s);
113 gl.TexParameteri(*target, GL_TEXTURE_WRAP_T, wrap_t);
114
115 if (wrap_s == IMPELLER_GL_CLAMP_TO_BORDER ||
116 wrap_t == IMPELLER_GL_CLAMP_TO_BORDER) {
117 // Transparent black.
118 const GLfloat border_color[4] = {0.0f, 0.0f, 0.0f, 0.0f};
119 gl.TexParameterfv(*target, IMPELLER_GL_TEXTURE_BORDER_COLOR, border_color);
120 }
121
122 return true;
123 }

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 27 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::ToAddressMode
static GLint ToAddressMode(SamplerAddressMode mode, bool supports_decal_sampler_address_mode)
Definition: sampler_gles.cc:56
IMPELLER_GL_TEXTURE_BORDER_COLOR
#define IMPELLER_GL_TEXTURE_BORDER_COLOR
Definition: gles.h:13
impeller::ToParam
static constexpr int ToParam(size_t index)
Definition: archive_statement.cc:77
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:67
impeller::Sampler::GetDescriptor
const SamplerDescriptor & GetDescriptor() const
Definition: sampler.cc:13
impeller::ToTextureTarget
constexpr std::optional< GLenum > ToTextureTarget(TextureType type)
Definition: formats_gles.h:184
IMPELLER_GL_CLAMP_TO_BORDER
#define IMPELLER_GL_CLAMP_TO_BORDER
Definition: gles.h:12