1 /*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "platform/common/rs_innovation.h"
17
18 #include <dlfcn.h>
19 #include <parameters.h>
20
21 namespace OHOS {
22 namespace Rosen {
OpenInnovationSo()23 void RSInnovation::OpenInnovationSo()
24 {
25 innovationHandle = dlopen("libgraphic_innovation.z.so", RTLD_NOW);
26 GetParallelCompositionFunc();
27 }
28
CloseInnovationSo()29 void RSInnovation::CloseInnovationSo()
30 {
31 if (innovationHandle) {
32 ResetParallelCompositionFunc();
33 dlclose(innovationHandle);
34 }
35 }
36
37 // parallel composition
GetParallelCompositionEnabled(bool isUniRender)38 bool RSInnovation::GetParallelCompositionEnabled(bool isUniRender)
39 {
40 static bool parallelcompositionEnabled =
41 std::atoi((system::GetParameter("persist.rosen.parallelcomposition.enabled", "0")).c_str()) != 0;
42 if (isUniRender) {
43 return parallelcompositionEnabled;
44 }
45 return _s_parallelCompositionLoaded && parallelcompositionEnabled;
46 }
47
GetParallelCompositionFunc()48 void RSInnovation::GetParallelCompositionFunc()
49 {
50 if (innovationHandle) {
51 _s_createParallelSyncSignal = dlsym(innovationHandle, "CreateParallelSyncSignal");
52 _s_signalCountDown = dlsym(innovationHandle, "SignalCountDown");
53 _s_signalAwait = dlsym(innovationHandle, "SignalAwait");
54 _s_assignTask = dlsym(innovationHandle, "AssignTask");
55 _s_removeStoppedThreads = dlsym(innovationHandle, "RemoveStoppedThreads");
56 _s_checkForSerialForced = dlsym(innovationHandle, "CheckForSerialForced");
57 _s_parallelCompositionLoaded =
58 (_s_createParallelSyncSignal != nullptr) &&
59 (_s_signalCountDown != nullptr) &&
60 (_s_signalAwait != nullptr) &&
61 (_s_assignTask != nullptr) &&
62 (_s_removeStoppedThreads != nullptr) &&
63 (_s_checkForSerialForced != nullptr);
64 }
65 }
66
ResetParallelCompositionFunc()67 void RSInnovation::ResetParallelCompositionFunc()
68 {
69 if (_s_parallelCompositionLoaded) {
70 _s_parallelCompositionLoaded = false;
71 _s_createParallelSyncSignal = nullptr;
72 _s_signalCountDown = nullptr;
73 _s_signalAwait = nullptr;
74 _s_assignTask = nullptr;
75 _s_removeStoppedThreads = nullptr;
76 _s_checkForSerialForced = nullptr;
77 }
78 }
79 } // namespace Rosen
80 } // namespace OHOS
81