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-gl-abstraction.cpp
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include "test-gl-abstraction.h"
19 #include "test-trace-call-stack.h"
20
21 namespace Dali
22 {
23 TestGlAbstraction::TestGlAbstraction()
24 : mBufferTrace(true, std::string("gl")),
25   mCullFaceTrace(true, "gl"),
26   mEnableDisableTrace(true, "gl"),
27   mShaderTrace(true, "gl"),
28   mTextureTrace(true, std::string("gl")),
29   mTexParameterTrace(true, "gl"),
30   mDrawTrace(true, "gl"),
31   mDepthFunctionTrace(true, "gl"),
32   mStencilFunctionTrace(true, "gl"),
33   mScissorTrace(true, "gl"),
34   mSetUniformTrace(true, "Uniform "),
35   mViewportTrace(true, "gl")
36 {
37   Initialize();
38 }
39
40 TestGlAbstraction::~TestGlAbstraction()
41 {
42 }
43
44 void TestGlAbstraction::Initialize()
45 {
46   mCurrentProgram                  = 0;
47   mCompileStatus                   = GL_TRUE;
48   mLinkStatus                      = GL_TRUE;
49   mNumberOfActiveUniforms          = 0;
50   mGetErrorResult                  = 0;
51   mGetStringResult                 = NULL;
52   mIsBufferResult                  = 0;
53   mIsEnabledResult                 = 0;
54   mIsFramebufferResult             = 0;
55   mIsProgramResult                 = 0;
56   mIsRenderbufferResult            = 0;
57   mIsShaderResult                  = 0;
58   mIsTextureResult                 = 0;
59   mActiveTextureUnit               = 0;
60   mCheckFramebufferStatusResult    = 0;
61   mFramebufferStatus               = 0;
62   mFramebufferDepthAttached        = 0;
63   mFramebufferStencilAttached      = 0;
64   mFramebufferColorAttachmentCount = 0;
65   mFrameBufferColorStatus          = 0;
66   mNumBinaryFormats                = 0;
67   mBinaryFormats                   = 0;
68   mProgramBinaryLength             = 0;
69
70   mVertexAttribArrayChanged = false;
71   mGetProgramBinaryCalled   = false;
72
73   mLastShaderCompiled = 0;
74   mLastClearBitMask   = 0;
75   mLastClearColor     = Color::TRANSPARENT;
76   mClearCount         = 0;
77
78   mLastBlendEquationRgb   = 0;
79   mLastBlendEquationAlpha = 0;
80   mLastBlendFuncSrcRgb    = 0;
81   mLastBlendFuncDstRgb    = 0;
82   mLastBlendFuncSrcAlpha  = 0;
83   mLastBlendFuncDstAlpha  = 0;
84   mLastAutoTextureIdUsed  = 0;
85   mNumGeneratedTextures   = 0;
86   mLastShaderIdUsed       = 0;
87   mLastProgramIdUsed      = 0;
88   mLastUniformIdUsed      = 0;
89   mLastDepthMask          = false;
90
91   mUniforms.clear();
92   mProgramUniforms1i.clear();
93   mProgramUniforms1f.clear();
94   mProgramUniforms2f.clear();
95   mProgramUniforms3f.clear();
96   mProgramUniforms4f.clear();
97
98   mAttribLocs.clear();
99   mAttribLocs.push_back("aPosition");
100   mAttribLocs.push_back("aTexCoord");
101   mCullFaceTrace.Reset();
102   mDepthFunctionTrace.Reset();
103   mEnableDisableTrace.Reset();
104   mShaderTrace.Reset();
105   mStencilFunctionTrace.Reset();
106   mScissorTrace.Reset();
107   mTextureTrace.Reset();
108   mTexParameterTrace.Reset();
109   mDrawTrace.Reset();
110
111   for(unsigned int i = 0; i < MAX_ATTRIBUTE_CACHE_SIZE; ++i)
112   {
113     mVertexAttribArrayState[i] = false;
114   }
115 }
116
117 void TestGlAbstraction::PreRender()
118 {
119 }
120
121 void TestGlAbstraction::PostRender()
122 {
123 }
124
125 bool TestGlAbstraction::IsSurfacelessContextSupported() const
126 {
127   return true;
128 }
129
130 bool TestGlAbstraction::IsAdvancedBlendEquationSupported()
131 {
132   return true;
133 }
134
135 bool TestGlAbstraction::IsBlendEquationSupported(DevelBlendEquation::Type blendEquation)
136 {
137   return true;
138 }
139
140 std::string TestGlAbstraction::GetShaderVersionPrefix()
141 {
142   return std::string("");
143 }
144
145 std::string TestGlAbstraction::GetVertexShaderPrefix()
146 {
147   return std::string("");
148 }
149
150 std::string TestGlAbstraction::GetFragmentShaderPrefix()
151 {
152   return std::string("");
153 }
154
155 bool TestGlAbstraction::TextureRequiresConverting(const GLenum imageGlFormat, const GLenum textureGlFormat, const bool isSubImage) const
156 {
157   return ((imageGlFormat == GL_RGB) && (textureGlFormat == GL_RGBA));
158 }
159
160 } // namespace Dali
161
162 bool BlendEnabled(const Dali::TraceCallStack& callStack)
163 {
164   std::stringstream out;
165   out << GL_BLEND;
166   bool blendEnabled = callStack.FindMethodAndParams("Enable", out.str());
167   return blendEnabled;
168 }
169
170 bool BlendDisabled(const Dali::TraceCallStack& callStack)
171 {
172   std::stringstream out;
173   out << GL_BLEND;
174   bool blendEnabled = callStack.FindMethodAndParams("Disable", out.str());
175   return blendEnabled;
176 }