2 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include <dali/integration-api/adaptor-framework/shader-precompiler.h>
21 #include <dali/integration-api/debug.h>
25 std::unique_ptr<ShaderPreCompiler> ShaderPreCompiler::mInstance = nullptr;
26 std::once_flag ShaderPreCompiler::mOnceFlag;
28 ShaderPreCompiler::ShaderPreCompiler()
35 ShaderPreCompiler& ShaderPreCompiler::Get()
37 std::call_once(mOnceFlag, []()
38 { mInstance.reset(new ShaderPreCompiler); });
40 return *(mInstance.get());
43 void ShaderPreCompiler::AddPreCompiledProgram(Graphics::UniquePtr<Dali::Graphics::Program> program)
45 mProgram.push_back(move(program));
48 void ShaderPreCompiler::GetPreCompileShaderList(std::vector<RawShaderData>& shaderList)
51 shaderList = mRawShaderList;
54 void ShaderPreCompiler::SavePreCompileShaderList(std::vector<RawShaderData>& shaderList)
56 mRawShaderList = shaderList;
61 bool ShaderPreCompiler::IsReady() const
66 void ShaderPreCompiler::Enable()
71 bool ShaderPreCompiler::IsEnable()
76 void ShaderPreCompiler::Wait()
78 ConditionalWait::ScopedLock lock(mConditionalWait);
80 Dali::Mutex::ScopedLock mutexLock(mMutex);
87 mConditionalWait.Wait(lock);
90 void ShaderPreCompiler::Awake()
92 ConditionalWait::ScopedLock lock(mConditionalWait);
93 Dali::Mutex::ScopedLock mutexLock(mMutex);
95 mConditionalWait.Notify(lock);