Flutter Impeller
sampler_library_gles.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
6 
7 #include "impeller/base/config.h"
12 
13 namespace impeller {
14 
15 SamplerLibraryGLES::SamplerLibraryGLES(bool supports_decal_sampler_address_mode)
16  : supports_decal_sampler_address_mode_(
17  supports_decal_sampler_address_mode) {}
18 
19 // |SamplerLibrary|
21 
22 // |SamplerLibrary|
23 raw_ptr<const Sampler> SamplerLibraryGLES::GetSampler(
24  const SamplerDescriptor& descriptor) {
25  if (!supports_decal_sampler_address_mode_ &&
29  VALIDATION_LOG << "SamplerAddressMode::kDecal is not supported by the "
30  "current OpenGLES backend.";
31  return raw_ptr<const Sampler>{nullptr};
32  }
33  uint64_t p_key = SamplerDescriptor::ToKey(descriptor);
34  for (const auto& [key, value] : samplers_) {
35  if (key == p_key) {
36  return raw_ptr(value);
37  }
38  }
39 
40  // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
41  auto sampler = std::unique_ptr<SamplerGLES>(new SamplerGLES(descriptor));
42  samplers_.push_back(std::make_pair(p_key, std::move(sampler)));
43 
44  return raw_ptr(samplers_.back().second);
45 }
46 
47 } // namespace impeller
A wrapper around a raw ptr that adds additional unopt mode only checks.
Definition: raw_ptr.h:15
int32_t value
@ kDecal
decal sampling mode is only supported on devices that pass the Capabilities.SupportsDecalSamplerAddre...
SamplerAddressMode depth_address_mode
SamplerAddressMode width_address_mode
SamplerAddressMode height_address_mode
static uint64_t ToKey(const SamplerDescriptor &d)
#define VALIDATION_LOG
Definition: validation.h:91