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