Fixed SVACE errors in Test Graphics
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / test-graphics-texture.h
1 #ifndef DALI_TEST_GRAPHICS_TEXTURE_H
2 #define DALI_TEST_GRAPHICS_TEXTURE_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-texture-create-info.h>
21 #include <dali/graphics-api/graphics-texture.h>
22 #include <dali/graphics-api/graphics-types.h>
23 #include <dali/integration-api/gl-defines.h>
24 #include "test-gl-abstraction.h"
25 #include "test-graphics-sampler.h"
26
27 namespace Dali
28 {
29 class TestGraphicsTexture : public Graphics::Texture
30 {
31 public:
32   TestGraphicsTexture(TestGlAbstraction& glAbstraction, const Graphics::TextureCreateInfo& createInfo);
33
34   ~TestGraphicsTexture();
35
36   /**
37    * Initialize the texture: allocate gl mem, apply default samplers
38    */
39   void Initialize(GLuint target);
40
41   /**
42    * Ensure native resource is created, bound and targeted.
43    */
44   void InitializeNativeImage(GLuint target);
45
46   /**
47    * Get the GL target of this texture
48    */
49   GLuint GetTarget();
50
51   /**
52    * Get the texture type
53    */
54   Graphics::TextureType GetType()
55   {
56     return mCreateInfo.textureType;
57   }
58
59   /**
60    * Get the texture format
61    */
62   Graphics::Format GetFormat()
63   {
64     return mCreateInfo.format;
65   }
66
67   /**
68    * Bind this texture, ensure Native image is initialized if necessary.
69    */
70   void Bind(uint32_t textureUnit);
71
72   /**
73    * Prepare ensures that the native texture is updated if necessary (SourceChanged)
74    */
75   void Prepare();
76
77   /**
78    * Writes actual texture data to GL.
79    */
80   void Update(Graphics::TextureUpdateInfo updateInfo, Graphics::TextureUpdateSourceInfo source);
81
82   GLuint                      mId{0};
83   TestGlAbstraction&          mGlAbstraction;
84   Graphics::TextureCreateInfo mCreateInfo;
85   bool                        mIsCompressed{false};
86   GLint                       mGlInternalFormat; ///< The gl internal format of the pixel data
87   GLenum                      mGlFormat;         ///< The gl format of the pixel data
88   GLenum                      mPixelDataType;    ///< The data type of the pixel data
89 };
90
91 } // namespace Dali
92
93 #endif //DALI_TEST_GRAPHICS_TEXTURE_H