| 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
5 #include "impeller/renderer/backend/gles/sampler_library_gles.h"
6
7 #include "impeller/base/config.h"
8 #include "impeller/base/validation.h"
9 #include "impeller/core/formats.h"
10 #include "impeller/core/sampler_descriptor.h"
11 #include "impeller/renderer/backend/gles/sampler_gles.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|
20 SamplerLibraryGLES::~SamplerLibraryGLES() = default;
21
22 // |SamplerLibrary|
23 raw_ptr<const Sampler> SamplerLibraryGLES::GetSampler(
24 const SamplerDescriptor& descriptor) {
25 if (!supports_decal_sampler_address_mode_ &&
26 (descriptor.width_address_mode == SamplerAddressMode::kDecal ||
27 descriptor.height_address_mode == SamplerAddressMode::kDecal ||
28 descriptor.depth_address_mode == SamplerAddressMode::kDecal)) {
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
config.h
impeller::SamplerLibraryGLES::~SamplerLibraryGLES
~SamplerLibraryGLES() override
impeller::raw_ptr
A wrapper around a raw ptr that adds additional unopt mode only checks.
Definition: raw_ptr.h:15
formats.h
value
int32_t value
Definition: dl_golden_unittests.cc:459
impeller
Definition: allocation.cc:12
impeller::SamplerAddressMode::kDecal
@ kDecal
decal sampling mode is only supported on devices that pass the Capabilities.SupportsDecalSamplerAddre...
sampler_descriptor.h
sampler_gles.h
sampler_library_gles.h
impeller::SamplerDescriptor
Definition: sampler_descriptor.h:14
impeller::SamplerDescriptor::depth_address_mode
SamplerAddressMode depth_address_mode
Definition: sampler_descriptor.h:21
impeller::SamplerDescriptor::width_address_mode
SamplerAddressMode width_address_mode
Definition: sampler_descriptor.h:19
impeller::SamplerDescriptor::height_address_mode
SamplerAddressMode height_address_mode
Definition: sampler_descriptor.h:20
impeller::SamplerDescriptor::ToKey
static uint64_t ToKey(const SamplerDescriptor &d)
Definition: sampler_descriptor.h:32
validation.h
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:91