Skip to content

Commit fac2aab

Browse files
committed
[Impeller] Make SamplerStateCache a class and include sampler/texture headers
- Convert `SamplerStateCache` from `struct` to `class` with private `configured_samplers_` and deleted copy operations per the Google C++ Style Guide. - Replace forward declarations of `SamplerGLES` and `TextureGLES` in `buffer_bindings_gles.h` with direct `#include`s.
1 parent 65c03ed commit fac2aab

2 files changed

Lines changed: 18 additions & 9 deletions

File tree

‎engine/src/flutter/impeller/renderer/backend/gles/buffer_bindings_gles.cc‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,14 +271,14 @@ bool SamplerStateCache::ConfigureBoundTexture(const SamplerGLES& sampler,
271271
const uint64_t sampler_key =
272272
SamplerDescriptor::ToKey(sampler.GetDescriptor());
273273
const HandleGLES& handle = texture.GetHandle();
274-
auto it = configured_samplers.find(handle);
275-
if (it != configured_samplers.end() && it->second == sampler_key) {
274+
auto it = configured_samplers_.find(handle);
275+
if (it != configured_samplers_.end() && it->second == sampler_key) {
276276
return true;
277277
}
278278
if (!sampler.ConfigureBoundTexture(texture, gl)) {
279279
return false;
280280
}
281-
configured_samplers[handle] = sampler_key;
281+
configured_samplers_[handle] = sampler_key;
282282
return true;
283283
}
284284

‎engine/src/flutter/impeller/renderer/backend/gles/buffer_bindings_gles.h‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@
1212
#include "impeller/renderer/backend/gles/gles.h"
1313
#include "impeller/renderer/backend/gles/handle_gles.h"
1414
#include "impeller/renderer/backend/gles/proc_table_gles.h"
15+
#include "impeller/renderer/backend/gles/sampler_gles.h"
16+
#include "impeller/renderer/backend/gles/texture_gles.h"
1517
#include "impeller/renderer/command.h"
1618
#include "third_party/abseil-cpp/absl/container/flat_hash_map.h"
1719

1820
namespace impeller {
1921

20-
class SamplerGLES;
21-
class TextureGLES;
22-
2322
namespace testing {
2423
FML_TEST_CLASS(BufferBindingsGLESTest, BindUniformData);
2524
FML_TEST_CLASS(BufferBindingsGLESTest, BindArrayData);
@@ -37,13 +36,23 @@ FML_TEST_CLASS(BufferBindingsGLESTest,
3736
/// @brief Caches the sampler configuration state applied to GL texture
3837
/// objects during a render pass.
3938
///
40-
struct SamplerStateCache {
41-
absl::flat_hash_map<HandleGLES, uint64_t, HandleGLES::Hash, HandleGLES::Equal>
42-
configured_samplers;
39+
class SamplerStateCache {
40+
public:
41+
SamplerStateCache() = default;
42+
43+
~SamplerStateCache() = default;
4344

4445
bool ConfigureBoundTexture(const SamplerGLES& sampler,
4546
const TextureGLES& texture,
4647
const ProcTableGLES& gl);
48+
49+
private:
50+
absl::flat_hash_map<HandleGLES, uint64_t, HandleGLES::Hash, HandleGLES::Equal>
51+
configured_samplers_;
52+
53+
SamplerStateCache(const SamplerStateCache&) = delete;
54+
55+
SamplerStateCache& operator=(const SamplerStateCache&) = delete;
4756
};
4857

4958
//------------------------------------------------------------------------------

0 commit comments

Comments
 (0)