Updated test files to match dali-core Pipeline VtxFmt
[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
20 namespace Dali
21 {
22 TestGlAbstraction::TestGlAbstraction()
23 : mBufferTrace(true, "gl"),
24   mTextureTrace(true, "gl"),
25   mTexParameterTrace(true, "gl"),
26   mDrawTrace(true, "gl")
27 {
28   Initialize();
29 }
30
31 TestGlAbstraction::~TestGlAbstraction()
32 {
33 }
34
35 void TestGlAbstraction::Initialize()
36 {
37   mCurrentProgram                  = 0;
38   mCompileStatus                   = GL_TRUE;
39   mLinkStatus                      = GL_TRUE;
40   mNumberOfActiveUniforms          = 0;
41   mGetErrorResult                  = 0;
42   mGetStringResult                 = NULL;
43   mIsBufferResult                  = 0;
44   mIsEnabledResult                 = 0;
45   mIsFramebufferResult             = 0;
46   mIsProgramResult                 = 0;
47   mIsRenderbufferResult            = 0;
48   mIsShaderResult                  = 0;
49   mIsTextureResult                 = 0;
50   mActiveTextureUnit               = 0;
51   mCheckFramebufferStatusResult    = 0;
52   mFramebufferStatus               = 0;
53   mFramebufferDepthAttached        = 0;
54   mFramebufferStencilAttached      = 0;
55   mFramebufferColorAttachmentCount = 0;
56   mFrameBufferColorStatus          = 0;
57   mNumBinaryFormats                = 0;
58   mBinaryFormats                   = 0;
59   mProgramBinaryLength             = 0;
60
61   mVertexAttribArrayChanged = false;
62   mGetProgramBinaryCalled   = false;
63
64   mLastShaderCompiled = 0;
65   mLastClearBitMask   = 0;
66   mLastClearColor     = Color::TRANSPARENT;
67   mClearCount         = 0;
68
69   mLastBlendEquationRgb   = 0;
70   mLastBlendEquationAlpha = 0;
71   mLastBlendFuncSrcRgb    = 0;
72   mLastBlendFuncDstRgb    = 0;
73   mLastBlendFuncSrcAlpha  = 0;
74   mLastBlendFuncDstAlpha  = 0;
75   mLastAutoTextureIdUsed  = 0;
76   mNumGeneratedTextures   = 0;
77   mLastShaderIdUsed       = 0;
78   mLastProgramIdUsed      = 0;
79   mLastUniformIdUsed      = 0;
80   mLastDepthMask          = false;
81
82   mUniforms.clear();
83   mProgramUniforms1i.clear();
84   mProgramUniforms1f.clear();
85   mProgramUniforms2f.clear();
86   mProgramUniforms3f.clear();
87   mProgramUniforms4f.clear();
88
89   mAttribLocs.clear();
90   mAttribLocs.push_back("aPosition");
91   mAttribLocs.push_back("aTexCoord");
92   mCullFaceTrace.Reset();
93   mDepthFunctionTrace.Reset();
94   mEnableDisableTrace.Reset();
95   mShaderTrace.Reset();
96   mStencilFunctionTrace.Reset();
97   mScissorTrace.Reset();
98   mTextureTrace.Reset();
99   mTexParameterTrace.Reset();
100   mDrawTrace.Reset();
101
102   for(unsigned int i = 0; i < MAX_ATTRIBUTE_CACHE_SIZE; ++i)
103   {
104     mVertexAttribArrayState[i] = false;
105   }
106 }
107
108 void TestGlAbstraction::PreRender()
109 {
110 }
111
112 void TestGlAbstraction::PostRender()
113 {
114 }
115
116 bool TestGlAbstraction::IsSurfacelessContextSupported() const
117 {
118   return true;
119 }
120
121 bool TestGlAbstraction::IsAdvancedBlendEquationSupported()
122 {
123   return true;
124 }
125
126 bool TestGlAbstraction::IsBlendEquationSupported(DevelBlendEquation::Type blendEquation)
127 {
128   return true;
129 }
130
131 std::string TestGlAbstraction::GetShaderVersionPrefix()
132 {
133   return std::string("");
134 }
135
136 std::string TestGlAbstraction::GetVertexShaderPrefix()
137 {
138   return std::string("");
139 }
140
141 std::string TestGlAbstraction::GetFragmentShaderPrefix()
142 {
143   return std::string("");
144 }
145
146 bool TestGlAbstraction::TextureRequiresConverting(const GLenum imageGlFormat, const GLenum textureGlFormat, const bool isSubImage) const
147 {
148   return ((imageGlFormat == GL_RGB) && (textureGlFormat == GL_RGBA));
149 }
150
151 } // namespace Dali
152
153 bool BlendEnabled(const Dali::TraceCallStack& callStack)
154 {
155   std::stringstream out;
156   out << GL_BLEND;
157   bool blendEnabled = callStack.FindMethodAndParams("Enable", out.str());
158   return blendEnabled;
159 }
160
161 bool BlendDisabled(const Dali::TraceCallStack& callStack)
162 {
163   std::stringstream out;
164   out << GL_BLEND;
165   bool blendEnabled = callStack.FindMethodAndParams("Disable", out.str());
166   return blendEnabled;
167 }