1 #ifndef DALI_TEST_GRAPHICS_SAMPLER_H
2 #define DALI_TEST_GRAPHICS_SAMPLER_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 #include <dali/graphics-api/graphics-sampler-create-info.h>
21 #include <dali/graphics-api/graphics-sampler.h>
22 #include <dali/graphics-api/graphics-types.h>
23 #include <dali/integration-api/gl-defines.h>
26 #include "test-gl-abstraction.h"
31 * Maintains a cache of parameters per texture/texture target
33 class TestGraphicsSampler : public Graphics::Sampler
36 TestGraphicsSampler(TestGlAbstraction& glAbstraction, const Graphics::SamplerCreateInfo& createInfo);
39 * Apply sampler to target texture.
41 void Apply(GLuint target);
43 static void SetTexParameter(TestGlAbstraction& glAbstraction, GLuint target, GLenum pname, GLint value);
45 static GLint FilterModeToGL(Graphics::SamplerFilter filterMode);
47 static GLint FilterModeToGL(Graphics::SamplerFilter filterMode, Graphics::SamplerMipmapMode mipmapMode);
50 * @brief Convert from a WrapMode to its corresponding GL enumeration
51 * @param[in] wrapMode The wrap mode
52 * @param[in] defaultWrapMode The mode to use if WrapMode is Default
53 * @return The equivalent GL wrap mode
55 static GLint WrapModeToGL(Graphics::SamplerAddressMode wrapMode);
57 static uint32_t GetTexParamHash(TestGlAbstraction& glAbstraction, GLuint target, GLenum pname);
60 static std::map<uint32_t, GLint> mParamCache;
62 TestGlAbstraction& mGlAbstraction;
63 Graphics::SamplerCreateInfo mCreateInfo;
68 #endif //DALI_TEST_GRAPHICS_SAMPLER_H