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

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

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:50
IMPELLER_GL_TEXTURE_BORDER_COLOR
#define IMPELLER_GL_TEXTURE_BORDER_COLOR
Definition: gles.h:13
impeller::ToParam
static GLint ToParam(MinMagFilter minmag_filter, std::optional< MipFilter > mip_filter=std::nullopt)
Definition: sampler_gles.cc:19
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:73
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