Merge "Add parameter (bool immediate) to TextChanged signal in interface" into devel...
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / test-graphics-sampler.h
1 #ifndef DALI_TEST_GRAPHICS_SAMPLER_H
2 #define DALI_TEST_GRAPHICS_SAMPLER_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  */
19
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>
24 #include <cstdint>
25 #include <map>
26 #include "test-gl-abstraction.h"
27
28 namespace Dali
29 {
30 /**
31  * Maintains a cache of parameters per texture/texture target
32  */
33 class TestGraphicsSampler : public Graphics::Sampler
34 {
35 public:
36   TestGraphicsSampler(TestGlAbstraction& glAbstraction, const Graphics::SamplerCreateInfo& createInfo);
37
38   /**
39    * Apply sampler to target texture.
40    */
41   void Apply(GLuint target);
42
43   static void SetTexParameter(TestGlAbstraction& glAbstraction, GLuint target, GLenum pname, GLint value);
44
45   static GLint FilterModeToGL(Graphics::SamplerFilter filterMode);
46
47   static GLint FilterModeToGL(Graphics::SamplerFilter filterMode, Graphics::SamplerMipmapMode mipmapMode);
48
49   /**
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
54    */
55   static GLint WrapModeToGL(Graphics::SamplerAddressMode wrapMode);
56
57   static uint32_t GetTexParamHash(TestGlAbstraction& glAbstraction, GLuint target, GLenum pname);
58
59 public:
60   static std::map<uint32_t, GLint> mParamCache;
61
62   TestGlAbstraction&          mGlAbstraction;
63   Graphics::SamplerCreateInfo mCreateInfo;
64 };
65
66 } // namespace Dali
67
68 #endif //DALI_TEST_GRAPHICS_SAMPLER_H