blob: 6012203897a2bd1834cf5b04f9b0a993591ea9bb [file] [log] [blame]
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "impeller/renderer/backend/gles/sampler_library_gles.h"
#include "impeller/base/config.h"
#include "impeller/base/validation.h"
#include "impeller/core/formats.h"
#include "impeller/renderer/backend/gles/sampler_gles.h"
namespace impeller {
SamplerLibraryGLES::SamplerLibraryGLES(bool supports_decal_sampler_address_mode)
: supports_decal_sampler_address_mode_(
supports_decal_sampler_address_mode) {}
// |SamplerLibrary|
SamplerLibraryGLES::~SamplerLibraryGLES() = default;
// |SamplerLibrary|
std::shared_ptr<const Sampler> SamplerLibraryGLES::GetSampler(
SamplerDescriptor descriptor) {
if (!supports_decal_sampler_address_mode_ &&
(descriptor.width_address_mode == SamplerAddressMode::kDecal ||
descriptor.height_address_mode == SamplerAddressMode::kDecal ||
descriptor.depth_address_mode == SamplerAddressMode::kDecal)) {
VALIDATION_LOG << "SamplerAddressMode::kDecal is not supported by the "
"current OpenGLES backend.";
return nullptr;
}
auto found = samplers_.find(descriptor);
if (found != samplers_.end()) {
return found->second;
}
return samplers_[descriptor] =
std::shared_ptr<SamplerGLES>(new SamplerGLES(descriptor));
}
} // namespace impeller