• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 
17 #include "config/DrawingConfig.h"
18 #ifdef DRAWING_DISABLE_API
19 #include <string>
20 #include <vector>
21 #include "base/startup/init/interfaces/innerkits/include/syspara/parameters.h"
22 #include "utils/log.h"
23 
24 namespace OHOS {
25 namespace Rosen {
26 namespace Drawing {
27 int flagCount = static_cast<int>(DrawingConfig::DrawingDisableFlag::COUNT);
28 std::mutex DrawingConfig::mutex;
29 std::vector<bool> gDrawingDisableFlags(flagCount, false);
30 
31 std::vector<std::string> gDrawingDisableFlagStr = {
32     "disablePoint",
33     "disableTextBlob",
34     "disableImage",
35     "disableRect",
36     "disableRRect",
37     "disableOval",
38     "disableArc",
39     "disablePath",
40     "disablePicture",
41     "disableImageRect",
42     "disableImageLattice",
43     "disableSdf",
44     "disableLine",
45     "disableNestedRRect",
46     "disablePie",
47     "disableCircle",
48     "disableBackground",
49     "disableShadow",
50     "disableShadowStyle",
51     "disableColor",
52     "disableRegion",
53     "disablePatch",
54     "disableVertices",
55     "disableAtlas",
56     "disableBitmap",
57     "disableImageNine",
58     "disableSVGDOM",
59     "disableSymbol",
60     "disableClipRect",
61     "disableClipIRect",
62     "disableClipRRect",
63     "disableClipPath",
64     "disableClipRegion",
65     "disableBlurImage",
66     "disableColorFilter",
67     "disableImageFilter",
68     "disableMaskFilter",
69     "disableShader",
70     "disableBlender",
71     "disablePathEffect"
72 };
73 
UpdateDrawingProperties()74 void DrawingConfig::UpdateDrawingProperties()
75 {
76     std::lock_guard<std::mutex> lock(mutex);
77     if (flagCount != static_cast<int>(gDrawingDisableFlagStr.size())) {
78         LOGE("The number of gDrawingDisableFlagStr and DrawingDisableFlag is inconsistent");
79         return;
80     }
81 
82     for (int i = 0; i < flagCount; i++) {
83         std::string key = "drawing." + gDrawingDisableFlagStr[i];
84         gDrawingDisableFlags[i] = OHOS::system::GetBoolParameter(key, false);
85     }
86 }
87 
IsDisabled(DrawingDisableFlag flag)88 bool DrawingConfig::IsDisabled(DrawingDisableFlag flag)
89 {
90     std::lock_guard<std::mutex> lock(mutex);
91     return gDrawingDisableFlags[static_cast<int>(flag)];
92 }
93 }
94 }
95 }
96 #endif
97