a694eebb40d31ea872f22e0e84cb44f45b48a24a
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / test-gl-abstraction.cpp
1 /*
2  * Copyright (c) 2020 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 {
24   Initialize();
25 }
26
27 TestGlAbstraction::~TestGlAbstraction()
28 {
29 }
30
31 void TestGlAbstraction::Initialize()
32 {
33   mCurrentProgram                  = 0;
34   mCompileStatus                   = GL_TRUE;
35   mLinkStatus                      = GL_TRUE;
36   mNumberOfActiveUniforms          = 0;
37   mGetAttribLocationResult         = 0;
38   mGetErrorResult                  = 0;
39   mGetStringResult                 = NULL;
40   mIsBufferResult                  = 0;
41   mIsEnabledResult                 = 0;
42   mIsFramebufferResult             = 0;
43   mIsProgramResult                 = 0;
44   mIsRenderbufferResult            = 0;
45   mIsShaderResult                  = 0;
46   mIsTextureResult                 = 0;
47   mActiveTextureUnit               = 0;
48   mCheckFramebufferStatusResult    = 0;
49   mFramebufferStatus               = 0;
50   mFramebufferDepthAttached        = 0;
51   mFramebufferStencilAttached      = 0;
52   mFramebufferColorAttachmentCount = 0;
53   mFrameBufferColorStatus          = 0;
54   mNumBinaryFormats                = 0;
55   mBinaryFormats                   = 0;
56   mProgramBinaryLength             = 0;
57
58   mVertexAttribArrayChanged = false;
59   mGetProgramBinaryCalled   = false;
60
61   mLastShaderCompiled = 0;
62   mLastClearBitMask   = 0;
63   mLastClearColor     = Color::TRANSPARENT;
64   mClearCount         = 0;
65
66   mLastBlendEquationRgb   = 0;
67   mLastBlendEquationAlpha = 0;
68   mLastBlendFuncSrcRgb    = 0;
69   mLastBlendFuncDstRgb    = 0;
70   mLastBlendFuncSrcAlpha  = 0;
71   mLastBlendFuncDstAlpha  = 0;
72   mLastAutoTextureIdUsed  = 0;
73   mNumGeneratedTextures   = 0;
74   mLastShaderIdUsed       = 0;
75   mLastProgramIdUsed      = 0;
76   mLastUniformIdUsed      = 0;
77   mLastDepthMask          = false;
78
79   mUniforms.clear();
80   mProgramUniforms1i.clear();
81   mProgramUniforms1f.clear();
82   mProgramUniforms2f.clear();
83   mProgramUniforms3f.clear();
84   mProgramUniforms4f.clear();
85
86   mCullFaceTrace.Reset();
87   mDepthFunctionTrace.Reset();
88   mEnableDisableTrace.Reset();
89   mShaderTrace.Reset();
90   mStencilFunctionTrace.Reset();
91   mScissorTrace.Reset();
92   mTextureTrace.Reset();
93   mTexParamaterTrace.Reset();
94   mDrawTrace.Reset();
95
96   for(unsigned int i = 0; i < MAX_ATTRIBUTE_CACHE_SIZE; ++i)
97   {
98     mVertexAttribArrayState[i] = false;
99   }
100 }
101
102 void TestGlAbstraction::PreRender()
103 {
104 }
105
106 void TestGlAbstraction::PostRender()
107 {
108 }
109
110 bool TestGlAbstraction::IsSurfacelessContextSupported() const
111 {
112   return true;
113 }
114
115 bool TestGlAbstraction::TextureRequiresConverting(const GLenum imageGlFormat, const GLenum textureGlFormat, const bool isSubImage) const
116 {
117   return ((imageGlFormat == GL_RGB) && (textureGlFormat == GL_RGBA));
118 }
119
120 } // namespace Dali
121
122 bool BlendEnabled(const Dali::TraceCallStack& callStack)
123 {
124   std::stringstream out;
125   out << GL_BLEND;
126   bool blendEnabled = callStack.FindMethodAndParams("Enable", out.str());
127   return blendEnabled;
128 }
129
130 bool BlendDisabled(const Dali::TraceCallStack& callStack)
131 {
132   std::stringstream out;
133   out << GL_BLEND;
134   bool blendEnabled = callStack.FindMethodAndParams("Disable", out.str());
135   return blendEnabled;
136 }